@visulima/cerebro 3.0.0-alpha.11 → 3.0.0-alpha.13

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/LICENSE.md +471 -4345
  3. package/README.md +26 -0
  4. package/dist/commands/completion-command.d.ts +6 -5
  5. package/dist/commands/help-command.d.ts +9 -9
  6. package/dist/commands/help-command.js +63 -1
  7. package/dist/commands/readme-command.d.ts +6 -5
  8. package/dist/commands/readme-command.js +1 -1
  9. package/dist/commands/version-command.d.ts +4 -3
  10. package/dist/index.d.ts +422 -95
  11. package/dist/index.js +2 -1
  12. package/dist/logger/create-pail-logger.d.ts +779 -8
  13. package/dist/packem_shared/{Cerebro-CXEIHSN2.js → Cerebro-C1h3DXwy.js} +66 -8
  14. package/dist/packem_shared/{index-DNXLgme3.js → index--1UArng3.js} +1 -2
  15. package/dist/packem_shared/index.d-Br8HpP0A.d.ts +93 -0
  16. package/dist/packem_shared/lazyNamed-B278Tf9_.js +6 -0
  17. package/dist/packem_shared/plugin-manager.d-Du-YXFui.d.ts +541 -0
  18. package/dist/plugins/error-handler-plugin.d.ts +21 -19
  19. package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
  20. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +21 -8
  21. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -2
  22. package/dist/util/general/compile-cache.d.ts +38 -38
  23. package/dist/util/general/heap-tuning.d.ts +14 -77
  24. package/package.json +18 -18
  25. package/dist/cli.d.ts +0 -225
  26. package/dist/constants.d.ts +0 -29
  27. package/dist/default-env.d.ts +0 -7
  28. package/dist/default-options.d.ts +0 -3
  29. package/dist/empty-toolbox.d.ts +0 -16
  30. package/dist/errors/cerebro-error.d.ts +0 -10
  31. package/dist/errors/command-not-found-error.d.ts +0 -9
  32. package/dist/errors/command-validation-error.d.ts +0 -10
  33. package/dist/errors/completion-error.d.ts +0 -9
  34. package/dist/errors/conflicting-options-error.d.ts +0 -10
  35. package/dist/errors/plugin-error.d.ts +0 -9
  36. package/dist/errors/update-notifier-error.d.ts +0 -7
  37. package/dist/plugin-manager.d.ts +0 -53
  38. package/dist/plugins/update-notifier/cache.d.ts +0 -11
  39. package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
  40. package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
  41. package/dist/types/cli.d.ts +0 -113
  42. package/dist/types/command-line-usage.d.ts +0 -37
  43. package/dist/types/command.d.ts +0 -136
  44. package/dist/types/option-types.d.ts +0 -83
  45. package/dist/types/options.d.ts +0 -4
  46. package/dist/types/plugin.d.ts +0 -53
  47. package/dist/types/toolbox.d.ts +0 -120
  48. package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
  49. package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
  50. package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
  51. package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
  52. package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
  53. package/dist/util/command-line-commands.d.ts +0 -10
  54. package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
  55. package/dist/util/command-line-usage/index.d.ts +0 -3
  56. package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
  57. package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
  58. package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
  59. package/dist/util/command-processing/command-processor.d.ts +0 -37
  60. package/dist/util/command-processing/command-validation.d.ts +0 -17
  61. package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
  62. package/dist/util/command-processing/option-processor.d.ts +0 -44
  63. package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
  64. package/dist/util/data-processing/merge-arguments.d.ts +0 -7
  65. package/dist/util/general/find-alternatives.d.ts +0 -8
  66. package/dist/util/general/hide-bin.d.ts +0 -2
  67. package/dist/util/general/parse-raw-command.d.ts +0 -7
  68. package/dist/util/general/register-exception-handler.d.ts +0 -9
  69. package/dist/util/general/runtime-process.d.ts +0 -65
  70. package/dist/util/general/semver-gt.d.ts +0 -2
  71. package/dist/util/general/validate-input.d.ts +0 -24
  72. package/dist/util/process-env-variables.d.ts +0 -9
  73. package/dist/util/security.d.ts +0 -58
  74. package/dist/util/text-processing/template-format.d.ts +0 -5
