@xunlei-open/create-miniapp 0.1.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (98) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +106 -0
  3. package/dist/index.mjs +416 -0
  4. package/dist/index.mjs.map +1 -0
  5. package/package.json +59 -0
  6. package/templates/react/.prettierignore +3 -0
  7. package/templates/react/.prettierrc.ejs +7 -0
  8. package/templates/react/_gitignore +24 -0
  9. package/templates/react/biome.json +41 -0
  10. package/templates/react/eslint.config.js.ejs +43 -0
  11. package/templates/react/index.html.ejs +12 -0
  12. package/templates/react/jsconfig.json +9 -0
  13. package/templates/react/manifest.json +16 -0
  14. package/templates/react/miniapp.config.js.ejs +16 -0
  15. package/templates/react/package.json.ejs +42 -0
  16. package/templates/react/src/App.jsx.ejs +53 -0
  17. package/templates/react/src/index.css +105 -0
  18. package/templates/react/src/main.jsx +10 -0
  19. package/templates/react/tests/App.spec.jsx.ejs +12 -0
  20. package/templates/react/vitest.config.js +11 -0
  21. package/templates/react-ts/.prettierignore +3 -0
  22. package/templates/react-ts/.prettierrc.ejs +7 -0
  23. package/templates/react-ts/_gitignore +25 -0
  24. package/templates/react-ts/biome.json +41 -0
  25. package/templates/react-ts/eslint.config.js.ejs +33 -0
  26. package/templates/react-ts/index.html.ejs +12 -0
  27. package/templates/react-ts/manifest.json +16 -0
  28. package/templates/react-ts/miniapp.config.ts.ejs +16 -0
  29. package/templates/react-ts/package.json.ejs +48 -0
  30. package/templates/react-ts/src/App.tsx.ejs +53 -0
  31. package/templates/react-ts/src/index.css +105 -0
  32. package/templates/react-ts/src/main.tsx +10 -0
  33. package/templates/react-ts/src/vite-env.d.ts +2 -0
  34. package/templates/react-ts/tests/App.spec.tsx.ejs +12 -0
  35. package/templates/react-ts/tsconfig.app.json +28 -0
  36. package/templates/react-ts/tsconfig.json +7 -0
  37. package/templates/react-ts/tsconfig.node.json +24 -0
  38. package/templates/react-ts/vitest.config.js +11 -0
  39. package/templates/vanilla/.prettierignore +3 -0
  40. package/templates/vanilla/.prettierrc.ejs +7 -0
  41. package/templates/vanilla/_gitignore +23 -0
  42. package/templates/vanilla/biome.json +40 -0
  43. package/templates/vanilla/eslint.config.js.ejs +25 -0
  44. package/templates/vanilla/index.html.ejs +12 -0
  45. package/templates/vanilla/jsconfig.json +8 -0
  46. package/templates/vanilla/manifest.json +16 -0
  47. package/templates/vanilla/miniapp.config.js.ejs +15 -0
  48. package/templates/vanilla/package.json.ejs +33 -0
  49. package/templates/vanilla/src/main.js.ejs +54 -0
  50. package/templates/vanilla/src/style.css +101 -0
  51. package/templates/vanilla/tests/example.spec.js +7 -0
  52. package/templates/vanilla-ts/.prettierignore +3 -0
  53. package/templates/vanilla-ts/.prettierrc.ejs +7 -0
  54. package/templates/vanilla-ts/_gitignore +23 -0
  55. package/templates/vanilla-ts/biome.json +40 -0
  56. package/templates/vanilla-ts/eslint.config.js.ejs +36 -0
  57. package/templates/vanilla-ts/index.html.ejs +12 -0
  58. package/templates/vanilla-ts/manifest.json +16 -0
  59. package/templates/vanilla-ts/miniapp.config.ts.ejs +15 -0
  60. package/templates/vanilla-ts/package.json.ejs +38 -0
  61. package/templates/vanilla-ts/src/main.ts.ejs +54 -0
  62. package/templates/vanilla-ts/src/style.css +101 -0
  63. package/templates/vanilla-ts/src/vite-env.d.ts +2 -0
  64. package/templates/vanilla-ts/tests/example.spec.ts +7 -0
  65. package/templates/vanilla-ts/tsconfig.json +26 -0
  66. package/templates/vue/.prettierignore +3 -0
  67. package/templates/vue/.prettierrc.ejs +7 -0
  68. package/templates/vue/_gitignore +25 -0
  69. package/templates/vue/biome.json +46 -0
  70. package/templates/vue/eslint.config.js.ejs +26 -0
  71. package/templates/vue/index.html.ejs +12 -0
  72. package/templates/vue/jsconfig.json +8 -0
  73. package/templates/vue/manifest.json +16 -0
  74. package/templates/vue/miniapp.config.js.ejs +16 -0
  75. package/templates/vue/package.json.ejs +39 -0
  76. package/templates/vue/src/App.vue.ejs +51 -0
  77. package/templates/vue/src/assets/main.css +105 -0
  78. package/templates/vue/src/main.js +5 -0
  79. package/templates/vue/tests/App.spec.js.ejs +12 -0
  80. package/templates/vue/vitest.config.js +11 -0
  81. package/templates/vue-ts/.prettierignore +3 -0
  82. package/templates/vue-ts/.prettierrc.ejs +7 -0
  83. package/templates/vue-ts/_gitignore +25 -0
  84. package/templates/vue-ts/biome.json +46 -0
  85. package/templates/vue-ts/eslint.config.js.ejs +32 -0
  86. package/templates/vue-ts/index.html.ejs +12 -0
  87. package/templates/vue-ts/manifest.json +16 -0
  88. package/templates/vue-ts/miniapp.config.ts.ejs +16 -0
  89. package/templates/vue-ts/package.json.ejs +46 -0
  90. package/templates/vue-ts/src/App.vue.ejs +51 -0
  91. package/templates/vue-ts/src/assets/main.css +105 -0
  92. package/templates/vue-ts/src/main.ts +5 -0
  93. package/templates/vue-ts/src/vite-env.d.ts +2 -0
  94. package/templates/vue-ts/tests/App.spec.ts.ejs +12 -0
  95. package/templates/vue-ts/tsconfig.app.json +17 -0
  96. package/templates/vue-ts/tsconfig.json +7 -0
  97. package/templates/vue-ts/tsconfig.node.json +24 -0
  98. package/templates/vue-ts/vitest.config.js +11 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 miniapp-devkit contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,106 @@
