@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.
@@ -0,0 +1,152 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://guanghechen.github.io/sora/schemas/commander/preset.config.schema.json",
4
+ "title": "Commander Preset Config",
5
+ "description": "Preset profile manifest for @guanghechen/commander --preset-file.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["version", "profiles"],
9
+ "examples": [
10
+ {
11
+ "version": 1,
12
+ "defaults": { "profile": "dev:local" },
13
+ "profiles": {
14
+ "dev": {
15
+ "envFile": "dev.env",
16
+ "envs": { "NODE_ENV": "development" },
17
+ "opts": { "logLevel": "debug", "retry": 2 },
18
+ "defaultVariant": "local",
19
+ "variants": {
20
+ "local": { "opts": { "retry": 1 } },
21
+ "ci": { "envFile": "ci.env", "envs": { "CI": "1" } }
22
+ }
23
+ }
24
+ }
25
+ }
26
+ ],
27
+ "properties": {
28
+ "$schema": {
29
+ "type": "string",
30
+ "description": "Optional schema reference for editors (e.g. VSCode)."
31
+ },
32
+ "version": {
33
+ "type": "integer",
34
+ "const": 1,
35
+ "description": "Schema version."
36
+ },
37
+ "defaults": {
38
+ "type": "object",
39
+ "additionalProperties": false,
40
+ "properties": {
41
+ "profile": {
42
+ "$ref": "#/$defs/profileSelector"
43
+ }
44
+ },
45
+ "description": "Default selector when --preset-profile is not provided."
46
+ },
47
+ "profiles": {
48
+ "type": "object",
49
+ "minProperties": 1,
50
+ "propertyNames": {
51
+ "$ref": "#/$defs/profileName"
52
+ },
53
+ "additionalProperties": {
54
+ "$ref": "#/$defs/profileItem"
55
+ },
56
+ "description": "Profiles keyed by profile name."
57
+ }
58
+ },
59
+ "$defs": {
60
+ "profileName": {
61
+ "type": "string",
62
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$",
63
+ "description": "Profile/variant name."
64
+ },
65
+ "profileSelector": {
66
+ "type": "string",
67
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*(?::[A-Za-z0-9][A-Za-z0-9._-]*)?$",
68
+ "description": "Selector format: <profile> or <profile>:<variant>."
69
+ },
70
+ "optionName": {
71
+ "type": "string",
72
+ "pattern": "^(?:--)?(?:[a-z][a-zA-Z0-9]*|[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)+)$",
73
+ "description": "Option key in opts map; aligned with runtime normalization."
74
+ },
75
+ "optionValue": {
76
+ "oneOf": [
77
+ { "type": "boolean" },
78
+ { "type": "string" },
79
+ { "type": "number" },
80
+ {
81
+ "type": "array",
82
+ "items": {
83
+ "oneOf": [{ "type": "string" }, { "type": "number" }]
84
+ }
85
+ }
86
+ ]
87
+ },
88
+ "envMap": {
89
+ "type": "object",
90
+ "additionalProperties": {
91
+ "type": "string"
92
+ }
93
+ },
94
+ "optsMap": {
95
+ "type": "object",
96
+ "propertyNames": {
97
+ "$ref": "#/$defs/optionName"
98
+ },
99
+ "additionalProperties": {
100
+ "$ref": "#/$defs/optionValue"
101
+ }
102
+ },
103
+ "variantItem": {
104
+ "type": "object",
105
+ "additionalProperties": false,
106
+ "properties": {
107
+ "envFile": {
108
+ "type": "string",
109
+ "minLength": 1
110
+ },
111
+ "envs": {
112
+ "$ref": "#/$defs/envMap"
113
+ },
114
+ "opts": {
115
+ "$ref": "#/$defs/optsMap"
116
+ }
117
+ }
118
+ },
119
+ "variantsMap": {
120
+ "type": "object",
121
+ "propertyNames": {
122
+ "$ref": "#/$defs/profileName"
123
+ },
124
+ "additionalProperties": {
125
+ "$ref": "#/$defs/variantItem"
126
+ }
127
+ },
128
+ "profileItem": {
129
+ "type": "object",
130
+ "additionalProperties": false,
131
+ "properties": {
132
+ "envFile": {
133
+ "type": "string",
134
+ "minLength": 1
135
+ },
136
+ "envs": {
137
+ "$ref": "#/$defs/envMap"
138
+ },
139
+ "opts": {
140
+ "$ref": "#/$defs/optsMap"
141
+ },
142
+ "defaultVariant": {
143
+ "$ref": "#/$defs/profileName"
144
+ },
145
+ "variants": {
146
+ "$ref": "#/$defs/variantsMap"
147
+ }
148
+ },
149
+ "description": "defaultVariant existence in variants must still be validated by runtime."
150
+ }
151
+ }
152
+ }
@@ -0,0 +1,152 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://guanghechen.github.io/sora/schemas/commander/preset.schema.json",
4
+ "title": "Commander Preset Config",
5
+ "description": "Preset profile manifest for @guanghechen/commander --preset-file.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["version", "profiles"],
9
+ "examples": [
10
+ {
11
+ "version": 1,
12
+ "defaults": { "profile": "dev:local" },
13
+ "profiles": {
14
+ "dev": {
15
+ "envFile": "dev.env",
16
+ "envs": { "NODE_ENV": "development" },
17
+ "opts": { "logLevel": "debug", "retry": 2 },
18
+ "defaultVariant": "local",
19
+ "variants": {
20
+ "local": { "opts": { "retry": 1 } },
21
+ "ci": { "envFile": "ci.env", "envs": { "CI": "1" } }
22
+ }
23
+ }
24
+ }
25
+ }
26
+ ],
27
+ "properties": {
28
+ "$schema": {
29
+ "type": "string",
30
+ "description": "Optional schema reference for editors (e.g. VSCode)."
31
+ },
32
+ "version": {
33
+ "type": "integer",
34
+ "const": 1,
35
+ "description": "Schema version."
36
+ },
37
+ "defaults": {
38
+ "type": "object",
39
+ "additionalProperties": false,
40
+ "properties": {
41
+ "profile": {
42
+ "$ref": "#/$defs/profileSelector"
43
+ }
44
+ },
45
+ "description": "Default selector when --preset-profile is not provided."
46
+ },
47
+ "profiles": {
48
+ "type": "object",
49
+ "minProperties": 1,
50
+ "propertyNames": {
51
+ "$ref": "#/$defs/profileName"
52
+ },
53
+ "additionalProperties": {
54
+ "$ref": "#/$defs/profileItem"
55
+ },
56
+ "description": "Profiles keyed by profile name."
57
+ }
58
+ },
59
+ "$defs": {
60
+ "profileName": {
61
+ "type": "string",
62
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*$",
63
+ "description": "Profile/variant name."
64
+ },
65
+ "profileSelector": {
66
+ "type": "string",
67
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]*(?::[A-Za-z0-9][A-Za-z0-9._-]*)?$",
68
+ "description": "Selector format: <profile> or <profile>:<variant>."
69
+ },
70
+ "optionName": {
71
+ "type": "string",
72
+ "pattern": "^(?:--)?(?:[a-z][a-zA-Z0-9]*|[A-Za-z][A-Za-z0-9]*(?:-[A-Za-z0-9]+)+)$",
73
+ "description": "Option key in opts map; aligned with runtime normalization."
74
+ },
75
+ "optionValue": {
76
+ "oneOf": [
77
+ { "type": "boolean" },
78
+ { "type": "string" },
79
+ { "type": "number" },
80
+ {
81
+ "type": "array",
82
+ "items": {
83
+ "oneOf": [{ "type": "string" }, { "type": "number" }]
84
+ }
85
+ }
86
+ ]
87
+ },
88
+ "envMap": {
89
+ "type": "object",
90
+ "additionalProperties": {
91
+ "type": "string"
92
+ }
93
+ },
94
+ "optsMap": {
95
+ "type": "object",
96
+ "propertyNames": {
97
+ "$ref": "#/$defs/optionName"
98
+ },
99
+ "additionalProperties": {
100
+ "$ref": "#/$defs/optionValue"
101
+ }
102
+ },
103
+ "variantItem": {
104
+ "type": "object",
105
+ "additionalProperties": false,
106
+ "properties": {
107
+ "envFile": {
108
+ "type": "string",
109
+ "minLength": 1
110
+ },
111
+ "envs": {
112
+ "$ref": "#/$defs/envMap"
113
+ },
114
+ "opts": {
115
+ "$ref": "#/$defs/optsMap"
116
+ }
117
+ }
118
+ },
119
+ "variantsMap": {
120
+ "type": "object",
121
+ "propertyNames": {
122
+ "$ref": "#/$defs/profileName"
123
+ },
124
+ "additionalProperties": {
125
+ "$ref": "#/$defs/variantItem"
126
+ }
127
+ },
128
+ "profileItem": {
129
+ "type": "object",
130
+ "additionalProperties": false,
131
+ "properties": {
132
+ "envFile": {
133
+ "type": "string",
134
+ "minLength": 1
135
+ },
136
+ "envs": {
137
+ "$ref": "#/$defs/envMap"
138
+ },
139
+ "opts": {
140
+ "$ref": "#/$defs/optsMap"
141
+ },
142
+ "defaultVariant": {
143
+ "$ref": "#/$defs/profileName"
144
+ },
145
+ "variants": {
146
+ "$ref": "#/$defs/variantsMap"
147
+ }
148
+ },
149
+ "description": "defaultVariant existence in variants must still be validated by runtime."
150
+ }
151
+ }
152
+ }
@@ -124,12 +124,48 @@ interface ICommandExample {
124
124
  }
