icore 1.0.13 → 1.0.15

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/dist/cli.d.ts CHANGED
@@ -9,6 +9,6 @@
9
9
  * This file must not contain parser, validator, or command runtime logic.
10
10
  */
11
11
  export { parseArgv, type ParsedArgv } from './argv';
12
- export { defineCommand, defineCommandRegistry, isCommandName, prepareCommandFromArgs, resolveCommand, resolveCommandFromArgs, runCommand, runPreparedCommand, runCommandFromRegistry, type CommandDefinition, type CommandInput, type CommandName, type CommandRegistry, type CommandResolutionOptions, type PreparedCommand, type PreparedCommandInput, type ResolvedCommand } from './commands';
12
+ export { defineCommand, defineCommandRegistry, isCommandName, isPreparedCommandName, prepareCommandFromArgs, resolveCommand, resolveCommandFromArgs, runCommand, runPreparedCommand, runCommandFromRegistry, type CommandDefinition, type CommandContext, type CommandInput, type CommandName, type CommandPayload, type CommandRegistry, type CommandResolutionOptions, type CommandResult, type PreparedCommand, type PreparedCommandInput, type ResolvedCommand } from './commands';
13
13
  export { IcoreError, type IcoreErrorCode, type IcoreErrorDetails } from './errors';
14
14
  export { mergeOptionsSchema, parseOptions, parseOptionsDetailed, type BooleanOption, type InferOptions, type InferProvidedOptions, type MergeOptionsSchemas, type NumberOption, type OptionDefinition, type OptionsSchema, type ParseOptionsResult, type RawOptionValue, type StringOption } from './options';
package/dist/cli.js CHANGED
@@ -10,13 +10,14 @@
10
10
  * This file must not contain parser, validator, or command runtime logic.
11
11
  */
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.parseOptionsDetailed = exports.parseOptions = exports.mergeOptionsSchema = exports.IcoreError = exports.runCommandFromRegistry = exports.runPreparedCommand = exports.runCommand = exports.resolveCommandFromArgs = exports.resolveCommand = exports.prepareCommandFromArgs = exports.isCommandName = exports.defineCommandRegistry = exports.defineCommand = exports.parseArgv = void 0;
13
+ exports.parseOptionsDetailed = exports.parseOptions = exports.mergeOptionsSchema = exports.IcoreError = exports.runCommandFromRegistry = exports.runPreparedCommand = exports.runCommand = exports.resolveCommandFromArgs = exports.resolveCommand = exports.prepareCommandFromArgs = exports.isPreparedCommandName = exports.isCommandName = exports.defineCommandRegistry = exports.defineCommand = exports.parseArgv = void 0;
14
14
  var argv_1 = require("./argv");
15
15
  Object.defineProperty(exports, "parseArgv", { enumerable: true, get: function () { return argv_1.parseArgv; } });
16
16
  var commands_1 = require("./commands");
17
17
  Object.defineProperty(exports, "defineCommand", { enumerable: true, get: function () { return commands_1.defineCommand; } });
18
18
  Object.defineProperty(exports, "defineCommandRegistry", { enumerable: true, get: function () { return commands_1.defineCommandRegistry; } });
19
19
  Object.defineProperty(exports, "isCommandName", { enumerable: true, get: function () { return commands_1.isCommandName; } });
20
+ Object.defineProperty(exports, "isPreparedCommandName", { enumerable: true, get: function () { return commands_1.isPreparedCommandName; } });
20
21
  Object.defineProperty(exports, "prepareCommandFromArgs", { enumerable: true, get: function () { return commands_1.prepareCommandFromArgs; } });
21
22
  Object.defineProperty(exports, "resolveCommand", { enumerable: true, get: function () { return commands_1.resolveCommand; } });
22
23
  Object.defineProperty(exports, "resolveCommandFromArgs", { enumerable: true, get: function () { return commands_1.resolveCommandFromArgs; } });
@@ -78,10 +78,10 @@ type CommandDefinitionParts<TCommand extends AnyCommandDefinition> = TCommand ex
78
78
  metadata: TCommand['metadata'];
79
79
  payload: unknown;
80
80
  };
81
- type CommandContext<TCommand extends AnyCommandDefinition> = CommandDefinitionParts<TCommand>['context'];
82
- type CommandResult<TCommand extends AnyCommandDefinition> = Awaited<CommandDefinitionParts<TCommand>['result']>;
81
+ export type CommandContext<TCommand extends AnyCommandDefinition> = CommandDefinitionParts<TCommand>['context'];
82
+ export type CommandResult<TCommand extends AnyCommandDefinition> = Awaited<CommandDefinitionParts<TCommand>['result']>;
83
83
  type CommandSchema<TCommand extends AnyCommandDefinition> = CommandDefinitionParts<TCommand>['schema'];
