@visulima/cerebro 3.0.0-alpha.2 → 3.0.0-alpha.21

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 (89) hide show
  1. package/CHANGELOG.md +334 -0
  2. package/LICENSE.md +589 -4096
  3. package/README.md +26 -0
  4. package/dist/commands/completion-command.d.ts +6 -5
  5. package/dist/commands/completion-command.js +2 -2
  6. package/dist/commands/help-command.d.ts +9 -9
  7. package/dist/commands/help-command.js +1 -1
  8. package/dist/commands/readme-command.d.ts +6 -5
  9. package/dist/commands/readme-command.js +20 -20
  10. package/dist/commands/version-command.d.ts +4 -3
  11. package/dist/index.d.ts +422 -95
  12. package/dist/index.js +1 -1
  13. package/dist/logger/create-pail-logger.d.ts +779 -8
  14. package/dist/logger/create-pail-logger.js +1 -1
  15. package/dist/packem_chunks/has-new-version.js +1 -1
  16. package/dist/packem_shared/Cerebro-DVWKQlmP.js +4 -0
  17. package/dist/packem_shared/VisulimaError-Bh91XNXu.js +76 -0
  18. package/dist/packem_shared/index-B0BiusY7.js +6 -0
  19. package/dist/packem_shared/index.d-Br8HpP0A.d.ts +93 -0
  20. package/dist/packem_shared/lazyNamed-DOmefeJM.js +1 -0
  21. package/dist/packem_shared/plugin-manager.d-Dz-wu1tI.d.ts +544 -0
  22. package/dist/packem_shared/renderError-B_XyYPKJ-B65kP-Ou.js +24 -0
  23. package/dist/packem_shared/{runtime-process-G-n-wOub.js → runtime-process-DKHFvYkv.js} +1 -1
  24. package/dist/plugins/error-handler-plugin.d.ts +21 -19
  25. package/dist/plugins/error-handler-plugin.js +1 -1
  26. package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
  27. package/dist/plugins/runtime-version-check-plugin.js +1 -1
  28. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +21 -8
  29. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
  30. package/dist/util/general/compile-cache.d.ts +41 -0
  31. package/dist/util/general/compile-cache.js +1 -0
  32. package/dist/util/general/heap-tuning.d.ts +18 -0
  33. package/dist/util/general/heap-tuning.js +1 -0
  34. package/package.json +52 -44
  35. package/dist/cli.d.ts +0 -203
  36. package/dist/constants.d.ts +0 -29
  37. package/dist/default-env.d.ts +0 -7
  38. package/dist/default-options.d.ts +0 -3
  39. package/dist/empty-toolbox.d.ts +0 -15
  40. package/dist/errors/cerebro-error.d.ts +0 -10
  41. package/dist/errors/command-not-found-error.d.ts +0 -9
  42. package/dist/errors/command-validation-error.d.ts +0 -10
  43. package/dist/errors/completion-error.d.ts +0 -9
  44. package/dist/errors/conflicting-options-error.d.ts +0 -10
  45. package/dist/errors/plugin-error.d.ts +0 -9
  46. package/dist/errors/update-notifier-error.d.ts +0 -7
  47. package/dist/packem_shared/Cerebro-aPZjbfzf.js +0 -4
  48. package/dist/packem_shared/VisulimaError-BJideSBf.js +0 -76
  49. package/dist/packem_shared/help-command-CIRIXN03.js +0 -1
  50. package/dist/packem_shared/index-DQ3pvLQH.js +0 -6
  51. package/dist/packem_shared/renderError-ZMlMvw1N-eVUSdl6c.js +0 -24
  52. package/dist/plugin-manager.d.ts +0 -53
  53. package/dist/plugins/update-notifier/cache.d.ts +0 -11
  54. package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
  55. package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
  56. package/dist/types/cli.d.ts +0 -102
  57. package/dist/types/command-line-usage.d.ts +0 -37
  58. package/dist/types/command.d.ts +0 -136
  59. package/dist/types/option-types.d.ts +0 -83
  60. package/dist/types/options.d.ts +0 -4
  61. package/dist/types/plugin.d.ts +0 -53
  62. package/dist/types/toolbox.d.ts +0 -96
  63. package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
  64. package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
  65. package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
  66. package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
  67. package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
  68. package/dist/util/command-line-commands.d.ts +0 -10
  69. package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
  70. package/dist/util/command-line-usage/index.d.ts +0 -3
  71. package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
  72. package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
  73. package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
  74. package/dist/util/command-processing/command-processor.d.ts +0 -37
  75. package/dist/util/command-processing/command-validation.d.ts +0 -17
  76. package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
  77. package/dist/util/command-processing/option-processor.d.ts +0 -44
  78. package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
  79. package/dist/util/data-processing/merge-arguments.d.ts +0 -7
  80. package/dist/util/general/find-alternatives.d.ts +0 -8
  81. package/dist/util/general/hide-bin.d.ts +0 -2
  82. package/dist/util/general/parse-raw-command.d.ts +0 -7
  83. package/dist/util/general/register-exception-handler.d.ts +0 -9
  84. package/dist/util/general/runtime-process.d.ts +0 -65
  85. package/dist/util/general/semver-gt.d.ts +0 -2
  86. package/dist/util/general/validate-input.d.ts +0 -24
  87. package/dist/util/process-env-variables.d.ts +0 -9
  88. package/dist/util/security.d.ts +0 -58
  89. package/dist/util/text-processing/template-format.d.ts +0 -5
