@aigne/cli 1.60.0-beta → 1.74.0-beta
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 +12 -12
- package/dist/_virtual/rolldown_runtime.cjs +29 -0
- package/dist/bunwrapper.cjs +22 -0
- package/dist/bunwrapper.d.cts +1 -0
- package/dist/bunwrapper.d.mts +1 -0
- package/dist/bunwrapper.mjs +23 -0
- package/dist/bunwrapper.mjs.map +1 -0
- package/dist/cli.cjs +42 -0
- package/dist/cli.d.cts +9 -0
- package/dist/cli.d.cts.map +1 -0
- package/dist/cli.d.mts +10 -0
- package/dist/cli.d.mts.map +1 -0
- package/dist/cli.mjs +41 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/commands/aigne.cjs +23 -0
- package/dist/commands/aigne.mjs +22 -0
- package/dist/commands/aigne.mjs.map +1 -0
- package/dist/commands/app/agent.cjs +117 -0
- package/dist/commands/app/agent.mjs +113 -0
- package/dist/commands/app/agent.mjs.map +1 -0
- package/dist/commands/app/app.cjs +92 -0
- package/dist/commands/app/app.mjs +90 -0
- package/dist/commands/app/app.mjs.map +1 -0
- package/dist/commands/app/cli.cjs +6 -0
- package/dist/commands/app/cli.d.cts +1 -0
- package/dist/commands/app/cli.d.mts +1 -0
- package/dist/commands/app/cli.mjs +8 -0
- package/dist/commands/app/cli.mjs.map +1 -0
- package/dist/commands/app/upgrade.cjs +243 -0
- package/dist/commands/app/upgrade.mjs +240 -0
- package/dist/commands/app/upgrade.mjs.map +1 -0
- package/dist/commands/app.cjs +53 -0
- package/dist/commands/app.mjs +53 -0
- package/dist/commands/app.mjs.map +1 -0
- package/dist/commands/create.cjs +66 -0
- package/dist/commands/create.mjs +65 -0
- package/dist/commands/create.mjs.map +1 -0
- package/dist/commands/deploy.cjs +237 -0
- package/dist/commands/deploy.mjs +237 -0
- package/dist/commands/deploy.mjs.map +1 -0
- package/dist/commands/eval.cjs +88 -0
- package/dist/commands/eval.mjs +88 -0
- package/dist/commands/eval.mjs.map +1 -0
- package/dist/commands/hub.cjs +297 -0
- package/dist/commands/hub.mjs +294 -0
- package/dist/commands/hub.mjs.map +1 -0
- package/dist/commands/observe.cjs +49 -0
- package/dist/commands/observe.mjs +46 -0
- package/dist/commands/observe.mjs.map +1 -0
- package/dist/commands/run-skill.cjs +84 -0
- package/dist/commands/run-skill.mjs +81 -0
- package/dist/commands/run-skill.mjs.map +1 -0
- package/dist/commands/run.cjs +172 -0
- package/dist/commands/run.mjs +171 -0
- package/dist/commands/run.mjs.map +1 -0
- package/dist/commands/serve-mcp.cjs +68 -0
- package/dist/commands/serve-mcp.mjs +67 -0
- package/dist/commands/serve-mcp.mjs.map +1 -0
- package/dist/commands/test.cjs +40 -0
- package/dist/commands/test.mjs +39 -0
- package/dist/commands/test.mjs.map +1 -0
- package/dist/constants.cjs +28 -0
- package/dist/constants.d.cts +9 -0
- package/dist/constants.d.cts.map +1 -0
- package/dist/constants.d.mts +9 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +24 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/global.d.cjs +0 -0
- package/dist/global.d.cts +6 -0
- package/dist/global.d.cts.map +1 -0
- package/dist/global.d.mts +6 -0
- package/dist/global.d.mts.map +1 -0
- package/dist/index.cjs +0 -0
- package/dist/index.d.cts +2 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +1 -0
- package/dist/tracer/terminal.cjs +336 -0
- package/dist/tracer/terminal.mjs +332 -0
- package/dist/tracer/terminal.mjs.map +1 -0
- package/dist/type.cjs +0 -0
- package/dist/type.d.cts +10 -0
- package/dist/type.d.cts.map +1 -0
- package/dist/type.d.mts +10 -0
- package/dist/type.d.mts.map +1 -0
- package/dist/type.mjs +1 -0
- package/dist/ui/utils/terminal-input.cjs +145 -0
- package/dist/ui/utils/terminal-input.mjs +144 -0
- package/dist/ui/utils/terminal-input.mjs.map +1 -0
- package/dist/ui/utils/text-buffer.cjs +865 -0
- package/dist/ui/utils/text-buffer.mjs +865 -0
- package/dist/ui/utils/text-buffer.mjs.map +1 -0
- package/dist/ui/utils/text-utils.cjs +85 -0
- package/dist/ui/utils/text-utils.mjs +78 -0
- package/dist/ui/utils/text-utils.mjs.map +1 -0
- package/dist/utils/agent-v1.cjs +180 -0
- package/dist/utils/agent-v1.d.cts +138 -0
- package/dist/utils/agent-v1.d.cts.map +1 -0
- package/dist/utils/agent-v1.d.mts +138 -0
- package/dist/utils/agent-v1.d.mts.map +1 -0
- package/dist/utils/agent-v1.mjs +179 -0
- package/dist/utils/agent-v1.mjs.map +1 -0
- package/dist/utils/aigne-hub/constants.cjs +22 -0
- package/dist/utils/aigne-hub/constants.mjs +18 -0
- package/dist/utils/aigne-hub/constants.mjs.map +1 -0
- package/dist/utils/aigne-hub/credential.cjs +179 -0
- package/dist/utils/aigne-hub/credential.mjs +175 -0
- package/dist/utils/aigne-hub/credential.mjs.map +1 -0
- package/dist/utils/aigne-hub/crypto.cjs +41 -0
- package/dist/utils/aigne-hub/crypto.mjs +33 -0
- package/dist/utils/aigne-hub/crypto.mjs.map +1 -0
- package/dist/utils/aigne-hub/model.cjs +112 -0
- package/dist/utils/aigne-hub/model.d.cts +19 -0
- package/dist/utils/aigne-hub/model.d.cts.map +1 -0
- package/dist/utils/aigne-hub/model.d.mts +19 -0
- package/dist/utils/aigne-hub/model.d.mts.map +1 -0
- package/dist/utils/aigne-hub/model.mjs +106 -0
- package/dist/utils/aigne-hub/model.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/file.cjs +64 -0
- package/dist/utils/aigne-hub/store/file.mjs +64 -0
- package/dist/utils/aigne-hub/store/file.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/index.cjs +37 -0
- package/dist/utils/aigne-hub/store/index.mjs +37 -0
- package/dist/utils/aigne-hub/store/index.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/keytar.cjs +61 -0
- package/dist/utils/aigne-hub/store/keytar.mjs +61 -0
- package/dist/utils/aigne-hub/store/keytar.mjs.map +1 -0
- package/dist/utils/aigne-hub/store/migrate.cjs +46 -0
- package/dist/utils/aigne-hub/store/migrate.mjs +45 -0
- package/dist/utils/aigne-hub/store/migrate.mjs.map +1 -0
- package/dist/utils/aigne-hub/type.d.cts +18 -0
- package/dist/utils/aigne-hub/type.d.cts.map +1 -0
- package/dist/utils/aigne-hub/type.d.mts +18 -0
- package/dist/utils/aigne-hub/type.d.mts.map +1 -0
- package/dist/utils/aigne-hub-user.cjs +11 -0
- package/dist/utils/aigne-hub-user.d.cts +23 -0
- package/dist/utils/aigne-hub-user.d.cts.map +1 -0
- package/dist/utils/aigne-hub-user.d.mts +23 -0
- package/dist/utils/aigne-hub-user.d.mts.map +1 -0
- package/dist/utils/aigne-hub-user.mjs +11 -0
- package/dist/utils/aigne-hub-user.mjs.map +1 -0
- package/dist/utils/ascii-logo.cjs +30 -0
- package/dist/utils/ascii-logo.d.cts +5 -0
- package/dist/utils/ascii-logo.d.cts.map +1 -0
- package/dist/utils/ascii-logo.d.mts +5 -0
- package/dist/utils/ascii-logo.d.mts.map +1 -0
- package/dist/utils/{ascii-logo.js → ascii-logo.mjs} +13 -3
- package/dist/utils/ascii-logo.mjs.map +1 -0
- package/dist/utils/download.cjs +25 -0
- package/dist/utils/download.d.cts +7 -0
- package/dist/utils/download.d.cts.map +1 -0
- package/dist/utils/download.d.mts +7 -0
- package/dist/utils/download.d.mts.map +1 -0
- package/dist/utils/download.mjs +25 -0
- package/dist/utils/download.mjs.map +1 -0
- package/dist/utils/evaluation/core.cjs +84 -0
- package/dist/utils/evaluation/core.mjs +84 -0
- package/dist/utils/evaluation/core.mjs.map +1 -0
- package/dist/utils/evaluation/dataset.cjs +47 -0
- package/dist/utils/evaluation/dataset.mjs +46 -0
- package/dist/utils/evaluation/dataset.mjs.map +1 -0
- package/dist/utils/evaluation/evaluator.cjs +109 -0
- package/dist/utils/evaluation/{evaluator.js → evaluator.mjs} +48 -45
- package/dist/utils/evaluation/evaluator.mjs.map +1 -0
- package/dist/utils/evaluation/reporter.cjs +225 -0
- package/dist/utils/evaluation/reporter.mjs +220 -0
- package/dist/utils/evaluation/reporter.mjs.map +1 -0
- package/dist/utils/evaluation/runner.cjs +85 -0
- package/dist/utils/evaluation/runner.mjs +85 -0
- package/dist/utils/evaluation/runner.mjs.map +1 -0
- package/dist/utils/get-url-origin.cjs +12 -0
- package/dist/utils/get-url-origin.d.cts +5 -0
- package/dist/utils/get-url-origin.d.cts.map +1 -0
- package/dist/utils/get-url-origin.d.mts +5 -0
- package/dist/utils/get-url-origin.d.mts.map +1 -0
- package/dist/utils/get-url-origin.mjs +12 -0
- package/dist/utils/get-url-origin.mjs.map +1 -0
- package/dist/utils/inquirer/checkbox.cjs +265 -0
- package/dist/utils/inquirer/checkbox.mjs +262 -0
- package/dist/utils/inquirer/checkbox.mjs.map +1 -0
- package/dist/utils/listr.cjs +226 -0
- package/dist/utils/listr.d.cts +71 -0
- package/dist/utils/listr.d.cts.map +1 -0
- package/dist/utils/listr.d.mts +71 -0
- package/dist/utils/listr.d.mts.map +1 -0
- package/dist/utils/listr.mjs +222 -0
- package/dist/utils/listr.mjs.map +1 -0
- package/dist/utils/load-aigne.cjs +77 -0
- package/dist/utils/load-aigne.d.cts +29 -0
- package/dist/utils/load-aigne.d.cts.map +1 -0
- package/dist/utils/load-aigne.d.mts +29 -0
- package/dist/utils/load-aigne.d.mts.map +1 -0
- package/dist/utils/load-aigne.mjs +74 -0
- package/dist/utils/load-aigne.mjs.map +1 -0
- package/dist/utils/run-chat-loop.cjs +90 -0
- package/dist/utils/run-chat-loop.d.cts +20 -0
- package/dist/utils/run-chat-loop.d.cts.map +1 -0
- package/dist/utils/run-chat-loop.d.mts +20 -0
- package/dist/utils/run-chat-loop.d.mts.map +1 -0
- package/dist/utils/run-chat-loop.mjs +89 -0
- package/dist/utils/run-chat-loop.mjs.map +1 -0
- package/dist/utils/run-with-aigne.cjs +131 -0
- package/dist/utils/run-with-aigne.d.cts +46 -0
- package/dist/utils/run-with-aigne.d.cts.map +1 -0
- package/dist/utils/run-with-aigne.d.mts +46 -0
- package/dist/utils/run-with-aigne.d.mts.map +1 -0
- package/dist/utils/run-with-aigne.mjs +126 -0
- package/dist/utils/run-with-aigne.mjs.map +1 -0
- package/dist/utils/serve-mcp.cjs +91 -0
- package/dist/utils/serve-mcp.d.cts +20 -0
- package/dist/utils/serve-mcp.d.cts.map +1 -0
- package/dist/utils/serve-mcp.d.mts +20 -0
- package/dist/utils/serve-mcp.d.mts.map +1 -0
- package/dist/utils/serve-mcp.mjs +89 -0
- package/dist/utils/serve-mcp.mjs.map +1 -0
- package/dist/utils/spinner.cjs +19 -0
- package/dist/utils/spinner.d.cts +5 -0
- package/dist/utils/spinner.d.cts.map +1 -0
- package/dist/utils/spinner.d.mts +5 -0
- package/dist/utils/spinner.d.mts.map +1 -0
- package/dist/utils/spinner.mjs +19 -0
- package/dist/utils/spinner.mjs.map +1 -0
- package/dist/utils/string-utils.cjs +11 -0
- package/dist/utils/string-utils.d.cts +5 -0
- package/dist/utils/string-utils.d.cts.map +1 -0
- package/dist/utils/string-utils.d.mts +5 -0
- package/dist/utils/string-utils.d.mts.map +1 -0
- package/dist/utils/string-utils.mjs +10 -0
- package/dist/utils/string-utils.mjs.map +1 -0
- package/dist/utils/time.cjs +14 -0
- package/dist/utils/time.d.cts +5 -0
- package/dist/utils/time.d.cts.map +1 -0
- package/dist/utils/time.d.mts +5 -0
- package/dist/utils/time.d.mts.map +1 -0
- package/dist/utils/time.mjs +14 -0
- package/dist/utils/time.mjs.map +1 -0
- package/dist/utils/url.cjs +8 -0
- package/dist/utils/url.d.cts +5 -0
- package/dist/utils/url.d.cts.map +1 -0
- package/dist/utils/url.d.mts +5 -0
- package/dist/utils/url.d.mts.map +1 -0
- package/dist/utils/url.mjs +8 -0
- package/dist/utils/url.mjs.map +1 -0
- package/dist/utils/yargs.cjs +191 -0
- package/dist/utils/yargs.d.cts +96 -0
- package/dist/utils/yargs.d.cts.map +1 -0
- package/dist/utils/yargs.d.mts +96 -0
- package/dist/utils/yargs.d.mts.map +1 -0
- package/dist/utils/yargs.mjs +186 -0
- package/dist/utils/yargs.mjs.map +1 -0
- package/package.json +122 -45
- package/CHANGELOG.md +0 -5019
- package/dist/bunwrapper.d.ts +0 -2
- package/dist/bunwrapper.js +0 -18
- package/dist/cli.d.ts +0 -7
- package/dist/cli.js +0 -42
- package/dist/commands/aigne.d.ts +0 -4
- package/dist/commands/aigne.js +0 -35
- package/dist/commands/app/agent.d.ts +0 -26
- package/dist/commands/app/agent.js +0 -122
- package/dist/commands/app/app.d.ts +0 -7
- package/dist/commands/app/app.js +0 -92
- package/dist/commands/app/cli.d.ts +0 -1
- package/dist/commands/app/cli.js +0 -2
- package/dist/commands/app/upgrade.d.ts +0 -54
- package/dist/commands/app/upgrade.js +0 -236
- package/dist/commands/app.d.ts +0 -4
- package/dist/commands/app.js +0 -54
- package/dist/commands/create.d.ts +0 -6
- package/dist/commands/create.js +0 -74
- package/dist/commands/deploy.d.ts +0 -11
- package/dist/commands/deploy.js +0 -255
- package/dist/commands/eval.d.ts +0 -11
- package/dist/commands/eval.js +0 -110
- package/dist/commands/hub.d.ts +0 -3
- package/dist/commands/hub.js +0 -323
- package/dist/commands/observe.d.ts +0 -7
- package/dist/commands/observe.js +0 -41
- package/dist/commands/run-skill.d.ts +0 -6
- package/dist/commands/run-skill.js +0 -102
- package/dist/commands/run.d.ts +0 -9
- package/dist/commands/run.js +0 -187
- package/dist/commands/serve-mcp.d.ts +0 -20
- package/dist/commands/serve-mcp.js +0 -67
- package/dist/commands/test.d.ts +0 -9
- package/dist/commands/test.js +0 -33
- package/dist/constants.d.ts +0 -7
- package/dist/constants.js +0 -21
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/tracer/terminal.d.ts +0 -62
- package/dist/tracer/terminal.js +0 -404
- package/dist/type.d.ts +0 -5
- package/dist/type.js +0 -1
- package/dist/ui/utils/terminal-input.d.ts +0 -19
- package/dist/ui/utils/terminal-input.js +0 -123
- package/dist/ui/utils/text-buffer.d.ts +0 -87
- package/dist/ui/utils/text-buffer.js +0 -1059
- package/dist/ui/utils/text-utils.d.ts +0 -37
- package/dist/ui/utils/text-utils.js +0 -185
- package/dist/utils/agent-v1.d.ts +0 -134
- package/dist/utils/agent-v1.js +0 -213
- package/dist/utils/aigne-hub/constants.d.ts +0 -6
- package/dist/utils/aigne-hub/constants.js +0 -12
- package/dist/utils/aigne-hub/credential.d.ts +0 -20
- package/dist/utils/aigne-hub/credential.js +0 -182
- package/dist/utils/aigne-hub/crypto.d.ts +0 -4
- package/dist/utils/aigne-hub/crypto.js +0 -30
- package/dist/utils/aigne-hub/model.d.ts +0 -13
- package/dist/utils/aigne-hub/model.js +0 -122
- package/dist/utils/aigne-hub/store/file.d.ts +0 -15
- package/dist/utils/aigne-hub/store/file.js +0 -69
- package/dist/utils/aigne-hub/store/index.d.ts +0 -5
- package/dist/utils/aigne-hub/store/index.js +0 -43
- package/dist/utils/aigne-hub/store/keytar.d.ts +0 -15
- package/dist/utils/aigne-hub/store/keytar.js +0 -67
- package/dist/utils/aigne-hub/store/migrate.d.ts +0 -2
- package/dist/utils/aigne-hub/store/migrate.js +0 -57
- package/dist/utils/aigne-hub/type.d.ts +0 -38
- package/dist/utils/aigne-hub/type.js +0 -1
- package/dist/utils/aigne-hub-user.d.ts +0 -16
- package/dist/utils/aigne-hub-user.js +0 -10
- package/dist/utils/ascii-logo.d.ts +0 -1
- package/dist/utils/download.d.ts +0 -3
- package/dist/utils/download.js +0 -19
- package/dist/utils/evaluation/core.d.ts +0 -8
- package/dist/utils/evaluation/core.js +0 -83
- package/dist/utils/evaluation/dataset.d.ts +0 -15
- package/dist/utils/evaluation/dataset.js +0 -61
- package/dist/utils/evaluation/evaluator.d.ts +0 -9
- package/dist/utils/evaluation/reporter.d.ts +0 -28
- package/dist/utils/evaluation/reporter.js +0 -221
- package/dist/utils/evaluation/runner.d.ts +0 -16
- package/dist/utils/evaluation/runner.js +0 -129
- package/dist/utils/evaluation/type.d.ts +0 -69
- package/dist/utils/evaluation/type.js +0 -1
- package/dist/utils/get-url-origin.d.ts +0 -1
- package/dist/utils/get-url-origin.js +0 -8
- package/dist/utils/inquirer/checkbox.d.ts +0 -55
- package/dist/utils/inquirer/checkbox.js +0 -319
- package/dist/utils/listr.d.ts +0 -64
- package/dist/utils/listr.js +0 -265
- package/dist/utils/load-aigne.d.ts +0 -18
- package/dist/utils/load-aigne.js +0 -80
- package/dist/utils/run-chat-loop.d.ts +0 -15
- package/dist/utils/run-chat-loop.js +0 -87
- package/dist/utils/run-with-aigne.d.ts +0 -27
- package/dist/utils/run-with-aigne.js +0 -157
- package/dist/utils/serve-mcp.d.ts +0 -9
- package/dist/utils/serve-mcp.js +0 -93
- package/dist/utils/spinner.d.ts +0 -1
- package/dist/utils/spinner.js +0 -14
- package/dist/utils/string-utils.d.ts +0 -1
- package/dist/utils/string-utils.js +0 -4
- package/dist/utils/time.d.ts +0 -1
- package/dist/utils/time.js +0 -12
- package/dist/utils/url.d.ts +0 -1
- package/dist/utils/url.js +0 -3
- package/dist/utils/yargs.d.ts +0 -94
- package/dist/utils/yargs.js +0 -210
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-url-origin.mjs","names":[],"sources":["../../src/utils/get-url-origin.ts"],"sourcesContent":["export const getUrlOrigin = (url: string) => {\n try {\n return new URL(url).origin;\n } catch {\n return url;\n }\n};\n"],"mappings":";AAAA,MAAa,gBAAgB,QAAgB;AAC3C,KAAI;AACF,SAAO,IAAI,IAAI,IAAI,CAAC;SACd;AACN,SAAO"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
const require_rolldown_runtime = require('../../_virtual/rolldown_runtime.cjs');
|
|
2
|
+
let _inquirer_core = require("@inquirer/core");
|
|
3
|
+
let _inquirer_figures = require("@inquirer/figures");
|
|
4
|
+
_inquirer_figures = require_rolldown_runtime.__toESM(_inquirer_figures);
|
|
5
|
+
let ansi_escapes = require("ansi-escapes");
|
|
6
|
+
ansi_escapes = require_rolldown_runtime.__toESM(ansi_escapes);
|
|
7
|
+
let yoctocolors_cjs = require("yoctocolors-cjs");
|
|
8
|
+
yoctocolors_cjs = require_rolldown_runtime.__toESM(yoctocolors_cjs);
|
|
9
|
+
|
|
10
|
+
//#region src/utils/inquirer/checkbox.ts
|
|
11
|
+
const checkboxTheme = {
|
|
12
|
+
icon: {
|
|
13
|
+
checked: yoctocolors_cjs.default.green(_inquirer_figures.default.circleFilled),
|
|
14
|
+
unchecked: _inquirer_figures.default.circle,
|
|
15
|
+
cursor: _inquirer_figures.default.pointer
|
|
16
|
+
},
|
|
17
|
+
style: {
|
|
18
|
+
disabledChoice: (text) => yoctocolors_cjs.default.dim(`- ${text}`),
|
|
19
|
+
renderSelectedChoices: (selectedChoices) => selectedChoices.map((choice) => choice.short).join(", "),
|
|
20
|
+
description: (text) => yoctocolors_cjs.default.cyan(text),
|
|
21
|
+
searchTerm: (text) => yoctocolors_cjs.default.cyan(text)
|
|
22
|
+
},
|
|
23
|
+
helpMode: "auto"
|
|
24
|
+
};
|
|
25
|
+
function isSelectable(item) {
|
|
26
|
+
return !_inquirer_core.Separator.isSeparator(item) && !item.disabled;
|
|
27
|
+
}
|
|
28
|
+
function toggle(item) {
|
|
29
|
+
return isSelectable(item) ? {
|
|
30
|
+
...item,
|
|
31
|
+
checked: !item.checked
|
|
32
|
+
} : item;
|
|
33
|
+
}
|
|
34
|
+
function check(checked) {
|
|
35
|
+
return (item) => isSelectable(item) ? {
|
|
36
|
+
...item,
|
|
37
|
+
checked
|
|
38
|
+
} : item;
|
|
39
|
+
}
|
|
40
|
+
function normalizeChoices(choices) {
|
|
41
|
+
return choices.map((choice) => {
|
|
42
|
+
if (_inquirer_core.Separator.isSeparator(choice)) return choice;
|
|
43
|
+
if (typeof choice === "string") return {
|
|
44
|
+
value: choice,
|
|
45
|
+
name: choice,
|
|
46
|
+
short: choice,
|
|
47
|
+
disabled: false,
|
|
48
|
+
checked: false
|
|
49
|
+
};
|
|
50
|
+
const name = choice.name ?? String(choice.value);
|
|
51
|
+
const normalizedChoice = {
|
|
52
|
+
value: choice.value,
|
|
53
|
+
name,
|
|
54
|
+
short: choice.short ?? name,
|
|
55
|
+
disabled: choice.disabled ?? false,
|
|
56
|
+
checked: choice.checked ?? false
|
|
57
|
+
};
|
|
58
|
+
if (choice.description) normalizedChoice.description = choice.description;
|
|
59
|
+
return normalizedChoice;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
var checkbox_default = (0, _inquirer_core.createPrompt)((config, done) => {
|
|
63
|
+
const { instructions, pageSize = 7, loop = true, required, validate = () => true } = config;
|
|
64
|
+
const shortcuts = {
|
|
65
|
+
all: "a",
|
|
66
|
+
invert: "i",
|
|
67
|
+
...config.shortcuts
|
|
68
|
+
};
|
|
69
|
+
const theme = (0, _inquirer_core.makeTheme)(checkboxTheme, {
|
|
70
|
+
...config.theme,
|
|
71
|
+
helpMode: config.theme?.helpMode || (config.source ? "always" : "auto")
|
|
72
|
+
});
|
|
73
|
+
const firstRender = (0, _inquirer_core.useRef)(true);
|
|
74
|
+
const [status, setStatus] = (0, _inquirer_core.useState)(config.source ? "loading" : "idle");
|
|
75
|
+
const prefix = (0, _inquirer_core.usePrefix)({
|
|
76
|
+
status,
|
|
77
|
+
theme
|
|
78
|
+
});
|
|
79
|
+
const [searchTerm, setSearchTerm] = (0, _inquirer_core.useState)("");
|
|
80
|
+
const [searchError, setSearchError] = (0, _inquirer_core.useState)();
|
|
81
|
+
const [preserveActivePosition, setPreserveActivePosition] = (0, _inquirer_core.useState)(false);
|
|
82
|
+
const initialItems = config.choices ? normalizeChoices(config.choices) : [];
|
|
83
|
+
const [selectedChoices, setSelectedChoices] = (0, _inquirer_core.useState)(new Map(initialItems.filter((item) => !_inquirer_core.Separator.isSeparator(item) && item.checked).map((item) => [item.value, item])));
|
|
84
|
+
const [items, setItems] = (0, _inquirer_core.useState)(initialItems);
|
|
85
|
+
(0, _inquirer_core.useEffect)(() => {
|
|
86
|
+
const { source } = config;
|
|
87
|
+
if (!source) return;
|
|
88
|
+
const controller = new AbortController();
|
|
89
|
+
setStatus("loading");
|
|
90
|
+
setSearchError(void 0);
|
|
91
|
+
const fetchResults = async () => {
|
|
92
|
+
try {
|
|
93
|
+
const results = await source(searchTerm || void 0, { signal: controller.signal });
|
|
94
|
+
if (!controller.signal.aborted) {
|
|
95
|
+
const itemsWithSelection = normalizeChoices(results).map((item) => {
|
|
96
|
+
if (!_inquirer_core.Separator.isSeparator(item)) return {
|
|
97
|
+
...item,
|
|
98
|
+
checked: selectedChoices.has(item.value)
|
|
99
|
+
};
|
|
100
|
+
return item;
|
|
101
|
+
});
|
|
102
|
+
setItems(itemsWithSelection);
|
|
103
|
+
if (!preserveActivePosition) {
|
|
104
|
+
const firstSelectable = itemsWithSelection.findIndex(isSelectable);
|
|
105
|
+
if (firstSelectable >= 0) setActive(firstSelectable);
|
|
106
|
+
}
|
|
107
|
+
setPreserveActivePosition(false);
|
|
108
|
+
setSearchError(void 0);
|
|
109
|
+
setStatus("idle");
|
|
110
|
+
}
|
|
111
|
+
} catch (error$1) {
|
|
112
|
+
if (!controller.signal.aborted && error$1 instanceof Error) setSearchError(error$1.message);
|
|
113
|
+
}
|
|
114
|
+
};
|
|
115
|
+
fetchResults();
|
|
116
|
+
return () => {
|
|
117
|
+
controller.abort();
|
|
118
|
+
};
|
|
119
|
+
}, [
|
|
120
|
+
searchTerm,
|
|
121
|
+
config.source,
|
|
122
|
+
selectedChoices
|
|
123
|
+
]);
|
|
124
|
+
const bounds = (0, _inquirer_core.useMemo)(() => {
|
|
125
|
+
const first = items.findIndex(isSelectable);
|
|
126
|
+
const last = items.findLastIndex(isSelectable);
|
|
127
|
+
if (first === -1 && !config.source && status !== "loading") throw new _inquirer_core.ValidationError("[checkbox prompt] No selectable choices. All choices are disabled.");
|
|
128
|
+
return {
|
|
129
|
+
first,
|
|
130
|
+
last
|
|
131
|
+
};
|
|
132
|
+
}, [
|
|
133
|
+
items,
|
|
134
|
+
config.source,
|
|
135
|
+
status
|
|
136
|
+
]);
|
|
137
|
+
const [active, setActive] = (0, _inquirer_core.useState)(bounds.first >= 0 ? bounds.first : 0);
|
|
138
|
+
const [showHelpTip, setShowHelpTip] = (0, _inquirer_core.useState)(true);
|
|
139
|
+
const [errorMsg, setError] = (0, _inquirer_core.useState)();
|
|
140
|
+
(0, _inquirer_core.useKeypress)(async (key, rl) => {
|
|
141
|
+
if ((0, _inquirer_core.isEnterKey)(key)) {
|
|
142
|
+
const selectionChoices = Array.from(selectedChoices.values());
|
|
143
|
+
const isValid = await validate(selectionChoices);
|
|
144
|
+
if (required && selectedChoices.size === 0) setError("At least one choice must be selected");
|
|
145
|
+
else if (isValid === true) {
|
|
146
|
+
setStatus("done");
|
|
147
|
+
done(selectionChoices.map((choice) => choice.value));
|
|
148
|
+
} else setError(isValid || "You must select a valid value");
|
|
149
|
+
} else if ((0, _inquirer_core.isUpKey)(key) || (0, _inquirer_core.isDownKey)(key)) {
|
|
150
|
+
if (loop || (0, _inquirer_core.isUpKey)(key) && active !== bounds.first || (0, _inquirer_core.isDownKey)(key) && active !== bounds.last) {
|
|
151
|
+
const offset = (0, _inquirer_core.isUpKey)(key) ? -1 : 1;
|
|
152
|
+
let next = active;
|
|
153
|
+
do
|
|
154
|
+
next = (next + offset + items.length) % items.length;
|
|
155
|
+
while (!isSelectable(items[next]));
|
|
156
|
+
setActive(next);
|
|
157
|
+
}
|
|
158
|
+
} else if ((0, _inquirer_core.isSpaceKey)(key)) {
|
|
159
|
+
setError(void 0);
|
|
160
|
+
setShowHelpTip(false);
|
|
161
|
+
if (config.source) {
|
|
162
|
+
rl.clearLine(0);
|
|
163
|
+
rl.write(searchTerm);
|
|
164
|
+
setPreserveActivePosition(true);
|
|
165
|
+
}
|
|
166
|
+
const activeItem = items[active];
|
|
167
|
+
if (activeItem && isSelectable(activeItem)) {
|
|
168
|
+
const newSelectedChoices = new Map(selectedChoices);
|
|
169
|
+
if (selectedChoices.has(activeItem.value)) newSelectedChoices.delete(activeItem.value);
|
|
170
|
+
else newSelectedChoices.set(activeItem.value, activeItem);
|
|
171
|
+
setSelectedChoices(newSelectedChoices);
|
|
172
|
+
setItems(items.map((choice, i) => i === active ? toggle(choice) : choice));
|
|
173
|
+
}
|
|
174
|
+
} else if (key.name === shortcuts.all && !config.source || key.ctrl && key.name === "a") {
|
|
175
|
+
const selectAll = items.some((choice) => isSelectable(choice) && !choice.checked);
|
|
176
|
+
const newSelectedChoices = /* @__PURE__ */ new Map();
|
|
177
|
+
if (selectAll) items.forEach((item) => {
|
|
178
|
+
if (isSelectable(item)) newSelectedChoices.set(item.value, item);
|
|
179
|
+
});
|
|
180
|
+
setSelectedChoices(newSelectedChoices);
|
|
181
|
+
setItems(items.map(check(selectAll)));
|
|
182
|
+
if (config.source) setPreserveActivePosition(true);
|
|
183
|
+
} else if (key.name === shortcuts.invert && !config.source) {
|
|
184
|
+
const newSelectedChoices = /* @__PURE__ */ new Map();
|
|
185
|
+
items.forEach((item) => {
|
|
186
|
+
if (isSelectable(item)) {
|
|
187
|
+
if (!selectedChoices.has(item.value)) newSelectedChoices.set(item.value, item);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
setSelectedChoices(newSelectedChoices);
|
|
191
|
+
setItems(items.map(toggle));
|
|
192
|
+
} else if ((0, _inquirer_core.isNumberKey)(key) && !config.source) {
|
|
193
|
+
const selectedIndex = Number(key.name) - 1;
|
|
194
|
+
let selectableIndex = -1;
|
|
195
|
+
const position = items.findIndex((item) => {
|
|
196
|
+
if (_inquirer_core.Separator.isSeparator(item)) return false;
|
|
197
|
+
selectableIndex++;
|
|
198
|
+
return selectableIndex === selectedIndex;
|
|
199
|
+
});
|
|
200
|
+
const selectedItem = items[position];
|
|
201
|
+
if (selectedItem && isSelectable(selectedItem)) {
|
|
202
|
+
setActive(position);
|
|
203
|
+
const newSelectedChoices = new Map(selectedChoices);
|
|
204
|
+
if (selectedChoices.has(selectedItem.value)) newSelectedChoices.delete(selectedItem.value);
|
|
205
|
+
else newSelectedChoices.set(selectedItem.value, selectedItem);
|
|
206
|
+
setSelectedChoices(newSelectedChoices);
|
|
207
|
+
setItems(items.map((choice, i) => i === position ? toggle(choice) : choice));
|
|
208
|
+
}
|
|
209
|
+
} else if (config.source && !(0, _inquirer_core.isSpaceKey)(key)) setSearchTerm(rl.line);
|
|
210
|
+
});
|
|
211
|
+
const message = theme.style.message(config.message, status);
|
|
212
|
+
let description;
|
|
213
|
+
const page = (0, _inquirer_core.usePagination)({
|
|
214
|
+
items,
|
|
215
|
+
active,
|
|
216
|
+
renderItem({ item, isActive }) {
|
|
217
|
+
if (_inquirer_core.Separator.isSeparator(item)) return ` ${item.separator}`;
|
|
218
|
+
if (item.disabled) {
|
|
219
|
+
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
220
|
+
return theme.style.disabledChoice(`${item.name} ${disabledLabel}`);
|
|
221
|
+
}
|
|
222
|
+
if (isActive) description = item.description;
|
|
223
|
+
const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;
|
|
224
|
+
return (isActive ? theme.style.highlight : (x) => x)(`${isActive ? theme.icon.cursor : " "}${checkbox} ${item.name}`);
|
|
225
|
+
},
|
|
226
|
+
pageSize,
|
|
227
|
+
loop
|
|
228
|
+
});
|
|
229
|
+
if (status === "done") {
|
|
230
|
+
const selection = Array.from(selectedChoices.values());
|
|
231
|
+
return `${prefix} ${message} ${theme.style.answer(theme.style.renderSelectedChoices(selection, items))}`;
|
|
232
|
+
}
|
|
233
|
+
let helpTipTop = "";
|
|
234
|
+
let helpTipBottom = "";
|
|
235
|
+
if (theme.helpMode === "always" || theme.helpMode === "auto" && showHelpTip && (instructions === void 0 || instructions)) {
|
|
236
|
+
if (typeof instructions === "string") helpTipTop = instructions;
|
|
237
|
+
else helpTipTop = ` (Press ${[
|
|
238
|
+
`${theme.style.key("space")} to select`,
|
|
239
|
+
!config.source && shortcuts.all ? `${theme.style.key(shortcuts.all)} to toggle all` : "",
|
|
240
|
+
!config.source && shortcuts.invert ? `${theme.style.key(shortcuts.invert)} to invert selection` : "",
|
|
241
|
+
`and ${theme.style.key("enter")} to proceed`
|
|
242
|
+
].filter((key) => key !== "").join(", ")})`;
|
|
243
|
+
if (config.source) {
|
|
244
|
+
const message$1 = items.length > pageSize ? "(Use arrow keys to reveal more choices, ctrl+a to select all)" : "(Use arrow keys to navigate, ctrl+a to select all)";
|
|
245
|
+
helpTipBottom = `\n${theme.style.help(message$1)}`;
|
|
246
|
+
} else if (items.length > pageSize && (theme.helpMode === "always" || theme.helpMode === "auto" && firstRender.current)) {
|
|
247
|
+
helpTipBottom = `\n${theme.style.help("(Use arrow keys to reveal more choices)")}`;
|
|
248
|
+
firstRender.current = false;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const choiceDescription = description ? `\n${theme.style.description(description)}` : ``;
|
|
252
|
+
let error = "";
|
|
253
|
+
if (searchError) error = `\n${theme.style.error(searchError)}`;
|
|
254
|
+
else if (config.source && items.length === 0 && searchTerm !== "" && status === "idle") error = `\n${theme.style.error("No results found")}`;
|
|
255
|
+
else if (errorMsg) error = `\n${theme.style.error(errorMsg)}`;
|
|
256
|
+
if (config.source) return [[
|
|
257
|
+
prefix,
|
|
258
|
+
message,
|
|
259
|
+
theme.style.searchTerm(searchTerm)
|
|
260
|
+
].filter(Boolean).join(" "), `${error}${error ? "\n" : ""}${page}${helpTipBottom}${choiceDescription}`];
|
|
261
|
+
return `${prefix} ${message}${helpTipTop}\n${page}${helpTipBottom}${choiceDescription}${error}${ansi_escapes.default.cursorHide}`;
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
//#endregion
|
|
265
|
+
exports.default = checkbox_default;
|
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
import { Separator, ValidationError, createPrompt, isDownKey, isEnterKey, isNumberKey, isSpaceKey, isUpKey, makeTheme, useEffect, useKeypress, useMemo, usePagination, usePrefix, useRef, useState } from "@inquirer/core";
|
|
2
|
+
import figures from "@inquirer/figures";
|
|
3
|
+
import ansiEscapes from "ansi-escapes";
|
|
4
|
+
import colors from "yoctocolors-cjs";
|
|
5
|
+
|
|
6
|
+
//#region src/utils/inquirer/checkbox.ts
|
|
7
|
+
const checkboxTheme = {
|
|
8
|
+
icon: {
|
|
9
|
+
checked: colors.green(figures.circleFilled),
|
|
10
|
+
unchecked: figures.circle,
|
|
11
|
+
cursor: figures.pointer
|
|
12
|
+
},
|
|
13
|
+
style: {
|
|
14
|
+
disabledChoice: (text) => colors.dim(`- ${text}`),
|
|
15
|
+
renderSelectedChoices: (selectedChoices) => selectedChoices.map((choice) => choice.short).join(", "),
|
|
16
|
+
description: (text) => colors.cyan(text),
|
|
17
|
+
searchTerm: (text) => colors.cyan(text)
|
|
18
|
+
},
|
|
19
|
+
helpMode: "auto"
|
|
20
|
+
};
|
|
21
|
+
function isSelectable(item) {
|
|
22
|
+
return !Separator.isSeparator(item) && !item.disabled;
|
|
23
|
+
}
|
|
24
|
+
function toggle(item) {
|
|
25
|
+
return isSelectable(item) ? {
|
|
26
|
+
...item,
|
|
27
|
+
checked: !item.checked
|
|
28
|
+
} : item;
|
|
29
|
+
}
|
|
30
|
+
function check(checked) {
|
|
31
|
+
return (item) => isSelectable(item) ? {
|
|
32
|
+
...item,
|
|
33
|
+
checked
|
|
34
|
+
} : item;
|
|
35
|
+
}
|
|
36
|
+
function normalizeChoices(choices) {
|
|
37
|
+
return choices.map((choice) => {
|
|
38
|
+
if (Separator.isSeparator(choice)) return choice;
|
|
39
|
+
if (typeof choice === "string") return {
|
|
40
|
+
value: choice,
|
|
41
|
+
name: choice,
|
|
42
|
+
short: choice,
|
|
43
|
+
disabled: false,
|
|
44
|
+
checked: false
|
|
45
|
+
};
|
|
46
|
+
const name = choice.name ?? String(choice.value);
|
|
47
|
+
const normalizedChoice = {
|
|
48
|
+
value: choice.value,
|
|
49
|
+
name,
|
|
50
|
+
short: choice.short ?? name,
|
|
51
|
+
disabled: choice.disabled ?? false,
|
|
52
|
+
checked: choice.checked ?? false
|
|
53
|
+
};
|
|
54
|
+
if (choice.description) normalizedChoice.description = choice.description;
|
|
55
|
+
return normalizedChoice;
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
var checkbox_default = createPrompt((config, done) => {
|
|
59
|
+
const { instructions, pageSize = 7, loop = true, required, validate = () => true } = config;
|
|
60
|
+
const shortcuts = {
|
|
61
|
+
all: "a",
|
|
62
|
+
invert: "i",
|
|
63
|
+
...config.shortcuts
|
|
64
|
+
};
|
|
65
|
+
const theme = makeTheme(checkboxTheme, {
|
|
66
|
+
...config.theme,
|
|
67
|
+
helpMode: config.theme?.helpMode || (config.source ? "always" : "auto")
|
|
68
|
+
});
|
|
69
|
+
const firstRender = useRef(true);
|
|
70
|
+
const [status, setStatus] = useState(config.source ? "loading" : "idle");
|
|
71
|
+
const prefix = usePrefix({
|
|
72
|
+
status,
|
|
73
|
+
theme
|
|
74
|
+
});
|
|
75
|
+
const [searchTerm, setSearchTerm] = useState("");
|
|
76
|
+
const [searchError, setSearchError] = useState();
|
|
77
|
+
const [preserveActivePosition, setPreserveActivePosition] = useState(false);
|
|
78
|
+
const initialItems = config.choices ? normalizeChoices(config.choices) : [];
|
|
79
|
+
const [selectedChoices, setSelectedChoices] = useState(new Map(initialItems.filter((item) => !Separator.isSeparator(item) && item.checked).map((item) => [item.value, item])));
|
|
80
|
+
const [items, setItems] = useState(initialItems);
|
|
81
|
+
useEffect(() => {
|
|
82
|
+
const { source } = config;
|
|
83
|
+
if (!source) return;
|
|
84
|
+
const controller = new AbortController();
|
|
85
|
+
setStatus("loading");
|
|
86
|
+
setSearchError(void 0);
|
|
87
|
+
const fetchResults = async () => {
|
|
88
|
+
try {
|
|
89
|
+
const results = await source(searchTerm || void 0, { signal: controller.signal });
|
|
90
|
+
if (!controller.signal.aborted) {
|
|
91
|
+
const itemsWithSelection = normalizeChoices(results).map((item) => {
|
|
92
|
+
if (!Separator.isSeparator(item)) return {
|
|
93
|
+
...item,
|
|
94
|
+
checked: selectedChoices.has(item.value)
|
|
95
|
+
};
|
|
96
|
+
return item;
|
|
97
|
+
});
|
|
98
|
+
setItems(itemsWithSelection);
|
|
99
|
+
if (!preserveActivePosition) {
|
|
100
|
+
const firstSelectable = itemsWithSelection.findIndex(isSelectable);
|
|
101
|
+
if (firstSelectable >= 0) setActive(firstSelectable);
|
|
102
|
+
}
|
|
103
|
+
setPreserveActivePosition(false);
|
|
104
|
+
setSearchError(void 0);
|
|
105
|
+
setStatus("idle");
|
|
106
|
+
}
|
|
107
|
+
} catch (error$1) {
|
|
108
|
+
if (!controller.signal.aborted && error$1 instanceof Error) setSearchError(error$1.message);
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
fetchResults();
|
|
112
|
+
return () => {
|
|
113
|
+
controller.abort();
|
|
114
|
+
};
|
|
115
|
+
}, [
|
|
116
|
+
searchTerm,
|
|
117
|
+
config.source,
|
|
118
|
+
selectedChoices
|
|
119
|
+
]);
|
|
120
|
+
const bounds = useMemo(() => {
|
|
121
|
+
const first = items.findIndex(isSelectable);
|
|
122
|
+
const last = items.findLastIndex(isSelectable);
|
|
123
|
+
if (first === -1 && !config.source && status !== "loading") throw new ValidationError("[checkbox prompt] No selectable choices. All choices are disabled.");
|
|
124
|
+
return {
|
|
125
|
+
first,
|
|
126
|
+
last
|
|
127
|
+
};
|
|
128
|
+
}, [
|
|
129
|
+
items,
|
|
130
|
+
config.source,
|
|
131
|
+
status
|
|
132
|
+
]);
|
|
133
|
+
const [active, setActive] = useState(bounds.first >= 0 ? bounds.first : 0);
|
|
134
|
+
const [showHelpTip, setShowHelpTip] = useState(true);
|
|
135
|
+
const [errorMsg, setError] = useState();
|
|
136
|
+
useKeypress(async (key, rl) => {
|
|
137
|
+
if (isEnterKey(key)) {
|
|
138
|
+
const selectionChoices = Array.from(selectedChoices.values());
|
|
139
|
+
const isValid = await validate(selectionChoices);
|
|
140
|
+
if (required && selectedChoices.size === 0) setError("At least one choice must be selected");
|
|
141
|
+
else if (isValid === true) {
|
|
142
|
+
setStatus("done");
|
|
143
|
+
done(selectionChoices.map((choice) => choice.value));
|
|
144
|
+
} else setError(isValid || "You must select a valid value");
|
|
145
|
+
} else if (isUpKey(key) || isDownKey(key)) {
|
|
146
|
+
if (loop || isUpKey(key) && active !== bounds.first || isDownKey(key) && active !== bounds.last) {
|
|
147
|
+
const offset = isUpKey(key) ? -1 : 1;
|
|
148
|
+
let next = active;
|
|
149
|
+
do
|
|
150
|
+
next = (next + offset + items.length) % items.length;
|
|
151
|
+
while (!isSelectable(items[next]));
|
|
152
|
+
setActive(next);
|
|
153
|
+
}
|
|
154
|
+
} else if (isSpaceKey(key)) {
|
|
155
|
+
setError(void 0);
|
|
156
|
+
setShowHelpTip(false);
|
|
157
|
+
if (config.source) {
|
|
158
|
+
rl.clearLine(0);
|
|
159
|
+
rl.write(searchTerm);
|
|
160
|
+
setPreserveActivePosition(true);
|
|
161
|
+
}
|
|
162
|
+
const activeItem = items[active];
|
|
163
|
+
if (activeItem && isSelectable(activeItem)) {
|
|
164
|
+
const newSelectedChoices = new Map(selectedChoices);
|
|
165
|
+
if (selectedChoices.has(activeItem.value)) newSelectedChoices.delete(activeItem.value);
|
|
166
|
+
else newSelectedChoices.set(activeItem.value, activeItem);
|
|
167
|
+
setSelectedChoices(newSelectedChoices);
|
|
168
|
+
setItems(items.map((choice, i) => i === active ? toggle(choice) : choice));
|
|
169
|
+
}
|
|
170
|
+
} else if (key.name === shortcuts.all && !config.source || key.ctrl && key.name === "a") {
|
|
171
|
+
const selectAll = items.some((choice) => isSelectable(choice) && !choice.checked);
|
|
172
|
+
const newSelectedChoices = /* @__PURE__ */ new Map();
|
|
173
|
+
if (selectAll) items.forEach((item) => {
|
|
174
|
+
if (isSelectable(item)) newSelectedChoices.set(item.value, item);
|
|
175
|
+
});
|
|
176
|
+
setSelectedChoices(newSelectedChoices);
|
|
177
|
+
setItems(items.map(check(selectAll)));
|
|
178
|
+
if (config.source) setPreserveActivePosition(true);
|
|
179
|
+
} else if (key.name === shortcuts.invert && !config.source) {
|
|
180
|
+
const newSelectedChoices = /* @__PURE__ */ new Map();
|
|
181
|
+
items.forEach((item) => {
|
|
182
|
+
if (isSelectable(item)) {
|
|
183
|
+
if (!selectedChoices.has(item.value)) newSelectedChoices.set(item.value, item);
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
setSelectedChoices(newSelectedChoices);
|
|
187
|
+
setItems(items.map(toggle));
|
|
188
|
+
} else if (isNumberKey(key) && !config.source) {
|
|
189
|
+
const selectedIndex = Number(key.name) - 1;
|
|
190
|
+
let selectableIndex = -1;
|
|
191
|
+
const position = items.findIndex((item) => {
|
|
192
|
+
if (Separator.isSeparator(item)) return false;
|
|
193
|
+
selectableIndex++;
|
|
194
|
+
return selectableIndex === selectedIndex;
|
|
195
|
+
});
|
|
196
|
+
const selectedItem = items[position];
|
|
197
|
+
if (selectedItem && isSelectable(selectedItem)) {
|
|
198
|
+
setActive(position);
|
|
199
|
+
const newSelectedChoices = new Map(selectedChoices);
|
|
200
|
+
if (selectedChoices.has(selectedItem.value)) newSelectedChoices.delete(selectedItem.value);
|
|
201
|
+
else newSelectedChoices.set(selectedItem.value, selectedItem);
|
|
202
|
+
setSelectedChoices(newSelectedChoices);
|
|
203
|
+
setItems(items.map((choice, i) => i === position ? toggle(choice) : choice));
|
|
204
|
+
}
|
|
205
|
+
} else if (config.source && !isSpaceKey(key)) setSearchTerm(rl.line);
|
|
206
|
+
});
|
|
207
|
+
const message = theme.style.message(config.message, status);
|
|
208
|
+
let description;
|
|
209
|
+
const page = usePagination({
|
|
210
|
+
items,
|
|
211
|
+
active,
|
|
212
|
+
renderItem({ item, isActive }) {
|
|
213
|
+
if (Separator.isSeparator(item)) return ` ${item.separator}`;
|
|
214
|
+
if (item.disabled) {
|
|
215
|
+
const disabledLabel = typeof item.disabled === "string" ? item.disabled : "(disabled)";
|
|
216
|
+
return theme.style.disabledChoice(`${item.name} ${disabledLabel}`);
|
|
217
|
+
}
|
|
218
|
+
if (isActive) description = item.description;
|
|
219
|
+
const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;
|
|
220
|
+
return (isActive ? theme.style.highlight : (x) => x)(`${isActive ? theme.icon.cursor : " "}${checkbox} ${item.name}`);
|
|
221
|
+
},
|
|
222
|
+
pageSize,
|
|
223
|
+
loop
|
|
224
|
+
});
|
|
225
|
+
if (status === "done") {
|
|
226
|
+
const selection = Array.from(selectedChoices.values());
|
|
227
|
+
return `${prefix} ${message} ${theme.style.answer(theme.style.renderSelectedChoices(selection, items))}`;
|
|
228
|
+
}
|
|
229
|
+
let helpTipTop = "";
|
|
230
|
+
let helpTipBottom = "";
|
|
231
|
+
if (theme.helpMode === "always" || theme.helpMode === "auto" && showHelpTip && (instructions === void 0 || instructions)) {
|
|
232
|
+
if (typeof instructions === "string") helpTipTop = instructions;
|
|
233
|
+
else helpTipTop = ` (Press ${[
|
|
234
|
+
`${theme.style.key("space")} to select`,
|
|
235
|
+
!config.source && shortcuts.all ? `${theme.style.key(shortcuts.all)} to toggle all` : "",
|
|
236
|
+
!config.source && shortcuts.invert ? `${theme.style.key(shortcuts.invert)} to invert selection` : "",
|
|
237
|
+
`and ${theme.style.key("enter")} to proceed`
|
|
238
|
+
].filter((key) => key !== "").join(", ")})`;
|
|
239
|
+
if (config.source) {
|
|
240
|
+
const message$1 = items.length > pageSize ? "(Use arrow keys to reveal more choices, ctrl+a to select all)" : "(Use arrow keys to navigate, ctrl+a to select all)";
|
|
241
|
+
helpTipBottom = `\n${theme.style.help(message$1)}`;
|
|
242
|
+
} else if (items.length > pageSize && (theme.helpMode === "always" || theme.helpMode === "auto" && firstRender.current)) {
|
|
243
|
+
helpTipBottom = `\n${theme.style.help("(Use arrow keys to reveal more choices)")}`;
|
|
244
|
+
firstRender.current = false;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
const choiceDescription = description ? `\n${theme.style.description(description)}` : ``;
|
|
248
|
+
let error = "";
|
|
249
|
+
if (searchError) error = `\n${theme.style.error(searchError)}`;
|
|
250
|
+
else if (config.source && items.length === 0 && searchTerm !== "" && status === "idle") error = `\n${theme.style.error("No results found")}`;
|
|
251
|
+
else if (errorMsg) error = `\n${theme.style.error(errorMsg)}`;
|
|
252
|
+
if (config.source) return [[
|
|
253
|
+
prefix,
|
|
254
|
+
message,
|
|
255
|
+
theme.style.searchTerm(searchTerm)
|
|
256
|
+
].filter(Boolean).join(" "), `${error}${error ? "\n" : ""}${page}${helpTipBottom}${choiceDescription}`];
|
|
257
|
+
return `${prefix} ${message}${helpTipTop}\n${page}${helpTipBottom}${choiceDescription}${error}${ansiEscapes.cursorHide}`;
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
//#endregion
|
|
261
|
+
export { checkbox_default as default };
|
|
262
|
+
//# sourceMappingURL=checkbox.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"checkbox.mjs","names":["error","message"],"sources":["../../../src/utils/inquirer/checkbox.ts"],"sourcesContent":["import {\n createPrompt,\n isDownKey,\n isEnterKey,\n isNumberKey,\n isSpaceKey,\n isUpKey,\n makeTheme,\n Separator,\n type Status,\n type Theme,\n useEffect,\n useKeypress,\n useMemo,\n usePagination,\n usePrefix,\n useRef,\n useState,\n ValidationError,\n} from \"@inquirer/core\";\nimport figures from \"@inquirer/figures\";\nimport type { PartialDeep } from \"@inquirer/type\";\nimport ansiEscapes from \"ansi-escapes\";\nimport colors from \"yoctocolors-cjs\";\n\ntype CheckboxTheme = {\n icon: {\n checked: string;\n unchecked: string;\n cursor: string;\n };\n style: {\n disabledChoice: (text: string) => string;\n renderSelectedChoices: <T>(\n selectedChoices: ReadonlyArray<NormalizedChoice<T>>,\n allChoices: ReadonlyArray<NormalizedChoice<T> | Separator>,\n ) => string;\n description: (text: string) => string;\n searchTerm: (text: string) => string;\n };\n helpMode: \"always\" | \"never\" | \"auto\";\n};\n\ntype CheckboxShortcuts = {\n all?: string | null;\n invert?: string | null;\n};\n\nconst checkboxTheme: CheckboxTheme = {\n icon: {\n checked: colors.green(figures.circleFilled),\n unchecked: figures.circle,\n cursor: figures.pointer,\n },\n style: {\n disabledChoice: (text: string) => colors.dim(`- ${text}`),\n renderSelectedChoices: (selectedChoices) =>\n selectedChoices.map((choice) => choice.short).join(\", \"),\n description: (text: string) => colors.cyan(text),\n searchTerm: (text: string) => colors.cyan(text),\n },\n helpMode: \"auto\",\n};\n\ntype Choice<Value> = {\n value: Value;\n name?: string;\n description?: string;\n short?: string;\n disabled?: boolean | string;\n checked?: boolean;\n type?: never;\n};\n\ntype NormalizedChoice<Value> = {\n value: Value;\n name: string;\n description?: string;\n short: string;\n disabled: boolean | string;\n checked: boolean;\n};\n\ntype CheckboxConfig<\n Value,\n ChoicesObject = ReadonlyArray<string | Separator> | ReadonlyArray<Choice<Value> | Separator>,\n> = {\n message: string;\n prefix?: string;\n pageSize?: number;\n instructions?: string | boolean;\n choices?: ChoicesObject extends ReadonlyArray<string | Separator>\n ? ChoicesObject\n : ReadonlyArray<Choice<Value> | Separator>;\n source?: (\n term: string | undefined,\n opt: { signal: AbortSignal },\n ) => ChoicesObject extends ReadonlyArray<string | Separator>\n ? ChoicesObject | Promise<ChoicesObject>\n : ReadonlyArray<Choice<Value> | Separator> | Promise<ReadonlyArray<Choice<Value> | Separator>>;\n loop?: boolean;\n required?: boolean;\n validate?: (\n choices: ReadonlyArray<Choice<Value>>,\n ) => boolean | string | Promise<string | boolean>;\n theme?: PartialDeep<Theme<CheckboxTheme>>;\n shortcuts?: CheckboxShortcuts;\n};\n\ntype Item<Value> = NormalizedChoice<Value> | Separator;\n\nfunction isSelectable<Value>(item: Item<Value>): item is NormalizedChoice<Value> {\n return !Separator.isSeparator(item) && !item.disabled;\n}\n\nfunction toggle<Value>(item: Item<Value>): Item<Value> {\n return isSelectable(item) ? { ...item, checked: !item.checked } : item;\n}\n\nfunction check(checked: boolean) {\n return <Value>(item: Item<Value>): Item<Value> =>\n isSelectable(item) ? { ...item, checked } : item;\n}\n\nfunction normalizeChoices<Value>(\n choices: ReadonlyArray<string | Separator> | ReadonlyArray<Choice<Value> | Separator>,\n): Item<Value>[] {\n return choices.map((choice) => {\n if (Separator.isSeparator(choice)) return choice;\n\n if (typeof choice === \"string\") {\n return {\n value: choice as Value,\n name: choice,\n short: choice,\n disabled: false,\n checked: false,\n };\n }\n\n const name = choice.name ?? String(choice.value);\n const normalizedChoice: NormalizedChoice<Value> = {\n value: choice.value,\n name,\n short: choice.short ?? name,\n disabled: choice.disabled ?? false,\n checked: choice.checked ?? false,\n };\n\n if (choice.description) {\n normalizedChoice.description = choice.description;\n }\n\n return normalizedChoice;\n });\n}\n\nexport default createPrompt(\n <Value>(config: CheckboxConfig<Value>, done: (value: Array<Value>) => void) => {\n const { instructions, pageSize = 7, loop = true, required, validate = () => true } = config;\n const shortcuts = { all: \"a\", invert: \"i\", ...config.shortcuts };\n const theme = makeTheme<CheckboxTheme>(checkboxTheme, {\n ...config.theme,\n helpMode: config.theme?.helpMode || (config.source ? \"always\" : \"auto\"),\n });\n const firstRender = useRef(true);\n const [status, setStatus] = useState<Status>(config.source ? \"loading\" : \"idle\");\n const prefix = usePrefix({ status, theme });\n\n const [searchTerm, setSearchTerm] = useState<string>(\"\");\n const [searchError, setSearchError] = useState<string>();\n const [preserveActivePosition, setPreserveActivePosition] = useState(false);\n\n const initialItems = config.choices ? normalizeChoices(config.choices) : [];\n const initialSelectedChoices = new Map<Value, NormalizedChoice<Value>>(\n initialItems\n .filter(\n (item): item is NormalizedChoice<Value> => !Separator.isSeparator(item) && item.checked,\n )\n .map((item) => [item.value, item]),\n );\n\n const [selectedChoices, setSelectedChoices] =\n useState<Map<Value, NormalizedChoice<Value>>>(initialSelectedChoices);\n const [items, setItems] = useState<ReadonlyArray<Item<Value>>>(initialItems);\n\n useEffect(() => {\n const { source } = config;\n if (!source) return;\n\n const controller = new AbortController();\n setStatus(\"loading\");\n setSearchError(undefined);\n\n const fetchResults = async () => {\n try {\n const results = await source(searchTerm || undefined, {\n signal: controller.signal,\n });\n\n if (!controller.signal.aborted) {\n const normalizedResults = normalizeChoices(results);\n\n // Preserve selected state from selectedChoices\n const itemsWithSelection = normalizedResults.map((item) => {\n if (!Separator.isSeparator(item)) {\n return {\n ...item,\n checked: selectedChoices.has(item.value),\n };\n }\n return item;\n });\n setItems(itemsWithSelection);\n // Only reset active to first selectable item when not preserving position\n if (!preserveActivePosition) {\n const firstSelectable = itemsWithSelection.findIndex(isSelectable);\n if (firstSelectable >= 0) {\n setActive(firstSelectable);\n }\n }\n setPreserveActivePosition(false);\n setSearchError(undefined);\n setStatus(\"idle\");\n }\n } catch (error: unknown) {\n if (!controller.signal.aborted && error instanceof Error) {\n setSearchError(error.message);\n }\n }\n };\n\n void fetchResults();\n\n return () => {\n controller.abort();\n };\n }, [searchTerm, config.source, selectedChoices]);\n\n const bounds = useMemo(() => {\n const first = items.findIndex(isSelectable);\n const last = items.findLastIndex(isSelectable);\n\n if (first === -1 && !config.source && status !== \"loading\") {\n throw new ValidationError(\n \"[checkbox prompt] No selectable choices. All choices are disabled.\",\n );\n }\n\n return { first, last };\n }, [items, config.source, status]);\n\n const [active, setActive] = useState(bounds.first >= 0 ? bounds.first : 0);\n const [showHelpTip, setShowHelpTip] = useState(true);\n const [errorMsg, setError] = useState<string>();\n\n useKeypress(async (key, rl) => {\n if (isEnterKey(key)) {\n const selectionChoices = Array.from(selectedChoices.values());\n const isValid = await validate(selectionChoices);\n if (required && selectedChoices.size === 0) {\n setError(\"At least one choice must be selected\");\n } else if (isValid === true) {\n setStatus(\"done\");\n done(selectionChoices.map((choice) => choice.value));\n } else {\n setError(isValid || \"You must select a valid value\");\n }\n } else if (isUpKey(key) || isDownKey(key)) {\n if (\n loop ||\n (isUpKey(key) && active !== bounds.first) ||\n (isDownKey(key) && active !== bounds.last)\n ) {\n const offset = isUpKey(key) ? -1 : 1;\n let next = active;\n do {\n next = (next + offset + items.length) % items.length;\n } while (!isSelectable(items[next]!));\n setActive(next);\n }\n } else if (isSpaceKey(key)) {\n setError(undefined);\n setShowHelpTip(false);\n if (config.source) {\n // In search mode, prevent space from being added to search term\n rl.clearLine(0);\n rl.write(searchTerm); // Restore search term without the space\n // Preserve active position when updating selected choices\n setPreserveActivePosition(true);\n }\n const activeItem = items[active];\n if (activeItem && isSelectable(activeItem)) {\n const newSelectedChoices = new Map(selectedChoices);\n if (selectedChoices.has(activeItem.value)) {\n newSelectedChoices.delete(activeItem.value);\n } else {\n newSelectedChoices.set(activeItem.value, activeItem);\n }\n setSelectedChoices(newSelectedChoices);\n setItems(items.map((choice, i) => (i === active ? toggle(choice) : choice)));\n }\n } else if ((key.name === shortcuts.all && !config.source) || (key.ctrl && key.name === \"a\")) {\n const selectAll = items.some((choice) => isSelectable(choice) && !choice.checked);\n const newSelectedChoices = new Map<Value, NormalizedChoice<Value>>();\n if (selectAll) {\n items.forEach((item) => {\n if (isSelectable(item)) {\n newSelectedChoices.set(item.value, item);\n }\n });\n }\n setSelectedChoices(newSelectedChoices);\n setItems(items.map(check(selectAll)));\n if (config.source) {\n // Preserve active position when updating selected choices in search mode\n setPreserveActivePosition(true);\n }\n } else if (key.name === shortcuts.invert && !config.source) {\n const newSelectedChoices = new Map<Value, NormalizedChoice<Value>>();\n items.forEach((item) => {\n if (isSelectable(item)) {\n if (!selectedChoices.has(item.value)) {\n newSelectedChoices.set(item.value, item);\n }\n }\n });\n setSelectedChoices(newSelectedChoices);\n setItems(items.map(toggle));\n } else if (isNumberKey(key) && !config.source) {\n const selectedIndex = Number(key.name) - 1;\n\n // Find the nth item (ignoring separators)\n let selectableIndex = -1;\n const position = items.findIndex((item) => {\n if (Separator.isSeparator(item)) return false;\n\n selectableIndex++;\n return selectableIndex === selectedIndex;\n });\n\n const selectedItem = items[position];\n if (selectedItem && isSelectable(selectedItem)) {\n setActive(position);\n const newSelectedChoices = new Map(selectedChoices);\n if (selectedChoices.has(selectedItem.value)) {\n newSelectedChoices.delete(selectedItem.value);\n } else {\n newSelectedChoices.set(selectedItem.value, selectedItem);\n }\n setSelectedChoices(newSelectedChoices);\n setItems(items.map((choice, i) => (i === position ? toggle(choice) : choice)));\n }\n } else if (config.source && !isSpaceKey(key)) {\n setSearchTerm(rl.line);\n }\n });\n\n const message = theme.style.message(config.message, status);\n\n let description: string | undefined;\n const page = usePagination({\n items,\n active,\n renderItem({ item, isActive }) {\n if (Separator.isSeparator(item)) {\n return ` ${item.separator}`;\n }\n\n if (item.disabled) {\n const disabledLabel = typeof item.disabled === \"string\" ? item.disabled : \"(disabled)\";\n return theme.style.disabledChoice(`${item.name} ${disabledLabel}`);\n }\n\n if (isActive) {\n description = item.description;\n }\n\n const checkbox = item.checked ? theme.icon.checked : theme.icon.unchecked;\n const color = isActive ? theme.style.highlight : (x: string) => x;\n const cursor = isActive ? theme.icon.cursor : \" \";\n return color(`${cursor}${checkbox} ${item.name}`);\n },\n pageSize,\n loop,\n });\n\n if (status === \"done\") {\n const selection = Array.from(selectedChoices.values());\n const answer = theme.style.answer(theme.style.renderSelectedChoices(selection, items));\n\n return `${prefix} ${message} ${answer}`;\n }\n\n let helpTipTop = \"\";\n let helpTipBottom = \"\";\n if (\n theme.helpMode === \"always\" ||\n (theme.helpMode === \"auto\" && showHelpTip && (instructions === undefined || instructions))\n ) {\n if (typeof instructions === \"string\") {\n helpTipTop = instructions;\n } else {\n const keys = [\n `${theme.style.key(\"space\")} to select`,\n !config.source && shortcuts.all ? `${theme.style.key(shortcuts.all)} to toggle all` : \"\",\n !config.source && shortcuts.invert\n ? `${theme.style.key(shortcuts.invert)} to invert selection`\n : \"\",\n `and ${theme.style.key(\"enter\")} to proceed`,\n ];\n helpTipTop = ` (Press ${keys.filter((key) => key !== \"\").join(\", \")})`;\n }\n\n if (config.source) {\n // Always show bottom tip in search mode for better UX\n const message =\n items.length > pageSize\n ? \"(Use arrow keys to reveal more choices, ctrl+a to select all)\"\n : \"(Use arrow keys to navigate, ctrl+a to select all)\";\n helpTipBottom = `\\n${theme.style.help(message)}`;\n } else if (\n items.length > pageSize &&\n (theme.helpMode === \"always\" || (theme.helpMode === \"auto\" && firstRender.current))\n ) {\n helpTipBottom = `\\n${theme.style.help(\"(Use arrow keys to reveal more choices)\")}`;\n firstRender.current = false;\n }\n }\n\n const choiceDescription = description ? `\\n${theme.style.description(description)}` : ``;\n\n let error = \"\";\n if (searchError) {\n error = `\\n${theme.style.error(searchError)}`;\n } else if (config.source && items.length === 0 && searchTerm !== \"\" && status === \"idle\") {\n error = `\\n${theme.style.error(\"No results found\")}`;\n } else if (errorMsg) {\n error = `\\n${theme.style.error(errorMsg)}`;\n }\n\n if (config.source) {\n const searchStr = theme.style.searchTerm(searchTerm);\n return [\n [prefix, message, searchStr].filter(Boolean).join(\" \"),\n `${error}${error ? \"\\n\" : \"\"}${page}${helpTipBottom}${choiceDescription}`,\n ];\n }\n\n return `${prefix} ${message}${helpTipTop}\\n${page}${helpTipBottom}${choiceDescription}${error}${ansiEscapes.cursorHide}`;\n },\n);\n"],"mappings":";;;;;;AAgDA,MAAM,gBAA+B;CACnC,MAAM;EACJ,SAAS,OAAO,MAAM,QAAQ,aAAa;EAC3C,WAAW,QAAQ;EACnB,QAAQ,QAAQ;EACjB;CACD,OAAO;EACL,iBAAiB,SAAiB,OAAO,IAAI,KAAK,OAAO;EACzD,wBAAwB,oBACtB,gBAAgB,KAAK,WAAW,OAAO,MAAM,CAAC,KAAK,KAAK;EAC1D,cAAc,SAAiB,OAAO,KAAK,KAAK;EAChD,aAAa,SAAiB,OAAO,KAAK,KAAK;EAChD;CACD,UAAU;CACX;AAiDD,SAAS,aAAoB,MAAoD;AAC/E,QAAO,CAAC,UAAU,YAAY,KAAK,IAAI,CAAC,KAAK;;AAG/C,SAAS,OAAc,MAAgC;AACrD,QAAO,aAAa,KAAK,GAAG;EAAE,GAAG;EAAM,SAAS,CAAC,KAAK;EAAS,GAAG;;AAGpE,SAAS,MAAM,SAAkB;AAC/B,S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