1
+ # @xunlei-open/create-miniapp
2
+
3
+ 迅雷开放平台前端脚手架 CLI(自研命令行 + EJS 模板引擎)。
4
+
5
+ - 微应用开发说明见[仓库 README](https://github.com/xunlei-open/miniapp-devkit#readme),完整能力以[官方开发文档](https://open.xunlei.com/doc/miniapp/introduction)为准。
6
+
7
+ ## 环境要求
8
+
9
+ - **Node.js** 20.19+ 或 22.12+(模板使用 Vite 8,[官方要求](https://vite.dev/blog/announcing-vite8#node-js-support);含 Vitest / jsdom 29)
10
+
11
+ ## 能力
12
+
13
+ | Framework | Variant | 模板 ID | 包含 |
14
+ |-----------|---------|---------|------|
15
+ | Vanilla | TypeScript | `vanilla-ts` | 迅雷微应用 CLI、Vite 8、TypeScript;可选 Lint / Biome / Vitest |
16
+ | Vanilla | JavaScript | `vanilla` | 迅雷微应用 CLI、Vite 8;可选 Lint / Biome / Vitest |
17
+ | Vue | TypeScript | `vue-ts` | 迅雷微应用 CLI、Vite 8、Vue 3;可选 Lint / Biome(Experimental)/ Vitest |
18
+ | Vue | JavaScript | `vue` | 同上(JavaScript) |
19
+ | React | TypeScript | `react-ts` | Vite 8、React 19;可选 Lint / Biome / Vitest |
20
+ | React | JavaScript | `react` | 同上(JavaScript) |
21
+
22
+ **Lint** = ESLint + Prettier + `eslint-plugin-prettier`(规则 `prettier/prettier: error`)。编辑时红线依赖本机 ESLint 扩展读取项目配置,无需 `.vscode` 工作区文件。
23
+
24
+ **Biome** = `@biomejs/biome` 一体 lint + format,生成 `biome.json` 与 `.vscode/settings.json`。Vue 模板对 `.vue` SFC 支持为实验性,交互选项标注 `(Experimental)`。
25
+
26
+ 生成的项目默认包含一个调用 `xunlei.tasks.create` 创建下载任务的页面示例,并声明最小权限 `tasks.create`;不包含 `src/events` 或 manifest `scripts`。需要介入下载任务生命周期时,可按照根目录 README 的“可选:让微应用响应下载事件”章节手动添加。
27
+
28
+ 模板使用 `miniapp.config.ts`(JavaScript 模板为 `.js`)作为唯一工具配置。Vue/React 模板通过 `modules` 声明对应的 `@xunlei-open/miniapp-module-vue` 或 `@xunlei-open/miniapp-module-react`,自动加载框架的 Vite 插件;额外配置仍放在 `vite` 字段中。build 和 package 不执行类型检查,TS 模板提供可选的 `typecheck` 命令。常用命令为:
29
+
30
+ ```bash
31
+ pnpm dev # xunlei-miniapp
32
+ pnpm build # xunlei-miniapp build
33
+ pnpm run package # 构建、校验并生成 ZIP
34
+ ```
35
+
36
+ ## 使用
37
+
38
+ 生成的项目不写入 `packageManager` 字段,不固定包管理器版本。可使用 npm、yarn 或 pnpm,具体版本由用户自行管理。
39
+
40
+ ```bash
41
+ # 创建项目(推荐)
42
+ npm create @xunlei-open/miniapp@latest
43
+
44
+ # 等价写法
45
+ npx @xunlei-open/create-miniapp@latest
46
+
47
+ # 指定项目名与参数(非交互)
48
+ npx @xunlei-open/create-miniapp my-app -y --framework vue --variant typescript --features lint,vitest
49
+
50
+ # 使用 Biome(Vue 为实验性支持)
51
+ npx @xunlei-open/create-miniapp my-app -y --framework vue --variant typescript --features biome --no-install
52
+
53
+ # 本仓库开发调试
54
+ pnpm install
55
+ pnpm dev # 交互式,等同发布后的 create 命令
56
+ pnpm build
57
+ node dist/index.mjs my-demo -y --framework vue --variant typescript --features lint --no-install
58
+ ```
59
+
60
+ ### 命令行参数
61
+
62
+ | 参数 | 说明 |
63
+ |------|------|
64
+ | `-y, --yes` | 跳过问答,使用默认或命令行参数 |
65
+ | `--framework vanilla \| vue \| react` | 框架 |
66
+ | `--variant typescript \| javascript` | 语言变体 |
67
+ | `--features lint,biome,vitest` | 可选特性(逗号分隔);`lint` 与 `biome` 二选一 |
68
+ | `--features eslint` / `prettier` | 已合并为 `lint`,仍可作为别名传入 |
69
+ | (默认) | 交互时 features 默认全不选;`-y` 未传 `--features` 时不包含任何特性 |
70
+ | `--no-install` | 不自动安装依赖 |
71
+
72
+ ## 目录结构
73
+
74
+ ```text
75
+ src/
76
+ index.ts # Commander 入口
77
+ prompts.ts # 交互选型
78
+ generator.ts # EJS 渲染 + 拷贝
79
+ utils.ts # 包名、framework/variant/features 解析
80
+ types.ts # 类型定义
81
+ templates/
82
+ vanilla/
83
+ vanilla-ts/
84
+ vue/
85
+ vue-ts/
86
+ react/
87
+ react-ts/
88
+ ```
89
+
90
+ ## 发布
91
+
92
+ ```bash
93
+ pnpm build
94
+ npm publish --access public
95
+ ```
96
+
97
+ ## 扩展模板
98
+
99
+ 1. 在 `templates/` 下新增目录,并在 `resolveTemplateId` 的 `TEMPLATE_IDS` 中映射 framework + variant
100
+ 2. 需变量替换的文件使用 `.ejs` 后缀
101
+ 3. 勾选 `lint` 时需包含 `eslint.config.js.ejs`、`.prettierrc.ejs` 等
102
+ 4. 勾选 `biome` 时需包含 `biome.json`、`.vscode/settings.json`,并在 `package.json.ejs` 中条件注入 `@biomejs/biome` 与 scripts
103
+
104
+ ## 版本说明
105
+
106
+ - v0.1:Vanilla / Vue / React(JS/TS);可选 Lint(ESLint+Prettier)、Biome(Vue 为 Experimental)、Vitest
package/dist/index.mjs ADDED
@@ -0,0 +1,416 @@
1
+ #!/usr/bin/env node
2
+ import { Command } from "commander";
3
+ import { execa } from "execa";
4
+ import { cyan, green, red } from "kolorist";
5
+ import path from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+ import ejs from "ejs";
8
+ import fs from "fs-extra";
9
+ import validate from "validate-npm-package-name";
10
+ import { checkbox, confirm, input, select } from "@inquirer/prompts";
11
+ //#region package.json
12
+ var version = "0.1.1-beta.0";
13
+ //#endregion
14
+ //#region src/utils.ts
15
+ function toPackageName(input) {
16
+ return input.trim().toLowerCase().replace(/\s+/g, "-").replace(/[^a-z0-9-_]/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
17
+ }
18
+ function assertValidPackageName(name) {
19
+ const result = validate(name);
20
+ if (!result.validForNewPackages) {
21
+ const errors = [...result.errors ?? [], ...result.warnings ?? []];
22
+ throw new Error(`Invalid package name "${name}": ${errors.join(", ")}`);
23
+ }
24
+ }
25
+ const ALL_FEATURES = [
26
+ "lint",
27
+ "biome",
28
+ "vitest"
29
+ ];
30
+ const FEATURE_ALIASES = {
31
+ lint: "lint",
32
+ eslint: "lint",
33
+ prettier: "lint",
34
+ biome: "biome",
35
+ vitest: "vitest"
36
+ };
37
+ const TEMPLATE_IDS = {
38
+ vanilla: {
39
+ javascript: "vanilla",
40
+ typescript: "vanilla-ts"
41
+ },
42
+ vue: {
43
+ javascript: "vue",
44
+ typescript: "vue-ts"
45
+ },
46
+ react: {
47
+ javascript: "react",
48
+ typescript: "react-ts"
49
+ }
50
+ };
51
+ /** Map CLI framework / variant to the templates/ directory name. */
52
+ function resolveTemplateId(framework, variant) {
53
+ return TEMPLATE_IDS[framework][variant];
54
+ }
55
+ function parseFramework(input) {
56
+ return {
57
+ vanilla: "vanilla",
58
+ vue: "vue",
59
+ react: "react"
60
+ }[input.trim().toLowerCase()];
61
+ }
62
+ function parsePackageManager(input) {
63
+ return {
64
+ npm: "npm",
65
+ yarn: "yarn",
66
+ pnpm: "pnpm"
67
+ }[input.trim().toLowerCase()];
68
+ }
69
+ function pkgFromUserAgent(userAgent) {
70
+ if (!userAgent) return void 0;
71
+ const [name, version] = userAgent.split(" ")[0]?.split("/") ?? [];
72
+ if (!name) return void 0;
73
+ return {
74
+ name,
75
+ version: version ?? ""
76
+ };
77
+ }
78
+ /** Infer npm / yarn / pnpm from npx, pnpx, yarn dlx, pnpm create, etc. */
79
+ function detectInvokedPackageManager() {
80
+ const pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);
81
+ if (pkgInfo) {
82
+ const pm = parsePackageManager(pkgInfo.name);
83
+ if (pm) return pm;
84
+ }
85
+ const execPath = process.env.npm_execpath ?? "";
86
+ if (execPath.includes("pnpm")) return "pnpm";
87
+ if (execPath.includes("yarn")) return "yarn";
88
+ return "npm";
89
+ }
90
+ function pmInstallCommand(pm) {
91
+ return pm === "yarn" ? "yarn" : `${pm} install`;
92
+ }
93
+ function pmDevCommand(pm) {
94
+ return pm === "npm" ? "npm run dev" : `${pm} dev`;
95
+ }
96
+ function pmTestCommand(pm) {
97
+ return pm === "npm" ? "npm test" : `${pm} test`;
98
+ }
99
+ function pmDevArgs(pm) {
100
+ return pm === "npm" ? ["run", "dev"] : ["dev"];
101
+ }
102
+ function parseVariant(input) {
103
+ return {
104
+ typescript: "typescript",
105
+ ts: "typescript",
106
+ javascript: "javascript",
107
+ js: "javascript"
108
+ }[input.trim().toLowerCase()];
109
+ }
110
+ function parseFeatures(input) {
111
+ const features = [];
112
+ for (const part of input.split(/[,+]/)) {
113
+ const key = part.trim().toLowerCase();
114
+ if (!key) continue;
115
+ const feature = FEATURE_ALIASES[key];
116
+ if (feature && !features.includes(feature)) features.push(feature);
117
+ }
118
+ return resolveMutuallyExclusiveLint(features);
119
+ }
120
+ function hasFeature(features, feature) {
121
+ return features.includes(feature);
122
+ }
123
+ function supportsOptionalFeatures(_framework) {
124
+ return true;
125
+ }
126
+ function defaultFeatures(_framework) {
127
+ return [];
128
+ }
129
+ /** lint and biome are mutually exclusive; prefer lint when both are present. */
130
+ function resolveMutuallyExclusiveLint(features) {
131
+ if (features.includes("lint") && features.includes("biome")) return features.filter((f) => f !== "biome");
132
+ return features;
133
+ }
134
+ function supportsBiomeLinter(framework) {
135
+ return framework === "vanilla" || framework === "react" || framework === "vue";
136
+ }
137
+ function isBiomeExperimental(framework) {
138
+ return framework === "vue";
139
+ }
140
+ function normalizeFeatures(features, framework) {
141
+ let result = [];
142
+ for (const f of features ?? []) if (ALL_FEATURES.includes(f) && !result.includes(f)) result.push(f);
143
+ result = resolveMutuallyExclusiveLint(result);
144
+ if (result.includes("biome") && !supportsBiomeLinter(framework)) result = result.filter((f) => f !== "biome");
145
+ return result;
146
+ }
147
+ //#endregion
148
+ //#region src/generator.ts
149
+ const __dirname = path.dirname(fileURLToPath(import.meta.url));
150
+ function getTemplatesRoot() {
151
+ return path.resolve(__dirname, "../templates");
152
+ }
153
+ function shouldSkip(relPath, options) {
154
+ const normalized = relPath.replace(/\\/g, "/");
155
+ const { features } = options;
156
+ if (!hasFeature(features, "vitest")) {
157
+ if (normalized.startsWith("tests/") || normalized.includes("/tests/") || normalized.includes("vitest.config") || normalized.startsWith("src/test/")) return true;
158
+ }
159
+ if (!hasFeature(features, "lint")) {
160
+ if (normalized.endsWith("eslint.config.js") || normalized.endsWith("eslint.config.js.ejs")) return true;
161
+ if (relPath.endsWith(".prettierrc.ejs")) return true;
162
+ if (relPath.endsWith(".prettierignore")) return true;
163
+ }
164
+ if (!hasFeature(features, "biome")) {
165
+ if (normalized === "biome.json" || normalized.endsWith("/biome.json")) return true;
166
+ if (normalized === ".vscode/settings.json" || normalized.endsWith("/.vscode/settings.json")) return true;
167
+ }
168
+ if (relPath.endsWith("pnpm-lock.yaml") || relPath.endsWith("package-lock.json") || relPath.endsWith("yarn.lock")) return true;
169
+ return false;
170
+ }
171
+ async function renderFile(src, dest, context) {
172
+ const content = await fs.readFile(src, "utf-8");
173
+ const rendered = ejs.render(content, context, { rmWhitespace: false });
174
+ await fs.ensureDir(path.dirname(dest));
175
+ await fs.writeFile(dest, rendered, "utf-8");
176
+ }
177
+ async function copyTemplateDir(templateDir, targetDir, context, options, relBase = "") {
178
+ const entries = await fs.readdir(templateDir, { withFileTypes: true });
179
+ for (const entry of entries) {
180
+ const srcPath = path.join(templateDir, entry.name);
181
+ const relPath = relBase ? `${relBase}/${entry.name}` : entry.name;
182
+ if (shouldSkip(relPath, options)) continue;
183
+ if (entry.isDirectory()) {
184
+ await copyTemplateDir(srcPath, path.join(targetDir, entry.name), context, options, relPath);
185
+ continue;
186
+ }
187
+ const isEjs = entry.name.endsWith(".ejs");
188
+ const templateName = isEjs ? entry.name.slice(0, -4) : entry.name;
189
+ const outName = templateName === "_gitignore" ? ".gitignore" : templateName;
190
+ const destPath = path.join(targetDir, outName);
191
+ if (isEjs) await renderFile(srcPath, destPath, context);
192
+ else {
193
+ await fs.ensureDir(path.dirname(destPath));
194
+ await fs.copy(srcPath, destPath);
195
+ }
196
+ }
197
+ }
198
+ async function generateProject(options) {
199
+ const templateId = resolveTemplateId(options.framework, options.variant);
200
+ const templateDir = path.join(getTemplatesRoot(), templateId);
201
+ if (!await fs.pathExists(templateDir)) throw new Error(`Template "${templateId}" is not available (${options.framework} + ${options.variant}).`);
202
+ const targetDir = path.resolve(process.cwd(), options.projectName);
203
+ if (await fs.pathExists(targetDir)) {
204
+ if ((await fs.readdir(targetDir)).length > 0) throw new Error(`Target directory is not empty: ${targetDir}`);
205
+ }
206
+ const context = {
207
+ projectName: options.projectName,
208
+ packageName: options.packageName,
209
+ variant: options.variant,
210
+ features: options.features,
211
+ devkitVersion: version,
212
+ isTypeScript: options.variant === "typescript"
213
+ };
214
+ await fs.ensureDir(targetDir);
215
+ await copyTemplateDir(templateDir, targetDir, context, options);
216
+ return targetDir;
217
+ }
218
+ function printNextSteps(targetDir, options, installed, autoStartDev = false) {
219
+ const rel = path.relative(process.cwd(), targetDir) || ".";
220
+ const commands = [];
221
+ if (rel !== "." && !autoStartDev) commands.push(`cd ${rel}`);
222
+ const { packageManager } = options;
223
+ if (!installed) commands.push(pmInstallCommand(packageManager));
224
+ if (!autoStartDev) commands.push(pmDevCommand(packageManager));
225
+ if (hasFeature(options.features, "vitest")) commands.push(pmTestCommand(packageManager));
226
+ if (commands.length > 0) {
227
+ console.log(green("\nDone. Now run:\n"));
228
+ for (const command of commands) console.log(` ${command}`);
229
+ console.log("");
230
+ } else console.log(green("\nDone.\n"));
231
+ console.log("Optional: Initialize Git in your project directory with:\n");
232
+ console.log(" git init && git add -A && git commit -m \"initial commit\"");
233
+ console.log("");
234
+ }
235
+ function printError(err) {
236
+ const msg = err instanceof Error ? err.message : String(err);
237
+ console.error(red(`\n✖ ${msg}\n`));
238
+ }
239
+ //#endregion
240
+ //#region src/prompts.ts
241
+ async function runPrompts(defaults = {}) {
242
+ const projectName = await input({
243
+ message: "Project name:",
244
+ default: defaults.projectName ?? "xunlei-plugin-project"
245
+ });
246
+ const packageName = toPackageName(defaults.packageName ?? projectName);
247
+ assertValidPackageName(packageName);
248
+ const framework = await select({
249
+ message: "Select a framework:",
250
+ choices: [
251
+ {
252
+ name: "Vanilla",
253
+ value: "vanilla"
254
+ },
255
+ {
256
+ name: "Vue",
257
+ value: "vue"
258
+ },
259
+ {
260
+ name: "React",
261
+ value: "react"
262
+ }
263
+ ],
264
+ default: defaults.framework ?? "vanilla"
265
+ });
266
+ const variant = await selectVariant(defaults.variant);
267
+ const features = supportsOptionalFeatures(framework) ? await promptFeatures(framework, variant, defaults.features ?? defaultFeatures(framework)) : [];
268
+ const packageManager = defaults.packageManager ?? detectInvokedPackageManager();
269
+ return {
270
+ projectName,
271
+ packageName,
272
+ framework,
273
+ variant,
274
+ features,
275
+ packageManager,
276
+ install: await confirm({
277
+ message: `Install dependencies with ${packageManager} and start now?`,
278
+ default: defaults.install ?? true
279
+ })
280
+ };
281
+ }
282
+ async function promptFeatures(framework, _variant, defaultSelected) {
283
+ const features = [];
284
+ if (await promptAddLinter(defaultSelected)) features.push(await promptLintTool(framework, defaultSelected));
285
+ const extra = await checkbox({
286
+ message: "Select additional features:",
287
+ choices: [{
288
+ name: "Vitest (unit testing)",
289
+ value: "vitest",
290
+ checked: defaultSelected.includes("vitest")
291
+ }]
292
+ });
293
+ features.push(...extra);
294
+ return features;
295
+ }
296
+ async function promptAddLinter(_defaultSelected) {
297
+ return select({
298
+ message: "Add linter / formatter?",
299
+ choices: [{
300
+ name: "No",
301
+ value: false
302
+ }, {
303
+ name: "Yes",
304
+ value: true
305
+ }],
306
+ default: true
307
+ });
308
+ }
309
+ async function promptLintTool(framework, defaultSelected) {
310
+ const biomeLabel = isBiomeExperimental(framework) ? "Biome (lint + format) (Experimental)" : "Biome (lint + format)";
311
+ const choices = supportsBiomeLinter(framework) ? [{
312
+ name: "ESLint + Prettier",
313
+ value: "lint"
314
+ }, {
315
+ name: biomeLabel,
316
+ value: "biome"
317
+ }] : [{
318
+ name: "ESLint + Prettier",
319
+ value: "lint"
320
+ }];
321
+ return select({
322
+ message: "Select linter / formatter:",
323
+ choices,
324
+ default: defaultSelected.includes("biome") ? "biome" : "lint"
325
+ });
326
+ }
327
+ async function selectVariant(defaultVariant) {
328
+ return select({
329
+ message: "Select a variant:",
330
+ choices: [{
331
+ name: "TypeScript",
332
+ value: "typescript"
333
+ }, {
334
+ name: "JavaScript",
335
+ value: "javascript"
336
+ }],
337
+ default: defaultVariant ?? "typescript"
338
+ });
339
+ }
340
+ //#endregion
341
+ //#region src/index.ts
342
+ const CLI_NAME = "@xunlei-open/create-miniapp";
343
+ const program = new Command();
344
+ program.name(CLI_NAME).description("Xunlei Open Platform plugin scaffold").version(version).argument("[project-name]", "project name").option("--framework <framework>", "vanilla | vue | react").option("--variant <variant>", "typescript | javascript").option("--features <features>", "comma-separated: lint,biome,vitest (lint and biome are mutually exclusive; eslint/prettier alias lint)").option("--package-manager <pm>", "npm | yarn | pnpm").option("--no-install", "skip dependency installation").option("-y, --yes", "use defaults and skip prompts").action(async (projectName, opts) => {
345
+ try {
346
+ const defaults = {};
347
+ if (projectName) defaults.projectName = projectName;
348
+ const frameworkInput = opts.framework;
349
+ if (frameworkInput) {
350
+ const parsed = parseFramework(frameworkInput);
351
+ if (!parsed) throw new Error(`Unknown framework: ${frameworkInput} (supported: vanilla | vue | react)`);
352
+ defaults.framework = parsed;
353
+ }
354
+ const variantInput = opts.variant;
355
+ if (variantInput) {
356
+ const parsed = parseVariant(variantInput);
357
+ if (!parsed) throw new Error(`Unknown variant: ${variantInput} (supported: typescript | javascript)`);
358
+ defaults.variant = parsed;
359
+ }
360
+ const featuresInput = opts.features;
361
+ if (featuresInput) {
362
+ const parsed = parseFeatures(featuresInput);
363
+ if (parsed.length === 0) throw new Error(`Unknown features: ${featuresInput} (supported: lint, biome, vitest; eslint/prettier alias lint)`);
364
+ defaults.features = parsed;
365
+ }
366
+ if (opts.install === false) defaults.install = false;
367
+ const packageManagerInput = opts.packageManager;
368
+ if (packageManagerInput) {
369
+ const parsed = parsePackageManager(packageManagerInput);
370
+ if (!parsed) throw new Error(`Unknown package manager: ${packageManagerInput} (supported: npm | yarn | pnpm)`);
371
+ defaults.packageManager = parsed;
372
+ } else defaults.packageManager = detectInvokedPackageManager();
373
+ console.log(cyan(`\n ${CLI_NAME} \n`));
374
+ const options = opts.yes ? resolveOptionsFromDefaults(defaults) : await runPrompts(defaults);
375
+ const targetDir = await generateProject(options);
376
+ let installed = false;
377
+ if (options.install) {
378
+ const { packageManager: pm } = options;
379
+ console.log(cyan(`\nInstalling dependencies (${pm})...\n`));
380
+ await execa(pm, ["install"], {
381
+ cwd: targetDir,
382
+ stdio: "inherit"
383
+ });
384
+ installed = true;
385
+ printNextSteps(targetDir, options, installed, true);
386
+ console.log(cyan(`\nStarting dev server (${pmDevCommand(pm)})...\n`));
387
+ await execa(pm, pmDevArgs(pm), {
388
+ cwd: targetDir,
389
+ stdio: "inherit"
390
+ });
391
+ } else printNextSteps(targetDir, options, installed);
392
+ } catch (err) {
393
+ printError(err);
394
+ process.exit(1);
395
+ }
396
+ });
397
+ function resolveOptionsFromDefaults(defaults) {
398
+ const projectName = defaults.projectName ?? "xunlei-plugin-project";
399
+ const packageName = toPackageName(defaults.packageName ?? projectName);
400
+ assertValidPackageName(packageName);
401
+ const framework = defaults.framework ?? "vanilla";
402
+ return {
403
+ projectName,
404
+ packageName,
405
+ framework,
406
+ variant: defaults.variant ?? "typescript",
407
+ features: normalizeFeatures(defaults.features, framework),
408
+ packageManager: defaults.packageManager ?? detectInvokedPackageManager(),
409
+ install: defaults.install ?? true
410
+ };
411
+ }
412
+ program.parse();
413
+ //#endregion
414
+ export {};
415
+
416
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":["packageJson.version","packageJson.version"],"sources":["../package.json","../src/utils.ts","../src/generator.ts","../src/prompts.ts","../src/index.ts"],"sourcesContent":["","import validate from \"validate-npm-package-name\";\nimport type { Feature, Framework, PackageManager, Variant } from \"./types.js\";\n\nexport function toPackageName(input: string): string {\n\treturn input\n\t\t.trim()\n\t\t.toLowerCase()\n\t\t.replace(/\\s+/g, \"-\")\n\t\t.replace(/[^a-z0-9-_]/g, \"-\")\n\t\t.replace(/-+/g, \"-\")\n\t\t.replace(/^-|-$/g, \"\");\n}\n\nexport function assertValidPackageName(name: string): void {\n\tconst result = validate(name);\n\tif (!result.validForNewPackages) {\n\t\tconst errors = [...(result.errors ?? []), ...(result.warnings ?? [])];\n\t\tthrow new Error(`Invalid package name \"${name}\": ${errors.join(\", \")}`);\n\t}\n}\n\nconst ALL_FEATURES: Feature[] = [\"lint\", \"biome\", \"vitest\"];\n\nconst FEATURE_ALIASES: Record<string, Feature> = {\n\tlint: \"lint\",\n\teslint: \"lint\",\n\tprettier: \"lint\",\n\tbiome: \"biome\",\n\tvitest: \"vitest\",\n};\n\nconst TEMPLATE_IDS: Record<Framework, Record<Variant, string>> = {\n\tvanilla: {\n\t\tjavascript: \"vanilla\",\n\t\ttypescript: \"vanilla-ts\",\n\t},\n\tvue: {\n\t\tjavascript: \"vue\",\n\t\ttypescript: \"vue-ts\",\n\t},\n\treact: {\n\t\tjavascript: \"react\",\n\t\ttypescript: \"react-ts\",\n\t},\n};\n\n/** Map CLI framework / variant to the templates/ directory name. */\nexport function resolveTemplateId(\n\tframework: Framework,\n\tvariant: Variant,\n): string {\n\treturn TEMPLATE_IDS[framework][variant];\n}\n\nexport function parseFramework(input: string): Framework | undefined {\n\tconst key = input.trim().toLowerCase();\n\tconst map: Record<string, Framework> = {\n\t\tvanilla: \"vanilla\",\n\t\tvue: \"vue\",\n\t\treact: \"react\",\n\t};\n\treturn map[key];\n}\n\nexport function parsePackageManager(input: string): PackageManager | undefined {\n\tconst key = input.trim().toLowerCase();\n\tconst map: Record<string, PackageManager> = {\n\t\tnpm: \"npm\",\n\t\tyarn: \"yarn\",\n\t\tpnpm: \"pnpm\",\n\t};\n\treturn map[key];\n}\n\nfunction pkgFromUserAgent(\n\tuserAgent: string | undefined,\n): { name: string; version: string } | undefined {\n\tif (!userAgent) return undefined;\n\tconst pkgSpec = userAgent.split(\" \")[0];\n\tconst [name, version] = pkgSpec?.split(\"/\") ?? [];\n\tif (!name) return undefined;\n\treturn { name, version: version ?? \"\" };\n}\n\n/** Infer npm / yarn / pnpm from npx, pnpx, yarn dlx, pnpm create, etc. */\nexport function detectInvokedPackageManager(): PackageManager {\n\tconst pkgInfo = pkgFromUserAgent(process.env.npm_config_user_agent);\n\tif (pkgInfo) {\n\t\tconst pm = parsePackageManager(pkgInfo.name);\n\t\tif (pm) return pm;\n\t}\n\n\tconst execPath = process.env.npm_execpath ?? \"\";\n\tif (execPath.includes(\"pnpm\")) return \"pnpm\";\n\tif (execPath.includes(\"yarn\")) return \"yarn\";\n\n\treturn \"npm\";\n}\n\nexport function pmInstallCommand(pm: PackageManager): string {\n\treturn pm === \"yarn\" ? \"yarn\" : `${pm} install`;\n}\n\nexport function pmDevCommand(pm: PackageManager): string {\n\treturn pm === \"npm\" ? \"npm run dev\" : `${pm} dev`;\n}\n\nexport function pmTestCommand(pm: PackageManager): string {\n\treturn pm === \"npm\" ? \"npm test\" : `${pm} test`;\n}\n\nexport function pmDevArgs(pm: PackageManager): string[] {\n\treturn pm === \"npm\" ? [\"run\", \"dev\"] : [\"dev\"];\n}\n\nexport function parseVariant(input: string): Variant | undefined {\n\tconst key = input.trim().toLowerCase();\n\tconst map: Record<string, Variant> = {\n\t\ttypescript: \"typescript\",\n\t\tts: \"typescript\",\n\t\tjavascript: \"javascript\",\n\t\tjs: \"javascript\",\n\t};\n\treturn map[key];\n}\n\nexport function parseFeatures(input: string): Feature[] {\n\tconst features: Feature[] = [];\n\tfor (const part of input.split(/[,+]/)) {\n\t\tconst key = part.trim().toLowerCase();\n\t\tif (!key) continue;\n\t\tconst feature = FEATURE_ALIASES[key];\n\t\tif (feature && !features.includes(feature)) {\n\t\t\tfeatures.push(feature);\n\t\t}\n\t}\n\treturn resolveMutuallyExclusiveLint(features);\n}\n\nexport function hasFeature(features: Feature[], feature: Feature): boolean {\n\treturn features.includes(feature);\n}\n\nexport function supportsOptionalFeatures(_framework: Framework): boolean {\n\treturn true;\n}\n\nexport function defaultFeatures(_framework: Framework): Feature[] {\n\treturn [];\n}\n\n/** lint and biome are mutually exclusive; prefer lint when both are present. */\nexport function resolveMutuallyExclusiveLint(features: Feature[]): Feature[] {\n\tif (features.includes(\"lint\") && features.includes(\"biome\")) {\n\t\treturn features.filter((f) => f !== \"biome\");\n\t}\n\treturn features;\n}\n\nexport function supportsBiomeLinter(framework: Framework): boolean {\n\treturn (\n\t\tframework === \"vanilla\" || framework === \"react\" || framework === \"vue\"\n\t);\n}\n\nexport function isBiomeExperimental(framework: Framework): boolean {\n\treturn framework === \"vue\";\n}\n\nexport function normalizeFeatures(\n\tfeatures: Feature[] | undefined,\n\tframework: Framework,\n): Feature[] {\n\tlet result: Feature[] = [];\n\n\tfor (const f of features ?? []) {\n\t\tif (ALL_FEATURES.includes(f) && !result.includes(f)) {\n\t\t\tresult.push(f);\n\t\t}\n\t}\n\n\tresult = resolveMutuallyExclusiveLint(result);\n\n\tif (result.includes(\"biome\") && !supportsBiomeLinter(framework)) {\n\t\tresult = result.filter((f) => f !== \"biome\");\n\t}\n\n\treturn result;\n}\n","import path from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport ejs from \"ejs\";\nimport fs from \"fs-extra\";\nimport { green, red } from \"kolorist\";\nimport packageJson from \"../package.json\";\nimport type { CreateOptions, TemplateContext } from \"./types.js\";\nimport {\n\thasFeature,\n\tpmDevCommand,\n\tpmInstallCommand,\n\tpmTestCommand,\n\tresolveTemplateId,\n} from \"./utils.js\";\n\nconst __dirname = path.dirname(fileURLToPath(import.meta.url));\n\nfunction getTemplatesRoot(): string {\n\t// dist/index.mjs -> ../templates ; dev tsx -> ../templates\n\treturn path.resolve(__dirname, \"../templates\");\n}\n\nfunction shouldSkip(relPath: string, options: CreateOptions): boolean {\n\tconst normalized = relPath.replace(/\\\\/g, \"/\");\n\tconst { features } = options;\n\n\tif (!hasFeature(features, \"vitest\")) {\n\t\tif (\n\t\t\tnormalized.startsWith(\"tests/\") ||\n\t\t\tnormalized.includes(\"/tests/\") ||\n\t\t\tnormalized.includes(\"vitest.config\") ||\n\t\t\tnormalized.startsWith(\"src/test/\")\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t}\n\tif (!hasFeature(features, \"lint\")) {\n\t\tif (\n\t\t\tnormalized.endsWith(\"eslint.config.js\") ||\n\t\t\tnormalized.endsWith(\"eslint.config.js.ejs\")\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t\tif (relPath.endsWith(\".prettierrc.ejs\")) return true;\n\t\tif (relPath.endsWith(\".prettierignore\")) return true;\n\t}\n\tif (!hasFeature(features, \"biome\")) {\n\t\tif (normalized === \"biome.json\" || normalized.endsWith(\"/biome.json\")) {\n\t\t\treturn true;\n\t\t}\n\t\tif (\n\t\t\tnormalized === \".vscode/settings.json\" ||\n\t\t\tnormalized.endsWith(\"/.vscode/settings.json\")\n\t\t) {\n\t\t\treturn true;\n\t\t}\n\t}\n\tif (\n\t\trelPath.endsWith(\"pnpm-lock.yaml\") ||\n\t\trelPath.endsWith(\"package-lock.json\") ||\n\t\trelPath.endsWith(\"yarn.lock\")\n\t) {\n\t\treturn true;\n\t}\n\treturn false;\n}\n\nasync function renderFile(\n\tsrc: string,\n\tdest: string,\n\tcontext: TemplateContext,\n): Promise<void> {\n\tconst content = await fs.readFile(src, \"utf-8\");\n\tconst rendered = ejs.render(content, context, { rmWhitespace: false });\n\tawait fs.ensureDir(path.dirname(dest));\n\tawait fs.writeFile(dest, rendered, \"utf-8\");\n}\n\nasync function copyTemplateDir(\n\ttemplateDir: string,\n\ttargetDir: string,\n\tcontext: TemplateContext,\n\toptions: CreateOptions,\n\trelBase = \"\",\n): Promise<void> {\n\tconst entries = await fs.readdir(templateDir, { withFileTypes: true });\n\n\tfor (const entry of entries) {\n\t\tconst srcPath = path.join(templateDir, entry.name);\n\t\tconst relPath = relBase ? `${relBase}/${entry.name}` : entry.name;\n\n\t\tif (shouldSkip(relPath, options)) continue;\n\n\t\tif (entry.isDirectory()) {\n\t\t\tawait copyTemplateDir(\n\t\t\t\tsrcPath,\n\t\t\t\tpath.join(targetDir, entry.name),\n\t\t\t\tcontext,\n\t\t\t\toptions,\n\t\t\t\trelPath,\n\t\t\t);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst isEjs = entry.name.endsWith(\".ejs\");\n\t\tconst templateName = isEjs ? entry.name.slice(0, -4) : entry.name;\n\t\t// npm excludes .gitignore files from published tarballs, so templates\n\t\t// store the file under a portable name and restore it during generation.\n\t\tconst outName = templateName === \"_gitignore\" ? \".gitignore\" : templateName;\n\t\tconst destPath = path.join(targetDir, outName);\n\n\t\tif (isEjs) {\n\t\t\tawait renderFile(srcPath, destPath, context);\n\t\t} else {\n\t\t\tawait fs.ensureDir(path.dirname(destPath));\n\t\t\tawait fs.copy(srcPath, destPath);\n\t\t}\n\t}\n}\n\nexport async function generateProject(options: CreateOptions): Promise<string> {\n\tconst templateId = resolveTemplateId(options.framework, options.variant);\n\tconst templateDir = path.join(getTemplatesRoot(), templateId);\n\n\tif (!(await fs.pathExists(templateDir))) {\n\t\tthrow new Error(\n\t\t\t`Template \"${templateId}\" is not available (${options.framework} + ${options.variant}).`,\n\t\t);\n\t}\n\n\tconst targetDir = path.resolve(process.cwd(), options.projectName);\n\n\tif (await fs.pathExists(targetDir)) {\n\t\tconst files = await fs.readdir(targetDir);\n\t\tif (files.length > 0) {\n\t\t\tthrow new Error(`Target directory is not empty: ${targetDir}`);\n\t\t}\n\t}\n\n\tconst context: TemplateContext = {\n\t\tprojectName: options.projectName,\n\t\tpackageName: options.packageName,\n\t\tvariant: options.variant,\n\t\tfeatures: options.features,\n\t\tdevkitVersion: packageJson.version,\n\t\tisTypeScript: options.variant === \"typescript\",\n\t};\n\n\tawait fs.ensureDir(targetDir);\n\tawait copyTemplateDir(templateDir, targetDir, context, options);\n\n\treturn targetDir;\n}\n\nexport function printNextSteps(\n\ttargetDir: string,\n\toptions: CreateOptions,\n\tinstalled: boolean,\n\tautoStartDev = false,\n): void {\n\tconst rel = path.relative(process.cwd(), targetDir) || \".\";\n\tconst commands: string[] = [];\n\n\tif (rel !== \".\" && !autoStartDev) {\n\t\tcommands.push(`cd ${rel}`);\n\t}\n\tconst { packageManager } = options;\n\n\tif (!installed) {\n\t\tcommands.push(pmInstallCommand(packageManager));\n\t}\n\tif (!autoStartDev) {\n\t\tcommands.push(pmDevCommand(packageManager));\n\t}\n\tif (hasFeature(options.features, \"vitest\")) {\n\t\tcommands.push(pmTestCommand(packageManager));\n\t}\n\n\tif (commands.length > 0) {\n\t\tconsole.log(green(\"\\nDone. Now run:\\n\"));\n\t\tfor (const command of commands) {\n\t\t\tconsole.log(` ${command}`);\n\t\t}\n\t\tconsole.log(\"\");\n\t} else {\n\t\tconsole.log(green(\"\\nDone.\\n\"));\n\t}\n\n\tconsole.log(\"Optional: Initialize Git in your project directory with:\\n\");\n\tconsole.log(' git init && git add -A && git commit -m \"initial commit\"');\n\tconsole.log(\"\");\n}\n\nexport function printError(err: unknown): void {\n\tconst msg = err instanceof Error ? err.message : String(err);\n\tconsole.error(red(`\\n✖ ${msg}\\n`));\n}\n","import { checkbox, confirm, input, select } from \"@inquirer/prompts\";\nimport type { CreateOptions, Feature, Framework, Variant } from \"./types.js\";\nimport {\n\tassertValidPackageName,\n\tdefaultFeatures,\n\tdetectInvokedPackageManager,\n\tisBiomeExperimental,\n\tsupportsBiomeLinter,\n\tsupportsOptionalFeatures,\n\ttoPackageName,\n} from \"./utils.js\";\n\nexport async function runPrompts(\n\tdefaults: Partial<CreateOptions> = {},\n): Promise<CreateOptions> {\n\tconst projectName = await input({\n\t\tmessage: \"Project name:\",\n\t\tdefault: defaults.projectName ?? \"xunlei-plugin-project\",\n\t});\n\n\tconst packageName = toPackageName(defaults.packageName ?? projectName);\n\tassertValidPackageName(packageName);\n\n\tconst framework = await select({\n\t\tmessage: \"Select a framework:\",\n\t\tchoices: [\n\t\t\t{ name: \"Vanilla\", value: \"vanilla\" as const },\n\t\t\t{ name: \"Vue\", value: \"vue\" as const },\n\t\t\t{ name: \"React\", value: \"react\" as const },\n\t\t],\n\t\tdefault: defaults.framework ?? \"vanilla\",\n\t});\n\n\tconst variant = await selectVariant(defaults.variant);\n\n\tconst features = supportsOptionalFeatures(framework)\n\t\t? await promptFeatures(\n\t\t\t\tframework,\n\t\t\t\tvariant,\n\t\t\t\tdefaults.features ?? defaultFeatures(framework),\n\t\t\t)\n\t\t: [];\n\n\tconst packageManager =\n\t\tdefaults.packageManager ?? detectInvokedPackageManager();\n\n\tconst install = await confirm({\n\t\tmessage: `Install dependencies with ${packageManager} and start now?`,\n\t\tdefault: defaults.install ?? true,\n\t});\n\n\treturn {\n\t\tprojectName,\n\t\tpackageName,\n\t\tframework,\n\t\tvariant,\n\t\tfeatures,\n\t\tpackageManager,\n\t\tinstall,\n\t};\n}\n\nasync function promptFeatures(\n\tframework: Framework,\n\t_variant: Variant,\n\tdefaultSelected: Feature[],\n): Promise<Feature[]> {\n\tconst features: Feature[] = [];\n\n\tconst wantsLint = await promptAddLinter(defaultSelected);\n\tif (wantsLint) {\n\t\tfeatures.push(await promptLintTool(framework, defaultSelected));\n\t}\n\n\tconst extra = await checkbox({\n\t\tmessage: \"Select additional features:\",\n\t\tchoices: [\n\t\t\t{\n\t\t\t\tname: \"Vitest (unit testing)\",\n\t\t\t\tvalue: \"vitest\",\n\t\t\t\tchecked: defaultSelected.includes(\"vitest\"),\n\t\t\t},\n\t\t],\n\t});\n\tfeatures.push(...(extra as Feature[]));\n\n\treturn features;\n}\n\nasync function promptAddLinter(_defaultSelected: Feature[]): Promise<boolean> {\n\treturn select({\n\t\tmessage: \"Add linter / formatter?\",\n\t\tchoices: [\n\t\t\t{ name: \"No\", value: false as const },\n\t\t\t{ name: \"Yes\", value: true as const },\n\t\t],\n\t\tdefault: true,\n\t});\n}\n\nasync function promptLintTool(\n\tframework: Framework,\n\tdefaultSelected: Feature[],\n): Promise<\"lint\" | \"biome\"> {\n\tconst biomeLabel = isBiomeExperimental(framework)\n\t\t? \"Biome (lint + format) (Experimental)\"\n\t\t: \"Biome (lint + format)\";\n\n\tconst choices = supportsBiomeLinter(framework)\n\t\t? [\n\t\t\t\t{ name: \"ESLint + Prettier\", value: \"lint\" as const },\n\t\t\t\t{ name: biomeLabel, value: \"biome\" as const },\n\t\t\t]\n\t\t: [{ name: \"ESLint + Prettier\", value: \"lint\" as const }];\n\n\treturn select({\n\t\tmessage: \"Select linter / formatter:\",\n\t\tchoices,\n\t\tdefault: defaultSelected.includes(\"biome\") ? \"biome\" : \"lint\",\n\t});\n}\n\nasync function selectVariant(defaultVariant?: Variant): Promise<Variant> {\n\treturn select({\n\t\tmessage: \"Select a variant:\",\n\t\tchoices: [\n\t\t\t{ name: \"TypeScript\", value: \"typescript\" as const },\n\t\t\t{ name: \"JavaScript\", value: \"javascript\" as const },\n\t\t],\n\t\tdefault: defaultVariant ?? \"typescript\",\n\t});\n}\n","import { Command } from \"commander\";\nimport { execa } from \"execa\";\nimport { cyan } from \"kolorist\";\nimport packageJson from \"../package.json\";\nimport { generateProject, printError, printNextSteps } from \"./generator.js\";\nimport { runPrompts } from \"./prompts.js\";\nimport type { CreateOptions, Framework, Variant } from \"./types.js\";\nimport {\n\tassertValidPackageName,\n\tdetectInvokedPackageManager,\n\tnormalizeFeatures,\n\tparseFeatures,\n\tparseFramework,\n\tparsePackageManager,\n\tparseVariant,\n\tpmDevArgs,\n\tpmDevCommand,\n\ttoPackageName,\n} from \"./utils.js\";\n\nconst CLI_NAME = \"@xunlei-open/create-miniapp\";\n\nconst program = new Command();\n\nprogram\n\t.name(CLI_NAME)\n\t.description(\"Xunlei Open Platform plugin scaffold\")\n\t.version(packageJson.version)\n\t.argument(\"[project-name]\", \"project name\")\n\t.option(\"--framework <framework>\", \"vanilla | vue | react\")\n\t.option(\"--variant <variant>\", \"typescript | javascript\")\n\t.option(\n\t\t\"--features <features>\",\n\t\t\"comma-separated: lint,biome,vitest (lint and biome are mutually exclusive; eslint/prettier alias lint)\",\n\t)\n\t.option(\"--package-manager <pm>\", \"npm | yarn | pnpm\")\n\t.option(\"--no-install\", \"skip dependency installation\")\n\t.option(\"-y, --yes\", \"use defaults and skip prompts\")\n\t.action(async (projectName: string | undefined, opts) => {\n\t\ttry {\n\t\t\tconst defaults: Partial<CreateOptions> = {};\n\t\t\tif (projectName) defaults.projectName = projectName;\n\n\t\t\tconst frameworkInput = opts.framework;\n\t\t\tif (frameworkInput) {\n\t\t\t\tconst parsed = parseFramework(frameworkInput);\n\t\t\t\tif (!parsed) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unknown framework: ${frameworkInput} (supported: vanilla | vue | react)`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tdefaults.framework = parsed;\n\t\t\t}\n\n\t\t\tconst variantInput = opts.variant;\n\t\t\tif (variantInput) {\n\t\t\t\tconst parsed = parseVariant(variantInput);\n\t\t\t\tif (!parsed) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unknown variant: ${variantInput} (supported: typescript | javascript)`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tdefaults.variant = parsed;\n\t\t\t}\n\n\t\t\tconst featuresInput = opts.features;\n\t\t\tif (featuresInput) {\n\t\t\t\tconst parsed = parseFeatures(featuresInput);\n\t\t\t\tif (parsed.length === 0) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unknown features: ${featuresInput} (supported: lint, biome, vitest; eslint/prettier alias lint)`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tdefaults.features = parsed;\n\t\t\t}\n\n\t\t\tif (opts.install === false) defaults.install = false;\n\n\t\t\tconst packageManagerInput = opts.packageManager;\n\t\t\tif (packageManagerInput) {\n\t\t\t\tconst parsed = parsePackageManager(packageManagerInput);\n\t\t\t\tif (!parsed) {\n\t\t\t\t\tthrow new Error(\n\t\t\t\t\t\t`Unknown package manager: ${packageManagerInput} (supported: npm | yarn | pnpm)`,\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t\tdefaults.packageManager = parsed;\n\t\t\t} else {\n\t\t\t\tdefaults.packageManager = detectInvokedPackageManager();\n\t\t\t}\n\n\t\t\tconsole.log(cyan(`\\n ${CLI_NAME} \\n`));\n\t\t\tconst options = opts.yes\n\t\t\t\t? resolveOptionsFromDefaults(defaults)\n\t\t\t\t: await runPrompts(defaults);\n\t\t\tconst targetDir = await generateProject(options);\n\n\t\t\tlet installed = false;\n\t\t\tif (options.install) {\n\t\t\t\tconst { packageManager: pm } = options;\n\t\t\t\tconsole.log(cyan(`\\nInstalling dependencies (${pm})...\\n`));\n\t\t\t\tawait execa(pm, [\"install\"], {\n\t\t\t\t\tcwd: targetDir,\n\t\t\t\t\tstdio: \"inherit\",\n\t\t\t\t});\n\t\t\t\tinstalled = true;\n\n\t\t\t\tprintNextSteps(targetDir, options, installed, true);\n\t\t\t\tconsole.log(cyan(`\\nStarting dev server (${pmDevCommand(pm)})...\\n`));\n\t\t\t\tawait execa(pm, pmDevArgs(pm), { cwd: targetDir, stdio: \"inherit\" });\n\t\t\t} else {\n\t\t\t\tprintNextSteps(targetDir, options, installed);\n\t\t\t}\n\t\t} catch (err) {\n\t\t\tprintError(err);\n\t\t\tprocess.exit(1);\n\t\t}\n\t});\n\nfunction resolveOptionsFromDefaults(\n\tdefaults: Partial<CreateOptions>,\n): CreateOptions {\n\tconst projectName = defaults.projectName ?? \"xunlei-plugin-project\";\n\tconst packageName = toPackageName(defaults.packageName ?? projectName);\n\tassertValidPackageName(packageName);\n\n\tconst framework = (defaults.framework ?? \"vanilla\") as Framework;\n\tconst variant = (defaults.variant ?? \"typescript\") as Variant;\n\n\tconst features = normalizeFeatures(defaults.features, framework);\n\tconst packageManager =\n\t\tdefaults.packageManager ?? detectInvokedPackageManager();\n\tconst install = defaults.install ?? true;\n\n\treturn {\n\t\tprojectName,\n\t\tpackageName,\n\t\tframework,\n\t\tvariant,\n\t\tfeatures,\n\t\tpackageManager,\n\t\tinstall,\n\t};\n}\n\nprogram.parse();\n"],"mappings":";;;;;;;;;;;;;;ACGA,SAAgB,cAAc,OAAuB;CACpD,OAAO,MACL,KAAK,CAAC,CACN,YAAY,CAAC,CACb,QAAQ,QAAQ,GAAG,CAAC,CACpB,QAAQ,gBAAgB,GAAG,CAAC,CAC5B,QAAQ,OAAO,GAAG,CAAC,CACnB,QAAQ,UAAU,EAAE;AACvB;AAEA,SAAgB,uBAAuB,MAAoB;CAC1D,MAAM,SAAS,SAAS,IAAI;CAC5B,IAAI,CAAC,OAAO,qBAAqB;EAChC,MAAM,SAAS,CAAC,GAAI,OAAO,UAAU,CAAC,GAAI,GAAI,OAAO,YAAY,CAAC,CAAE;EACpE,MAAM,IAAI,MAAM,yBAAyB,KAAK,KAAK,OAAO,KAAK,IAAI,GAAG;CACvE;AACD;AAEA,MAAM,eAA0B;CAAC;CAAQ;CAAS;AAAQ;AAE1D,MAAM,kBAA2C;CAChD,MAAM;CACN,QAAQ;CACR,UAAU;CACV,OAAO;CACP,QAAQ;AACT;AAEA,MAAM,eAA2D;CAChE,SAAS;EACR,YAAY;EACZ,YAAY;CACb;CACA,KAAK;EACJ,YAAY;EACZ,YAAY;CACb;CACA,OAAO;EACN,YAAY;EACZ,YAAY;CACb;AACD;;AAGA,SAAgB,kBACf,WACA,SACS;CACT,OAAO,aAAa,UAAU,CA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AAoB,gCACjD;GAED,SAAS,iBAAiB;EAC3B,OACC,SAAS,iBAAiB,4BAA4B;EAGvD,QAAQ,IAAI,KAAK,MAAM,SAAS,IAAI,CAAC;EACrC,MAAM,UAAU,KAAK,MAClB,2BAA2B,QAAQ,IACnC,MAAM,WAAW,QAAQ;EAC5B,MAAM,YAAY,MAAM,gBAAgB,OAAO;EAE/C,IAAI,YAAY;EAChB,IAAI,QAAQ,SAAS;GACpB,MAAM,EAAE,gBAAgB,OAAO;GAC/B,QAAQ,IAAI,KAAK,8BAA8B,GAAG,OAAO,CAAC;GAC1D,MAAM,MAAM,IAAI,CAAC,SAAS,GAAG;IAC5B,KAAK;IACL,OAAO;GACR,CAAC;GACD,YAAY;GAEZ,eAAe,WAAW,SAAS,WAAW,IAAI;GAClD,QAAQ,IAAI,KAAK,0BAA0B,aAAa,EAAE,EAAE,OAAO,CAAC;GACpE,MAAM,MAAM,IAAI,UAAU,EAAE,GAAG;IAAE,KAAK;IAAW,OAAO;GAAU,CAAC;EACpE,OACC,eAAe,WAAW,SAAS,SAAS;CAE9C,SAAS,KAAK;EACb,WAAW,GAAG;EACd,QAAQ,KAAK,CAAC;CACf;AACD,CAAC;AAEF,SAAS,2BACR,UACgB;CAChB,MAAM,cAAc,SAAS,eAAe;CAC5C,MAAM,cAAc,cAAc,SAAS,eAAe,WAAW;CACrE,uBAAuB,WAAW;CAElC,MAAM,YAAa,SAAS,aAAa;CAQzC,OAAO;EACN;EACA;EACA;EACA,SAXgB,SAAS,WAAW;EAYpC,UAVgB,kBAAkB,SAAS,UAAU,SAU9C;EACP,gBATA,SAAS,kBAAkB,4BAA4B;EAUvD,SATe,SAAS,WAAW;CAUpC;AACD;AAEA,QAAQ,MAAM"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@xunlei-open/create-miniapp",
3
+ "version": "0.1.1-beta.0",
4
+ "description": "Create a Xunlei Miniapp with Vanilla, Vue, or React",
5
+ "type": "module",
6
+ "bin": {
7
+ "create-miniapp": "./dist/index.mjs"
8
+ },
9
+ "files": [
10
+ "dist",
11
+ "templates",
12
+ "README.md"
13
+ ],
14
+ "keywords": [
15
+ "xunlei",
16
+ "miniapp",
17
+ "scaffold",
18
+ "vite",
19
+ "create-miniapp"
20
+ ],
21
+ "license": "MIT",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "git+https://github.com/xunlei-open/miniapp-devkit.git",
25
+ "directory": "packages/create-miniapp"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/xunlei-open/miniapp-devkit/issues"
29
+ },
30
+ "homepage": "https://github.com/xunlei-open/miniapp-devkit#readme",
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "engines": {
35
+ "node": ">=20.19.0"
36
+ },
37
+ "dependencies": {
38
+ "@inquirer/prompts": "^7.4.0",
39
+ "commander": "^13.1.0",
40
+ "ejs": "^3.1.10",
41
+ "execa": "^9.5.2",
42
+ "fs-extra": "^11.3.0",
43
+ "kolorist": "^1.8.0",
44
+ "validate-npm-package-name": "^6.0.0"
45
+ },
46
+ "devDependencies": {
47
+ "@types/ejs": "^3.1.5",
48
+ "@types/fs-extra": "^11.0.4",
49
+ "@types/validate-npm-package-name": "^4.0.2",
50
+ "tsx": "^4.20.0"
51
+ },
52
+ "scripts": {
53
+ "dev": "tsx src/index.ts",
54
+ "build": "tsdown",
55
+ "clean": "node -e \"require('node:fs').rmSync('dist',{recursive:true,force:true})\"",
56
+ "check": "tsc --noEmit",
57
+ "test": "vitest run __tests__"
58
+ }
59
+ }
@@ -0,0 +1,3 @@
1
+ dist
2
+ node_modules
3
+ pnpm-lock.yaml