@miyaoka/fsss 0.2.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,10 +108,53 @@ Options:
|
|
|
108
108
|
-h, --help ヘルプを表示する
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
##
|
|
111
|
+
## Plugin — `_plugins/` を置くだけで横断的処理を追加
|
|
112
|
+
|
|
113
|
+
```
|
|
114
|
+
commands/
|
|
115
|
+
_plugins/
|
|
116
|
+
logger.ts ← 全コマンドに適用
|
|
117
|
+
serve.ts
|
|
118
|
+
remote/
|
|
119
|
+
_plugins/
|
|
120
|
+
auth.ts ← remote 配下にのみ適用
|
|
121
|
+
[name]/
|
|
122
|
+
push.ts
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
`commands/` ツリーの任意の階層に `_plugins/` を配置するだけで、その階層以下のコマンドにプラグインが自動適用される。
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
// commands/_plugins/logger.ts
|
|
129
|
+
export default definePlugin(({ cliName }) => ({
|
|
130
|
+
provide: {
|
|
131
|
+
logger: {
|
|
132
|
+
info: (msg: string) => console.log(`[${cliName}] ${msg}`),
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
middleware: async (_ctx, next) => {
|
|
136
|
+
const start = performance.now();
|
|
137
|
+
await next();
|
|
138
|
+
console.log(`${(performance.now() - start).toFixed(0)}ms`);
|
|
139
|
+
},
|
|
140
|
+
}));
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
- `provide` で注入した値はコマンドの `run()` で `extensions` として型付きで受け取れる
|
|
144
|
+
- `middleware` はコマンドの実行を包む onion model(root 側が外側、leaf 側が内側)
|
|
145
|
+
- Extensions の型は `fsss-codegen` で自動生成される
|
|
146
|
+
|
|
147
|
+
```ts
|
|
148
|
+
run({ extensions }) {
|
|
149
|
+
extensions.logger.info("hello");
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## [ドキュメント](docs/README.md)
|
|
112
154
|
|
|
113
155
|
- [ファイルベースルーティング](docs/routing.md) — コマンドツリー、動的セグメント、params と args の分離
|
|
114
156
|
- [スキーマと値の解決](docs/schema.md) — defineCommand、args 定義、値の優先順位、ヘルプ生成
|
|
115
157
|
- [設定ファイルと環境変数](docs/config.md) — autoEnv、config ファイル階層、`--config` フラグ
|
|
158
|
+
- [プラグインシステム](docs/plugin.md) — `_plugins/` 規約、ミドルウェア、Extensions の型生成
|
|
116
159
|
- [内部アーキテクチャ](docs/architecture.md) — パイプライン設計、各モジュールの責務、処理トレース
|
|
117
|
-
- [既存ツールとの比較](docs/comparison.md) — commander / oclif / Pastel / Gud CLI / convict との比較
|
|
160
|
+
- [既存ツールとの比較](docs/comparison.md) — commander / oclif / Pastel / Gud CLI / gunshi / convict との比較
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@miyaoka/fsss",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "A CLI framework where your file structure becomes your command structure, and a single schema gives you typed values whether they come from flags, env vars, or config files.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "miyaoka",
|