juisy 2.0.0-beta.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/README.md +211 -0
- package/bin/cli/cli.js +23 -0
- package/bin/cli/cmds/changelog.js +41 -0
- package/bin/cli/cmds/docs/generate-api.js +22 -0
- package/bin/cli/cmds/docs/generate-cli.js +11 -0
- package/bin/cli/cmds/docs/generate-readme.js +11 -0
- package/bin/cli/cmds/docs/index.js +22 -0
- package/bin/cli/cmds/docs/lint.js +42 -0
- package/bin/cli/cmds/eject.js +28 -0
- package/bin/cli/cmds/git-hooks/index.js +20 -0
- package/bin/cli/cmds/git-hooks/reset.js +48 -0
- package/bin/cli/cmds/git-hooks/sync.js +19 -0
- package/bin/cli/cmds/index.js +15 -0
- package/bin/cli/cmds/print-globals.js +28 -0
- package/bin/cli/cmds/release.js +231 -0
- package/bin/cli/cmds/squeeze.js +269 -0
- package/bin/cli/cmds/test.js +33 -0
- package/bin/cli/index.js +9 -0
- package/bin/cli/lib/docs/generate-api-doc.js +78 -0
- package/bin/cli/lib/version/update-version.js +52 -0
- package/bin/scripts/commit-msg.js +32 -0
- package/bin/scripts/pre-commit.js +24 -0
- package/dist/DataExporter.d.ts +67 -0
- package/dist/cli/CLIFactory.d.ts +19 -0
- package/dist/cli/Command.d.ts +44 -0
- package/dist/cli/InterfaceUtils.d.ts +53 -0
- package/dist/cli/OutputUtils.d.ts +123 -0
- package/dist/cli/command-visitors/command-handler-injections.d.ts +10 -0
- package/dist/cli/command-visitors/get-command-meta.d.ts +10 -0
- package/dist/cli/command-visitors/index.d.ts +9 -0
- package/dist/cli/command-visitors/private-command.d.ts +16 -0
- package/dist/cli/create-engine.d.ts +7 -0
- package/dist/cli/extract-usage.d.ts +72 -0
- package/dist/cli/index.d.ts +20 -0
- package/dist/cli/index.js +559 -0
- package/dist/cli/types.d.ts +112 -0
- package/dist/cli/utils.d.ts +19 -0
- package/dist/eject.d.ts +22 -0
- package/dist/get-package-info.d.ts +6 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +244 -0
- package/dist/project-globals.d.ts +63 -0
- package/dist/templater/Templater.d.ts +23 -0
- package/dist/templater/index.d.ts +6 -0
- package/dist/templater/index.js +330 -0
- package/dist/templater/markdown-templater/ReadmeTemplater.d.ts +154 -0
- package/dist/templater/markdown-templater/index.d.ts +25 -0
- package/dist/templater/types.d.ts +10 -0
- package/dist/utils/misc.d.ts +21 -0
- package/package.json +179 -0
- package/src/index.js +507 -0
- package/template/CHANGELOG.md +0 -0
- package/template/bin/cli/cli.js +27 -0
- package/template/bin/cli/cmds/changelog.js +71 -0
- package/template/bin/cli/cmds/docs.js +30 -0
- package/template/bin/cli/cmds/docs_cmds/generate-api.js +75 -0
- package/template/bin/cli/cmds/docs_cmds/generate-readme.js +51 -0
- package/template/bin/cli/cmds/git-hooks.js +30 -0
- package/template/bin/cli/cmds/git_hooks_cmds/reset.js +76 -0
- package/template/bin/cli/cmds/git_hooks_cmds/sync.js +44 -0
- package/template/bin/cli/cmds/release.js +219 -0
- package/template/bin/cli/index.js +7 -0
- package/template/bin/cli/lib/docs/generate-api-doc.js +33 -0
- package/template/bin/cli/lib/release/generate-release-note.js +3 -0
- package/template/bin/cli/lib/version/update-version.js +51 -0
- package/template/bin/scripts/commit-msg.js +42 -0
- package/template/bin/scripts/pre-commit.js +32 -0
- package/template/docs/api/docs.config.js +10 -0
- package/template/docs/readme/config.js +22 -0
- package/template/docs/readme/readme.js +70 -0
- package/template/docs/readme/template.md +53 -0
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import run from 'execa'
|
|
2
|
+
/**
|
|
3
|
+
* commit-msg git hook
|
|
4
|
+
*/
|
|
5
|
+
;(async function () {
|
|
6
|
+
console.log('Git hook: commit-msg')
|
|
7
|
+
|
|
8
|
+
// Get git commit msg path from args
|
|
9
|
+
const args = process.argv.slice(2)
|
|
10
|
+
const gitMsgPath = args[0]
|
|
11
|
+
|
|
12
|
+
try {
|
|
13
|
+
// original is: npx --no -- commitlint --edit ${1}
|
|
14
|
+
// we replace "${1}" by gitMsgPath arg
|
|
15
|
+
await run('npx', [
|
|
16
|
+
'--no',
|
|
17
|
+
'--',
|
|
18
|
+
'commitlint',
|
|
19
|
+
'--edit',
|
|
20
|
+
gitMsgPath
|
|
21
|
+
])
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.error('❌ Git hook: "commit-msg" failed. Please check ./COMMIT_CONVENTION.md for more informations.', e)
|
|
24
|
+
console.log() // blank line
|
|
25
|
+
process.exit(1) // Abort with error
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Everything is okay
|
|
29
|
+
console.log('✔ Git hook: "commit-msg" passed')
|
|
30
|
+
|
|
31
|
+
console.log() // blank line
|
|
32
|
+
})()
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import run from 'execa'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Pre commit git hook
|
|
5
|
+
*/
|
|
6
|
+
;(async function () {
|
|
7
|
+
console.log('Git hook: pre-commit')
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
// npx lint-staged
|
|
11
|
+
await run('npx', [
|
|
12
|
+
'lint-staged'
|
|
13
|
+
], { stdio: 'pipe' })
|
|
14
|
+
} catch (e) {
|
|
15
|
+
console.error('Git hook: "commit-msg" error: ', e)
|
|
16
|
+
console.log() // blank line
|
|
17
|
+
process.exit(1)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// Everything is okay
|
|
21
|
+
console.log('✔ Git hook: "pre-commit" passed')
|
|
22
|
+
|
|
23
|
+
console.log() // blank line
|
|
24
|
+
})()
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { default as yaml } from 'yaml';
|
|
2
|
+
import { Json2CsvOptions } from 'json-2-csv';
|
|
3
|
+
import { Options as XMLoptions } from 'jstoxml';
|
|
4
|
+
declare const SUPPORTED_FORMATS: readonly ["json", "yaml", "csv", "xml"];
|
|
5
|
+
export type DataExporterFormat = typeof SUPPORTED_FORMATS[number];
|
|
6
|
+
export type ExportOptions<F extends DataExporterFormat> = F extends 'json' ? Parameters<typeof jsonExporter>[1] : F extends 'yaml' ? Parameters<typeof yamlExporter>[1] : F extends 'csv' ? Parameters<typeof csvExporter>[1] : F extends 'xml' ? Parameters<typeof xmlExporter>[1] : {};
|
|
7
|
+
/**
|
|
8
|
+
* JSON exporter
|
|
9
|
+
* @param data - The data object
|
|
10
|
+
* @param options - Specific JSON exporter options
|
|
11
|
+
* @returns The data as JSON string
|
|
12
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
|
|
13
|
+
*/
|
|
14
|
+
declare const jsonExporter: (data: any, options?: {
|
|
15
|
+
replacer?: Parameters<typeof JSON.stringify>[1];
|
|
16
|
+
space?: Parameters<typeof JSON.stringify>[2];
|
|
17
|
+
}) => string;
|
|
18
|
+
/**
|
|
19
|
+
* YAML exporter
|
|
20
|
+
* @param data - The data object
|
|
21
|
+
* @param options - Specific YAML exporter options
|
|
22
|
+
* @returns The data as YAML string
|
|
23
|
+
* @see https://www.npmjs.com/package/yaml
|
|
24
|
+
* @see https://eemeli.org/yaml/#yaml
|
|
25
|
+
*/
|
|
26
|
+
declare const yamlExporter: (data: any, options?: {
|
|
27
|
+
replacer?: Parameters<typeof yaml.stringify>[1];
|
|
28
|
+
exporter?: Parameters<typeof yaml.stringify>[2];
|
|
29
|
+
}) => string;
|
|
30
|
+
/**
|
|
31
|
+
* CSV exporter
|
|
32
|
+
* @param data - The data object
|
|
33
|
+
* @param options - Specific CSV exporter options
|
|
34
|
+
* @returns The data as CSV string
|
|
35
|
+
* @see https://www.npmjs.com/package/json-2-csv
|
|
36
|
+
* @see https://mrodrig.github.io/json-2-csv/
|
|
37
|
+
*/
|
|
38
|
+
declare const csvExporter: (data: any, options: Json2CsvOptions) => string;
|
|
39
|
+
/**
|
|
40
|
+
* XML exporter
|
|
41
|
+
* @param data - The data object
|
|
42
|
+
* @param options - Specific XML exporter options
|
|
43
|
+
* @returns The data as XML string
|
|
44
|
+
* @see https://www.npmjs.com/package/jstoxml
|
|
45
|
+
* @see https://github.com/davidcalhoun/jstoxml
|
|
46
|
+
*/
|
|
47
|
+
declare const xmlExporter: (data: any, options: XMLoptions) => string;
|
|
48
|
+
/**
|
|
49
|
+
* Universal data exporter
|
|
50
|
+
*/
|
|
51
|
+
export declare class DataExporter {
|
|
52
|
+
/**
|
|
53
|
+
* The target format
|
|
54
|
+
*/
|
|
55
|
+
private format;
|
|
56
|
+
/**
|
|
57
|
+
* Creates new instance of Costume
|
|
58
|
+
* @param options - Costume options
|
|
59
|
+
*/
|
|
60
|
+
constructor(format: DataExporterFormat);
|
|
61
|
+
exportSync(data: any, options?: ExportOptions<'json'>): ReturnType<typeof jsonExporter>;
|
|
62
|
+
exportSync(data: any, options?: ExportOptions<'yaml'>): ReturnType<typeof yamlExporter>;
|
|
63
|
+
exportSync(data: any, options?: ExportOptions<'csv'>): ReturnType<typeof csvExporter>;
|
|
64
|
+
exportSync(data: any, options?: ExportOptions<'xml'>): ReturnType<typeof xmlExporter>;
|
|
65
|
+
export(...args: Parameters<typeof this.exportSync>): Promise<ReturnType<typeof this.exportSync>>;
|
|
66
|
+
}
|
|
67
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { CLIBuilder } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Creates a CLI factory (default: yargs instance)
|
|
4
|
+
* @param builder - The CLI builder function
|
|
5
|
+
* @returns A function that takes optional argv as first parameter
|
|
6
|
+
* @example
|
|
7
|
+
* import { CLIFactory } from '@hperchec/juisy'
|
|
8
|
+
*
|
|
9
|
+
* const cli = CLIFactory(cli => cli
|
|
10
|
+
* .scriptName('my-juicy-cli')
|
|
11
|
+
* .usage('Usage: $0 <command> [<options>]')
|
|
12
|
+
* )
|
|
13
|
+
*
|
|
14
|
+
* const argv = process.argv.slice(2)
|
|
15
|
+
*
|
|
16
|
+
* // Parse argv
|
|
17
|
+
* cli().parse(argv)
|
|
18
|
+
*/
|
|
19
|
+
export declare function CLIFactory(builder: CLIBuilder): (argv: typeof process.argv) => import('./types').CLIEngine;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { CommandModule } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Class to wrap command definition (CommandModule)
|
|
4
|
+
*/
|
|
5
|
+
export declare class Command implements CommandModule {
|
|
6
|
+
/**
|
|
7
|
+
* Creates a Command instance from object (CommandModule)
|
|
8
|
+
* @param {CommandModule} commandObject - The command definition object
|
|
9
|
+
*/
|
|
10
|
+
constructor(commandObject: CommandModule & {
|
|
11
|
+
builder?: CommandModule['builder'];
|
|
12
|
+
});
|
|
13
|
+
/**
|
|
14
|
+
* The command
|
|
15
|
+
*/
|
|
16
|
+
command: string | readonly string[] | undefined;
|
|
17
|
+
/**
|
|
18
|
+
* The aliases
|
|
19
|
+
*/
|
|
20
|
+
aliases: string | readonly string[] | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Command description
|
|
23
|
+
*/
|
|
24
|
+
describe: string | false | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Is deprecated?
|
|
27
|
+
*/
|
|
28
|
+
deprecated: string | boolean | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Command meta
|
|
31
|
+
*/
|
|
32
|
+
meta: Record<string, any>;
|
|
33
|
+
/**
|
|
34
|
+
* Command builder
|
|
35
|
+
*/
|
|
36
|
+
builder: (cli: import('./types').CLIEngine) => import('./types').CLIEngine | PromiseLike<import('./types').CLIEngine>;
|
|
37
|
+
/**
|
|
38
|
+
* Command handler
|
|
39
|
+
*/
|
|
40
|
+
handler: (this: import('./types').YargsCommandHandler & {
|
|
41
|
+
engine?: import('./types').CLIEngine;
|
|
42
|
+
log?: (msg?: string, options?: any) => void;
|
|
43
|
+
}, argv: Parameters<import('yargs').CommandModule["handler"]>[0]) => ReturnType<import('yargs').CommandModule["handler"]>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { default as execa } from 'execa';
|
|
2
|
+
import { default as _prompts } from 'prompts';
|
|
3
|
+
export declare class InterfaceUtils {
|
|
4
|
+
/**
|
|
5
|
+
* Get root directory path
|
|
6
|
+
* @example
|
|
7
|
+
* import { CLIUtils: { rootDir } } from '@hperchec/juisy'
|
|
8
|
+
* console.log(rootDir) // => 'path/to/your/root/dir'
|
|
9
|
+
*/
|
|
10
|
+
static rootDir: string;
|
|
11
|
+
/**
|
|
12
|
+
* @param {string} bin - Command
|
|
13
|
+
* @param {string[]} args - Same as execa second arg
|
|
14
|
+
* @param {object} [opts] - Options
|
|
15
|
+
* @returns {Promise<object>} The `execa` Promise
|
|
16
|
+
* @description
|
|
17
|
+
* Run command (child_process). See also `execa` package documentation
|
|
18
|
+
* @example
|
|
19
|
+
* const { run } = require('@hperchec/juisy').utils
|
|
20
|
+
* await run('npm', [ 'run', 'test' ], { stdio: 'inherit' })
|
|
21
|
+
*/
|
|
22
|
+
static run(bin: string, args: string[], opts?: {}): execa.ExecaChildProcess<string>;
|
|
23
|
+
/**
|
|
24
|
+
* @alias utils.abort
|
|
25
|
+
* @param {number} [code] - Code for process.exit() (default: 0)
|
|
26
|
+
* @returns {void}
|
|
27
|
+
* @description
|
|
28
|
+
* Exit process
|
|
29
|
+
* @example
|
|
30
|
+
* const { abort } = require('@hperchec/juisy').utils
|
|
31
|
+
* abort() // => exit process with code 0
|
|
32
|
+
* abort(1) // => error code
|
|
33
|
+
*/
|
|
34
|
+
static abort(code?: number): void;
|
|
35
|
+
/**
|
|
36
|
+
* @alias utils.confirm
|
|
37
|
+
* @param {prompts.PromptObject} question - A prompt question object (see https://gitlab.com/hperchec/juisy/-/blob/main/documentation/utils.md#utilspromptsargs-object)
|
|
38
|
+
* @returns {Promise<boolean>} - True if confirmed
|
|
39
|
+
* @description
|
|
40
|
+
* Demand confirmation with prompts native util. If not confirmed, it will automatically abort the script.
|
|
41
|
+
* @example
|
|
42
|
+
* confirm({ message: 'Confirm to continue' }) // Deny it will abort the script
|
|
43
|
+
*/
|
|
44
|
+
static confirm(question: _prompts.PromptObject): Promise<true | undefined>;
|
|
45
|
+
/**
|
|
46
|
+
* See `prompts` package documentation
|
|
47
|
+
* @example
|
|
48
|
+
* const { prompts } = InterfaceUtils
|
|
49
|
+
* // See prompts documentation
|
|
50
|
+
* @see https://www.npmjs.com/package/prompts
|
|
51
|
+
*/
|
|
52
|
+
static prompts: typeof _prompts;
|
|
53
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { default as chalk } from 'chalk';
|
|
2
|
+
import { default as indent } from 'indent-string';
|
|
3
|
+
import { default as _stripAnsi } from 'strip-ansi';
|
|
4
|
+
export declare class OutputUtils {
|
|
5
|
+
/**
|
|
6
|
+
* To automatically increment step index
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
9
|
+
private static stepsCache;
|
|
10
|
+
/**
|
|
11
|
+
* Use `chalk` package to style output in console/stdout
|
|
12
|
+
* @example
|
|
13
|
+
* const { $style } = OutputUtils
|
|
14
|
+
* console.log($style.green('Green text!')) // => '[32mGreen text![0m'
|
|
15
|
+
*/
|
|
16
|
+
static $style: chalk.Chalk & chalk.ChalkFunction & {
|
|
17
|
+
supportsColor: chalk.ColorSupport | false;
|
|
18
|
+
Level: chalk.Level;
|
|
19
|
+
Color: ("black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright") | ("bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright");
|
|
20
|
+
ForegroundColor: "black" | "red" | "green" | "yellow" | "blue" | "magenta" | "cyan" | "white" | "gray" | "grey" | "blackBright" | "redBright" | "greenBright" | "yellowBright" | "blueBright" | "magentaBright" | "cyanBright" | "whiteBright";
|
|
21
|
+
BackgroundColor: "bgBlack" | "bgRed" | "bgGreen" | "bgYellow" | "bgBlue" | "bgMagenta" | "bgCyan" | "bgWhite" | "bgGray" | "bgGrey" | "bgBlackBright" | "bgRedBright" | "bgGreenBright" | "bgYellowBright" | "bgBlueBright" | "bgMagentaBright" | "bgCyanBright" | "bgWhiteBright";
|
|
22
|
+
Modifiers: "bold" | "reset" | "dim" | "italic" | "underline" | "inverse" | "hidden" | "strikethrough" | "visible";
|
|
23
|
+
stderr: chalk.Chalk & {
|
|
24
|
+
supportsColor: chalk.ColorSupport | false;
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Format a message for console output
|
|
29
|
+
* @param msg - The message to format
|
|
30
|
+
* @param options - Format options
|
|
31
|
+
* @returns The formatted message
|
|
32
|
+
* @example
|
|
33
|
+
* formatOutputMessage('laundry\nshopping', { indentChar: '- ' })
|
|
34
|
+
* // => '- laundry\n- shopping'
|
|
35
|
+
*
|
|
36
|
+
* formatOutputMessage('foo\nbar', { indent: 2, indentChar: '❤' })
|
|
37
|
+
* // => '❤❤foo\n❤❤bar'
|
|
38
|
+
*/
|
|
39
|
+
static formatOutputMessage(msg: string, options?: {
|
|
40
|
+
indent?: Parameters<typeof indent>[1];
|
|
41
|
+
indentChar?: string;
|
|
42
|
+
}): string;
|
|
43
|
+
/**
|
|
44
|
+
* @param msg - The message
|
|
45
|
+
* @param options - (Optional) Options object
|
|
46
|
+
* @param options.indent - How many repeat indent (see `indent-string` package)
|
|
47
|
+
* @param options.indentChar - Indent character(s). If `options.indent` not provided, will be repeated only 1 time
|
|
48
|
+
* @description
|
|
49
|
+
* Log message in console
|
|
50
|
+
* @example
|
|
51
|
+
* const { log } = OutputUtils
|
|
52
|
+
* log() // => blank line
|
|
53
|
+
* log('Hello world! =)') // => 'Hello world! =)'
|
|
54
|
+
* log('To do:', { indent: 2 }) // => ' To do:'
|
|
55
|
+
*/
|
|
56
|
+
static log(msg?: string, options?: Parameters<typeof this.formatOutputMessage>[1] & {
|
|
57
|
+
loggerInstance?: {
|
|
58
|
+
log: Function;
|
|
59
|
+
};
|
|
60
|
+
}): void;
|
|
61
|
+
/**
|
|
62
|
+
* Display warning message
|
|
63
|
+
* @param msg - The message to display
|
|
64
|
+
* @example
|
|
65
|
+
* const { warn } = OutputUtils
|
|
66
|
+
* warn('No configuration file') // => '[33m⚠ Warning: No configuration file[0m'
|
|
67
|
+
*/
|
|
68
|
+
static warn(msg: string): void;
|
|
69
|
+
/**
|
|
70
|
+
* @param msg - The message to display
|
|
71
|
+
* @param {Error} [err] - If provided, throw the error
|
|
72
|
+
* @description
|
|
73
|
+
* Display error message. Throws `err` if provided.
|
|
74
|
+
* @example
|
|
75
|
+
* const { error } = require('@hperchec/juisy').utils
|
|
76
|
+
* error('No configuration file') // => '[31m⨉ ERROR: No configuration file[0m'
|
|
77
|
+
* error('No configuration file', error) // => Log and throws error
|
|
78
|
+
*/
|
|
79
|
+
static error(msg: string, err?: undefined): void;
|
|
80
|
+
/**
|
|
81
|
+
* Log step title
|
|
82
|
+
* @param msg - The message to display
|
|
83
|
+
* @param options - Options object
|
|
84
|
+
* @param options.index - Custom index. If `null`, no index prepended to string
|
|
85
|
+
* @example
|
|
86
|
+
* step('Important step') // => '● 1 - Important step'
|
|
87
|
+
* step('Very important step') // => '● 2 - Very important step'
|
|
88
|
+
*/
|
|
89
|
+
static step(msg: string, options?: {
|
|
90
|
+
index?: number | string;
|
|
91
|
+
}): void;
|
|
92
|
+
/**
|
|
93
|
+
* Log substep title
|
|
94
|
+
* @param msg - The message to display
|
|
95
|
+
* @param options - Options object
|
|
96
|
+
* @param options.last - Defines if it is the last substep
|
|
97
|
+
* @example
|
|
98
|
+
* const { substep } = require('@hperchec/juisy').utils
|
|
99
|
+
* substep('Awesome substep') // => '├ Awesome substep'
|
|
100
|
+
* substep('Last substep', { last: true }) // => '└ Last substep'
|
|
101
|
+
*/
|
|
102
|
+
static substep(msg: string, options?: {
|
|
103
|
+
last?: boolean;
|
|
104
|
+
}): void;
|
|
105
|
+
/**
|
|
106
|
+
* @param {string} message - Message to display
|
|
107
|
+
* @param {Function} fct - The function to execute
|
|
108
|
+
* @returns {Promise<void>}
|
|
109
|
+
* @description
|
|
110
|
+
* Wait function: display loading during 'fct' execution
|
|
111
|
+
* @example
|
|
112
|
+
* const { wait } = require('@hperchec/juisy').utils
|
|
113
|
+
* await wait('Waiting', async () => {
|
|
114
|
+
* // Do async logic
|
|
115
|
+
* })
|
|
116
|
+
*/
|
|
117
|
+
static wait(message: string, fct: () => PromiseLike<void>): Promise<void>;
|
|
118
|
+
/**
|
|
119
|
+
* See `strip-ansi` package documentation
|
|
120
|
+
* @see https://www.npmjs.com/package/strip-ansi
|
|
121
|
+
*/
|
|
122
|
+
static stripAnsi: typeof _stripAnsi;
|
|
123
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommandVisitor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Global command visitor to auto-set command meta
|
|
4
|
+
* @ignore
|
|
5
|
+
* @param commandObject - The command object
|
|
6
|
+
* @param cli - The CLIEngine instance
|
|
7
|
+
* @returns The commandObject with wrapped handler to inject properties.
|
|
8
|
+
*/
|
|
9
|
+
export declare const visitor: CommandVisitor;
|
|
10
|
+
export declare const options: {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CommandVisitor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Global command visitor to auto-set command meta
|
|
4
|
+
* @ignore
|
|
5
|
+
* @param commandObject - The command object
|
|
6
|
+
* @param cli - The CLIEngine instance
|
|
7
|
+
* @returns The commandObject with wrapped builder to inject CLI instance meta.
|
|
8
|
+
*/
|
|
9
|
+
export declare const visitor: CommandVisitor;
|
|
10
|
+
export declare const options: {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as commandHandlerInjections from './command-handler-injections';
|
|
2
|
+
import * as getCommandMeta from './get-command-meta';
|
|
3
|
+
import * as privateCommand from './private-command';
|
|
4
|
+
declare const _default: {
|
|
5
|
+
commandHandlerInjections: typeof commandHandlerInjections;
|
|
6
|
+
getCommandMeta: typeof getCommandMeta;
|
|
7
|
+
privateCommand: typeof privateCommand;
|
|
8
|
+
};
|
|
9
|
+
export default _default;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CommandVisitor } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* @ignore
|
|
4
|
+
* @param commandModule - The exported command object
|
|
5
|
+
* @param engine - The CLI (yargs) instance
|
|
6
|
+
* @param options - The global command visitor defined options
|
|
7
|
+
* @returns {object|boolean} False if command is private and env key is set to "private".
|
|
8
|
+
* Otherwise, returns the commandModule with wrapped builder to tag CLI instance as private.
|
|
9
|
+
* @description
|
|
10
|
+
* Global command visitor to auto-set command private status
|
|
11
|
+
*/
|
|
12
|
+
export declare const visitor: CommandVisitor;
|
|
13
|
+
export declare const options: {
|
|
14
|
+
metaProp: string;
|
|
15
|
+
envKey: string;
|
|
16
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { CLIEngine } from './types';
|
|
2
|
+
import { CLIFactory } from './CLIFactory';
|
|
3
|
+
export type CommandDoclet = {
|
|
4
|
+
/**
|
|
5
|
+
* The command
|
|
6
|
+
*/
|
|
7
|
+
command: string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* The command args
|
|
10
|
+
*/
|
|
11
|
+
args: string[] | undefined;
|
|
12
|
+
/**
|
|
13
|
+
* The yargs instance `aliasMap` reference
|
|
14
|
+
* @todo Declare type?
|
|
15
|
+
*/
|
|
16
|
+
aliases: unknown;
|
|
17
|
+
/**
|
|
18
|
+
* If command is deprecated
|
|
19
|
+
*/
|
|
20
|
+
deprecated: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* The extracted usage object from yargs usage instance
|
|
23
|
+
*/
|
|
24
|
+
extractedUsage: ExtractedUsage | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* The usage output as string (as if `--help` option passed)
|
|
27
|
+
*/
|
|
28
|
+
rawUsage: string | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* The child commands
|
|
31
|
+
*/
|
|
32
|
+
children: Record<string, ExtractedUsage> | undefined;
|
|
33
|
+
};
|
|
34
|
+
export type ExtractedUsage = {
|
|
35
|
+
/**
|
|
36
|
+
* Same as yargs instance `getDemandedCommands` method
|
|
37
|
+
*/
|
|
38
|
+
demandedCommands: ReturnType<CLIEngine['getDemandedCommands']>;
|
|
39
|
+
/**
|
|
40
|
+
* Same as yargs instance `getDemandedOptions` method
|
|
41
|
+
*/
|
|
42
|
+
demandedOptions: ReturnType<CLIEngine['getDemandedOptions']>;
|
|
43
|
+
/**
|
|
44
|
+
* Same as yargs instance `getDeprecatedOptions` method
|
|
45
|
+
*/
|
|
46
|
+
deprecatedOptions: ReturnType<CLIEngine['getDeprecatedOptions']>;
|
|
47
|
+
/**
|
|
48
|
+
* Same as yargs instance `getGroups` method
|
|
49
|
+
*/
|
|
50
|
+
groups: ReturnType<CLIEngine['getGroups']>;
|
|
51
|
+
/**
|
|
52
|
+
* Same as yargs instance `getOptions` method
|
|
53
|
+
*/
|
|
54
|
+
options: ReturnType<CLIEngine['getOptions']>;
|
|
55
|
+
/**
|
|
56
|
+
* Same as yargs usage instance `getUsage` method
|
|
57
|
+
*/
|
|
58
|
+
usages: [string, string][];
|
|
59
|
+
/**
|
|
60
|
+
* The result of yargs usage instance `getCommands` method as object.
|
|
61
|
+
* While the UsageInstance commands items are defined as follow: `[cmd, description, isDefault, aliases, deprecated]`,
|
|
62
|
+
* we cast it to an object like: `{cmd, description, isDefault, aliases, deprecated}`.
|
|
63
|
+
*/
|
|
64
|
+
commands: Record<string, {
|
|
65
|
+
cmd: string;
|
|
66
|
+
description: string;
|
|
67
|
+
isDefault: boolean;
|
|
68
|
+
aliases: string[];
|
|
69
|
+
deprecated: boolean;
|
|
70
|
+
}>;
|
|
71
|
+
};
|
|
72
|
+
export declare function extractUsage(factory: ReturnType<typeof CLIFactory>, recursive?: boolean, args?: string[], locale?: string): Promise<CommandDoclet>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { hideBin } from 'yargs/helpers';
|
|
2
|
+
import { Command } from './Command';
|
|
3
|
+
import { InterfaceUtils } from './InterfaceUtils';
|
|
4
|
+
import { OutputUtils } from './OutputUtils';
|
|
5
|
+
export * from './CLIFactory';
|
|
6
|
+
export * from './Command';
|
|
7
|
+
export * from './InterfaceUtils';
|
|
8
|
+
export * from './OutputUtils';
|
|
9
|
+
export { extractUsage } from './extract-usage';
|
|
10
|
+
export type * from './types';
|
|
11
|
+
declare global {
|
|
12
|
+
var CLI: {
|
|
13
|
+
helpers: {
|
|
14
|
+
hideBin: typeof hideBin;
|
|
15
|
+
};
|
|
16
|
+
Command: typeof Command;
|
|
17
|
+
InterfaceUtils: typeof InterfaceUtils;
|
|
18
|
+
OutputUtils: typeof OutputUtils;
|
|
19
|
+
};
|
|
20
|
+
}
|