@@ -0,0 +1,541 @@
1
+ import { TableOptions } from '@visulima/tabular';
2
+ /**
3
+ * Definition for a command-line option.
4
+ */
5
+ interface OptionDefinition$1 {
6
+ /**
7
+ * A getopt-style short option name. Can be any single character except a digit or hyphen.
8
+ */
9
+ alias?: string;
10
+ /**
11
+ * Any values unaccounted for by an option definition will be set on the `defaultOption`. This flag is typically set
12
+ * on the most commonly-used option to enable more concise usage.
13
+ */
14
+ defaultOption?: boolean;
15
+ /**
16
+ * An initial value for the option.
17
+ */
18
+ defaultValue?: any;
19
+ /**
20
+ * One or more group names the option belongs to.
21
+ */
22
+ group?: string | string[];
23
+ /**
24
+ * Identical to `multiple` but with greedy parsing disabled.
25
+ */
26
+ lazyMultiple?: boolean;
27
+ /**
28
+ * Set this flag if the option accepts multiple values. In the output, you will receive an array of values each passed through the `type` function.
29
+ */
30
+ multiple?: boolean;
31
+ /**
32
+ * The long option name.
33
+ */
34
+ name: string;
35
+ /**
36
+ * A setter function (you receive the output from this) enabling you to be specific about the type and value received. Typical values
37
+ * are `String` (the default), `Number` and `Boolean` but you can use a custom function. If no option value was set you will receive `null`.
38
+ */
39
+ type?: (input: string) => any;
40
+ }
41
+ /** A Content section comprises a header and one or more lines of content. */
42
+ interface Content {
43
+ /**
44
+ * Overloaded property, accepting data in one of four formats.
45
+ * 1. A single string (one line of text).
46
+ * 2. An array of strings (multiple lines of text).
47
+ * 3. An array of arrays (recordset-style data). In this case, the data will be rendered in table format.
48
+ * 4. An object with two properties - data and options. In this case, the data and options will be passed directly to the underlying table module for rendering.
49
+ */
50
+ content?: string[] | string[][] | string | {
51
+ data: string[][];
52
+ options: TableOptions;
53
+ };
54
+ /** The section header, always bold and underlined. */
55
+ header?: string;
56
+ /** Set to true to avoid indentation and wrapping. Useful for banners. */
57
+ raw?: boolean;
58
+ }
59
+ /**
60
+ * A flexible object for the many "options" objects we throw around in cerebro.
61
+ */
62
+ type Options = Record<string | symbol, unknown>;
63
+ /**
64
+ * Type-safe Toolbox interface with customizable options and environment variable types.
65
+ * @template TLogger - The logger type (defaults to Console)
66
+ * @template TOptions - The options type (defaults to Options/Record&lt;string, unknown>)
67
+ * @template TEnv - The environment variables type (defaults to Record&lt;string, unknown>)
68
+ */
69
+ interface Toolbox<TLogger extends Console = Console, TOptions extends Record<string, unknown> = Options, TEnv extends Record<string, unknown> = Record<string, unknown>> extends Cerebro.ExtensionOverrides {
70
+ /**
71
+ * The argument passed to the command.
72
+ * For example, if you run `cerebro foo bar baz`, then this will be `["foo", "bar", "baz"]`.
73
+ * @example
74
+ * ```typescript
75
+ * cli.addCommand({
76
+ * name: "copy",
77
+ * argument: {
78
+ * name: "files",
79
+ * type: String,
80
+ * description: "Files to copy"
81
+ * },
82
+ * execute: ({ argument }) => {
83
+ * // argument is an array of strings
84
+ * // argument[0] is the first file, argument[1] is the second, etc.
85
+ * argument.forEach((file) => console.log(`Copying ${file}...`));
86
+ * }
87
+ * });
88
+ * ```
89
+ */
90
+ argument: string[];
91
+ argv: ReadonlyArray<string>;
92
+ /**
93
+ * The command that is being executed.
94
+ */
95
+ command: Command;
96
+ /**
97
+ * The name of the command that is being executed.
98
+ */
99
+ commandName: string;
100
+ /**
101
+ * Environment variables processed from the command definition.
102
+ * Values are transformed according to their type definitions and default values.
103
+ * @example
104
+ * ```typescript
105
+ * // Define env types when creating command
106
+ * type MyEnv = { apiKey: string; debug: boolean };
107
+ *
108
+ * cli.addCommand({
109
+ * name: "build",
110
+ * env: [
111
+ * { name: "API_KEY", type: String },
112
+ * { name: "DEBUG", type: Boolean }
113
+ * ],
114
+ * execute: ({ env }) => {
115
+ * // env.apiKey and env.debug are now typed!
116
+ * console.log(env.apiKey, env.debug);
117
+ * }
118
+ * });
119
+ * ```
120
+ */
121
+ env: TEnv;
122
+ /** The logger instance. */
123
+ logger: TLogger;
124
+ /**
125
+ * Any optional parameters. Typically coming from command-line
126
+ * argument like this: `--force -p tsconfig-mjson`.
127
+ * @example
128
+ * ```typescript
129
+ * // Define options type for better autocomplete
130
+ * type MyOptions = {
131
+ * output?: string;
132
+ * verbose?: boolean;
133
+ * port?: number;
134
+ * };
135
+ *
136
+ * cli.addCommand({
137
+ * name: "serve",
138
+ * options: [
139
+ * { name: "output", type: String },
140
+ * { name: "verbose", type: Boolean },
141
+ * { name: "port", type: Number }
142
+ * ],
143
+ * execute: ({ options }: { options: MyOptions }) => {
144
+ * // options.output, options.verbose, options.port are typed!
145
+ * console.log(options.output, options.verbose, options.port);
146
+ * }
147
+ * });
148
+ * ```
149
+ */
150
+ options: TOptions;
151
+ /**
152
+ * Raw tokens that command-line-args could not assign to a defined
153
+ * option — typically everything after a `--` separator, since
154
+ * cerebro runs the parser with `stopAtFirstUnknown: true`.
155
+ *
156
+ * Use this for passthrough patterns like
157
+ * `my-cmd foo bar -- --flag=value --other`, where everything after
158
+ * `--` is forwarded to an inner tool (`create-vite`, a template
159
+ * runner, etc.). Empty array when there was no `--` segment.
160
+ * @example
161
+ * ```typescript
162
+ * cli.addCommand({
163
+ * name: "create",
164
+ * argument: { name: "template", type: String },
165
+ * execute: ({ argument, rawUnknown }) => {
166
+ * // `vis create vite my-app -- --template react-ts`
167
+ * // → argument === ["vite", "my-app"]
168
+ * // → rawUnknown === ["--template", "react-ts"]
169
+ * spawnSync("npm", ["create", "vite", ...rawUnknown]);
170
+ * },
171
+ * });
172
+ * ```
173
+ */
174
+ rawUnknown: ReadonlyArray<string>;
175
+ /**
176
+ * This is the instance of the CLI that is running the command.
177
+ */
178
+ runtime: Cli<TLogger>;
179
+ }
180
+ type TypeConstructor<T> = (value: unknown) => T extends (infer R)[] ? R | undefined : T | undefined;
181
+ /**
182
+ * Type constructor for environment variables.
183
+ * Environment variables are always strings (or undefined), so the transform function receives string | undefined.
184
+ */
185
+ type EnvTypeConstructor<T> = (value: string | undefined) => T extends (infer R)[] ? R | undefined : T | undefined;
186
+ type MultiplePropertyOptions<T> = T extends ReadonlyArray<unknown> ? {
187
+ lazyMultiple: true;
188
+ } | {
189
+ multiple: true;
190
+ } : unknown;
191
+ type OptionDefinition<T> = MultiplePropertyOptions<T> & Omit<OptionDefinition$1, "type|defaultValue"> & {
192
+ /**
193
+ * A string or array of strings indicating the conflicting option(s).
194
+ * Note: The default value for an option does not cause a conflict.
195
+ */
196
+ conflicts?: string[] | string;
197
+ /** An initial value for the option. */
198
+ defaultValue?: T;
199
+ /** A string describing the option. */
200
+ description?: string;
201
+ /** Option is hidden from help */
202
+ hidden?: boolean;
203
+ implies?: Record<string, unknown>; /** Specifies whether the variable is required. */
204
+ required?: boolean;
205
+ /**
206
+ * A setter function (you receive the output from this) enabling you to be specific about the type and value received. Typical values
207
+ * are `String`, `Number` and `Boolean` but you can use a custom function.
208
+ */
209
+ type?: TypeConstructor<T>;
210
+ /** A string to replace the default type string (e.g. &lt;string>). It's often more useful to set a more descriptive type label, like &lt;ms>, &lt;files>, &lt;command>, etc.. */
211
+ typeLabel?: string;
212
+ };
213
+ type ArgumentDefinition<T = unknown> = Omit<OptionDefinition<T>, "multiple|lazyMultiple|defaultOption|alias|group|defaultValue">;
214
+ /**
215
+ * Environment variable definition for commands.
216
+ * Used to document and provide type-safe access to environment variables a command supports.
217
+ * @template T The type of the environment variable value
218
+ */
219
+ interface EnvDefinition<T = string> {
220
+ /** Default value if the environment variable is not set */
221
+ defaultValue?: T;
222
+ /** A description of what the environment variable does */
223
+ description?: string;
224
+ /** Environment variable is hidden from help */
225
+ hidden?: boolean;
226
+ /** The name of the environment variable */
227
+ name: string;
228
+ /**
229
+ * A transform function to convert the string environment variable value to the desired type.
230
+ * Typical values are `String`, `Number`, `Boolean` or custom functions.
231
+ * The function receives `string | undefined` and should return the transformed value.
232
+ */
233
+ type?: EnvTypeConstructor<T>;
234
+ /** A string to replace the default type string (e.g. &lt;string>). Useful for more descriptive type labels. */
235
+ typeLabel?: string;
236
+ }
237
+ /**
238
+ * Command interface with type-safe options and environment variables.
239
+ * @template O - The option definition type
240
+ * @template TContext - The toolbox context type (allows custom typing for better autocomplete)
241
+ * @example
242
+ * ```typescript
243
+ * // Define your options type for autocomplete
244
+ * type BuildOptions = {
245
+ * output?: string;
246
+ * production?: boolean;
247
+ * watch?: boolean;
248
+ * };
249
+ *
250
+ * type BuildEnv = {
251
+ * apiKey?: string;
252
+ * debug?: boolean;
253
+ * };
254
+ *
255
+ * cli.addCommand({
256
+ * name: "build",
257
+ * options: [
258
+ * { name: "output", type: String, alias: "o" },
259
+ * { name: "production", type: Boolean },
260
+ * { name: "watch", type: Boolean }
261
+ * ],
262
+ * env: [
263
+ * { name: "API_KEY", type: String },
264
+ * { name: "DEBUG", type: Boolean }
265
+ * ],
266
+ * execute: ({ options, env }: Toolbox<Console, BuildOptions, BuildEnv>) => {
267
+ * // Full autocomplete on options and env!
268
+ * console.log(options.output, options.production, env.apiKey);
269
+ * }
270
+ * });
271
+ * ```
272
+ */
273
+ /**
274
+ * Handler signature for commands. Used by both `execute` and the resolved default export of `loader`.
275
+ */
276
+ type CommandExecute<TContext> = ((toolbox: TContext) => Promise<void>) | ((toolbox: TContext) => void);
277
+ /**
278
+ * Module shape returned by a command `loader`. The default export is the command handler.
279
+ */
280
+ interface LazyCommandModule<TContext> {
281
+ default: CommandExecute<TContext>;
282
+ }
283
+ interface Command<O extends OptionDefinition<unknown> = OptionDefinition<unknown>, TLogger extends Console = Console, TContext extends Toolbox<TLogger> = Toolbox<TLogger>> {
284
+ /** Potential other names for this command */
285
+ alias?: string[] | string;
286
+ /** Positional argument */
287
+ argument?: ArgumentDefinition;
288
+ /** The command path, an array that describes how to get to this command */
289
+ commandPath?: string[];
290
+ /** A tweet-sized summary of your command */
291
+ description?: string;
292
+ /** Environment variables supported by this command */
293
+ env?: (EnvDefinition<boolean> | EnvDefinition<number> | EnvDefinition)[];
294
+ /** The full command examples, can be multiple lines */
295
+ examples?: string[] | string[][];
296
+ /**
297
+ * The function for running your command, can be async.
298
+ * Either `execute` or `loader` must be provided (but not both).
299
+ */
300
+ execute?: CommandExecute<TContext>;
301
+ /** The path to the file name for this command. */
302
+ file?: string;
303
+ /** Group commands together under a heading */
304
+ group?: string;
305
+ /** Should your command be shown in the listings */
306
+ hidden?: boolean;
307
+ /**
308
+ * Lazily loads the command handler on first execution. The module's default export is used as the handler.
309
+ * Either `execute` or `loader` must be provided (but not both).
310
+ * Help, completion, and validation work from the metadata declared on this object and never trigger the loader.
311
+ * @example
312
+ * ```typescript
313
+ * cli.addCommand({
314
+ * name: "build",
315
+ * description: "Build the project",
316
+ * options: [{ name: "output", type: String }],
317
+ * loader: () => import("./commands/build"),
318
+ * });
319
+ *
320
+ * // commands/build.ts
321
+ * export default ({ options }) => { ... };
322
+ * ```
323
+ */
324
+ loader?: () => Promise<LazyCommandModule<TContext>>;
325
+ /** The name of your command */
326
+ name: string;
327
+ options?: (O | OptionDefinition<boolean[]> | OptionDefinition<boolean> | OptionDefinition<number[]> | OptionDefinition<number> | OptionDefinition<string[]> | OptionDefinition<string>)[];
328
+ usage?: Content[];
329
+ }
330
+ type CommandSection = {
331
+ footer?: string;
332
+ header?: string;
333
+ };
334
+ type CliRunOptions = {
335
+ [key: string]: unknown;
336
+ /**
337
+ * Whether to automatically dispose/cleanup the CLI instance after execution
338
+ * @default true
339
+ */
340
+ autoDispose?: boolean;
341
+ shouldExitProcess?: boolean;
342
+ };
343
+ type RunCommandOptions = {
344
+ /**
345
+ * Extra options to merge into the command's options.
346
+ * These will be merged with the command's default options and parsed arguments.
347
+ * Use this to override or add additional options programmatically.
348
+ * @default Empty object
349
+ */
350
+ [key: string]: unknown;
351
+ /**
352
+ * Command-line arguments to pass to the command.
353
+ * If not provided, uses the default argv from the CLI instance.
354
+ * These arguments will be parsed and merged with the command's options.
355
+ * @default Empty array
356
+ */
357
+ argv?: string[];
358
+ };
359
+ interface Cli<T extends Console> {
360
+ /**
361
+ * Add an arbitrary command to the CLI.
362
+ * @param command The command to add.
363
+ * @returns self
364
+ */
365
+ addCommand: <OD extends OptionDefinition<unknown> = OptionDefinition<unknown>>(command: Command<OD, T>) => this;
366
+ /**
367
+ * Add a global option available to all commands.
368
+ * Global options are parsed alongside command options and shown in help output.
369
+ * @param option The option definition
370
+ * @returns self
371
+ */
372
+ addGlobalOption: <V = unknown>(option: OptionDefinition<V>) => this;
373
+ /**
374
+ * Add a plugin to extend the CLI functionality
375
+ * @param plugin The plugin to add.
376
+ * @returns self
377
+ */
378
+ addPlugin: (plugin: Plugin<T>) => this;
379
+ /**
380
+ * Disposes the CLI instance and cleans up resources
381
+ * @returns void
382
+ */
383
+ dispose: () => void;
384
+ getCliName: () => string;
385
+ getCommands: () => Map<string, Command<OptionDefinition<unknown>, T>>;
386
+ getCommandSection: () => CommandSection;
387
+ getCwd: () => string;
388
+ /**
389
+ * Gets all global options (built-in + custom).
390
+ */
391
+ getGlobalOptions: () => OptionDefinition<unknown>[];
392
+ getPackageName: () => string | undefined;
393
+ getPackageVersion: () => string | undefined;
394
+ /**
395
+ * Get the plugin manager instance
396
+ * @returns The plugin manager
397
+ */
398
+ getPluginManager: () => PluginManager<T>;
399
+ run: (extraOptions?: CliRunOptions) => Promise<void>;
400
+ /**
401
+ * Runs a command programmatically from within another command.
402
+ * This allows commands to call other commands during execution.
403
+ * @param commandName The name of the command to execute
404
+ * @param options Optional options including argv and other command options
405
+ * @returns A promise that resolves with the command's result (or void if command doesn't return a value)
406
+ * @throws {Error} If the specified command doesn't exist or command arguments are invalid
407
+ * @example
408
+ * ```typescript
409
+ * cli.addCommand({
410
+ * name: 'deploy',
411
+ * execute: async ({ runtime, logger }) => {
412
+ * logger.info('Building...');
413
+ * const buildResult = await runtime.runCommand('build', { argv: ['--production'] });
414
+ * // buildResult is the return value from the build command's execute function
415
+ *
416
+ * logger.info('Testing...');
417
+ * await runtime.runCommand('test', { argv: ['--coverage'] });
418
+ * }
419
+ * });
420
+ * ```
421
+ */
422
+ runCommand: (commandName: string, options?: RunCommandOptions) => Promise<unknown>;
423
+ setCommandSection: (commandSection: CommandSection) => this;
424
+ /**
425
+ * Set a default command, to display a different command if cli is call without command.
426
+ * @param commandName
427
+ * @returns self
428
+ */
429
+ setDefaultCommand: (commandName: string) => this;
430
+ }
431
+ /**
432
+ * Any of the output types [[OUTPUT_NORMAL]], [[OUTPUT_RAW]] and [[OUTPUT_PLAIN]].
433
+ */
434
+ type OutputType = 1 | 2 | 4;
435
+ /**
436
+ * Any of the verbosity types
437
+ * [[VERBOSITY_QUIET]], [[VERBOSITY_NORMAL]], [[VERBOSITY_VERBOSE]] and [[VERBOSITY_DEBUG]].
438
+ */
439
+ type VERBOSITY_LEVEL = 16 | 32 | 64 | 128 | 256;
440
+ /**
441
+ * Context provided to plugins during initialization
442
+ */
443
+ interface PluginContext<T extends Console = Console> {
444
+ /** The CLI instance */
445
+ cli: Cli<T>;
446
+ /** Current working directory */
447
+ cwd: string;
448
+ /** Logger instance */
449
+ logger: T;
450
+ }
451
+ /**
452
+ * Plugin interface with lifecycle hooks
453
+ */
454
+ interface Plugin<T extends Console = Console> {
455
+ /**
456
+ * Called after command execution completes successfully
457
+ * @param toolbox The command toolbox
458
+ * @param result The result returned by the command
459
+ */
460
+ afterCommand?: (toolbox: Toolbox<T>, result: unknown) => Promise<void> | void;
461
+ /**
462
+ * Called before command execution
463
+ * @param toolbox The command toolbox
464
+ */
465
+ beforeCommand?: (toolbox: Toolbox<T>) => Promise<void> | void;
466
+ /** Plugin dependencies (other plugin names that must be loaded first) */
467
+ dependencies?: string[];
468
+ /** Plugin description */
469
+ description?: string;
470
+ /**
471
+ * Called during command execution (for plugins that extend toolbox functionality)
472
+ * @param toolbox The command toolbox
473
+ */
474
+ execute?: (toolbox: Toolbox<T>) => Promise<void> | void;
475
+ /**
476
+ * Called once during plugin initialization
477
+ * @param context The plugin context
478
+ */
479
+ init?: (context: PluginContext<T>) => Promise<void> | void;
480
+ /** Plugin name (must be unique) */
481
+ name: string;
482
+ /**
483
+ * Called when an error occurs during command execution
484
+ * @param error The error that occurred
485
+ * @param toolbox The command toolbox
486
+ */
487
+ onError?: (error: Error, toolbox: Toolbox<T>) => Promise<void> | void;
488
+ /** Plugin version */
489
+ version?: string;
490
+ }
491
+ type Logger = Console;
492
+ /**
493
+ * Manages plugin lifecycle and execution
494
+ */
495
+ declare class PluginManager<T extends Logger = Logger> {
496
+ private readonly logger;
497
+ private readonly plugins;
498
+ private initialized;
499
+ private cachedDependencyOrder;
500
+ constructor(logger: T);
501
+ /**
502
+ * Checks if any plugins are registered.
503
+ * @returns True if at least one plugin is registered
504
+ */
505
+ hasPlugins(): boolean;
506
+ /**
507
+ * Registers a plugin.
508
+ * @param plugin The plugin to register
509
+ * @throws {Error} If plugin name is already registered or dependencies are invalid
510
+ */
511
+ register(plugin: Plugin<T>): void;
512
+ /**
513
+ * Initializes all registered plugins.
514
+ * @param context The plugin context for initialization
515
+ */
516
+ init(context: PluginContext<T>): Promise<void>;
517
+ /**
518
+ * Executes a specific lifecycle hook for all plugins.
519
+ * @param hook The lifecycle hook name
520
+ * @param toolbox The command toolbox (for command-specific hooks)
521
+ * @param result The command result (for afterCommand hook)
522
+ */
523
+ executeLifecycle(hook: "beforeCommand" | "afterCommand" | "execute", toolbox: Toolbox<T>, result?: unknown): Promise<void>;
524
+ /**
525
+ * Executes error handlers for all plugins.
526
+ * @param error The error that occurred
527
+ * @param toolbox The command toolbox
528
+ */
529
+ executeErrorHandlers(error: Error, toolbox: Toolbox<T>): Promise<void>;
530
+ /**
531
+ * Gets all registered plugins in dependency order.
532
+ * @returns Array of plugins sorted by dependencies
533
+ */
534
+ getDependencyOrder(): Plugin<T>[];
535
+ /**
536
+ * Validates that all plugin dependencies exist.
537
+ * @throws {Error} If any dependencies are missing
538
+ */
539
+ private validateDependencies;
540
+ }
541
+ export { ArgumentDefinition as A, Command as C, EnvDefinition as E, LazyCommandModule as L, OptionDefinition as O, Plugin as P, RunCommandOptions as R, Toolbox as T, VERBOSITY_LEVEL as V, CommandSection as a, PluginManager as b, CliRunOptions as c, Cli as d, CommandExecute as e, OutputType as f, PluginContext as g };
@@ -1,21 +1,23 @@
1
- import type { RenderErrorOptions } from "@visulima/error";
2
- import type { Plugin } from "../types/plugin.d.ts";
3
- export type ErrorHandlerOptions = {
4
- /** Show detailed error information including stack traces and code frames (default: false) */
5
- detailed?: boolean;
6
- /** Exit process after handling error (default: true) */
7
- exitOnError?: boolean;
8
- /** Custom error formatter function */
9
- formatter?: (error: Error) => string;
10
- /** Whether to log errors (default: true) */
11
- logErrors?: boolean;
12
- /** Options for renderError from \@visulima/error (only used when detailed is true) */
13
- renderOptions?: Partial<RenderErrorOptions>;
1
+ import { O as Options$1 } from "../packem_shared/index.d-Br8HpP0A.js";
2
+ import { P as Plugin } from "../packem_shared/plugin-manager.d-Du-YXFui.js";
3
+ import '@visulima/tabular';
4
+ type ErrorHandlerOptions = {
5
+ /** Show detailed error information including stack traces and code frames (default: false) */
6
+ detailed?: boolean;
7
+ /** Exit process after handling error (default: true) */
8
+ exitOnError?: boolean;
9
+ /** Custom error formatter function */
10
+ formatter?: (error: Error) => string;
11
+ /** Whether to log errors (default: true) */
12
+ logErrors?: boolean;
13
+ /** Options for renderError from \@visulima/error (only used when detailed is true) */
14
+ renderOptions?: Partial<Options$1>;
14
15
  };
15
16
  /**
16
- * Create an error handler plugin for enhanced error reporting.
17
- * Uses \@visulima/error for beautiful error formatting with code frames and stack traces.
18
- * @param options Error handler configuration options
19
- * @returns Plugin instance
20
- */
21
- export declare const errorHandlerPlugin: (options?: ErrorHandlerOptions) => Plugin;
17
+ * Create an error handler plugin for enhanced error reporting.
18
+ * Uses \@visulima/error for beautiful error formatting with code frames and stack traces.
19
+ * @param options Error handler configuration options
20
+ * @returns Plugin instance
21
+ */
22
+ declare const errorHandlerPlugin: (options?: ErrorHandlerOptions) => Plugin;
23
+ export { ErrorHandlerOptions, errorHandlerPlugin };
@@ -1,23 +1,25 @@
1
- import type { Plugin } from "../types/plugin.d.ts";
2
- export type RuntimeType = "bun" | "deno" | "node";
3
- export type RuntimeVersionRequirement = {
4
- /** Minimum version required */
5
- minVersion: number;
1
+ import { P as Plugin } from "../packem_shared/plugin-manager.d-Du-YXFui.js";
2
+ import '@visulima/tabular';
3
+ type RuntimeType = "bun" | "deno" | "node";
4
+ type RuntimeVersionRequirement = {
5
+ /** Minimum version required */
6
+ minVersion: number;
6
7
  };
7
- export type RuntimeVersionCheckOptions = {
8
- /** Runtime version requirements for specific runtimes */
9
- runtimes?: {
10
- /** Minimum Bun version requirement */
11
- bun?: RuntimeVersionRequirement;
12
- /** Minimum Deno version requirement */
13
- deno?: RuntimeVersionRequirement;
14
- /** Minimum Node.js version requirement */
15
- node?: RuntimeVersionRequirement;
16
- };
8
+ type RuntimeVersionCheckOptions = {
9
+ /** Runtime version requirements for specific runtimes */
10
+ runtimes?: {
11
+ /** Minimum Bun version requirement */
12
+ bun?: RuntimeVersionRequirement;
13
+ /** Minimum Deno version requirement */
14
+ deno?: RuntimeVersionRequirement;
15
+ /** Minimum Node.js version requirement */
16
+ node?: RuntimeVersionRequirement;
17
+ };
17
18
  };
18
19
  /**
19
- * Create a runtime version check plugin that supports Node.js, Bun, and Deno.
20
- * @param options Configuration for runtime version requirements
21
- * @returns Plugin instance that validates runtime version on initialization
22
- */
23
- export declare const runtimeVersionCheckPlugin: (options?: RuntimeVersionCheckOptions) => Plugin;
20
+ * Create a runtime version check plugin that supports Node.js, Bun, and Deno.
21
+ * @param options Configuration for runtime version requirements
22
+ * @returns Plugin instance that validates runtime version on initialization
23
+ */
24
+ declare const runtimeVersionCheckPlugin: (options?: RuntimeVersionCheckOptions) => Plugin;
25
+ export { RuntimeType, RuntimeVersionCheckOptions, RuntimeVersionRequirement, runtimeVersionCheckPlugin };
@@ -1,9 +1,22 @@
1
- import type { Plugin } from "../../types/plugin.d.ts";
2
- import type { UpdateNotifierOptions } from "./has-new-version.d.ts";
3
- export type UpdateNotifierPluginOptions = Partial<Omit<UpdateNotifierOptions, "debug" | "pkg">>;
1
+ import { P as Plugin } from "../../packem_shared/plugin-manager.d-Du-YXFui.js";
2
+ import '@visulima/tabular';
3
+ type UpdateNotifierOptions = {
4
+ alwaysRun?: boolean;
5
+ debug?: boolean;
6
+ distTag?: string;
7
+ pkg: {
8
+ name: string;
9
+ version: string;
10
+ };
11
+ registryUrl?: string;
12
+ shouldNotifyInNpmScript?: boolean;
13
+ updateCheckInterval?: number;
14
+ };
15
+ type UpdateNotifierPluginOptions = Partial<Omit<UpdateNotifierOptions, "debug" | "pkg">>;
4
16
  /**
5
- * Create an update notifier plugin that checks for package updates.
6
- * @param options Update notifier configuration options.
7
- * @returns Plugin instance.
8
- */
9
- export declare const updateNotifierPlugin: (options?: UpdateNotifierPluginOptions) => Plugin;
17
+ * Create an update notifier plugin that checks for package updates.
18
+ * @param options Update notifier configuration options.
19
+ * @returns Plugin instance.
20
+ */
21
+ declare const updateNotifierPlugin: (options?: UpdateNotifierPluginOptions) => Plugin;
22
+ export { UpdateNotifierPluginOptions, updateNotifierPlugin };
@@ -482,8 +482,7 @@ const updateNotifierPlugin = (options = {}) => {
482
482
  updateCheckInterval: 1e3 * 60 * 60 * 24,
483
483
  ...options
484
484
  };
485
- const shouldCheck = Boolean(updateNotifierOptions.alwaysRun) || // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing -- intentional boolean coercion for truthy check
486
- !(env.NO_UPDATE_NOTIFIER || env.NODE_ENV === "test" || toolbox.argv.includes("--no-update-notifier") || ciInfoExports.isCI);
485
+ const shouldCheck = Boolean(updateNotifierOptions.alwaysRun) || !(env.NO_UPDATE_NOTIFIER || env.NODE_ENV === "test" || toolbox.argv.includes("--no-update-notifier") || ciInfoExports.isCI);
487
486
  if (!shouldCheck) {
488
487
  logger.debug("Update notifier: skipping check (disabled by environment or flags)");
489
488
  return;