84
- type CommandPayload<TCommand extends AnyCommandDefinition> = CommandDefinitionParts<TCommand>['payload'];
84
+ export type CommandPayload<TCommand extends AnyCommandDefinition> = CommandDefinitionParts<TCommand>['payload'];
85
85
  /**
86
86
  * Infers the public command name from a command path.
87
87
  */
@@ -116,7 +116,7 @@ export type ResolvedCommand<TCommand extends AnyCommandDefinition> = {
116
116
  /**
117
117
  * Command resolved and validated without runtime context.
118
118
  */
119
- export type PreparedCommand<TCommand extends AnyCommandDefinition> = {
119
+ export type PreparedCommand<TCommand extends AnyCommandDefinition> = TCommand extends AnyCommandDefinition ? {
120
120
  name: CommandName<TCommand>;
121
121
  path: TCommand['path'];
122
122
  command: TCommand;
@@ -124,7 +124,7 @@ export type PreparedCommand<TCommand extends AnyCommandDefinition> = {
124
124
  provided: InferProvidedOptions<CommandSchema<TCommand>>;
125
125
  positionals: string[];
126
126
  payload: CommandPayload<TCommand>;
127
- };
127
+ } : never;
128
128
  /**
129
129
  * Defines a command while preserving literal option schema types.
130
130
  */
@@ -137,6 +137,12 @@ export declare function defineCommandRegistry<const TCommands extends readonly A
137
137
  * Checks whether a value is a command name registered in the given registry.
138
138
  */
139
139
  export declare function isCommandName<const TCommands extends readonly AnyCommandDefinition[]>(registry: CommandRegistry<TCommands>, value: unknown): value is CommandName<TCommands[number]>;
140
+ /**
141
+ * Checks whether a prepared command has the given command name.
142
+ */
143
+ export declare function isPreparedCommandName<TPrepared extends PreparedCommand<AnyCommandDefinition>, TName extends TPrepared['name']>(prepared: TPrepared, name: TName): prepared is Extract<TPrepared, {
144
+ name: TName;
145
+ }>;
140
146
  /**
141
147
  * Resolves a command from already parsed positional arguments.
142
148
  */
package/dist/commands.js CHANGED
@@ -15,6 +15,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.defineCommand = defineCommand;
16
16
  exports.defineCommandRegistry = defineCommandRegistry;
17
17
  exports.isCommandName = isCommandName;
18
+ exports.isPreparedCommandName = isPreparedCommandName;
18
19
  exports.resolveCommand = resolveCommand;
19
20
  exports.resolveCommandFromArgs = resolveCommandFromArgs;
20
21
  exports.prepareCommandFromArgs = prepareCommandFromArgs;
@@ -48,6 +49,12 @@ function isCommandName(registry, value) {
48
49
  return typeof value === 'string'
49
50
  && registry.commandNames.includes(value);
50
51
  }
52
+ /**
53
+ * Checks whether a prepared command has the given command name.
54
+ */
55
+ function isPreparedCommandName(prepared, name) {
56
+ return prepared.name === name;
57
+ }
51
58
  /**
52
59
  * Resolves a command from already parsed positional arguments.
53
60
  */
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { defineCommand, defineCommandRegistry, IcoreError, isCommandName, mergeOptionsSchema, parseArgv, parseOptions, parseOptionsDetailed, prepareCommandFromArgs, resolveCommand, resolveCommandFromArgs, runCommand, runPreparedCommand, runCommandFromRegistry, type BooleanOption, type CommandDefinition, type CommandInput, type CommandName, type CommandRegistry, type CommandResolutionOptions, type InferOptions, type InferProvidedOptions, type IcoreErrorCode, type IcoreErrorDetails, type MergeOptionsSchemas, type NumberOption, type OptionDefinition, type OptionsSchema, type ParseOptionsResult, type ParsedArgv, type PreparedCommand, type PreparedCommandInput, type RawOptionValue, type ResolvedCommand, type StringOption } from './cli';
1
+ export { defineCommand, defineCommandRegistry, IcoreError, isCommandName, isPreparedCommandName, mergeOptionsSchema, parseArgv, parseOptions, parseOptionsDetailed, prepareCommandFromArgs, resolveCommand, resolveCommandFromArgs, runCommand, runPreparedCommand, runCommandFromRegistry, type BooleanOption, type CommandDefinition, type CommandContext, type CommandInput, type CommandName, type CommandPayload, type CommandRegistry, type CommandResolutionOptions, type CommandResult, type InferOptions, type InferProvidedOptions, type IcoreErrorCode, type IcoreErrorDetails, type MergeOptionsSchemas, type NumberOption, type OptionDefinition, type OptionsSchema, type ParseOptionsResult, type ParsedArgv, type PreparedCommand, type PreparedCommandInput, type RawOptionValue, type ResolvedCommand, type StringOption } from './cli';
package/dist/index.js CHANGED
@@ -1,11 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runCommandFromRegistry = exports.runPreparedCommand = exports.runCommand = exports.resolveCommandFromArgs = exports.resolveCommand = exports.prepareCommandFromArgs = exports.parseOptionsDetailed = exports.parseOptions = exports.parseArgv = exports.mergeOptionsSchema = exports.isCommandName = exports.IcoreError = exports.defineCommandRegistry = exports.defineCommand = void 0;
3
+ exports.runCommandFromRegistry = exports.runPreparedCommand = exports.runCommand = exports.resolveCommandFromArgs = exports.resolveCommand = exports.prepareCommandFromArgs = exports.parseOptionsDetailed = exports.parseOptions = exports.parseArgv = exports.mergeOptionsSchema = exports.isPreparedCommandName = exports.isCommandName = exports.IcoreError = exports.defineCommandRegistry = exports.defineCommand = void 0;
4
4
  var cli_1 = require("./cli");
5
5
  Object.defineProperty(exports, "defineCommand", { enumerable: true, get: function () { return cli_1.defineCommand; } });
6
6
  Object.defineProperty(exports, "defineCommandRegistry", { enumerable: true, get: function () { return cli_1.defineCommandRegistry; } });
7
7
  Object.defineProperty(exports, "IcoreError", { enumerable: true, get: function () { return cli_1.IcoreError; } });
8
8
  Object.defineProperty(exports, "isCommandName", { enumerable: true, get: function () { return cli_1.isCommandName; } });
9
+ Object.defineProperty(exports, "isPreparedCommandName", { enumerable: true, get: function () { return cli_1.isPreparedCommandName; } });
9
10
  Object.defineProperty(exports, "mergeOptionsSchema", { enumerable: true, get: function () { return cli_1.mergeOptionsSchema; } });
10
11
  Object.defineProperty(exports, "parseArgv", { enumerable: true, get: function () { return cli_1.parseArgv; } });
11
12
  Object.defineProperty(exports, "parseOptions", { enumerable: true, get: function () { return cli_1.parseOptions; } });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "icore",
3
- "version": "1.0.13",
3
+ "version": "1.0.15",
4
4
  "description": "Declarative command line interface mechanics for Node.js",
5
5
  "keywords": [
6
6
  "command-line",
@@ -28,6 +28,7 @@
28
28
  "types": "dist/index.d.ts",
29
29
  "scripts": {
30
30
  "build": "tsc",
31
+ "prepare": "tsc",
31
32
  "test": "node --test dist/*.test.js",
32
33
  "lint": "eslint src"
33
34
  },
package/readme.md CHANGED
@@ -32,6 +32,7 @@ npm install icore
32
32
  - [`defineCommand(command)`](#definecommandcommand)
33
33
  - [`defineCommandRegistry(commands)`](#definecommandregistrycommands)
34
34
  - [`isCommandName(registry, value)`](#iscommandnameregistry-value)
35
+ - [`isPreparedCommandName(prepared, name)`](#ispreparedcommandnameprepared-name)
35
36
  - [`resolveCommand(registry, positionals)`](#resolvecommandregistry-positionals)
36
37
  - [`resolveCommandFromArgs(registry, args)`](#resolvecommandfromargsregistry-args)
37
38
  - [`prepareCommandFromArgs(registry, args, options?)`](#preparecommandfromargsregistry-args-options)
@@ -236,6 +237,17 @@ if (isCommandName(registry, value)) {
236
237
  }
237
238
  ```
238
239
 
240
+ ### `isPreparedCommandName(prepared, name)`
241
+
242
+ Checks whether a prepared command has the given command name and narrows the
243
+ prepared command union.
244
+
245
+ ```ts
246
+ if (isPreparedCommandName(prepared, 'hello')) {
247
+ // prepared.payload is narrowed to the `hello` command payload.
248
+ }
249
+ ```
250
+
239
251
  ### `resolveCommand(registry, positionals)`
240
252
 
241
253
  Resolves a command from already parsed positional arguments.
package/CHANGELOG.md DELETED
@@ -1,121 +0,0 @@
1
- # Changelog
2
-
3
- All notable user-facing changes to this package are documented here.
4
-
5
- This file was reconstructed from npm publish metadata and local git history.
6
- Older releases did not have a maintained changelog, so early entries are
7
- intentionally conservative.
8
-
9
- ## 1.0.13 - Unreleased
10
-
11
- ### Added
12
-
13
- - Added machine-readable `IcoreError` codes and details.
14
- - Added opt-in `strict: true` command resolution for rejecting options before command paths.
15
- - Added `strict: true` support to direct `runCommand` execution.
16
- - Added typed prepared command `payload` returned from `prepare` and passed to `handle`.
17
- - Added this changelog.
18
-
19
- ### Changed
20
-
21
- - Boolean options reject explicit values such as `--flag=true` and `--flag=false`; use `--flag` and `--no-flag`.
22
-
23
- ## 1.0.12 - 2026-07-02
24
-
25
- - Replaced the preliminary flag-only boolean option naming with `syntax: 'flag'`.
26
- - Documented flag-only boolean option behavior.
27
-
28
- ## 1.0.11 - 2026-07-02
29
-
30
- - Added preliminary flag-only boolean option support.
31
-
32
- ## 1.0.10 - 2026-07-02
33
-
34
- - Added two-phase command execution.
35
- - Added `PreparedCommandInput`.
36
- - Added `PreparedCommand`.
37
- - Added `prepareCommandFromArgs`.
38
- - Added `runPreparedCommand`.
39
- - Added command `metadata`.
40
- - Added command `prepare` hook.
41
- - Changed `runCommand` and `runCommandFromRegistry` to use the prepare-and-run flow internally.
42
- - Added focused tests for prepare-time validation and handler safety.
43
-
44
- ## 1.0.9 - 2026-07-02
45
-
46
- - Refined npm package metadata.
47
- - Updated repository metadata for npm.
48
- - Simplified published package contents.
49
-
50
- ## 1.0.8 - 2026-07-02
51
-
52
- - Updated package author metadata.
53
- - Normalized README heading structure.
54
-
55
- ## 1.0.7 - 2026-07-02
56
-
57
- - Renamed README examples from `upper` to `uppercase`.
58
- - Cleaned duplicated command test coverage without changing public behavior.
59
-
60
- ## 1.0.6 - 2026-07-02
61
-
62
- - Added explicit long boolean values such as `--flag=true` and `--flag=false`.
63
- - Added schema-known boolean negation such as `--no-flag`.
64
- - Added short option aliases such as `-f` and `-n value`.
65
- - Added alias validation and duplicate detection between short and long option forms.
66
- - Documented supported option syntax.
67
-
68
- ## 1.0.5 - 2026-07-01
69
-
70
- - Rebuilt README as the main public documentation entry point.
71
- - Removed separate generated reference docs from the published documentation flow.
72
-
73
- ## 1.0.4 - 2026-07-01
74
-
75
- - Reorganized README and documentation references.
76
-
77
- ## 1.0.3 - 2026-07-01
78
-
79
- - Added README table of contents.
80
- - Polished README formatting and emphasis.
81
-
82
- ## 1.0.2 - 2026-06-30
83
-
84
- - Clarified CLI scope and supported syntax in README.
85
- - Added module boundary comments to production source files.
86
- - Updated package description and keywords.
87
-
88
- ## 1.0.1 - 2026-06-30
89
-
90
- - Published documentation updates after the first stable release.
91
- - No dedicated version commit is present in local git history for this patch.
92
-
93
- ## 1.0.0 - 2026-06-30
94
-
95
- - First stable release of the new `icore` CLI mechanics package.
96
- - Added declarative option parsing and validation.
97
- - Added schema-aware argv parsing.
98
- - Added option presence metadata through `parseOptionsDetailed`.
99
- - Added option schema composition through `mergeOptionsSchema`.
100
- - Added command registry routing.
101
- - Added typed command handler input.
102
- - Added CommonJS package entry points and TypeScript declarations.
103
- - Lowered the runtime Node.js engine to `>=16.9.0`.
104
-
105
- ## 1.0.0-alpha - 2026-06-28
106
-
107
- - Started the new CLI mechanics codebase after pruning the legacy package code.
108
- - Added the initial TypeScript build, test, and lint setup for the new package.
109
-
110
- ## 0.1.38 - 2019-06-12
111
-
112
- - Final legacy web-framework line release.
113
- - Added legacy tests and documentation.
114
- - Updated the legacy package description.
115
- - Trimmed legacy runtime dependencies.
116
-
117
- ## 0.0.37 and earlier
118
-
119
- - Original legacy npm package line published between 2017 and 2019.
120
- - Legacy history is preserved for package provenance.
121
- - Detailed changelog entries were not maintained for these releases.