Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions .github/workflows/api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,26 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Use pnpm
uses: pnpm/action-setup@v6

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version: 22.14.0

Comment thread
samunohito marked this conversation as resolved.
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-

- name: Install dependencies
run: npm ci
run: pnpm install --frozen-lockfile

- name: Build
run: npm run build
run: pnpm run build

- name: Check files
run: ls built

- name: API report
run: npm run api-prod
run: pnpm run api-prod

- name: Show report
if: always()
Expand Down
15 changes: 6 additions & 9 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,17 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Use pnpm
uses: pnpm/action-setup@v6

- name: Setup Node.js
uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version: 22.14.0

Comment thread
samunohito marked this conversation as resolved.
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-

- name: Install dependencies
run: npm ci
run: pnpm install --frozen-lockfile

- name: Lint
run: npm run lint
run: pnpm run lint
17 changes: 7 additions & 10 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,26 +18,23 @@ jobs:
- name: Checkout
uses: actions/checkout@v4

- name: Use pnpm
uses: pnpm/action-setup@v6

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
cache: 'pnpm'
node-version: ${{ matrix.node-version }}

Comment thread
samunohito marked this conversation as resolved.
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: npm-

- name: Install dependencies
run: npm ci
run: pnpm install --frozen-lockfile

- name: Build
run: npm run build
run: pnpm run build

- name: Test
run: npm test
run: pnpm run test
env:
CI: true

Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ PRを作成する前に、以下をご確認ください:
- この変更により新たに作成、もしくは更新すべきドキュメントがないか確認してください。
- 機能追加やバグ修正をした場合は、可能であればテストケースを追加してください。
- テスト、Lintが通っていることを予め確認してください。
- `npm run test`、`npm run lint`でぞれぞれ実施可能です
- `npm run api`を実行してAPIレポートを更新し、差分がある場合はコミットしてください。
- `pnpm run test`、`pnpm run lint`でそれぞれ実施可能です
- `pnpm run api`を実行してAPIレポートを更新し、差分がある場合はコミットしてください。
- APIレポートの詳細については[こちら](#api-extractor)

ご協力ありがとうございます🤗
Expand All @@ -43,24 +43,24 @@ CI上でも自動でチェックされ、ルールに則っていないコード
テストは[`/test`ディレクトリ](/test)に置かれます。

テストはCIにより各コミット/各PRに対して自動で実施されます。
ローカル環境でテストを実施するには、`npm run test`を実行してください。
ローカル環境でテストを実施するには、`pnpm run test`を実行してください。

### tsd
このプロジェクトでは型のテストを行うために[tsd](https://github.com/SamVerschueren/tsd)を導入しています。
Jestによるテストでは「型が期待したものか」というのはチェックすることができません。tsdを使うことで、型が意図したものであることを担保することができます。
tsdによる型テストは[`/test-d`ディレクトリ](/test-d)に置かれます。

テストはCIにより各コミット/各PRに対して自動で実施されます。
ローカル環境でテストを実施するには、`npm run test`を実行してください。
ローカル環境でテストを実施するには、`pnpm run test`を実行してください。

### API Extractor
このプロジェクトでは[API Extractor](https://api-extractor.com/)を導入しています。API ExtractorはAPIレポートを生成する役割を持ちます。
APIレポートはいわばAPIのスナップショットで、このライブラリが外部に公開(export)している各種関数や型の定義が含まれています。`npm run api`コマンドを実行すると、その時点でのレポートが[`/etc`ディレクトリ](/etc)に生成されるようになっています。
APIレポートはいわばAPIのスナップショットで、このライブラリが外部に公開(export)している各種関数や型の定義が含まれています。`pnpm run api`コマンドを実行すると、その時点でのレポートが[`/etc`ディレクトリ](/etc)に生成されるようになっています。

exportしているAPIに変更があると、当然生成されるレポートの内容も変わるので、例えばdevelopブランチで生成されたレポートとPRのブランチで生成されたレポートを比較することで、意図しない破壊的変更の検出や、破壊的変更の影響確認に用いることができます。
また、各コミットや各PRで実行されるCI内部では、都度APIレポートを生成して既存のレポートと差分が無いかチェックしています。もし差分があるとエラーになります。

PRを作る際は、`npm run api`コマンドを実行してAPIレポートを生成し、差分がある場合はコミットしてください。
PRを作る際は、`pnpm run api`コマンドを実行してAPIレポートを生成し、差分がある場合はコミットしてください。
レポートをコミットすることでその破壊的変更が意図したものであると示すことができるほか、上述したようにレポート間の差分が出ることで影響範囲をレビューしやすくなります。

### Codecov
Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,23 +48,25 @@ git clone https://github.com/misskey-dev/mfm.js.git
### 2. Install packages
```
cd mfm.js
npm i

# This repository uses pnpm as its package manager.
Comment thread
samunohito marked this conversation as resolved.
pnpm i
```

### 3. Build
```
npm run build
pnpm run build
```

### Use the interactive CLI parser
full parser:
```
npm run parse
pnpm run parse
```

simple parser:
```
npm run parse-simple
pnpm run parse-simple
```

## License
Expand Down
4 changes: 2 additions & 2 deletions docs/CONTRIBUTING.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Thank you for your PR! Before creating a PR, please check the following:
- 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`.
- Run `npm run api` to update the API report and commit it if there are any diffs.
- You can run it with `pnpm run test` and `pnpm run lint`.
- Run `pnpm run api` to update the API report and commit it if there are any diffs.

Thanks for your cooperation 🤗

Loading
Loading