@crustjs/core 0.0.10 → 0.0.11
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/index.d.ts +20 -13
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -377,7 +377,7 @@ type MergeFlags<
|
|
|
377
377
|
type EffectiveFlags<
|
|
378
378
|
Inherited extends FlagsDef,
|
|
379
379
|
Local extends FlagsDef
|
|
380
|
-
> = MergeFlags<InheritableFlags<Inherited>, Local>;
|
|
380
|
+
> = string extends keyof Inherited ? Local : MergeFlags<InheritableFlags<Inherited>, Local>;
|
|
381
381
|
/**
|
|
382
382
|
* Infer the resolved type for a single ArgDef:
|
|
383
383
|
*
|
|
@@ -615,6 +615,7 @@ declare const VALIDATION_MODE_ENV = "CRUST_INTERNAL_VALIDATE_ONLY";
|
|
|
615
615
|
* - `Inherited` — flags inherited from a parent command (populated by `.command()`)
|
|
616
616
|
* - `Local` — flags defined on this command via `.flags()`
|
|
617
617
|
* - `A` — positional argument definitions
|
|
618
|
+
* - `Eff` — effective flags (merged inherited + local flags, computed internally)
|
|
618
619
|
*
|
|
619
620
|
* @example
|
|
620
621
|
* ```ts
|
|
@@ -631,13 +632,15 @@ declare const VALIDATION_MODE_ENV = "CRUST_INTERNAL_VALIDATE_ONLY";
|
|
|
631
632
|
declare class Crust<
|
|
632
633
|
Inherited extends FlagsDef = FlagsDef,
|
|
633
634
|
Local extends FlagsDef = FlagsDef,
|
|
634
|
-
A extends ArgsDef = ArgsDef
|
|
635
|
+
A extends ArgsDef = ArgsDef,
|
|
636
|
+
Eff extends FlagsDef = EffectiveFlags<Inherited, Local>
|
|
635
637
|
> {
|
|
636
638
|
/** @internal — Phantom property exposing generic parameters for type-level testing */
|
|
637
639
|
readonly _types: {
|
|
638
640
|
inherited: Inherited;
|
|
639
641
|
local: Local;
|
|
640
642
|
args: A;
|
|
643
|
+
effective: Eff;
|
|
641
644
|
};
|
|
642
645
|
/** @internal */
|
|
643
646
|
readonly _node: CommandNode;
|
|
@@ -654,7 +657,7 @@ declare class Crust<
|
|
|
654
657
|
* @internal — Create a child builder with pre-populated inherited flags.
|
|
655
658
|
* Used by `.command()` to propagate parent flags to the child.
|
|
656
659
|
*/
|
|
657
|
-
static _createChild<I extends FlagsDef>(name: string, inheritedFlags: FlagsDef): Crust<I, {}, []
|
|
660
|
+
static _createChild<I extends FlagsDef>(name: string, inheritedFlags: FlagsDef): Crust<I, {}, [], EffectiveFlags<I, {}>>;
|
|
658
661
|
/**
|
|
659
662
|
* @internal — Clone this builder with a new node, preserving generics.
|
|
660
663
|
*/
|
|
@@ -671,18 +674,22 @@ declare class Crust<
|
|
|
671
674
|
* @param meta - Metadata fields to set (description, usage)
|
|
672
675
|
* @returns A new `Crust` instance with updated metadata
|
|
673
676
|
*/
|
|
674
|
-
meta(meta: Omit<CommandMeta, "name">): Crust<Inherited, Local, A>;
|
|
677
|
+
meta(meta: Omit<CommandMeta, "name">): Crust<Inherited, Local, A, Eff>;
|
|
675
678
|
/**
|
|
676
679
|
* Define local flags for this command.
|
|
677
680
|
*
|
|
678
681
|
* Returns a new builder with updated local flag types. The original
|
|
679
682
|
* builder is not mutated.
|
|
680
683
|
*
|
|
684
|
+
* NOTE: Compile-time inherited/local cross-collision checks are intentionally
|
|
685
|
+
* omitted here to reduce TypeScript type-check cost in large projects.
|
|
686
|
+
* Runtime collision checks still run during parsing and command-tree validation.
|
|
687
|
+
*
|
|
681
688
|
* @param defs - Flag definitions record
|
|
682
689
|
* @returns A new `Crust` instance with the given flags
|
|
683
690
|
* @throws {CrustError} `DEFINITION` if flag names/aliases violate constraints
|
|
684
691
|
*/
|
|
685
|
-
flags<const F extends FlagsDef>(defs: F & ValidateNoPrefixedFlags<ValidateFlagAliases<F>>
|
|
692
|
+
flags<const F extends FlagsDef>(defs: F & ValidateNoPrefixedFlags<ValidateFlagAliases<F>>): Crust<Inherited, F, A, EffectiveFlags<Inherited, F>>;
|
|
686
693
|
/**
|
|
687
694
|
* Define positional arguments for this command.
|
|
688
695
|
*
|
|
@@ -692,7 +699,7 @@ declare class Crust<
|
|
|
692
699
|
* @param defs - Ordered tuple of positional argument definitions
|
|
693
700
|
* @returns A new `Crust` instance with the given args
|
|
694
701
|
*/
|
|
695
|
-
args<const NewA extends ArgsDef>(defs: NewA & ValidateVariadicArgs<NewA>): Crust<Inherited, Local, NewA>;
|
|
702
|
+
args<const NewA extends ArgsDef>(defs: NewA & ValidateVariadicArgs<NewA>): Crust<Inherited, Local, NewA, Eff>;
|
|
696
703
|
/**
|
|
697
704
|
* Set the main command handler.
|
|
698
705
|
*
|
|
@@ -706,7 +713,7 @@ declare class Crust<
|
|
|
706
713
|
* @param handler - The main command handler function
|
|
707
714
|
* @returns A new `Crust` instance with the handler registered
|
|
708
715
|
*/
|
|
709
|
-
run(handler: (ctx: NoInfer<CrustCommandContext<A,
|
|
716
|
+
run(handler: (ctx: NoInfer<CrustCommandContext<A, Eff>>) => void | Promise<void>): Crust<Inherited, Local, A, Eff>;
|
|
710
717
|
/**
|
|
711
718
|
* Set the pre-run lifecycle hook.
|
|
712
719
|
*
|
|
@@ -716,7 +723,7 @@ declare class Crust<
|
|
|
716
723
|
* @param handler - The pre-run handler function
|
|
717
724
|
* @returns A new `Crust` instance with the preRun handler registered
|
|
718
725
|
*/
|
|
719
|
-
preRun(handler: (ctx: NoInfer<CrustCommandContext<A,
|
|
726
|
+
preRun(handler: (ctx: NoInfer<CrustCommandContext<A, Eff>>) => void | Promise<void>): Crust<Inherited, Local, A, Eff>;
|
|
720
727
|
/**
|
|
721
728
|
* Set the post-run lifecycle hook.
|
|
722
729
|
*
|
|
@@ -726,7 +733,7 @@ declare class Crust<
|
|
|
726
733
|
* @param handler - The post-run handler function
|
|
727
734
|
* @returns A new `Crust` instance with the postRun handler registered
|
|
728
735
|
*/
|
|
729
|
-
postRun(handler: (ctx: NoInfer<CrustCommandContext<A,
|
|
736
|
+
postRun(handler: (ctx: NoInfer<CrustCommandContext<A, Eff>>) => void | Promise<void>): Crust<Inherited, Local, A, Eff>;
|
|
730
737
|
/**
|
|
731
738
|
* Register a plugin on this command.
|
|
732
739
|
*
|
|
@@ -740,7 +747,7 @@ declare class Crust<
|
|
|
740
747
|
* @param plugin - The plugin to register
|
|
741
748
|
* @returns A new `Crust` instance with the plugin registered
|
|
742
749
|
*/
|
|
743
|
-
use(plugin: CrustPlugin): Crust<Inherited, Local, A>;
|
|
750
|
+
use(plugin: CrustPlugin): Crust<Inherited, Local, A, Eff>;
|
|
744
751
|
/**
|
|
745
752
|
* Create a subcommand builder pre-typed with this command's inheritable flags.
|
|
746
753
|
*
|
|
@@ -773,7 +780,7 @@ declare class Crust<
|
|
|
773
780
|
* app.command(deployCmd).execute();
|
|
774
781
|
* ```
|
|
775
782
|
*/
|
|
776
|
-
sub<N extends string>(name: N): Crust<
|
|
783
|
+
sub<N extends string>(name: N): Crust<Eff, {}, [], EffectiveFlags<Eff, {}>>;
|
|
777
784
|
/**
|
|
778
785
|
* Register a named subcommand via inline callback.
|
|
779
786
|
*
|
|
@@ -786,7 +793,7 @@ declare class Crust<
|
|
|
786
793
|
* @returns A new `Crust` instance with the subcommand registered
|
|
787
794
|
* @throws {CrustError} `DEFINITION` if name is empty or already registered
|
|
788
795
|
*/
|
|
789
|
-
command<N extends string>(name: N, cb: (cmd: Crust<
|
|
796
|
+
command<N extends string>(name: N, cb: (cmd: Crust<Eff, {}, [], EffectiveFlags<Eff, {}>>) => Crust<any, any, any>): Crust<Inherited, Local, A, Eff>;
|
|
790
797
|
/**
|
|
791
798
|
* Register a pre-built subcommand builder (from `.sub()`).
|
|
792
799
|
*
|
|
@@ -798,7 +805,7 @@ declare class Crust<
|
|
|
798
805
|
* @returns A new `Crust` instance with the subcommand registered
|
|
799
806
|
* @throws {CrustError} `DEFINITION` if builder name is empty or already registered
|
|
800
807
|
*/
|
|
801
|
-
command(builder: Crust<any, any, any>): Crust<Inherited, Local, A>;
|
|
808
|
+
command(builder: Crust<any, any, any>): Crust<Inherited, Local, A, Eff>;
|
|
802
809
|
/**
|
|
803
810
|
* Parse `process.argv`, resolve subcommands, run plugins and middleware,
|
|
804
811
|
* and execute the matched command handler.
|