@@ -0,0 +1,544 @@
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
+ /**
42
+ * Error thrown when an option is already set (duplicate assignment).
43
+ */
44
+ /** A Content section comprises a header and one or more lines of content. */
45
+ interface Content {
46
+ /**
47
+ * Overloaded property, accepting data in one of four formats.
48
+ * 1. A single string (one line of text).
49
+ * 2. An array of strings (multiple lines of text).
50
+ * 3. An array of arrays (recordset-style data). In this case, the data will be rendered in table format.
51
+ * 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.
52
+ */
53
+ content?: string[] | string[][] | string | {
54
+ data: string[][];
55
+ options: TableOptions;
56
+ };
57
+ /** The section header, always bold and underlined. */
58
+ header?: string;
59
+ /** Set to true to avoid indentation and wrapping. Useful for banners. */
60
+ raw?: boolean;
61
+ }
62
+ /**
63
+ * A flexible object for the many "options" objects we throw around in cerebro.
64
+ */
65
+ type Options = Record<string | symbol, unknown>;
66
+ /**
67
+ * Type-safe Toolbox interface with customizable options and environment variable types.
68
+ * @template TLogger - The logger type (defaults to Console)
69
+ * @template TOptions - The options type (defaults to Options/Record&lt;string, unknown>)
70
+ * @template TEnv - The environment variables type (defaults to Record&lt;string, unknown>)
71
+ */
72
+ interface Toolbox<TLogger extends Console = Console, TOptions extends Record<string, unknown> = Options, TEnv extends Record<string, unknown> = Record<string, unknown>> extends Cerebro.ExtensionOverrides {
73
+ /**
74
+ * The argument passed to the command.
75
+ * For example, if you run `cerebro foo bar baz`, then this will be `["foo", "bar", "baz"]`.
76
+ * @example
77
+ * ```typescript
78
+ * cli.addCommand({
79
+ * name: "copy",
80
+ * argument: {
81
+ * name: "files",
82
+ * type: String,
83
+ * description: "Files to copy"
84
+ * },
85
+ * execute: ({ argument }) => {
86
+ * // argument is an array of strings
87
+ * // argument[0] is the first file, argument[1] is the second, etc.
88
+ * argument.forEach((file) => console.log(`Copying ${file}...`));
89
+ * }
90
+ * });
91
+ * ```
92
+ */
93
+ argument: string[];
94
+ argv: ReadonlyArray<string>;
95
+ /**
96
+ * The command that is being executed.
97
+ */
98
+ command: Command;
99
+ /**
100
+ * The name of the command that is being executed.
101
+ */
102
+ commandName: string;
103
+ /**
104
+ * Environment variables processed from the command definition.
105
+ * Values are transformed according to their type definitions and default values.
106
+ * @example
107
+ * ```typescript
108
+ * // Define env types when creating command
109
+ * type MyEnv = { apiKey: string; debug: boolean };
110
+ *
111
+ * cli.addCommand({
112
+ * name: "build",
113
+ * env: [
114
+ * { name: "API_KEY", type: String },
115
+ * { name: "DEBUG", type: Boolean }
116
+ * ],
117
+ * execute: ({ env }) => {
118
+ * // env.apiKey and env.debug are now typed!
119
+ * console.log(env.apiKey, env.debug);
120
+ * }
121
+ * });
122
+ * ```
123
+ */
124
+ env: TEnv;
125
+ /** The logger instance. */
126
+ logger: TLogger;
127
+ /**
128
+ * Any optional parameters. Typically coming from command-line
129
+ * argument like this: `--force -p tsconfig-mjson`.
130
+ * @example
131
+ * ```typescript
132
+ * // Define options type for better autocomplete
133
+ * type MyOptions = {
134
+ * output?: string;
135
+ * verbose?: boolean;
136
+ * port?: number;
137
+ * };
138
+ *
139
+ * cli.addCommand({
140
+ * name: "serve",
141
+ * options: [
142
+ * { name: "output", type: String },
143
+ * { name: "verbose", type: Boolean },
144
+ * { name: "port", type: Number }
145
+ * ],
146
+ * execute: ({ options }: { options: MyOptions }) => {
147
+ * // options.output, options.verbose, options.port are typed!
148
+ * console.log(options.output, options.verbose, options.port);
149
+ * }
150
+ * });
151
+ * ```
152
+ */
153
+ options: TOptions;
154
+ /**
155
+ * Raw tokens that command-line-args could not assign to a defined
156
+ * option — typically everything after a `--` separator, since
157
+ * cerebro runs the parser with `stopAtFirstUnknown: true`.
158
+ *
159
+ * Use this for passthrough patterns like
160
+ * `my-cmd foo bar -- --flag=value --other`, where everything after
161
+ * `--` is forwarded to an inner tool (`create-vite`, a template
162
+ * runner, etc.). Empty array when there was no `--` segment.
163
+ * @example
164
+ * ```typescript
165
+ * cli.addCommand({
166
+ * name: "create",
167
+ * argument: { name: "template", type: String },
168
+ * execute: ({ argument, rawUnknown }) => {
169
+ * // `vis create vite my-app -- --template react-ts`
170
+ * // → argument === ["vite", "my-app"]
171
+ * // → rawUnknown === ["--template", "react-ts"]
172
+ * spawnSync("npm", ["create", "vite", ...rawUnknown]);
173
+ * },
174
+ * });
175
+ * ```
176
+ */
177
+ rawUnknown: ReadonlyArray<string>;
178
+ /**
179
+ * This is the instance of the CLI that is running the command.
180
+ */
181
+ runtime: Cli<TLogger>;
182
+ }
183
+ type TypeConstructor<T> = (value: unknown) => T extends (infer R)[] ? R | undefined : T | undefined;
184
+ /**
185
+ * Type constructor for environment variables.
186
+ * Environment variables are always strings (or undefined), so the transform function receives string | undefined.
187
+ */
188
+ type EnvTypeConstructor<T> = (value: string | undefined) => T extends (infer R)[] ? R | undefined : T | undefined;
189
+ type MultiplePropertyOptions<T> = T extends ReadonlyArray<unknown> ? {
190
+ lazyMultiple: true;
191
+ } | {
192
+ multiple: true;
193
+ } : unknown;
194
+ type OptionDefinition<T> = MultiplePropertyOptions<T> & Omit<OptionDefinition$1, "type|defaultValue"> & {
195
+ /**
196
+ * A string or array of strings indicating the conflicting option(s).
197
+ * Note: The default value for an option does not cause a conflict.
198
+ */
199
+ conflicts?: string[] | string;
200
+ /** An initial value for the option. */
201
+ defaultValue?: T;
202
+ /** A string describing the option. */
203
+ description?: string;
204
+ /** Option is hidden from help */
205
+ hidden?: boolean;
206
+ implies?: Record<string, unknown>; /** Specifies whether the variable is required. */
207
+ required?: boolean;
208
+ /**
209
+ * A setter function (you receive the output from this) enabling you to be specific about the type and value received. Typical values
210
+ * are `String`, `Number` and `Boolean` but you can use a custom function.
211
+ */
212
+ type?: TypeConstructor<T>;
213
+ /** 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.. */
214
+ typeLabel?: string;
215
+ };
216
+ type ArgumentDefinition<T = unknown> = Omit<OptionDefinition<T>, "multiple|lazyMultiple|defaultOption|alias|group|defaultValue">;
217
+ /**
218
+ * Environment variable definition for commands.
219
+ * Used to document and provide type-safe access to environment variables a command supports.
220
+ * @template T The type of the environment variable value
221
+ */
222
+ interface EnvDefinition<T = string> {
223
+ /** Default value if the environment variable is not set */
224
+ defaultValue?: T;
225
+ /** A description of what the environment variable does */
226
+ description?: string;
227
+ /** Environment variable is hidden from help */
228
+ hidden?: boolean;
229
+ /** The name of the environment variable */
230
+ name: string;
231
+ /**
232
+ * A transform function to convert the string environment variable value to the desired type.
233
+ * Typical values are `String`, `Number`, `Boolean` or custom functions.
234
+ * The function receives `string | undefined` and should return the transformed value.
235
+ */
236
+ type?: EnvTypeConstructor<T>;
237
+ /** A string to replace the default type string (e.g. &lt;string>). Useful for more descriptive type labels. */
238
+ typeLabel?: string;
239
+ }
240
+ /**
241
+ * Command interface with type-safe options and environment variables.
242
+ * @template O - The option definition type
243
+ * @template TContext - The toolbox context type (allows custom typing for better autocomplete)
244
+ * @example
245
+ * ```typescript
246
+ * // Define your options type for autocomplete
247
+ * type BuildOptions = {
248
+ * output?: string;
249
+ * production?: boolean;
250
+ * watch?: boolean;
251
+ * };
252
+ *
253
+ * type BuildEnv = {
254
+ * apiKey?: string;
255
+ * debug?: boolean;
256
+ * };
257
+ *
258
+ * cli.addCommand({
259
+ * name: "build",
260
+ * options: [
261
+ * { name: "output", type: String, alias: "o" },
262
+ * { name: "production", type: Boolean },
263
+ * { name: "watch", type: Boolean }
264
+ * ],
265
+ * env: [
266
+ * { name: "API_KEY", type: String },
267
+ * { name: "DEBUG", type: Boolean }
268
+ * ],
269
+ * execute: ({ options, env }: Toolbox<Console, BuildOptions, BuildEnv>) => {
270
+ * // Full autocomplete on options and env!
271
+ * console.log(options.output, options.production, env.apiKey);
272
+ * }
273
+ * });
274
+ * ```
275
+ */
276
+ /**
277
+ * Handler signature for commands. Used by both `execute` and the resolved default export of `loader`.
278
+ */
279
+ type CommandExecute<TContext> = ((toolbox: TContext) => Promise<void>) | ((toolbox: TContext) => void);
280
+ /**
281
+ * Module shape returned by a command `loader`. The default export is the command handler.
282
+ */
283
+ interface LazyCommandModule<TContext> {
284
+ default: CommandExecute<TContext>;
285
+ }
286
+ interface Command<O extends OptionDefinition<unknown> = OptionDefinition<unknown>, TLogger extends Console = Console, TContext extends Toolbox<TLogger> = Toolbox<TLogger>> {
287
+ /** Potential other names for this command */
288
+ alias?: string[] | string;
289
+ /** Positional argument */
290
+ argument?: ArgumentDefinition;
291
+ /** The command path, an array that describes how to get to this command */
292
+ commandPath?: string[];
293
+ /** A tweet-sized summary of your command */
294
+ description?: string;
295
+ /** Environment variables supported by this command */
296
+ env?: (EnvDefinition<boolean> | EnvDefinition<number> | EnvDefinition)[];
297
+ /** The full command examples, can be multiple lines */
298
+ examples?: string[] | string[][];
299
+ /**
300
+ * The function for running your command, can be async.
301
+ * Either `execute` or `loader` must be provided (but not both).
302
+ */
303
+ execute?: CommandExecute<TContext>;
304
+ /** The path to the file name for this command. */
305
+ file?: string;
306
+ /** Group commands together under a heading */
307
+ group?: string;
308
+ /** Should your command be shown in the listings */
309
+ hidden?: boolean;
310
+ /**
311
+ * Lazily loads the command handler on first execution. The module's default export is used as the handler.
312
+ * Either `execute` or `loader` must be provided (but not both).
313
+ * Help, completion, and validation work from the metadata declared on this object and never trigger the loader.
314
+ * @example
315
+ * ```typescript
316
+ * cli.addCommand({
317
+ * name: "build",
318
+ * description: "Build the project",
319
+ * options: [{ name: "output", type: String }],
320
+ * loader: () => import("./commands/build"),
321
+ * });
322
+ *
323
+ * // commands/build.ts
324
+ * export default ({ options }) => { ... };
325
+ * ```
326
+ */
327
+ loader?: () => Promise<LazyCommandModule<TContext>>;
328
+ /** The name of your command */
329
+ name: string;
330
+ options?: (O | OptionDefinition<boolean[]> | OptionDefinition<boolean> | OptionDefinition<number[]> | OptionDefinition<number> | OptionDefinition<string[]> | OptionDefinition<string>)[];
331
+ usage?: Content[];
332
+ }
333
+ type CommandSection = {
334
+ footer?: string;
335
+ header?: string;
336
+ };
337
+ type CliRunOptions = {
338
+ [key: string]: unknown;
339
+ /**
340
+ * Whether to automatically dispose/cleanup the CLI instance after execution
341
+ * @default true
342
+ */
343
+ autoDispose?: boolean;
344
+ shouldExitProcess?: boolean;
345
+ };
346
+ type RunCommandOptions = {
347
+ /**
348
+ * Extra options to merge into the command's options.
349
+ * These will be merged with the command's default options and parsed arguments.
350
+ * Use this to override or add additional options programmatically.
351
+ * @default Empty object
352
+ */
353
+ [key: string]: unknown;
354
+ /**
355
+ * Command-line arguments to pass to the command.
356
+ * If not provided, uses the default argv from the CLI instance.
357
+ * These arguments will be parsed and merged with the command's options.
358
+ * @default Empty array
359
+ */
360
+ argv?: string[];
361
+ };
362
+ interface Cli<T extends Console> {
363
+ /**
364
+ * Add an arbitrary command to the CLI.
365
+ * @param command The command to add.
366
+ * @returns self
367
+ */
368
+ addCommand: <OD extends OptionDefinition<unknown> = OptionDefinition<unknown>>(command: Command<OD, T>) => this;
369
+ /**
370
+ * Add a global option available to all commands.
371
+ * Global options are parsed alongside command options and shown in help output.
372
+ * @param option The option definition
373
+ * @returns self
374
+ */
375
+ addGlobalOption: <V = unknown>(option: OptionDefinition<V>) => this;
376
+ /**
377
+ * Add a plugin to extend the CLI functionality
378
+ * @param plugin The plugin to add.
379
+ * @returns self
380
+ */
381
+ addPlugin: (plugin: Plugin<T>) => this;
382
+ /**
383
+ * Disposes the CLI instance and cleans up resources
384
+ * @returns void
385
+ */
386
+ dispose: () => void;
387
+ getCliName: () => string;
388
+ getCommands: () => Map<string, Command<OptionDefinition<unknown>, T>>;
389
+ getCommandSection: () => CommandSection;
390
+ getCwd: () => string;
391
+ /**
392
+ * Gets all global options (built-in + custom).
393
+ */
394
+ getGlobalOptions: () => OptionDefinition<unknown>[];
395
+ getPackageName: () => string | undefined;
396
+ getPackageVersion: () => string | undefined;
397
+ /**
398
+ * Get the plugin manager instance
399
+ * @returns The plugin manager
400
+ */
401
+ getPluginManager: () => PluginManager<T>;
402
+ run: (extraOptions?: CliRunOptions) => Promise<void>;
403
+ /**
404
+ * Runs a command programmatically from within another command.
405
+ * This allows commands to call other commands during execution.
406
+ * @param commandName The name of the command to execute
407
+ * @param options Optional options including argv and other command options
408
+ * @returns A promise that resolves with the command's result (or void if command doesn't return a value)
409
+ * @throws {Error} If the specified command doesn't exist or command arguments are invalid
410
+ * @example
411
+ * ```typescript
412
+ * cli.addCommand({
413
+ * name: 'deploy',
414
+ * execute: async ({ runtime, logger }) => {
415
+ * logger.info('Building...');
416
+ * const buildResult = await runtime.runCommand('build', { argv: ['--production'] });
417
+ * // buildResult is the return value from the build command's execute function
418
+ *
419
+ * logger.info('Testing...');
420
+ * await runtime.runCommand('test', { argv: ['--coverage'] });
421
+ * }
422
+ * });
423
+ * ```
424
+ */
425
+ runCommand: (commandName: string, options?: RunCommandOptions) => Promise<unknown>;
426
+ setCommandSection: (commandSection: CommandSection) => this;
427
+ /**
428
+ * Set a default command, to display a different command if cli is call without command.
429
+ * @param commandName
430
+ * @returns self
431
+ */
432
+ setDefaultCommand: (commandName: string) => this;
433
+ }
434
+ /**
435
+ * Any of the output types [[OUTPUT_NORMAL]], [[OUTPUT_RAW]] and [[OUTPUT_PLAIN]].
436
+ */
437
+ type OutputType = 1 | 2 | 4;
438
+ /**
439
+ * Any of the verbosity types
440
+ * [[VERBOSITY_QUIET]], [[VERBOSITY_NORMAL]], [[VERBOSITY_VERBOSE]] and [[VERBOSITY_DEBUG]].
441
+ */
442
+ type VERBOSITY_LEVEL = 16 | 32 | 64 | 128 | 256;
443
+ /**
444
+ * Context provided to plugins during initialization
445
+ */
446
+ interface PluginContext<T extends Console = Console> {
447
+ /** The CLI instance */
448
+ cli: Cli<T>;
449
+ /** Current working directory */
450
+ cwd: string;
451
+ /** Logger instance */
452
+ logger: T;
453
+ }
454
+ /**
455
+ * Plugin interface with lifecycle hooks
456
+ */
457
+ interface Plugin<T extends Console = Console> {
458
+ /**
459
+ * Called after command execution completes successfully
460
+ * @param toolbox The command toolbox
461
+ * @param result The result returned by the command
462
+ */
463
+ afterCommand?: (toolbox: Toolbox<T>, result: unknown) => Promise<void> | void;
464
+ /**
465
+ * Called before command execution
466
+ * @param toolbox The command toolbox
467
+ */
468
+ beforeCommand?: (toolbox: Toolbox<T>) => Promise<void> | void;
469
+ /** Plugin dependencies (other plugin names that must be loaded first) */
470
+ dependencies?: string[];
471
+ /** Plugin description */
472
+ description?: string;
473
+ /**
474
+ * Called during command execution (for plugins that extend toolbox functionality)
475
+ * @param toolbox The command toolbox
476
+ */
477
+ execute?: (toolbox: Toolbox<T>) => Promise<void> | void;
478
+ /**
479
+ * Called once during plugin initialization
480
+ * @param context The plugin context
481
+ */
482
+ init?: (context: PluginContext<T>) => Promise<void> | void;
483
+ /** Plugin name (must be unique) */
484
+ name: string;
485
+ /**
486
+ * Called when an error occurs during command execution
487
+ * @param error The error that occurred
488
+ * @param toolbox The command toolbox
489
+ */
490
+ onError?: (error: Error, toolbox: Toolbox<T>) => Promise<void> | void;
491
+ /** Plugin version */
492
+ version?: string;
493
+ }
494
+ type Logger = Console;
495
+ /**
496
+ * Manages plugin lifecycle and execution
497
+ */
498
+ declare class PluginManager<T extends Logger = Logger> {
499
+ private readonly logger;
500
+ private readonly plugins;
501
+ private initialized;
502
+ private cachedDependencyOrder;
503
+ constructor(logger: T);
504
+ /**
505
+ * Checks if any plugins are registered.
506
+ * @returns True if at least one plugin is registered
507
+ */
508
+ hasPlugins(): boolean;
509
+ /**
510
+ * Registers a plugin.
511
+ * @param plugin The plugin to register
512
+ * @throws {Error} If plugin name is already registered or dependencies are invalid
513
+ */
514
+ register(plugin: Plugin<T>): void;
515
+ /**
516
+ * Initializes all registered plugins.
517
+ * @param context The plugin context for initialization
518
+ */
519
+ init(context: PluginContext<T>): Promise<void>;
520
+ /**
521
+ * Executes a specific lifecycle hook for all plugins.
522
+ * @param hook The lifecycle hook name
523
+ * @param toolbox The command toolbox (for command-specific hooks)
524
+ * @param result The command result (for afterCommand hook)
525
+ */
526
+ executeLifecycle(hook: "beforeCommand" | "afterCommand" | "execute", toolbox: Toolbox<T>, result?: unknown): Promise<void>;
527
+ /**
528
+ * Executes error handlers for all plugins.
529
+ * @param error The error that occurred
530
+ * @param toolbox The command toolbox
531
+ */
532
+ executeErrorHandlers(error: Error, toolbox: Toolbox<T>): Promise<void>;
533
+ /**
534
+ * Gets all registered plugins in dependency order.
535
+ * @returns Array of plugins sorted by dependencies
536
+ */
537
+ getDependencyOrder(): Plugin<T>[];
538
+ /**
539
+ * Validates that all plugin dependencies exist.
540
+ * @throws {Error} If any dependencies are missing
541
+ */
542
+ private validateDependencies;
543
+ }
544
+ 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 };
@@ -0,0 +1,24 @@
1
+ var Q=Object.defineProperty;var N=(r,e)=>Q(r,"name",{value:e,configurable:!0});import{createRequire as X}from"node:module";const Y=X(import.meta.url),S=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Z=N(r=>{if(typeof S<"u"&&S.versions&&S.versions.node){const[e,t]=S.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return S.getBuiltinModule(r)}return Y(r)},"__cjs_getBuiltinModule"),{createRequire:ee}=Z("node:module");var re=Object.defineProperty,te=N((r,e)=>re(r,"name",{value:e,configurable:!0}),"A$2"),ie=Object.defineProperty,A=te((r,e)=>ie(r,"name",{value:e,configurable:!0}),"$"),ne=Object.defineProperty,oe=A((r,e)=>ne(r,"name",{value:e,configurable:!0}),"r$1");const se=oe(r=>r.replaceAll(/\r\n|\r(?!\n)|\n/gu,`
2
+ `),"normalizeLF"),ae=globalThis.process??Object.create(null),P={versions:{}},T=new Proxy(ae,{get(r,e){if(e in r)return r[e];if(e in P)return P[e]}});var le=Object.defineProperty,ce=A((r,e)=>le(r,"name",{value:e,configurable:!0}),"b");const de=ce((r,e,t,i)=>{const s={column:0,line:-1,...r.start},o={...s,...r.end},n=s.line,l=s.column,d=o.line,c=o.column;let a=Math.max(n-(t+1),0),p=Math.min(e.length,d+i);n===-1&&(a=0),d===-1&&(p=e.length);const g=d-n,m={};if(g)for(let u=0;u<=g;u++){const $=u+n;if(!l)m[$]=!0;else if(u===0){const h=e[$-1]?.length;m[$]=[l,(h??0)-l+1]}else if(u===g)m[$]=[0,c];else{const h=e[$-u]?.length;m[$]=[0,h]}}else l===c?m[n]=l?[l,0]:!0:m[n]=[l,(c??0)-(l??0)];return{end:p,markerLines:m,start:a}},"getMarkerLines");var ue=Object.defineProperty,E=A((r,e)=>ue(r,"name",{value:e,configurable:!0}),"t");const fe=T.platform==="win32"&&!T.env?.WT_SESSION?">":"❯",me=E((r,e,t)=>{const i={linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,tabWidth:4,...t,color:{gutter:E(u=>u,"gutter"),marker:E(u=>u,"marker"),message:E(u=>u,"message"),...t?.color}},s=typeof e.start.column=="number";let o=se(r).split(`
3
+ `);typeof i.tabWidth=="number"&&(o=o.map(u=>u.replaceAll(" "," ".repeat(i.tabWidth))));const{end:n,markerLines:l,start:d}=de(e,o,i.linesAbove,i.linesBelow),c=String(n).length,{gutter:a,marker:p,message:g}=i.color;let m=o.slice(d,n).map((u,$)=>{const h=d+1+$,k=l[h],D=` ${String(h)}`.slice(-c),U=!l[h+1],j=` ${D}${i.showGutter?" |":""}`;if(k){let O="";if(Array.isArray(k)){const H=u.replaceAll(/[^\t]/g," ").slice(0,Math.max(k[0]-1,0)),K=k[1]||1;O=[`
4
+ `,i.prefix+a(j.replaceAll(/\d/g," "))," ",H,p("^").repeat(K)].join(""),U&&i.message&&(O+=` ${g(i.message)}`)}return[i.prefix+p(fe),a(j),u.length>0?` ${u}`:"",O].join("")}return`${i.prefix} ${a(j)}${u.length>0?` ${u}`:""}`}).join(`
5
+ `);return i.message&&!s&&(m=`${i.prefix+" ".repeat(c+1)+i.message}
6
+ ${m}`),m},"codeFrame");var pe=Object.defineProperty,ve=N((r,e)=>pe(r,"name",{value:e,configurable:!0}),"x$1"),ge=Object.defineProperty,$e=ve((r,e)=>ge(r,"name",{value:e,configurable:!0}),"x"),he=Object.defineProperty,v=$e((r,e)=>he(r,"name",{value:e,configurable:!0}),"u");const b=v((r,...e)=>{process.env.DEBUG&&process.env.DEBUG==="true"&&console.debug(`error:parse-stacktrace: ${r}`,...e)},"debugLog"),y="<unknown>",be=/^.*?\s*at\s(?:(.+?\)(?:\s\[.+\])?|\(?.*?)\s?\((?:address\sat\s)?)?(?:async\s)?((?:<anonymous>|[-a-z]+:|.*bundle|\/)?.*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i,ye=/\((\S+)\),\s(<[^>]+>)?:(\d+)?:(\d+)?\)?/,xe=/(.*?):(\d+):(\d+)(?:\s<-\s.+:\d+:\d+)?/,we=/eval\sat\s(<anonymous>)\s\((.*)\)?:(\d+)?:(\d+)\),\s*<anonymous>?:(\d+)?:(\d+)/,Ne=/^\s*in\s(?:([^\\/]+(?:\s\[as\s\S+\])?)\s\(?)?\(at?\s?(.*?):(\d+)(?::(\d+))?\)?\s*$/,Se=/in\s(.*)\s\(at\s(.+)\)\sat/,ke=/^(?:.*@)?(.*):(\d+):(\d+)$/,Ee=/^\s*(.*?)(?:\((.*?)\))?(?:^|@)?((?:[-a-z]+)?:\/.*?|\[native code\]|[^@]*(?:bundle|\d+\.js)|\/[\w\-. \/=]+)(?::(\d+))?(?::(\d+))?\s*$/i,je=/(\S+) line (\d+)(?: > eval line \d+)* > eval/i,Oe=/(\S[^\s[]*\[.*\]|.*?)@(.*):(\d+):(\d+)/,_=/\(error: (.*)\)/,Ae=/at\s/,Le=/^(\S+):(\d+):(\d+)$|^(\S+):(\d+)$/,Me=/^\s+|\s+$/g,Pe=/\S*(?:Error: |AggregateError:)/,C=/^Anonymous function$/,Te=/^\s*in\s.*/,_e=/^.*?\s*at\s.*/,Ce=/^.*?\s*@.*|\[native code\]/,B=v((r,e)=>{const t=r.includes("safari-extension"),i=r.includes("safari-web-extension");return t||i?[r.includes("@")?r.split("@")[0]:y,t?`safari-extension:${e}`:`safari-web-extension:${e}`]:[r,e]},"extractSafariExtensionDetails"),W=v((r,e)=>{const t=xe.exec(e);t&&(r.file=t[1],r.line=+t[2],r.column=+t[3])},"parseMapped"),Be=v(r=>{const e=Se.exec(r);if(e){b(`parse nested node error stack line: "${r}"`,`found: ${JSON.stringify(e)}`);const i=e[2].split(":");return{column:i[2]?+i[2]:void 0,file:i[0],line:i[1]?+i[1]:void 0,methodName:e[1]??y,raw:r,type:void 0}}const t=Ne.exec(r);if(t){b(`parse node error stack line: "${r}"`,`found: ${JSON.stringify(t)}`);const i={column:t[4]?+t[4]:void 0,file:t[2]?t[2].replace(Ae,""):void 0,line:t[3]?+t[3]:void 0,methodName:t[1]??y,raw:r,type:r.startsWith("internal")?"internal":void 0};return W(i,`${t[2]}:${t[3]}:${t[4]}`),i}},"parseNode"),We=v(r=>{const e=be.exec(r);if(e){b(`parse chrome error stack line: "${r}"`,`found: ${JSON.stringify(e)}`);const t=e[2]?.startsWith("native"),i=e[2]?.startsWith("eval")||e[1]?.startsWith("eval");let s,o;if(i){const c=ye.exec(r);if(c){const a=Le.exec(c[1]);a?(e[2]=a[4]??a[1],e[3]=a[5]??a[2],e[4]=a[3]):c[2]&&(e[2]=c[1]),c[2]&&(s={column:c[4]?+c[4]:void 0,file:c[2],line:c[3]?+c[3]:void 0,methodName:"eval",raw:r,type:"eval"})}else{const a=we.exec(r);a&&(o={column:a[4]?+a[4]:void 0,file:a[2],line:a[3]?+a[3]:void 0},s={column:a[6]?+a[6]:void 0,file:a[1],line:a[5]?+a[5]:void 0,methodName:"eval",raw:a[0],type:"eval"})}}const[n,l]=B(e[1]?e[1].replace(C,"<anonymous>"):y,e[2]),d={column:e[4]?+e[4]:void 0,evalOrigin:s,file:l,line:e[3]?+e[3]:void 0,methodName:n,raw:r,type:i?"eval":t?"native":void 0};return o?(d.column=o.column,d.file=o.file,d.line=o.line):W(d,`${l}:${e[3]}:${e[4]}`),d}},"parseChromium"),Ge=v((r,e)=>{const t=Ee.exec(r);if(t){b(`parse gecko error stack line: "${r}"`,`found: ${JSON.stringify(t)}`);const i=t[3]?.includes(" > eval"),s=i&&t[3]&&je.exec(t[3]);let o;i&&s&&(t[3]=s[1],o={column:t[5]?+t[5]:void 0,file:t[3],line:t[4]?+t[4]:void 0,methodName:"eval",raw:r,type:"eval"},t[4]=s[2]);const[n,l]=B(t[1]?t[1].replace(C,"<anonymous>"):y,t[3]);let d;(e?.type==="safari"||!i&&e?.type==="firefox")&&e.column?d=e.column:!i&&t[5]&&(d=+t[5]);let c;return(e?.type==="safari"||!i&&e?.type==="firefox")&&e.line?c=e.line:t[4]&&(c=+t[4]),{column:d,evalOrigin:o,file:l,line:c,methodName:n,raw:r,type:i?"eval":l.includes("[native code]")?"native":void 0}}},"parseGecko"),Re=v((r,e)=>{const t=Oe.exec(r);if(!(t&&t[2].includes(" > eval"))&&t)return b(`parse firefox error stack line: "${r}"`,`found: ${JSON.stringify(t)}`),{column:t[4]?+t[4]:e?.column??void 0,file:t[2],line:t[3]?+t[3]:e?.line??void 0,methodName:t[1]||y,raw:r,type:void 0}},"parseFirefox"),Fe=v(r=>{const e=ke.exec(r);if(e)return b(`parse react android native error stack line: "${r}"`,`found: ${JSON.stringify(e)}`),{column:e[3]?+e[3]:void 0,file:e[1],line:e[2]?+e[2]:void 0,methodName:y,raw:r,type:void 0}},"parseReactAndroidNative"),G=v((r,{filter:e,frameLimit:t=50}={})=>{const i=r;let s=(typeof i.stacktrace=="string"?i.stacktrace:r.stack??"").split(`
7
+ `).map(o=>(_.test(o)?o.replace(_,"$1"):o).replaceAll(Me,"")).filter(o=>!Pe.test(o)&&o!=="eval code");return e&&(s=s.filter(o=>e(o))),s=s.slice(0,t),s.reduce((o,n,l)=>{if(!n||n.length>1024)return o;let d;if(Te.test(n))d=Be(n);else if(_e.test(n))d=We(n);else if(Ce.test(n)){let c;if(l===0){const a=r,p=a.columnNumber,g=a.lineNumber,m=a.line,u=a.column;p||g?c={column:p,line:g,type:"firefox"}:(m||u)&&(c={column:u,line:m,type:"safari"})}d=Re(n,c)??Ge(n,c)}else d=Fe(n);return d?o.push(d):b(`parse error stack line: "${n}"`,"not parser found"),o},[])},"parseStacktrace");var Ie=Object.defineProperty,Ve=N((r,e)=>Ie(r,"name",{value:e,configurable:!0}),"p"),Je=Object.defineProperty,R=Ve((r,e)=>Je(r,"name",{value:e,configurable:!0}),"m");const qe=ee(import.meta.url),x=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,L=R(r=>{if(typeof x<"u"&&x.versions&&x.versions.node){const[e,t]=x.versions.node.split(".").map(Number);if(e>22||e===22&&t>=3||e===20&&t>=16)return x.getBuiltinModule(r)}return qe(r)},"__cjs_getBuiltinModule"),{existsSync:ze,readFileSync:De}=L("node:fs"),{relative:Ue}=L("node:path"),{cwd:He}=x,{fileURLToPath:Ke}=L("node:url");var Qe=Object.defineProperty,f=R((r,e)=>Qe(r,"name",{value:e,configurable:!0}),"o");const w=f((r,e,t)=>t===0?r:e===" "?r+" ".repeat(t):r+" ".repeat(e*t),"getPrefix"),Xe=f((r,e)=>{const t=r.replace("async file:","file:");return Ue(e,t.startsWith("file:")?Ke(t):t)},"getRelativePath"),Ye=f((r,e,t)=>{if(e)return t.title(r.message);const i=r.message?`: ${r.message}`:"";return t.title(r.name+i)},"getTitleText"),F=f((r,{color:e,hideErrorTitle:t,indentation:i,prefix:s},o)=>`${w(s,i,o)}${Ye(r,t,e)}
8
+ `,"getMessage"),I=f((r,{color:e,indentation:t,prefix:i},s)=>{if(r.hint===void 0)return;const o=w(i,t,s);let n="";if(Array.isArray(r.hint))for(const l of r.hint)n+=`${o+l}
9
+ `;else n+=o+r.hint;return e.hint(n)},"getHint"),M=f((r,{color:e,cwd:t,displayShortPath:i,indentation:s,prefix:o},n=0)=>{const l=i?Xe(r.file,t):r.file,{fileLine:d,method:c}=e;return`${w(o,s,n)}at ${r.methodName?`${c(r.methodName)} `:""}${d(l)}:${d(r.line?.toString()??"")}`},"getMainFrame"),V=f((r,{color:e,indentation:t,linesAbove:i,linesBelow:s,prefix:o,showGutter:n,showLineNumbers:l,tabWidth:d},c)=>{if(r.file===void 0)return;const a=r.file.replace("file://","");if(!ze(a))return;const p=De(a,"utf8");return me(p,{start:{column:r.column,line:r.line}},{color:e,linesAbove:i,linesBelow:s,prefix:w(o,t,c),showGutter:n,showLineNumbers:l,tabWidth:d})},"getCode"),J=f((r,e,t)=>{if(r.errors.length===0)return;let i=`${w(e.prefix,e.indentation,t)}Errors:
10
+
11
+ `,s=!0;for(const o of r.errors)s?s=!1:i+=`
12
+
13
+ `,i+=z(o,{...e,framesMaxLimit:1,hideErrorCodeView:e.hideErrorErrorsCodeView},t+1);return`
14
+ ${i}`},"getErrors"),q=f((r,e,t)=>{let i=`${w(e.prefix,e.indentation,t)}Caused by:
15
+
16
+ `;const s=r.cause;i+=F(s,e,t);const o=G(s).shift(),n=I(s,e,t);if(n&&(i+=`${n}
17
+ `),o&&(i+=M(o,e,t),!e.hideErrorCauseCodeView)){const l=V(o,e,t);l!==void 0&&(i+=`
18
+ ${l}`)}if(s.cause)i+=`
19
+ ${q(s,e,t+1)}`;else if(s instanceof AggregateError){const l=J(s,e,t);l!==void 0&&(i+=`
20
+ ${l}`)}return`
21
+ ${i}`},"getCause"),Ze=f((r,e)=>(r.length>0?`
22
+ `:"")+r.map(t=>M(t,e)).join(`
23
+ `),"getStacktrace"),z=f((r,e,t)=>{const i={cwd:He(),displayShortPath:!1,filterStacktrace:void 0,framesMaxLimit:Number.POSITIVE_INFINITY,hideErrorCauseCodeView:!1,hideErrorCodeView:!1,hideErrorErrorsCodeView:!1,hideErrorTitle:!1,hideMessage:!1,indentation:4,linesAbove:2,linesBelow:3,prefix:"",showGutter:!0,showLineNumbers:!0,tabWidth:4,...e,color:{fileLine:f(n=>n,"fileLine"),gutter:f(n=>n,"gutter"),hint:f(n=>n,"hint"),marker:f(n=>n,"marker"),message:f(n=>n,"message"),method:f(n=>n,"method"),title:f(n=>n,"title"),...e.color}},s=G(r,{filter:e.filterStacktrace,frameLimit:i.framesMaxLimit}),o=s.shift();return[e.hideMessage?void 0:F(r,i,t),I(r,i,t),o?M(o,i,t):void 0,o&&!i.hideErrorCodeView?V(o,i,t):void 0,r instanceof AggregateError?J(r,i,t):void 0,r.cause===void 0?void 0:q(r,i,t),s.length>0?Ze(s,i):void 0].filter(Boolean).join(`
24
+ `).replaceAll("\\","/")},"internalRenderError"),tr=f((r,e={})=>{if(e.framesMaxLimit!==void 0&&e.framesMaxLimit<=0)throw new RangeError("The 'framesMaxLimit' option must be a positive number");return z(r,e,0)},"renderError");export{tr as G,me as N,G as Q,fe as k};
@@ -1 +1 @@
1
- var a=Object.defineProperty;var l=(e,s)=>a(e,"name",{value:s,configurable:!0});var g=Object.defineProperty,r=l((e,s)=>g(e,"name",{value:s,configurable:!0}),"r");const t=r(e=>"Deno"in e,"hasDeno"),i=r(e=>"Bun"in e,"hasBun"),h=r(()=>{if(t(globalThis)){const e=globalThis.Deno,s=e.execPath();let o=s;try{const{importMeta:n}=globalThis;n?.url&&(o=n.url)}catch{}return[s,o,...e.args]}return i(globalThis)?globalThis.Bun.process.argv:process.argv},"getArgv"),b=r(()=>t(globalThis)?globalThis.Deno.cwd():i(globalThis)?globalThis.Bun.process.cwd():process.cwd(),"getCwd"),u=r(()=>{if(t(globalThis)){const e=globalThis.Deno;return new Proxy(e.env.toObject(),{get:r((s,o)=>typeof o=="string"?e.env.get(o):s[o],"get"),has:r((s,o)=>typeof o=="string"?e.env.has(o):o in s,"has"),set:r((s,o,n)=>typeof o=="string"?(n===void 0||e.env.set(o,n),!0):!1,"set")})}return i(globalThis)?globalThis.Bun.process.env:process.env},"getEnv"),T=r(()=>t(globalThis)?[]:i(globalThis)?globalThis.Bun.process.execArgv:process.execArgv,"getExecArgv"),v=r(()=>t(globalThis)?globalThis.Deno.execPath():i(globalThis)?globalThis.Bun.process.execPath:process.execPath,"getExecPath"),p=r(()=>{if(t(globalThis)){const e=globalThis.Deno.build?.os??"unknown";return e==="windows"?"win32":e}return i(globalThis)?globalThis.Bun.platform??"unknown":process.platform},"getPlatform"),f=r(()=>{if(t(globalThis)){const e=globalThis.Deno.build?.arch??"unknown";return e==="x86_64"?"x64":e==="aarch64"?"arm64":e}return i(globalThis)?globalThis.Bun.process.arch:process.arch},"getArch"),x=r(()=>{if(t(globalThis)){const e=globalThis.Deno,s={};return e.version?.deno&&(s.deno=e.version.deno),e.version?.v8&&(s.v8=e.version.v8),e.version?.typescript&&(s.typescript=e.version.typescript),s}if(i(globalThis)){const e=globalThis.Bun,s={...e.process.versions};return e.version&&(s.bun=e.version),s}return process.versions},"getVersions"),d=r((e=0)=>{if(t(globalThis))throw globalThis.Deno.exit(e),new Error("Deno exit failed");if(i(globalThis))throw globalThis.Bun.process.exit(e),new Error("Bun exit failed");process.exit(e)},"exitProcess"),w=r((e,s)=>{if(t(globalThis))return()=>{};if(i(globalThis)){try{const n=globalThis.Bun;if(n.process?.on)return n.process.on(e,s),()=>{n.process?.removeListener&&n.process.removeListener(e,s)}}catch{}return()=>{}}const o=process;return o.on(e,s),()=>{o.removeListener(e,s)}},"onProcessEvent");export{b as a,p as b,f as c,u as d,d as e,h as f,x as g,v as h,T as i,w as o};
1
+ var a=Object.defineProperty;var l=(e,s)=>a(e,"name",{value:s,configurable:!0});var g=Object.defineProperty,r=l((e,s)=>g(e,"name",{value:s,configurable:!0}),"r");const t=r(e=>"Deno"in e,"hasDeno"),i=r(e=>"Bun"in e,"hasBun"),h=r(()=>{if(t(globalThis)){const e=globalThis.Deno,s=e.execPath();let o=s;try{const{importMeta:n}=globalThis;n?.url&&(o=n.url)}catch{}return[s,o,...e.args]}return i(globalThis)?globalThis.Bun.process.argv:process.argv},"getArgv"),b=r(()=>t(globalThis)?globalThis.Deno.cwd():i(globalThis)?globalThis.Bun.process.cwd():process.cwd(),"getCwd"),u=r(()=>{if(t(globalThis)){const e=globalThis.Deno;return new Proxy(e.env.toObject(),{get:r((s,o)=>typeof o=="string"?e.env.get(o):s[o],"get"),has:r((s,o)=>typeof o=="string"?e.env.has(o):o in s,"has"),set:r((s,o,n)=>typeof o=="string"?(n===void 0||e.env.set(o,n),!0):!1,"set")})}return i(globalThis)?globalThis.Bun.process.env:process.env},"getEnv"),T=r(()=>t(globalThis)?[]:i(globalThis)?globalThis.Bun.process.execArgv:process.execArgv,"getExecArgv"),v=r(()=>t(globalThis)?globalThis.Deno.execPath():i(globalThis)?globalThis.Bun.process.execPath:process.execPath,"getExecPath"),p=r(()=>{if(t(globalThis)){const e=globalThis.Deno.build?.os??"unknown";return e==="windows"?"win32":e}return i(globalThis)?globalThis.Bun.platform??"unknown":process.platform},"getPlatform"),f=r(()=>{if(t(globalThis)){const e=globalThis.Deno.build?.arch??"unknown";return e==="x86_64"?"x64":e==="aarch64"?"arm64":e}return i(globalThis)?globalThis.Bun.process.arch:process.arch},"getArch"),x=r(()=>{if(t(globalThis)){const e=globalThis.Deno,s={};return e.version?.deno&&(s.deno=e.version.deno),e.version?.v8&&(s.v8=e.version.v8),e.version?.typescript&&(s.typescript=e.version.typescript),s}if(i(globalThis)){const e=globalThis.Bun,s={...e.process.versions};return e.version&&(s.bun=e.version),s}return process.versions},"getVersions"),d=r((e=0)=>{if(t(globalThis))throw globalThis.Deno.exit(e),new Error("Deno exit failed");if(i(globalThis))throw globalThis.Bun.process.exit(e),new Error("Bun exit failed");process.exit(e)},"exitProcess"),w=r((e,s)=>{if(t(globalThis))return()=>{};if(i(globalThis)){try{const n=globalThis.Bun;if(n.process?.on)return n.process.on(e,s),()=>{n.process?.removeListener&&n.process.removeListener(e,s)}}catch{}return()=>{}}const o=process;return o.on(e,s),()=>{o.removeListener(e,s)}},"onProcessEvent");export{b as a,p as b,f as c,u as d,d as e,T as f,x as g,h,v as i,w as o};
@@ -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-Dz-wu1tI.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 +1 @@
1
- var u=Object.defineProperty;var i=(e,r)=>u(e,"name",{value:r,configurable:!0});import{G as h}from"../packem_shared/renderError-ZMlMvw1N-eVUSdl6c.js";import{e as p}from"../packem_shared/runtime-process-G-n-wOub.js";var E=Object.defineProperty,a=i((e,r)=>E(e,"name",{value:r,configurable:!0}),"n");const P=a((e={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:a(async(r,t)=>{const{logger:o,runtime:l}=t,{detailed:s=!1,exitOnError:d=!0,formatter:n,logErrors:f=!0,renderOptions:c={}}=e;if(f)if(n)o.error(n(r));else if(s){const g=l.getCwd(),m=h(r,{cwd:g,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...c});o.error(m)}else o.error(r);d&&p(1)},"handleError"),version:"1.0.0"}),"errorHandlerPlugin");export{P as errorHandlerPlugin};
1
+ var u=Object.defineProperty;var n=(e,r)=>u(e,"name",{value:r,configurable:!0});import{G as h}from"../packem_shared/renderError-B_XyYPKJ-B65kP-Ou.js";import{e as p}from"../packem_shared/runtime-process-DKHFvYkv.js";var E=Object.defineProperty,a=n((e,r)=>E(e,"name",{value:r,configurable:!0}),"n");const P=a((e={})=>({description:"Enhanced error handling and reporting with beautiful code frames",name:"error-handler",onError:a((r,t)=>{const{logger:o,runtime:l}=t,{detailed:s=!1,exitOnError:d=!0,formatter:i,logErrors:f=!0,renderOptions:g={}}=e;if(f)if(i)o.error(i(r));else if(s){const c=l.getCwd(),m=h(r,{cwd:c,hideErrorCodeView:!1,hideErrorTitle:!1,hideMessage:!1,linesAbove:2,linesBelow:3,...g});o.error(m)}else o.error(r);d&&p(1)},"handleError"),version:"1.0.0"}),"errorHandlerPlugin");export{P as errorHandlerPlugin};