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