create-rstack 2.1.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -1
- package/README.md +43 -73
- package/bin.js +2 -0
- package/dist/index.js +202 -3588
- package/package.json +26 -46
- package/template-app-lit-js/package.json +23 -0
- package/template-app-lit-js/rstack.config.js +28 -0
- package/template-app-lit-js/src/index.css +6 -0
- package/template-app-lit-js/src/index.html +7 -0
- package/template-app-lit-js/src/index.js +4 -0
- package/template-app-lit-js/src/my-element.js +34 -0
- package/template-app-lit-js/tests/index.test.js +12 -0
- package/template-app-lit-ts/package.json +25 -0
- package/template-app-lit-ts/rstack.config.ts +27 -0
- package/template-app-lit-ts/src/index.css +6 -0
- package/template-app-lit-ts/src/index.html +7 -0
- package/template-app-lit-ts/src/index.ts +4 -0
- package/template-app-lit-ts/src/my-element.ts +34 -0
- package/template-app-lit-ts/tests/index.test.ts +12 -0
- package/template-app-lit-ts/tsconfig.json +23 -0
- package/template-app-preact-js/package.json +26 -0
- package/template-app-preact-js/rstack.config.js +29 -0
- package/template-app-preact-js/src/App.css +26 -0
- package/template-app-preact-js/src/App.jsx +12 -0
- package/template-app-preact-js/src/index.jsx +4 -0
- package/template-app-preact-js/tests/index.test.jsx +8 -0
- package/template-app-preact-js/tests/rstest.setup.js +4 -0
- package/template-app-preact-ts/package.json +28 -0
- package/template-app-preact-ts/rstack.config.ts +29 -0
- package/template-app-preact-ts/src/App.css +26 -0
- package/template-app-preact-ts/src/App.tsx +12 -0
- package/template-app-preact-ts/src/index.tsx +7 -0
- package/template-app-preact-ts/tests/index.test.tsx +8 -0
- package/template-app-preact-ts/tests/rstest.setup.ts +4 -0
- package/template-app-preact-ts/tests/tsconfig.json +7 -0
- package/template-app-preact-ts/tsconfig.json +28 -0
- package/template-app-react-js/package.json +28 -0
- package/template-app-react-js/rstack.config.js +29 -0
- package/template-app-react-js/src/App.css +26 -0
- package/template-app-react-js/src/App.jsx +12 -0
- package/template-app-react-js/src/index.jsx +10 -0
- package/template-app-react-js/tests/index.test.jsx +8 -0
- package/template-app-react-js/tests/rstest.setup.js +4 -0
- package/template-app-react-ts/package.json +32 -0
- package/template-app-react-ts/rstack.config.ts +29 -0
- package/template-app-react-ts/src/App.css +26 -0
- package/template-app-react-ts/src/App.tsx +12 -0
- package/template-app-react-ts/src/env.d.ts +9 -0
- package/template-app-react-ts/src/index.tsx +13 -0
- package/template-app-react-ts/tests/index.test.tsx +8 -0
- package/template-app-react-ts/tests/rstest.setup.ts +4 -0
- package/template-app-react-ts/tests/tsconfig.json +7 -0
- package/template-app-react-ts/tsconfig.json +23 -0
- package/template-app-solid-js/package.json +27 -0
- package/template-app-solid-js/rstack.config.js +31 -0
- package/template-app-solid-js/src/App.css +26 -0
- package/template-app-solid-js/src/App.jsx +12 -0
- package/template-app-solid-js/src/index.jsx +4 -0
- package/template-app-solid-js/tests/index.test.jsx +8 -0
- package/template-app-solid-js/tests/rstest.setup.js +4 -0
- package/template-app-solid-ts/package.json +29 -0
- package/template-app-solid-ts/rstack.config.ts +30 -0
- package/template-app-solid-ts/src/App.css +26 -0
- package/template-app-solid-ts/src/App.tsx +12 -0
- package/template-app-solid-ts/src/index.tsx +7 -0
- package/template-app-solid-ts/tests/index.test.tsx +8 -0
- package/template-app-solid-ts/tests/rstest.setup.ts +4 -0
- package/template-app-solid-ts/tests/tsconfig.json +7 -0
- package/template-app-solid-ts/tsconfig.json +24 -0
- package/template-app-svelte-js/package.json +27 -0
- package/template-app-svelte-js/pnpm-workspace.yaml +2 -0
- package/template-app-svelte-js/rstack.config.js +26 -0
- package/template-app-svelte-js/src/App.svelte +28 -0
- package/template-app-svelte-js/src/index.css +6 -0
- package/template-app-svelte-js/src/index.js +8 -0
- package/template-app-svelte-js/tests/index.test.js +8 -0
- package/template-app-svelte-js/tests/rstest.setup.js +4 -0
- package/template-app-svelte-ts/package.json +30 -0
- package/template-app-svelte-ts/pnpm-workspace.yaml +2 -0
- package/template-app-svelte-ts/rstack.config.ts +25 -0
- package/template-app-svelte-ts/src/App.svelte +37 -0
- package/template-app-svelte-ts/src/index.css +6 -0
- package/template-app-svelte-ts/src/index.ts +14 -0
- package/template-app-svelte-ts/tests/index.test.ts +11 -0
- package/template-app-svelte-ts/tests/rstest.setup.ts +4 -0
- package/template-app-svelte-ts/tests/tsconfig.json +7 -0
- package/template-app-svelte-ts/tsconfig.json +22 -0
- package/template-app-vanilla-js/package.json +22 -0
- package/template-app-vanilla-js/rstack.config.js +21 -0
- package/template-app-vanilla-js/src/index.css +26 -0
- package/template-app-vanilla-js/src/index.js +12 -0
- package/template-app-vanilla-js/tests/dom.test.js +12 -0
- package/template-app-vanilla-js/tests/rstest.setup.js +4 -0
- package/template-app-vanilla-ts/package.json +24 -0
- package/template-app-vanilla-ts/rstack.config.ts +20 -0
- package/template-app-vanilla-ts/src/index.css +26 -0
- package/template-app-vanilla-ts/src/index.ts +12 -0
- package/template-app-vanilla-ts/tests/dom.test.ts +12 -0
- package/template-app-vanilla-ts/tests/rstest.setup.ts +4 -0
- package/template-app-vanilla-ts/tests/tsconfig.json +7 -0
- package/template-app-vanilla-ts/tsconfig.json +22 -0
- package/template-app-vue-js/package.json +26 -0
- package/template-app-vue-js/rstack.config.js +25 -0
- package/template-app-vue-js/src/App.vue +28 -0
- package/template-app-vue-js/src/index.css +6 -0
- package/template-app-vue-js/src/index.js +5 -0
- package/template-app-vue-js/tests/index.test.js +8 -0
- package/template-app-vue-js/tests/rstest.setup.js +6 -0
- package/template-app-vue-ts/package.json +29 -0
- package/template-app-vue-ts/rstack.config.ts +24 -0
- package/template-app-vue-ts/src/App.vue +28 -0
- package/template-app-vue-ts/src/index.css +6 -0
- package/template-app-vue-ts/src/index.ts +5 -0
- package/template-app-vue-ts/tests/index.test.ts +8 -0
- package/template-app-vue-ts/tests/rstest.setup.ts +6 -0
- package/template-app-vue-ts/tests/tsconfig.json +7 -0
- package/template-app-vue-ts/tsconfig.json +24 -0
- package/template-common/AGENTS.md +7 -0
- package/template-common/README.md +34 -0
- package/template-common/gitignore +13 -0
- package/template-doc-basic/README.md +34 -0
- package/template-doc-basic/docs/_nav.json +16 -0
- package/template-doc-basic/docs/api/_meta.json +1 -0
- package/template-doc-basic/docs/api/commands.mdx +25 -0
- package/template-doc-basic/docs/api/index.mdx +6 -0
- package/template-doc-basic/docs/guide/_meta.json +7 -0
- package/template-doc-basic/docs/guide/start/_meta.json +1 -0
- package/template-doc-basic/docs/guide/start/introduction.md +5 -0
- package/template-doc-basic/docs/index.md +39 -0
- package/template-doc-basic/gitignore +14 -0
- package/template-doc-basic/package.json +24 -0
- package/template-doc-basic/rstack.config.ts +23 -0
- package/template-doc-basic/tsconfig.json +26 -0
- package/template-doc-i18n/README.md +34 -0
- package/template-doc-i18n/docs/en/_nav.json +16 -0
- package/template-doc-i18n/docs/en/api/_meta.json +1 -0
- package/template-doc-i18n/docs/en/api/commands.mdx +25 -0
- package/template-doc-i18n/docs/en/api/index.mdx +6 -0
- package/template-doc-i18n/docs/en/guide/_meta.json +7 -0
- package/template-doc-i18n/docs/en/guide/start/_meta.json +1 -0
- package/template-doc-i18n/docs/en/guide/start/introduction.md +5 -0
- package/template-doc-i18n/docs/en/index.md +39 -0
- package/template-doc-i18n/docs/zh/_nav.json +16 -0
- package/template-doc-i18n/docs/zh/api/_meta.json +12 -0
- package/template-doc-i18n/docs/zh/api/commands.mdx +25 -0
- package/template-doc-i18n/docs/zh/api/index.mdx +6 -0
- package/template-doc-i18n/docs/zh/guide/_meta.json +7 -0
- package/template-doc-i18n/docs/zh/guide/start/_meta.json +7 -0
- package/template-doc-i18n/docs/zh/guide/start/introduction.md +5 -0
- package/template-doc-i18n/docs/zh/index.md +39 -0
- package/template-doc-i18n/gitignore +14 -0
- package/template-doc-i18n/package.json +24 -0
- package/template-doc-i18n/rstack.config.ts +39 -0
- package/template-doc-i18n/tsconfig.json +26 -0
- package/template-lib-node-js/README.md +40 -0
- package/template-lib-node-js/package.json +33 -0
- package/template-lib-node-js/rstack.config.js +21 -0
- package/template-lib-node-js/src/index.js +1 -0
- package/template-lib-node-js/tests/index.test.js +7 -0
- package/template-lib-node-ts/README.md +40 -0
- package/template-lib-node-ts/package.json +37 -0
- package/template-lib-node-ts/rstack.config.ts +21 -0
- package/template-lib-node-ts/src/index.ts +1 -0
- package/template-lib-node-ts/tests/index.test.ts +7 -0
- package/template-lib-node-ts/tsconfig.json +23 -0
- package/template-lib-react-js/README.md +40 -0
- package/template-lib-react-js/package.json +41 -0
- package/template-lib-react-js/rstack.config.js +38 -0
- package/template-lib-react-js/src/Button.jsx +21 -0
- package/template-lib-react-js/src/button.css +34 -0
- package/template-lib-react-js/src/index.jsx +1 -0
- package/template-lib-react-js/tests/index.test.jsx +11 -0
- package/template-lib-react-js/tests/rstest.setup.js +4 -0
- package/template-lib-react-ts/README.md +40 -0
- package/template-lib-react-ts/package.json +46 -0
- package/template-lib-react-ts/rstack.config.ts +39 -0
- package/template-lib-react-ts/src/Button.tsx +46 -0
- package/template-lib-react-ts/src/button.css +34 -0
- package/template-lib-react-ts/src/index.tsx +1 -0
- package/template-lib-react-ts/tests/index.test.tsx +11 -0
- package/template-lib-react-ts/tests/rstest.setup.ts +4 -0
- package/template-lib-react-ts/tests/tsconfig.json +8 -0
- package/template-lib-react-ts/tsconfig.json +24 -0
- package/template-lib-solid-js/README.md +40 -0
- package/template-lib-solid-js/package.json +39 -0
- package/template-lib-solid-js/rstack.config.js +86 -0
- package/template-lib-solid-js/src/Button.jsx +18 -0
- package/template-lib-solid-js/src/button.css +34 -0
- package/template-lib-solid-js/src/index.jsx +1 -0
- package/template-lib-solid-js/tests/index.test.jsx +11 -0
- package/template-lib-solid-js/tests/rstest.setup.js +4 -0
- package/template-lib-solid-ts/README.md +40 -0
- package/template-lib-solid-ts/package.json +43 -0
- package/template-lib-solid-ts/rstack.config.ts +86 -0
- package/template-lib-solid-ts/src/Button.tsx +43 -0
- package/template-lib-solid-ts/src/button.css +34 -0
- package/template-lib-solid-ts/src/index.tsx +2 -0
- package/template-lib-solid-ts/tests/index.test.tsx +11 -0
- package/template-lib-solid-ts/tests/rstest.setup.ts +4 -0
- package/template-lib-solid-ts/tests/tsconfig.json +8 -0
- package/template-lib-solid-ts/tsconfig.json +25 -0
- package/template-lib-svelte-js/README.md +40 -0
- package/template-lib-svelte-js/package.json +36 -0
- package/template-lib-svelte-js/pnpm-workspace.yaml +2 -0
- package/template-lib-svelte-js/rstack.config.js +35 -0
- package/template-lib-svelte-js/src/Button.svelte +24 -0
- package/template-lib-svelte-js/src/button.css +34 -0
- package/template-lib-svelte-js/src/index.js +1 -0
- package/template-lib-svelte-js/tests/index.test.js +19 -0
- package/template-lib-svelte-ts/README.md +40 -0
- package/template-lib-svelte-ts/package.json +42 -0
- package/template-lib-svelte-ts/pnpm-workspace.yaml +2 -0
- package/template-lib-svelte-ts/rstack.config.ts +35 -0
- package/template-lib-svelte-ts/scripts/rslib-plugin-svelte-dts.ts +59 -0
- package/template-lib-svelte-ts/src/Button.svelte +34 -0
- package/template-lib-svelte-ts/src/button.css +34 -0
- package/template-lib-svelte-ts/src/index.ts +1 -0
- package/template-lib-svelte-ts/tests/index.test.ts +19 -0
- package/template-lib-svelte-ts/tests/tsconfig.json +7 -0
- package/template-lib-svelte-ts/tsconfig.json +25 -0
- package/template-lib-vue-js/README.md +40 -0
- package/template-lib-vue-js/package.json +37 -0
- package/template-lib-vue-js/rstack.config.js +34 -0
- package/template-lib-vue-js/src/Button.vue +43 -0
- package/template-lib-vue-js/src/button.css +34 -0
- package/template-lib-vue-js/src/index.js +1 -0
- package/template-lib-vue-js/tests/index.test.js +17 -0
- package/template-lib-vue-js/tests/rstest.setup.js +6 -0
- package/template-lib-vue-ts/README.md +40 -0
- package/template-lib-vue-ts/package.json +42 -0
- package/template-lib-vue-ts/rstack.config.ts +33 -0
- package/template-lib-vue-ts/src/Button.vue +35 -0
- package/template-lib-vue-ts/src/button.css +34 -0
- package/template-lib-vue-ts/src/index.ts +1 -0
- package/template-lib-vue-ts/tests/index.test.ts +17 -0
- package/template-lib-vue-ts/tests/rstest.setup.ts +6 -0
- package/template-lib-vue-ts/tests/tsconfig.json +8 -0
- package/template-lib-vue-ts/tsconfig.json +27 -0
- package/dist/index.d.ts +0 -316
- package/template-biome/AGENTS.md +0 -6
- package/template-biome/biome.json.template +0 -34
- package/template-biome/package.json +0 -12
- package/template-eslint/AGENTS.md +0 -5
- package/template-eslint/react-js/eslint.config.mjs +0 -23
- package/template-eslint/react-js/package.json +0 -15
- package/template-eslint/react-ts/eslint.config.mjs +0 -22
- package/template-eslint/react-ts/package.json +0 -16
- package/template-eslint/svelte-js/eslint.config.mjs +0 -20
- package/template-eslint/svelte-js/package.json +0 -14
- package/template-eslint/svelte-ts/eslint.config.mjs +0 -28
- package/template-eslint/svelte-ts/package.json +0 -16
- package/template-eslint/vanilla-js/eslint.config.mjs +0 -8
- package/template-eslint/vanilla-js/package.json +0 -13
- package/template-eslint/vanilla-ts/eslint.config.mjs +0 -10
- package/template-eslint/vanilla-ts/package.json +0 -14
- package/template-eslint/vue-js/eslint.config.mjs +0 -15
- package/template-eslint/vue-js/package.json +0 -14
- package/template-eslint/vue-ts/eslint.config.mjs +0 -23
- package/template-eslint/vue-ts/package.json +0 -15
- package/template-prettier/.prettierignore +0 -4
- package/template-prettier/.prettierrc +0 -3
- package/template-prettier/AGENTS.md +0 -5
- package/template-prettier/package.json +0 -11
- package/template-rslint/AGENTS.md +0 -9
- package/template-rslint/react-js/package.json +0 -11
- package/template-rslint/react-js/rslint.config.ts +0 -7
- package/template-rslint/react-ts/package.json +0 -11
- package/template-rslint/react-ts/rslint.config.ts +0 -14
- package/template-rslint/vanilla-js/package.json +0 -11
- package/template-rslint/vanilla-js/rslint.config.ts +0 -3
- package/template-rslint/vanilla-ts/package.json +0 -11
- package/template-rslint/vanilla-ts/rslint.config.ts +0 -3
package/dist/index.js
CHANGED
|
@@ -1,3606 +1,220 @@
|
|
|
1
|
-
import "
|
|
2
|
-
import
|
|
3
|
-
import node_path
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
31
|
-
__webpack_require__.d(getter, {
|
|
32
|
-
a: getter
|
|
33
|
-
});
|
|
34
|
-
return getter;
|
|
35
|
-
};
|
|
36
|
-
})();
|
|
37
|
-
(()=>{
|
|
38
|
-
__webpack_require__.d = (exports, definition)=>{
|
|
39
|
-
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) Object.defineProperty(exports, key, {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
get: definition[key]
|
|
42
|
-
});
|
|
43
|
-
};
|
|
44
|
-
})();
|
|
45
|
-
(()=>{
|
|
46
|
-
__webpack_require__.add = function(modules) {
|
|
47
|
-
Object.assign(__webpack_require__.m, modules);
|
|
48
|
-
};
|
|
49
|
-
})();
|
|
50
|
-
(()=>{
|
|
51
|
-
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
52
|
-
})();
|
|
53
|
-
__webpack_require__.add({
|
|
54
|
-
"./node_modules/.pnpm/@vercel+detect-agent@1.2.3/node_modules/@vercel/detect-agent/dist/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
55
|
-
var __defProp = Object.defineProperty;
|
|
56
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
57
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
58
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
59
|
-
var __export = (target, all)=>{
|
|
60
|
-
for(var name in all)__defProp(target, name, {
|
|
61
|
-
get: all[name],
|
|
62
|
-
enumerable: true
|
|
63
|
-
});
|
|
64
|
-
};
|
|
65
|
-
var __copyProps = (to, from, except, desc)=>{
|
|
66
|
-
if (from && "object" == typeof from || "function" == typeof from) {
|
|
67
|
-
for (let key of __getOwnPropNames(from))if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
68
|
-
get: ()=>from[key],
|
|
69
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return to;
|
|
73
|
-
};
|
|
74
|
-
var __toCommonJS = (mod)=>__copyProps(__defProp({}, "__esModule", {
|
|
75
|
-
value: true
|
|
76
|
-
}), mod);
|
|
77
|
-
var src_exports = {};
|
|
78
|
-
__export(src_exports, {
|
|
79
|
-
KNOWN_AGENTS: ()=>KNOWN_AGENTS,
|
|
80
|
-
determineAgent: ()=>determineAgent
|
|
81
|
-
});
|
|
82
|
-
module.exports = __toCommonJS(src_exports);
|
|
83
|
-
var import_promises = __webpack_require__("node:fs/promises");
|
|
84
|
-
var import_node_fs = __webpack_require__("node:fs?9592");
|
|
85
|
-
const DEVIN_LOCAL_PATH = "/opt/.devin";
|
|
86
|
-
const CURSOR = "cursor";
|
|
87
|
-
const CURSOR_CLI = "cursor-cli";
|
|
88
|
-
const CLAUDE = "claude";
|
|
89
|
-
const COWORK = "cowork";
|
|
90
|
-
const DEVIN = "devin";
|
|
91
|
-
const REPLIT = "replit";
|
|
92
|
-
const GEMINI = "gemini";
|
|
93
|
-
const CODEX = "codex";
|
|
94
|
-
const ANTIGRAVITY = "antigravity";
|
|
95
|
-
const AUGMENT_CLI = "augment-cli";
|
|
96
|
-
const OPENCODE = "opencode";
|
|
97
|
-
const GITHUB_COPILOT = "github-copilot";
|
|
98
|
-
const GITHUB_COPILOT_CLI = "github-copilot-cli";
|
|
99
|
-
const V0 = "v0";
|
|
100
|
-
const KNOWN_AGENTS = {
|
|
101
|
-
CURSOR,
|
|
102
|
-
CURSOR_CLI,
|
|
103
|
-
CLAUDE,
|
|
104
|
-
COWORK,
|
|
105
|
-
DEVIN,
|
|
106
|
-
REPLIT,
|
|
107
|
-
GEMINI,
|
|
108
|
-
CODEX,
|
|
109
|
-
ANTIGRAVITY,
|
|
110
|
-
AUGMENT_CLI,
|
|
111
|
-
OPENCODE,
|
|
112
|
-
GITHUB_COPILOT,
|
|
113
|
-
V0
|
|
114
|
-
};
|
|
115
|
-
async function determineAgent() {
|
|
116
|
-
if (process.env.AI_AGENT) {
|
|
117
|
-
const name = process.env.AI_AGENT.trim();
|
|
118
|
-
if (name) {
|
|
119
|
-
if (name === GITHUB_COPILOT || name === GITHUB_COPILOT_CLI) return {
|
|
120
|
-
isAgent: true,
|
|
121
|
-
agent: {
|
|
122
|
-
name: GITHUB_COPILOT
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
if (name === V0) return {
|
|
126
|
-
isAgent: true,
|
|
127
|
-
agent: {
|
|
128
|
-
name: V0
|
|
129
|
-
}
|
|
130
|
-
};
|
|
131
|
-
return {
|
|
132
|
-
isAgent: true,
|
|
133
|
-
agent: {
|
|
134
|
-
name
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
if (process.env.CURSOR_TRACE_ID) return {
|
|
140
|
-
isAgent: true,
|
|
141
|
-
agent: {
|
|
142
|
-
name: CURSOR
|
|
143
|
-
}
|
|
144
|
-
};
|
|
145
|
-
if (process.env.CURSOR_AGENT || "agent-exec" === process.env.CURSOR_EXTENSION_HOST_ROLE) return {
|
|
146
|
-
isAgent: true,
|
|
147
|
-
agent: {
|
|
148
|
-
name: CURSOR_CLI
|
|
149
|
-
}
|
|
150
|
-
};
|
|
151
|
-
if (process.env.GEMINI_CLI) return {
|
|
152
|
-
isAgent: true,
|
|
153
|
-
agent: {
|
|
154
|
-
name: GEMINI
|
|
155
|
-
}
|
|
156
|
-
};
|
|
157
|
-
if (process.env.CODEX_SANDBOX || process.env.CODEX_CI || process.env.CODEX_THREAD_ID) return {
|
|
158
|
-
isAgent: true,
|
|
159
|
-
agent: {
|
|
160
|
-
name: CODEX
|
|
161
|
-
}
|
|
162
|
-
};
|
|
163
|
-
if (process.env.ANTIGRAVITY_AGENT) return {
|
|
164
|
-
isAgent: true,
|
|
165
|
-
agent: {
|
|
166
|
-
name: ANTIGRAVITY
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
if (process.env.AUGMENT_AGENT) return {
|
|
170
|
-
isAgent: true,
|
|
171
|
-
agent: {
|
|
172
|
-
name: AUGMENT_CLI
|
|
173
|
-
}
|
|
174
|
-
};
|
|
175
|
-
if (process.env.OPENCODE_CLIENT) return {
|
|
176
|
-
isAgent: true,
|
|
177
|
-
agent: {
|
|
178
|
-
name: OPENCODE
|
|
179
|
-
}
|
|
180
|
-
};
|
|
181
|
-
if (process.env.CLAUDECODE || process.env.CLAUDE_CODE) {
|
|
182
|
-
if (process.env.CLAUDE_CODE_IS_COWORK) return {
|
|
183
|
-
isAgent: true,
|
|
184
|
-
agent: {
|
|
185
|
-
name: COWORK
|
|
186
|
-
}
|
|
187
|
-
};
|
|
188
|
-
return {
|
|
189
|
-
isAgent: true,
|
|
190
|
-
agent: {
|
|
191
|
-
name: CLAUDE
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
}
|
|
195
|
-
if (process.env.REPL_ID) return {
|
|
196
|
-
isAgent: true,
|
|
197
|
-
agent: {
|
|
198
|
-
name: REPLIT
|
|
199
|
-
}
|
|
200
|
-
};
|
|
201
|
-
if (process.env.COPILOT_MODEL || process.env.COPILOT_ALLOW_ALL || process.env.COPILOT_GITHUB_TOKEN) return {
|
|
202
|
-
isAgent: true,
|
|
203
|
-
agent: {
|
|
204
|
-
name: GITHUB_COPILOT
|
|
205
|
-
}
|
|
206
|
-
};
|
|
207
|
-
try {
|
|
208
|
-
await (0, import_promises.access)(DEVIN_LOCAL_PATH, import_node_fs.constants.F_OK);
|
|
209
|
-
return {
|
|
210
|
-
isAgent: true,
|
|
211
|
-
agent: {
|
|
212
|
-
name: DEVIN
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
} catch (_error) {}
|
|
216
|
-
return {
|
|
217
|
-
isAgent: false,
|
|
218
|
-
agent: void 0
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
"./node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js" (module) {
|
|
223
|
-
var isMergeableObject = function(value) {
|
|
224
|
-
return isNonNullObject(value) && !isSpecial(value);
|
|
225
|
-
};
|
|
226
|
-
function isNonNullObject(value) {
|
|
227
|
-
return !!value && 'object' == typeof value;
|
|
228
|
-
}
|
|
229
|
-
function isSpecial(value) {
|
|
230
|
-
var stringValue = Object.prototype.toString.call(value);
|
|
231
|
-
return '[object RegExp]' === stringValue || '[object Date]' === stringValue || isReactElement(value);
|
|
232
|
-
}
|
|
233
|
-
var canUseSymbol = 'function' == typeof Symbol && Symbol.for;
|
|
234
|
-
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
235
|
-
function isReactElement(value) {
|
|
236
|
-
return value.$$typeof === REACT_ELEMENT_TYPE;
|
|
237
|
-
}
|
|
238
|
-
function emptyTarget(val) {
|
|
239
|
-
return Array.isArray(val) ? [] : {};
|
|
240
|
-
}
|
|
241
|
-
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
242
|
-
return false !== options.clone && options.isMergeableObject(value) ? deepmerge(emptyTarget(value), value, options) : value;
|
|
243
|
-
}
|
|
244
|
-
function defaultArrayMerge(target, source, options) {
|
|
245
|
-
return target.concat(source).map(function(element) {
|
|
246
|
-
return cloneUnlessOtherwiseSpecified(element, options);
|
|
247
|
-
});
|
|
248
|
-
}
|
|
249
|
-
function getMergeFunction(key, options) {
|
|
250
|
-
if (!options.customMerge) return deepmerge;
|
|
251
|
-
var customMerge = options.customMerge(key);
|
|
252
|
-
return 'function' == typeof customMerge ? customMerge : deepmerge;
|
|
253
|
-
}
|
|
254
|
-
function getEnumerableOwnPropertySymbols(target) {
|
|
255
|
-
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
256
|
-
return Object.propertyIsEnumerable.call(target, symbol);
|
|
257
|
-
}) : [];
|
|
258
|
-
}
|
|
259
|
-
function getKeys(target) {
|
|
260
|
-
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target));
|
|
261
|
-
}
|
|
262
|
-
function propertyIsOnObject(object, property) {
|
|
263
|
-
try {
|
|
264
|
-
return property in object;
|
|
265
|
-
} catch (_) {
|
|
266
|
-
return false;
|
|
267
|
-
}
|
|
268
|
-
}
|
|
269
|
-
function propertyIsUnsafe(target, key) {
|
|
270
|
-
return propertyIsOnObject(target, key) && !(Object.hasOwnProperty.call(target, key) && Object.propertyIsEnumerable.call(target, key));
|
|
271
|
-
}
|
|
272
|
-
function mergeObject(target, source, options) {
|
|
273
|
-
var destination = {};
|
|
274
|
-
if (options.isMergeableObject(target)) getKeys(target).forEach(function(key) {
|
|
275
|
-
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
276
|
-
});
|
|
277
|
-
getKeys(source).forEach(function(key) {
|
|
278
|
-
if (propertyIsUnsafe(target, key)) return;
|
|
279
|
-
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
280
|
-
else destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
281
|
-
});
|
|
282
|
-
return destination;
|
|
283
|
-
}
|
|
284
|
-
function deepmerge(target, source, options) {
|
|
285
|
-
options = options || {};
|
|
286
|
-
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
287
|
-
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
288
|
-
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
289
|
-
var sourceIsArray = Array.isArray(source);
|
|
290
|
-
var targetIsArray = Array.isArray(target);
|
|
291
|
-
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
292
|
-
if (!sourceAndTargetTypesMatch) return cloneUnlessOtherwiseSpecified(source, options);
|
|
293
|
-
if (sourceIsArray) return options.arrayMerge(target, source, options);
|
|
294
|
-
return mergeObject(target, source, options);
|
|
295
|
-
}
|
|
296
|
-
deepmerge.all = function(array, options) {
|
|
297
|
-
if (!Array.isArray(array)) throw new Error('first argument should be an array');
|
|
298
|
-
return array.reduce(function(prev, next) {
|
|
299
|
-
return deepmerge(prev, next, options);
|
|
300
|
-
}, {});
|
|
301
|
-
};
|
|
302
|
-
var deepmerge_1 = deepmerge;
|
|
303
|
-
module.exports = deepmerge_1;
|
|
304
|
-
},
|
|
305
|
-
"./node_modules/.pnpm/minimist@1.2.8/node_modules/minimist/index.js" (module) {
|
|
306
|
-
function hasKey(obj, keys) {
|
|
307
|
-
var o = obj;
|
|
308
|
-
keys.slice(0, -1).forEach(function(key) {
|
|
309
|
-
o = o[key] || {};
|
|
310
|
-
});
|
|
311
|
-
var key = keys[keys.length - 1];
|
|
312
|
-
return key in o;
|
|
313
|
-
}
|
|
314
|
-
function isNumber(x) {
|
|
315
|
-
if ('number' == typeof x) return true;
|
|
316
|
-
if (/^0x[0-9a-f]+$/i.test(x)) return true;
|
|
317
|
-
return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
|
|
318
|
-
}
|
|
319
|
-
function isConstructorOrProto(obj, key) {
|
|
320
|
-
return 'constructor' === key && 'function' == typeof obj[key] || '__proto__' === key;
|
|
321
|
-
}
|
|
322
|
-
module.exports = function(args, opts) {
|
|
323
|
-
if (!opts) opts = {};
|
|
324
|
-
var flags = {
|
|
325
|
-
bools: {},
|
|
326
|
-
strings: {},
|
|
327
|
-
unknownFn: null
|
|
328
|
-
};
|
|
329
|
-
if ('function' == typeof opts.unknown) flags.unknownFn = opts.unknown;
|
|
330
|
-
if ('boolean' == typeof opts.boolean && opts.boolean) flags.allBools = true;
|
|
331
|
-
else [].concat(opts.boolean).filter(Boolean).forEach(function(key) {
|
|
332
|
-
flags.bools[key] = true;
|
|
333
|
-
});
|
|
334
|
-
var aliases = {};
|
|
335
|
-
function aliasIsBoolean(key) {
|
|
336
|
-
return aliases[key].some(function(x) {
|
|
337
|
-
return flags.bools[x];
|
|
338
|
-
});
|
|
339
|
-
}
|
|
340
|
-
Object.keys(opts.alias || {}).forEach(function(key) {
|
|
341
|
-
aliases[key] = [].concat(opts.alias[key]);
|
|
342
|
-
aliases[key].forEach(function(x) {
|
|
343
|
-
aliases[x] = [
|
|
344
|
-
key
|
|
345
|
-
].concat(aliases[key].filter(function(y) {
|
|
346
|
-
return x !== y;
|
|
347
|
-
}));
|
|
348
|
-
});
|
|
349
|
-
});
|
|
350
|
-
[].concat(opts.string).filter(Boolean).forEach(function(key) {
|
|
351
|
-
flags.strings[key] = true;
|
|
352
|
-
if (aliases[key]) [].concat(aliases[key]).forEach(function(k) {
|
|
353
|
-
flags.strings[k] = true;
|
|
354
|
-
});
|
|
355
|
-
});
|
|
356
|
-
var defaults = opts.default || {};
|
|
357
|
-
var argv = {
|
|
358
|
-
_: []
|
|
359
|
-
};
|
|
360
|
-
function argDefined(key, arg) {
|
|
361
|
-
return flags.allBools && /^--[^=]+$/.test(arg) || flags.strings[key] || flags.bools[key] || aliases[key];
|
|
362
|
-
}
|
|
363
|
-
function setKey(obj, keys, value) {
|
|
364
|
-
var o = obj;
|
|
365
|
-
for(var i = 0; i < keys.length - 1; i++){
|
|
366
|
-
var key = keys[i];
|
|
367
|
-
if (isConstructorOrProto(o, key)) return;
|
|
368
|
-
if (void 0 === o[key]) o[key] = {};
|
|
369
|
-
if (o[key] === Object.prototype || o[key] === Number.prototype || o[key] === String.prototype) o[key] = {};
|
|
370
|
-
if (o[key] === Array.prototype) o[key] = [];
|
|
371
|
-
o = o[key];
|
|
372
|
-
}
|
|
373
|
-
var lastKey = keys[keys.length - 1];
|
|
374
|
-
if (isConstructorOrProto(o, lastKey)) return;
|
|
375
|
-
if (o === Object.prototype || o === Number.prototype || o === String.prototype) o = {};
|
|
376
|
-
if (o === Array.prototype) o = [];
|
|
377
|
-
if (void 0 === o[lastKey] || flags.bools[lastKey] || 'boolean' == typeof o[lastKey]) o[lastKey] = value;
|
|
378
|
-
else if (Array.isArray(o[lastKey])) o[lastKey].push(value);
|
|
379
|
-
else o[lastKey] = [
|
|
380
|
-
o[lastKey],
|
|
381
|
-
value
|
|
382
|
-
];
|
|
383
|
-
}
|
|
384
|
-
function setArg(key, val, arg) {
|
|
385
|
-
if (arg && flags.unknownFn && !argDefined(key, arg)) {
|
|
386
|
-
if (false === flags.unknownFn(arg)) return;
|
|
387
|
-
}
|
|
388
|
-
var value = !flags.strings[key] && isNumber(val) ? Number(val) : val;
|
|
389
|
-
setKey(argv, key.split('.'), value);
|
|
390
|
-
(aliases[key] || []).forEach(function(x) {
|
|
391
|
-
setKey(argv, x.split('.'), value);
|
|
392
|
-
});
|
|
393
|
-
}
|
|
394
|
-
Object.keys(flags.bools).forEach(function(key) {
|
|
395
|
-
setArg(key, void 0 === defaults[key] ? false : defaults[key]);
|
|
396
|
-
});
|
|
397
|
-
var notFlags = [];
|
|
398
|
-
if (-1 !== args.indexOf('--')) {
|
|
399
|
-
notFlags = args.slice(args.indexOf('--') + 1);
|
|
400
|
-
args = args.slice(0, args.indexOf('--'));
|
|
401
|
-
}
|
|
402
|
-
for(var i = 0; i < args.length; i++){
|
|
403
|
-
var arg = args[i];
|
|
404
|
-
var key;
|
|
405
|
-
var next;
|
|
406
|
-
if (/^--.+=/.test(arg)) {
|
|
407
|
-
var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
|
|
408
|
-
key = m[1];
|
|
409
|
-
var value = m[2];
|
|
410
|
-
if (flags.bools[key]) value = 'false' !== value;
|
|
411
|
-
setArg(key, value, arg);
|
|
412
|
-
} else if (/^--no-.+/.test(arg)) {
|
|
413
|
-
key = arg.match(/^--no-(.+)/)[1];
|
|
414
|
-
setArg(key, false, arg);
|
|
415
|
-
} else if (/^--.+/.test(arg)) {
|
|
416
|
-
key = arg.match(/^--(.+)/)[1];
|
|
417
|
-
next = args[i + 1];
|
|
418
|
-
if (void 0 === next || /^(-|--)[^-]/.test(next) || flags.bools[key] || flags.allBools || (aliases[key] ? aliasIsBoolean(key) : false)) if (/^(true|false)$/.test(next)) {
|
|
419
|
-
setArg(key, 'true' === next, arg);
|
|
420
|
-
i += 1;
|
|
421
|
-
} else setArg(key, flags.strings[key] ? '' : true, arg);
|
|
422
|
-
else {
|
|
423
|
-
setArg(key, next, arg);
|
|
424
|
-
i += 1;
|
|
425
|
-
}
|
|
426
|
-
} else if (/^-[^-]+/.test(arg)) {
|
|
427
|
-
var letters = arg.slice(1, -1).split('');
|
|
428
|
-
var broken = false;
|
|
429
|
-
for(var j = 0; j < letters.length; j++){
|
|
430
|
-
next = arg.slice(j + 2);
|
|
431
|
-
if ('-' === next) {
|
|
432
|
-
setArg(letters[j], next, arg);
|
|
433
|
-
continue;
|
|
434
|
-
}
|
|
435
|
-
if (/[A-Za-z]/.test(letters[j]) && '=' === next[0]) {
|
|
436
|
-
setArg(letters[j], next.slice(1), arg);
|
|
437
|
-
broken = true;
|
|
438
|
-
break;
|
|
439
|
-
}
|
|
440
|
-
if (/[A-Za-z]/.test(letters[j]) && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
|
|
441
|
-
setArg(letters[j], next, arg);
|
|
442
|
-
broken = true;
|
|
443
|
-
break;
|
|
444
|
-
}
|
|
445
|
-
if (letters[j + 1] && letters[j + 1].match(/\W/)) {
|
|
446
|
-
setArg(letters[j], arg.slice(j + 2), arg);
|
|
447
|
-
broken = true;
|
|
448
|
-
break;
|
|
449
|
-
}
|
|
450
|
-
setArg(letters[j], flags.strings[letters[j]] ? '' : true, arg);
|
|
451
|
-
}
|
|
452
|
-
key = arg.slice(-1)[0];
|
|
453
|
-
if (!broken && '-' !== key) if (!args[i + 1] || /^(-|--)[^-]/.test(args[i + 1]) || flags.bools[key] || (aliases[key] ? aliasIsBoolean(key) : false)) if (args[i + 1] && /^(true|false)$/.test(args[i + 1])) {
|
|
454
|
-
setArg(key, 'true' === args[i + 1], arg);
|
|
455
|
-
i += 1;
|
|
456
|
-
} else setArg(key, flags.strings[key] ? '' : true, arg);
|
|
457
|
-
else {
|
|
458
|
-
setArg(key, args[i + 1], arg);
|
|
459
|
-
i += 1;
|
|
460
|
-
}
|
|
461
|
-
} else {
|
|
462
|
-
if (!flags.unknownFn || false !== flags.unknownFn(arg)) argv._.push(flags.strings._ || !isNumber(arg) ? arg : Number(arg));
|
|
463
|
-
if (opts.stopEarly) {
|
|
464
|
-
argv._.push.apply(argv._, args.slice(i + 1));
|
|
465
|
-
break;
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
}
|
|
469
|
-
Object.keys(defaults).forEach(function(k) {
|
|
470
|
-
if (!hasKey(argv, k.split('.'))) {
|
|
471
|
-
setKey(argv, k.split('.'), defaults[k]);
|
|
472
|
-
(aliases[k] || []).forEach(function(x) {
|
|
473
|
-
setKey(argv, x.split('.'), defaults[k]);
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
});
|
|
477
|
-
if (opts['--']) argv['--'] = notFlags.slice();
|
|
478
|
-
else notFlags.forEach(function(k) {
|
|
479
|
-
argv._.push(k);
|
|
480
|
-
});
|
|
481
|
-
return argv;
|
|
482
|
-
};
|
|
483
|
-
},
|
|
484
|
-
"./node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js" (module) {
|
|
485
|
-
const ESC = '\x1B';
|
|
486
|
-
const CSI = `${ESC}[`;
|
|
487
|
-
const beep = '\u0007';
|
|
488
|
-
const cursor = {
|
|
489
|
-
to (x, y) {
|
|
490
|
-
if (!y) return `${CSI}${x + 1}G`;
|
|
491
|
-
return `${CSI}${y + 1};${x + 1}H`;
|
|
1
|
+
import { checkCancel, create, select as create_toolkit_select } from "@rstackjs/create-toolkit";
|
|
2
|
+
import { appendFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
3
|
+
import node_path from "node:path";
|
|
4
|
+
const packageRoot = node_path.join(import.meta.dirname, '..');
|
|
5
|
+
const getTemplateName = async ({ template })=>{
|
|
6
|
+
if ('string' == typeof template) {
|
|
7
|
+
if ('app' === template || template.startsWith('app-')) {
|
|
8
|
+
const [, framework = 'vanilla', language = 'js'] = template.split('-');
|
|
9
|
+
if ('js' === framework || 'ts' === framework) return `app-vanilla-${framework}`;
|
|
10
|
+
return `app-${framework}-${language}`;
|
|
11
|
+
}
|
|
12
|
+
if ('lib' === template || template.startsWith('lib-')) {
|
|
13
|
+
const [, libraryType = 'node', language = 'js'] = template.split('-');
|
|
14
|
+
if ('js' === libraryType || 'ts' === libraryType) return `lib-node-${libraryType}`;
|
|
15
|
+
return `lib-${libraryType}-${language}`;
|
|
16
|
+
}
|
|
17
|
+
if ('doc' === template || template.startsWith('doc-')) {
|
|
18
|
+
const [, documentationType = 'basic'] = template.split('-');
|
|
19
|
+
return `doc-${documentationType}`;
|
|
20
|
+
}
|
|
21
|
+
const [type, language = 'js'] = template.split('-');
|
|
22
|
+
return `${type}-${language}`;
|
|
23
|
+
}
|
|
24
|
+
const projectType = checkCancel(await create_toolkit_select({
|
|
25
|
+
message: 'Select project type',
|
|
26
|
+
options: [
|
|
27
|
+
{
|
|
28
|
+
value: 'app',
|
|
29
|
+
label: 'Web Application'
|
|
492
30
|
},
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
else if (x > 0) ret += `${CSI}${x}C`;
|
|
497
|
-
if (y < 0) ret += `${CSI}${-y}A`;
|
|
498
|
-
else if (y > 0) ret += `${CSI}${y}B`;
|
|
499
|
-
return ret;
|
|
31
|
+
{
|
|
32
|
+
value: 'lib',
|
|
33
|
+
label: 'Library'
|
|
500
34
|
},
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
backward: (count = 1)=>`${CSI}${count}D`,
|
|
505
|
-
nextLine: (count = 1)=>`${CSI}E`.repeat(count),
|
|
506
|
-
prevLine: (count = 1)=>`${CSI}F`.repeat(count),
|
|
507
|
-
left: `${CSI}G`,
|
|
508
|
-
hide: `${CSI}?25l`,
|
|
509
|
-
show: `${CSI}?25h`,
|
|
510
|
-
save: `${ESC}7`,
|
|
511
|
-
restore: `${ESC}8`
|
|
512
|
-
};
|
|
513
|
-
const scroll = {
|
|
514
|
-
up: (count = 1)=>`${CSI}S`.repeat(count),
|
|
515
|
-
down: (count = 1)=>`${CSI}T`.repeat(count)
|
|
516
|
-
};
|
|
517
|
-
const erase = {
|
|
518
|
-
screen: `${CSI}2J`,
|
|
519
|
-
up: (count = 1)=>`${CSI}1J`.repeat(count),
|
|
520
|
-
down: (count = 1)=>`${CSI}J`.repeat(count),
|
|
521
|
-
line: `${CSI}2K`,
|
|
522
|
-
lineEnd: `${CSI}K`,
|
|
523
|
-
lineStart: `${CSI}1K`,
|
|
524
|
-
lines (count) {
|
|
525
|
-
let clear = '';
|
|
526
|
-
for(let i = 0; i < count; i++)clear += this.line + (i < count - 1 ? cursor.up() : '');
|
|
527
|
-
if (count) clear += cursor.left;
|
|
528
|
-
return clear;
|
|
529
|
-
}
|
|
530
|
-
};
|
|
531
|
-
module.exports = {
|
|
532
|
-
cursor,
|
|
533
|
-
scroll,
|
|
534
|
-
erase,
|
|
535
|
-
beep
|
|
536
|
-
};
|
|
537
|
-
},
|
|
538
|
-
"node:fs?9592" (module) {
|
|
539
|
-
module.exports = __rspack_createRequire_require("node:fs");
|
|
540
|
-
},
|
|
541
|
-
"node:fs/promises" (module) {
|
|
542
|
-
module.exports = __rspack_createRequire_require("node:fs/promises");
|
|
543
|
-
}
|
|
544
|
-
});
|
|
545
|
-
const getCodePointsLength = (()=>{
|
|
546
|
-
const SURROGATE_PAIR_RE = /[\uD800-\uDBFF][\uDC00-\uDFFF]/g;
|
|
547
|
-
return (input)=>{
|
|
548
|
-
let surrogatePairsNr = 0;
|
|
549
|
-
SURROGATE_PAIR_RE.lastIndex = 0;
|
|
550
|
-
while(SURROGATE_PAIR_RE.test(input))surrogatePairsNr += 1;
|
|
551
|
-
return input.length - surrogatePairsNr;
|
|
552
|
-
};
|
|
553
|
-
})();
|
|
554
|
-
const isFullWidth = (x)=>0x3000 === x || x >= 0xFF01 && x <= 0xFF60 || x >= 0xFFE0 && x <= 0xFFE6;
|
|
555
|
-
const isWideNotCJKTNotEmoji = (x)=>0x231B === x || 0x2329 === x || x >= 0x2FF0 && x <= 0x2FFF || x >= 0x3001 && x <= 0x303E || x >= 0x3099 && x <= 0x30FF || x >= 0x3105 && x <= 0x312F || x >= 0x3131 && x <= 0x318E || x >= 0x3190 && x <= 0x31E3 || x >= 0x31EF && x <= 0x321E || x >= 0x3220 && x <= 0x3247 || x >= 0x3250 && x <= 0x4DBF || x >= 0xFE10 && x <= 0xFE19 || x >= 0xFE30 && x <= 0xFE52 || x >= 0xFE54 && x <= 0xFE66 || x >= 0xFE68 && x <= 0xFE6B || x >= 0x1F200 && x <= 0x1F202 || x >= 0x1F210 && x <= 0x1F23B || x >= 0x1F240 && x <= 0x1F248 || x >= 0x20000 && x <= 0x2FFFD || x >= 0x30000 && x <= 0x3FFFD;
|
|
556
|
-
const ANSI_RE = /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y;
|
|
557
|
-
const CONTROL_RE = /[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y;
|
|
558
|
-
const CJKT_WIDE_RE = /(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/yu;
|
|
559
|
-
const TAB_RE = /\t{1,1000}/y;
|
|
560
|
-
const EMOJI_RE = /[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/yu;
|
|
561
|
-
const LATIN_RE = /(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y;
|
|
562
|
-
const MODIFIER_RE = /\p{M}+/gu;
|
|
563
|
-
const NO_TRUNCATION = {
|
|
564
|
-
limit: 1 / 0,
|
|
565
|
-
ellipsis: ''
|
|
566
|
-
};
|
|
567
|
-
const getStringTruncatedWidth = (input, truncationOptions = {}, widthOptions = {})=>{
|
|
568
|
-
const LIMIT = truncationOptions.limit ?? 1 / 0;
|
|
569
|
-
const ELLIPSIS = truncationOptions.ellipsis ?? '';
|
|
570
|
-
const ELLIPSIS_WIDTH = truncationOptions?.ellipsisWidth ?? (ELLIPSIS ? getStringTruncatedWidth(ELLIPSIS, NO_TRUNCATION, widthOptions).width : 0);
|
|
571
|
-
const ANSI_WIDTH = 0;
|
|
572
|
-
const CONTROL_WIDTH = widthOptions.controlWidth ?? 0;
|
|
573
|
-
const TAB_WIDTH = widthOptions.tabWidth ?? 8;
|
|
574
|
-
const EMOJI_WIDTH = widthOptions.emojiWidth ?? 2;
|
|
575
|
-
const FULL_WIDTH_WIDTH = 2;
|
|
576
|
-
const REGULAR_WIDTH = widthOptions.regularWidth ?? 1;
|
|
577
|
-
const WIDE_WIDTH = widthOptions.wideWidth ?? FULL_WIDTH_WIDTH;
|
|
578
|
-
const PARSE_BLOCKS = [
|
|
579
|
-
[
|
|
580
|
-
LATIN_RE,
|
|
581
|
-
REGULAR_WIDTH
|
|
582
|
-
],
|
|
583
|
-
[
|
|
584
|
-
ANSI_RE,
|
|
585
|
-
ANSI_WIDTH
|
|
586
|
-
],
|
|
587
|
-
[
|
|
588
|
-
CONTROL_RE,
|
|
589
|
-
CONTROL_WIDTH
|
|
590
|
-
],
|
|
591
|
-
[
|
|
592
|
-
TAB_RE,
|
|
593
|
-
TAB_WIDTH
|
|
594
|
-
],
|
|
595
|
-
[
|
|
596
|
-
EMOJI_RE,
|
|
597
|
-
EMOJI_WIDTH
|
|
598
|
-
],
|
|
599
|
-
[
|
|
600
|
-
CJKT_WIDE_RE,
|
|
601
|
-
WIDE_WIDTH
|
|
602
|
-
]
|
|
603
|
-
];
|
|
604
|
-
let indexPrev = 0;
|
|
605
|
-
let index = 0;
|
|
606
|
-
let length = input.length;
|
|
607
|
-
let lengthExtra = 0;
|
|
608
|
-
let truncationEnabled = false;
|
|
609
|
-
let truncationIndex = length;
|
|
610
|
-
let truncationLimit = Math.max(0, LIMIT - ELLIPSIS_WIDTH);
|
|
611
|
-
let unmatchedStart = 0;
|
|
612
|
-
let unmatchedEnd = 0;
|
|
613
|
-
let width = 0;
|
|
614
|
-
let widthExtra = 0;
|
|
615
|
-
outer: while(true){
|
|
616
|
-
if (unmatchedEnd > unmatchedStart || index >= length && index > indexPrev) {
|
|
617
|
-
const unmatched = input.slice(unmatchedStart, unmatchedEnd) || input.slice(indexPrev, index);
|
|
618
|
-
lengthExtra = 0;
|
|
619
|
-
for (const char of unmatched.replaceAll(MODIFIER_RE, '')){
|
|
620
|
-
const codePoint = char.codePointAt(0) || 0;
|
|
621
|
-
widthExtra = isFullWidth(codePoint) ? FULL_WIDTH_WIDTH : isWideNotCJKTNotEmoji(codePoint) ? WIDE_WIDTH : REGULAR_WIDTH;
|
|
622
|
-
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, Math.max(unmatchedStart, indexPrev) + lengthExtra);
|
|
623
|
-
if (width + widthExtra > LIMIT) {
|
|
624
|
-
truncationEnabled = true;
|
|
625
|
-
break outer;
|
|
626
|
-
}
|
|
627
|
-
lengthExtra += char.length;
|
|
628
|
-
width += widthExtra;
|
|
629
|
-
}
|
|
630
|
-
unmatchedStart = unmatchedEnd = 0;
|
|
631
|
-
}
|
|
632
|
-
if (index >= length) break;
|
|
633
|
-
for(let i = 0, l = PARSE_BLOCKS.length; i < l; i++){
|
|
634
|
-
const [BLOCK_RE, BLOCK_WIDTH] = PARSE_BLOCKS[i];
|
|
635
|
-
BLOCK_RE.lastIndex = index;
|
|
636
|
-
if (BLOCK_RE.test(input)) {
|
|
637
|
-
lengthExtra = BLOCK_RE === CJKT_WIDE_RE ? getCodePointsLength(input.slice(index, BLOCK_RE.lastIndex)) : BLOCK_RE === EMOJI_RE ? 1 : BLOCK_RE.lastIndex - index;
|
|
638
|
-
widthExtra = lengthExtra * BLOCK_WIDTH;
|
|
639
|
-
if (width + widthExtra > truncationLimit) truncationIndex = Math.min(truncationIndex, index + Math.floor((truncationLimit - width) / BLOCK_WIDTH));
|
|
640
|
-
if (width + widthExtra > LIMIT) {
|
|
641
|
-
truncationEnabled = true;
|
|
642
|
-
break outer;
|
|
643
|
-
}
|
|
644
|
-
width += widthExtra;
|
|
645
|
-
unmatchedStart = indexPrev;
|
|
646
|
-
unmatchedEnd = index;
|
|
647
|
-
index = indexPrev = BLOCK_RE.lastIndex;
|
|
648
|
-
continue outer;
|
|
649
|
-
}
|
|
650
|
-
}
|
|
651
|
-
index += 1;
|
|
652
|
-
}
|
|
653
|
-
return {
|
|
654
|
-
width: truncationEnabled ? truncationLimit : width,
|
|
655
|
-
index: truncationEnabled ? truncationIndex : length,
|
|
656
|
-
truncated: truncationEnabled,
|
|
657
|
-
ellipsed: truncationEnabled && LIMIT >= ELLIPSIS_WIDTH
|
|
658
|
-
};
|
|
659
|
-
};
|
|
660
|
-
const dist = getStringTruncatedWidth;
|
|
661
|
-
const dist_NO_TRUNCATION = {
|
|
662
|
-
limit: 1 / 0,
|
|
663
|
-
ellipsis: '',
|
|
664
|
-
ellipsisWidth: 0
|
|
665
|
-
};
|
|
666
|
-
const fastStringWidth = (input, options = {})=>dist(input, dist_NO_TRUNCATION, options).width;
|
|
667
|
-
const fast_string_width_dist = fastStringWidth;
|
|
668
|
-
const ESC = '\x1B';
|
|
669
|
-
const CSI = '\x9B';
|
|
670
|
-
const END_CODE = 39;
|
|
671
|
-
const ANSI_ESCAPE_BELL = '\u0007';
|
|
672
|
-
const ANSI_CSI = '[';
|
|
673
|
-
const ANSI_OSC = ']';
|
|
674
|
-
const ANSI_SGR_TERMINATOR = 'm';
|
|
675
|
-
const ANSI_ESCAPE_LINK = `${ANSI_OSC}8;;`;
|
|
676
|
-
const GROUP_REGEX = new RegExp(`(?:\\${ANSI_CSI}(?<code>\\d+)m|\\${ANSI_ESCAPE_LINK}(?<uri>.*)${ANSI_ESCAPE_BELL})`, 'y');
|
|
677
|
-
const getClosingCode = (openingCode)=>{
|
|
678
|
-
if (openingCode >= 30 && openingCode <= 37) return 39;
|
|
679
|
-
if (openingCode >= 90 && openingCode <= 97) return 39;
|
|
680
|
-
if (openingCode >= 40 && openingCode <= 47) return 49;
|
|
681
|
-
if (openingCode >= 100 && openingCode <= 107) return 49;
|
|
682
|
-
if (1 === openingCode || 2 === openingCode) return 22;
|
|
683
|
-
if (3 === openingCode) return 23;
|
|
684
|
-
if (4 === openingCode) return 24;
|
|
685
|
-
if (7 === openingCode) return 27;
|
|
686
|
-
if (8 === openingCode) return 28;
|
|
687
|
-
if (9 === openingCode) return 29;
|
|
688
|
-
if (0 === openingCode) return 0;
|
|
689
|
-
};
|
|
690
|
-
const wrapAnsiCode = (code)=>`${ESC}${ANSI_CSI}${code}${ANSI_SGR_TERMINATOR}`;
|
|
691
|
-
const wrapAnsiHyperlink = (url)=>`${ESC}${ANSI_ESCAPE_LINK}${url}${ANSI_ESCAPE_BELL}`;
|
|
692
|
-
const wrapWord = (rows, word, columns)=>{
|
|
693
|
-
const characters = word[Symbol.iterator]();
|
|
694
|
-
let isInsideEscape = false;
|
|
695
|
-
let isInsideLinkEscape = false;
|
|
696
|
-
let lastRow = rows.at(-1);
|
|
697
|
-
let visible = void 0 === lastRow ? 0 : fast_string_width_dist(lastRow);
|
|
698
|
-
let currentCharacter = characters.next();
|
|
699
|
-
let nextCharacter = characters.next();
|
|
700
|
-
let rawCharacterIndex = 0;
|
|
701
|
-
while(!currentCharacter.done){
|
|
702
|
-
const character = currentCharacter.value;
|
|
703
|
-
const characterLength = fast_string_width_dist(character);
|
|
704
|
-
if (visible + characterLength <= columns) rows[rows.length - 1] += character;
|
|
705
|
-
else {
|
|
706
|
-
rows.push(character);
|
|
707
|
-
visible = 0;
|
|
708
|
-
}
|
|
709
|
-
if (character === ESC || character === CSI) {
|
|
710
|
-
isInsideEscape = true;
|
|
711
|
-
isInsideLinkEscape = word.startsWith(ANSI_ESCAPE_LINK, rawCharacterIndex + 1);
|
|
712
|
-
}
|
|
713
|
-
if (isInsideEscape) {
|
|
714
|
-
if (isInsideLinkEscape) {
|
|
715
|
-
if (character === ANSI_ESCAPE_BELL) {
|
|
716
|
-
isInsideEscape = false;
|
|
717
|
-
isInsideLinkEscape = false;
|
|
718
|
-
}
|
|
719
|
-
} else if (character === ANSI_SGR_TERMINATOR) isInsideEscape = false;
|
|
720
|
-
} else {
|
|
721
|
-
visible += characterLength;
|
|
722
|
-
if (visible === columns && !nextCharacter.done) {
|
|
723
|
-
rows.push('');
|
|
724
|
-
visible = 0;
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
currentCharacter = nextCharacter;
|
|
728
|
-
nextCharacter = characters.next();
|
|
729
|
-
rawCharacterIndex += character.length;
|
|
730
|
-
}
|
|
731
|
-
lastRow = rows.at(-1);
|
|
732
|
-
if (!visible && void 0 !== lastRow && lastRow.length && rows.length > 1) rows[rows.length - 2] += rows.pop();
|
|
733
|
-
};
|
|
734
|
-
const stringVisibleTrimSpacesRight = (string)=>{
|
|
735
|
-
const words = string.split(' ');
|
|
736
|
-
let last = words.length;
|
|
737
|
-
while(last){
|
|
738
|
-
if (fast_string_width_dist(words[last - 1])) break;
|
|
739
|
-
last--;
|
|
740
|
-
}
|
|
741
|
-
if (last === words.length) return string;
|
|
742
|
-
return words.slice(0, last).join(' ') + words.slice(last).join('');
|
|
743
|
-
};
|
|
744
|
-
const exec = (string, columns, options = {})=>{
|
|
745
|
-
if (false !== options.trim && '' === string.trim()) return '';
|
|
746
|
-
let returnValue = '';
|
|
747
|
-
let escapeCode;
|
|
748
|
-
let escapeUrl;
|
|
749
|
-
const words = string.split(' ');
|
|
750
|
-
let rows = [
|
|
751
|
-
''
|
|
752
|
-
];
|
|
753
|
-
let rowLength = 0;
|
|
754
|
-
for(let index = 0; index < words.length; index++){
|
|
755
|
-
const word = words[index];
|
|
756
|
-
if (false !== options.trim) {
|
|
757
|
-
const row = rows.at(-1) ?? '';
|
|
758
|
-
const trimmed = row.trimStart();
|
|
759
|
-
if (row.length !== trimmed.length) {
|
|
760
|
-
rows[rows.length - 1] = trimmed;
|
|
761
|
-
rowLength = fast_string_width_dist(trimmed);
|
|
762
|
-
}
|
|
763
|
-
}
|
|
764
|
-
if (0 !== index) {
|
|
765
|
-
if (rowLength >= columns && (false === options.wordWrap || false === options.trim)) {
|
|
766
|
-
rows.push('');
|
|
767
|
-
rowLength = 0;
|
|
768
|
-
}
|
|
769
|
-
if (rowLength || false === options.trim) {
|
|
770
|
-
rows[rows.length - 1] += ' ';
|
|
771
|
-
rowLength++;
|
|
772
|
-
}
|
|
773
|
-
}
|
|
774
|
-
const wordLength = fast_string_width_dist(word);
|
|
775
|
-
if (options.hard && wordLength > columns) {
|
|
776
|
-
const remainingColumns = columns - rowLength;
|
|
777
|
-
const breaksStartingThisLine = 1 + Math.floor((wordLength - remainingColumns - 1) / columns);
|
|
778
|
-
const breaksStartingNextLine = Math.floor((wordLength - 1) / columns);
|
|
779
|
-
if (breaksStartingNextLine < breaksStartingThisLine) rows.push('');
|
|
780
|
-
wrapWord(rows, word, columns);
|
|
781
|
-
rowLength = fast_string_width_dist(rows.at(-1) ?? '');
|
|
782
|
-
continue;
|
|
783
|
-
}
|
|
784
|
-
if (rowLength + wordLength > columns && rowLength && wordLength) {
|
|
785
|
-
if (false === options.wordWrap && rowLength < columns) {
|
|
786
|
-
wrapWord(rows, word, columns);
|
|
787
|
-
rowLength = fast_string_width_dist(rows.at(-1) ?? '');
|
|
788
|
-
continue;
|
|
35
|
+
{
|
|
36
|
+
value: 'doc',
|
|
37
|
+
label: 'Documentation'
|
|
789
38
|
}
|
|
790
|
-
rows.push('');
|
|
791
|
-
rowLength = 0;
|
|
792
|
-
}
|
|
793
|
-
if (rowLength + wordLength > columns && false === options.wordWrap) {
|
|
794
|
-
wrapWord(rows, word, columns);
|
|
795
|
-
rowLength = fast_string_width_dist(rows.at(-1) ?? '');
|
|
796
|
-
continue;
|
|
797
|
-
}
|
|
798
|
-
rows[rows.length - 1] += word;
|
|
799
|
-
rowLength += wordLength;
|
|
800
|
-
}
|
|
801
|
-
if (false !== options.trim) rows = rows.map((row)=>stringVisibleTrimSpacesRight(row));
|
|
802
|
-
const preString = rows.join('\n');
|
|
803
|
-
let inSurrogate = false;
|
|
804
|
-
for(let i = 0; i < preString.length; i++){
|
|
805
|
-
const character = preString[i];
|
|
806
|
-
returnValue += character;
|
|
807
|
-
if (inSurrogate) inSurrogate = false;
|
|
808
|
-
else {
|
|
809
|
-
inSurrogate = character >= '\ud800' && character <= '\udbff';
|
|
810
|
-
if (inSurrogate) continue;
|
|
811
|
-
}
|
|
812
|
-
if (character === ESC || character === CSI) {
|
|
813
|
-
GROUP_REGEX.lastIndex = i + 1;
|
|
814
|
-
const groupsResult = GROUP_REGEX.exec(preString);
|
|
815
|
-
const groups = groupsResult?.groups;
|
|
816
|
-
if (groups?.code !== void 0) {
|
|
817
|
-
const code = Number.parseFloat(groups.code);
|
|
818
|
-
escapeCode = code === END_CODE ? void 0 : code;
|
|
819
|
-
} else if (groups?.uri !== void 0) escapeUrl = 0 === groups.uri.length ? void 0 : groups.uri;
|
|
820
|
-
}
|
|
821
|
-
if ('\n' === preString[i + 1]) {
|
|
822
|
-
if (escapeUrl) returnValue += wrapAnsiHyperlink('');
|
|
823
|
-
const closingCode = escapeCode ? getClosingCode(escapeCode) : void 0;
|
|
824
|
-
if (escapeCode && closingCode) returnValue += wrapAnsiCode(closingCode);
|
|
825
|
-
} else if ('\n' === character) {
|
|
826
|
-
if (escapeCode && getClosingCode(escapeCode)) returnValue += wrapAnsiCode(escapeCode);
|
|
827
|
-
if (escapeUrl) returnValue += wrapAnsiHyperlink(escapeUrl);
|
|
828
|
-
}
|
|
829
|
-
}
|
|
830
|
-
return returnValue;
|
|
831
|
-
};
|
|
832
|
-
const CRLF_OR_LF = /\r?\n/;
|
|
833
|
-
function wrapAnsi(string, columns, options) {
|
|
834
|
-
return String(string).normalize().split(CRLF_OR_LF).map((line)=>exec(line, columns, options)).join('\n');
|
|
835
|
-
}
|
|
836
|
-
const src = __webpack_require__("./node_modules/.pnpm/sisteransi@1.0.5/node_modules/sisteransi/src/index.js");
|
|
837
|
-
function dist_d(r, t, s) {
|
|
838
|
-
if (!s.some((o)=>!o.disabled)) return r;
|
|
839
|
-
const e = r + t, i = Math.max(s.length - 1, 0), n = e < 0 ? i : e > i ? 0 : e;
|
|
840
|
-
return s[n].disabled ? dist_d(n, t < 0 ? -1 : 1, s) : n;
|
|
841
|
-
}
|
|
842
|
-
const dist_G = [
|
|
843
|
-
"up",
|
|
844
|
-
"down",
|
|
845
|
-
"left",
|
|
846
|
-
"right",
|
|
847
|
-
"space",
|
|
848
|
-
"enter",
|
|
849
|
-
"cancel"
|
|
850
|
-
], K = [
|
|
851
|
-
"January",
|
|
852
|
-
"February",
|
|
853
|
-
"March",
|
|
854
|
-
"April",
|
|
855
|
-
"May",
|
|
856
|
-
"June",
|
|
857
|
-
"July",
|
|
858
|
-
"August",
|
|
859
|
-
"September",
|
|
860
|
-
"October",
|
|
861
|
-
"November",
|
|
862
|
-
"December"
|
|
863
|
-
], dist_h = {
|
|
864
|
-
actions: new Set(dist_G),
|
|
865
|
-
aliases: new Map([
|
|
866
|
-
[
|
|
867
|
-
"k",
|
|
868
|
-
"up"
|
|
869
|
-
],
|
|
870
|
-
[
|
|
871
|
-
"j",
|
|
872
|
-
"down"
|
|
873
|
-
],
|
|
874
|
-
[
|
|
875
|
-
"h",
|
|
876
|
-
"left"
|
|
877
|
-
],
|
|
878
|
-
[
|
|
879
|
-
"l",
|
|
880
|
-
"right"
|
|
881
|
-
],
|
|
882
|
-
[
|
|
883
|
-
"",
|
|
884
|
-
"cancel"
|
|
885
|
-
],
|
|
886
|
-
[
|
|
887
|
-
"escape",
|
|
888
|
-
"cancel"
|
|
889
39
|
]
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
date: {
|
|
897
|
-
monthNames: [
|
|
898
|
-
...K
|
|
899
|
-
],
|
|
900
|
-
messages: {
|
|
901
|
-
required: "Please enter a valid date",
|
|
902
|
-
invalidMonth: "There are only 12 months in a year",
|
|
903
|
-
invalidDay: (r, t)=>`There are only ${r} days in ${t}`,
|
|
904
|
-
afterMin: (r)=>`Date must be on or after ${r.toISOString().slice(0, 10)}`,
|
|
905
|
-
beforeMax: (r)=>`Date must be on or before ${r.toISOString().slice(0, 10)}`
|
|
906
|
-
}
|
|
907
|
-
}
|
|
908
|
-
};
|
|
909
|
-
function dist_C(r, t) {
|
|
910
|
-
if ("string" == typeof r) return dist_h.aliases.get(r) === t;
|
|
911
|
-
for (const s of r)if (void 0 !== s && dist_C(s, t)) return !0;
|
|
912
|
-
return !1;
|
|
913
|
-
}
|
|
914
|
-
function z(r, t) {
|
|
915
|
-
if (r === t) return;
|
|
916
|
-
const s = r.split(`
|
|
917
|
-
`), e = t.split(`
|
|
918
|
-
`), i = Math.max(s.length, e.length), n = [];
|
|
919
|
-
for(let o = 0; o < i; o++)s[o] !== e[o] && n.push(o);
|
|
920
|
-
return {
|
|
921
|
-
lines: n,
|
|
922
|
-
numLinesBefore: s.length,
|
|
923
|
-
numLinesAfter: e.length,
|
|
924
|
-
numLines: i
|
|
925
|
-
};
|
|
926
|
-
}
|
|
927
|
-
globalThis.process.platform.startsWith("win");
|
|
928
|
-
const dist_k = Symbol("clack:cancel");
|
|
929
|
-
function dist_q(r) {
|
|
930
|
-
return r === dist_k;
|
|
931
|
-
}
|
|
932
|
-
function w(r, t) {
|
|
933
|
-
const s = r;
|
|
934
|
-
s.isTTY && s.setRawMode(t);
|
|
935
|
-
}
|
|
936
|
-
const dist_A = (r)=>"columns" in r && "number" == typeof r.columns ? r.columns : 80, dist_L = (r)=>"rows" in r && "number" == typeof r.rows ? r.rows : 20;
|
|
937
|
-
function dist_W(r, t, s, e = s, i) {
|
|
938
|
-
const n = dist_A(r ?? stdout);
|
|
939
|
-
return wrapAnsi(t, n - s.length, {
|
|
940
|
-
hard: !0,
|
|
941
|
-
trim: !1
|
|
942
|
-
}).split(`
|
|
943
|
-
`).map((o, u)=>{
|
|
944
|
-
const a = i ? i(o, u) : o;
|
|
945
|
-
return `${0 === u ? e : s}${a}`;
|
|
946
|
-
}).join(`
|
|
947
|
-
`);
|
|
948
|
-
}
|
|
949
|
-
let dist_p = class {
|
|
950
|
-
input;
|
|
951
|
-
output;
|
|
952
|
-
_abortSignal;
|
|
953
|
-
rl;
|
|
954
|
-
opts;
|
|
955
|
-
_render;
|
|
956
|
-
_track = !1;
|
|
957
|
-
_prevFrame = "";
|
|
958
|
-
_subscribers = new Map;
|
|
959
|
-
_cursor = 0;
|
|
960
|
-
state = "initial";
|
|
961
|
-
error = "";
|
|
962
|
-
value;
|
|
963
|
-
userInput = "";
|
|
964
|
-
constructor(t, s = !0){
|
|
965
|
-
const { input: e = stdin, output: i = stdout, render: n, signal: o, ...u } = t;
|
|
966
|
-
this.opts = u, this.onKeypress = this.onKeypress.bind(this), this.close = this.close.bind(this), this.render = this.render.bind(this), this._render = n.bind(this), this._track = s, this._abortSignal = o, this.input = e, this.output = i;
|
|
967
|
-
}
|
|
968
|
-
unsubscribe() {
|
|
969
|
-
this._subscribers.clear();
|
|
970
|
-
}
|
|
971
|
-
setSubscriber(t, s) {
|
|
972
|
-
const e = this._subscribers.get(t) ?? [];
|
|
973
|
-
e.push(s), this._subscribers.set(t, e);
|
|
974
|
-
}
|
|
975
|
-
on(t, s) {
|
|
976
|
-
this.setSubscriber(t, {
|
|
977
|
-
cb: s
|
|
978
|
-
});
|
|
979
|
-
}
|
|
980
|
-
once(t, s) {
|
|
981
|
-
this.setSubscriber(t, {
|
|
982
|
-
cb: s,
|
|
983
|
-
once: !0
|
|
984
|
-
});
|
|
985
|
-
}
|
|
986
|
-
emit(t, ...s) {
|
|
987
|
-
const e = this._subscribers.get(t) ?? [], i = [];
|
|
988
|
-
for (const n of e)n.cb(...s), n.once && i.push(()=>e.splice(e.indexOf(n), 1));
|
|
989
|
-
for (const n of i)n();
|
|
990
|
-
}
|
|
991
|
-
prompt() {
|
|
992
|
-
return new Promise((t)=>{
|
|
993
|
-
if (this._abortSignal) {
|
|
994
|
-
if (this._abortSignal.aborted) return this.state = "cancel", this.close(), t(dist_k);
|
|
995
|
-
this._abortSignal.addEventListener("abort", ()=>{
|
|
996
|
-
this.state = "cancel", this.close();
|
|
997
|
-
}, {
|
|
998
|
-
once: !0
|
|
999
|
-
});
|
|
1000
|
-
}
|
|
1001
|
-
this.rl = node_readline.createInterface({
|
|
1002
|
-
input: this.input,
|
|
1003
|
-
tabSize: 2,
|
|
1004
|
-
prompt: "",
|
|
1005
|
-
escapeCodeTimeout: 50,
|
|
1006
|
-
terminal: !0
|
|
1007
|
-
}), this.rl.prompt(), void 0 !== this.opts.initialUserInput && this._setUserInput(this.opts.initialUserInput, !0), this.input.on("keypress", this.onKeypress), w(this.input, !0), this.output.on("resize", this.render), this.render(), this.once("submit", ()=>{
|
|
1008
|
-
this.output.write(src.cursor.show), this.output.off("resize", this.render), w(this.input, !1), t(this.value);
|
|
1009
|
-
}), this.once("cancel", ()=>{
|
|
1010
|
-
this.output.write(src.cursor.show), this.output.off("resize", this.render), w(this.input, !1), t(dist_k);
|
|
1011
|
-
});
|
|
1012
|
-
});
|
|
1013
|
-
}
|
|
1014
|
-
_isActionKey(t, s) {
|
|
1015
|
-
return " " === t;
|
|
1016
|
-
}
|
|
1017
|
-
_shouldSubmit(t, s) {
|
|
1018
|
-
return !0;
|
|
1019
|
-
}
|
|
1020
|
-
_setValue(t) {
|
|
1021
|
-
this.value = t, this.emit("value", this.value);
|
|
1022
|
-
}
|
|
1023
|
-
_setUserInput(t, s) {
|
|
1024
|
-
this.userInput = t ?? "", this.emit("userInput", this.userInput), s && this._track && this.rl && (this.rl.write(this.userInput), this._cursor = this.rl.cursor);
|
|
1025
|
-
}
|
|
1026
|
-
_clearUserInput() {
|
|
1027
|
-
this.rl?.write(null, {
|
|
1028
|
-
ctrl: !0,
|
|
1029
|
-
name: "u"
|
|
1030
|
-
}), this._setUserInput("");
|
|
1031
|
-
}
|
|
1032
|
-
onKeypress(t, s) {
|
|
1033
|
-
if (this._track && "return" !== s.name && (s.name && this._isActionKey(t, s) && this.rl?.write(null, {
|
|
1034
|
-
ctrl: !0,
|
|
1035
|
-
name: "h"
|
|
1036
|
-
}), this._cursor = this.rl?.cursor ?? 0, this._setUserInput(this.rl?.line)), "error" === this.state && (this.state = "active"), s?.name && (!this._track && dist_h.aliases.has(s.name) && this.emit("cursor", dist_h.aliases.get(s.name)), dist_h.actions.has(s.name) && this.emit("cursor", s.name)), t && ("y" === t.toLowerCase() || "n" === t.toLowerCase()) && this.emit("confirm", "y" === t.toLowerCase()), this.emit("key", t?.toLowerCase(), s), s?.name === "return" && this._shouldSubmit(t, s)) {
|
|
1037
|
-
if (this.opts.validate) {
|
|
1038
|
-
const e = this.opts.validate(this.value);
|
|
1039
|
-
e && (this.error = e instanceof Error ? e.message : e, this.state = "error", this.rl?.write(this.userInput));
|
|
1040
|
-
}
|
|
1041
|
-
"error" !== this.state && (this.state = "submit");
|
|
1042
|
-
}
|
|
1043
|
-
dist_C([
|
|
1044
|
-
t,
|
|
1045
|
-
s?.name,
|
|
1046
|
-
s?.sequence
|
|
1047
|
-
], "cancel") && (this.state = "cancel"), ("submit" === this.state || "cancel" === this.state) && this.emit("finalize"), this.render(), ("submit" === this.state || "cancel" === this.state) && this.close();
|
|
1048
|
-
}
|
|
1049
|
-
close() {
|
|
1050
|
-
this.input.unpipe(), this.input.removeListener("keypress", this.onKeypress), this.output.write(`
|
|
1051
|
-
`), w(this.input, !1), this.rl?.close(), this.rl = void 0, this.emit(`${this.state}`, this.value), this.unsubscribe();
|
|
1052
|
-
}
|
|
1053
|
-
restoreCursor() {
|
|
1054
|
-
const t = wrapAnsi(this._prevFrame, process.stdout.columns, {
|
|
1055
|
-
hard: !0,
|
|
1056
|
-
trim: !1
|
|
1057
|
-
}).split(`
|
|
1058
|
-
`).length - 1;
|
|
1059
|
-
this.output.write(src.cursor.move(-999, -1 * t));
|
|
1060
|
-
}
|
|
1061
|
-
render() {
|
|
1062
|
-
const t = wrapAnsi(this._render(this) ?? "", process.stdout.columns, {
|
|
1063
|
-
hard: !0,
|
|
1064
|
-
trim: !1
|
|
1065
|
-
});
|
|
1066
|
-
if (t !== this._prevFrame) {
|
|
1067
|
-
if ("initial" === this.state) this.output.write(src.cursor.hide);
|
|
1068
|
-
else {
|
|
1069
|
-
const s = z(this._prevFrame, t), e = dist_L(this.output);
|
|
1070
|
-
if (this.restoreCursor(), s) {
|
|
1071
|
-
const i = Math.max(0, s.numLinesAfter - e), n = Math.max(0, s.numLinesBefore - e);
|
|
1072
|
-
let o = s.lines.find((u)=>u >= i);
|
|
1073
|
-
if (void 0 === o) {
|
|
1074
|
-
this._prevFrame = t;
|
|
1075
|
-
return;
|
|
1076
|
-
}
|
|
1077
|
-
if (1 === s.lines.length) {
|
|
1078
|
-
this.output.write(src.cursor.move(0, o - n)), this.output.write(src.erase.lines(1));
|
|
1079
|
-
const u = t.split(`
|
|
1080
|
-
`);
|
|
1081
|
-
this.output.write(u[o]), this._prevFrame = t, this.output.write(src.cursor.move(0, u.length - o - 1));
|
|
1082
|
-
return;
|
|
1083
|
-
}
|
|
1084
|
-
if (s.lines.length > 1) {
|
|
1085
|
-
if (i < n) o = i;
|
|
1086
|
-
else {
|
|
1087
|
-
const a = o - n;
|
|
1088
|
-
a > 0 && this.output.write(src.cursor.move(0, a));
|
|
1089
|
-
}
|
|
1090
|
-
this.output.write(src.erase.down());
|
|
1091
|
-
const u = t.split(`
|
|
1092
|
-
`).slice(o);
|
|
1093
|
-
this.output.write(u.join(`
|
|
1094
|
-
`)), this._prevFrame = t;
|
|
1095
|
-
return;
|
|
1096
|
-
}
|
|
1097
|
-
}
|
|
1098
|
-
this.output.write(src.erase.down());
|
|
1099
|
-
}
|
|
1100
|
-
this.output.write(t), "initial" === this.state && (this.state = "active"), this._prevFrame = t;
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
};
|
|
1104
|
-
function dist_B(r, t) {
|
|
1105
|
-
if (void 0 === r || 0 === t.length) return 0;
|
|
1106
|
-
const s = t.findIndex((e)=>e.value === r);
|
|
1107
|
-
return -1 !== s ? s : 0;
|
|
1108
|
-
}
|
|
1109
|
-
function J(r, t) {
|
|
1110
|
-
return (t.label ?? String(t.value)).toLowerCase().includes(r.toLowerCase());
|
|
1111
|
-
}
|
|
1112
|
-
function H(r, t) {
|
|
1113
|
-
if (t) return r ? t : t[0];
|
|
1114
|
-
}
|
|
1115
|
-
let Q = class extends dist_p {
|
|
1116
|
-
filteredOptions;
|
|
1117
|
-
multiple;
|
|
1118
|
-
isNavigating = !1;
|
|
1119
|
-
selectedValues = [];
|
|
1120
|
-
focusedValue;
|
|
1121
|
-
#s = 0;
|
|
1122
|
-
#r = "";
|
|
1123
|
-
#t;
|
|
1124
|
-
#n;
|
|
1125
|
-
#u;
|
|
1126
|
-
get cursor() {
|
|
1127
|
-
return this.#s;
|
|
1128
|
-
}
|
|
1129
|
-
get userInputWithCursor() {
|
|
1130
|
-
if (!this.userInput) return styleText([
|
|
1131
|
-
"inverse",
|
|
1132
|
-
"hidden"
|
|
1133
|
-
], "_");
|
|
1134
|
-
if (this._cursor >= this.userInput.length) return `${this.userInput}\u2588`;
|
|
1135
|
-
const t = this.userInput.slice(0, this._cursor), [s, ...e] = this.userInput.slice(this._cursor);
|
|
1136
|
-
return `${t}${styleText("inverse", s)}${e.join("")}`;
|
|
1137
|
-
}
|
|
1138
|
-
get options() {
|
|
1139
|
-
return "function" == typeof this.#n ? this.#n() : this.#n;
|
|
1140
|
-
}
|
|
1141
|
-
constructor(t){
|
|
1142
|
-
super(t), this.#n = t.options, this.#u = t.placeholder;
|
|
1143
|
-
const s = this.options;
|
|
1144
|
-
this.filteredOptions = [
|
|
1145
|
-
...s
|
|
1146
|
-
], this.multiple = !0 === t.multiple, this.#t = "function" == typeof t.options ? t.filter : t.filter ?? J;
|
|
1147
|
-
let e;
|
|
1148
|
-
if (t.initialValue && Array.isArray(t.initialValue) ? this.multiple ? e = t.initialValue : e = t.initialValue.slice(0, 1) : !this.multiple && this.options.length > 0 && (e = [
|
|
1149
|
-
this.options[0].value
|
|
1150
|
-
]), e) for (const i of e){
|
|
1151
|
-
const n = s.findIndex((o)=>o.value === i);
|
|
1152
|
-
-1 !== n && (this.toggleSelected(i), this.#s = n);
|
|
1153
|
-
}
|
|
1154
|
-
this.focusedValue = this.options[this.#s]?.value, this.on("key", (i, n)=>this.#e(i, n)), this.on("userInput", (i)=>this.#i(i));
|
|
1155
|
-
}
|
|
1156
|
-
_isActionKey(t, s) {
|
|
1157
|
-
return " " === t || this.multiple && this.isNavigating && "space" === s.name && void 0 !== t && "" !== t;
|
|
1158
|
-
}
|
|
1159
|
-
#e(t, s) {
|
|
1160
|
-
const e = "up" === s.name, i = "down" === s.name, n = "return" === s.name, o = "" === this.userInput || " " === this.userInput, u = this.#u, a = this.options, l = void 0 !== u && "" !== u && a.some((f)=>!f.disabled && (this.#t ? this.#t(u, f) : !0));
|
|
1161
|
-
if ("tab" === s.name && o && l) {
|
|
1162
|
-
" " === this.userInput && this._clearUserInput(), this._setUserInput(u, !0), this.isNavigating = !1;
|
|
1163
|
-
return;
|
|
1164
|
-
}
|
|
1165
|
-
e || i ? (this.#s = dist_d(this.#s, e ? -1 : 1, this.filteredOptions), this.focusedValue = this.filteredOptions[this.#s]?.value, this.multiple || (this.selectedValues = [
|
|
1166
|
-
this.focusedValue
|
|
1167
|
-
]), this.isNavigating = !0) : n ? this.value = H(this.multiple, this.selectedValues) : this.multiple ? void 0 !== this.focusedValue && ("tab" === s.name || this.isNavigating && "space" === s.name) ? this.toggleSelected(this.focusedValue) : this.isNavigating = !1 : (this.focusedValue && (this.selectedValues = [
|
|
1168
|
-
this.focusedValue
|
|
1169
|
-
]), this.isNavigating = !1);
|
|
1170
|
-
}
|
|
1171
|
-
deselectAll() {
|
|
1172
|
-
this.selectedValues = [];
|
|
1173
|
-
}
|
|
1174
|
-
toggleSelected(t) {
|
|
1175
|
-
0 !== this.filteredOptions.length && (this.multiple ? this.selectedValues.includes(t) ? this.selectedValues = this.selectedValues.filter((s)=>s !== t) : this.selectedValues = [
|
|
1176
|
-
...this.selectedValues,
|
|
1177
|
-
t
|
|
1178
|
-
] : this.selectedValues = [
|
|
1179
|
-
t
|
|
1180
|
-
]);
|
|
1181
|
-
}
|
|
1182
|
-
#i(t) {
|
|
1183
|
-
if (t !== this.#r) {
|
|
1184
|
-
this.#r = t;
|
|
1185
|
-
const s = this.options;
|
|
1186
|
-
t && this.#t ? this.filteredOptions = s.filter((n)=>this.#t?.(t, n)) : this.filteredOptions = [
|
|
1187
|
-
...s
|
|
1188
|
-
];
|
|
1189
|
-
const e = dist_B(this.focusedValue, this.filteredOptions);
|
|
1190
|
-
this.#s = dist_d(e, 0, this.filteredOptions);
|
|
1191
|
-
const i = this.filteredOptions[this.#s];
|
|
1192
|
-
i && !i.disabled ? this.focusedValue = i.value : this.focusedValue = void 0, this.multiple || (void 0 !== this.focusedValue ? this.toggleSelected(this.focusedValue) : this.deselectAll());
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
};
|
|
1196
|
-
class it extends dist_p {
|
|
1197
|
-
options;
|
|
1198
|
-
cursor = 0;
|
|
1199
|
-
#s;
|
|
1200
|
-
getGroupItems(t) {
|
|
1201
|
-
return this.options.filter((s)=>s.group === t);
|
|
1202
|
-
}
|
|
1203
|
-
isGroupSelected(t) {
|
|
1204
|
-
const s = this.getGroupItems(t), e = this.value;
|
|
1205
|
-
return void 0 === e ? !1 : s.every((i)=>e.includes(i.value));
|
|
1206
|
-
}
|
|
1207
|
-
toggleValue() {
|
|
1208
|
-
const t = this.options[this.cursor];
|
|
1209
|
-
if (void 0 === this.value && (this.value = []), !0 === t.group) {
|
|
1210
|
-
const s = t.value, e = this.getGroupItems(s);
|
|
1211
|
-
this.isGroupSelected(s) ? this.value = this.value.filter((i)=>-1 === e.findIndex((n)=>n.value === i)) : this.value = [
|
|
1212
|
-
...this.value,
|
|
1213
|
-
...e.map((i)=>i.value)
|
|
1214
|
-
], this.value = Array.from(new Set(this.value));
|
|
1215
|
-
} else {
|
|
1216
|
-
const s = this.value.includes(t.value);
|
|
1217
|
-
this.value = s ? this.value.filter((e)=>e !== t.value) : [
|
|
1218
|
-
...this.value,
|
|
1219
|
-
t.value
|
|
1220
|
-
];
|
|
1221
|
-
}
|
|
1222
|
-
}
|
|
1223
|
-
constructor(t){
|
|
1224
|
-
super(t, !1);
|
|
1225
|
-
const { options: s } = t;
|
|
1226
|
-
this.#s = !1 !== t.selectableGroups, this.options = Object.entries(s).flatMap(([e, i])=>[
|
|
40
|
+
}));
|
|
41
|
+
if ('doc' === projectType) {
|
|
42
|
+
const documentationType = checkCancel(await create_toolkit_select({
|
|
43
|
+
message: 'Choose documentation language setup',
|
|
44
|
+
initialValue: 'basic',
|
|
45
|
+
options: [
|
|
1227
46
|
{
|
|
1228
|
-
value:
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
},
|
|
1232
|
-
...i.map((n)=>({
|
|
1233
|
-
...n,
|
|
1234
|
-
group: e
|
|
1235
|
-
}))
|
|
1236
|
-
]), this.value = [
|
|
1237
|
-
...t.initialValues ?? []
|
|
1238
|
-
], this.cursor = Math.max(this.options.findIndex(({ value: e })=>e === t.cursorAt), this.#s ? 0 : 1), this.on("cursor", (e)=>{
|
|
1239
|
-
switch(e){
|
|
1240
|
-
case "left":
|
|
1241
|
-
case "up":
|
|
1242
|
-
{
|
|
1243
|
-
this.cursor = 0 === this.cursor ? this.options.length - 1 : this.cursor - 1;
|
|
1244
|
-
const i = this.options[this.cursor]?.group === !0;
|
|
1245
|
-
!this.#s && i && (this.cursor = 0 === this.cursor ? this.options.length - 1 : this.cursor - 1);
|
|
1246
|
-
break;
|
|
1247
|
-
}
|
|
1248
|
-
case "down":
|
|
1249
|
-
case "right":
|
|
1250
|
-
{
|
|
1251
|
-
this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1;
|
|
1252
|
-
const i = this.options[this.cursor]?.group === !0;
|
|
1253
|
-
!this.#s && i && (this.cursor = this.cursor === this.options.length - 1 ? 0 : this.cursor + 1);
|
|
1254
|
-
break;
|
|
1255
|
-
}
|
|
1256
|
-
case "space":
|
|
1257
|
-
this.toggleValue();
|
|
1258
|
-
break;
|
|
1259
|
-
}
|
|
1260
|
-
});
|
|
1261
|
-
}
|
|
1262
|
-
}
|
|
1263
|
-
let dist_nt = class extends dist_p {
|
|
1264
|
-
options;
|
|
1265
|
-
cursor = 0;
|
|
1266
|
-
get _value() {
|
|
1267
|
-
return this.options[this.cursor].value;
|
|
1268
|
-
}
|
|
1269
|
-
get _enabledOptions() {
|
|
1270
|
-
return this.options.filter((t)=>!0 !== t.disabled);
|
|
1271
|
-
}
|
|
1272
|
-
toggleAll() {
|
|
1273
|
-
const t = this._enabledOptions, s = void 0 !== this.value && this.value.length === t.length;
|
|
1274
|
-
this.value = s ? [] : t.map((e)=>e.value);
|
|
1275
|
-
}
|
|
1276
|
-
toggleInvert() {
|
|
1277
|
-
const t = this.value;
|
|
1278
|
-
if (!t) return;
|
|
1279
|
-
const s = this._enabledOptions.filter((e)=>!t.includes(e.value));
|
|
1280
|
-
this.value = s.map((e)=>e.value);
|
|
1281
|
-
}
|
|
1282
|
-
toggleValue() {
|
|
1283
|
-
void 0 === this.value && (this.value = []);
|
|
1284
|
-
const t = this.value.includes(this._value);
|
|
1285
|
-
this.value = t ? this.value.filter((s)=>s !== this._value) : [
|
|
1286
|
-
...this.value,
|
|
1287
|
-
this._value
|
|
1288
|
-
];
|
|
1289
|
-
}
|
|
1290
|
-
constructor(t){
|
|
1291
|
-
super(t, !1), this.options = t.options, this.value = [
|
|
1292
|
-
...t.initialValues ?? []
|
|
1293
|
-
];
|
|
1294
|
-
const s = Math.max(this.options.findIndex(({ value: e })=>e === t.cursorAt), 0);
|
|
1295
|
-
this.cursor = this.options[s].disabled ? dist_d(s, 1, this.options) : s, this.on("key", (e)=>{
|
|
1296
|
-
"a" === e && this.toggleAll(), "i" === e && this.toggleInvert();
|
|
1297
|
-
}), this.on("cursor", (e)=>{
|
|
1298
|
-
switch(e){
|
|
1299
|
-
case "left":
|
|
1300
|
-
case "up":
|
|
1301
|
-
this.cursor = dist_d(this.cursor, -1, this.options);
|
|
1302
|
-
break;
|
|
1303
|
-
case "down":
|
|
1304
|
-
case "right":
|
|
1305
|
-
this.cursor = dist_d(this.cursor, 1, this.options);
|
|
1306
|
-
break;
|
|
1307
|
-
case "space":
|
|
1308
|
-
this.toggleValue();
|
|
1309
|
-
break;
|
|
1310
|
-
}
|
|
1311
|
-
});
|
|
1312
|
-
}
|
|
1313
|
-
};
|
|
1314
|
-
class ut extends dist_p {
|
|
1315
|
-
options;
|
|
1316
|
-
cursor = 0;
|
|
1317
|
-
get _selectedValue() {
|
|
1318
|
-
return this.options[this.cursor];
|
|
1319
|
-
}
|
|
1320
|
-
changeValue() {
|
|
1321
|
-
this.value = this._selectedValue.value;
|
|
1322
|
-
}
|
|
1323
|
-
constructor(t){
|
|
1324
|
-
super(t, !1), this.options = t.options;
|
|
1325
|
-
const s = this.options.findIndex(({ value: i })=>i === t.initialValue), e = -1 === s ? 0 : s;
|
|
1326
|
-
this.cursor = this.options[e].disabled ? dist_d(e, 1, this.options) : e, this.changeValue(), this.on("cursor", (i)=>{
|
|
1327
|
-
switch(i){
|
|
1328
|
-
case "left":
|
|
1329
|
-
case "up":
|
|
1330
|
-
this.cursor = dist_d(this.cursor, -1, this.options);
|
|
1331
|
-
break;
|
|
1332
|
-
case "down":
|
|
1333
|
-
case "right":
|
|
1334
|
-
this.cursor = dist_d(this.cursor, 1, this.options);
|
|
1335
|
-
break;
|
|
1336
|
-
}
|
|
1337
|
-
this.changeValue();
|
|
1338
|
-
});
|
|
1339
|
-
}
|
|
1340
|
-
}
|
|
1341
|
-
class ht extends dist_p {
|
|
1342
|
-
get userInputWithCursor() {
|
|
1343
|
-
if ("submit" === this.state) return this.userInput;
|
|
1344
|
-
const t = this.userInput;
|
|
1345
|
-
if (this.cursor >= t.length) return `${this.userInput}\u2588`;
|
|
1346
|
-
const s = t.slice(0, this.cursor), [e, ...i] = t.slice(this.cursor);
|
|
1347
|
-
return `${s}${styleText("inverse", e)}${i.join("")}`;
|
|
1348
|
-
}
|
|
1349
|
-
get cursor() {
|
|
1350
|
-
return this._cursor;
|
|
1351
|
-
}
|
|
1352
|
-
constructor(t){
|
|
1353
|
-
super({
|
|
1354
|
-
...t,
|
|
1355
|
-
initialUserInput: t.initialUserInput ?? t.initialValue
|
|
1356
|
-
}), this.on("userInput", (s)=>{
|
|
1357
|
-
this._setValue(s);
|
|
1358
|
-
}), this.on("finalize", ()=>{
|
|
1359
|
-
this.value || (this.value = t.defaultValue), void 0 === this.value && (this.value = "");
|
|
1360
|
-
});
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
function te() {
|
|
1364
|
-
return "win32" !== node_process.platform ? "linux" !== node_process.env.TERM : !!node_process.env.CI || !!node_process.env.WT_SESSION || !!node_process.env.TERMINUS_SUBLIME || "{cmd::Cmder}" === node_process.env.ConEmuTask || "Terminus-Sublime" === node_process.env.TERM_PROGRAM || "vscode" === node_process.env.TERM_PROGRAM || "xterm-256color" === node_process.env.TERM || "alacritty" === node_process.env.TERM || "JetBrains-JediTerm" === node_process.env.TERMINAL_EMULATOR;
|
|
1365
|
-
}
|
|
1366
|
-
const dist_tt = te(), dist_at = ()=>"true" === process.env.CI, Tt = (t)=>!0 === t.isTTY, dist_w = (t, r)=>dist_tt ? t : r, _t = dist_w("\u25C6", "*"), dist_ot = dist_w("\u25A0", "x"), dist_ut = dist_w("\u25B2", "x"), dist_F = dist_w("\u25C7", "o"), dist_$ = (dist_w("\u250C", "T"), dist_w("\u2502", "|")), E = dist_w("\u2514", "\u2014"), dist_z = (dist_w("\u2510", "T"), dist_w("\u2518", "\u2014"), dist_w("\u25CF", ">")), dist_H = dist_w("\u25CB", " "), dist_et = dist_w("\u25FB", "[\u2022]"), dist_U = dist_w("\u25FC", "[+]"), dist_J = dist_w("\u25FB", "[ ]"), dist_st = (dist_w("\u25AA", "\u2022"), dist_w("\u2500", "-")), ct = dist_w("\u256E", "+"), xt = dist_w("\u251C", "+"), $t = dist_w("\u256F", "+"), dt = dist_w("\u2570", "+"), dist_ht = (dist_w("\u256D", "+"), dist_w("\u25CF", "\u2022")), pt = dist_w("\u25C6", "*"), mt = dist_w("\u25B2", "!"), gt = dist_w("\u25A0", "x"), M = (t)=>{
|
|
1367
|
-
switch(t){
|
|
1368
|
-
case "initial":
|
|
1369
|
-
case "active":
|
|
1370
|
-
return styleText("cyan", _t);
|
|
1371
|
-
case "cancel":
|
|
1372
|
-
return styleText("red", dist_ot);
|
|
1373
|
-
case "error":
|
|
1374
|
-
return styleText("yellow", dist_ut);
|
|
1375
|
-
case "submit":
|
|
1376
|
-
return styleText("green", dist_F);
|
|
1377
|
-
}
|
|
1378
|
-
}, yt = (t)=>{
|
|
1379
|
-
switch(t){
|
|
1380
|
-
case "initial":
|
|
1381
|
-
case "active":
|
|
1382
|
-
return styleText("cyan", dist_$);
|
|
1383
|
-
case "cancel":
|
|
1384
|
-
return styleText("red", dist_$);
|
|
1385
|
-
case "error":
|
|
1386
|
-
return styleText("yellow", dist_$);
|
|
1387
|
-
case "submit":
|
|
1388
|
-
return styleText("green", dist_$);
|
|
1389
|
-
}
|
|
1390
|
-
}, ee = (t, r, s, i, u)=>{
|
|
1391
|
-
let n = r, o = 0;
|
|
1392
|
-
for(let c = s; c < i; c++){
|
|
1393
|
-
const a = t[c];
|
|
1394
|
-
if (n -= a.length, o++, n <= u) break;
|
|
1395
|
-
}
|
|
1396
|
-
return {
|
|
1397
|
-
lineCount: n,
|
|
1398
|
-
removals: o
|
|
1399
|
-
};
|
|
1400
|
-
}, dist_Y = ({ cursor: t, options: r, style: s, output: i = process.stdout, maxItems: u = 1 / 0, columnPadding: n = 0, rowPadding: o = 4 })=>{
|
|
1401
|
-
const c = dist_A(i) - n, a = dist_L(i), l = styleText("dim", "..."), d = Math.max(a - o, 0), y = Math.max(Math.min(u, d), 5);
|
|
1402
|
-
let p = 0;
|
|
1403
|
-
t >= y - 3 && (p = Math.max(Math.min(t - y + 3, r.length - y), 0));
|
|
1404
|
-
let m = y < r.length && p > 0, g = y < r.length && p + y < r.length;
|
|
1405
|
-
const S = Math.min(p + y, r.length), h = [];
|
|
1406
|
-
let f = 0;
|
|
1407
|
-
m && f++, g && f++;
|
|
1408
|
-
const v = p + (m ? 1 : 0), T = S - (g ? 1 : 0);
|
|
1409
|
-
for(let b = v; b < T; b++){
|
|
1410
|
-
const G = wrapAnsi(s(r[b], b === t), c, {
|
|
1411
|
-
hard: !0,
|
|
1412
|
-
trim: !1
|
|
1413
|
-
}).split(`
|
|
1414
|
-
`);
|
|
1415
|
-
h.push(G), f += G.length;
|
|
1416
|
-
}
|
|
1417
|
-
if (f > d) {
|
|
1418
|
-
let b = 0, G = 0, x = f;
|
|
1419
|
-
const A = t - v, P = (N, D)=>ee(h, x, N, D, d);
|
|
1420
|
-
m ? ({ lineCount: x, removals: b } = P(0, A), x > d && ({ lineCount: x, removals: G } = P(A + 1, h.length))) : ({ lineCount: x, removals: G } = P(A + 1, h.length), x > d && ({ lineCount: x, removals: b } = P(0, A))), b > 0 && (m = !0, h.splice(0, b)), G > 0 && (g = !0, h.splice(h.length - G, G));
|
|
1421
|
-
}
|
|
1422
|
-
const C = [];
|
|
1423
|
-
m && C.push(l);
|
|
1424
|
-
for (const b of h)for (const G of b)C.push(G);
|
|
1425
|
-
return g && C.push(l), C;
|
|
1426
|
-
};
|
|
1427
|
-
function Mt(t) {
|
|
1428
|
-
return t.label ?? String(t.value ?? "");
|
|
1429
|
-
}
|
|
1430
|
-
function Rt(t, r) {
|
|
1431
|
-
if (!t) return !0;
|
|
1432
|
-
const s = (r.label ?? String(r.value ?? "")).toLowerCase(), i = (r.hint ?? "").toLowerCase(), u = String(r.value).toLowerCase(), n = t.toLowerCase();
|
|
1433
|
-
return s.includes(n) || i.includes(n) || u.includes(n);
|
|
1434
|
-
}
|
|
1435
|
-
function se(t, r) {
|
|
1436
|
-
const s = [];
|
|
1437
|
-
for (const i of r)t.includes(i.value) && s.push(i);
|
|
1438
|
-
return s;
|
|
1439
|
-
}
|
|
1440
|
-
const At = (t)=>new Q({
|
|
1441
|
-
options: t.options,
|
|
1442
|
-
initialValue: t.initialValue ? [
|
|
1443
|
-
t.initialValue
|
|
1444
|
-
] : void 0,
|
|
1445
|
-
initialUserInput: t.initialUserInput,
|
|
1446
|
-
placeholder: t.placeholder,
|
|
1447
|
-
filter: t.filter ?? ((r, s)=>Rt(r, s)),
|
|
1448
|
-
signal: t.signal,
|
|
1449
|
-
input: t.input,
|
|
1450
|
-
output: t.output,
|
|
1451
|
-
validate: t.validate,
|
|
1452
|
-
render () {
|
|
1453
|
-
const r = t.withGuide ?? dist_h.withGuide, s = r ? [
|
|
1454
|
-
`${styleText("gray", dist_$)}`,
|
|
1455
|
-
`${M(this.state)} ${t.message}`
|
|
1456
|
-
] : [
|
|
1457
|
-
`${M(this.state)} ${t.message}`
|
|
1458
|
-
], i = this.userInput, u = this.options, n = t.placeholder, o = "" === i && void 0 !== n, c = (a, l)=>{
|
|
1459
|
-
const d = Mt(a), y = a.hint && a.value === this.focusedValue ? styleText("dim", ` (${a.hint})`) : "";
|
|
1460
|
-
switch(l){
|
|
1461
|
-
case "active":
|
|
1462
|
-
return `${styleText("green", dist_z)} ${d}${y}`;
|
|
1463
|
-
case "inactive":
|
|
1464
|
-
return `${styleText("dim", dist_H)} ${styleText("dim", d)}`;
|
|
1465
|
-
case "disabled":
|
|
1466
|
-
return `${styleText("gray", dist_H)} ${styleText([
|
|
1467
|
-
"strikethrough",
|
|
1468
|
-
"gray"
|
|
1469
|
-
], d)}`;
|
|
1470
|
-
}
|
|
1471
|
-
};
|
|
1472
|
-
switch(this.state){
|
|
1473
|
-
case "submit":
|
|
1474
|
-
{
|
|
1475
|
-
const a = se(this.selectedValues, u), l = a.length > 0 ? ` ${styleText("dim", a.map(Mt).join(", "))}` : "", d = r ? styleText("gray", dist_$) : "";
|
|
1476
|
-
return `${s.join(`
|
|
1477
|
-
`)}
|
|
1478
|
-
${d}${l}`;
|
|
1479
|
-
}
|
|
1480
|
-
case "cancel":
|
|
1481
|
-
{
|
|
1482
|
-
const a = i ? ` ${styleText([
|
|
1483
|
-
"strikethrough",
|
|
1484
|
-
"dim"
|
|
1485
|
-
], i)}` : "", l = r ? styleText("gray", dist_$) : "";
|
|
1486
|
-
return `${s.join(`
|
|
1487
|
-
`)}
|
|
1488
|
-
${l}${a}`;
|
|
1489
|
-
}
|
|
1490
|
-
default:
|
|
1491
|
-
{
|
|
1492
|
-
const a = "error" === this.state ? "yellow" : "cyan", l = r ? `${styleText(a, dist_$)} ` : "", d = r ? styleText(a, E) : "";
|
|
1493
|
-
let y = "";
|
|
1494
|
-
if (this.isNavigating || o) {
|
|
1495
|
-
const v = o ? n : i;
|
|
1496
|
-
y = "" !== v ? ` ${styleText("dim", v)}` : "";
|
|
1497
|
-
} else y = ` ${this.userInputWithCursor}`;
|
|
1498
|
-
const p = this.filteredOptions.length !== u.length ? styleText("dim", ` (${this.filteredOptions.length} match${1 === this.filteredOptions.length ? "" : "es"})`) : "", m = 0 === this.filteredOptions.length && i ? [
|
|
1499
|
-
`${l}${styleText("yellow", "No matches found")}`
|
|
1500
|
-
] : [], g = "error" === this.state ? [
|
|
1501
|
-
`${l}${styleText("yellow", this.error)}`
|
|
1502
|
-
] : [];
|
|
1503
|
-
r && s.push(`${l.trimEnd()}`), s.push(`${l}${styleText("dim", "Search:")}${y}${p}`, ...m, ...g);
|
|
1504
|
-
const S = [
|
|
1505
|
-
`${styleText("dim", "\u2191/\u2193")} to select`,
|
|
1506
|
-
`${styleText("dim", "Enter:")} confirm`,
|
|
1507
|
-
`${styleText("dim", "Type:")} to search`
|
|
1508
|
-
], h = [
|
|
1509
|
-
`${l}${S.join(" \u2022 ")}`,
|
|
1510
|
-
d
|
|
1511
|
-
], f = 0 === this.filteredOptions.length ? [] : dist_Y({
|
|
1512
|
-
cursor: this.cursor,
|
|
1513
|
-
options: this.filteredOptions,
|
|
1514
|
-
columnPadding: r ? 3 : 0,
|
|
1515
|
-
rowPadding: s.length + h.length,
|
|
1516
|
-
style: (v, T)=>c(v, v.disabled ? "disabled" : T ? "active" : "inactive"),
|
|
1517
|
-
maxItems: t.maxItems,
|
|
1518
|
-
output: t.output
|
|
1519
|
-
});
|
|
1520
|
-
return [
|
|
1521
|
-
...s,
|
|
1522
|
-
...f.map((v)=>`${l}${v}`),
|
|
1523
|
-
...h
|
|
1524
|
-
].join(`
|
|
1525
|
-
`);
|
|
1526
|
-
}
|
|
1527
|
-
}
|
|
1528
|
-
}
|
|
1529
|
-
}).prompt();
|
|
1530
|
-
const pe = (t)=>{
|
|
1531
|
-
const { selectableGroups: r = !0, groupSpacing: s = 0 } = t, i = (n, o, c = [])=>{
|
|
1532
|
-
const a = n.label ?? String(n.value), l = "string" == typeof n.group, d = l && (c[c.indexOf(n) + 1] ?? {
|
|
1533
|
-
group: !0
|
|
1534
|
-
}), y = l && d && !0 === d.group, p = l ? r ? `${y ? E : dist_$} ` : " " : "";
|
|
1535
|
-
let m = "";
|
|
1536
|
-
if (s > 0 && !l) {
|
|
1537
|
-
const S = `
|
|
1538
|
-
${styleText("cyan", dist_$)}`;
|
|
1539
|
-
m = `${S.repeat(s - 1)}${S} `;
|
|
1540
|
-
}
|
|
1541
|
-
if ("active" === o) return `${m}${styleText("dim", p)}${styleText("cyan", dist_et)} ${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
1542
|
-
if ("group-active" === o) return `${m}${p}${styleText("cyan", dist_et)} ${styleText("dim", a)}`;
|
|
1543
|
-
if ("group-active-selected" === o) return `${m}${p}${styleText("green", dist_U)} ${styleText("dim", a)}`;
|
|
1544
|
-
if ("selected" === o) {
|
|
1545
|
-
const S = l || r ? styleText("green", dist_U) : "";
|
|
1546
|
-
return `${m}${styleText("dim", p)}${S} ${styleText("dim", a)}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
1547
|
-
}
|
|
1548
|
-
if ("cancelled" === o) return `${styleText([
|
|
1549
|
-
"strikethrough",
|
|
1550
|
-
"dim"
|
|
1551
|
-
], a)}`;
|
|
1552
|
-
if ("active-selected" === o) return `${m}${styleText("dim", p)}${styleText("green", dist_U)} ${a}${n.hint ? ` ${styleText("dim", `(${n.hint})`)}` : ""}`;
|
|
1553
|
-
if ("submitted" === o) return `${styleText("dim", a)}`;
|
|
1554
|
-
const g = l || r ? styleText("dim", dist_J) : "";
|
|
1555
|
-
return `${m}${styleText("dim", p)}${g} ${styleText("dim", a)}`;
|
|
1556
|
-
}, u = t.required ?? !0;
|
|
1557
|
-
return new it({
|
|
1558
|
-
options: t.options,
|
|
1559
|
-
signal: t.signal,
|
|
1560
|
-
input: t.input,
|
|
1561
|
-
output: t.output,
|
|
1562
|
-
initialValues: t.initialValues,
|
|
1563
|
-
required: u,
|
|
1564
|
-
cursorAt: t.cursorAt,
|
|
1565
|
-
selectableGroups: r,
|
|
1566
|
-
validate (n) {
|
|
1567
|
-
if (u && (void 0 === n || 0 === n.length)) return `Please select at least one option.
|
|
1568
|
-
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
1569
|
-
"gray",
|
|
1570
|
-
"bgWhite",
|
|
1571
|
-
"inverse"
|
|
1572
|
-
], " space ")} to select, ${styleText("gray", styleText([
|
|
1573
|
-
"bgWhite",
|
|
1574
|
-
"inverse"
|
|
1575
|
-
], " enter "))} to submit`))}`;
|
|
1576
|
-
},
|
|
1577
|
-
render () {
|
|
1578
|
-
const n = t.withGuide ?? dist_h.withGuide, o = `${n ? `${styleText("gray", dist_$)}
|
|
1579
|
-
` : ""}${M(this.state)} ${t.message}
|
|
1580
|
-
`, c = this.value ?? [];
|
|
1581
|
-
switch(this.state){
|
|
1582
|
-
case "submit":
|
|
1583
|
-
{
|
|
1584
|
-
const a = this.options.filter(({ value: d })=>c.includes(d)).map((d)=>i(d, "submitted")), l = 0 === a.length ? "" : ` ${a.join(styleText("dim", ", "))}`;
|
|
1585
|
-
return `${o}${n ? styleText("gray", dist_$) : ""}${l}`;
|
|
1586
|
-
}
|
|
1587
|
-
case "cancel":
|
|
1588
|
-
{
|
|
1589
|
-
const a = this.options.filter(({ value: l })=>c.includes(l)).map((l)=>i(l, "cancelled")).join(styleText("dim", ", "));
|
|
1590
|
-
return `${o}${n ? `${styleText("gray", dist_$)} ` : ""}${a.trim() ? `${a}${n ? `
|
|
1591
|
-
${styleText("gray", dist_$)}` : ""}` : ""}`;
|
|
1592
|
-
}
|
|
1593
|
-
case "error":
|
|
1594
|
-
{
|
|
1595
|
-
const a = this.error.split(`
|
|
1596
|
-
`).map((l, d)=>0 === d ? `${n ? `${styleText("yellow", E)} ` : ""}${styleText("yellow", l)}` : ` ${l}`).join(`
|
|
1597
|
-
`);
|
|
1598
|
-
return `${o}${n ? `${styleText("yellow", dist_$)} ` : ""}${this.options.map((l, d, y)=>{
|
|
1599
|
-
const p = c.includes(l.value) || !0 === l.group && this.isGroupSelected(`${l.value}`), m = d === this.cursor;
|
|
1600
|
-
return m || "string" != typeof l.group || this.options[this.cursor].value !== l.group ? m && p ? i(l, "active-selected", y) : p ? i(l, "selected", y) : i(l, m ? "active" : "inactive", y) : i(l, p ? "group-active-selected" : "group-active", y);
|
|
1601
|
-
}).join(`
|
|
1602
|
-
${n ? `${styleText("yellow", dist_$)} ` : ""}`)}
|
|
1603
|
-
${a}
|
|
1604
|
-
`;
|
|
1605
|
-
}
|
|
1606
|
-
default:
|
|
1607
|
-
{
|
|
1608
|
-
const a = this.options.map((d, y, p)=>{
|
|
1609
|
-
const m = c.includes(d.value) || !0 === d.group && this.isGroupSelected(`${d.value}`), g = y === this.cursor, S = !g && "string" == typeof d.group && this.options[this.cursor].value === d.group;
|
|
1610
|
-
let h = "";
|
|
1611
|
-
return S ? h = i(d, m ? "group-active-selected" : "group-active", p) : g && m ? h = i(d, "active-selected", p) : m ? h = i(d, "selected", p) : h = i(d, g ? "active" : "inactive", p), `${0 !== y && !h.startsWith(`
|
|
1612
|
-
`) ? " " : ""}${h}`;
|
|
1613
|
-
}).join(`
|
|
1614
|
-
${n ? styleText("cyan", dist_$) : ""}`), l = a.startsWith(`
|
|
1615
|
-
`) ? "" : " ";
|
|
1616
|
-
return `${o}${n ? styleText("cyan", dist_$) : ""}${l}${a}
|
|
1617
|
-
${n ? styleText("cyan", E) : ""}
|
|
1618
|
-
`;
|
|
1619
|
-
}
|
|
1620
|
-
}
|
|
1621
|
-
}
|
|
1622
|
-
}).prompt();
|
|
1623
|
-
}, dist_R = {
|
|
1624
|
-
message: (t = [], { symbol: r = styleText("gray", dist_$), secondarySymbol: s = styleText("gray", dist_$), output: i = process.stdout, spacing: u = 1, withGuide: n } = {})=>{
|
|
1625
|
-
const o = [], c = n ?? dist_h.withGuide, a = c ? s : "", l = c ? `${r} ` : "", d = c ? `${s} ` : "";
|
|
1626
|
-
for(let p = 0; p < u; p++)o.push(a);
|
|
1627
|
-
const y = Array.isArray(t) ? t : t.split(`
|
|
1628
|
-
`);
|
|
1629
|
-
if (y.length > 0) {
|
|
1630
|
-
const [p, ...m] = y;
|
|
1631
|
-
p.length > 0 ? o.push(`${l}${p}`) : o.push(c ? r : "");
|
|
1632
|
-
for (const g of m)g.length > 0 ? o.push(`${d}${g}`) : o.push(c ? s : "");
|
|
1633
|
-
}
|
|
1634
|
-
i.write(`${o.join(`
|
|
1635
|
-
`)}
|
|
1636
|
-
`);
|
|
1637
|
-
},
|
|
1638
|
-
info: (t, r)=>{
|
|
1639
|
-
dist_R.message(t, {
|
|
1640
|
-
...r,
|
|
1641
|
-
symbol: styleText("blue", dist_ht)
|
|
1642
|
-
});
|
|
1643
|
-
},
|
|
1644
|
-
success: (t, r)=>{
|
|
1645
|
-
dist_R.message(t, {
|
|
1646
|
-
...r,
|
|
1647
|
-
symbol: styleText("green", pt)
|
|
1648
|
-
});
|
|
1649
|
-
},
|
|
1650
|
-
step: (t, r)=>{
|
|
1651
|
-
dist_R.message(t, {
|
|
1652
|
-
...r,
|
|
1653
|
-
symbol: styleText("green", dist_F)
|
|
1654
|
-
});
|
|
1655
|
-
},
|
|
1656
|
-
warn: (t, r)=>{
|
|
1657
|
-
dist_R.message(t, {
|
|
1658
|
-
...r,
|
|
1659
|
-
symbol: styleText("yellow", mt)
|
|
1660
|
-
});
|
|
1661
|
-
},
|
|
1662
|
-
warning: (t, r)=>{
|
|
1663
|
-
dist_R.warn(t, r);
|
|
1664
|
-
},
|
|
1665
|
-
error: (t, r)=>{
|
|
1666
|
-
dist_R.message(t, {
|
|
1667
|
-
...r,
|
|
1668
|
-
symbol: styleText("red", gt)
|
|
1669
|
-
});
|
|
1670
|
-
}
|
|
1671
|
-
}, me = (t = "", r)=>{
|
|
1672
|
-
const s = r?.output ?? process.stdout, i = r?.withGuide ?? dist_h.withGuide ? `${styleText("gray", E)} ` : "";
|
|
1673
|
-
s.write(`${i}${styleText("red", t)}
|
|
1674
|
-
|
|
1675
|
-
`);
|
|
1676
|
-
}, ye = (t = "", r)=>{
|
|
1677
|
-
const s = r?.output ?? process.stdout, i = r?.withGuide ?? dist_h.withGuide ? `${styleText("gray", dist_$)}
|
|
1678
|
-
${styleText("gray", E)} ` : "";
|
|
1679
|
-
s.write(`${i}${t}
|
|
1680
|
-
|
|
1681
|
-
`);
|
|
1682
|
-
}, dist_Q = (t, r)=>t.split(`
|
|
1683
|
-
`).map((s)=>r(s)).join(`
|
|
1684
|
-
`), ve = (t)=>{
|
|
1685
|
-
const r = (i, u)=>{
|
|
1686
|
-
const n = i.label ?? String(i.value);
|
|
1687
|
-
return "disabled" === u ? `${styleText("gray", dist_J)} ${dist_Q(n, (o)=>styleText([
|
|
1688
|
-
"strikethrough",
|
|
1689
|
-
"gray"
|
|
1690
|
-
], o))}${i.hint ? ` ${styleText("dim", `(${i.hint ?? "disabled"})`)}` : ""}` : "active" === u ? `${styleText("cyan", dist_et)} ${n}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : "selected" === u ? `${styleText("green", dist_U)} ${dist_Q(n, (o)=>styleText("dim", o))}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : "cancelled" === u ? `${dist_Q(n, (o)=>styleText([
|
|
1691
|
-
"strikethrough",
|
|
1692
|
-
"dim"
|
|
1693
|
-
], o))}` : "active-selected" === u ? `${styleText("green", dist_U)} ${n}${i.hint ? ` ${styleText("dim", `(${i.hint})`)}` : ""}` : "submitted" === u ? `${dist_Q(n, (o)=>styleText("dim", o))}` : `${styleText("dim", dist_J)} ${dist_Q(n, (o)=>styleText("dim", o))}`;
|
|
1694
|
-
}, s = t.required ?? !0;
|
|
1695
|
-
return new dist_nt({
|
|
1696
|
-
options: t.options,
|
|
1697
|
-
signal: t.signal,
|
|
1698
|
-
input: t.input,
|
|
1699
|
-
output: t.output,
|
|
1700
|
-
initialValues: t.initialValues,
|
|
1701
|
-
required: s,
|
|
1702
|
-
cursorAt: t.cursorAt,
|
|
1703
|
-
validate (i) {
|
|
1704
|
-
if (s && (void 0 === i || 0 === i.length)) return `Please select at least one option.
|
|
1705
|
-
${styleText("reset", styleText("dim", `Press ${styleText([
|
|
1706
|
-
"gray",
|
|
1707
|
-
"bgWhite",
|
|
1708
|
-
"inverse"
|
|
1709
|
-
], " space ")} to select, ${styleText("gray", styleText("bgWhite", styleText("inverse", " enter ")))} to submit`))}`;
|
|
1710
|
-
},
|
|
1711
|
-
render () {
|
|
1712
|
-
const i = t.withGuide ?? dist_h.withGuide, u = dist_W(t.output, t.message, i ? `${yt(this.state)} ` : "", `${M(this.state)} `), n = `${i ? `${styleText("gray", dist_$)}
|
|
1713
|
-
` : ""}${u}
|
|
1714
|
-
`, o = this.value ?? [], c = (a, l)=>{
|
|
1715
|
-
if (a.disabled) return r(a, "disabled");
|
|
1716
|
-
const d = o.includes(a.value);
|
|
1717
|
-
return l && d ? r(a, "active-selected") : d ? r(a, "selected") : r(a, l ? "active" : "inactive");
|
|
1718
|
-
};
|
|
1719
|
-
switch(this.state){
|
|
1720
|
-
case "submit":
|
|
1721
|
-
{
|
|
1722
|
-
const a = this.options.filter(({ value: d })=>o.includes(d)).map((d)=>r(d, "submitted")).join(styleText("dim", ", ")) || styleText("dim", "none"), l = dist_W(t.output, a, i ? `${styleText("gray", dist_$)} ` : "");
|
|
1723
|
-
return `${n}${l}`;
|
|
1724
|
-
}
|
|
1725
|
-
case "cancel":
|
|
1726
|
-
{
|
|
1727
|
-
const a = this.options.filter(({ value: d })=>o.includes(d)).map((d)=>r(d, "cancelled")).join(styleText("dim", ", "));
|
|
1728
|
-
if ("" === a.trim()) return `${n}${styleText("gray", dist_$)}`;
|
|
1729
|
-
const l = dist_W(t.output, a, i ? `${styleText("gray", dist_$)} ` : "");
|
|
1730
|
-
return `${n}${l}${i ? `
|
|
1731
|
-
${styleText("gray", dist_$)}` : ""}`;
|
|
1732
|
-
}
|
|
1733
|
-
case "error":
|
|
1734
|
-
{
|
|
1735
|
-
const a = i ? `${styleText("yellow", dist_$)} ` : "", l = this.error.split(`
|
|
1736
|
-
`).map((p, m)=>0 === m ? `${i ? `${styleText("yellow", E)} ` : ""}${styleText("yellow", p)}` : ` ${p}`).join(`
|
|
1737
|
-
`), d = n.split(`
|
|
1738
|
-
`).length, y = l.split(`
|
|
1739
|
-
`).length + 1;
|
|
1740
|
-
return `${n}${a}${dist_Y({
|
|
1741
|
-
output: t.output,
|
|
1742
|
-
options: this.options,
|
|
1743
|
-
cursor: this.cursor,
|
|
1744
|
-
maxItems: t.maxItems,
|
|
1745
|
-
columnPadding: a.length,
|
|
1746
|
-
rowPadding: d + y,
|
|
1747
|
-
style: c
|
|
1748
|
-
}).join(`
|
|
1749
|
-
${a}`)}
|
|
1750
|
-
${l}
|
|
1751
|
-
`;
|
|
1752
|
-
}
|
|
1753
|
-
default:
|
|
1754
|
-
{
|
|
1755
|
-
const a = i ? `${styleText("cyan", dist_$)} ` : "", l = n.split(`
|
|
1756
|
-
`).length, d = i ? 2 : 1;
|
|
1757
|
-
return `${n}${a}${dist_Y({
|
|
1758
|
-
output: t.output,
|
|
1759
|
-
options: this.options,
|
|
1760
|
-
cursor: this.cursor,
|
|
1761
|
-
maxItems: t.maxItems,
|
|
1762
|
-
columnPadding: a.length,
|
|
1763
|
-
rowPadding: l + d,
|
|
1764
|
-
style: c
|
|
1765
|
-
}).join(`
|
|
1766
|
-
${a}`)}
|
|
1767
|
-
${i ? styleText("cyan", E) : ""}
|
|
1768
|
-
`;
|
|
1769
|
-
}
|
|
1770
|
-
}
|
|
1771
|
-
}
|
|
1772
|
-
}).prompt();
|
|
1773
|
-
}, we = (t)=>styleText("dim", t), be = (t, r, s)=>{
|
|
1774
|
-
const i = {
|
|
1775
|
-
hard: !0,
|
|
1776
|
-
trim: !1
|
|
1777
|
-
}, u = wrapAnsi(t, r, i).split(`
|
|
1778
|
-
`), n = u.reduce((a, l)=>Math.max(fast_string_width_dist(l), a), 0), o = u.map(s).reduce((a, l)=>Math.max(fast_string_width_dist(l), a), 0), c = r - (o - n);
|
|
1779
|
-
return wrapAnsi(t, c, i);
|
|
1780
|
-
}, Se = (t = "", r = "", s)=>{
|
|
1781
|
-
const i = s?.output ?? node_process.stdout, u = s?.withGuide ?? dist_h.withGuide, n = s?.format ?? we, o = [
|
|
1782
|
-
"",
|
|
1783
|
-
...be(t, dist_A(i) - 6, n).split(`
|
|
1784
|
-
`).map(n),
|
|
1785
|
-
""
|
|
1786
|
-
], c = fast_string_width_dist(r), a = Math.max(o.reduce((p, m)=>{
|
|
1787
|
-
const g = fast_string_width_dist(m);
|
|
1788
|
-
return g > p ? g : p;
|
|
1789
|
-
}, 0), c) + 2, l = o.map((p)=>`${styleText("gray", dist_$)} ${p}${" ".repeat(a - fast_string_width_dist(p))}${styleText("gray", dist_$)}`).join(`
|
|
1790
|
-
`), d = u ? `${styleText("gray", dist_$)}
|
|
1791
|
-
` : "", y = u ? xt : dt;
|
|
1792
|
-
i.write(`${d}${styleText("green", dist_F)} ${styleText("reset", r)} ${styleText("gray", dist_st.repeat(Math.max(a - c - 1, 1)) + ct)}
|
|
1793
|
-
${l}
|
|
1794
|
-
${styleText("gray", y + dist_st.repeat(a + 2) + $t)}
|
|
1795
|
-
`);
|
|
1796
|
-
};
|
|
1797
|
-
dist_w("\u2500", "-"), dist_w("\u2501", "="), dist_w("\u2588", "#");
|
|
1798
|
-
const dist_it = (t, r)=>t.includes(`
|
|
1799
|
-
`) ? t.split(`
|
|
1800
|
-
`).map((s)=>r(s)).join(`
|
|
1801
|
-
`) : r(t), Ee = (t)=>{
|
|
1802
|
-
const r = (s, i)=>{
|
|
1803
|
-
const u = s.label ?? String(s.value);
|
|
1804
|
-
switch(i){
|
|
1805
|
-
case "disabled":
|
|
1806
|
-
return `${styleText("gray", dist_H)} ${dist_it(u, (n)=>styleText("gray", n))}${s.hint ? ` ${styleText("dim", `(${s.hint ?? "disabled"})`)}` : ""}`;
|
|
1807
|
-
case "selected":
|
|
1808
|
-
return `${dist_it(u, (n)=>styleText("dim", n))}`;
|
|
1809
|
-
case "active":
|
|
1810
|
-
return `${styleText("green", dist_z)} ${u}${s.hint ? ` ${styleText("dim", `(${s.hint})`)}` : ""}`;
|
|
1811
|
-
case "cancelled":
|
|
1812
|
-
return `${dist_it(u, (n)=>styleText([
|
|
1813
|
-
"strikethrough",
|
|
1814
|
-
"dim"
|
|
1815
|
-
], n))}`;
|
|
1816
|
-
default:
|
|
1817
|
-
return `${styleText("dim", dist_H)} ${dist_it(u, (n)=>styleText("dim", n))}`;
|
|
1818
|
-
}
|
|
1819
|
-
};
|
|
1820
|
-
return new ut({
|
|
1821
|
-
options: t.options,
|
|
1822
|
-
signal: t.signal,
|
|
1823
|
-
input: t.input,
|
|
1824
|
-
output: t.output,
|
|
1825
|
-
initialValue: t.initialValue,
|
|
1826
|
-
render () {
|
|
1827
|
-
const s = t.withGuide ?? dist_h.withGuide, i = `${M(this.state)} `, u = `${yt(this.state)} `, n = dist_W(t.output, t.message, u, i), o = `${s ? `${styleText("gray", dist_$)}
|
|
1828
|
-
` : ""}${n}
|
|
1829
|
-
`;
|
|
1830
|
-
switch(this.state){
|
|
1831
|
-
case "submit":
|
|
1832
|
-
{
|
|
1833
|
-
const c = s ? `${styleText("gray", dist_$)} ` : "", a = dist_W(t.output, r(this.options[this.cursor], "selected"), c);
|
|
1834
|
-
return `${o}${a}`;
|
|
1835
|
-
}
|
|
1836
|
-
case "cancel":
|
|
1837
|
-
{
|
|
1838
|
-
const c = s ? `${styleText("gray", dist_$)} ` : "", a = dist_W(t.output, r(this.options[this.cursor], "cancelled"), c);
|
|
1839
|
-
return `${o}${a}${s ? `
|
|
1840
|
-
${styleText("gray", dist_$)}` : ""}`;
|
|
1841
|
-
}
|
|
1842
|
-
default:
|
|
1843
|
-
{
|
|
1844
|
-
const c = s ? `${styleText("cyan", dist_$)} ` : "", a = s ? styleText("cyan", E) : "", l = o.split(`
|
|
1845
|
-
`).length, d = s ? 2 : 1;
|
|
1846
|
-
return `${o}${c}${dist_Y({
|
|
1847
|
-
output: t.output,
|
|
1848
|
-
cursor: this.cursor,
|
|
1849
|
-
options: this.options,
|
|
1850
|
-
maxItems: t.maxItems,
|
|
1851
|
-
columnPadding: c.length,
|
|
1852
|
-
rowPadding: l + d,
|
|
1853
|
-
style: (y, p)=>r(y, y.disabled ? "disabled" : p ? "active" : "inactive")
|
|
1854
|
-
}).join(`
|
|
1855
|
-
${c}`)}
|
|
1856
|
-
${a}
|
|
1857
|
-
`;
|
|
1858
|
-
}
|
|
1859
|
-
}
|
|
1860
|
-
}
|
|
1861
|
-
}).prompt();
|
|
1862
|
-
}, Oe = (styleText("gray", dist_$), (t)=>t.replace(/\x1b\[(?:\d+;)*\d*[ABCDEFGHfJKSTsu]|\x1b\[(s|u)/g, "")), Me = (t)=>{
|
|
1863
|
-
const r = t.output ?? process.stdout, s = dist_A(r), i = styleText("gray", dist_$), u = t.spacing ?? 1, n = 3, o = !0 === t.retainLog, c = !dist_at() && Tt(r);
|
|
1864
|
-
r.write(`${i}
|
|
1865
|
-
`), r.write(`${styleText("green", dist_F)} ${t.title}
|
|
1866
|
-
`);
|
|
1867
|
-
for(let h = 0; h < u; h++)r.write(`${i}
|
|
1868
|
-
`);
|
|
1869
|
-
const a = [
|
|
1870
|
-
{
|
|
1871
|
-
value: "",
|
|
1872
|
-
full: ""
|
|
1873
|
-
}
|
|
1874
|
-
];
|
|
1875
|
-
let l = !1;
|
|
1876
|
-
const d = (h)=>{
|
|
1877
|
-
if (0 === a.length) return;
|
|
1878
|
-
let f = 0;
|
|
1879
|
-
h && (f += u + 2);
|
|
1880
|
-
for (const v of a){
|
|
1881
|
-
const { value: T, result: C } = v;
|
|
1882
|
-
let b = C?.message ?? T;
|
|
1883
|
-
if (0 === b.length) continue;
|
|
1884
|
-
void 0 === C && void 0 !== v.header && "" !== v.header && (b += `
|
|
1885
|
-
${v.header}`);
|
|
1886
|
-
const G = b.split(`
|
|
1887
|
-
`).reduce((x, A)=>"" === A ? x + 1 : x + Math.ceil((A.length + n) / s), 0);
|
|
1888
|
-
f += G;
|
|
1889
|
-
}
|
|
1890
|
-
f > 0 && (f += 1, r.write(src.erase.lines(f)));
|
|
1891
|
-
}, y = (h, f, v)=>{
|
|
1892
|
-
const T = v ? `${h.full}
|
|
1893
|
-
${h.value}` : h.value;
|
|
1894
|
-
void 0 !== h.header && "" !== h.header && dist_R.message(h.header.split(`
|
|
1895
|
-
`).map((C)=>styleText("bold", C)), {
|
|
1896
|
-
output: r,
|
|
1897
|
-
secondarySymbol: i,
|
|
1898
|
-
symbol: i,
|
|
1899
|
-
spacing: 0
|
|
1900
|
-
}), dist_R.message(T.split(`
|
|
1901
|
-
`).map((C)=>styleText("dim", C)), {
|
|
1902
|
-
output: r,
|
|
1903
|
-
secondarySymbol: i,
|
|
1904
|
-
symbol: i,
|
|
1905
|
-
spacing: f ?? u
|
|
1906
|
-
});
|
|
1907
|
-
}, p = ()=>{
|
|
1908
|
-
for (const h of a){
|
|
1909
|
-
const { header: f, value: v, full: T } = h;
|
|
1910
|
-
(void 0 === f || 0 === f.length) && 0 === v.length || y(h, void 0, !0 === o && T.length > 0);
|
|
1911
|
-
}
|
|
1912
|
-
}, m = (h, f, v)=>{
|
|
1913
|
-
if (d(!1), v?.raw === !0 && l || "" === h.value || (h.value += `
|
|
1914
|
-
`), h.value += Oe(f), l = v?.raw === !0, void 0 !== t.limit) {
|
|
1915
|
-
const T = h.value.split(`
|
|
1916
|
-
`), C = T.length - t.limit;
|
|
1917
|
-
if (C > 0) {
|
|
1918
|
-
const b = T.splice(0, C);
|
|
1919
|
-
o && (h.full += ("" === h.full ? "" : `
|
|
1920
|
-
`) + b.join(`
|
|
1921
|
-
`));
|
|
1922
|
-
}
|
|
1923
|
-
h.value = T.join(`
|
|
1924
|
-
`);
|
|
1925
|
-
}
|
|
1926
|
-
c && g();
|
|
1927
|
-
}, g = ()=>{
|
|
1928
|
-
for (const h of a)h.result ? "error" === h.result.status ? dist_R.error(h.result.message, {
|
|
1929
|
-
output: r,
|
|
1930
|
-
secondarySymbol: i,
|
|
1931
|
-
spacing: 0
|
|
1932
|
-
}) : dist_R.success(h.result.message, {
|
|
1933
|
-
output: r,
|
|
1934
|
-
secondarySymbol: i,
|
|
1935
|
-
spacing: 0
|
|
1936
|
-
}) : "" !== h.value && y(h, 0);
|
|
1937
|
-
}, S = (h, f)=>{
|
|
1938
|
-
d(!1), h.result = f, c && g();
|
|
1939
|
-
};
|
|
1940
|
-
return {
|
|
1941
|
-
message (h, f) {
|
|
1942
|
-
m(a[0], h, f);
|
|
1943
|
-
},
|
|
1944
|
-
group (h) {
|
|
1945
|
-
const f = {
|
|
1946
|
-
header: h,
|
|
1947
|
-
value: "",
|
|
1948
|
-
full: ""
|
|
1949
|
-
};
|
|
1950
|
-
return a.push(f), {
|
|
1951
|
-
message (v, T) {
|
|
1952
|
-
m(f, v, T);
|
|
1953
|
-
},
|
|
1954
|
-
error (v) {
|
|
1955
|
-
S(f, {
|
|
1956
|
-
status: "error",
|
|
1957
|
-
message: v
|
|
1958
|
-
});
|
|
47
|
+
value: 'basic',
|
|
48
|
+
label: 'Single language',
|
|
49
|
+
hint: 'docs'
|
|
1959
50
|
},
|
|
1960
|
-
|
|
1961
|
-
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
});
|
|
1965
|
-
}
|
|
1966
|
-
};
|
|
1967
|
-
},
|
|
1968
|
-
error (h, f) {
|
|
1969
|
-
d(!0), dist_R.error(h, {
|
|
1970
|
-
output: r,
|
|
1971
|
-
secondarySymbol: i,
|
|
1972
|
-
spacing: 1
|
|
1973
|
-
}), f?.showLog !== !1 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
1974
|
-
},
|
|
1975
|
-
success (h, f) {
|
|
1976
|
-
d(!0), dist_R.success(h, {
|
|
1977
|
-
output: r,
|
|
1978
|
-
secondarySymbol: i,
|
|
1979
|
-
spacing: 1
|
|
1980
|
-
}), f?.showLog === !0 && p(), a.splice(1, a.length - 1), a[0].value = "", a[0].full = "";
|
|
1981
|
-
}
|
|
1982
|
-
};
|
|
1983
|
-
}, Re = (t)=>new ht({
|
|
1984
|
-
validate: t.validate,
|
|
1985
|
-
placeholder: t.placeholder,
|
|
1986
|
-
defaultValue: t.defaultValue,
|
|
1987
|
-
initialValue: t.initialValue,
|
|
1988
|
-
output: t.output,
|
|
1989
|
-
signal: t.signal,
|
|
1990
|
-
input: t.input,
|
|
1991
|
-
render () {
|
|
1992
|
-
const r = t?.withGuide ?? dist_h.withGuide, s = `${r ? `${styleText("gray", dist_$)}
|
|
1993
|
-
` : ""}${M(this.state)} ${t.message}
|
|
1994
|
-
`, i = t.placeholder ? styleText("inverse", t.placeholder[0]) + styleText("dim", t.placeholder.slice(1)) : styleText([
|
|
1995
|
-
"inverse",
|
|
1996
|
-
"hidden"
|
|
1997
|
-
], "_"), u = this.userInput ? this.userInputWithCursor : i, n = this.value ?? "";
|
|
1998
|
-
switch(this.state){
|
|
1999
|
-
case "error":
|
|
2000
|
-
{
|
|
2001
|
-
const o = this.error ? ` ${styleText("yellow", this.error)}` : "", c = r ? `${styleText("yellow", dist_$)} ` : "", a = r ? styleText("yellow", E) : "";
|
|
2002
|
-
return `${s.trim()}
|
|
2003
|
-
${c}${u}
|
|
2004
|
-
${a}${o}
|
|
2005
|
-
`;
|
|
2006
|
-
}
|
|
2007
|
-
case "submit":
|
|
2008
|
-
{
|
|
2009
|
-
const o = n ? ` ${styleText("dim", n)}` : "", c = r ? styleText("gray", dist_$) : "";
|
|
2010
|
-
return `${s}${c}${o}`;
|
|
2011
|
-
}
|
|
2012
|
-
case "cancel":
|
|
2013
|
-
{
|
|
2014
|
-
const o = n ? ` ${styleText([
|
|
2015
|
-
"strikethrough",
|
|
2016
|
-
"dim"
|
|
2017
|
-
], n)}` : "", c = r ? styleText("gray", dist_$) : "";
|
|
2018
|
-
return `${s}${c}${o}${n.trim() ? `
|
|
2019
|
-
${c}` : ""}`;
|
|
2020
|
-
}
|
|
2021
|
-
default:
|
|
2022
|
-
{
|
|
2023
|
-
const o = r ? `${styleText("cyan", dist_$)} ` : "", c = r ? styleText("cyan", E) : "";
|
|
2024
|
-
return `${s}${o}${u}
|
|
2025
|
-
${c}
|
|
2026
|
-
`;
|
|
2027
|
-
}
|
|
2028
|
-
}
|
|
2029
|
-
}
|
|
2030
|
-
}).prompt();
|
|
2031
|
-
function checkNodeVersion() {
|
|
2032
|
-
const { versions } = process;
|
|
2033
|
-
if ("styleText" in node_util || !versions.node || versions.bun || versions.deno) return;
|
|
2034
|
-
throw new Error(`Unsupported Node.js version: "${process.versions.node || 'unknown'}". Expected Node.js >= 20.`);
|
|
2035
|
-
}
|
|
2036
|
-
checkNodeVersion();
|
|
2037
|
-
const createStyler = (style)=>(text)=>node_util.styleText(style, String(text));
|
|
2038
|
-
const color = {
|
|
2039
|
-
dim: createStyler('dim'),
|
|
2040
|
-
red: createStyler('red'),
|
|
2041
|
-
bold: createStyler('bold'),
|
|
2042
|
-
blue: createStyler('blue'),
|
|
2043
|
-
cyan: createStyler('cyan'),
|
|
2044
|
-
gray: createStyler('gray'),
|
|
2045
|
-
black: createStyler('black'),
|
|
2046
|
-
green: createStyler('green'),
|
|
2047
|
-
white: createStyler('white'),
|
|
2048
|
-
reset: createStyler('reset'),
|
|
2049
|
-
yellow: createStyler('yellow'),
|
|
2050
|
-
magenta: createStyler('magenta'),
|
|
2051
|
-
underline: createStyler('underline'),
|
|
2052
|
-
strikethrough: createStyler('strikethrough')
|
|
2053
|
-
};
|
|
2054
|
-
function hasFlag(flag, argv = globalThis.Deno ? globalThis.Deno.args : node_process.argv) {
|
|
2055
|
-
const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
|
|
2056
|
-
const position = argv.indexOf(prefix + flag);
|
|
2057
|
-
const terminatorPosition = argv.indexOf('--');
|
|
2058
|
-
return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
|
|
2059
|
-
}
|
|
2060
|
-
const { env: env } = node_process;
|
|
2061
|
-
let flagForceColor;
|
|
2062
|
-
if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) flagForceColor = 0;
|
|
2063
|
-
else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) flagForceColor = 1;
|
|
2064
|
-
function envForceColor() {
|
|
2065
|
-
if (!('FORCE_COLOR' in env)) return;
|
|
2066
|
-
if ('true' === env.FORCE_COLOR) return 1;
|
|
2067
|
-
if ('false' === env.FORCE_COLOR) return 0;
|
|
2068
|
-
if (0 === env.FORCE_COLOR.length) return 1;
|
|
2069
|
-
const level = Math.min(Number.parseInt(env.FORCE_COLOR, 10), 3);
|
|
2070
|
-
if (![
|
|
2071
|
-
0,
|
|
2072
|
-
1,
|
|
2073
|
-
2,
|
|
2074
|
-
3
|
|
2075
|
-
].includes(level)) return;
|
|
2076
|
-
return level;
|
|
2077
|
-
}
|
|
2078
|
-
function translateLevel(level) {
|
|
2079
|
-
if (0 === level) return false;
|
|
2080
|
-
return {
|
|
2081
|
-
level,
|
|
2082
|
-
hasBasic: true,
|
|
2083
|
-
has256: level >= 2,
|
|
2084
|
-
has16m: level >= 3
|
|
2085
|
-
};
|
|
2086
|
-
}
|
|
2087
|
-
function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
2088
|
-
const noFlagForceColor = envForceColor();
|
|
2089
|
-
if (void 0 !== noFlagForceColor) flagForceColor = noFlagForceColor;
|
|
2090
|
-
const forceColor = sniffFlags ? flagForceColor : noFlagForceColor;
|
|
2091
|
-
if (0 === forceColor) return 0;
|
|
2092
|
-
if (sniffFlags) {
|
|
2093
|
-
if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
|
|
2094
|
-
if (hasFlag('color=256')) return 2;
|
|
2095
|
-
}
|
|
2096
|
-
if ('TF_BUILD' in env && 'AGENT_NAME' in env) return 1;
|
|
2097
|
-
if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
|
|
2098
|
-
const min = forceColor || 0;
|
|
2099
|
-
if ('dumb' === env.TERM) return min;
|
|
2100
|
-
if ('win32' === node_process.platform) {
|
|
2101
|
-
const osRelease = node_os.release().split('.');
|
|
2102
|
-
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
2103
|
-
return 1;
|
|
2104
|
-
}
|
|
2105
|
-
if ('CI' in env) {
|
|
2106
|
-
if ([
|
|
2107
|
-
'GITHUB_ACTIONS',
|
|
2108
|
-
'GITEA_ACTIONS',
|
|
2109
|
-
'CIRCLECI'
|
|
2110
|
-
].some((key)=>key in env)) return 3;
|
|
2111
|
-
if ([
|
|
2112
|
-
'TRAVIS',
|
|
2113
|
-
'APPVEYOR',
|
|
2114
|
-
'GITLAB_CI',
|
|
2115
|
-
'BUILDKITE',
|
|
2116
|
-
'DRONE'
|
|
2117
|
-
].some((sign)=>sign in env) || 'codeship' === env.CI_NAME) return 1;
|
|
2118
|
-
return min;
|
|
2119
|
-
}
|
|
2120
|
-
if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
|
|
2121
|
-
if ('truecolor' === env.COLORTERM) return 3;
|
|
2122
|
-
if ('xterm-kitty' === env.TERM) return 3;
|
|
2123
|
-
if ('xterm-ghostty' === env.TERM) return 3;
|
|
2124
|
-
if ('wezterm' === env.TERM) return 3;
|
|
2125
|
-
if ('TERM_PROGRAM' in env) {
|
|
2126
|
-
const version = Number.parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
|
|
2127
|
-
switch(env.TERM_PROGRAM){
|
|
2128
|
-
case 'iTerm.app':
|
|
2129
|
-
return version >= 3 ? 3 : 2;
|
|
2130
|
-
case 'Apple_Terminal':
|
|
2131
|
-
return 2;
|
|
2132
|
-
}
|
|
2133
|
-
}
|
|
2134
|
-
if (/-256(color)?$/i.test(env.TERM)) return 2;
|
|
2135
|
-
if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
|
|
2136
|
-
if ('COLORTERM' in env) return 1;
|
|
2137
|
-
return min;
|
|
2138
|
-
}
|
|
2139
|
-
function createSupportsColor(stream, options = {}) {
|
|
2140
|
-
const level = _supportsColor(stream, {
|
|
2141
|
-
streamIsTTY: stream && stream.isTTY,
|
|
2142
|
-
...options
|
|
2143
|
-
});
|
|
2144
|
-
return translateLevel(level);
|
|
2145
|
-
}
|
|
2146
|
-
const supportsColor = {
|
|
2147
|
-
stdout: createSupportsColor({
|
|
2148
|
-
isTTY: node_tty.isatty(1)
|
|
2149
|
-
}),
|
|
2150
|
-
stderr: createSupportsColor({
|
|
2151
|
-
isTTY: node_tty.isatty(2)
|
|
2152
|
-
})
|
|
2153
|
-
};
|
|
2154
|
-
const supports_color = supportsColor;
|
|
2155
|
-
const colorLevel = supports_color.stdout ? supports_color.stdout.level : 0;
|
|
2156
|
-
let errorStackRegExp = /at [^\r\n]{0,200}:\d+:\d+[\s\)]*$/;
|
|
2157
|
-
let anonymousErrorStackRegExp = /at [^\r\n]{0,200}\(<anonymous>\)$/;
|
|
2158
|
-
let indexErrorStackRegExp = /at [^\r\n]{0,200}\(index\s\d+\)$/;
|
|
2159
|
-
let isErrorStackMessage = (message)=>errorStackRegExp.test(message) || anonymousErrorStackRegExp.test(message) || indexErrorStackRegExp.test(message);
|
|
2160
|
-
let startColor = [
|
|
2161
|
-
189,
|
|
2162
|
-
255,
|
|
2163
|
-
243
|
|
2164
|
-
];
|
|
2165
|
-
let endColor = [
|
|
2166
|
-
74,
|
|
2167
|
-
194,
|
|
2168
|
-
154
|
|
2169
|
-
];
|
|
2170
|
-
let isWord = (char)=>!/[\s\n]/.test(char);
|
|
2171
|
-
let gradient = (message)=>{
|
|
2172
|
-
if (colorLevel < 3) return 2 === colorLevel ? color.cyan(message) : message;
|
|
2173
|
-
let chars = [
|
|
2174
|
-
...message
|
|
2175
|
-
];
|
|
2176
|
-
let steps = chars.filter(isWord).length;
|
|
2177
|
-
let r = startColor[0];
|
|
2178
|
-
let g = startColor[1];
|
|
2179
|
-
let b = startColor[2];
|
|
2180
|
-
let rStep = (endColor[0] - r) / steps;
|
|
2181
|
-
let gStep = (endColor[1] - g) / steps;
|
|
2182
|
-
let bStep = (endColor[2] - b) / steps;
|
|
2183
|
-
let output = '';
|
|
2184
|
-
for (let char of chars){
|
|
2185
|
-
if (isWord(char)) {
|
|
2186
|
-
r += rStep;
|
|
2187
|
-
g += gStep;
|
|
2188
|
-
b += bStep;
|
|
2189
|
-
}
|
|
2190
|
-
output += `\x1b[38;2;${Math.round(r)};${Math.round(g)};${Math.round(b)}m${char}\x1b[39m`;
|
|
2191
|
-
}
|
|
2192
|
-
return color.bold(output);
|
|
2193
|
-
};
|
|
2194
|
-
let LOG_LEVEL = {
|
|
2195
|
-
silent: -1,
|
|
2196
|
-
error: 0,
|
|
2197
|
-
warn: 1,
|
|
2198
|
-
info: 2,
|
|
2199
|
-
log: 2,
|
|
2200
|
-
verbose: 3
|
|
2201
|
-
};
|
|
2202
|
-
let LOG_TYPES = {
|
|
2203
|
-
error: {
|
|
2204
|
-
label: 'error',
|
|
2205
|
-
level: 'error',
|
|
2206
|
-
color: color.red
|
|
2207
|
-
},
|
|
2208
|
-
warn: {
|
|
2209
|
-
label: 'warn',
|
|
2210
|
-
level: 'warn',
|
|
2211
|
-
color: color.yellow
|
|
2212
|
-
},
|
|
2213
|
-
info: {
|
|
2214
|
-
label: 'info',
|
|
2215
|
-
level: 'info',
|
|
2216
|
-
color: color.cyan
|
|
2217
|
-
},
|
|
2218
|
-
start: {
|
|
2219
|
-
label: 'start',
|
|
2220
|
-
level: 'info',
|
|
2221
|
-
color: color.cyan
|
|
2222
|
-
},
|
|
2223
|
-
ready: {
|
|
2224
|
-
label: 'ready',
|
|
2225
|
-
level: 'info',
|
|
2226
|
-
color: color.green
|
|
2227
|
-
},
|
|
2228
|
-
success: {
|
|
2229
|
-
label: 'success',
|
|
2230
|
-
level: 'info',
|
|
2231
|
-
color: color.green
|
|
2232
|
-
},
|
|
2233
|
-
log: {
|
|
2234
|
-
level: 'info'
|
|
2235
|
-
},
|
|
2236
|
-
debug: {
|
|
2237
|
-
label: 'debug',
|
|
2238
|
-
level: 'verbose',
|
|
2239
|
-
color: color.magenta
|
|
2240
|
-
}
|
|
2241
|
-
};
|
|
2242
|
-
const normalizeErrorMessage = (err)=>{
|
|
2243
|
-
if (err.stack) {
|
|
2244
|
-
let [name, ...rest] = err.stack.split('\n');
|
|
2245
|
-
if (name.startsWith('Error: ')) name = name.slice(7);
|
|
2246
|
-
return `${name}\n${color.gray(rest.join('\n'))}`;
|
|
2247
|
-
}
|
|
2248
|
-
return err.message;
|
|
2249
|
-
};
|
|
2250
|
-
let createLogger = (options = {})=>{
|
|
2251
|
-
const { level = 'info', prefix, console: console1 = globalThis.console } = options;
|
|
2252
|
-
let maxLevel = level;
|
|
2253
|
-
let log = (type, message, ...args)=>{
|
|
2254
|
-
let logType = LOG_TYPES[type];
|
|
2255
|
-
const { level } = logType;
|
|
2256
|
-
if (LOG_LEVEL[level] > LOG_LEVEL[maxLevel]) return;
|
|
2257
|
-
if (null == message) return console1.log();
|
|
2258
|
-
let label = '';
|
|
2259
|
-
let text = '';
|
|
2260
|
-
if ('label' in logType) {
|
|
2261
|
-
label = (logType.label || '').padEnd(7);
|
|
2262
|
-
label = color.bold(logType.color ? logType.color(label) : label);
|
|
2263
|
-
}
|
|
2264
|
-
if (message instanceof Error) {
|
|
2265
|
-
text += normalizeErrorMessage(message);
|
|
2266
|
-
const { cause } = message;
|
|
2267
|
-
if (cause) {
|
|
2268
|
-
text += color.yellow('\n [cause]: ');
|
|
2269
|
-
text += cause instanceof Error ? normalizeErrorMessage(cause) : String(cause);
|
|
2270
|
-
}
|
|
2271
|
-
} else if ('error' === level && 'string' == typeof message) {
|
|
2272
|
-
let lines = message.split('\n');
|
|
2273
|
-
text = lines.map((line)=>isErrorStackMessage(line) ? color.gray(line) : line).join('\n');
|
|
2274
|
-
} else text = `${message}`;
|
|
2275
|
-
if (prefix) text = `${prefix} ${text}`;
|
|
2276
|
-
const method = 'error' === level || 'warn' === level ? level : 'log';
|
|
2277
|
-
console1[method](label.length ? `${label} ${text}` : text, ...args);
|
|
2278
|
-
};
|
|
2279
|
-
let logger = {
|
|
2280
|
-
greet: (message)=>log('log', gradient(message))
|
|
2281
|
-
};
|
|
2282
|
-
Object.keys(LOG_TYPES).forEach((key)=>{
|
|
2283
|
-
logger[key] = (...args)=>log(key, ...args);
|
|
2284
|
-
});
|
|
2285
|
-
Object.defineProperty(logger, 'level', {
|
|
2286
|
-
get: ()=>maxLevel,
|
|
2287
|
-
set (val) {
|
|
2288
|
-
maxLevel = val;
|
|
2289
|
-
}
|
|
2290
|
-
});
|
|
2291
|
-
Object.defineProperty(logger, 'options', {
|
|
2292
|
-
get: ()=>({
|
|
2293
|
-
...options
|
|
2294
|
-
})
|
|
2295
|
-
});
|
|
2296
|
-
logger.override = (customLogger)=>{
|
|
2297
|
-
Object.assign(logger, customLogger);
|
|
2298
|
-
};
|
|
2299
|
-
return logger;
|
|
2300
|
-
};
|
|
2301
|
-
let src_logger = createLogger();
|
|
2302
|
-
var main_u = (e, t)=>()=>(t || (e((t = {
|
|
2303
|
-
exports: {}
|
|
2304
|
-
}).exports, t), e = null), t.exports);
|
|
2305
|
-
var main_d = /* @__PURE__ */ createRequire(import.meta.url);
|
|
2306
|
-
const main_f = /^path$/i;
|
|
2307
|
-
const main_p = {
|
|
2308
|
-
key: "PATH",
|
|
2309
|
-
value: ""
|
|
2310
|
-
};
|
|
2311
|
-
function main_m(e) {
|
|
2312
|
-
for(const t in e){
|
|
2313
|
-
if (!Object.prototype.hasOwnProperty.call(e, t) || !main_f.test(t)) continue;
|
|
2314
|
-
const n = e[t];
|
|
2315
|
-
if (!n) break;
|
|
2316
|
-
return {
|
|
2317
|
-
key: t,
|
|
2318
|
-
value: n
|
|
2319
|
-
};
|
|
2320
|
-
}
|
|
2321
|
-
return main_p;
|
|
2322
|
-
}
|
|
2323
|
-
function main_h(e, t) {
|
|
2324
|
-
const n = t.value.split(delimiter);
|
|
2325
|
-
const r = [];
|
|
2326
|
-
let s = e;
|
|
2327
|
-
let c;
|
|
2328
|
-
do {
|
|
2329
|
-
r.push(resolve(s, "node_modules", ".bin"));
|
|
2330
|
-
c = s;
|
|
2331
|
-
s = dirname(s);
|
|
2332
|
-
}while (s !== c);
|
|
2333
|
-
r.push(dirname(process.execPath));
|
|
2334
|
-
const l = r.concat(n).join(delimiter);
|
|
2335
|
-
return {
|
|
2336
|
-
key: t.key,
|
|
2337
|
-
value: l
|
|
2338
|
-
};
|
|
2339
|
-
}
|
|
2340
|
-
function main_g(e, t) {
|
|
2341
|
-
const n = {
|
|
2342
|
-
...process.env,
|
|
2343
|
-
...t
|
|
2344
|
-
};
|
|
2345
|
-
const r = main_h(e, main_m(n));
|
|
2346
|
-
n[r.key] = r.value;
|
|
2347
|
-
return n;
|
|
2348
|
-
}
|
|
2349
|
-
const main_ = (e)=>{
|
|
2350
|
-
let t = e.length;
|
|
2351
|
-
const n = new PassThrough();
|
|
2352
|
-
const r = ()=>{
|
|
2353
|
-
if (0 === --t) n.end();
|
|
2354
|
-
};
|
|
2355
|
-
for (const t of e)pipeline(t, n, {
|
|
2356
|
-
end: false
|
|
2357
|
-
}).then(r).catch(r);
|
|
2358
|
-
return n;
|
|
2359
|
-
};
|
|
2360
|
-
var main_v = /* @__PURE__ */ main_u((e, t)=>{
|
|
2361
|
-
t.exports = a;
|
|
2362
|
-
a.sync = o;
|
|
2363
|
-
var n = main_d("fs");
|
|
2364
|
-
function r(e, t) {
|
|
2365
|
-
var n = void 0 !== t.pathExt ? t.pathExt : process.env.PATHEXT;
|
|
2366
|
-
if (!n) return true;
|
|
2367
|
-
n = n.split(";");
|
|
2368
|
-
if (-1 !== n.indexOf("")) return true;
|
|
2369
|
-
for(var r = 0; r < n.length; r++){
|
|
2370
|
-
var i = n[r].toLowerCase();
|
|
2371
|
-
if (i && e.substr(-i.length).toLowerCase() === i) return true;
|
|
2372
|
-
}
|
|
2373
|
-
return false;
|
|
2374
|
-
}
|
|
2375
|
-
function i(e, t, n) {
|
|
2376
|
-
if (!e.isSymbolicLink() && !e.isFile()) return false;
|
|
2377
|
-
return r(t, n);
|
|
2378
|
-
}
|
|
2379
|
-
function a(e, t, r) {
|
|
2380
|
-
n.stat(e, function(n, a) {
|
|
2381
|
-
r(n, n ? false : i(a, e, t));
|
|
2382
|
-
});
|
|
2383
|
-
}
|
|
2384
|
-
function o(e, t) {
|
|
2385
|
-
return i(n.statSync(e), e, t);
|
|
2386
|
-
}
|
|
2387
|
-
});
|
|
2388
|
-
var main_y = /* @__PURE__ */ main_u((e, t)=>{
|
|
2389
|
-
t.exports = r;
|
|
2390
|
-
r.sync = i;
|
|
2391
|
-
var n = main_d("fs");
|
|
2392
|
-
function r(e, t, r) {
|
|
2393
|
-
n.stat(e, function(e, n) {
|
|
2394
|
-
r(e, e ? false : a(n, t));
|
|
2395
|
-
});
|
|
2396
|
-
}
|
|
2397
|
-
function i(e, t) {
|
|
2398
|
-
return a(n.statSync(e), t);
|
|
2399
|
-
}
|
|
2400
|
-
function a(e, t) {
|
|
2401
|
-
return e.isFile() && o(e, t);
|
|
2402
|
-
}
|
|
2403
|
-
function o(e, t) {
|
|
2404
|
-
var n = e.mode;
|
|
2405
|
-
var r = e.uid;
|
|
2406
|
-
var i = e.gid;
|
|
2407
|
-
var a = void 0 !== t.uid ? t.uid : process.getuid && process.getuid();
|
|
2408
|
-
var o = void 0 !== t.gid ? t.gid : process.getgid && process.getgid();
|
|
2409
|
-
var s = parseInt("100", 8);
|
|
2410
|
-
var c = parseInt("010", 8);
|
|
2411
|
-
var l = parseInt("001", 8);
|
|
2412
|
-
var u = s | c;
|
|
2413
|
-
return n & l || n & c && i === o || n & s && r === a || n & u && 0 === a;
|
|
2414
|
-
}
|
|
2415
|
-
});
|
|
2416
|
-
var main_b = /* @__PURE__ */ main_u((e, t)=>{
|
|
2417
|
-
main_d("fs");
|
|
2418
|
-
var n;
|
|
2419
|
-
n = "win32" === process.platform || global.TESTING_WINDOWS ? main_v() : main_y();
|
|
2420
|
-
t.exports = r;
|
|
2421
|
-
r.sync = i;
|
|
2422
|
-
function r(e, t, i) {
|
|
2423
|
-
if ("function" == typeof t) {
|
|
2424
|
-
i = t;
|
|
2425
|
-
t = {};
|
|
2426
|
-
}
|
|
2427
|
-
if (!i) {
|
|
2428
|
-
if ("function" != typeof Promise) throw new TypeError("callback not provided");
|
|
2429
|
-
return new Promise(function(n, i) {
|
|
2430
|
-
r(e, t || {}, function(e, t) {
|
|
2431
|
-
if (e) i(e);
|
|
2432
|
-
else n(t);
|
|
2433
|
-
});
|
|
2434
|
-
});
|
|
2435
|
-
}
|
|
2436
|
-
n(e, t || {}, function(e, n) {
|
|
2437
|
-
if (e) {
|
|
2438
|
-
if ("EACCES" === e.code || t && t.ignoreErrors) {
|
|
2439
|
-
e = null;
|
|
2440
|
-
n = false;
|
|
51
|
+
{
|
|
52
|
+
value: 'i18n',
|
|
53
|
+
label: 'Multilingual',
|
|
54
|
+
hint: 'docs/en, docs/zh'
|
|
2441
55
|
}
|
|
56
|
+
]
|
|
57
|
+
}));
|
|
58
|
+
return `doc-${documentationType}`;
|
|
59
|
+
}
|
|
60
|
+
const templateType = checkCancel(await create_toolkit_select({
|
|
61
|
+
message: 'app' === projectType ? 'Select framework' : 'Select library type',
|
|
62
|
+
options: 'app' === projectType ? [
|
|
63
|
+
{
|
|
64
|
+
value: 'vanilla',
|
|
65
|
+
label: 'Vanilla'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
value: 'react',
|
|
69
|
+
label: 'React'
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
value: 'preact',
|
|
73
|
+
label: 'Preact'
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
value: 'vue',
|
|
77
|
+
label: 'Vue'
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
value: 'lit',
|
|
81
|
+
label: 'Lit'
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
value: 'svelte',
|
|
85
|
+
label: 'Svelte'
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
value: 'solid',
|
|
89
|
+
label: 'Solid'
|
|
2442
90
|
}
|
|
2443
|
-
i(e, n);
|
|
2444
|
-
});
|
|
2445
|
-
}
|
|
2446
|
-
function i(e, t) {
|
|
2447
|
-
try {
|
|
2448
|
-
return n.sync(e, t || {});
|
|
2449
|
-
} catch (e) {
|
|
2450
|
-
if (t && t.ignoreErrors || "EACCES" === e.code) return false;
|
|
2451
|
-
throw e;
|
|
2452
|
-
}
|
|
2453
|
-
}
|
|
2454
|
-
});
|
|
2455
|
-
var main_x = /* @__PURE__ */ main_u((e, t)=>{
|
|
2456
|
-
const n = "win32" === process.platform || "cygwin" === process.env.OSTYPE || "msys" === process.env.OSTYPE;
|
|
2457
|
-
const r = main_d("path");
|
|
2458
|
-
const i = n ? ";" : ":";
|
|
2459
|
-
const a = main_b();
|
|
2460
|
-
const o = (e)=>Object.assign(/* @__PURE__ */ new Error(`not found: ${e}`), {
|
|
2461
|
-
code: "ENOENT"
|
|
2462
|
-
});
|
|
2463
|
-
const s = (e, t)=>{
|
|
2464
|
-
const r = t.colon || i;
|
|
2465
|
-
const a = e.match(/\//) || n && e.match(/\\/) ? [
|
|
2466
|
-
""
|
|
2467
91
|
] : [
|
|
2468
|
-
|
|
2469
|
-
|
|
2470
|
-
|
|
2471
|
-
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
|
|
2479
|
-
|
|
2480
|
-
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
if ("function" == typeof t) {
|
|
2488
|
-
n = t;
|
|
2489
|
-
t = {};
|
|
2490
|
-
}
|
|
2491
|
-
if (!t) t = {};
|
|
2492
|
-
const { pathEnv: i, pathExt: c, pathExtExe: l } = s(e, t);
|
|
2493
|
-
const u = [];
|
|
2494
|
-
const d = (n)=>new Promise((a, s)=>{
|
|
2495
|
-
if (n === i.length) return t.all && u.length ? a(u) : s(o(e));
|
|
2496
|
-
const c = i[n];
|
|
2497
|
-
const l = /^".*"$/.test(c) ? c.slice(1, -1) : c;
|
|
2498
|
-
const d = r.join(l, e);
|
|
2499
|
-
a(f(!l && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d, n, 0));
|
|
2500
|
-
});
|
|
2501
|
-
const f = (e, n, r)=>new Promise((i, o)=>{
|
|
2502
|
-
if (r === c.length) return i(d(n + 1));
|
|
2503
|
-
const s = c[r];
|
|
2504
|
-
a(e + s, {
|
|
2505
|
-
pathExt: l
|
|
2506
|
-
}, (a, o)=>{
|
|
2507
|
-
if (!a && o) if (!t.all) return i(e + s);
|
|
2508
|
-
else u.push(e + s);
|
|
2509
|
-
return i(f(e, n, r + 1));
|
|
2510
|
-
});
|
|
2511
|
-
});
|
|
2512
|
-
return n ? d(0).then((e)=>n(null, e), n) : d(0);
|
|
2513
|
-
};
|
|
2514
|
-
const l = (e, t)=>{
|
|
2515
|
-
t = t || {};
|
|
2516
|
-
const { pathEnv: n, pathExt: i, pathExtExe: c } = s(e, t);
|
|
2517
|
-
const l = [];
|
|
2518
|
-
for(let o = 0; o < n.length; o++){
|
|
2519
|
-
const s = n[o];
|
|
2520
|
-
const u = /^".*"$/.test(s) ? s.slice(1, -1) : s;
|
|
2521
|
-
const d = r.join(u, e);
|
|
2522
|
-
const f = !u && /^\.[\\\/]/.test(e) ? e.slice(0, 2) + d : d;
|
|
2523
|
-
for(let e = 0; e < i.length; e++){
|
|
2524
|
-
const n = f + i[e];
|
|
2525
|
-
try {
|
|
2526
|
-
if (a.sync(n, {
|
|
2527
|
-
pathExt: c
|
|
2528
|
-
})) if (!t.all) return n;
|
|
2529
|
-
else l.push(n);
|
|
2530
|
-
} catch (e) {}
|
|
2531
|
-
}
|
|
2532
|
-
}
|
|
2533
|
-
if (t.all && l.length) return l;
|
|
2534
|
-
if (t.nothrow) return null;
|
|
2535
|
-
throw o(e);
|
|
2536
|
-
};
|
|
2537
|
-
t.exports = c;
|
|
2538
|
-
c.sync = l;
|
|
2539
|
-
});
|
|
2540
|
-
var main_S = /* @__PURE__ */ main_u((e, t)=>{
|
|
2541
|
-
const n = (e = {})=>{
|
|
2542
|
-
const t = e.env || process.env;
|
|
2543
|
-
if ("win32" !== (e.platform || process.platform)) return "PATH";
|
|
2544
|
-
return Object.keys(t).reverse().find((e)=>"PATH" === e.toUpperCase()) || "Path";
|
|
2545
|
-
};
|
|
2546
|
-
t.exports = n;
|
|
2547
|
-
t.exports.default = n;
|
|
2548
|
-
});
|
|
2549
|
-
var main_C = /* @__PURE__ */ main_u((e, t)=>{
|
|
2550
|
-
const n = main_d("path");
|
|
2551
|
-
const r = main_x();
|
|
2552
|
-
const i = main_S();
|
|
2553
|
-
function a(e, t) {
|
|
2554
|
-
const a = e.options.env || process.env;
|
|
2555
|
-
const o = process.cwd();
|
|
2556
|
-
const s = null != e.options.cwd;
|
|
2557
|
-
const c = s && void 0 !== process.chdir && !process.chdir.disabled;
|
|
2558
|
-
if (c) try {
|
|
2559
|
-
process.chdir(e.options.cwd);
|
|
2560
|
-
} catch (e) {}
|
|
2561
|
-
let l;
|
|
2562
|
-
try {
|
|
2563
|
-
l = r.sync(e.command, {
|
|
2564
|
-
path: a[i({
|
|
2565
|
-
env: a
|
|
2566
|
-
})],
|
|
2567
|
-
pathExt: t ? n.delimiter : void 0
|
|
2568
|
-
});
|
|
2569
|
-
} catch (e) {} finally{
|
|
2570
|
-
if (c) process.chdir(o);
|
|
2571
|
-
}
|
|
2572
|
-
if (l) l = n.resolve(s ? e.options.cwd : "", l);
|
|
2573
|
-
return l;
|
|
2574
|
-
}
|
|
2575
|
-
function o(e) {
|
|
2576
|
-
return a(e) || a(e, true);
|
|
2577
|
-
}
|
|
2578
|
-
t.exports = o;
|
|
2579
|
-
});
|
|
2580
|
-
var main_w = /* @__PURE__ */ main_u((e, t)=>{
|
|
2581
|
-
const n = /([()\][%!^"`<>&|;, *?])/g;
|
|
2582
|
-
function r(e) {
|
|
2583
|
-
e = e.replace(n, "^$1");
|
|
2584
|
-
return e;
|
|
2585
|
-
}
|
|
2586
|
-
function i(e, t) {
|
|
2587
|
-
e = `${e}`;
|
|
2588
|
-
e = e.replace(/(?=(\\+?)?)\1"/g, "$1$1\\\"");
|
|
2589
|
-
e = e.replace(/(?=(\\+?)?)\1$/, "$1$1");
|
|
2590
|
-
e = `"${e}"`;
|
|
2591
|
-
e = e.replace(n, "^$1");
|
|
2592
|
-
if (t) e = e.replace(n, "^$1");
|
|
2593
|
-
return e;
|
|
2594
|
-
}
|
|
2595
|
-
t.exports.command = r;
|
|
2596
|
-
t.exports.argument = i;
|
|
2597
|
-
});
|
|
2598
|
-
var main_T = /* @__PURE__ */ main_u((e, t)=>{
|
|
2599
|
-
t.exports = /^#!(.*)/;
|
|
2600
|
-
});
|
|
2601
|
-
var main_E = /* @__PURE__ */ main_u((e, t)=>{
|
|
2602
|
-
const n = main_T();
|
|
2603
|
-
t.exports = (e = "")=>{
|
|
2604
|
-
const t = e.match(n);
|
|
2605
|
-
if (!t) return null;
|
|
2606
|
-
const [r, i] = t[0].replace(/#! ?/, "").split(" ");
|
|
2607
|
-
const a = r.split("/").pop();
|
|
2608
|
-
if ("env" === a) return i;
|
|
2609
|
-
return i ? `${a} ${i}` : a;
|
|
2610
|
-
};
|
|
2611
|
-
});
|
|
2612
|
-
var main_D = /* @__PURE__ */ main_u((e, t)=>{
|
|
2613
|
-
const n = main_d("fs");
|
|
2614
|
-
const r = main_E();
|
|
2615
|
-
function i(e) {
|
|
2616
|
-
const t = 150;
|
|
2617
|
-
const i = Buffer.alloc(t);
|
|
2618
|
-
let a;
|
|
2619
|
-
try {
|
|
2620
|
-
a = n.openSync(e, "r");
|
|
2621
|
-
n.readSync(a, i, 0, t, 0);
|
|
2622
|
-
n.closeSync(a);
|
|
2623
|
-
} catch (e) {}
|
|
2624
|
-
return r(i.toString());
|
|
2625
|
-
}
|
|
2626
|
-
t.exports = i;
|
|
2627
|
-
});
|
|
2628
|
-
var main_O = /* @__PURE__ */ main_u((e, t)=>{
|
|
2629
|
-
const n = main_d("path");
|
|
2630
|
-
const r = main_C();
|
|
2631
|
-
const i = main_w();
|
|
2632
|
-
const a = main_D();
|
|
2633
|
-
const o = "win32" === process.platform;
|
|
2634
|
-
const s = /\.(?:com|exe)$/i;
|
|
2635
|
-
const c = /node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;
|
|
2636
|
-
function l(e) {
|
|
2637
|
-
e.file = r(e);
|
|
2638
|
-
const t = e.file && a(e.file);
|
|
2639
|
-
if (t) {
|
|
2640
|
-
e.args.unshift(e.file);
|
|
2641
|
-
e.command = t;
|
|
2642
|
-
return r(e);
|
|
2643
|
-
}
|
|
2644
|
-
return e.file;
|
|
2645
|
-
}
|
|
2646
|
-
function u(e) {
|
|
2647
|
-
if (!o) return e;
|
|
2648
|
-
const t = l(e);
|
|
2649
|
-
const r = !s.test(t);
|
|
2650
|
-
if (e.options.forceShell || r) {
|
|
2651
|
-
const r = c.test(t);
|
|
2652
|
-
e.command = n.normalize(e.command);
|
|
2653
|
-
e.command = i.command(e.command);
|
|
2654
|
-
e.args = e.args.map((e)=>i.argument(e, r));
|
|
2655
|
-
e.args = [
|
|
2656
|
-
"/d",
|
|
2657
|
-
"/s",
|
|
2658
|
-
"/c",
|
|
2659
|
-
`"${[
|
|
2660
|
-
e.command
|
|
2661
|
-
].concat(e.args).join(" ")}"`
|
|
2662
|
-
];
|
|
2663
|
-
e.command = process.env.comspec || "cmd.exe";
|
|
2664
|
-
e.options.windowsVerbatimArguments = true;
|
|
2665
|
-
}
|
|
2666
|
-
return e;
|
|
2667
|
-
}
|
|
2668
|
-
function f(e, t, n) {
|
|
2669
|
-
if (t && !Array.isArray(t)) {
|
|
2670
|
-
n = t;
|
|
2671
|
-
t = null;
|
|
2672
|
-
}
|
|
2673
|
-
t = t ? t.slice(0) : [];
|
|
2674
|
-
n = Object.assign({}, n);
|
|
2675
|
-
const r = {
|
|
2676
|
-
command: e,
|
|
2677
|
-
args: t,
|
|
2678
|
-
options: n,
|
|
2679
|
-
file: void 0,
|
|
2680
|
-
original: {
|
|
2681
|
-
command: e,
|
|
2682
|
-
args: t
|
|
2683
|
-
}
|
|
2684
|
-
};
|
|
2685
|
-
return n.shell ? r : u(r);
|
|
2686
|
-
}
|
|
2687
|
-
t.exports = f;
|
|
2688
|
-
});
|
|
2689
|
-
var main_k = /* @__PURE__ */ main_u((e, t)=>{
|
|
2690
|
-
const n = "win32" === process.platform;
|
|
2691
|
-
function r(e, t) {
|
|
2692
|
-
return Object.assign(/* @__PURE__ */ new Error(`${t} ${e.command} ENOENT`), {
|
|
2693
|
-
code: "ENOENT",
|
|
2694
|
-
errno: "ENOENT",
|
|
2695
|
-
syscall: `${t} ${e.command}`,
|
|
2696
|
-
path: e.command,
|
|
2697
|
-
spawnargs: e.args
|
|
2698
|
-
});
|
|
2699
|
-
}
|
|
2700
|
-
function i(e, t) {
|
|
2701
|
-
if (!n) return;
|
|
2702
|
-
const r = e.emit;
|
|
2703
|
-
e.emit = function(n, i) {
|
|
2704
|
-
if ("exit" === n) {
|
|
2705
|
-
const n = a(i, t);
|
|
2706
|
-
if (n) return r.call(e, "error", n);
|
|
92
|
+
{
|
|
93
|
+
value: 'node',
|
|
94
|
+
label: 'Node.js'
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
value: 'react',
|
|
98
|
+
label: 'React'
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
value: 'vue',
|
|
102
|
+
label: 'Vue'
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
value: 'svelte',
|
|
106
|
+
label: 'Svelte'
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
value: 'solid',
|
|
110
|
+
label: 'Solid'
|
|
2707
111
|
}
|
|
2708
|
-
|
|
2709
|
-
};
|
|
2710
|
-
}
|
|
2711
|
-
function a(e, t) {
|
|
2712
|
-
if (n && 1 === e && !t.file) return r(t.original, "spawn");
|
|
2713
|
-
return null;
|
|
2714
|
-
}
|
|
2715
|
-
function o(e, t) {
|
|
2716
|
-
if (n && 1 === e && !t.file) return r(t.original, "spawnSync");
|
|
2717
|
-
return null;
|
|
2718
|
-
}
|
|
2719
|
-
t.exports = {
|
|
2720
|
-
hookChildProcess: i,
|
|
2721
|
-
verifyENOENT: a,
|
|
2722
|
-
verifyENOENTSync: o,
|
|
2723
|
-
notFoundError: r
|
|
2724
|
-
};
|
|
2725
|
-
});
|
|
2726
|
-
var main_A = /* @__PURE__ */ main_u((e, t)=>{
|
|
2727
|
-
const n = main_d("child_process");
|
|
2728
|
-
const r = main_O();
|
|
2729
|
-
const i = main_k();
|
|
2730
|
-
function a(e, t, a) {
|
|
2731
|
-
const o = r(e, t, a);
|
|
2732
|
-
const s = n.spawn(o.command, o.args, o.options);
|
|
2733
|
-
i.hookChildProcess(s, o);
|
|
2734
|
-
return s;
|
|
2735
|
-
}
|
|
2736
|
-
function o(e, t, a) {
|
|
2737
|
-
const o = r(e, t, a);
|
|
2738
|
-
const s = n.spawnSync(o.command, o.args, o.options);
|
|
2739
|
-
s.error = s.error || i.verifyENOENTSync(s.status, o);
|
|
2740
|
-
return s;
|
|
2741
|
-
}
|
|
2742
|
-
t.exports = a;
|
|
2743
|
-
t.exports.spawn = a;
|
|
2744
|
-
t.exports.sync = o;
|
|
2745
|
-
t.exports._parse = r;
|
|
2746
|
-
t.exports._enoent = i;
|
|
2747
|
-
});
|
|
2748
|
-
var main_j = main_A();
|
|
2749
|
-
var main_M = class extends Error {
|
|
2750
|
-
get exitCode() {
|
|
2751
|
-
if (null !== this.result.exitCode) return this.result.exitCode;
|
|
2752
|
-
}
|
|
2753
|
-
constructor(e, t){
|
|
2754
|
-
super(`Process exited with non-zero status (${e.exitCode})`);
|
|
2755
|
-
this.result = e;
|
|
2756
|
-
this.output = t;
|
|
2757
|
-
}
|
|
2758
|
-
};
|
|
2759
|
-
const main_P = {
|
|
2760
|
-
timeout: void 0,
|
|
2761
|
-
persist: false
|
|
2762
|
-
};
|
|
2763
|
-
const main_I = {
|
|
2764
|
-
windowsHide: true
|
|
2765
|
-
};
|
|
2766
|
-
function main_L(e) {
|
|
2767
|
-
const t = new AbortController();
|
|
2768
|
-
for (const n of e){
|
|
2769
|
-
if (n.aborted) {
|
|
2770
|
-
t.abort();
|
|
2771
|
-
return n;
|
|
2772
|
-
}
|
|
2773
|
-
const e = ()=>{
|
|
2774
|
-
t.abort(n.reason);
|
|
2775
|
-
};
|
|
2776
|
-
n.addEventListener("abort", e, {
|
|
2777
|
-
signal: t.signal
|
|
2778
|
-
});
|
|
2779
|
-
}
|
|
2780
|
-
return t.signal;
|
|
2781
|
-
}
|
|
2782
|
-
async function main_R(e) {
|
|
2783
|
-
let t = "";
|
|
2784
|
-
try {
|
|
2785
|
-
for await (const n of e)t += n.toString();
|
|
2786
|
-
} catch {}
|
|
2787
|
-
return t;
|
|
2788
|
-
}
|
|
2789
|
-
var main_z = class {
|
|
2790
|
-
_process;
|
|
2791
|
-
_aborted = false;
|
|
2792
|
-
_options;
|
|
2793
|
-
_command;
|
|
2794
|
-
_args;
|
|
2795
|
-
_resolveClose;
|
|
2796
|
-
_processClosed;
|
|
2797
|
-
_thrownError;
|
|
2798
|
-
get process() {
|
|
2799
|
-
return this._process;
|
|
2800
|
-
}
|
|
2801
|
-
get pid() {
|
|
2802
|
-
return this._process?.pid;
|
|
2803
|
-
}
|
|
2804
|
-
get exitCode() {
|
|
2805
|
-
if (this._process && null !== this._process.exitCode) return this._process.exitCode;
|
|
2806
|
-
}
|
|
2807
|
-
constructor(e, t, n){
|
|
2808
|
-
this._options = {
|
|
2809
|
-
...main_P,
|
|
2810
|
-
...n
|
|
2811
|
-
};
|
|
2812
|
-
this._command = e;
|
|
2813
|
-
this._args = t ?? [];
|
|
2814
|
-
this._processClosed = new Promise((e)=>{
|
|
2815
|
-
this._resolveClose = e;
|
|
2816
|
-
});
|
|
2817
|
-
}
|
|
2818
|
-
kill(e) {
|
|
2819
|
-
return this._process?.kill(e) === true;
|
|
2820
|
-
}
|
|
2821
|
-
get aborted() {
|
|
2822
|
-
return this._aborted;
|
|
2823
|
-
}
|
|
2824
|
-
get killed() {
|
|
2825
|
-
return this._process?.killed === true;
|
|
2826
|
-
}
|
|
2827
|
-
pipe(e, t, n) {
|
|
2828
|
-
return main_H(e, t, {
|
|
2829
|
-
...n,
|
|
2830
|
-
stdin: this
|
|
2831
|
-
});
|
|
2832
|
-
}
|
|
2833
|
-
async *[Symbol.asyncIterator]() {
|
|
2834
|
-
const e = this._process;
|
|
2835
|
-
if (!e) return;
|
|
2836
|
-
const t = [];
|
|
2837
|
-
if (this._streamErr) t.push(this._streamErr);
|
|
2838
|
-
if (this._streamOut) t.push(this._streamOut);
|
|
2839
|
-
const n = main_(t);
|
|
2840
|
-
const r = node_readline.createInterface({
|
|
2841
|
-
input: n
|
|
2842
|
-
});
|
|
2843
|
-
for await (const e of r)yield e.toString();
|
|
2844
|
-
await this._processClosed;
|
|
2845
|
-
e.removeAllListeners();
|
|
2846
|
-
if (this._thrownError) throw this._thrownError;
|
|
2847
|
-
if (this._options?.throwOnError && 0 !== this.exitCode && void 0 !== this.exitCode) throw new main_M(this);
|
|
2848
|
-
}
|
|
2849
|
-
async _waitForOutput() {
|
|
2850
|
-
const e = this._process;
|
|
2851
|
-
if (!e) throw new Error("No process was started");
|
|
2852
|
-
const [t, n] = await Promise.all([
|
|
2853
|
-
this._streamOut ? main_R(this._streamOut) : "",
|
|
2854
|
-
this._streamErr ? main_R(this._streamErr) : ""
|
|
2855
|
-
]);
|
|
2856
|
-
await this._processClosed;
|
|
2857
|
-
const { stdin: r } = this._options;
|
|
2858
|
-
if (r && "string" != typeof r) await r;
|
|
2859
|
-
e.removeAllListeners();
|
|
2860
|
-
if (this._thrownError) throw this._thrownError;
|
|
2861
|
-
const i = {
|
|
2862
|
-
stderr: n,
|
|
2863
|
-
stdout: t,
|
|
2864
|
-
exitCode: this.exitCode
|
|
2865
|
-
};
|
|
2866
|
-
if (this._options.throwOnError && 0 !== this.exitCode && void 0 !== this.exitCode) throw new main_M(this, i);
|
|
2867
|
-
return i;
|
|
2868
|
-
}
|
|
2869
|
-
then(e, t) {
|
|
2870
|
-
return this._waitForOutput().then(e, t);
|
|
2871
|
-
}
|
|
2872
|
-
_streamOut;
|
|
2873
|
-
_streamErr;
|
|
2874
|
-
spawn() {
|
|
2875
|
-
const e = external_node_process_cwd();
|
|
2876
|
-
const n = this._options;
|
|
2877
|
-
const i = {
|
|
2878
|
-
...main_I,
|
|
2879
|
-
...n.nodeOptions
|
|
2880
|
-
};
|
|
2881
|
-
const a = [];
|
|
2882
|
-
this._resetState();
|
|
2883
|
-
if (void 0 !== n.timeout) a.push(AbortSignal.timeout(n.timeout));
|
|
2884
|
-
if (void 0 !== n.signal) a.push(n.signal);
|
|
2885
|
-
if (true === n.persist) i.detached = true;
|
|
2886
|
-
if (a.length > 0) i.signal = main_L(a);
|
|
2887
|
-
i.env = main_g(e, i.env);
|
|
2888
|
-
const o = (0, main_j._parse)(this._command, this._args, i);
|
|
2889
|
-
const s = spawn(o.command, o.args, o.options);
|
|
2890
|
-
if (s.stderr) this._streamErr = s.stderr;
|
|
2891
|
-
if (s.stdout) this._streamOut = s.stdout;
|
|
2892
|
-
this._process = s;
|
|
2893
|
-
s.once("error", this._onError);
|
|
2894
|
-
s.once("close", this._onClose);
|
|
2895
|
-
if (s.stdin) {
|
|
2896
|
-
const { stdin: e } = n;
|
|
2897
|
-
if ("string" == typeof e) s.stdin.end(e);
|
|
2898
|
-
else e?.process?.stdout?.pipe(s.stdin);
|
|
2899
|
-
}
|
|
2900
|
-
}
|
|
2901
|
-
_resetState() {
|
|
2902
|
-
this._aborted = false;
|
|
2903
|
-
this._processClosed = new Promise((e)=>{
|
|
2904
|
-
this._resolveClose = e;
|
|
2905
|
-
});
|
|
2906
|
-
this._thrownError = void 0;
|
|
2907
|
-
}
|
|
2908
|
-
_onError = (e)=>{
|
|
2909
|
-
if ("AbortError" === e.name && (!(e.cause instanceof Error) || "TimeoutError" !== e.cause.name)) {
|
|
2910
|
-
this._aborted = true;
|
|
2911
|
-
return;
|
|
2912
|
-
}
|
|
2913
|
-
this._thrownError = e;
|
|
2914
|
-
};
|
|
2915
|
-
_onClose = ()=>{
|
|
2916
|
-
if (this._resolveClose) this._resolveClose();
|
|
2917
|
-
};
|
|
2918
|
-
};
|
|
2919
|
-
const main_V = (e, t, n)=>{
|
|
2920
|
-
const r = new main_z(e, t, n);
|
|
2921
|
-
r.spawn();
|
|
2922
|
-
return r;
|
|
2923
|
-
};
|
|
2924
|
-
const main_H = main_V;
|
|
2925
|
-
const NPM_TEMPLATE_PREFIX = 'npm:';
|
|
2926
|
-
const VALID_NPM_NAME = /^(@[\w.-]+\/)?[\w.-]+$/;
|
|
2927
|
-
const VALID_NPM_VERSION = /^[\w.\-+^~>=<* ]+$/;
|
|
2928
|
-
const sanitizeCacheKey = (packageName, version)=>{
|
|
2929
|
-
const normalized = packageName.startsWith('@') ? packageName : packageName.replace(/[\\/]/g, '_');
|
|
2930
|
-
const versionLabel = version || 'latest';
|
|
2931
|
-
return `${normalized}@${versionLabel}`;
|
|
2932
|
-
};
|
|
2933
|
-
function isNpmTemplate(templateInput) {
|
|
2934
|
-
const trimmedInput = templateInput.trim();
|
|
2935
|
-
if (trimmedInput.startsWith(NPM_TEMPLATE_PREFIX)) return true;
|
|
2936
|
-
if (trimmedInput.startsWith('@') || !trimmedInput.includes('/') && !trimmedInput.startsWith('http') && !trimmedInput.startsWith('.') && !trimmedInput.startsWith('github:')) return true;
|
|
2937
|
-
return false;
|
|
2938
|
-
}
|
|
2939
|
-
function resolveNpmTemplate(packageName, version, options) {
|
|
2940
|
-
const normalizedName = packageName.trim();
|
|
2941
|
-
const versionSpecifier = version?.trim() && 'latest' !== version.trim().toLowerCase() ? version.trim() : 'latest';
|
|
2942
|
-
if (!VALID_NPM_NAME.test(normalizedName)) throw new Error(`Invalid npm package name: "${normalizedName}". Package names may only contain word characters, hyphens, and dots.`);
|
|
2943
|
-
if ('latest' !== versionSpecifier && !VALID_NPM_VERSION.test(versionSpecifier)) throw new Error(`Invalid version specifier: "${versionSpecifier}". Version may only contain word characters, dots, hyphens, and range operators.`);
|
|
2944
|
-
const cacheKey = sanitizeCacheKey(normalizedName, versionSpecifier);
|
|
2945
|
-
const cacheRoot = options?.cacheDir || process.cwd();
|
|
2946
|
-
const templateDir = node_path.join(cacheRoot, '.temp-templates', cacheKey);
|
|
2947
|
-
const installRoot = node_path.join(templateDir, '.install');
|
|
2948
|
-
const packagePath = node_path.join(installRoot, 'node_modules', normalizedName);
|
|
2949
|
-
const forceLatest = options?.forceLatest ?? 'latest' === versionSpecifier;
|
|
2950
|
-
const shouldReuseCache = !forceLatest && node_fs.existsSync(templateDir);
|
|
2951
|
-
if (shouldReuseCache) return templateDir;
|
|
2952
|
-
node_fs.mkdirSync(installRoot, {
|
|
2953
|
-
recursive: true
|
|
2954
|
-
});
|
|
2955
|
-
const anchorPkgJson = node_path.join(installRoot, 'package.json');
|
|
2956
|
-
if (!node_fs.existsSync(anchorPkgJson)) {
|
|
2957
|
-
const minimal = {
|
|
2958
|
-
name: 'create-rstack-template-cache',
|
|
2959
|
-
private: true
|
|
2960
|
-
};
|
|
2961
|
-
node_fs.writeFileSync(anchorPkgJson, `${JSON.stringify(minimal, null, 2)}\n`, 'utf8');
|
|
2962
|
-
}
|
|
2963
|
-
try {
|
|
2964
|
-
execFileSync('npm', [
|
|
2965
|
-
'install',
|
|
2966
|
-
`${normalizedName}@${versionSpecifier}`,
|
|
2967
|
-
'--no-save',
|
|
2968
|
-
'--package-lock=false',
|
|
2969
|
-
'--no-audit',
|
|
2970
|
-
'--no-fund',
|
|
2971
|
-
'--silent'
|
|
2972
|
-
], {
|
|
2973
|
-
cwd: installRoot,
|
|
2974
|
-
stdio: 'pipe'
|
|
2975
|
-
});
|
|
2976
|
-
} catch (err) {
|
|
2977
|
-
const stderr = err instanceof Error && 'stderr' in err ? String(err.stderr).trim() : '';
|
|
2978
|
-
const detail = stderr ? `\n${stderr.split('\n').slice(0, 5).join('\n')}` : '';
|
|
2979
|
-
throw new Error(`Failed to install npm template "${normalizedName}@${versionSpecifier}". Please check if the package exists.${detail}`);
|
|
2980
|
-
}
|
|
2981
|
-
const possibleTemplatePaths = [
|
|
2982
|
-
node_path.join(packagePath, 'template'),
|
|
2983
|
-
node_path.join(packagePath, 'templates', 'app'),
|
|
2984
|
-
node_path.join(packagePath, 'templates', 'default'),
|
|
2985
|
-
packagePath
|
|
2986
|
-
];
|
|
2987
|
-
for (const pathCandidate of possibleTemplatePaths)if (node_fs.existsSync(pathCandidate) && node_fs.statSync(pathCandidate).isDirectory()) {
|
|
2988
|
-
if (node_fs.existsSync(templateDir)) {
|
|
2989
|
-
for (const entry of node_fs.readdirSync(templateDir))if ('.install' !== entry) node_fs.rmSync(node_path.join(templateDir, entry), {
|
|
2990
|
-
recursive: true,
|
|
2991
|
-
force: true
|
|
2992
|
-
});
|
|
2993
|
-
}
|
|
2994
|
-
node_fs.cpSync(pathCandidate, templateDir, {
|
|
2995
|
-
recursive: true
|
|
2996
|
-
});
|
|
2997
|
-
return templateDir;
|
|
2998
|
-
}
|
|
2999
|
-
throw new Error(`No valid template directory found in package "${normalizedName}". Expected one of: template/, templates/app/, templates/default/, or package root.`);
|
|
3000
|
-
}
|
|
3001
|
-
function resolveCustomTemplate(templateInput, version, options) {
|
|
3002
|
-
const trimmedInput = templateInput.trim();
|
|
3003
|
-
if (trimmedInput.startsWith(NPM_TEMPLATE_PREFIX)) {
|
|
3004
|
-
const packageName = trimmedInput.slice(NPM_TEMPLATE_PREFIX.length).trim();
|
|
3005
|
-
return resolveNpmTemplate(packageName, version, options);
|
|
3006
|
-
}
|
|
3007
|
-
if (isNpmTemplate(trimmedInput)) return resolveNpmTemplate(trimmedInput, version, options);
|
|
3008
|
-
return trimmedInput;
|
|
3009
|
-
}
|
|
3010
|
-
const dist_0 = __webpack_require__("./node_modules/.pnpm/@vercel+detect-agent@1.2.3/node_modules/@vercel/detect-agent/dist/index.js");
|
|
3011
|
-
const cjs = __webpack_require__("./node_modules/.pnpm/deepmerge@4.3.1/node_modules/deepmerge/dist/cjs.js");
|
|
3012
|
-
var cjs_default = /*#__PURE__*/ __webpack_require__.n(cjs);
|
|
3013
|
-
const minimist = __webpack_require__("./node_modules/.pnpm/minimist@1.2.8/node_modules/minimist/index.js");
|
|
3014
|
-
var minimist_default = /*#__PURE__*/ __webpack_require__.n(minimist);
|
|
3015
|
-
const src_filename = fileURLToPath(import.meta.url);
|
|
3016
|
-
const src_dirname = dirname(src_filename);
|
|
3017
|
-
function cancelAndExit() {
|
|
3018
|
-
me('Operation cancelled.');
|
|
3019
|
-
process.exit(0);
|
|
3020
|
-
}
|
|
3021
|
-
function checkCancel(value) {
|
|
3022
|
-
if (dist_q(value)) cancelAndExit();
|
|
3023
|
-
return value;
|
|
3024
|
-
}
|
|
3025
|
-
function formatProjectName(input) {
|
|
3026
|
-
const formatted = input.trim().replace(/\/+$/g, '');
|
|
3027
|
-
return {
|
|
3028
|
-
packageName: formatted.startsWith('@') ? formatted : node_path.basename(formatted),
|
|
3029
|
-
targetDir: formatted
|
|
3030
|
-
};
|
|
3031
|
-
}
|
|
3032
|
-
function pkgFromUserAgent(userAgent) {
|
|
3033
|
-
if (!userAgent) return;
|
|
3034
|
-
const pkgSpec = userAgent.split(' ')[0];
|
|
3035
|
-
const pkgSpecArr = pkgSpec.split('/');
|
|
3036
|
-
return {
|
|
3037
|
-
name: pkgSpecArr[0],
|
|
3038
|
-
version: pkgSpecArr[1]
|
|
3039
|
-
};
|
|
3040
|
-
}
|
|
3041
|
-
function isEmptyDir(path) {
|
|
3042
|
-
const files = node_fs.readdirSync(path);
|
|
3043
|
-
return 0 === files.length || 1 === files.length && '.git' === files[0];
|
|
3044
|
-
}
|
|
3045
|
-
function parseToolsOption(tools) {
|
|
3046
|
-
if (void 0 === tools) return null;
|
|
3047
|
-
const toolsArr = Array.isArray(tools) ? tools : [
|
|
3048
|
-
tools
|
|
3049
|
-
];
|
|
3050
|
-
return toolsArr.flatMap((tool)=>tool.split(',')).map((tool)=>tool.trim()).filter(Boolean);
|
|
3051
|
-
}
|
|
3052
|
-
function parseSkillsOption(skills) {
|
|
3053
|
-
if (void 0 === skills) return null;
|
|
3054
|
-
const skillsArr = Array.isArray(skills) ? skills : [
|
|
3055
|
-
skills
|
|
3056
|
-
];
|
|
3057
|
-
return skillsArr.flatMap((skill)=>skill.split(',')).map((skill)=>skill.trim()).filter(Boolean);
|
|
3058
|
-
}
|
|
3059
|
-
const BUILTIN_TOOLS = [
|
|
3060
|
-
'eslint',
|
|
3061
|
-
'rslint',
|
|
3062
|
-
'biome',
|
|
3063
|
-
'prettier'
|
|
3064
|
-
];
|
|
3065
|
-
function logHelpMessage(name, templates, extraTools, extraSkills) {
|
|
3066
|
-
const toolsList = [
|
|
3067
|
-
...BUILTIN_TOOLS
|
|
3068
|
-
];
|
|
3069
|
-
const skillsList = (extraSkills ?? []).map((skill)=>skill.value).filter(Boolean);
|
|
3070
|
-
const hasSkills = skillsList.length > 0;
|
|
3071
|
-
if (extraTools) {
|
|
3072
|
-
for (const tool of extraTools)if (tool.value) if ('pre' === tool.order) toolsList.unshift(tool.value);
|
|
3073
|
-
else toolsList.push(tool.value);
|
|
3074
|
-
}
|
|
3075
|
-
const skillsOptionLine = hasSkills ? ' --skill <skill> add optional skills, comma separated\n' : '';
|
|
3076
|
-
const optionalSkillsSection = hasSkills ? `
|
|
3077
|
-
Optional skills:
|
|
3078
|
-
${skillsList.join(', ')}` : '';
|
|
3079
|
-
src_logger.log(`
|
|
3080
|
-
Usage: create-${name} [dir] [options]
|
|
3081
|
-
|
|
3082
|
-
Options:
|
|
3083
|
-
|
|
3084
|
-
-h, --help display help for command
|
|
3085
|
-
-d, --dir <dir> create project in specified directory
|
|
3086
|
-
-t, --template <tpl> specify the template to use
|
|
3087
|
-
--tools <tool> add additional tools, comma separated
|
|
3088
|
-
${skillsOptionLine} --override override files in target directory
|
|
3089
|
-
--packageName <name> specify the package name
|
|
3090
|
-
--template-version <ver> specify the npm template version
|
|
3091
|
-
|
|
3092
|
-
Available templates:
|
|
3093
|
-
${templates.join(', ')}
|
|
3094
|
-
|
|
3095
|
-
Optional tools:
|
|
3096
|
-
${toolsList.join(', ')}${optionalSkillsSection}
|
|
3097
|
-
`);
|
|
3098
|
-
}
|
|
3099
|
-
async function getTools({ tools, dir, template }, extraTools, templateName) {
|
|
3100
|
-
const parsedTools = parseToolsOption(tools);
|
|
3101
|
-
const filteredExtraTools = extraTools?.filter((tool)=>{
|
|
3102
|
-
const when = tool.when ?? (()=>true);
|
|
3103
|
-
return templateName ? when({
|
|
3104
|
-
templateName
|
|
3105
|
-
}) : true;
|
|
3106
|
-
});
|
|
3107
|
-
if (null !== parsedTools) {
|
|
3108
|
-
const toolsArr = parsedTools.filter((tool)=>BUILTIN_TOOLS.includes(tool) || filteredExtraTools?.some((extraTool)=>extraTool.value === tool));
|
|
3109
|
-
return toolsArr;
|
|
3110
|
-
}
|
|
3111
|
-
if (dir && template) return [];
|
|
3112
|
-
const options = [
|
|
3113
|
-
{
|
|
3114
|
-
value: 'rslint',
|
|
3115
|
-
label: 'Rslint - linting'
|
|
3116
|
-
},
|
|
3117
|
-
{
|
|
3118
|
-
value: 'eslint',
|
|
3119
|
-
label: 'ESLint - linting'
|
|
3120
|
-
},
|
|
3121
|
-
{
|
|
3122
|
-
value: 'prettier',
|
|
3123
|
-
label: 'Prettier - formatting'
|
|
3124
|
-
},
|
|
3125
|
-
{
|
|
3126
|
-
value: 'biome',
|
|
3127
|
-
label: 'Biome - linting & formatting'
|
|
3128
|
-
}
|
|
3129
|
-
];
|
|
3130
|
-
if (filteredExtraTools) {
|
|
3131
|
-
const normalize = (tool)=>({
|
|
3132
|
-
value: tool.value,
|
|
3133
|
-
label: tool.label,
|
|
3134
|
-
hint: tool.command
|
|
3135
|
-
});
|
|
3136
|
-
options.unshift(...filteredExtraTools.filter((tool)=>'pre' === tool.order).map(normalize));
|
|
3137
|
-
options.push(...filteredExtraTools.filter((tool)=>'pre' !== tool.order).map(normalize));
|
|
3138
|
-
}
|
|
3139
|
-
return checkCancel(await ve({
|
|
3140
|
-
message: 'Select additional tools (Use <space> to select, <enter> to continue)',
|
|
3141
|
-
options,
|
|
3142
|
-
required: false
|
|
112
|
+
]
|
|
3143
113
|
}));
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
return [
|
|
3157
|
-
...extraSkills.filter((extraSkill)=>'pre' === extraSkill.order),
|
|
3158
|
-
...extraSkills.filter((extraSkill)=>void 0 === extraSkill.order),
|
|
3159
|
-
...extraSkills.filter((extraSkill)=>'post' === extraSkill.order)
|
|
3160
|
-
];
|
|
3161
|
-
}
|
|
3162
|
-
async function getSkills({ skill, dir, template }, extraSkills, templateName, tools = [], promptMultiselect = ve) {
|
|
3163
|
-
const parsedSkills = parseSkillsOption(skill);
|
|
3164
|
-
const filteredExtraSkills = filterExtraSkills(extraSkills, templateName, tools);
|
|
3165
|
-
if (null !== parsedSkills) return parsedSkills.filter((value)=>extraSkills?.some((extraSkill)=>extraSkill.value === value));
|
|
3166
|
-
if (dir && template) return [];
|
|
3167
|
-
if (!filteredExtraSkills?.length) return [];
|
|
3168
|
-
const orderedExtraSkills = orderExtraSkills(filteredExtraSkills);
|
|
3169
|
-
return checkCancel(await promptMultiselect({
|
|
3170
|
-
message: 'Select optional skills (Use <space> to select, <enter> to continue)',
|
|
3171
|
-
options: orderedExtraSkills.map((extraSkill)=>({
|
|
3172
|
-
value: extraSkill.value,
|
|
3173
|
-
label: extraSkill.label,
|
|
3174
|
-
hint: extraSkill.source
|
|
3175
|
-
})),
|
|
3176
|
-
required: false
|
|
114
|
+
const language = checkCancel(await create_toolkit_select({
|
|
115
|
+
message: 'Select language',
|
|
116
|
+
options: [
|
|
117
|
+
{
|
|
118
|
+
value: 'ts',
|
|
119
|
+
label: 'TypeScript'
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
value: 'js',
|
|
123
|
+
label: 'JavaScript'
|
|
124
|
+
}
|
|
125
|
+
]
|
|
3177
126
|
}));
|
|
3178
|
-
}
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
}
|
|
3191
|
-
});
|
|
3192
|
-
if (!argv.dir && argv._[0]) argv.dir = argv._[0];
|
|
3193
|
-
if (argv['package-name']) argv.packageName = argv['package-name'];
|
|
3194
|
-
if (argv['template-version']) argv.templateVersion = argv['template-version'];
|
|
3195
|
-
return argv;
|
|
3196
|
-
};
|
|
3197
|
-
async function runCommand(command, cwd, packageManager) {
|
|
3198
|
-
if (command.startsWith('npm create ')) {
|
|
3199
|
-
const createReplacements = {
|
|
3200
|
-
bun: 'bun create ',
|
|
3201
|
-
pnpm: 'pnpm create ',
|
|
3202
|
-
yarn: 'yarn create ',
|
|
3203
|
-
deno: 'deno run -A npm:create-'
|
|
3204
|
-
};
|
|
3205
|
-
const replacement = createReplacements[packageManager];
|
|
3206
|
-
if (replacement) command = command.replace('npm create ', replacement).replace(' -- --', ' --');
|
|
3207
|
-
if ('yarn' === packageManager) command = command.replace('@latest', '');
|
|
3208
|
-
}
|
|
3209
|
-
const result = await main_V(command, [], {
|
|
3210
|
-
nodeOptions: {
|
|
3211
|
-
shell: true,
|
|
3212
|
-
stdio: 'inherit',
|
|
3213
|
-
cwd
|
|
3214
|
-
}
|
|
3215
|
-
});
|
|
3216
|
-
if (0 !== result.exitCode) {
|
|
3217
|
-
const details = [
|
|
3218
|
-
result.stderr,
|
|
3219
|
-
result.stdout
|
|
3220
|
-
].filter(Boolean).join('\n').trim();
|
|
3221
|
-
throw new Error(`Failed to run command: ${command}${details ? `\n${details}` : ''}`);
|
|
3222
|
-
}
|
|
3223
|
-
}
|
|
3224
|
-
async function runSkillCommand(skills, cwd) {
|
|
3225
|
-
const [firstSkill] = skills;
|
|
3226
|
-
const installArgs = skills.flatMap((skill)=>[
|
|
3227
|
-
'--skill',
|
|
3228
|
-
skill.skill ?? skill.value
|
|
3229
|
-
]);
|
|
3230
|
-
const args = [
|
|
3231
|
-
'-y',
|
|
3232
|
-
'skills',
|
|
3233
|
-
'add',
|
|
3234
|
-
firstSkill.source,
|
|
3235
|
-
'--agent',
|
|
3236
|
-
'universal',
|
|
3237
|
-
'--yes',
|
|
3238
|
-
'--copy',
|
|
3239
|
-
...installArgs
|
|
127
|
+
return `${projectType}-${templateType}-${language}`;
|
|
128
|
+
};
|
|
129
|
+
const getStagedConfig = (templateName)=>{
|
|
130
|
+
const scriptExtensions = [
|
|
131
|
+
'js',
|
|
132
|
+
'jsx',
|
|
133
|
+
'ts',
|
|
134
|
+
'tsx',
|
|
135
|
+
'mjs',
|
|
136
|
+
'cjs',
|
|
137
|
+
'mts',
|
|
138
|
+
'cts'
|
|
3240
139
|
];
|
|
3241
|
-
const
|
|
3242
|
-
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
cwd,
|
|
3251
|
-
stdio: 'pipe'
|
|
3252
|
-
}
|
|
3253
|
-
});
|
|
3254
|
-
for await (const line of proc)installationTaskLog.message(line);
|
|
3255
|
-
const result = await proc;
|
|
3256
|
-
if (0 !== result.exitCode) {
|
|
3257
|
-
const quotedSkillLabel = skills.map((skill)=>`"${skill.value}"`).join(', ');
|
|
3258
|
-
const message = `Failed to install ${skillNoun} ${quotedSkillLabel} from "${firstSkill.source}" using command: ${command}`;
|
|
3259
|
-
installationTaskLog.error(message);
|
|
3260
|
-
throw new Error(message);
|
|
3261
|
-
}
|
|
3262
|
-
installationTaskLog.success(`Installed ${skillNoun} ${skillLabel}`);
|
|
3263
|
-
}
|
|
3264
|
-
function logNextStepsAndOutro(noteInformation, targetDir, packageManager) {
|
|
3265
|
-
const nextSteps = noteInformation ? noteInformation : [
|
|
3266
|
-
`1. ${color.cyan(`cd ${targetDir}`)}`,
|
|
3267
|
-
`2. ${color.cyan('git init')} ${color.dim('(optional)')}`,
|
|
3268
|
-
`3. ${color.cyan(`${packageManager} install`)}`,
|
|
3269
|
-
`4. ${color.cyan(`${packageManager} run dev`)}`
|
|
140
|
+
const formatExtensions = [
|
|
141
|
+
'json',
|
|
142
|
+
'jsonc',
|
|
143
|
+
'md',
|
|
144
|
+
'mdx',
|
|
145
|
+
'css',
|
|
146
|
+
'html',
|
|
147
|
+
'yml',
|
|
148
|
+
'yaml'
|
|
3270
149
|
];
|
|
3271
|
-
|
|
3272
|
-
|
|
3273
|
-
|
|
3274
|
-
async function create({ name, root, templates, skipFiles, getTemplateName, mapESLintTemplate, mapRslintTemplate, version, noteInformation, extraTools, extraSkills, argv: processArgv = process.argv }) {
|
|
3275
|
-
src_logger.greet(`\n◆ Create ${upperFirst(name)} Project`);
|
|
3276
|
-
const { isAgent } = await (0, dist_0.determineAgent)();
|
|
3277
|
-
if (isAgent) {
|
|
3278
|
-
console.log('');
|
|
3279
|
-
src_logger.info(`To create a project non-interactively, run: npx -y create-${name} <DIR> --template <TEMPLATE>`);
|
|
3280
|
-
}
|
|
3281
|
-
const argv = parseArgv(processArgv);
|
|
3282
|
-
if (argv.help) return void logHelpMessage(name, templates, extraTools, extraSkills);
|
|
3283
|
-
const cwd = process.cwd();
|
|
3284
|
-
const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
|
|
3285
|
-
const packageManager = pkgInfo ? pkgInfo.name : 'npm';
|
|
3286
|
-
const templateParameters = {
|
|
3287
|
-
packageManager
|
|
3288
|
-
};
|
|
3289
|
-
if (!version) version = (await readPackageJson(root)).version;
|
|
3290
|
-
const projectName = argv.dir ?? checkCancel(await Re({
|
|
3291
|
-
message: 'Project name or path',
|
|
3292
|
-
placeholder: `${name.toLowerCase()}-project`,
|
|
3293
|
-
defaultValue: `${name.toLowerCase()}-project`,
|
|
3294
|
-
validate (value) {
|
|
3295
|
-
if (value?.length === 0) return 'Project name is required';
|
|
3296
|
-
}
|
|
3297
|
-
}));
|
|
3298
|
-
const formatted = formatProjectName(projectName);
|
|
3299
|
-
const { targetDir } = formatted;
|
|
3300
|
-
const packageName = argv.packageName || formatted.packageName;
|
|
3301
|
-
const distFolder = node_path.isAbsolute(targetDir) ? targetDir : node_path.join(cwd, targetDir);
|
|
3302
|
-
if (!argv.override && node_fs.existsSync(distFolder) && !isEmptyDir(distFolder)) {
|
|
3303
|
-
const option = checkCancel(await Ee({
|
|
3304
|
-
message: `"${targetDir}" is not empty, please choose:`,
|
|
3305
|
-
options: [
|
|
3306
|
-
{
|
|
3307
|
-
value: 'yes',
|
|
3308
|
-
label: 'Continue and override files'
|
|
3309
|
-
},
|
|
3310
|
-
{
|
|
3311
|
-
value: 'no',
|
|
3312
|
-
label: 'Cancel operation'
|
|
3313
|
-
}
|
|
3314
|
-
]
|
|
3315
|
-
}));
|
|
3316
|
-
if ('no' === option) cancelAndExit();
|
|
3317
|
-
}
|
|
3318
|
-
const templateName = await getTemplateName(argv);
|
|
3319
|
-
const srcFolder = node_path.join(root, `template-${templateName}`);
|
|
3320
|
-
if ('string' == typeof argv.template && isNpmTemplate(argv.template) && !node_fs.existsSync(srcFolder)) {
|
|
3321
|
-
const templateVersion = argv.templateVersion ?? argv['template-version'];
|
|
3322
|
-
const templatePath = resolveCustomTemplate(argv.template, templateVersion, {
|
|
3323
|
-
cacheDir: root
|
|
3324
|
-
});
|
|
3325
|
-
copyFolder({
|
|
3326
|
-
from: templatePath,
|
|
3327
|
-
to: distFolder,
|
|
3328
|
-
version,
|
|
3329
|
-
packageName,
|
|
3330
|
-
templateParameters,
|
|
3331
|
-
skipFiles
|
|
3332
|
-
});
|
|
3333
|
-
logNextStepsAndOutro(noteInformation, targetDir, packageManager);
|
|
3334
|
-
return;
|
|
3335
|
-
}
|
|
3336
|
-
const tools = await getTools(argv, extraTools, templateName);
|
|
3337
|
-
const skills = await getSkills(argv, extraSkills, templateName, tools, ve);
|
|
3338
|
-
const commonFolder = node_path.join(root, 'template-common');
|
|
3339
|
-
if (!node_fs.existsSync(srcFolder)) throw new Error(`Invalid input: template "${templateName}" not found.`);
|
|
3340
|
-
copyFolder({
|
|
3341
|
-
from: commonFolder,
|
|
3342
|
-
to: distFolder,
|
|
3343
|
-
version,
|
|
3344
|
-
skipFiles,
|
|
3345
|
-
templateParameters
|
|
3346
|
-
});
|
|
3347
|
-
copyFolder({
|
|
3348
|
-
from: srcFolder,
|
|
3349
|
-
to: distFolder,
|
|
3350
|
-
version,
|
|
3351
|
-
packageName,
|
|
3352
|
-
templateParameters,
|
|
3353
|
-
skipFiles
|
|
3354
|
-
});
|
|
3355
|
-
const skillsByValue = new Map((extraSkills ?? []).map((extraSkill)=>[
|
|
3356
|
-
extraSkill.value,
|
|
3357
|
-
extraSkill
|
|
3358
|
-
]));
|
|
3359
|
-
let currentSkillBatch = [];
|
|
3360
|
-
for (const skillValue of skills){
|
|
3361
|
-
const matchedSkill = skillsByValue.get(skillValue);
|
|
3362
|
-
if (matchedSkill) {
|
|
3363
|
-
if (currentSkillBatch.length > 0 && currentSkillBatch[0].source !== matchedSkill.source) {
|
|
3364
|
-
await runSkillCommand(currentSkillBatch, distFolder);
|
|
3365
|
-
currentSkillBatch = [];
|
|
3366
|
-
}
|
|
3367
|
-
currentSkillBatch.push(matchedSkill);
|
|
3368
|
-
}
|
|
3369
|
-
}
|
|
3370
|
-
if (currentSkillBatch.length > 0) await runSkillCommand(currentSkillBatch, distFolder);
|
|
3371
|
-
const packageRoot = node_path.resolve(src_dirname, '..');
|
|
3372
|
-
const agentsMdSearchDirs = [
|
|
3373
|
-
commonFolder,
|
|
3374
|
-
srcFolder
|
|
150
|
+
const componentExtensions = [
|
|
151
|
+
'svelte',
|
|
152
|
+
'vue'
|
|
3375
153
|
];
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
if (matchedTool) {
|
|
3380
|
-
if (matchedTool.action) await matchedTool.action({
|
|
3381
|
-
templateName,
|
|
3382
|
-
distFolder,
|
|
3383
|
-
addAgentsMdSearchDirs: (dir)=>agentsMdSearchDirs.push(dir)
|
|
3384
|
-
});
|
|
3385
|
-
if (matchedTool.command) await runCommand(matchedTool.command, distFolder, packageManager);
|
|
3386
|
-
continue;
|
|
3387
|
-
}
|
|
3388
|
-
}
|
|
3389
|
-
const toolFolder = node_path.join(packageRoot, `template-${tool}`);
|
|
3390
|
-
if ('eslint' === tool) {
|
|
3391
|
-
const eslintTemplateName = mapESLintTemplate ? mapESLintTemplate(templateName, {
|
|
3392
|
-
distFolder
|
|
3393
|
-
}) : 'vanilla-ts';
|
|
3394
|
-
if (!eslintTemplateName) continue;
|
|
3395
|
-
const subFolder = node_path.join(toolFolder, eslintTemplateName);
|
|
3396
|
-
copyFolder({
|
|
3397
|
-
from: subFolder,
|
|
3398
|
-
to: distFolder,
|
|
3399
|
-
version,
|
|
3400
|
-
skipFiles,
|
|
3401
|
-
templateParameters,
|
|
3402
|
-
isMergePackageJson: true
|
|
3403
|
-
});
|
|
3404
|
-
agentsMdSearchDirs.push(toolFolder);
|
|
3405
|
-
agentsMdSearchDirs.push(subFolder);
|
|
3406
|
-
continue;
|
|
3407
|
-
}
|
|
3408
|
-
if ('rslint' === tool) {
|
|
3409
|
-
const rslintTemplateName = mapRslintTemplate ? mapRslintTemplate(templateName, {
|
|
3410
|
-
distFolder
|
|
3411
|
-
}) : 'vanilla-ts';
|
|
3412
|
-
if (!rslintTemplateName) continue;
|
|
3413
|
-
const subFolder = node_path.join(toolFolder, rslintTemplateName);
|
|
3414
|
-
copyFolder({
|
|
3415
|
-
from: subFolder,
|
|
3416
|
-
to: distFolder,
|
|
3417
|
-
version,
|
|
3418
|
-
skipFiles,
|
|
3419
|
-
templateParameters,
|
|
3420
|
-
isMergePackageJson: true
|
|
3421
|
-
});
|
|
3422
|
-
agentsMdSearchDirs.push(toolFolder);
|
|
3423
|
-
agentsMdSearchDirs.push(subFolder);
|
|
3424
|
-
continue;
|
|
3425
|
-
}
|
|
3426
|
-
copyFolder({
|
|
3427
|
-
from: toolFolder,
|
|
3428
|
-
to: distFolder,
|
|
3429
|
-
version,
|
|
3430
|
-
skipFiles,
|
|
3431
|
-
templateParameters,
|
|
3432
|
-
isMergePackageJson: true
|
|
3433
|
-
});
|
|
3434
|
-
agentsMdSearchDirs.push(toolFolder);
|
|
3435
|
-
if ('biome' === tool) await node_fs.promises.rename(node_path.join(distFolder, 'biome.json.template'), node_path.join(distFolder, 'biome.json'));
|
|
3436
|
-
}
|
|
3437
|
-
const agentsFiles = collectAgentsFiles(agentsMdSearchDirs);
|
|
3438
|
-
if (agentsFiles.length > 0) {
|
|
3439
|
-
const mergedAgents = mergeAgentsFiles(agentsFiles);
|
|
3440
|
-
const agentsPath = node_path.join(distFolder, 'AGENTS.md');
|
|
3441
|
-
node_fs.writeFileSync(agentsPath, `${replacePlaceholder(mergedAgents, templateParameters)}\n`);
|
|
3442
|
-
}
|
|
3443
|
-
logNextStepsAndOutro(noteInformation, targetDir, packageManager);
|
|
3444
|
-
}
|
|
3445
|
-
function sortObjectKeys(obj) {
|
|
3446
|
-
const sortedKeys = Object.keys(obj).sort();
|
|
3447
|
-
const sortedObj = {};
|
|
3448
|
-
for (const key of sortedKeys)sortedObj[key] = obj[key];
|
|
3449
|
-
return sortedObj;
|
|
3450
|
-
}
|
|
3451
|
-
function mergePackageJson(targetPackage, extraPackage) {
|
|
3452
|
-
if (!node_fs.existsSync(targetPackage)) return;
|
|
3453
|
-
const targetJson = JSON.parse(node_fs.readFileSync(targetPackage, 'utf-8'));
|
|
3454
|
-
const extraJson = JSON.parse(node_fs.readFileSync(extraPackage, 'utf-8'));
|
|
3455
|
-
const mergedJson = cjs_default()(targetJson, extraJson);
|
|
3456
|
-
mergedJson.name = targetJson.name || extraJson.name;
|
|
3457
|
-
for (const key of [
|
|
3458
|
-
"scripts",
|
|
3459
|
-
'dependencies',
|
|
3460
|
-
'devDependencies'
|
|
3461
|
-
])if (key in mergedJson) mergedJson[key] = sortObjectKeys(mergedJson[key]);
|
|
3462
|
-
node_fs.writeFileSync(targetPackage, `${JSON.stringify(mergedJson, null, 2)}\n`);
|
|
3463
|
-
}
|
|
3464
|
-
const isMarkdown = (file)=>file.endsWith('.md') || file.endsWith('.mdx');
|
|
3465
|
-
const replacePlaceholder = (content, templateParameters)=>{
|
|
3466
|
-
let result = content;
|
|
3467
|
-
for (const key of Object.keys(templateParameters))result = result.replace(new RegExp(`{{ ${key} }}`, 'g'), templateParameters[key]);
|
|
3468
|
-
return result;
|
|
3469
|
-
};
|
|
3470
|
-
function copyFolder({ from, to, version, packageName, templateParameters, isMergePackageJson, skipFiles = [] }) {
|
|
3471
|
-
const renameFiles = {
|
|
3472
|
-
gitignore: '.gitignore'
|
|
3473
|
-
};
|
|
3474
|
-
const allSkipFiles = [
|
|
3475
|
-
'node_modules',
|
|
3476
|
-
'dist',
|
|
3477
|
-
...skipFiles
|
|
154
|
+
const templateFormatExtensions = [
|
|
155
|
+
...formatExtensions,
|
|
156
|
+
...componentExtensions.filter((extension)=>templateName.includes(extension))
|
|
3478
157
|
];
|
|
3479
|
-
|
|
158
|
+
return [
|
|
159
|
+
'',
|
|
160
|
+
'define.staged({',
|
|
161
|
+
` '*.{${scriptExtensions.join(',')}}': ['rs lint --fix', 'rs fmt'],`,
|
|
162
|
+
` '*.{${templateFormatExtensions.join(',')}}': 'rs fmt',`,
|
|
163
|
+
'});',
|
|
164
|
+
''
|
|
165
|
+
].join('\n');
|
|
166
|
+
};
|
|
167
|
+
const injectStagedSetup = async ({ templateName, distFolder, gitEnabled, isGitRoot })=>{
|
|
168
|
+
if (!gitEnabled || !isGitRoot) return;
|
|
169
|
+
const configExtension = templateName.endsWith('-js') ? 'js' : 'ts';
|
|
170
|
+
const packageJsonPath = node_path.join(distFolder, 'package.json');
|
|
171
|
+
const packageJson = JSON.parse(await readFile(packageJsonPath, 'utf8'));
|
|
172
|
+
packageJson.scripts = Object.fromEntries(Object.entries({
|
|
173
|
+
...packageJson.scripts,
|
|
174
|
+
prepare: 'rs setup'
|
|
175
|
+
}).sort(([left], [right])=>left.localeCompare(right)));
|
|
176
|
+
const hooksDirectory = node_path.join(distFolder, '.rstack', 'hooks');
|
|
177
|
+
await mkdir(hooksDirectory, {
|
|
3480
178
|
recursive: true
|
|
3481
179
|
});
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3488
|
-
|
|
3489
|
-
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3497
|
-
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
'
|
|
3510
|
-
'
|
|
3511
|
-
'
|
|
3512
|
-
'
|
|
3513
|
-
'
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
if (pkg.dependencies?.[name]) pkg.dependencies[name] = ver;
|
|
3524
|
-
if (pkg.devDependencies?.[name]) pkg.devDependencies[name] = ver;
|
|
3525
|
-
}
|
|
3526
|
-
if ('.' === name) {
|
|
3527
|
-
const projectName = node_path.basename(node_path.dirname(pkgJsonPath));
|
|
3528
|
-
if (projectName.length) pkg.name = projectName;
|
|
3529
|
-
} else if (name) pkg.name = name;
|
|
3530
|
-
node_fs.writeFileSync(pkgJsonPath, `${JSON.stringify(pkg, null, 2)}\n`);
|
|
3531
|
-
};
|
|
3532
|
-
function readAgentsFile(filePath) {
|
|
3533
|
-
if (!node_fs.existsSync(filePath)) return null;
|
|
3534
|
-
return node_fs.readFileSync(filePath, 'utf-8');
|
|
3535
|
-
}
|
|
3536
|
-
function parseAgentsContent(content) {
|
|
3537
|
-
const sections = {};
|
|
3538
|
-
const lines = content.split('\n');
|
|
3539
|
-
let currentKey = '';
|
|
3540
|
-
let currentTitle = '';
|
|
3541
|
-
let currentLevel = 0;
|
|
3542
|
-
let currentContent = [];
|
|
3543
|
-
for (const line of lines){
|
|
3544
|
-
const sectionMatch = line.match(/^(#{1,2})\s+(.+)$/);
|
|
3545
|
-
if (sectionMatch) {
|
|
3546
|
-
if (currentKey) sections[currentKey] = {
|
|
3547
|
-
title: currentTitle,
|
|
3548
|
-
level: currentLevel,
|
|
3549
|
-
content: currentContent.join('\n').trim()
|
|
3550
|
-
};
|
|
3551
|
-
currentLevel = sectionMatch[1].length;
|
|
3552
|
-
currentTitle = sectionMatch[2].trim();
|
|
3553
|
-
currentKey = `${currentLevel}-${currentTitle.toLowerCase()}`;
|
|
3554
|
-
currentContent = [];
|
|
3555
|
-
} else if (currentKey) currentContent.push(line);
|
|
3556
|
-
}
|
|
3557
|
-
if (currentKey) sections[currentKey] = {
|
|
3558
|
-
title: currentTitle,
|
|
3559
|
-
level: currentLevel,
|
|
3560
|
-
content: currentContent.join('\n').trim()
|
|
3561
|
-
};
|
|
3562
|
-
return sections;
|
|
3563
|
-
}
|
|
3564
|
-
function mergeAgentsFiles(agentsFiles) {
|
|
3565
|
-
const allSections = {};
|
|
3566
|
-
for (const fileContent of agentsFiles){
|
|
3567
|
-
if (!fileContent) continue;
|
|
3568
|
-
const sections = parseAgentsContent(fileContent);
|
|
3569
|
-
for (const [key, section] of Object.entries(sections)){
|
|
3570
|
-
if (!allSections[key]) allSections[key] = {
|
|
3571
|
-
title: section.title,
|
|
3572
|
-
level: section.level,
|
|
3573
|
-
contents: []
|
|
3574
|
-
};
|
|
3575
|
-
if (section.content && !allSections[key].contents.includes(section.content)) allSections[key].contents.push(section.content);
|
|
3576
|
-
}
|
|
3577
|
-
}
|
|
3578
|
-
const result = [];
|
|
3579
|
-
for (const [, section] of Object.entries(allSections)){
|
|
3580
|
-
result.push(`${'#'.repeat(section.level)} ${section.title}`);
|
|
3581
|
-
result.push('');
|
|
3582
|
-
for(let i = 0; i < section.contents.length; i++){
|
|
3583
|
-
const content = section.contents[i];
|
|
3584
|
-
const nextContent = section.contents[i + 1];
|
|
3585
|
-
result.push(content);
|
|
3586
|
-
if (nextContent) {
|
|
3587
|
-
const lastNewLineIndex = content.lastIndexOf('\n');
|
|
3588
|
-
const lastLine = -1 === lastNewLineIndex ? content : content.substring(lastNewLineIndex + 1);
|
|
3589
|
-
const firstNewLineIndex = nextContent.indexOf('\n');
|
|
3590
|
-
const nextFirstLine = -1 === firstNewLineIndex ? nextContent : nextContent.substring(0, firstNewLineIndex);
|
|
3591
|
-
if (lastLine.startsWith('- ') && nextFirstLine.startsWith('- ')) continue;
|
|
3592
|
-
}
|
|
3593
|
-
result.push('');
|
|
3594
|
-
}
|
|
3595
|
-
}
|
|
3596
|
-
return result.join('\n').trim();
|
|
3597
|
-
}
|
|
3598
|
-
function collectAgentsFiles(agentsMdSearchDirs) {
|
|
3599
|
-
const agentsFiles = [];
|
|
3600
|
-
for (const dir of agentsMdSearchDirs){
|
|
3601
|
-
const agentsContent = readAgentsFile(node_path.join(dir, 'AGENTS.md'));
|
|
3602
|
-
if (agentsContent) agentsFiles.push(agentsContent);
|
|
3603
|
-
}
|
|
3604
|
-
return agentsFiles;
|
|
3605
|
-
}
|
|
3606
|
-
export { At as autocomplete, BUILTIN_TOOLS, Ee as select, Re as text, checkCancel, collectAgentsFiles, copyFolder, create, isNpmTemplate, mergeAgentsFiles, mergePackageJson, pe as groupMultiselect, resolveCustomTemplate, resolveNpmTemplate, sanitizeCacheKey, ve as multiselect };
|
|
180
|
+
await Promise.all([
|
|
181
|
+
writeFile(packageJsonPath, `${JSON.stringify(packageJson, null, 2)}\n`),
|
|
182
|
+
appendFile(node_path.join(distFolder, `rstack.config.${configExtension}`), getStagedConfig(templateName)),
|
|
183
|
+
writeFile(node_path.join(hooksDirectory, 'pre-commit'), 'rs staged\n')
|
|
184
|
+
]);
|
|
185
|
+
};
|
|
186
|
+
await create({
|
|
187
|
+
root: packageRoot,
|
|
188
|
+
name: 'rstack',
|
|
189
|
+
templates: [
|
|
190
|
+
'app-vanilla-js',
|
|
191
|
+
'app-vanilla-ts',
|
|
192
|
+
'app-react-js',
|
|
193
|
+
'app-react-ts',
|
|
194
|
+
'app-preact-js',
|
|
195
|
+
'app-preact-ts',
|
|
196
|
+
'app-vue-js',
|
|
197
|
+
'app-vue-ts',
|
|
198
|
+
'app-lit-js',
|
|
199
|
+
'app-lit-ts',
|
|
200
|
+
'app-svelte-js',
|
|
201
|
+
'app-svelte-ts',
|
|
202
|
+
'app-solid-js',
|
|
203
|
+
'app-solid-ts',
|
|
204
|
+
'lib-node-js',
|
|
205
|
+
'lib-node-ts',
|
|
206
|
+
'lib-react-js',
|
|
207
|
+
'lib-react-ts',
|
|
208
|
+
'lib-vue-js',
|
|
209
|
+
'lib-vue-ts',
|
|
210
|
+
'lib-svelte-js',
|
|
211
|
+
'lib-svelte-ts',
|
|
212
|
+
'lib-solid-js',
|
|
213
|
+
'lib-solid-ts',
|
|
214
|
+
'doc-basic',
|
|
215
|
+
'doc-i18n'
|
|
216
|
+
],
|
|
217
|
+
builtinTools: [],
|
|
218
|
+
getTemplateName: getTemplateName,
|
|
219
|
+
onGitResolved: injectStagedSetup
|
|
220
|
+
});
|