2017-03-30 18:11:38 +02:00
# Contribution guide
2021-09-20 16:24:07 +02:00
We're glad you're interested in contributing Misskey! In this document you will find the information you need to contribute to the project.
2017-03-26 14:32:19 +02:00
2021-09-20 16:24:07 +02:00
**ℹ ️ Important:** This project uses Japanese as its major language, **but you do not need to translate and write the Issues/PRs in Japanese.**
Also, you might receive comments on your Issue/PR in Japanese, but you do not need to reply to them in Japanese as well.\
The accuracy of translation into Japanese is not high, so it will be easier for us to understand if you write it in the original language.
It will also allow the reader to use the translation tool of their preference if necessary.
2021-08-28 08:42:27 +02:00
2018-09-01 11:02:04 +02:00
## Issues
2021-09-20 16:24:07 +02:00
Before creating an issue, please check the following:
- To avoid duplication, please search for similar issues before creating a new issue.
- Do not use Issues as a question.
- Issues should only be used to feature requests, suggestions, and report problems.
- Please ask questions in the [Misskey Forum ](https://forum.misskey.io/ ) or [Discord ](https://discord.gg/Wp8gVStHW3 ).
## Before implementation
When you want to add a feature or fix a bug, first have the design and policy reviewed in an Issue (if it is not there, please make one). Without this step, there is a high possibility that the PR will not be merged even if it is implemented.
Also, when you start implementation, assign yourself to the Issue (if you cannot do it yourself, ask another member to assign you). By expressing your intention to work the Issue, you can prevent conflicts in the work.
## Well-known branches
2021-08-30 13:11:22 +02:00
- **`master`** branch is tracking the latest release and used for production purposes.
- **`develop`** branch is where we work for the next release.
2021-09-20 16:24:07 +02:00
- When you create a PR, basically target it to this branch.
2021-08-30 13:11:22 +02:00
- **`l10n_develop`** branch is reserved for localization management.
2019-07-22 07:57:23 +02:00
2021-09-20 16:24:07 +02:00
## Creating a PR
Thank you for your PR! Before creating a PR, please check the following:
- If possible, prefix the title with a keyword that identifies the type of this PR, as shown below.
- `fix` / `refactor` / `feat` / `enhance` / `perf` / `chore` etc
- Also, make sure that the granularity of this PR is appropriate. Please do not include more than one type of change or interest in a single PR.
- If there is an Issue which will be resolved by this PR, please include a reference to the Issue in the text.
- Please add the summary of the changes to [`CHANGELOG.md` ](/CHANGELOG.md ). However, this is not necessary for changes that do not affect the users, such as refactoring.
- Check if there are any documents that need to be created or updated due to this change.
- If you have added a feature or fixed a bug, please add a test case if possible.
- Please make sure that tests and Lint are passed in advance.
- You can run it with `npm run test` and `npm run lint` . [See more info ](#testing )
- If this PR includes UI changes, please attach a screenshot in the text.
Thanks for your cooperation 🤗
2018-09-01 11:02:04 +02:00
## Localization (l10n)
2019-05-24 12:31:40 +02:00
Misskey uses [Crowdin ](https://crowdin.com/project/misskey ) for localization management.
You can improve our translations with your Crowdin account.
2019-07-22 07:57:23 +02:00
Your changes in Crowdin are automatically submitted as a PR (with the title "New Crowdin translations") to the repository.
The owner [@syuilo ](https://github.com/syuilo ) merges the PR into the develop branch before the next release.
2019-05-24 12:31:40 +02:00
2019-07-22 07:57:23 +02:00
If your language is not listed in Crowdin, please open an issue.
2017-03-26 14:32:19 +02:00
2018-09-01 11:15:25 +02:00
![Crowdin ](https://d322cqt584bo4o.cloudfront.net/misskey/localized.svg )
2017-03-26 14:32:19 +02:00
2018-09-01 11:02:04 +02:00
## Documentation
2019-05-26 05:48:37 +02:00
* Documents for instance admins are located in [`/docs` ](/docs ).
* Documents for end users are located in [`/src/docs` ](/src/docs ).
2017-03-26 14:32:19 +02:00
2021-08-30 13:11:22 +02:00
## Testing
- Test codes are located in [`/test` ](/test ).
2018-09-01 11:02:04 +02:00
2021-08-30 13:11:22 +02:00
### Run test
```
npm run test
```
#### Run specify test
2021-08-19 04:26:26 +02:00
```
npx cross-env TS_NODE_FILES=true TS_NODE_TRANSPILE_ONLY=true TS_NODE_PROJECT="./test/tsconfig.json" npx mocha test/foo.ts --require ts-node/register
```
2021-08-30 13:11:22 +02:00
### e2e tests
TODO
2018-09-01 11:02:04 +02:00
## Continuous integration
2021-06-11 05:19:48 +02:00
Misskey uses GitHub Actions for executing automated tests.
Configuration files are located in [`/.github/workflows` ](/.github/workflows ).
2018-12-19 19:01:02 +01:00
2019-08-18 07:41:33 +02:00
## Adding MisskeyRoom items
2019-08-20 09:16:27 +02:00
* Use English for material, object and texture names.
* Use meter for unit of length.
* Your PR should include all source files (e.g. `.png` , `.blend` ) of your models (for later editing).
* Your PR must include the glTF binary files (`.glb`) of your models.
* Add a locale key `room.furnitures.YOUR_ITEM` at [`/locales/ja-JP.yml` ](/locales/ja-JP.yml ).
2021-04-29 04:18:08 +02:00
* Add a furniture definition at [`src/client/scripts/room/furnitures.json5` ](src/client/scripts/room/furnitures.json5 ).
2019-08-18 07:41:33 +02:00
2019-08-18 16:40:52 +02:00
If you have no experience on 3D modeling, we suggest to use the free 3DCG software [Blender ](https://www.blender.org/ ).
2019-08-18 07:41:33 +02:00
You can find information on glTF 2.0 at [glTF 2.0 — Blender Manual ]( https://docs.blender.org/manual/en/dev/addons/io_scene_gltf2.html ).
2021-08-30 13:00:31 +02:00
## Notes
2019-07-15 13:47:09 +02:00
### How to resolve conflictions occurred at yarn.lock?
2019-07-15 14:32:09 +02:00
Just execute `yarn` to fix it.
2019-07-14 03:05:19 +02:00
2019-04-07 14:50:36 +02:00
### placeholder
SQLをクエリビルダで組み立てる際、使用するプレースホルダは重複してはならない
例えば
``` ts
query.andWhere(new Brackets(qb => {
for (const type of ps.fileType) {
qb.orWhere(`:type = ANY(note.attachedFileTypes)`, { type: type });
}
}));
```
と書くと、ループ中で`type`というプレースホルダが複数回使われてしまいおかしくなる
だから次のようにする必要がある
```ts
query.andWhere(new Brackets(qb => {
for (const type of ps.fileType) {
const i = ps.fileType.indexOf(type);
qb.orWhere(`:type${i} = ANY(note.attachedFileTypes)`, { [`type${i}`]: type });
}
}));
```
2019-05-20 14:44:16 +02:00
### Not `null` in TypeORM
```ts
const foo = await Foos.findOne({
bar: Not(null)
});
```
のようなクエリ(`bar`が`null`ではない)は期待通りに動作しない。
次のようにします:
```ts
const foo = await Foos.findOne({
bar: Not(IsNull())
});
```
2019-04-07 14:50:36 +02:00
### `null` in SQL
SQLを発行する際、パラメータが`null`になる可能性のある場合はSQL文を出し分けなければならない
例えば
``` ts
query.where('file.folderId = :folderId', { folderId: ps.folderId });
```
という処理で、`ps.folderId`が`null`だと結果的に`file.folderId = null`のようなクエリが発行されてしまい、これは正しいSQLではないので期待した結果が得られない
だから次のようにする必要がある
``` ts
if (ps.folderId) {
query.where('file.folderId = :folderId', { folderId: ps.folderId });
} else {
query.where('file.folderId IS NULL');
}
```
### `[]` in SQL
SQLを発行する際、`IN`のパラメータが`[]`(空の配列)になる可能性のある場合はSQL文を出し分けなければならない
例えば
``` ts
const users = await Users.find({
id: In(userIds)
});
```
という処理で、`userIds`が`[]`だと結果的に`user.id IN ()`のようなクエリが発行されてしまい、これは正しいSQLではないので期待した結果が得られない
だから次のようにする必要がある
``` ts
const users = userIds.length > 0 ? await Users.find({
id: In(userIds)
}) : [];
```
2019-04-13 07:04:29 +02:00
### 配列のインデックス in SQL
SQLでは配列のインデックスは**1始まり**。
`[a, b, c]` の `a` にアクセスしたいなら`[0]`ではなく`[1]`と書く
2019-04-07 14:50:36 +02:00
### `undefined`にご用心
MongoDBの時とは違い、findOneでレコードを取得する時に対象レコードが存在しない場合 ** `undefined` ** が返ってくるので注意。
MongoDBは`null`で返してきてたので、その感覚で`if (x === null)`とか書くとバグる。代わりに`if (x == null)`と書いてください
2019-04-13 07:31:05 +02:00
2019-05-13 19:57:04 +02:00
### Migration作成方法
```
2019-07-06 22:26:04 +02:00
npx ts-node ./node_modules/typeorm/cli.js migration:generate -n 変更の名前
2019-05-13 19:57:04 +02:00
```
作成されたスクリプトは不必要な変更を含むため除去してください。
2019-09-08 14:21:08 +02:00
2021-07-26 04:12:06 +02:00
### コネクションには`markRaw`せよ
**Vueのコンポーネントのdataオプションとして**misskey.jsのコネクションを設定するとき、必ず`markRaw`でラップしてください。インスタンスが不必要にリアクティブ化されることで、misskey.js内の処理で不具合が発生するとともに、パフォーマンス上の問題にも繋がる。なお、Composition APIを使う場合はこの限りではない(リアクティブ化はマニュアルなため)。
2021-08-20 14:34:56 +02:00
### JSONのimportに気を付けよう
TypeScriptでjsonをimportすると、tscでコンパイルするときにそのjsonファイルも一緒にdistディレクトリに吐き出されてしまう。この挙動により、意図せずファイルの書き換えが発生することがあるので、jsonをimportするときは書き換えられても良いものかどうか確認すること。書き換えされて欲しくない場合は、importで読み込むのではなく、`fs.readFileSync`などの関数を使って読み込むようにすればよい。
2019-09-08 14:21:08 +02:00
## その他
### HTMLのクラス名で follow という単語は使わない
広告ブロッカーで誤ってブロックされる