firefish/CONTRIBUTING.md
syuilo 45b972c059
MisskeyRoom (#5267)
* wip

* Add pemcil

* Fix bug

* Update .gitattributes

* Add 🍮

* Better 🍮

* Add color boxes

* Add pc

* Add keyboard

* Add 📦

* Add more 📦

* ✌️

* carpet

* Add plant

* ✌️

* ✌️

* Update room.vue

* Add plant

* ✌️

* ✌️

* ✌️

* ✌️

* ✌️

* 段ボール箱がてかりすぎているのを修正

* Update room.ts

* Render username

* ✌️

* Add new 📦

* Update room.ts

* Remove blender backup files

* Refactor

* Improve performance

* Update room.ts

* Update .gitattributes

* Update room.ts

* Better fan

* Better tissue rendering

* Add 🐧

* Create photoframe2.glb

* chairs

* Add 📖

* fix: HiDPi環境でオブジェクトを選択できない (#5268)

* Better monitor

* ✌️

* Add corkboard

* Add missing blend

* mousepad

* Add missing blend

* Add cube

* 額縁やモニターなどに任意の画像を表示できるように

* Update MisskeyRoom section of CONTRIBUTING.md (#5272)

* Update MisskeyRoom section of CONTRIBUTING.md

* Update CONTRIBUTING.md

* Update CONTRIBUTING.md

* Refactor

* カスタムテクスチャがずれないように

* Remove debug code

* Update furnitures.json5

* 一部の家具の色を自由に変えられるように

* Update ja-JP.yml

* Type annotation

* 家具の色やテクスチャをすぐ反映するように

* Update room.vue

* Update furnitures.json5

* Add 📺

* Update ja-JP.yml

* 床の色を変えられるように

* 和室にできるように

* Update washitsu

* Use MeshLambertMaterial to improve performance

* Use MeshLambertMaterial

* Fix bug

* Refactor

* Update room.ts

* Fix washitsu

* Update room.vue

* Update washistu

* Use MeshLambertMaterial

* Update room.ts

* Set current property value

* Disable reactivity to improve performance a bit

* Fix bug

* Set current carpet color

* Update ja-JP.yml

* Add rubik-cube (#5278)

* Update ja-JP.yml (#5279)

* Update UI

* ルームの設定を追加

* Add room link

* 家具をドラッグで移動や回転できるように

* esnextにする (#5286)

* Fix moduleResolution

* Use uuid v4

* Fix bug

* マットの色を変えられるように

* ✌️

* 異方性フィルタリングするように

* グラフィックの品質をフィルタリングに反映

* Add bloom effect when ultra graphics

* Add posters

* 🎨
2019-08-18 14:41:33 +09:00

8.3 KiB

Contribution guide

✌️ Thanks for your contributions ✌️

Issues

Feature suggestions and bug reports are filed in https://github.com/syuilo/misskey/issues .

  • Please search existing issues to avoid duplication. If your issue is already filed, please add your reaction or comment to the existing one.
  • If you have multiple independent issues, please submit them separately.

Branches

  • master branch is tracking the latest release and used for production purposes.
  • develop branch is where we work for the next release.
  • l10n_develop branch is reserved for localization management.

Localization (l10n)

Misskey uses Crowdin for localization management. You can improve our translations with your Crowdin account. Your changes in Crowdin are automatically submitted as a PR (with the title "New Crowdin translations") to the repository. The owner @syuilo merges the PR into the develop branch before the next release.

If your language is not listed in Crowdin, please open an issue.

Crowdin

Internationalization (i18n)

Misskey uses the Vue.js plugin Vue I18n. Documentation of Vue I18n is available at http://kazupon.github.io/vue-i18n/introduction.html .

Documentation

  • Documents for contributors are located in /docs.
  • Documents for instance admins are located in /docs.
  • Documents for end users are located in /src/docs.

Test

  • Test codes are located in /test.

Continuous integration

Misskey uses CircleCI for executing automated tests. Configuration files are located in /.circleci.

Adding MisskeyRoom items

Currently, we accept only 3D models created with Blender.

  • Use English for material, object and texture names
  • Use meter for unit of length
  • Your PR must include all source files of your models (for later editing)
  • Your PR must include the glTF binary files (.glb) of your models

You can find information on glTF 2.0 at glTF 2.0 — Blender Manual.

FAQ

How to resolve conflictions occurred at yarn.lock?

Just execute yarn to fix it.

Glossary

AP

Stands for ActivityPub.

MFM

Stands for Misskey Flavored Markdown.

Mk

Stands for Misskey.

SW

Stands for ServiceWorker.

Nyaize

Convert な(na) to にゃ(nya)

Denyaize

Revert Nyaize

TypeScript Coding Style

Do not omit semicolons

This is to avoid Automatic Semicolon Insertion (ASI) hazard.

Ref:

Do not omit curly brackets

Bad:

if (foo)
	bar;
else
	baz;

Good:

if (foo) {
	bar;
} else {
	baz;
}

As a special case, you can omit the curly brackets if

  • the body of the if-statement have only one statement and,
  • the if-statement does not have else-clause.

Good:

if (foo) bar;

Make sure that the condition and the body statement are on the same line.

Do not use == when it can simply be replaced with ===.

🥰

Bad:

if (foo.length)

Good:

if (foo.length > 0)

Do not use export default

This is because the current language support does not work well with export default.

Ref:

Bad:

export default function(foo: string): string {

Good:

export function something(foo: string): string {

Directory structure

src ... Source code
	@types ... Type definitions
	prelude ... Independence utils for coding JavaScript without side effects
	misc ... Independence utils for Misskey without side effects
	service ... Common functions with side effects
	queue ... Job queues and Jobs
	server ... Web Server
	client ... Client
	mfm ... MFM

test ... Test code

Notes

placeholder

SQLをクエリビルダで組み立てる際、使用するプレースホルダは重複してはならない 例えば

query.andWhere(new Brackets(qb => {
	for (const type of ps.fileType) {
		qb.orWhere(`:type = ANY(note.attachedFileTypes)`, { type: type });
	}
}));

と書くと、ループ中でtypeというプレースホルダが複数回使われてしまいおかしくなる だから次のようにする必要がある

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 });
	}
}));

Not null in TypeORM

const foo = await Foos.findOne({
	bar: Not(null)
});

のようなクエリ(barnullではない)は期待通りに動作しない。 次のようにします:

const foo = await Foos.findOne({
	bar: Not(IsNull())
});

null in SQL

SQLを発行する際、パラメータがnullになる可能性のある場合はSQL文を出し分けなければならない 例えば

query.where('file.folderId = :folderId', { folderId: ps.folderId });

という処理で、ps.folderIdnullだと結果的にfile.folderId = nullのようなクエリが発行されてしまい、これは正しいSQLではないので期待した結果が得られない だから次のようにする必要がある

if (ps.folderId) {
	query.where('file.folderId = :folderId', { folderId: ps.folderId });
} else {
	query.where('file.folderId IS NULL');
}

[] in SQL

SQLを発行する際、INのパラメータが[](空の配列)になる可能性のある場合はSQL文を出し分けなければならない 例えば

const users = await Users.find({
	id: In(userIds)
});

という処理で、userIds[]だと結果的にuser.id IN ()のようなクエリが発行されてしまい、これは正しいSQLではないので期待した結果が得られない だから次のようにする必要がある

const users = userIds.length > 0 ? await Users.find({
	id: In(userIds)
}) : [];

配列のインデックス in SQL

SQLでは配列のインデックスは1始まり[a, b, c]aにアクセスしたいなら[0]ではなく[1]と書く

undefinedにご用心

MongoDBの時とは違い、findOneでレコードを取得する時に対象レコードが存在しない場合 undefined が返ってくるので注意。 MongoDBはnullで返してきてたので、その感覚でif (x === null)とか書くとバグる。代わりにif (x == null)と書いてください

簡素なundefinedチェック

データベースからレコードを取得するときに、プログラムの流れ的に(ほぼ)絶対undefinedにはならない場合でも、undefinedチェックしないとTypeScriptに怒られます。 でもいちいち複数行を費やして、発生するはずのないundefinedをチェックするのも面倒なので、ensureというユーティリティ関数を用意しています。 例えば、

const user = await Users.findOne(userId);
// この時点で user の型は User | undefined
if (user == null) {
	throw 'missing user';
}
// この時点で user の型は User

という処理をensureを使うと

const user = await Users.findOne(userId).then(ensure);
// この時点で user の型は User

という風に書けます。 もちろんensure内部でエラーを握りつぶすようなことはしておらず、万が一undefinedだった場合はPromiseがRejectされ後続の処理は実行されません。

const user = await Users.findOne(userId).then(ensure);
// 万が一 Users.findOne の結果が undefined だったら、ensure でエラーが発生するので
// この行に到達することは無い
// なので、.then(ensure) は
// if (user == null) {
//	throw 'missing user';
// }
// の糖衣構文のような扱いです

Migration作成方法

npx ts-node ./node_modules/typeorm/cli.js migration:generate -n 変更の名前

作成されたスクリプトは不必要な変更を含むため除去してください。