@guanghechen/commander 4.7.5 → 4.7.7
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/CHANGELOG.md +17 -0
- package/README.md +46 -39
- package/lib/cjs/browser.cjs +428 -175
- package/lib/cjs/node.cjs +427 -174
- package/lib/esm/browser.mjs +428 -175
- package/lib/esm/node.mjs +427 -174
- package/lib/schema/preset.config.schema.json +152 -0
- package/lib/schema/preset.schema.json +152 -0
- package/lib/types/browser.d.ts +43 -7
- package/lib/types/node.d.ts +43 -7
- package/package.json +1 -1
- package/lib/cjs/index.cjs +0 -1237
- package/lib/esm/index.mjs +0 -1208
- package/lib/types/index.d.ts +0 -384
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## 4.7.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Improve preset schema naming consistency and extend envFile preset-path resolution test coverage.
|
|
8
|
+
Stabilize commander test coverage thresholds.
|
|
9
|
+
|
|
10
|
+
## 4.7.6
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Auto-generated release notes:
|
|
15
|
+
- @guanghechen/commander
|
|
16
|
+
- 59f8231 :sparkles: feat(commander): add preset config schema and build-time schema copy
|
|
17
|
+
- 6fc5ee3 :sparkles: feat(commander)!: remove preset suitable restriction
|
|
18
|
+
- 60a6d31 :sparkles: feat(commander): support preset profile variants and manifest presets
|
|
19
|
+
|
|
3
20
|
## 4.7.5
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -209,52 +209,59 @@ new Command({ name: 'example', desc: 'Option types demo' })
|
|
|
209
209
|
})
|
|
210
210
|
```
|
|
211
211
|
|
|
212
|
-
### Preset
|
|
212
|
+
### Preset Profiles
|
|
213
213
|
|
|
214
|
-
`--preset-
|
|
215
|
-
env inputs before normal CLI parsing.
|
|
214
|
+
Use `--preset-file` with an optional `--preset-profile=<profile[:variant]>` to load profile-based presets.
|
|
216
215
|
|
|
217
216
|
```bash
|
|
218
|
-
mycli
|
|
217
|
+
mycli run --preset-file=./preset.json --preset-profile=dev:staging
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
`preset.json` example:
|
|
221
|
+
|
|
222
|
+
```json
|
|
223
|
+
{
|
|
224
|
+
"version": 1,
|
|
225
|
+
"defaults": { "profile": "dev" },
|
|
226
|
+
"profiles": {
|
|
227
|
+
"dev": {
|
|
228
|
+
"envFile": "dev.env",
|
|
229
|
+
"envs": { "NODE_ENV": "development" },
|
|
230
|
+
"opts": { "mode": "fast", "retry": 2 },
|
|
231
|
+
"defaultVariant": "local",
|
|
232
|
+
"variants": {
|
|
233
|
+
"local": {
|
|
234
|
+
"opts": { "retry": 1 }
|
|
235
|
+
},
|
|
236
|
+
"staging": {
|
|
237
|
+
"envFile": "staging.env",
|
|
238
|
+
"envs": { "NODE_ENV": "staging" },
|
|
239
|
+
"opts": { "retry": 3 }
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
Schema:
|
|
248
|
+
|
|
249
|
+
```json
|
|
250
|
+
{
|
|
251
|
+
"$schema": "./node_modules/@guanghechen/commander/lib/schema/preset.schema.json"
|
|
252
|
+
}
|
|
219
253
|
```
|
|
220
254
|
|
|
221
255
|
Behavior:
|
|
222
256
|
|
|
223
|
-
1.
|
|
224
|
-
2.
|
|
225
|
-
3.
|
|
226
|
-
4.
|
|
227
|
-
5.
|
|
228
|
-
6.
|
|
229
|
-
7.
|
|
230
|
-
8.
|
|
231
|
-
9. Expose source snapshots through `ctx.sources` and reuse existing tokenize/resolve/parse pipeline.
|
|
232
|
-
|
|
233
|
-
Precedence for same option key:
|
|
234
|
-
|
|
235
|
-
1. User CLI tokens (highest)
|
|
236
|
-
2. Tokens loaded from `--preset-opts`
|
|
237
|
-
3. Option `default` / implicit defaults
|
|
238
|
-
4. `NO_COLOR` fallback for color rendering only (applies only when no explicit `--color/--no-color` token appears)
|
|
239
|
-
|
|
240
|
-
Precedence for same env key:
|
|
241
|
-
|
|
242
|
-
1. Key-values loaded from `--preset-envs` (highest)
|
|
243
|
-
2. User envs (e.g. `process.env`)
|
|
244
|
-
|
|
245
|
-
Additional notes:
|
|
246
|
-
|
|
247
|
-
1. `variadic` options append in appearance order.
|
|
248
|
-
2. `NO_COLOR` is evaluated from `ctx.envs` and remains a fallback only when no color token is explicitly provided.
|
|
249
|
-
3. The `--preset-opts` file is expected to contain option fragments (`-x`/`--xxx` and their values), not command-route tokens.
|
|
250
|
-
4. The `--preset-envs` file must be parseable by `@guanghechen/env`.
|
|
251
|
-
5. Only preset flags before `--` are processed; after `--` they are treated as normal args.
|
|
252
|
-
6. Repeated preset flags are processed in appearance order.
|
|
253
|
-
7. Built-in control semantics recognize `--help` / `help` / `--version` only (no short aliases).
|
|
254
|
-
8. `long: 'help'` and `long: 'version'` are reserved and must not be user-defined in `.option()`.
|
|
255
|
-
9. `--help` / `help` / `--version` are forbidden in `--preset-opts` files; loading should fail fast.
|
|
256
|
-
10. `--` is forbidden inside `--preset-opts` files; loading should fail fast.
|
|
257
|
-
11. `parse()` never executes control handlers; it only records control hits in `ctx.controls`.
|
|
257
|
+
1. Profile selector resolution order is `--preset-profile` > `command.preset.profile` > `defaults.profile`.
|
|
258
|
+
2. Selector supports `<profile>` and `<profile>:<variant>`; when variant is omitted it falls back to `profile.defaultVariant`.
|
|
259
|
+
3. `envFile` is optional and resolved relative to the preset file directory when not absolute.
|
|
260
|
+
4. Variant fields override base profile fields by `base + variant`.
|
|
261
|
+
5. `opts` are converted into preset option fragments and merged before user CLI tokens.
|
|
262
|
+
6. `envs` override keys loaded from `envFile`.
|
|
263
|
+
7. Only `--preset-file` / `--preset-profile` are supported as preset directives.
|
|
264
|
+
8. `--preset-root` is removed.
|
|
258
265
|
|
|
259
266
|
### Built-in Coerce Factories
|
|
260
267
|
|