@zokugun/cli-utils 0.3.3 → 0.4.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 +18 -8
- package/lib/cjs/commander.cjs +6 -1
- package/lib/cjs/commander.d.cts +2 -2
- package/lib/cjs/enquirer/confirm.d.cts +2 -1
- package/lib/cjs/enquirer/enquirer.cjs +2 -0
- package/lib/cjs/enquirer/enquirer.d.cts +98 -0
- package/lib/cjs/enquirer.d.cts +3 -2
- package/lib/cjs/exec.cjs +7 -0
- package/lib/cjs/exec.d.cts +3 -0
- package/lib/cjs/index.cjs +10 -1
- package/lib/cjs/index.d.cts +8 -2
- package/lib/cjs/logger.cjs +30 -4
- package/lib/cjs/logger.d.cts +7 -1
- package/lib/cjs/unwrap-fatal.cjs +47 -0
- package/lib/cjs/unwrap-fatal.d.cts +9 -0
- package/lib/cjs/utils/index.cjs +7 -0
- package/lib/cjs/utils/index.d.cts +2 -0
- package/lib/cjs/utils/register-safety-handlers.cjs +17 -0
- package/lib/cjs/utils/register-safety-handlers.d.cts +1 -0
- package/lib/esm/commander.d.mts +2 -2
- package/lib/esm/commander.mjs +2 -4
- package/lib/esm/enquirer/confirm.d.mts +2 -1
- package/lib/esm/enquirer/enquirer.d.mts +98 -0
- package/lib/esm/enquirer/enquirer.mjs +1 -0
- package/lib/esm/enquirer.d.mts +3 -2
- package/lib/esm/exec.d.mts +3 -0
- package/lib/esm/exec.mjs +4 -0
- package/lib/esm/index.d.mts +8 -2
- package/lib/esm/index.mjs +5 -1
- package/lib/esm/logger.d.mts +7 -1
- package/lib/esm/logger.mjs +28 -4
- package/lib/esm/unwrap-fatal.d.mts +9 -0
- package/lib/esm/unwrap-fatal.mjs +8 -0
- package/lib/esm/utils/index.d.mts +2 -0
- package/lib/esm/utils/index.mjs +2 -0
- package/lib/esm/utils/register-safety-handlers.d.mts +1 -0
- package/lib/esm/utils/register-safety-handlers.mjs +11 -0
- package/package.json +56 -23
package/README.md
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
[@zokugun/cli-utils](https://github.com/zokugun/node-cli-utils)
|
|
2
|
-
|
|
2
|
+
===============================================================
|
|
3
3
|
|
|
4
|
-
[](./LICENSE)
|
|
5
|
+
[](https://www.npmjs.com/package/@zokugun/cli-utils)
|
|
6
|
+
[](#requirements)
|
|
7
|
+
[](#requirements)
|
|
8
|
+
[](https://ko-fi.com/daiyam)
|
|
9
|
+
[](https://liberapay.com/daiyam/donate)
|
|
10
|
+
[](https://paypal.me/daiyam99)
|
|
9
11
|
|
|
10
12
|
A small collection of focused utilities to build user-friendly Node.js command-line applications.
|
|
11
13
|
|
|
@@ -15,8 +17,7 @@ It bundles lightweight helpers so you can compose rich CLI interactions without
|
|
|
15
17
|
- prompt utilities (https://github.com/enquirer/enquirer)
|
|
16
18
|
- a tiny commander wrapper (https://github.com/tj/commander.js)
|
|
17
19
|
- a simple logger (use https://github.com/zokugun/node-log-update-plus)
|
|
18
|
-
|
|
19
|
-
Compatible with **Node.js 18.x**.
|
|
20
|
+
- a tiny `child_process` wrapper (use https://github.com/zokugun/node-picoexec)
|
|
20
21
|
|
|
21
22
|
Installation
|
|
22
23
|
------------
|
|
@@ -25,6 +26,12 @@ Installation
|
|
|
25
26
|
npm install @zokugun/cli-utils
|
|
26
27
|
```
|
|
27
28
|
|
|
29
|
+
Requirements
|
|
30
|
+
------------
|
|
31
|
+
|
|
32
|
+
- **Node.js**: `v18.20` or higher
|
|
33
|
+
- **Modules**: ECMAScript Modules (`ESM`) or CommonJS (`CJS`)
|
|
34
|
+
|
|
28
35
|
Quick Start
|
|
29
36
|
-----------
|
|
30
37
|
|
|
@@ -47,6 +54,7 @@ Quick Reference
|
|
|
47
54
|
- **cli-spinners**: common spinner frame sets and metadata for progress indicators.
|
|
48
55
|
- **commander**: thin convenience exports for building CLI commands.
|
|
49
56
|
- **enquirer**: prompt helpers for interactive prompts (+ patch and `confirm`, `Invisible`).
|
|
57
|
+
- **exec**: a tiny `child_process` wrapper.
|
|
50
58
|
- **logger**: simple logging helpers for consistent CLI output.
|
|
51
59
|
|
|
52
60
|
Module entry points
|
|
@@ -61,7 +69,9 @@ Choose the entry point that matches your environment and naming preferences:
|
|
|
61
69
|
| `@zokugun/cli-utils/cli-spinners` | spinners from `cli-spinners` |
|
|
62
70
|
| `@zokugun/cli-utils/commander` | tiny command from `commander` |
|
|
63
71
|
| `@zokugun/cli-utils/enquirer` | prompt utilities from `enquirer` |
|
|
72
|
+
| `@zokugun/cli-utils/exec` | tiny exec from `picoexec` |
|
|
64
73
|
| `@zokugun/cli-utils/logger` | the logger |
|
|
74
|
+
| `@zokugun/cli-utils/utils` | some utilities |
|
|
65
75
|
|
|
66
76
|
Donations
|
|
67
77
|
---------
|
package/lib/cjs/commander.cjs
CHANGED
|
@@ -33,8 +33,13 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.Command = void 0;
|
|
36
|
+
exports.Option = exports.createArgument = exports.createOption = exports.createCommand = exports.CommanderError = exports.Command = void 0;
|
|
37
37
|
const commander = __importStar(require("@commander-js/extra-typings"));
|
|
38
38
|
const extra_typings_1 = require("@commander-js/extra-typings");
|
|
39
39
|
Object.defineProperty(exports, "Command", { enumerable: true, get: function () { return extra_typings_1.Command; } });
|
|
40
|
+
Object.defineProperty(exports, "CommanderError", { enumerable: true, get: function () { return extra_typings_1.CommanderError; } });
|
|
41
|
+
Object.defineProperty(exports, "createCommand", { enumerable: true, get: function () { return extra_typings_1.createCommand; } });
|
|
42
|
+
Object.defineProperty(exports, "createOption", { enumerable: true, get: function () { return extra_typings_1.createOption; } });
|
|
43
|
+
Object.defineProperty(exports, "createArgument", { enumerable: true, get: function () { return extra_typings_1.createArgument; } });
|
|
44
|
+
Object.defineProperty(exports, "Option", { enumerable: true, get: function () { return extra_typings_1.Option; } });
|
|
40
45
|
exports.default = commander;
|
package/lib/cjs/commander.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as commander from '@commander-js/extra-typings';
|
|
2
|
-
import { Command } from '@commander-js/extra-typings';
|
|
2
|
+
import { AddHelpTextPosition, Command, CommanderError, CommandOptions, CommandUnknownOpts, createCommand, createOption, createArgument, ErrorOptions, ExecutableCommandOptions, HelpConfiguration, HelpContext, HookEvent, Option, OptionValueSource, OutputConfiguration, ParseOptions, ParseOptionsResult } from '@commander-js/extra-typings';
|
|
3
3
|
export default commander;
|
|
4
|
-
export { Command, };
|
|
4
|
+
export { AddHelpTextPosition, Command, CommanderError, CommandOptions, CommandUnknownOpts, createCommand, createOption, createArgument, ErrorOptions, ExecutableCommandOptions, HelpConfiguration, HelpContext, HookEvent, Option, OptionValueSource, OutputConfiguration, ParseOptions, ParseOptionsResult, };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
|
|
3
|
+
export interface BasePromptOptions {
|
|
4
|
+
name: string | (() => string)
|
|
5
|
+
type: string | (() => string)
|
|
6
|
+
message: string | (() => string) | (() => Promise<string>)
|
|
7
|
+
prefix?: string
|
|
8
|
+
initial?: any
|
|
9
|
+
required?: boolean
|
|
10
|
+
enabled?: boolean | string
|
|
11
|
+
disabled?: boolean | string
|
|
12
|
+
format?(value: string): string | Promise<string>
|
|
13
|
+
result?(value: string): string | Promise<string>
|
|
14
|
+
skip?: ((state: object) => boolean | Promise<boolean>) | boolean
|
|
15
|
+
validate?(value: string): boolean | string | Promise<boolean | string>
|
|
16
|
+
onSubmit?(name: string, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
|
|
17
|
+
onCancel?(name: string, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
|
|
18
|
+
stdin?: NodeJS.ReadStream
|
|
19
|
+
stdout?: NodeJS.WriteStream
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Choice {
|
|
23
|
+
name: string
|
|
24
|
+
message?: string
|
|
25
|
+
value?: unknown
|
|
26
|
+
hint?: string
|
|
27
|
+
role?: string
|
|
28
|
+
enabled?: boolean
|
|
29
|
+
disabled?: boolean | string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ArrayPromptOptions extends BasePromptOptions {
|
|
33
|
+
type:
|
|
34
|
+
| 'autocomplete'
|
|
35
|
+
| 'editable'
|
|
36
|
+
| 'form'
|
|
37
|
+
| 'multiselect'
|
|
38
|
+
| 'select'
|
|
39
|
+
| 'survey'
|
|
40
|
+
| 'list'
|
|
41
|
+
| 'scale'
|
|
42
|
+
choices: (string | Choice)[]
|
|
43
|
+
maxChoices?: number
|
|
44
|
+
multiple?: boolean
|
|
45
|
+
initial?: number
|
|
46
|
+
delay?: number
|
|
47
|
+
separator?: boolean
|
|
48
|
+
sort?: boolean
|
|
49
|
+
linebreak?: boolean
|
|
50
|
+
edgeLength?: number
|
|
51
|
+
align?: 'left' | 'right'
|
|
52
|
+
scroll?: boolean
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface BooleanPromptOptions extends BasePromptOptions {
|
|
56
|
+
type: 'confirm'
|
|
57
|
+
initial?: boolean
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface StringPromptOptions extends BasePromptOptions {
|
|
61
|
+
type: 'input' | 'invisible' | 'list' | 'password' | 'text'
|
|
62
|
+
initial?: string
|
|
63
|
+
multiline?: boolean
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface NumberPromptOptions extends BasePromptOptions {
|
|
67
|
+
type: 'numeral'
|
|
68
|
+
min?: number
|
|
69
|
+
max?: number
|
|
70
|
+
delay?: number
|
|
71
|
+
float?: boolean
|
|
72
|
+
round?: boolean
|
|
73
|
+
major?: number
|
|
74
|
+
minor?: number
|
|
75
|
+
initial?: number
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface SnippetPromptOptions extends BasePromptOptions {
|
|
79
|
+
type: 'snippet'
|
|
80
|
+
newline?: string
|
|
81
|
+
template?: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface SortPromptOptions extends BasePromptOptions {
|
|
85
|
+
type: 'sort'
|
|
86
|
+
hint?: string
|
|
87
|
+
drag?: boolean
|
|
88
|
+
numbered?: boolean
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type PromptOptions =
|
|
92
|
+
| BasePromptOptions
|
|
93
|
+
| ArrayPromptOptions
|
|
94
|
+
| BooleanPromptOptions
|
|
95
|
+
| StringPromptOptions
|
|
96
|
+
| NumberPromptOptions
|
|
97
|
+
| SnippetPromptOptions
|
|
98
|
+
| SortPromptOptions
|
package/lib/cjs/enquirer.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Choice, PromptOptions } from './enquirer/enquirer.cjs';
|
|
2
|
+
import enquirer from 'enquirer';
|
|
2
3
|
import { confirm } from './enquirer/confirm.cjs';
|
|
3
4
|
import { Invisible } from './enquirer/invisible.cjs';
|
|
4
|
-
export { type PromptOptions, confirm, enquirer, Invisible, };
|
|
5
|
+
export { type Choice, type PromptOptions, confirm, enquirer, Invisible, };
|
package/lib/cjs/exec.cjs
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.exec = exports.ExecProcess = void 0;
|
|
4
|
+
const picoexec_1 = require("@zokugun/picoexec");
|
|
5
|
+
Object.defineProperty(exports, "ExecProcess", { enumerable: true, get: function () { return picoexec_1.ExecProcess; } });
|
|
6
|
+
Object.defineProperty(exports, "exec", { enumerable: true, get: function () { return picoexec_1.exec; } });
|
|
7
|
+
/* eslint-enable unicorn/prefer-export-from */
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ExecFailure, ExecResult, ExecSuccess, KillSignal, Options as ExecOptions, Subprocess } from '@zokugun/picoexec';
|
|
2
|
+
import { ExecProcess, exec } from '@zokugun/picoexec';
|
|
3
|
+
export { type ExecFailure, type ExecOptions, type ExecResult, type ExecSuccess, type KillSignal, type Subprocess, ExecProcess, exec, };
|
package/lib/cjs/index.cjs
CHANGED
|
@@ -36,7 +36,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.logger = exports.Invisible = exports.enquirer = exports.cliSpinners = exports.confirm = exports.commander = exports.colors = exports.c = void 0;
|
|
39
|
+
exports.unwrapFatal = exports.registerSafetyHandlers = exports.logger = exports.isCI = exports.Invisible = exports.exec = exports.ExecProcess = exports.enquirer = exports.cliSpinners = exports.confirm = exports.commander = exports.colors = exports.c = void 0;
|
|
40
|
+
const picoexec_1 = require("@zokugun/picoexec");
|
|
41
|
+
Object.defineProperty(exports, "ExecProcess", { enumerable: true, get: function () { return picoexec_1.ExecProcess; } });
|
|
42
|
+
Object.defineProperty(exports, "exec", { enumerable: true, get: function () { return picoexec_1.exec; } });
|
|
40
43
|
const ansi_colors_1 = __importDefault(require("ansi-colors"));
|
|
41
44
|
exports.c = ansi_colors_1.default;
|
|
42
45
|
exports.colors = ansi_colors_1.default;
|
|
@@ -52,4 +55,10 @@ const invisible_js_1 = require("./enquirer/invisible.cjs");
|
|
|
52
55
|
Object.defineProperty(exports, "Invisible", { enumerable: true, get: function () { return invisible_js_1.Invisible; } });
|
|
53
56
|
const logger_js_1 = __importDefault(require("./logger.cjs"));
|
|
54
57
|
exports.logger = logger_js_1.default;
|
|
58
|
+
const unwrap_fatal_js_1 = require("./unwrap-fatal.cjs");
|
|
59
|
+
Object.defineProperty(exports, "unwrapFatal", { enumerable: true, get: function () { return unwrap_fatal_js_1.unwrapFatal; } });
|
|
60
|
+
const is_ci_js_1 = require("./utils/is-ci.cjs");
|
|
61
|
+
Object.defineProperty(exports, "isCI", { enumerable: true, get: function () { return is_ci_js_1.isCI; } });
|
|
62
|
+
const register_safety_handlers_js_1 = require("./utils/register-safety-handlers.cjs");
|
|
63
|
+
Object.defineProperty(exports, "registerSafetyHandlers", { enumerable: true, get: function () { return register_safety_handlers_js_1.registerSafetyHandlers; } });
|
|
55
64
|
/* eslint-enable unicorn/prefer-export-from */
|
package/lib/cjs/index.d.cts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import type { ExecFailure, ExecResult, ExecSuccess, KillSignal, Options as ExecOptions, Subprocess } from '@zokugun/picoexec';
|
|
2
|
+
import type { Choice, PromptOptions } from './enquirer/enquirer.cjs';
|
|
3
|
+
import { ExecProcess, exec } from '@zokugun/picoexec';
|
|
1
4
|
import colors from 'ansi-colors';
|
|
2
5
|
import cliSpinners from 'cli-spinners';
|
|
3
6
|
import * as commander from 'commander';
|
|
4
|
-
import enquirer
|
|
7
|
+
import enquirer from 'enquirer';
|
|
5
8
|
import { confirm } from './enquirer/confirm.cjs';
|
|
6
9
|
import { Invisible } from './enquirer/invisible.cjs';
|
|
7
10
|
import logger from './logger.cjs';
|
|
8
|
-
|
|
11
|
+
import { unwrapFatal } from './unwrap-fatal.cjs';
|
|
12
|
+
import { isCI } from './utils/is-ci.cjs';
|
|
13
|
+
import { registerSafetyHandlers } from './utils/register-safety-handlers.cjs';
|
|
14
|
+
export { type Choice, type ExecFailure, type ExecOptions, type ExecResult, type ExecSuccess, type KillSignal, type PromptOptions, type Subprocess, colors as c, colors, commander, confirm, cliSpinners, enquirer, ExecProcess, exec, Invisible, isCI, logger, registerSafetyHandlers, unwrapFatal, };
|
package/lib/cjs/logger.cjs
CHANGED
|
@@ -9,8 +9,10 @@ exports.createSpinner = createSpinner;
|
|
|
9
9
|
exports.createStep = createStep;
|
|
10
10
|
exports.debug = debug;
|
|
11
11
|
exports.error = error;
|
|
12
|
+
exports.exit = exit;
|
|
12
13
|
exports.fatal = fatal;
|
|
13
14
|
exports.finishTimer = finishTimer;
|
|
15
|
+
exports.flagCI = flagCI;
|
|
14
16
|
exports.info = info;
|
|
15
17
|
exports.newLine = newLine;
|
|
16
18
|
exports.pauseProgress = pauseProgress;
|
|
@@ -24,8 +26,10 @@ const node_process_1 = __importDefault(require("node:process"));
|
|
|
24
26
|
const log_update_plus_1 = require("@zokugun/log-update-plus");
|
|
25
27
|
const ansi_colors_1 = __importDefault(require("ansi-colors"));
|
|
26
28
|
const cli_spinners_1 = __importDefault(require("cli-spinners"));
|
|
29
|
+
const unwrap_fatal_js_1 = require("./unwrap-fatal.cjs");
|
|
27
30
|
const is_ci_js_1 = require("./utils/is-ci.cjs");
|
|
28
31
|
const { dots } = cli_spinners_1.default;
|
|
32
|
+
let $ci = (0, is_ci_js_1.isCI)();
|
|
29
33
|
let $loading;
|
|
30
34
|
let $progessFn;
|
|
31
35
|
let $start = 0;
|
|
@@ -48,10 +52,18 @@ function createSpinner(label) {
|
|
|
48
52
|
},
|
|
49
53
|
};
|
|
50
54
|
} // }}}
|
|
51
|
-
function createStep(label) {
|
|
52
|
-
|
|
55
|
+
function createStep(label, createMessage) {
|
|
56
|
+
if (!$ci) {
|
|
57
|
+
showProgress(ansi_colors_1.default.bold(label) + ansi_colors_1.default.dim('...'));
|
|
58
|
+
}
|
|
53
59
|
return () => {
|
|
54
|
-
|
|
60
|
+
stopProgress();
|
|
61
|
+
if (createMessage) {
|
|
62
|
+
log_update_plus_1.stdout.persist(createMessage(label));
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
check(ansi_colors_1.default.bold(`${label}:`) + ansi_colors_1.default.dim(' done'));
|
|
66
|
+
}
|
|
55
67
|
};
|
|
56
68
|
} // }}}
|
|
57
69
|
function debug(message) {
|
|
@@ -61,6 +73,14 @@ function error(message) {
|
|
|
61
73
|
log_update_plus_1.stdout.persist(`${ansi_colors_1.default.red(ansi_colors_1.default.symbols.cross)} ${ansi_colors_1.default.bold('Error!')}`);
|
|
62
74
|
log_update_plus_1.stdout.persist(message);
|
|
63
75
|
} // }}}
|
|
76
|
+
function exit(code = 0) {
|
|
77
|
+
stopProgress();
|
|
78
|
+
if ($start) {
|
|
79
|
+
finishTimer();
|
|
80
|
+
}
|
|
81
|
+
// eslint-disable-next-line unicorn/no-process-exit
|
|
82
|
+
node_process_1.default.exit(code);
|
|
83
|
+
} // }}}
|
|
64
84
|
function fatal(message, code = 1) {
|
|
65
85
|
stopProgress();
|
|
66
86
|
log_update_plus_1.stdout.persist(`${ansi_colors_1.default.red(ansi_colors_1.default.symbols.cross)} ${ansi_colors_1.default.bold('Fatal!')}`);
|
|
@@ -78,6 +98,9 @@ function finishTimer(duration) {
|
|
|
78
98
|
}
|
|
79
99
|
stopProgress(`🏁 ${ansi_colors_1.default.bold('Done')} (in ${duration}s).`);
|
|
80
100
|
} // }}}
|
|
101
|
+
function flagCI() {
|
|
102
|
+
$ci = true;
|
|
103
|
+
} // }}}
|
|
81
104
|
function info(message) {
|
|
82
105
|
log_update_plus_1.stdout.persist(`${ansi_colors_1.default.cyan(ansi_colors_1.default.symbols.bullet)} ${message}`);
|
|
83
106
|
} // }}}
|
|
@@ -97,7 +120,7 @@ function resumeProgress() {
|
|
|
97
120
|
}
|
|
98
121
|
} // }}}
|
|
99
122
|
function showProgress(label) {
|
|
100
|
-
if (
|
|
123
|
+
if ($ci) {
|
|
101
124
|
log_update_plus_1.stdout.render(label);
|
|
102
125
|
}
|
|
103
126
|
else {
|
|
@@ -132,8 +155,10 @@ exports.default = {
|
|
|
132
155
|
createStep,
|
|
133
156
|
debug,
|
|
134
157
|
error,
|
|
158
|
+
exit,
|
|
135
159
|
fatal,
|
|
136
160
|
finishTimer,
|
|
161
|
+
flagCI,
|
|
137
162
|
info,
|
|
138
163
|
newLine,
|
|
139
164
|
pauseProgress,
|
|
@@ -142,5 +167,6 @@ exports.default = {
|
|
|
142
167
|
showProgress,
|
|
143
168
|
stopProgress,
|
|
144
169
|
success,
|
|
170
|
+
unwrapFatal: unwrap_fatal_js_1.unwrapFatal,
|
|
145
171
|
warn,
|
|
146
172
|
};
|
package/lib/cjs/logger.d.cts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unwrapFatal } from './unwrap-fatal.cjs';
|
|
1
2
|
export type IndicatorLoading = ReturnType<typeof setInterval>;
|
|
2
3
|
export type Spinner = {
|
|
3
4
|
fail: () => void;
|
|
@@ -6,11 +7,13 @@ export type Spinner = {
|
|
|
6
7
|
export declare function beginTimer(): void;
|
|
7
8
|
export declare function check(message: string): void;
|
|
8
9
|
export declare function createSpinner(label: string): Spinner;
|
|
9
|
-
export declare function createStep(label: string): () => void;
|
|
10
|
+
export declare function createStep(label: string, createMessage?: (label: string) => string): () => void;
|
|
10
11
|
export declare function debug(message: string): void;
|
|
11
12
|
export declare function error(message: string): void;
|
|
13
|
+
export declare function exit(code?: number): never;
|
|
12
14
|
export declare function fatal(message: string, code?: number): never;
|
|
13
15
|
export declare function finishTimer(duration?: number): void;
|
|
16
|
+
export declare function flagCI(): void;
|
|
14
17
|
export declare function info(message: string): void;
|
|
15
18
|
export declare function newLine(): void;
|
|
16
19
|
export declare function pauseProgress(): void;
|
|
@@ -27,8 +30,10 @@ declare const _default: {
|
|
|
27
30
|
createStep: typeof createStep;
|
|
28
31
|
debug: typeof debug;
|
|
29
32
|
error: typeof error;
|
|
33
|
+
exit: typeof exit;
|
|
30
34
|
fatal: typeof fatal;
|
|
31
35
|
finishTimer: typeof finishTimer;
|
|
36
|
+
flagCI: typeof flagCI;
|
|
32
37
|
info: typeof info;
|
|
33
38
|
newLine: typeof newLine;
|
|
34
39
|
pauseProgress: typeof pauseProgress;
|
|
@@ -37,6 +42,7 @@ declare const _default: {
|
|
|
37
42
|
showProgress: typeof showProgress;
|
|
38
43
|
stopProgress: typeof stopProgress;
|
|
39
44
|
success: typeof success;
|
|
45
|
+
unwrapFatal: typeof unwrapFatal;
|
|
40
46
|
warn: typeof warn;
|
|
41
47
|
};
|
|
42
48
|
export default _default;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.unwrapFatal = unwrapFatal;
|
|
40
|
+
const xtry = __importStar(require("@zokugun/xtry"));
|
|
41
|
+
const logger_js_1 = __importDefault(require("./logger.cjs"));
|
|
42
|
+
function unwrapFatal(result) {
|
|
43
|
+
if (result.fails) {
|
|
44
|
+
return logger_js_1.default.fatal(xtry?.stringifyError(result.error) ?? String(result.error));
|
|
45
|
+
}
|
|
46
|
+
return result.value;
|
|
47
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.registerSafetyHandlers = exports.isCI = void 0;
|
|
4
|
+
var is_ci_js_1 = require("./is-ci.cjs");
|
|
5
|
+
Object.defineProperty(exports, "isCI", { enumerable: true, get: function () { return is_ci_js_1.isCI; } });
|
|
6
|
+
var register_safety_handlers_js_1 = require("./register-safety-handlers.cjs");
|
|
7
|
+
Object.defineProperty(exports, "registerSafetyHandlers", { enumerable: true, get: function () { return register_safety_handlers_js_1.registerSafetyHandlers; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.registerSafetyHandlers = registerSafetyHandlers;
|
|
7
|
+
const node_process_1 = __importDefault(require("node:process"));
|
|
8
|
+
function registerSafetyHandlers() {
|
|
9
|
+
node_process_1.default.on('unhandledRejection', (reason, promise) => {
|
|
10
|
+
if (reason) {
|
|
11
|
+
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
|
12
|
+
}
|
|
13
|
+
else {
|
|
14
|
+
console.error('☠️');
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerSafetyHandlers(): void;
|
package/lib/esm/commander.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import * as commander from '@commander-js/extra-typings';
|
|
2
|
-
import { Command } from '@commander-js/extra-typings';
|
|
2
|
+
import { AddHelpTextPosition, Command, CommanderError, CommandOptions, CommandUnknownOpts, createCommand, createOption, createArgument, ErrorOptions, ExecutableCommandOptions, HelpConfiguration, HelpContext, HookEvent, Option, OptionValueSource, OutputConfiguration, ParseOptions, ParseOptionsResult } from '@commander-js/extra-typings';
|
|
3
3
|
export default commander;
|
|
4
|
-
export { Command, };
|
|
4
|
+
export { AddHelpTextPosition, Command, CommanderError, CommandOptions, CommandUnknownOpts, createCommand, createOption, createArgument, ErrorOptions, ExecutableCommandOptions, HelpConfiguration, HelpContext, HookEvent, Option, OptionValueSource, OutputConfiguration, ParseOptions, ParseOptionsResult, };
|
package/lib/esm/commander.mjs
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import * as commander from '@commander-js/extra-typings';
|
|
2
|
-
import { Command } from '@commander-js/extra-typings';
|
|
2
|
+
import { Command, CommanderError, createCommand, createOption, createArgument, Option, } from '@commander-js/extra-typings';
|
|
3
3
|
export default commander;
|
|
4
|
-
export {
|
|
5
|
-
// eslint-disable-next-line unicorn/prefer-export-from
|
|
6
|
-
Command, };
|
|
4
|
+
export { Command, CommanderError, createCommand, createOption, createArgument, Option, };
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { EventEmitter } from "events";
|
|
2
|
+
|
|
3
|
+
export interface BasePromptOptions {
|
|
4
|
+
name: string | (() => string)
|
|
5
|
+
type: string | (() => string)
|
|
6
|
+
message: string | (() => string) | (() => Promise<string>)
|
|
7
|
+
prefix?: string
|
|
8
|
+
initial?: any
|
|
9
|
+
required?: boolean
|
|
10
|
+
enabled?: boolean | string
|
|
11
|
+
disabled?: boolean | string
|
|
12
|
+
format?(value: string): string | Promise<string>
|
|
13
|
+
result?(value: string): string | Promise<string>
|
|
14
|
+
skip?: ((state: object) => boolean | Promise<boolean>) | boolean
|
|
15
|
+
validate?(value: string): boolean | string | Promise<boolean | string>
|
|
16
|
+
onSubmit?(name: string, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
|
|
17
|
+
onCancel?(name: string, value: any, prompt: Enquirer.Prompt): boolean | Promise<boolean>
|
|
18
|
+
stdin?: NodeJS.ReadStream
|
|
19
|
+
stdout?: NodeJS.WriteStream
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface Choice {
|
|
23
|
+
name: string
|
|
24
|
+
message?: string
|
|
25
|
+
value?: unknown
|
|
26
|
+
hint?: string
|
|
27
|
+
role?: string
|
|
28
|
+
enabled?: boolean
|
|
29
|
+
disabled?: boolean | string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ArrayPromptOptions extends BasePromptOptions {
|
|
33
|
+
type:
|
|
34
|
+
| 'autocomplete'
|
|
35
|
+
| 'editable'
|
|
36
|
+
| 'form'
|
|
37
|
+
| 'multiselect'
|
|
38
|
+
| 'select'
|
|
39
|
+
| 'survey'
|
|
40
|
+
| 'list'
|
|
41
|
+
| 'scale'
|
|
42
|
+
choices: (string | Choice)[]
|
|
43
|
+
maxChoices?: number
|
|
44
|
+
multiple?: boolean
|
|
45
|
+
initial?: number
|
|
46
|
+
delay?: number
|
|
47
|
+
separator?: boolean
|
|
48
|
+
sort?: boolean
|
|
49
|
+
linebreak?: boolean
|
|
50
|
+
edgeLength?: number
|
|
51
|
+
align?: 'left' | 'right'
|
|
52
|
+
scroll?: boolean
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface BooleanPromptOptions extends BasePromptOptions {
|
|
56
|
+
type: 'confirm'
|
|
57
|
+
initial?: boolean
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface StringPromptOptions extends BasePromptOptions {
|
|
61
|
+
type: 'input' | 'invisible' | 'list' | 'password' | 'text'
|
|
62
|
+
initial?: string
|
|
63
|
+
multiline?: boolean
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
interface NumberPromptOptions extends BasePromptOptions {
|
|
67
|
+
type: 'numeral'
|
|
68
|
+
min?: number
|
|
69
|
+
max?: number
|
|
70
|
+
delay?: number
|
|
71
|
+
float?: boolean
|
|
72
|
+
round?: boolean
|
|
73
|
+
major?: number
|
|
74
|
+
minor?: number
|
|
75
|
+
initial?: number
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface SnippetPromptOptions extends BasePromptOptions {
|
|
79
|
+
type: 'snippet'
|
|
80
|
+
newline?: string
|
|
81
|
+
template?: string
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export interface SortPromptOptions extends BasePromptOptions {
|
|
85
|
+
type: 'sort'
|
|
86
|
+
hint?: string
|
|
87
|
+
drag?: boolean
|
|
88
|
+
numbered?: boolean
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type PromptOptions =
|
|
92
|
+
| BasePromptOptions
|
|
93
|
+
| ArrayPromptOptions
|
|
94
|
+
| BooleanPromptOptions
|
|
95
|
+
| StringPromptOptions
|
|
96
|
+
| NumberPromptOptions
|
|
97
|
+
| SnippetPromptOptions
|
|
98
|
+
| SortPromptOptions
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/enquirer.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { Choice, PromptOptions } from './enquirer/enquirer.mjs';
|
|
2
|
+
import enquirer from 'enquirer';
|
|
2
3
|
import { confirm } from './enquirer/confirm.mjs';
|
|
3
4
|
import { Invisible } from './enquirer/invisible.mjs';
|
|
4
|
-
export { type PromptOptions, confirm, enquirer, Invisible, };
|
|
5
|
+
export { type Choice, type PromptOptions, confirm, enquirer, Invisible, };
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { ExecFailure, ExecResult, ExecSuccess, KillSignal, Options as ExecOptions, Subprocess } from '@zokugun/picoexec';
|
|
2
|
+
import { ExecProcess, exec } from '@zokugun/picoexec';
|
|
3
|
+
export { type ExecFailure, type ExecOptions, type ExecResult, type ExecSuccess, type KillSignal, type Subprocess, ExecProcess, exec, };
|
package/lib/esm/exec.mjs
ADDED
package/lib/esm/index.d.mts
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
|
+
import type { ExecFailure, ExecResult, ExecSuccess, KillSignal, Options as ExecOptions, Subprocess } from '@zokugun/picoexec';
|
|
2
|
+
import type { Choice, PromptOptions } from './enquirer/enquirer.mjs';
|
|
3
|
+
import { ExecProcess, exec } from '@zokugun/picoexec';
|
|
1
4
|
import colors from 'ansi-colors';
|
|
2
5
|
import cliSpinners from 'cli-spinners';
|
|
3
6
|
import * as commander from 'commander';
|
|
4
|
-
import enquirer
|
|
7
|
+
import enquirer from 'enquirer';
|
|
5
8
|
import { confirm } from './enquirer/confirm.mjs';
|
|
6
9
|
import { Invisible } from './enquirer/invisible.mjs';
|
|
7
10
|
import logger from './logger.mjs';
|
|
8
|
-
|
|
11
|
+
import { unwrapFatal } from './unwrap-fatal.mjs';
|
|
12
|
+
import { isCI } from './utils/is-ci.mjs';
|
|
13
|
+
import { registerSafetyHandlers } from './utils/register-safety-handlers.mjs';
|
|
14
|
+
export { type Choice, type ExecFailure, type ExecOptions, type ExecResult, type ExecSuccess, type KillSignal, type PromptOptions, type Subprocess, colors as c, colors, commander, confirm, cliSpinners, enquirer, ExecProcess, exec, Invisible, isCI, logger, registerSafetyHandlers, unwrapFatal, };
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ExecProcess, exec } from '@zokugun/picoexec';
|
|
1
2
|
import colors from 'ansi-colors';
|
|
2
3
|
import cliSpinners from 'cli-spinners';
|
|
3
4
|
import * as commander from 'commander';
|
|
@@ -5,6 +6,9 @@ import enquirer from 'enquirer';
|
|
|
5
6
|
import { confirm } from './enquirer/confirm.mjs';
|
|
6
7
|
import { Invisible } from './enquirer/invisible.mjs';
|
|
7
8
|
import logger from './logger.mjs';
|
|
9
|
+
import { unwrapFatal } from './unwrap-fatal.mjs';
|
|
10
|
+
import { isCI } from './utils/is-ci.mjs';
|
|
11
|
+
import { registerSafetyHandlers } from './utils/register-safety-handlers.mjs';
|
|
8
12
|
/* eslint-disable unicorn/prefer-export-from */
|
|
9
|
-
export { colors as c, colors, commander, confirm, cliSpinners, enquirer, Invisible, logger, };
|
|
13
|
+
export { colors as c, colors, commander, confirm, cliSpinners, enquirer, ExecProcess, exec, Invisible, isCI, logger, registerSafetyHandlers, unwrapFatal, };
|
|
10
14
|
/* eslint-enable unicorn/prefer-export-from */
|
package/lib/esm/logger.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { unwrapFatal } from './unwrap-fatal.mjs';
|
|
1
2
|
export type IndicatorLoading = ReturnType<typeof setInterval>;
|
|
2
3
|
export type Spinner = {
|
|
3
4
|
fail: () => void;
|
|
@@ -6,11 +7,13 @@ export type Spinner = {
|
|
|
6
7
|
export declare function beginTimer(): void;
|
|
7
8
|
export declare function check(message: string): void;
|
|
8
9
|
export declare function createSpinner(label: string): Spinner;
|
|
9
|
-
export declare function createStep(label: string): () => void;
|
|
10
|
+
export declare function createStep(label: string, createMessage?: (label: string) => string): () => void;
|
|
10
11
|
export declare function debug(message: string): void;
|
|
11
12
|
export declare function error(message: string): void;
|
|
13
|
+
export declare function exit(code?: number): never;
|
|
12
14
|
export declare function fatal(message: string, code?: number): never;
|
|
13
15
|
export declare function finishTimer(duration?: number): void;
|
|
16
|
+
export declare function flagCI(): void;
|
|
14
17
|
export declare function info(message: string): void;
|
|
15
18
|
export declare function newLine(): void;
|
|
16
19
|
export declare function pauseProgress(): void;
|
|
@@ -27,8 +30,10 @@ declare const _default: {
|
|
|
27
30
|
createStep: typeof createStep;
|
|
28
31
|
debug: typeof debug;
|
|
29
32
|
error: typeof error;
|
|
33
|
+
exit: typeof exit;
|
|
30
34
|
fatal: typeof fatal;
|
|
31
35
|
finishTimer: typeof finishTimer;
|
|
36
|
+
flagCI: typeof flagCI;
|
|
32
37
|
info: typeof info;
|
|
33
38
|
newLine: typeof newLine;
|
|
34
39
|
pauseProgress: typeof pauseProgress;
|
|
@@ -37,6 +42,7 @@ declare const _default: {
|
|
|
37
42
|
showProgress: typeof showProgress;
|
|
38
43
|
stopProgress: typeof stopProgress;
|
|
39
44
|
success: typeof success;
|
|
45
|
+
unwrapFatal: typeof unwrapFatal;
|
|
40
46
|
warn: typeof warn;
|
|
41
47
|
};
|
|
42
48
|
export default _default;
|
package/lib/esm/logger.mjs
CHANGED
|
@@ -2,8 +2,10 @@ import process from 'node:process';
|
|
|
2
2
|
import { stdout } from '@zokugun/log-update-plus';
|
|
3
3
|
import c from 'ansi-colors';
|
|
4
4
|
import cliSpinners from 'cli-spinners';
|
|
5
|
+
import { unwrapFatal } from './unwrap-fatal.mjs';
|
|
5
6
|
import { isCI } from './utils/is-ci.mjs';
|
|
6
7
|
const { dots } = cliSpinners;
|
|
8
|
+
let $ci = isCI();
|
|
7
9
|
let $loading;
|
|
8
10
|
let $progessFn;
|
|
9
11
|
let $start = 0;
|
|
@@ -26,10 +28,18 @@ export function createSpinner(label) {
|
|
|
26
28
|
},
|
|
27
29
|
};
|
|
28
30
|
} // }}}
|
|
29
|
-
export function createStep(label) {
|
|
30
|
-
|
|
31
|
+
export function createStep(label, createMessage) {
|
|
32
|
+
if (!$ci) {
|
|
33
|
+
showProgress(c.bold(label) + c.dim('...'));
|
|
34
|
+
}
|
|
31
35
|
return () => {
|
|
32
|
-
|
|
36
|
+
stopProgress();
|
|
37
|
+
if (createMessage) {
|
|
38
|
+
stdout.persist(createMessage(label));
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
check(c.bold(`${label}:`) + c.dim(' done'));
|
|
42
|
+
}
|
|
33
43
|
};
|
|
34
44
|
} // }}}
|
|
35
45
|
export function debug(message) {
|
|
@@ -39,6 +49,14 @@ export function error(message) {
|
|
|
39
49
|
stdout.persist(`${c.red(c.symbols.cross)} ${c.bold('Error!')}`);
|
|
40
50
|
stdout.persist(message);
|
|
41
51
|
} // }}}
|
|
52
|
+
export function exit(code = 0) {
|
|
53
|
+
stopProgress();
|
|
54
|
+
if ($start) {
|
|
55
|
+
finishTimer();
|
|
56
|
+
}
|
|
57
|
+
// eslint-disable-next-line unicorn/no-process-exit
|
|
58
|
+
process.exit(code);
|
|
59
|
+
} // }}}
|
|
42
60
|
export function fatal(message, code = 1) {
|
|
43
61
|
stopProgress();
|
|
44
62
|
stdout.persist(`${c.red(c.symbols.cross)} ${c.bold('Fatal!')}`);
|
|
@@ -56,6 +74,9 @@ export function finishTimer(duration) {
|
|
|
56
74
|
}
|
|
57
75
|
stopProgress(`🏁 ${c.bold('Done')} (in ${duration}s).`);
|
|
58
76
|
} // }}}
|
|
77
|
+
export function flagCI() {
|
|
78
|
+
$ci = true;
|
|
79
|
+
} // }}}
|
|
59
80
|
export function info(message) {
|
|
60
81
|
stdout.persist(`${c.cyan(c.symbols.bullet)} ${message}`);
|
|
61
82
|
} // }}}
|
|
@@ -75,7 +96,7 @@ export function resumeProgress() {
|
|
|
75
96
|
}
|
|
76
97
|
} // }}}
|
|
77
98
|
export function showProgress(label) {
|
|
78
|
-
if (
|
|
99
|
+
if ($ci) {
|
|
79
100
|
stdout.render(label);
|
|
80
101
|
}
|
|
81
102
|
else {
|
|
@@ -110,8 +131,10 @@ export default {
|
|
|
110
131
|
createStep,
|
|
111
132
|
debug,
|
|
112
133
|
error,
|
|
134
|
+
exit,
|
|
113
135
|
fatal,
|
|
114
136
|
finishTimer,
|
|
137
|
+
flagCI,
|
|
115
138
|
info,
|
|
116
139
|
newLine,
|
|
117
140
|
pauseProgress,
|
|
@@ -120,5 +143,6 @@ export default {
|
|
|
120
143
|
showProgress,
|
|
121
144
|
stopProgress,
|
|
122
145
|
success,
|
|
146
|
+
unwrapFatal,
|
|
123
147
|
warn,
|
|
124
148
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function registerSafetyHandlers(): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import process from 'node:process';
|
|
2
|
+
export function registerSafetyHandlers() {
|
|
3
|
+
process.on('unhandledRejection', (reason, promise) => {
|
|
4
|
+
if (reason) {
|
|
5
|
+
console.error('Unhandled Rejection at:', promise, 'reason:', reason);
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
console.error('☠️');
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zokugun/cli-utils",
|
|
3
3
|
"description": "Utils for CLI app",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "Baptiste Augrain",
|
|
7
7
|
"email": "daiyam@zokugun.org"
|
|
@@ -37,9 +37,17 @@
|
|
|
37
37
|
"import": "./lib/esm/enquirer.mjs",
|
|
38
38
|
"require": "./lib/cjs/enquirer.cjs"
|
|
39
39
|
},
|
|
40
|
+
"./exec": {
|
|
41
|
+
"import": "./lib/esm/exec.mjs",
|
|
42
|
+
"require": "./lib/cjs/exec.cjs"
|
|
43
|
+
},
|
|
40
44
|
"./logger": {
|
|
41
45
|
"import": "./lib/esm/logger.mjs",
|
|
42
46
|
"require": "./lib/cjs/logger.cjs"
|
|
47
|
+
},
|
|
48
|
+
"./utils": {
|
|
49
|
+
"import": "./lib/esm/utils/index.mjs",
|
|
50
|
+
"require": "./lib/cjs/utils/index.cjs"
|
|
43
51
|
}
|
|
44
52
|
},
|
|
45
53
|
"main": "lib/cjs/index.cjs",
|
|
@@ -61,30 +69,35 @@
|
|
|
61
69
|
"enquirer": [
|
|
62
70
|
"./lib/cjs/enquirer.d.cts"
|
|
63
71
|
],
|
|
72
|
+
"exec": [
|
|
73
|
+
"./lib/cjs/exec.d.cts"
|
|
74
|
+
],
|
|
64
75
|
"logger": [
|
|
65
76
|
"./lib/cjs/logger.d.cts"
|
|
77
|
+
],
|
|
78
|
+
"utils": [
|
|
79
|
+
"./lib/cjs/utils/index.d.cts"
|
|
66
80
|
]
|
|
67
81
|
}
|
|
68
82
|
},
|
|
69
83
|
"scripts": {
|
|
70
84
|
"audit:fix": "npm audit fix --min-release-age=0",
|
|
71
|
-
"build": "npm run clean && npm run build:
|
|
72
|
-
"build:
|
|
85
|
+
"build": "npm run clean && npm run build:out",
|
|
86
|
+
"build:out": "tsc-leda generate",
|
|
73
87
|
"build:package": "tsc-leda update-package && npm run lint:package",
|
|
74
88
|
"ci:lint": "zizmor .",
|
|
75
89
|
"ci:lint:fix": "zizmor . --fix=all",
|
|
76
90
|
"clean": "rimraf lib .src",
|
|
77
91
|
"compile:src": "tsc -p src",
|
|
78
|
-
"lint": "
|
|
79
|
-
"lint:all": "npm
|
|
80
|
-
"lint:fix": "
|
|
92
|
+
"lint": "eslint",
|
|
93
|
+
"lint:all": "npm run lint:package && npm audit && npm run ci:lint",
|
|
94
|
+
"lint:fix": "eslint --fix",
|
|
81
95
|
"lint:package": "fixpack || true",
|
|
82
|
-
"postinstall": "patch-package",
|
|
83
96
|
"prepack": "npm run build",
|
|
84
97
|
"prepare": "husky; npm run lint:package",
|
|
85
|
-
"release": "
|
|
98
|
+
"release": "",
|
|
86
99
|
"update:artifacts": "artifact update",
|
|
87
|
-
"update:ci": "
|
|
100
|
+
"update:ci": "pinact run -min-age 7 -update",
|
|
88
101
|
"update:deps": "taze --all",
|
|
89
102
|
"watch:build": "tsc-watch -p src --onSuccess 'npm run build'",
|
|
90
103
|
"watch:src": "tsc-watch -p src"
|
|
@@ -92,37 +105,57 @@
|
|
|
92
105
|
"dependencies": {
|
|
93
106
|
"@commander-js/extra-typings": "14.0.0",
|
|
94
107
|
"@zokugun/log-update-plus": "0.1.1",
|
|
108
|
+
"@zokugun/picoexec": "0.1.0",
|
|
95
109
|
"ansi-colors": "4.1.3",
|
|
96
110
|
"cli-spinners": "3.4.0",
|
|
97
111
|
"commander": "14.0.3",
|
|
98
|
-
"enquirer": "2.4.1"
|
|
99
|
-
"patch-package": "8.0.1"
|
|
112
|
+
"enquirer": "2.4.1"
|
|
100
113
|
},
|
|
101
114
|
"devDependencies": {
|
|
102
115
|
"@commitlint/cli": "20.5.3",
|
|
103
116
|
"@commitlint/config-conventional": "20.5.3",
|
|
104
117
|
"@types/node": "20.19.43",
|
|
105
|
-
"@zokugun/
|
|
118
|
+
"@zokugun/eslint-config": "0.2.1",
|
|
119
|
+
"@zokugun/eslint-config-data": "0.2.1",
|
|
120
|
+
"@zokugun/eslint-config-glossary": "0.2.0",
|
|
121
|
+
"@zokugun/eslint-config-js": "0.2.1",
|
|
122
|
+
"@zokugun/eslint-config-md": "0.4.1",
|
|
123
|
+
"@zokugun/eslint-config-nodejs": "0.2.0",
|
|
124
|
+
"@zokugun/eslint-config-style": "0.3.1",
|
|
125
|
+
"@zokugun/eslint-config-ts": "0.3.2",
|
|
126
|
+
"@zokugun/tsc-leda": "0.9.3",
|
|
127
|
+
"eslint": "10.13.0",
|
|
106
128
|
"fixpack": "4.0.0",
|
|
107
129
|
"husky": "9.1.7",
|
|
108
130
|
"lint-staged": "16.4.0",
|
|
109
|
-
"
|
|
110
|
-
"
|
|
111
|
-
"
|
|
112
|
-
"
|
|
113
|
-
|
|
114
|
-
|
|
131
|
+
"rimraf": "6.1.4",
|
|
132
|
+
"taze": "19.17.2",
|
|
133
|
+
"tsc-watch": "7.2.1",
|
|
134
|
+
"typescript": "5.9.3"
|
|
135
|
+
},
|
|
136
|
+
"optionalDependencies": {
|
|
137
|
+
"@zokugun/xtry": "*"
|
|
115
138
|
},
|
|
116
139
|
"overrides": {
|
|
117
|
-
"@
|
|
118
|
-
"
|
|
140
|
+
"@eslint/config-array": {
|
|
141
|
+
"minimatch": "11.0.1"
|
|
142
|
+
},
|
|
143
|
+
"@typescript-eslint/typescript-estree": {
|
|
144
|
+
"minimatch": "11.0.1"
|
|
145
|
+
},
|
|
146
|
+
"eslint": {
|
|
147
|
+
"minimatch": "11.0.1"
|
|
148
|
+
},
|
|
149
|
+
"eslint-plugin-import-x": {
|
|
150
|
+
"minimatch": "11.0.1"
|
|
119
151
|
},
|
|
120
|
-
"
|
|
121
|
-
"
|
|
152
|
+
"micromark-extension-math": {
|
|
153
|
+
"katex": "0.18.2"
|
|
122
154
|
}
|
|
123
155
|
},
|
|
124
156
|
"allowScripts": {
|
|
125
|
-
"@zokugun/cli-utils": true
|
|
157
|
+
"@zokugun/cli-utils": true,
|
|
158
|
+
"unrs-resolver": true
|
|
126
159
|
},
|
|
127
160
|
"keywords": []
|
|
128
161
|
}
|