125
125
  /** Command preset defaults */
126
126
  interface ICommandPresetConfig {
127
- /** Preset root directory (absolute path) */
128
- root?: string;
129
- /** Default preset options file */
130
- opt?: string;
131
- /** Default preset envs file */
132
- env?: string;
127
+ /** Default preset profile file */
128
+ file?: string;
129
+ /** Default preset profile selector: <profile> or <profile>:<variant> */
130
+ profile?: string;
131
+ }
132
+ /** Allowed inline profile option value */
133
+ type ICommandPresetProfileOptionValue = boolean | string | number | ReadonlyArray<string | number>;
134
+ /** Variant item nested under a preset profile */
135
+ interface ICommandPresetProfileVariantItem {
136
+ /** Optional env file path to parse (relative to preset file directory when non-absolute) */
137
+ envFile?: string;
138
+ /** Inline env overrides */
139
+ envs?: Record<string, string>;
140
+ /** Inline option overrides */
141
+ opts?: Record<string, ICommandPresetProfileOptionValue>;
142
+ }
143
+ /** Profile item in preset manifest */
144
+ interface ICommandPresetProfileItem {
145
+ /** Optional env file path to parse (relative to preset file directory when non-absolute) */
146
+ envFile?: string;
147
+ /** Inline env overrides */
148
+ envs?: Record<string, string>;
149
+ /** Inline option overrides */
150
+ opts?: Record<string, ICommandPresetProfileOptionValue>;
151
+ /** Default selected variant name */
152
+ defaultVariant?: string;
153
+ /** Optional variants keyed by variant name */
154
+ variants?: Record<string, ICommandPresetProfileVariantItem>;
155
+ }
156
+ /** Profile manifest defaults */
157
+ interface ICommandPresetProfileDefaults {
158
+ /** Default selected profile selector: <profile> or <profile>:<variant> */
159
+ profile?: string;
160
+ }
161
+ /** Profile manifest structure loaded from --preset-file */
162
+ interface ICommandPresetProfileManifest {
163
+ /** Schema version */
164
+ version: 1;
165
+ /** Optional defaults */
166
+ defaults?: ICommandPresetProfileDefaults;
167
+ /** Profiles keyed by profile name */
168
+ profiles: Record<string, ICommandPresetProfileItem>;
133
169
  }
