@h3ravel/musket 0.3.5 → 0.3.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/dist/index.cjs CHANGED
@@ -638,7 +638,7 @@ var Musket = class Musket {
638
638
  * CLI Commands auto registration
639
639
  */
640
640
  for await (const pth of glob.glob.stream(paths)) {
641
- const name = node_path.default.basename(pth).replace(".js", "").replace(".ts", "");
641
+ const name = node_path.default.basename(pth).replaceAll(/\.ts|\.js|\.mjs/g, "");
642
642
  try {
643
643
  const cmdClass = (await import(pth))[name];
644
644
  commands.push(new cmdClass(this.app, this.kernel));
@@ -1,7 +1,7 @@
1
1
  import * as commander0 from "commander";
2
2
  import { Argument, Command as Command$1 } from "commander";
3
3
  import { ChoiceOrSeparatorArray, Choices } from "@h3ravel/shared";
4
- import { Options } from "tsdown";
4
+ import { UserConfig } from "tsdown";
5
5
  import { XGeneric } from "@h3ravel/support";
6
6
 
7
7
  //#region src/Contracts/ICommand.d.ts
@@ -79,7 +79,7 @@ interface InitConfig {
79
79
  /**
80
80
  * If we need to programmatically run the tsdown build command, we will use this config.
81
81
  */
82
- tsDownConfig?: Options;
82
+ tsDownConfig?: UserConfig;
83
83
  /**
84
84
  * Packages that should show up up when the `-V` flag is passed
85
85
  */
@@ -182,7 +182,7 @@ declare class Command {
182
182
  option(key: string, def?: any): any;
183
183
  options(key?: string): any;
184
184
  argument(key: string, def?: any): any;
185
- arguments(): any;
185
+ arguments(): Record<string, any>;
186
186
  loadBaseFlags(): void;
187
187
  /**
188
188
  * Check if the command is quiet
@@ -255,7 +255,7 @@ declare class Command {
255
255
  /**
256
256
  * The default value
257
257
  */
258
- def?: string | undefined): any;
258
+ def?: string | undefined): Promise<string>;
259
259
  /**
260
260
  * Allows users to pick from a predefined set of choices when asked a question.
261
261
  */
@@ -271,7 +271,7 @@ declare class Command {
271
271
  /**
272
272
  * Item index front of which the cursor will initially appear
273
273
  */
274
- defaultIndex?: number): any;
274
+ defaultIndex?: number): Promise<string>;
275
275
  /**
276
276
  * Ask the user for a simple "yes or no" confirmation. By default, this method returns `false`.
277
277
  * However, if the user enters y or yes in response to the prompt, the method would return `true`.
@@ -284,7 +284,7 @@ declare class Command {
284
284
  /**
285
285
  * The default value
286
286
  */
287
- def?: boolean | undefined): any;
287
+ def?: boolean | undefined): Promise<boolean>;
288
288
  /**
289
289
  * Prompt the user with the given question, accept their input which will
290
290
  * not be visible to them as they type in the console, and then return the user's input back to your command.
@@ -299,7 +299,7 @@ declare class Command {
299
299
  *
300
300
  * @default true
301
301
  */
302
- mask?: string | boolean): any;
302
+ mask?: string | boolean): Promise<string>;
303
303
  /**
304
304
  * Provide auto-completion for possible choices. The user can still provide any
305
305
  * answer, regardless of the auto-completion hints.
@@ -316,7 +316,7 @@ declare class Command {
316
316
  /**
317
317
  * Set a default value
318
318
  */
319
- def?: string): any;
319
+ def?: string): Promise<any>;
320
320
  }
321
321
  //#endregion
322
322
  //#region src/Musket.d.ts
