@visulima/cerebro 3.0.0-alpha.9 → 3.0.0
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/CHANGELOG.md +591 -0
- package/LICENSE.md +1295 -3950
- package/README.md +182 -2
- package/dist/commands/completion-command.d.ts +6 -5
- package/dist/commands/completion-command.js +5 -203
- package/dist/commands/help-command.d.ts +10 -9
- package/dist/commands/help-command.js +1 -3
- package/dist/commands/readme-command.d.ts +6 -5
- package/dist/commands/readme-command.js +32 -330
- package/dist/commands/version-command.d.ts +4 -3
- package/dist/commands/version-command.js +1 -18
- package/dist/index.d.ts +516 -95
- package/dist/index.js +1 -7
- package/dist/logger/create-pail-logger.d.ts +770 -8
- package/dist/logger/create-pail-logger.js +1 -34
- package/dist/packem_chunks/has-new-version.js +1 -259
- package/dist/packem_shared/Cerebro-Czc4t-75.js +4 -0
- package/dist/packem_shared/VERBOSITY_DEBUG-XPultrIA.js +1 -0
- package/dist/packem_shared/VisulimaError-C90oeIMu.js +76 -0
- package/dist/packem_shared/VisulimaError-DTMgXonA-CzaryRgZ.js +1 -0
- package/dist/packem_shared/cerebro-error-BjBcYVRO.js +1 -0
- package/dist/packem_shared/command.d-DbhtfXF4.d.ts +639 -0
- package/dist/packem_shared/index-B7-8G-9s.js +29 -0
- package/dist/packem_shared/index.d-BL4NtVR3.d.ts +127 -0
- package/dist/packem_shared/lazyNamed-DMUm8mZe.js +1 -0
- package/dist/packem_shared/renderError-B3ePOoBG-BmZlyMcr.js +25 -0
- package/dist/packem_shared/runtime-process-Dmz0vCJy.js +1 -0
- package/dist/packem_shared/split-by-case-Dbpgd7rf.js +1 -0
- package/dist/plugins/error-handler-plugin.d.ts +21 -19
- package/dist/plugins/error-handler-plugin.js +1 -636
- package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
- package/dist/plugins/runtime-version-check-plugin.js +1 -77
- package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +28 -8
- package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -517
- package/dist/util/general/compile-cache.d.ts +41 -0
- package/dist/util/general/compile-cache.js +1 -0
- package/dist/util/general/heap-tuning.d.ts +18 -0
- package/dist/util/general/heap-tuning.js +1 -0
- package/package.json +33 -28
- package/dist/cli.d.ts +0 -203
- package/dist/constants.d.ts +0 -29
- package/dist/default-env.d.ts +0 -7
- package/dist/default-options.d.ts +0 -3
- package/dist/empty-toolbox.d.ts +0 -15
- package/dist/errors/cerebro-error.d.ts +0 -10
- package/dist/errors/command-not-found-error.d.ts +0 -9
- package/dist/errors/command-validation-error.d.ts +0 -10
- package/dist/errors/completion-error.d.ts +0 -9
- package/dist/errors/conflicting-options-error.d.ts +0 -10
- package/dist/errors/plugin-error.d.ts +0 -9
- package/dist/errors/update-notifier-error.d.ts +0 -7
- package/dist/packem_shared/Cerebro-C2mnCyQf.js +0 -3313
- package/dist/packem_shared/VERBOSITY_QUIET-Dp46zlLW.js +0 -10
- package/dist/packem_shared/VisulimaError-DA7QsCxH.js +0 -34
- package/dist/packem_shared/cerebro-error-GmJ3jN7Q.js +0 -16
- package/dist/packem_shared/help-command-BY7rQUvM.js +0 -249
- package/dist/packem_shared/index-C2-8b3A4.js +0 -259
- package/dist/packem_shared/runtime-process-B6ZplyWn.js +0 -187
- package/dist/plugin-manager.d.ts +0 -53
- package/dist/plugins/update-notifier/cache.d.ts +0 -11
- package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
- package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
- package/dist/types/cli.d.ts +0 -102
- package/dist/types/command-line-usage.d.ts +0 -37
- package/dist/types/command.d.ts +0 -136
- package/dist/types/option-types.d.ts +0 -83
- package/dist/types/options.d.ts +0 -4
- package/dist/types/plugin.d.ts +0 -53
- package/dist/types/toolbox.d.ts +0 -96
- package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
- package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
- package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
- package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
- package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
- package/dist/util/command-line-commands.d.ts +0 -10
- package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
- package/dist/util/command-line-usage/index.d.ts +0 -3
- package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
- package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
- package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
- package/dist/util/command-processing/command-processor.d.ts +0 -37
- package/dist/util/command-processing/command-validation.d.ts +0 -17
- package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
- package/dist/util/command-processing/option-processor.d.ts +0 -44
- package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
- package/dist/util/data-processing/merge-arguments.d.ts +0 -7
- package/dist/util/general/find-alternatives.d.ts +0 -8
- package/dist/util/general/hide-bin.d.ts +0 -2
- package/dist/util/general/parse-raw-command.d.ts +0 -7
- package/dist/util/general/register-exception-handler.d.ts +0 -9
- package/dist/util/general/runtime-process.d.ts +0 -65
- package/dist/util/general/semver-gt.d.ts +0 -2
- package/dist/util/general/validate-input.d.ts +0 -24
- package/dist/util/process-env-variables.d.ts +0 -9
- package/dist/util/security.d.ts +0 -58
- package/dist/util/text-processing/template-format.d.ts +0 -5
package/dist/types/plugin.d.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { Cli } from "./cli.d.ts";
|
|
2
|
-
import type { Toolbox } from "./toolbox.d.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Context provided to plugins during initialization
|
|
5
|
-
*/
|
|
6
|
-
export interface PluginContext<T extends Console = Console> {
|
|
7
|
-
/** The CLI instance */
|
|
8
|
-
cli: Cli<T>;
|
|
9
|
-
/** Current working directory */
|
|
10
|
-
cwd: string;
|
|
11
|
-
/** Logger instance */
|
|
12
|
-
logger: T;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Plugin interface with lifecycle hooks
|
|
16
|
-
*/
|
|
17
|
-
export interface Plugin<T extends Console = Console> {
|
|
18
|
-
/**
|
|
19
|
-
* Called after command execution completes successfully
|
|
20
|
-
* @param toolbox The command toolbox
|
|
21
|
-
* @param result The result returned by the command
|
|
22
|
-
*/
|
|
23
|
-
afterCommand?: (toolbox: Toolbox<T>, result: unknown) => Promise<void> | void;
|
|
24
|
-
/**
|
|
25
|
-
* Called before command execution
|
|
26
|
-
* @param toolbox The command toolbox
|
|
27
|
-
*/
|
|
28
|
-
beforeCommand?: (toolbox: Toolbox<T>) => Promise<void> | void;
|
|
29
|
-
/** Plugin dependencies (other plugin names that must be loaded first) */
|
|
30
|
-
dependencies?: string[];
|
|
31
|
-
/** Plugin description */
|
|
32
|
-
description?: string;
|
|
33
|
-
/**
|
|
34
|
-
* Called during command execution (for plugins that extend toolbox functionality)
|
|
35
|
-
* @param toolbox The command toolbox
|
|
36
|
-
*/
|
|
37
|
-
execute?: (toolbox: Toolbox<T>) => Promise<void> | void;
|
|
38
|
-
/**
|
|
39
|
-
* Called once during plugin initialization
|
|
40
|
-
* @param context The plugin context
|
|
41
|
-
*/
|
|
42
|
-
init?: (context: PluginContext<T>) => Promise<void> | void;
|
|
43
|
-
/** Plugin name (must be unique) */
|
|
44
|
-
name: string;
|
|
45
|
-
/**
|
|
46
|
-
* Called when an error occurs during command execution
|
|
47
|
-
* @param error The error that occurred
|
|
48
|
-
* @param toolbox The command toolbox
|
|
49
|
-
*/
|
|
50
|
-
onError?: (error: Error, toolbox: Toolbox<T>) => Promise<void> | void;
|
|
51
|
-
/** Plugin version */
|
|
52
|
-
version?: string;
|
|
53
|
-
}
|
package/dist/types/toolbox.d.ts
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import type { Cli as ICli } from "./cli.d.ts";
|
|
2
|
-
import type { Command as ICommand } from "./command.d.ts";
|
|
3
|
-
import type { Options } from "./options.d.ts";
|
|
4
|
-
/**
|
|
5
|
-
* Type-safe Toolbox interface with customizable options and environment variable types.
|
|
6
|
-
* @template TLogger - The logger type (defaults to Console)
|
|
7
|
-
* @template TOptions - The options type (defaults to Options/Record<string, unknown>)
|
|
8
|
-
* @template TEnv - The environment variables type (defaults to Record<string, unknown>)
|
|
9
|
-
*/
|
|
10
|
-
export interface Toolbox<TLogger extends Console = Console, TOptions extends Record<string, unknown> = Options, TEnv extends Record<string, unknown> = Record<string, unknown>> extends Cerebro.ExtensionOverrides {
|
|
11
|
-
/**
|
|
12
|
-
* The argument passed to the command.
|
|
13
|
-
* For example, if you run `cerebro foo bar baz`, then this will be `["foo", "bar", "baz"]`.
|
|
14
|
-
* @example
|
|
15
|
-
* ```typescript
|
|
16
|
-
* cli.addCommand({
|
|
17
|
-
* name: "copy",
|
|
18
|
-
* argument: {
|
|
19
|
-
* name: "files",
|
|
20
|
-
* type: String,
|
|
21
|
-
* description: "Files to copy"
|
|
22
|
-
* },
|
|
23
|
-
* execute: ({ argument }) => {
|
|
24
|
-
* // argument is an array of strings
|
|
25
|
-
* // argument[0] is the first file, argument[1] is the second, etc.
|
|
26
|
-
* argument.forEach((file) => console.log(`Copying ${file}...`));
|
|
27
|
-
* }
|
|
28
|
-
* });
|
|
29
|
-
* ```
|
|
30
|
-
*/
|
|
31
|
-
argument: string[];
|
|
32
|
-
argv: ReadonlyArray<string>;
|
|
33
|
-
/**
|
|
34
|
-
* The command that is being executed.
|
|
35
|
-
*/
|
|
36
|
-
command: ICommand;
|
|
37
|
-
/**
|
|
38
|
-
* The name of the command that is being executed.
|
|
39
|
-
*/
|
|
40
|
-
commandName: string;
|
|
41
|
-
/**
|
|
42
|
-
* Environment variables processed from the command definition.
|
|
43
|
-
* Values are transformed according to their type definitions and default values.
|
|
44
|
-
* @example
|
|
45
|
-
* ```typescript
|
|
46
|
-
* // Define env types when creating command
|
|
47
|
-
* type MyEnv = { apiKey: string; debug: boolean };
|
|
48
|
-
*
|
|
49
|
-
* cli.addCommand({
|
|
50
|
-
* name: "build",
|
|
51
|
-
* env: [
|
|
52
|
-
* { name: "API_KEY", type: String },
|
|
53
|
-
* { name: "DEBUG", type: Boolean }
|
|
54
|
-
* ],
|
|
55
|
-
* execute: ({ env }) => {
|
|
56
|
-
* // env.apiKey and env.debug are now typed!
|
|
57
|
-
* console.log(env.apiKey, env.debug);
|
|
58
|
-
* }
|
|
59
|
-
* });
|
|
60
|
-
* ```
|
|
61
|
-
*/
|
|
62
|
-
env: TEnv;
|
|
63
|
-
/** The logger instance. */
|
|
64
|
-
logger: TLogger;
|
|
65
|
-
/**
|
|
66
|
-
* Any optional parameters. Typically coming from command-line
|
|
67
|
-
* argument like this: `--force -p tsconfig-mjson`.
|
|
68
|
-
* @example
|
|
69
|
-
* ```typescript
|
|
70
|
-
* // Define options type for better autocomplete
|
|
71
|
-
* type MyOptions = {
|
|
72
|
-
* output?: string;
|
|
73
|
-
* verbose?: boolean;
|
|
74
|
-
* port?: number;
|
|
75
|
-
* };
|
|
76
|
-
*
|
|
77
|
-
* cli.addCommand({
|
|
78
|
-
* name: "serve",
|
|
79
|
-
* options: [
|
|
80
|
-
* { name: "output", type: String },
|
|
81
|
-
* { name: "verbose", type: Boolean },
|
|
82
|
-
* { name: "port", type: Number }
|
|
83
|
-
* ],
|
|
84
|
-
* execute: ({ options }: { options: MyOptions }) => {
|
|
85
|
-
* // options.output, options.verbose, options.port are typed!
|
|
86
|
-
* console.log(options.output, options.verbose, options.port);
|
|
87
|
-
* }
|
|
88
|
-
* });
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
options: TOptions;
|
|
92
|
-
/**
|
|
93
|
-
* This is the instance of the CLI that is running the command.
|
|
94
|
-
*/
|
|
95
|
-
runtime: ICli<TLogger>;
|
|
96
|
-
}
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { OptionDefinition, PossibleOptionDefinition } from "../../types/command.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Gets the values of any boolean arguments that were specified on the command line with a value.
|
|
4
|
-
* These arguments were removed by removeBooleanValues.
|
|
5
|
-
*/
|
|
6
|
-
declare const getBooleanValues: <OD extends OptionDefinition<unknown>>(arguments_: string[], options: PossibleOptionDefinition<OD>[], optionMapByName?: Map<string, PossibleOptionDefinition<OD>>, optionMapByAlias?: Map<string, PossibleOptionDefinition<OD>>) => Partial<OD>;
|
|
7
|
-
export default getBooleanValues;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { OptionDefinition, PossibleOptionDefinition } from "../../types/command.d.ts";
|
|
2
|
-
declare const getParameterOption: <OD extends OptionDefinition<unknown>>(argument: string, options: PossibleOptionDefinition<OD>[], optionMapByName?: Map<string, PossibleOptionDefinition<OD>>, optionMapByAlias?: Map<string, PossibleOptionDefinition<OD>>) => {
|
|
3
|
-
argName?: string;
|
|
4
|
-
argValue?: string;
|
|
5
|
-
option?: PossibleOptionDefinition<OD>;
|
|
6
|
-
};
|
|
7
|
-
export default getParameterOption;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { OptionDefinition, PossibleOptionDefinition } from "../../types/command.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Determines whether an option definition is typed as Boolean.
|
|
4
|
-
* @template OD
|
|
5
|
-
* @param option Option definition to inspect.
|
|
6
|
-
* @returns True when the option's type constructor is the built-in `Boolean`.
|
|
7
|
-
*/
|
|
8
|
-
declare const optionIsBoolean: <OD extends OptionDefinition<unknown>>(option: PossibleOptionDefinition<OD>) => boolean;
|
|
9
|
-
export default optionIsBoolean;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { OptionDefinition, PossibleOptionDefinition } from "../../types/command.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Removes boolean values from arguments to prevent commandLineArgs errors.
|
|
4
|
-
* commandLineArgs throws an error if we pass a value for a boolean arg as follows:
|
|
5
|
-
* myCommand -a=true --booleanArg=false --otherArg true
|
|
6
|
-
* This function removes these booleans to avoid errors from commandLineArgs.
|
|
7
|
-
*/
|
|
8
|
-
declare const removeBooleanValues: <OD extends OptionDefinition<any>>(arguments_: string[], options: PossibleOptionDefinition<OD>[], optionMapByName?: Map<string, PossibleOptionDefinition<OD>>, optionMapByAlias?: Map<string, PossibleOptionDefinition<OD>>) => string[];
|
|
9
|
-
export default removeBooleanValues;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copied from
|
|
3
|
-
* The MIT License (MIT)
|
|
4
|
-
* Copyright (c) 2015-21 Lloyd Brookes <75pound@gmail.com>
|
|
5
|
-
*/
|
|
6
|
-
declare const commandLineCommands: (commands: (string | null)[], argv: string[]) => {
|
|
7
|
-
argv: string[];
|
|
8
|
-
command: string | null;
|
|
9
|
-
};
|
|
10
|
-
export default commandLineCommands;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Gets the terminal width from the CEREBRO_TERMINAL_WIDTH environment variable.
|
|
3
|
-
* Falls back to undefined if not set, allowing the tabular package to detect it automatically.
|
|
4
|
-
* @returns The terminal width as a number, or undefined if not set
|
|
5
|
-
*/
|
|
6
|
-
declare const getTerminalWidth: () => number | undefined;
|
|
7
|
-
export default getTerminalWidth;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { Content as IContent } from "../../../types/command-line-usage.d.ts";
|
|
2
|
-
import BaseSection from "./base-section.d.ts";
|
|
3
|
-
/**
|
|
4
|
-
* A Content section comprises a header and one or more lines of content.
|
|
5
|
-
* @property header The section header, always bold and underlined.
|
|
6
|
-
* @property content Overloaded property, accepting data in one of four formats:
|
|
7
|
-
*
|
|
8
|
-
* 1. A single string (one line of text)
|
|
9
|
-
* 2. An array of strings (multiple lines of text)
|
|
10
|
-
* 3. An array of objects (recordset-style data). In this case, the data will be rendered in table format. The property names of each object are not important, so long as they are consistent throughout the array.
|
|
11
|
-
* 4. An object with two properties - `data` and `options`. In this case, the data and options will be passed directly to the underlying [table](https://github.com/visulima/visulima/tree/main/packages/tabular) module for rendering.
|
|
12
|
-
* @property raw - Set to true to avoid indentation and wrapping. Useful for banners.
|
|
13
|
-
* @example
|
|
14
|
-
* Simple string of content. For ansi formatting, use [colorize template literal syntax](https://github.com/visulima/visulima/tree/main/packages/colorize#tagged-template-literals).
|
|
15
|
-
* ```js
|
|
16
|
-
* {
|
|
17
|
-
* header: 'A typical app',
|
|
18
|
-
* content: 'Generates something {rgb(255,200,0).italic very {underline.bgRed important}}.'
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* An array of strings is interpreted as lines, to be joined by the system newline character.
|
|
23
|
-
* ```js
|
|
24
|
-
* {
|
|
25
|
-
* header: 'A typical app',
|
|
26
|
-
* content: [
|
|
27
|
-
* 'First line.',
|
|
28
|
-
* 'Second line.'
|
|
29
|
-
* ],
|
|
30
|
-
* }
|
|
31
|
-
* ```
|
|
32
|
-
*
|
|
33
|
-
* An array of arrays is rendered in table layout.
|
|
34
|
-
* ```js
|
|
35
|
-
* {
|
|
36
|
-
* header: 'A typical app',
|
|
37
|
-
* content: [
|
|
38
|
-
* [ 'First row, first column.', 'First row, second column.', ],
|
|
39
|
-
* [ 'Second row, first column.', 'Second row, second column.', ],
|
|
40
|
-
* ]
|
|
41
|
-
* }
|
|
42
|
-
* ```
|
|
43
|
-
*
|
|
44
|
-
* An object with `data` and `options` properties will be passed directly to the underlying [table](https://github.com/cli-table/cli-table3) module for rendering.
|
|
45
|
-
* ```js
|
|
46
|
-
* {
|
|
47
|
-
* header: 'A typical app',
|
|
48
|
-
* content: {
|
|
49
|
-
* data: [
|
|
50
|
-
* [ 'First row, first column.', 'First row, second column.', ],
|
|
51
|
-
* [ 'Second row, first column.', 'Second row, second column.', ],
|
|
52
|
-
* 'Second row, first column.',
|
|
53
|
-
* ],
|
|
54
|
-
* options: {
|
|
55
|
-
* colWidths: [80],
|
|
56
|
-
* }
|
|
57
|
-
* }
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
*/
|
|
61
|
-
declare class ContentSection extends BaseSection {
|
|
62
|
-
constructor(section: IContent);
|
|
63
|
-
private getContentLines;
|
|
64
|
-
}
|
|
65
|
-
export default ContentSection;
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { OptionList as IOptionList } from "../../../types/command-line-usage.d.ts";
|
|
2
|
-
import BaseSection from "./base-section.d.ts";
|
|
3
|
-
declare class OptionListSection extends BaseSection {
|
|
4
|
-
constructor(data: IOptionList);
|
|
5
|
-
private getOptionNames;
|
|
6
|
-
private intersect;
|
|
7
|
-
}
|
|
8
|
-
/**
|
|
9
|
-
* An OptionList section adds a table displaying the supplied option definitions.
|
|
10
|
-
* @property {string} [header] - The section header, always bold and underlined.
|
|
11
|
-
* @property optionList {OptionDefinition[]} - An array of [option definition](https://github.com/75lb/command-line-args/blob/master/doc/option-definition.md) objects. In addition to the regular definition properties, command-line-usage will look for:
|
|
12
|
-
*
|
|
13
|
-
* - `description` - a string describing the option.
|
|
14
|
-
* - `typeLabel` - a string to replace the default type string (e.g. `<string>`). It's often more useful to set a more descriptive type label, like `<ms>`, `<files>`, `<command>` etc.
|
|
15
|
-
* @property {string|string[]} [group] - If specified, only options from this particular group will be printed. [Example](https://github.com/75lb/command-line-usage/blob/master/example/groups.js).
|
|
16
|
-
* @property {string|string[]} [hide] - The names of one of more option definitions to hide from the option list. [Example](https://github.com/75lb/command-line-usage/blob/master/example/hide.js).
|
|
17
|
-
* @property {boolean} [reverseNameOrder] - If true, the option alias will be displayed after the name, i.e. `--verbose, -v` instead of `-v, --verbose`).
|
|
18
|
-
* @property {object} [tableOptions] - An options object suitable for passing into [table-layout](https://github.com/75lb/table-layout#table-). See [here for an example](https://github.com/75lb/command-line-usage/blob/master/example/option-list-options.js).
|
|
19
|
-
* @example
|
|
20
|
-
* {
|
|
21
|
-
* header: 'Options',
|
|
22
|
-
* optionList: [
|
|
23
|
-
* {
|
|
24
|
-
* name: 'help',
|
|
25
|
-
* alias: 'h',
|
|
26
|
-
* description: 'Display this usage guide.'
|
|
27
|
-
* },
|
|
28
|
-
* {
|
|
29
|
-
* name: 'src',
|
|
30
|
-
* description: 'The input files to process',
|
|
31
|
-
* multiple: true,
|
|
32
|
-
* defaultOption: true,
|
|
33
|
-
* typeLabel: '{underline file} ...'
|
|
34
|
-
* },
|
|
35
|
-
* {
|
|
36
|
-
* name: 'timeout',
|
|
37
|
-
* description: 'Timeout value in ms.',
|
|
38
|
-
* alias: 't',
|
|
39
|
-
* typeLabel: '{underline ms}'
|
|
40
|
-
* }
|
|
41
|
-
* ]
|
|
42
|
-
* }
|
|
43
|
-
*/
|
|
44
|
-
export default OptionListSection;
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import type { CommandLineOptions } from "@visulima/command-line-args";
|
|
2
|
-
import type { Command as ICommand, OptionDefinition } from "../../types/command.d.ts";
|
|
3
|
-
import type { Toolbox as IToolbox } from "../../types/toolbox.d.ts";
|
|
4
|
-
import mergeArguments from "../data-processing/merge-arguments.d.ts";
|
|
5
|
-
/**
|
|
6
|
-
* Prepares the toolbox for command execution.
|
|
7
|
-
* @template OD The option definition type.
|
|
8
|
-
* @param command The command to prepare toolbox for.
|
|
9
|
-
* @param parsedArgs Parsed command-line arguments.
|
|
10
|
-
* @param booleanValues Extracted boolean flag values.
|
|
11
|
-
* @param extraOptions Additional options to merge into toolbox.
|
|
12
|
-
* @returns The prepared toolbox instance.
|
|
13
|
-
*/
|
|
14
|
-
export declare const prepareToolbox: <OD extends OptionDefinition<unknown>, TLogger extends Console = Console>(command: ICommand<OD, TLogger>, parsedArgs: CommandLineOptions, booleanValues: Record<string, unknown>, extraOptions: Record<string, unknown>) => IToolbox<TLogger>;
|
|
15
|
-
/**
|
|
16
|
-
* Processes command arguments and options.
|
|
17
|
-
* @template OD The option definition type.
|
|
18
|
-
* @param command The command to process arguments for.
|
|
19
|
-
* @param commandArguments Raw command-line argument strings.
|
|
20
|
-
* @param defaultOptions Default option definitions to merge.
|
|
21
|
-
* @returns Object containing merged arguments, boolean values, and parsed args.
|
|
22
|
-
* @throws {Error} When an argument has both multiple and lazyMultiple options.
|
|
23
|
-
*/
|
|
24
|
-
export declare const processCommandArgs: <OD extends OptionDefinition<unknown>, TLogger extends Console = Console>(command: ICommand<OD, TLogger>, commandArguments: string[], defaultOptions: OptionDefinition<unknown>[]) => {
|
|
25
|
-
arguments_: ReturnType<typeof mergeArguments>;
|
|
26
|
-
booleanValues: Record<string, unknown>;
|
|
27
|
-
parsedArgs: CommandLineOptions;
|
|
28
|
-
};
|
|
29
|
-
/**
|
|
30
|
-
* Executes a command and returns its result.
|
|
31
|
-
* @template OD The option definition type.
|
|
32
|
-
* @param command The command to execute.
|
|
33
|
-
* @param toolbox The prepared toolbox for command execution.
|
|
34
|
-
* @param _commandArgs Parsed command arguments.
|
|
35
|
-
* @returns Promise resolving to the command execution result.
|
|
36
|
-
*/
|
|
37
|
-
export declare const executeCommand: <OD extends OptionDefinition<unknown>, TLogger extends Console = Console>(command: ICommand<OD, TLogger>, toolbox: IToolbox<TLogger>, _commandArgs: CommandLineOptions) => Promise<unknown>;
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type { CommandLineOptions } from "@visulima/command-line-args";
|
|
2
|
-
import type { Command as ICommand, OptionDefinition, PossibleOptionDefinition } from "../../types/command.d.ts";
|
|
3
|
-
import type { Toolbox as IToolbox } from "../../types/toolbox.d.ts";
|
|
4
|
-
/**
|
|
5
|
-
* Validates that all required options are present.
|
|
6
|
-
* Uses pre-computed required options metadata from command registration for performance.
|
|
7
|
-
*/
|
|
8
|
-
export declare const validateRequiredOptions: <OD extends OptionDefinition<unknown>, TLogger extends Console = Console>(arguments_: PossibleOptionDefinition<OD>[], commandArguments: CommandLineOptions, command: ICommand<OD, TLogger>) => void;
|
|
9
|
-
/**
|
|
10
|
-
* Validates for conflicting options.
|
|
11
|
-
* Uses pre-computed conflict metadata from command registration for performance.
|
|
12
|
-
*/
|
|
13
|
-
export declare const validateConflictingOptions: <OD extends OptionDefinition<unknown>, TLogger extends Console = Console>(arguments_: PossibleOptionDefinition<OD>[], commandArguments: IToolbox["options"], command: ICommand<OD, TLogger>) => void;
|
|
14
|
-
/**
|
|
15
|
-
* Validates for duplicate option definitions.
|
|
16
|
-
*/
|
|
17
|
-
export declare const validateDuplicateOptions: <OD extends OptionDefinition<unknown>>(command: ICommand<OD>) => void;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses nested command paths from argv.
|
|
3
|
-
* Supports both flat commands (e.g., "build") and nested commands (e.g., "deploy staging").
|
|
4
|
-
* @param availableCommands Map of all available commands keyed by their full path string
|
|
5
|
-
* @param argv Command line arguments to parse
|
|
6
|
-
* @returns Object with the matched command path and remaining argv
|
|
7
|
-
*/
|
|
8
|
-
export declare const parseNestedCommand: (availableCommands: Map<string, string[]>, argv: string[]) => {
|
|
9
|
-
argv: string[];
|
|
10
|
-
commandPath: string[] | undefined;
|
|
11
|
-
};
|
|
12
|
-
/**
|
|
13
|
-
* Generates a lookup key from a command path array.
|
|
14
|
-
* @param commandPath Array of command path segments
|
|
15
|
-
* @returns The command path key string
|
|
16
|
-
*/
|
|
17
|
-
export declare const getCommandPathKey: (commandPath: string[]) => string;
|
|
18
|
-
/**
|
|
19
|
-
* Generates the full command path for a command, including its commandPath if present.
|
|
20
|
-
* Combines the command name with any parent path segments.
|
|
21
|
-
* @param commandName The name of the command to add to the path
|
|
22
|
-
* @param commandPath Optional path segments from the command definition
|
|
23
|
-
* @returns The full command path array combining commandPath and commandName
|
|
24
|
-
*/
|
|
25
|
-
export declare const getFullCommandPath: (commandName: string, commandPath?: string[]) => string[];
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import type { OptionDefinition } from "../../types/command.d.ts";
|
|
2
|
-
import type { Toolbox as IToolbox } from "../../types/toolbox.d.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Converts option names to camelCase and adds them as __camelCaseName__ properties.
|
|
5
|
-
* @template OD The option definition type
|
|
6
|
-
* @param command The command object containing options to process
|
|
7
|
-
* @param command.options The options array to process
|
|
8
|
-
*/
|
|
9
|
-
export declare const processOptionNames: <OD extends OptionDefinition<unknown>>(command: {
|
|
10
|
-
options?: OD[];
|
|
11
|
-
}) => void;
|
|
12
|
-
/**
|
|
13
|
-
* Adds negatable options for boolean flags.
|
|
14
|
-
* For options starting with "no-", creates a corresponding non-negated option.
|
|
15
|
-
* @template OD The option definition type
|
|
16
|
-
* @param command The command object to add negatable options to
|
|
17
|
-
* @param command.name The name of the command (used for error messages)
|
|
18
|
-
* @param command.options The array of option definitions to process
|
|
19
|
-
* @throws {Error} When a negated option is not of type Boolean
|
|
20
|
-
*/
|
|
21
|
-
export declare const addNegatableOptions: <OD extends OptionDefinition<unknown>>(command: {
|
|
22
|
-
name: string;
|
|
23
|
-
options?: OD[];
|
|
24
|
-
}) => void;
|
|
25
|
-
/**
|
|
26
|
-
* Maps negatable options to their non-negated counterparts.
|
|
27
|
-
* Processes toolbox options starting with "no" and converts them to non-negated form.
|
|
28
|
-
* @param toolbox The command toolbox containing options
|
|
29
|
-
* @param command The command object with option definitions
|
|
30
|
-
* @param command.options The command options array
|
|
31
|
-
*/
|
|
32
|
-
export declare const mapNegatableOptions: <O extends OptionDefinition<unknown>, TLogger extends Console = Console>(toolbox: IToolbox<TLogger>, command: {
|
|
33
|
-
options?: ReadonlyArray<O | OptionDefinition<boolean[]> | OptionDefinition<boolean> | OptionDefinition<number[]> | OptionDefinition<number> | OptionDefinition<string[]> | OptionDefinition<string>>;
|
|
34
|
-
}) => void;
|
|
35
|
-
/**
|
|
36
|
-
* Applies implied option values.
|
|
37
|
-
* Sets implied option values from option definitions that have an implies property.
|
|
38
|
-
* @param toolbox The command toolbox to apply implied values to
|
|
39
|
-
* @param command The command object with option definitions
|
|
40
|
-
* @param command.options The command options array
|
|
41
|
-
*/
|
|
42
|
-
export declare const mapImpliedOptions: <O extends OptionDefinition<unknown>, TLogger extends Console = Console>(toolbox: IToolbox<TLogger>, command: {
|
|
43
|
-
options?: ReadonlyArray<O | OptionDefinition<boolean[]> | OptionDefinition<boolean> | OptionDefinition<number[]> | OptionDefinition<number> | OptionDefinition<string[]> | OptionDefinition<string>>;
|
|
44
|
-
}) => void;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import type { CommandLineOptions } from "@visulima/command-line-args";
|
|
2
|
-
import type { OptionDefinition, PossibleOptionDefinition } from "../../types/command.d.ts";
|
|
3
|
-
/**
|
|
4
|
-
* Lists missing required arguments from parsed command line options
|
|
5
|
-
* Optimized to use pre-filtered required options when available
|
|
6
|
-
* Combines filter operations for better performance
|
|
7
|
-
*
|
|
8
|
-
* Note: This function mutates parsedArguments by setting missing boolean options to false.
|
|
9
|
-
* @param commandLineConfig All command options OR pre-filtered required options
|
|
10
|
-
* @param parsedArguments Parsed command line arguments (will be mutated for boolean defaults)
|
|
11
|
-
* @param onlyRequired If true, commandLineConfig already contains only required options (optimization)
|
|
12
|
-
* @returns Array of missing required options
|
|
13
|
-
*/
|
|
14
|
-
declare const listMissingArguments: <OD extends OptionDefinition<any>>(commandLineConfig: PossibleOptionDefinition<OD>[], parsedArguments: CommandLineOptions, onlyRequired?: boolean) => PossibleOptionDefinition<OD>[];
|
|
15
|
-
export default listMissingArguments;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import type { OptionDefinition, PossibleOptionDefinition } from "../../types/command.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Performs a simple merge of multiple argument lists. Does not mutate given
|
|
4
|
-
* argument lists or argument.
|
|
5
|
-
*/
|
|
6
|
-
declare const mergeArguments: <OD extends OptionDefinition<any>>(argumentLists: PossibleOptionDefinition<OD>[]) => PossibleOptionDefinition<OD>[];
|
|
7
|
-
export default mergeArguments;
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Finds strings in an array that are similar to the given string.
|
|
3
|
-
* @param string The target string to match against
|
|
4
|
-
* @param array Array of candidate strings to search
|
|
5
|
-
* @returns Array of similar strings from the input array
|
|
6
|
-
*/
|
|
7
|
-
declare const findAlternatives: (string: string, array: string[]) => string[];
|
|
8
|
-
export default findAlternatives;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Parses the raw command into an array of strings.
|
|
3
|
-
* @param commandArray Command string or list of command parts.
|
|
4
|
-
* @returns The command as an array of strings.
|
|
5
|
-
*/
|
|
6
|
-
declare const parseRawCommand: (commandArray: string[] | string) => string[];
|
|
7
|
-
export default parseRawCommand;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Registers global exception handlers for uncaught exceptions and unhandled promise rejections.
|
|
3
|
-
* Logs errors using the provided logger and exits the process with code 1.
|
|
4
|
-
* @template T - Logger type that extends Console interface
|
|
5
|
-
* @param logger Console-like logger instance for error reporting
|
|
6
|
-
* @returns Cleanup function to remove event listeners
|
|
7
|
-
*/
|
|
8
|
-
declare const registerExceptionHandler: <T extends Console = Console>(logger: T) => () => void;
|
|
9
|
-
export default registerExceptionHandler;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runtime-agnostic process-like APIs that work across Node.js, Deno, and Bun.
|
|
3
|
-
*/
|
|
4
|
-
/**
|
|
5
|
-
* Gets command line arguments compatible with process.argv format.
|
|
6
|
-
* For Deno, constructs argv from Deno.args (prepending execPath).
|
|
7
|
-
* For Node.js and Bun, uses process.argv directly.
|
|
8
|
-
* @returns Array of command line arguments
|
|
9
|
-
*/
|
|
10
|
-
export declare const getArgv: () => ReadonlyArray<string>;
|
|
11
|
-
/**
|
|
12
|
-
* Gets the current working directory.
|
|
13
|
-
* @returns The current working directory path
|
|
14
|
-
*/
|
|
15
|
-
export declare const getCwd: () => string;
|
|
16
|
-
/**
|
|
17
|
-
* Gets environment variables as a mutable object.
|
|
18
|
-
* Returns a proxy object that handles mutations across different runtimes.
|
|
19
|
-
* @returns Environment variables object (mutable proxy)
|
|
20
|
-
*/
|
|
21
|
-
export declare const getEnv: () => Record<string, string | undefined>;
|
|
22
|
-
/**
|
|
23
|
-
* Gets execution arguments (e.g., --inspect, --trace-warnings).
|
|
24
|
-
* @returns Array of execution arguments
|
|
25
|
-
*/
|
|
26
|
-
export declare const getExecArgv: () => ReadonlyArray<string>;
|
|
27
|
-
/**
|
|
28
|
-
* Gets the absolute pathname of the executable that started the process.
|
|
29
|
-
* @returns The executable path
|
|
30
|
-
*/
|
|
31
|
-
export declare const getExecPath: () => string;
|
|
32
|
-
/**
|
|
33
|
-
* Gets the operating system platform.
|
|
34
|
-
* @returns Platform string (e.g., "darwin", "linux", "win32")
|
|
35
|
-
*/
|
|
36
|
-
export declare const getPlatform: () => string;
|
|
37
|
-
/**
|
|
38
|
-
* Gets the CPU architecture.
|
|
39
|
-
* @returns Architecture string (e.g., "x64", "arm64")
|
|
40
|
-
*/
|
|
41
|
-
export declare const getArch: () => string;
|
|
42
|
-
/**
|
|
43
|
-
* Gets version information about the runtime.
|
|
44
|
-
* @returns Object with version strings
|
|
45
|
-
*/
|
|
46
|
-
export declare const getVersions: () => Record<string, string>;
|
|
47
|
-
/**
|
|
48
|
-
* Terminates the process with the specified exit code.
|
|
49
|
-
* @param exitCode Exit code (default: 0)
|
|
50
|
-
*/
|
|
51
|
-
export declare const exitProcess: (exitCode?: number) => never;
|
|
52
|
-
/**
|
|
53
|
-
* Runtime-agnostic event handler registration.
|
|
54
|
-
* Note: Deno and Bun don't have equivalent event emitters, so this only works in Node.js.
|
|
55
|
-
* In other runtimes, handlers are registered but may not be called for all events.
|
|
56
|
-
*/
|
|
57
|
-
export type ProcessEventType = "uncaughtException" | "unhandledRejection";
|
|
58
|
-
export type ProcessEventHandler = (...args: unknown[]) => void;
|
|
59
|
-
/**
|
|
60
|
-
* Registers an event handler for process events.
|
|
61
|
-
* @param event Event type to listen for
|
|
62
|
-
* @param handler Handler function
|
|
63
|
-
* @returns Cleanup function to remove the handler
|
|
64
|
-
*/
|
|
65
|
-
export declare const onProcessEvent: (event: ProcessEventType, handler: ProcessEventHandler) => () => void;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Validates that a string is not empty or whitespace-only.
|
|
3
|
-
*/
|
|
4
|
-
export declare const validateNonEmptyString: (value: unknown, fieldName: string) => string;
|
|
5
|
-
/**
|
|
6
|
-
* Validates that a value is an array of strings.
|
|
7
|
-
*/
|
|
8
|
-
export declare const validateStringArray: (value: unknown, fieldName: string) => string[];
|
|
9
|
-
/**
|
|
10
|
-
* Validates that a value is a function.
|
|
11
|
-
*/
|
|
12
|
-
export declare const validateFunction: (value: unknown, fieldName: string) => (...args: unknown[]) => unknown;
|
|
13
|
-
/**
|
|
14
|
-
* Validates that a value is an object (but not null).
|
|
15
|
-
*/
|
|
16
|
-
export declare const validateObject: (value: unknown, fieldName: string) => Record<string, unknown>;
|
|
17
|
-
/**
|
|
18
|
-
* Validates command name format and prevents malicious inputs.
|
|
19
|
-
*/
|
|
20
|
-
export declare const validateCommandName: (name: string) => string;
|
|
21
|
-
/**
|
|
22
|
-
* Validates plugin name format and prevents malicious inputs.
|
|
23
|
-
*/
|
|
24
|
-
export declare const validatePluginName: (name: string) => string;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { EnvDefinition } from "../types/command.d.ts";
|
|
2
|
-
/**
|
|
3
|
-
* Processes environment variables from a command definition.
|
|
4
|
-
* Transforms string values to their specified types and applies default values.
|
|
5
|
-
* @param envDefinitions Array of environment variable definitions
|
|
6
|
-
* @returns Object with camelCase keys and transformed values
|
|
7
|
-
*/
|
|
8
|
-
declare const processEnvVariables: (envDefinitions: (EnvDefinition<boolean> | EnvDefinition<number> | EnvDefinition<string>)[] | undefined) => Record<string, unknown>;
|
|
9
|
-
export default processEnvVariables;
|