134
170
  /** Runtime file stats abstraction */
135
171
  interface ICommandRuntimeStats {
@@ -572,4 +608,4 @@ declare function getDefaultCommandRuntime(): ICommandRuntime;
572
608
  declare function setDefaultCommandRuntime(runtime: ICommandRuntime): void;
573
609
 
574
610
  export { Coerce, Command, CommanderError, createBrowserCommandRuntime, getDefaultCommandRuntime, isDomain, isIp, isIpv4, isIpv6, logColorfulOption, logDateOption, logLevelOption, setDefaultCommandRuntime, silentOption };
575
- export type { ICommand, ICommandAction, ICommandActionParams, ICommandArgumentConfig, ICommandArgumentKind, ICommandArgumentType, ICommandBuiltinConfig, ICommandBuiltinOptionConfig, ICommandBuiltinOptionResolved, ICommandBuiltinResolved, ICommandConfig, ICommandContext, ICommandControlScanResult, ICommandControls, ICommandExample, ICommandInputSources, ICommandOptionArgs, ICommandOptionConfig, ICommandOptionType, ICommandParseResult, ICommandParsedArgs, ICommandParsedOpts, ICommandPresetConfig, ICommandPresetResult, ICommandResolveResult, ICommandRouteResult, ICommandRunParams, ICommandRuntime, ICommandRuntimeStats, ICommandShiftResult, ICommandToken, ICommandTokenType, ICommandTokenizeResult, ICommanderErrorKind, ICompletionArgumentMeta, ICompletionCommandConfig, ICompletionMeta, ICompletionOptionMeta, ICompletionPaths, ICompletionShellType, IHelpArgumentLine, IHelpCommandLine, IHelpData, IHelpExampleLine, IHelpOptionLine, ISubcommandEntry };
611
+ export type { ICommand, ICommandAction, ICommandActionParams, ICommandArgumentConfig, ICommandArgumentKind, ICommandArgumentType, ICommandBuiltinConfig, ICommandBuiltinOptionConfig, ICommandBuiltinOptionResolved, ICommandBuiltinResolved, ICommandConfig, ICommandContext, ICommandControlScanResult, ICommandControls, ICommandExample, ICommandInputSources, ICommandOptionArgs, ICommandOptionConfig, ICommandOptionType, ICommandParseResult, ICommandParsedArgs, ICommandParsedOpts, ICommandPresetConfig, ICommandPresetProfileDefaults, ICommandPresetProfileItem, ICommandPresetProfileManifest, ICommandPresetProfileOptionValue, ICommandPresetProfileVariantItem, ICommandPresetResult, ICommandResolveResult, ICommandRouteResult, ICommandRunParams, ICommandRuntime, ICommandRuntimeStats, ICommandShiftResult, ICommandToken, ICommandTokenType, ICommandTokenizeResult, ICommanderErrorKind, ICompletionArgumentMeta, ICompletionCommandConfig, ICompletionMeta, ICompletionOptionMeta, ICompletionPaths, ICompletionShellType, IHelpArgumentLine, IHelpCommandLine, IHelpData, IHelpExampleLine, IHelpOptionLine, ISubcommandEntry };
@@ -124,12 +124,48 @@ interface ICommandExample {
124
124
  }
125
125
  /** Command preset defaults */
126
126
  interface ICommandPresetConfig {
127
- /** Preset root directory (absolute path) */
128
- root?: string;
129
- /** Default preset options file */
130
- opt?: string;
131
- /** Default preset envs file */
132
- env?: string;
127
+ /** Default preset profile file */
128
+ file?: string;
129
+ /** Default preset profile selector: <profile> or <profile>:<variant> */
130
+ profile?: string;
131
+ }
132
+ /** Allowed inline profile option value */
133
+ type ICommandPresetProfileOptionValue = boolean | string | number | ReadonlyArray<string | number>;
134
+ /** Variant item nested under a preset profile */
135
+ interface ICommandPresetProfileVariantItem {
136
+ /** Optional env file path to parse (relative to preset file directory when non-absolute) */
137
+ envFile?: string;
138
+ /** Inline env overrides */
139
+ envs?: Record<string, string>;
140
+ /** Inline option overrides */
141
+ opts?: Record<string, ICommandPresetProfileOptionValue>;
142
+ }
143
+ /** Profile item in preset manifest */
144
+ interface ICommandPresetProfileItem {
145
+ /** Optional env file path to parse (relative to preset file directory when non-absolute) */
146
+ envFile?: string;
147
+ /** Inline env overrides */
148
+ envs?: Record<string, string>;
149
+ /** Inline option overrides */
150
+ opts?: Record<string, ICommandPresetProfileOptionValue>;
151
+ /** Default selected variant name */
152
+ defaultVariant?: string;
153
+ /** Optional variants keyed by variant name */
154
+ variants?: Record<string, ICommandPresetProfileVariantItem>;
155
+ }
156
+ /** Profile manifest defaults */
157
+ interface ICommandPresetProfileDefaults {
158
+ /** Default selected profile selector: <profile> or <profile>:<variant> */
159
+ profile?: string;
160
+ }
161
+ /** Profile manifest structure loaded from --preset-file */
162
+ interface ICommandPresetProfileManifest {
163
+ /** Schema version */
164
+ version: 1;
165
+ /** Optional defaults */
166
+ defaults?: ICommandPresetProfileDefaults;
167
+ /** Profiles keyed by profile name */
168
+ profiles: Record<string, ICommandPresetProfileItem>;
133
169
  }
134
170
  /** Runtime file stats abstraction */
135
171
  interface ICommandRuntimeStats {
@@ -625,4 +661,4 @@ declare class PwshCompletion {
625
661
  }
626
662
 
627
663
  export { BashCompletion, Coerce, Command, CommanderError, CompletionCommand, FishCompletion, PwshCompletion, createBrowserCommandRuntime, createNodeCommandRuntime, getDefaultCommandRuntime, isDomain, isIp, isIpv4, isIpv6, logColorfulOption, logDateOption, logLevelOption, setDefaultCommandRuntime, silentOption };
628
- export type { ICommand, ICommandAction, ICommandActionParams, ICommandArgumentConfig, ICommandArgumentKind, ICommandArgumentType, ICommandBuiltinConfig, ICommandBuiltinOptionConfig, ICommandBuiltinOptionResolved, ICommandBuiltinResolved, ICommandConfig, ICommandContext, ICommandControlScanResult, ICommandControls, ICommandExample, ICommandInputSources, ICommandOptionArgs, ICommandOptionConfig, ICommandOptionType, ICommandParseResult, ICommandParsedArgs, ICommandParsedOpts, ICommandPresetConfig, ICommandPresetResult, ICommandResolveResult, ICommandRouteResult, ICommandRunParams, ICommandRuntime, ICommandRuntimeStats, ICommandShiftResult, ICommandToken, ICommandTokenType, ICommandTokenizeResult, ICommanderErrorKind, ICompletionArgumentMeta, ICompletionCommandConfig, ICompletionMeta, ICompletionOptionMeta, ICompletionPaths, ICompletionShellType, IHelpArgumentLine, IHelpCommandLine, IHelpData, IHelpExampleLine, IHelpOptionLine, ISubcommandEntry };
664
+ export type { ICommand, ICommandAction, ICommandActionParams, ICommandArgumentConfig, ICommandArgumentKind, ICommandArgumentType, ICommandBuiltinConfig, ICommandBuiltinOptionConfig, ICommandBuiltinOptionResolved, ICommandBuiltinResolved, ICommandConfig, ICommandContext, ICommandControlScanResult, ICommandControls, ICommandExample, ICommandInputSources, ICommandOptionArgs, ICommandOptionConfig, ICommandOptionType, ICommandParseResult, ICommandParsedArgs, ICommandParsedOpts, ICommandPresetConfig, ICommandPresetProfileDefaults, ICommandPresetProfileItem, ICommandPresetProfileManifest, ICommandPresetProfileOptionValue, ICommandPresetProfileVariantItem, ICommandPresetResult, ICommandResolveResult, ICommandRouteResult, ICommandRunParams, ICommandRuntime, ICommandRuntimeStats, ICommandShiftResult, ICommandToken, ICommandTokenType, ICommandTokenizeResult, ICommanderErrorKind, ICompletionArgumentMeta, ICompletionCommandConfig, ICompletionMeta, ICompletionOptionMeta, ICompletionPaths, ICompletionShellType, IHelpArgumentLine, IHelpCommandLine, IHelpData, IHelpExampleLine, IHelpOptionLine, ISubcommandEntry };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guanghechen/commander",
3
- "version": "4.7.5",
3
+ "version": "4.7.7",
4
4
  "description": "A minimal, type-safe command-line interface builder with fluent API",
5
5
  "author": {
6
6
  "name": "guanghechen",