@@ -334,7 +334,7 @@ declare class Musket {
334
334
  cliName: string;
335
335
  private config;
336
336
  private commands;
337
- constructor(app: Application, kernel: Kernel, baseCommands?: Command[], resolver?: NonNullable<InitConfig["resolver"]> | undefined, tsDownConfig?: Options);
337
+ constructor(app: Application, kernel: Kernel, baseCommands?: Command[], resolver?: NonNullable<InitConfig["resolver"]> | undefined, tsDownConfig?: UserConfig);
338
338
  build(): Promise<Command$1>;
339
339
  private loadBaseCommands;
340
340
  /**
@@ -614,7 +614,7 @@ var Musket = class Musket {
614
614
  * CLI Commands auto registration
615
615
  */
616
616
  for await (const pth of glob.stream(paths)) {
617
- const name = path.basename(pth).replace(".js", "").replace(".ts", "");
617
+ const name = path.basename(pth).replaceAll(/\.ts|\.js|\.mjs/g, "");
618
618
  try {
619
619
  const cmdClass = (await import(pth))[name];
620
620
  commands.push(new cmdClass(this.app, this.kernel));
package/package.json CHANGED
@@ -1,18 +1,22 @@
1
1
  {
2
2
  "name": "@h3ravel/musket",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "description": "Musket CLI is a framework-agnostic CLI framework designed to allow you build artisan-like CLI apps and for use in the H3ravel framework.",
5
5
  "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
6
9
  "exports": {
7
10
  ".": {
8
- "import": "./dist/index.mjs",
11
+ "import": "./dist/index.js",
9
12
  "require": "./dist/index.cjs"
10
- }
13
+ },
14
+ "./package.json": "./package.json"
11
15
  },
12
16
  "typesVersions": {
13
17
  "*": {
14
18
  "*": [
15
- "dist/index.d.mts"
19
+ "dist/index.d.ts"
16
20
  ]
17
21
  }
18
22
  },
@@ -46,7 +50,7 @@
46
50
  "console"
47
51
  ],
48
52
  "peerDependencies": {
49
- "@h3ravel/support": "^0.15.2"
53
+ "@h3ravel/support": "^0.15.4"
50
54
  },
51
55
  "devDependencies": {
52
56
  "@types/node": "^24.7.2",
@@ -62,7 +66,7 @@
62
66
  "vitest": "^3.2.4"
63
67
  },
64
68
  "dependencies": {
65
- "@h3ravel/shared": "^0.27.2",
69
+ "@h3ravel/shared": "^0.27.4",
66
70
  "chalk": "^5.6.2",
67
71
  "commander": "^14.0.1",
68
72
  "dayjs": "^1.11.18",
package/dist/index.d.mts DELETED
@@ -1,398 +0,0 @@
1
- import { ChoiceOrSeparatorArray, Choices } from "@h3ravel/shared";
2
- import * as commander0 from "commander";
3
- import { Argument, Command as Command$1 } from "commander";
4
- import { Options } from "tsdown";
5
- import { XGeneric } from "@h3ravel/support";
6
-
7
- //#region src/Contracts/ICommand.d.ts
8
- type CommandOption = {
9
- name: string;
10
- shared?: boolean;
11
- required?: boolean;
12
- multiple?: boolean;
13
- placeholder?: string;
14
- description?: string;
15
- defaultValue?: string | number | boolean | undefined | string[];
16
- choices?: string[];
17
- argParser?: (...args: []) => any;
18
- /**
19
- * for options like --Q|queue
20
- */
21
- flags?: string[];
22
- /**
23
- * true if it's a flag option
24
- */
25
- isFlag?: boolean;
26
- /**
27
- * true if name begins with '#' or '^'
28
- */
29
- isHidden?: boolean;
30
- /**
31
- * for nested options
32
- */
33
- nestedOptions?: CommandOption[];
34
- };
35
- type ParsedCommand = {
36
- commandClass: Command;
37
- baseCommand: string;
38
- description?: string;
39
- /**
40
- * true if baseCommand begins with '#' or '^'
41
- */
42
- isHidden?: boolean;
43
- /**
44
- * true if baseCommand ends with ':'
45
- */
46
- isNamespaceCommand: boolean;
47
- /**
48
- * for colon-ended commands
49
- */
50
- subCommands?: CommandOption[];
51
- /**
52
- * for normal commands
53
- */
54
- options?: CommandOption[];
55
- };
56
- interface InitConfig {
57
- /**
58
- * ASCII Art style logo
59
- */
60
- logo?: string;
61
- /**
62
- * The name of the CLI app we're building
63
- *
64
- * @default musket
65
- */
66
- cliName?: string;
67
- /**
68
- * Don't parse the command, usefull for testing or manual control
69
- */
70
- skipParsing?: boolean;
71
- /**
72
- * A callback function that should resolve the handle method of every command
73
- *
74
- * @param cmd
75
- * @param met
76
- * @returns
77
- */
78
- resolver?: <X extends Command>(cmd: X, met: any) => Promise<X>;
79
- /**
80
- * If we need to programmatically run the tsdown build command, we will use this config.
81
- */
82
- tsDownConfig?: Options;
83
- /**
84
- * Packages that should show up up when the `-V` flag is passed
85
- */
86
- packages?: (string | {
87
- name: string;
88
- alias: string;
89
- })[];
90
- /**
91
- * If set to true, information about musket CLI like name and
92
- * version info will not be unexpectedly shown in console
93
- */
94
- hideMusketInfo?: boolean;
95
- /**
96
- * If enabled rebuilds will be triggered when code changes happen
97
- */
98
- allowRebuilds?: boolean;
99
- /**
100
- * Commands that should be autoloaded by default
101
- */
102
- baseCommands?: typeof Command[];
103
- /**
104
- * A command that will be run when the script is run without arguments
105
- */
106
- rootCommand?: typeof Command;
107
- /**
108
- * Paths where musket can search and auto discover commands
109
- *
110
- *
111
- * @example 'Console/Commands/*.js'
112
- * @example 'dist/app/Console/Commands/*.js'
113
- * @example ['Console/Commands/*.js', 'src/app/Commands/*.js']
114
- */
115
- discoveryPaths?: string | string[];
116
- }
117
- //#endregion
118
- //#region src/Core/Kernel.d.ts
119
- declare class Kernel {
120
- app: Application;
121
- cwd: string;
122
- output: "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function";
123
- modules: XGeneric<{
124
- version: string;
125
- name: string;
126
- }>[];
127
- basePath: string;
128
- packages: NonNullable<InitConfig['packages']>;
129
- config: InitConfig;
130
- constructor(app: Application);
131
- ensureDirectoryExists(dir: string): Promise<void>;
132
- static init(app: Application, config?: InitConfig): Promise<commander0.Command>;
133
- private run;
134
- private loadRequirements;
135
- }
136
- //#endregion
137
- //#region src/Core/Command.d.ts
138
- declare class Command {
139
- protected app: Application;
140
- protected kernel: Kernel;
141
- constructor(app: Application, kernel: Kernel);
142
- /**
143
- * The underlying commander instance.
144
- *
145
- * @var Command
146
- */
147
- program: Command$1;
148
- /**
149
- * The name and signature of the console command.
150
- *
151
- * @var string
152
- */
153
- protected signature: string;
154
- /**
155
- * A dictionary of signatures or what not.
156
- *
157
- * @var object
158
- */
159
- protected dictionary: Record<string, any>;
160
- /**
161
- * The console command description.
162
- *
163
- * @var string
164
- */
165
- protected description?: string;
166
- /**
167
- * The console command input.
168
- *
169
- * @var object
170
- */
171
- private input;
172
- /**
173
- * Execute the console command.
174
- */
175
- handle(..._args: any[]): Promise<void>;
176
- setApplication(app: Application): void;
177
- setInput(options: XGeneric, args: string[], regArgs: readonly Argument[], dictionary: Record<string, any>, program: Command$1): this;
178
- setOption(key: string, value: unknown): this;
179
- setProgram(program: Command$1): this;
180
- getSignature(): string;
181
- getDescription(): string | undefined;
182
- option(key: string, def?: any): any;
183
- options(key?: string): any;
184
- argument(key: string, def?: any): any;
185
- arguments(): any;
186
- loadBaseFlags(): void;
187
- /**
188
- * Check if the command is quiet
189
- *
190
- * @returns
191
- */
192
- isQuiet(): any;
193
- /**
194
- * Check if the command is silent
195
- *
196
- * @returns
197
- */
198
- isSilent(): any;
199
- /**
200
- * Check if the command is non interactive
201
- *
202
- * @returns
203
- */
204
- isNonInteractive(): boolean;
205
- /**
206
- * Get the verbosity of the command
207
- *
208
- * @returns
209
- */
210
- getVerbosity(): number;
211
- /**
212
- * Log an info message
213
- */
214
- info(message: string): this;
215
- /**
216
- * Log a warning message
217
- */
218
- warn(message: string): this;
219
- /**
220
- * Log a line message
221
- */
222
- line(message: string): this;
223
- /**
224
- * Log a new line
225
- */
226
- newLine(count?: number): this;
227
- /**
228
- * Log a success message
229
- */
230
- success(message: string): this;
231
- /**
232
- * Log an error message
233
- */
234
- error(message: string): this;
235
- /**
236
- * Log an error message and terminate execution of the command
237
- * return an exit code of 1
238
- *
239
- * This method is not chainable
240
- */
241
- fail(message: string): void;
242
- /**
243
- * Log a debug message
244
- */
245
- debug(message: string | string[]): this;
246
- /**
247
- * Prompt the user with the given question, accept their input, and
248
- * then return the user's input back to your command.
249
- */
250
- ask(
251
- /**
252
- * Message to dislpay
253
- */
254
- message: string,
255
- /**
256
- * The default value
257
- */
258
- def?: string | undefined): any;
259
- /**
260
- * Allows users to pick from a predefined set of choices when asked a question.
261
- */
262
- choice(
263
- /**
264
- * Message to dislpay
265
- */
266
- message: string,
267
- /**
268
- * The choices available to the user
269
- */
270
- choices: Choices,
271
- /**
272
- * Item index front of which the cursor will initially appear
273
- */
274
- defaultIndex?: number): any;
275
- /**
276
- * Ask the user for a simple "yes or no" confirmation. By default, this method returns `false`.
277
- * However, if the user enters y or yes in response to the prompt, the method would return `true`.
278
- */
279
- confirm(
280
- /**
281
- * Message to dislpay
282
- */
283
- message: string,
284
- /**
285
- * The default value
286
- */
287
- def?: boolean | undefined): any;
288
- /**
289
- * Prompt the user with the given question, accept their input which will
290
- * not be visible to them as they type in the console, and then return the user's input back to your command.
291
- */
292
- secret(
293
- /**
294
- * Message to dislpay
295
- */
296
- message: string,
297
- /**
298
- * Mask the user input
299
- *
300
- * @default true
301
- */
302
- mask?: string | boolean): any;
303
- /**
304
- * Provide auto-completion for possible choices. The user can still provide any
305
- * answer, regardless of the auto-completion hints.
306
- */
307
- anticipate(
308
- /**
309
- * Message to dislpay
310
- */
311
- message: string,
312
- /**
313
- * The source of completions
314
- */
315
- source: string[] | ((input?: string | undefined) => Promise<ChoiceOrSeparatorArray<any>>),
316
- /**
317
- * Set a default value
318
- */
319
- def?: string): any;
320
- }
321
- //#endregion
322
- //#region src/Musket.d.ts
323
- declare class Musket {
324
- private app;
325
- private kernel;
326
- private baseCommands;
327
- private resolver?;
328
- private tsDownConfig;
329
- /**
330
- * The name of the CLI app we're building
331
- *
332
- * @default musket
333
- */
334
- cliName: string;
335
- private config;
336
- private commands;
337
- constructor(app: Application, kernel: Kernel, baseCommands?: Command[], resolver?: NonNullable<InitConfig["resolver"]> | undefined, tsDownConfig?: Options);
338
- build(): Promise<Command$1>;
339
- private loadBaseCommands;
340
- /**
341
- * Provide the configuration to initialize the CLI with
342
- *
343
- * @param config
344
- * @returns
345
- */
346
- configure(config: InitConfig): this;
347
- /**
348
- * Set the paths where the cli can search and auto discover commands
349
- *
350
- * @param paths
351
- *
352
- * @example instance.discoverCommandsFrom('Console/Commands/*.js')
353
- * @example instance.discoverCommandsFrom(['Console/Commands/*.js', 'App/Commands/*.js'])
354
- *
355
- * @returns the current cli intance
356
- */
357
- discoverCommandsFrom(paths: string | string[]): this;
358
- private loadDiscoveredCommands;
359
- addCommand(command: Command): void;
360
- private initialize;
361
- rebuild(name: string): Promise<void>;
362
- private makeOption;
363
- private handle;
364
- static parse(kernel: Kernel, config?: InitConfig): Promise<Command$1>;
365
- }
366
- //#endregion
367
- //#region src/Contracts/Application.d.ts
368
- declare class Application {
369
- /**
370
- * The current musket CLI Instance
371
- */
372
- musket?: Musket;
373
- /**
374
- * Registered commands will be preloaded
375
- */
376
- registeredCommands?: typeof Command[];
377
- }
378
- //#endregion
379
- //#region src/Signature.d.ts
380
- declare class Signature {
381
- /**
382
- * Helper to parse options inside a block of text
383
- *
384
- * @param block
385
- * @returns
386
- */
387
- static parseOptions(block: string): CommandOption[];
388
- /**
389
- * Helper to parse a command's signature
390
- *
391
- * @param signature
392
- * @param commandClass
393
- * @returns
394
- */
395
- static parseSignature(signature: string, commandClass: Command): ParsedCommand;
396
- }
397
- //#endregion
398
- export { Application, Command, CommandOption, InitConfig, Kernel, Musket, ParsedCommand, Signature };