create-unibest 3.2.0 → 3.3.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 (3) hide show
  1. package/README.md +32 -12
  2. package/dist/index.js +227 -143
  3. package/package.json +2 -1
package/README.md CHANGED
@@ -15,7 +15,38 @@
15
15
 
16
16
  ## 🚤 快速使用
17
17
 
18
- ### 全局安装
18
+ ```shell
19
+ pnpm create unibest <command> [options] # 基本命令格式
20
+ pnpm create unibest my-project # 创建新的unibest项目
21
+ pnpm create unibest -v # 查看版本信息
22
+ pnpm create unibest -h # 查看帮助信息
23
+ ```
24
+
25
+ ### 命令行参数
26
+
27
+ 支持通过命令行参数跳过交互式询问,实现静默/快捷创建。
28
+
29
+ | 参数 | 简写 | 说明 | 可选值 / 示例 |
30
+ | :----------- | :--- | :----------- | :----------------------------------------------------------------------------------------------------- |
31
+ | `--platform` | `-p` | 指定平台 | `h5`, `mp-weixin`, `app`, `mp-alipay`, `mp-toutiao`<br>示例: `-p h5,mp-weixin` 或 `-p h5 -p mp-weixin` |
32
+ | `--ui` | `-u` | 指定 UI 库 | `wot-ui`, `uview-pro`, `sard-uniapp`, `uv-ui`, `uview-plus`, `none` |
33
+ | `--login` | `-l` | 启用登录策略 | 无值,存在即开启 |
34
+ | `--i18n` | `-i` | 启用多语言 | 无值,存在即开启 |
35
+
36
+ #### 示例
37
+
38
+ ```bash
39
+ # 1. 基础用法:指定 UI 库和平台(H5 + 微信小程序)
40
+ pnpm create unibest my-project -u wot-ui -p h5,mp-weixin
41
+
42
+ # 2. 进阶用法:指定 UI 库,并开启登录策略和多语言
43
+ pnpm create unibest my-project -u uview-plus -l -i
44
+
45
+ # 3. 极简用法:不使用 UI 库,但支持多端(H5 + App + 微信小程序)
46
+ pnpm create unibest my-project -u none -p h5,app,mp-weixin
47
+ ```
48
+
49
+ ### 全局安装(可选)
19
50
 
20
51
  ```shell
21
52
  npm i -g create-unibest # 全局安装,得到 best 命令
@@ -27,17 +58,6 @@ npm update -g create-unibest # 更新 create-unibest 包
27
58
  ```shell
28
59
  best <command> [options] # 基本命令格式
29
60
  best my-project # 创建新的unibest项目
30
- best new my-project # 创建新的unibest项目
31
61
  best -v # 查看版本信息
32
62
  best -h # 查看帮助信息
33
63
  ```
34
-
35
- ### 临时使用
36
-
37
- ```shell
38
- pnpm create unibest <command> [options] # 基本命令格式
39
- pnpm create unibest my-project # 创建新的unibest项目
40
- pnpm create unibest new my-project # 创建新的unibest项目
41
- pnpm create unibest -v # 查看版本信息
42
- pnpm create unibest -h # 查看帮助信息
43
- ```
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import process4 from "process";
4
+ import process5 from "process";
5
5
  import minimist from "minimist";
6
6
 
7
7
  // src/commands/create/prompts.ts
@@ -58,8 +58,46 @@ function checkProjectNameExistAndValidate(_projectName) {
58
58
  }
59
59
 
60
60
  // src/commands/create/prompts.ts
61
- import { green as green2 } from "kolorist";
61
+ import { green as green2, red as red2 } from "kolorist";
62
+ import process2 from "process";
63
+ var VALID_PLATFORMS = ["h5", "mp-weixin", "app", "mp-alipay", "mp-toutiao"];
64
+ var VALID_UI_LIBRARIES = ["none", "wot-ui", "uview-pro", "sard-uniapp", "uv-ui", "uview-plus"];
62
65
  async function promptUser(projectName, argv = {}) {
66
+ let platforms;
67
+ let uiLibrary;
68
+ let loginStrategy;
69
+ let i18n;
70
+ const platformArg = argv.p || argv.platform;
71
+ if (platformArg) {
72
+ let parsedPlatforms = [];
73
+ if (Array.isArray(platformArg)) {
74
+ parsedPlatforms = platformArg;
75
+ } else if (typeof platformArg === "string") {
76
+ parsedPlatforms = platformArg.split(",");
77
+ }
78
+ const invalidPlatforms = parsedPlatforms.filter((p) => !VALID_PLATFORMS.includes(p));
79
+ if (invalidPlatforms.length > 0) {
80
+ console.error(red2(`\u65E0\u6548\u7684\u5E73\u53F0\u53C2\u6570: ${invalidPlatforms.join(", ")}`));
81
+ console.error(red2(`\u53EF\u9009\u503C: ${VALID_PLATFORMS.join(", ")}`));
82
+ process2.exit(1);
83
+ }
84
+ platforms = parsedPlatforms;
85
+ }
86
+ const uiArg = argv.u || argv.ui;
87
+ if (uiArg) {
88
+ if (!VALID_UI_LIBRARIES.includes(uiArg)) {
89
+ console.error(red2(`\u65E0\u6548\u7684UI\u5E93\u53C2\u6570: ${uiArg}`));
90
+ console.error(red2(`\u53EF\u9009\u503C: ${VALID_UI_LIBRARIES.join(", ")}`));
91
+ process2.exit(1);
92
+ }
93
+ uiLibrary = uiArg;
94
+ }
95
+ if (argv.l || argv.login) {
96
+ loginStrategy = true;
97
+ }
98
+ if (argv.i || argv.i18n) {
99
+ i18n = true;
100
+ }
63
101
  try {
64
102
  if (!projectName) {
65
103
  const inputProjectName = await text({
@@ -74,58 +112,70 @@ async function promptUser(projectName, argv = {}) {
74
112
  });
75
113
  if (isCancel(inputProjectName)) {
76
114
  cancel("\u64CD\u4F5C\u5DF2\u53D6\u6D88");
77
- process.exit(0);
115
+ process2.exit(0);
78
116
  }
79
117
  projectName = inputProjectName;
80
118
  }
81
- const platforms = await multiselect({
82
- message: `\u8BF7\u9009\u62E9\u9700\u8981\u652F\u6301\u7684\u5E73\u53F0\uFF08\u591A\u9009\uFF09${green2("[\u811A\u624B\u67B6\u5C06\u6839\u636E\u6240\u9009\u5E73\u53F0\u751F\u6210\u5BF9\u5E94\u7684\u5E73\u53F0\u4EE3\u7801\uFF0C\u8BF7\u6839\u636E\u5B9E\u9645\u60C5\u51B5\u9009\u62E9]")}`,
83
- options: [
84
- { value: "h5", label: "H5" },
85
- { value: "mp-weixin", label: "\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F" },
86
- { value: "app", label: "APP" },
87
- { value: "mp-alipay", label: "\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\uFF08\u5305\u542B\u9489\u9489\uFF09" },
88
- { value: "mp-toutiao", label: "\u6296\u97F3\u5C0F\u7A0B\u5E8F" }
89
- ],
90
- initialValues: ["h5"],
91
- // 默认选择 H5
92
- required: true
93
- });
94
- if (isCancel(platforms)) {
95
- cancel("\u64CD\u4F5C\u5DF2\u53D6\u6D88");
96
- process.exit(0);
119
+ if (!platforms) {
120
+ const selectedPlatforms = await multiselect({
121
+ message: `\u8BF7\u9009\u62E9\u9700\u8981\u652F\u6301\u7684\u5E73\u53F0\uFF08\u591A\u9009\uFF09${green2("[\u811A\u624B\u67B6\u5C06\u6839\u636E\u6240\u9009\u5E73\u53F0\u751F\u6210\u5BF9\u5E94\u7684\u5E73\u53F0\u4EE3\u7801\uFF0C\u8BF7\u6839\u636E\u5B9E\u9645\u60C5\u51B5\u9009\u62E9]")}`,
122
+ options: [
123
+ { value: "h5", label: "H5" },
124
+ { value: "mp-weixin", label: "\u5FAE\u4FE1\u5C0F\u7A0B\u5E8F" },
125
+ { value: "app", label: "APP" },
126
+ { value: "mp-alipay", label: "\u652F\u4ED8\u5B9D\u5C0F\u7A0B\u5E8F\uFF08\u5305\u542B\u9489\u9489\uFF09" },
127
+ { value: "mp-toutiao", label: "\u6296\u97F3\u5C0F\u7A0B\u5E8F" }
128
+ ],
129
+ initialValues: ["h5"],
130
+ // 默认选择 H5
131
+ required: true
132
+ });
133
+ if (isCancel(selectedPlatforms)) {
134
+ cancel("\u64CD\u4F5C\u5DF2\u53D6\u6D88");
135
+ process2.exit(0);
136
+ }
137
+ platforms = selectedPlatforms;
97
138
  }
98
- const uiLibrary = await select({
99
- message: "\u8BF7\u9009\u62E9UI\u5E93",
100
- options: [
101
- { value: "none", label: "\u65E0UI\u5E93" },
102
- { value: "wot-ui", label: "wot-ui" },
103
- { value: "uview-pro", label: "uview-pro" },
104
- { value: "sard-uniapp", label: "sard-uniapp" },
105
- { value: "uv-ui", label: "uv-ui" },
106
- { value: "uview-plus", label: "uview-plus" }
107
- ],
108
- initialValue: "none"
109
- });
110
- if (isCancel(uiLibrary)) {
111
- cancel("\u64CD\u4F5C\u5DF2\u53D6\u6D88");
112
- process.exit(0);
139
+ if (!uiLibrary) {
140
+ const selectedUiLibrary = await select({
141
+ message: "\u8BF7\u9009\u62E9UI\u5E93",
142
+ options: [
143
+ { value: "none", label: "\u65E0UI\u5E93" },
144
+ { value: "wot-ui", label: "wot-ui" },
145
+ { value: "uview-pro", label: "uview-pro" },
146
+ { value: "sard-uniapp", label: "sard-uniapp" },
147
+ { value: "uv-ui", label: "uv-ui" },
148
+ { value: "uview-plus", label: "uview-plus" }
149
+ ],
150
+ initialValue: "none"
151
+ });
152
+ if (isCancel(selectedUiLibrary)) {
153
+ cancel("\u64CD\u4F5C\u5DF2\u53D6\u6D88");
154
+ process2.exit(0);
155
+ }
156
+ uiLibrary = selectedUiLibrary;
113
157
  }
114
- const loginStrategy = await confirm({
115
- message: `\u662F\u5426\u9700\u8981\u767B\u5F55\u7B56\u7565\uFF08\u9ED1\u767D\u540D\u5355\u3001\u767B\u5F55\u62E6\u622A\u7B49\uFF09\uFF1F${green2("[\u6682\u4E0D\u77E5\u9053\u7684\uFF0C\u9009No\u5373\u53EF\uFF0C\u9879\u76EE\u751F\u6210\u540E\u4E5F\u53EF\u4EE5\u52A0\u8BE5\u7B56\u7565]")}`,
116
- initialValue: false
117
- });
118
- if (isCancel(loginStrategy)) {
119
- cancel("\u64CD\u4F5C\u5DF2\u53D6\u6D88");
120
- process.exit(0);
158
+ if (loginStrategy === void 0) {
159
+ const selectedLoginStrategy = await confirm({
160
+ message: `\u662F\u5426\u9700\u8981\u767B\u5F55\u7B56\u7565\uFF08\u9ED1\u767D\u540D\u5355\u3001\u767B\u5F55\u62E6\u622A\u7B49\uFF09\uFF1F${green2("[\u6682\u4E0D\u77E5\u9053\u7684\uFF0C\u9009No\u5373\u53EF\uFF0C\u9879\u76EE\u751F\u6210\u540E\u4E5F\u53EF\u4EE5\u52A0\u8BE5\u7B56\u7565]")}`,
161
+ initialValue: false
162
+ });
163
+ if (isCancel(selectedLoginStrategy)) {
164
+ cancel("\u64CD\u4F5C\u5DF2\u53D6\u6D88");
165
+ process2.exit(0);
166
+ }
167
+ loginStrategy = selectedLoginStrategy;
121
168
  }
122
- const i18n = await confirm({
123
- message: "\u662F\u5426\u9700\u8981\u591A\u8BED\u8A00i18n\uFF1F",
124
- initialValue: false
125
- });
126
- if (isCancel(i18n)) {
127
- cancel("\u64CD\u4F5C\u5DF2\u53D6\u6D88");
128
- process.exit(0);
169
+ if (i18n === void 0) {
170
+ const selectedI18n = await confirm({
171
+ message: "\u662F\u5426\u9700\u8981\u591A\u8BED\u8A00i18n\uFF1F",
172
+ initialValue: false
173
+ });
174
+ if (isCancel(selectedI18n)) {
175
+ cancel("\u64CD\u4F5C\u5DF2\u53D6\u6D88");
176
+ process2.exit(0);
177
+ }
178
+ i18n = selectedI18n;
129
179
  }
130
180
  return {
131
181
  projectName,
@@ -139,34 +189,105 @@ async function promptUser(projectName, argv = {}) {
139
189
  };
140
190
  } catch (error) {
141
191
  logger.error(`\u8BE2\u95EE\u8FC7\u7A0B\u51FA\u9519: ${error.message}`);
142
- process.exit(1);
192
+ process2.exit(1);
143
193
  }
144
194
  }
145
195
 
146
196
  // src/commands/create/generate.ts
147
- import process3 from "process";
197
+ import process4 from "process";
148
198
  import { log } from "@clack/prompts";
149
199
 
150
200
  // src/utils/cloneRepo.ts
151
201
  import { exec } from "child_process";
152
202
  import { promises as fs } from "fs";
153
203
  import { join as join3 } from "path";
154
- import process2 from "process";
155
- import { red as red2 } from "kolorist";
204
+ import process3 from "process";
205
+ import { red as red3 } from "kolorist";
156
206
 
157
207
  // src/utils/replacePackageJson.ts
158
208
  import { readFileSync, writeFileSync } from "fs";
159
209
  import { join as join2 } from "path";
160
- function replaceContent(filePath, projectName, version2) {
210
+
211
+ // package.json
212
+ var version = "3.3.0";
213
+ var package_default = {
214
+ name: "create-unibest",
215
+ type: "module",
216
+ version,
217
+ updateTime: "2026-01-19",
218
+ packageManager: "pnpm@9.0.0",
219
+ description: "\u5FEB\u901F\u521B\u5EFAunibest\u9879\u76EE\u7684\u811A\u624B\u67B6\u5DE5\u5177",
220
+ author: "",
221
+ license: "ISC",
222
+ keywords: [],
223
+ main: "dist/index.js",
224
+ bin: {
225
+ best: "bin/index.js",
226
+ "create-unibest": "bin/index.js"
227
+ },
228
+ files: [
229
+ "bin",
230
+ "dist"
231
+ ],
232
+ scripts: {
233
+ dev: "cross-env NODE_ENV=development tsup --watch",
234
+ build: "cross-env NODE_ENV=production tsup",
235
+ prepare: "cross-env NODE_ENV=production npm run build",
236
+ start: "cross-env NODE_ENV=development node bin/index.js"
237
+ },
238
+ dependencies: {
239
+ "@clack/prompts": "^0.11.0",
240
+ dayjs: "^1.11.18",
241
+ ejs: "^3.1.10",
242
+ "fs-extra": "^11.3.0",
243
+ kolorist: "^1.8.0",
244
+ minimist: "^1.2.8",
245
+ "node-fetch": "^3.3.2"
246
+ },
247
+ devDependencies: {
248
+ "@types/ejs": "^3.1.5",
249
+ "@types/fs-extra": "^11.0.4",
250
+ "@types/minimist": "^1.2.5",
251
+ "@types/node": "^24.5.0",
252
+ "cross-env": "^7.0.3",
253
+ tsup: "^8.5.0",
254
+ typescript: "^5.9.0"
255
+ }
256
+ };
257
+
258
+ // src/utils/replacePackageJson.ts
259
+ import dayjs from "dayjs";
260
+ function replaceContent(filePath, projectName, version2, options) {
161
261
  const fileContent = JSON.parse(readFileSync(filePath, "utf8"));
162
- fileContent.name = projectName;
163
- fileContent.version = version2;
164
- writeFileSync(filePath, JSON.stringify(fileContent, null, 2));
262
+ const unibestVersion = fileContent["unibest-version"];
263
+ const unibestUpdateTime = fileContent["unibest-update-time"];
264
+ delete fileContent["unibest-version"];
265
+ delete fileContent["unibest-update-time"];
266
+ delete fileContent.metadata;
267
+ delete fileContent.name;
268
+ delete fileContent.version;
269
+ const { projectName: _, ...restOptions } = options;
270
+ const newContent = {
271
+ name: projectName,
272
+ type: fileContent.type,
273
+ // 保持 type 在前(如果存在)
274
+ version: version2,
275
+ unibest: {
276
+ ...restOptions,
277
+ cliVersion: version,
278
+ unibestVersion,
279
+ unibestUpdateTime,
280
+ createdAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
281
+ },
282
+ ...fileContent
283
+ // 剩余字段
284
+ };
285
+ writeFileSync(filePath, JSON.stringify(newContent, null, 2));
165
286
  }
166
- function replacePackageJson(root2, name, version2) {
287
+ function replacePackageJson(root2, name, version2, options) {
167
288
  const projectName = name.toLocaleLowerCase().replace(/\s/g, "-");
168
289
  const pkgPath = join2(root2, "package.json");
169
- replaceContent(pkgPath, projectName, version2);
290
+ replaceContent(pkgPath, projectName, version2, options);
170
291
  }
171
292
 
172
293
  // src/utils/cloneRepo.ts
@@ -174,14 +295,14 @@ async function removeGitFolder(localPath) {
174
295
  const gitFolderPath = join3(localPath, ".git");
175
296
  await fs.rm(gitFolderPath, { recursive: true, force: true });
176
297
  }
177
- var REPO_URL = "https://github.com/unibest-tech/unibest.git";
298
+ var REPO_URL = "https://gitee.com/feige996/unibest.git";
178
299
  async function cloneRepo(projectName, branch) {
179
300
  try {
180
301
  await new Promise((resolve, reject) => {
181
302
  const execStr = `git clone --depth=1 -b ${branch} ${REPO_URL} "${projectName}"`;
182
303
  exec(execStr, async (error) => {
183
304
  if (error) {
184
- console.error(`${red2("exec error:")} ${error}`);
305
+ console.error(`${red3("exec error:")} ${error}`);
185
306
  reject(error);
186
307
  return;
187
308
  }
@@ -195,19 +316,19 @@ async function cloneRepo(projectName, branch) {
195
316
  });
196
317
  return;
197
318
  } catch (error) {
198
- console.error(`${red2("cloneRepo error:")} ${error}`);
319
+ console.error(`${red3("cloneRepo error:")} ${error}`);
199
320
  throw new Error("cloneRepo error");
200
321
  }
201
322
  }
202
- async function cloneRepoByBranch(root2, name, branch) {
323
+ async function cloneRepoByBranch(root2, name, branch, options) {
203
324
  try {
204
325
  await cloneRepo(name, branch);
205
326
  } catch (error) {
206
- console.error(`${red2(`\u6A21\u677F\u7C7B\u578B${branch}\u4E0B\u8F7D\u5931\u8D25\uFF01`)} ${error}`);
207
- process2.exit(1);
327
+ console.error(`${red3(`\u6A21\u677F\u7C7B\u578B${branch}\u4E0B\u8F7D\u5931\u8D25\uFF01`)} ${error}`);
328
+ process3.exit(1);
208
329
  }
209
330
  const projectPath = join3(root2, name);
210
- replacePackageJson(projectPath, name, "1.0.0");
331
+ replacePackageJson(projectPath, name, "1.0.0", options);
211
332
  }
212
333
 
213
334
  // src/utils/uiLibrary.ts
@@ -567,22 +688,22 @@ function debug(...args) {
567
688
 
568
689
  // src/commands/create/generate.ts
569
690
  import path from "path";
570
- var root = process3.cwd();
691
+ var root = process4.cwd();
571
692
  async function generateProject(options) {
572
693
  debug("generateProject options", options);
573
694
  const { projectName, platforms, uiLibrary, loginStrategy, i18n } = options;
574
695
  if (!loginStrategy && !i18n) {
575
696
  debug("\u62C9\u53D6 base \u5206\u652F");
576
- await cloneRepoByBranch(root, projectName, "base");
697
+ await cloneRepoByBranch(root, projectName, "base", options);
577
698
  } else if (!loginStrategy && i18n) {
578
699
  debug("\u62C9\u53D6 base-i18n \u5206\u652F");
579
- await cloneRepoByBranch(root, projectName, "base-i18n");
700
+ await cloneRepoByBranch(root, projectName, "base-i18n", options);
580
701
  } else if (loginStrategy && !i18n) {
581
702
  debug("\u62C9\u53D6 base-login \u5206\u652F");
582
- await cloneRepoByBranch(root, projectName, "base-login");
703
+ await cloneRepoByBranch(root, projectName, "base-login", options);
583
704
  } else if (loginStrategy && i18n) {
584
705
  debug("\u62C9\u53D6 base-login-i18n \u5206\u652F");
585
- await cloneRepoByBranch(root, projectName, "base-login-i18n");
706
+ await cloneRepoByBranch(root, projectName, "base-login-i18n", options);
586
707
  }
587
708
  const projectPath = path.join(root, projectName);
588
709
  if (uiLibrary === "none") {
@@ -611,67 +732,19 @@ async function generateProject(options) {
611
732
  }
612
733
  }
613
734
 
614
- // package.json
615
- var version = "3.2.0";
616
- var package_default = {
617
- name: "create-unibest",
618
- type: "module",
619
- version,
620
- packageManager: "pnpm@9.0.0",
621
- description: "\u5FEB\u901F\u521B\u5EFAunibest\u9879\u76EE\u7684\u811A\u624B\u67B6\u5DE5\u5177",
622
- author: "",
623
- license: "ISC",
624
- keywords: [],
625
- main: "dist/index.js",
626
- bin: {
627
- best: "bin/index.js",
628
- "create-unibest": "bin/index.js"
629
- },
630
- files: [
631
- "bin",
632
- "dist"
633
- ],
634
- scripts: {
635
- dev: "cross-env NODE_ENV=development tsup --watch",
636
- build: "cross-env NODE_ENV=production tsup",
637
- prepare: "cross-env NODE_ENV=production npm run build",
638
- start: "cross-env NODE_ENV=development node bin/index.js"
639
- },
640
- dependencies: {
641
- "@clack/prompts": "^0.11.0",
642
- dayjs: "^1.11.18",
643
- ejs: "^3.1.10",
644
- "fs-extra": "^11.3.0",
645
- kolorist: "^1.8.0",
646
- minimist: "^1.2.8",
647
- "node-fetch": "^3.3.2"
648
- },
649
- devDependencies: {
650
- "@types/ejs": "^3.1.5",
651
- "@types/fs-extra": "^11.0.4",
652
- "@types/minimist": "^1.2.5",
653
- "@types/node": "^24.5.0",
654
- "cross-env": "^7.0.3",
655
- tsup: "^8.5.0",
656
- typescript: "^5.9.0"
657
- }
658
- };
659
-
660
735
  // src/commands/create.ts
661
736
  import { intro, log as log2 } from "@clack/prompts";
662
- import { bold as bold3, yellow as yellow3, green as green3 } from "kolorist";
737
+ import { bold as bold2, yellow as yellow3, green as green3 } from "kolorist";
663
738
 
664
739
  // src/utils/unibestVersion.ts
665
740
  import fetch from "node-fetch";
666
- async function getUnibestVersionFromGithub() {
741
+ async function getUnibestVersionFromGitee() {
667
742
  try {
668
- const apiUrl = `https://api.github.com/repos/feige996/unibest/contents/package.json?ref=main`;
743
+ const apiUrl = `https://gitee.com/api/v5/repos/feige996/unibest/contents/package.json?ref=main`;
669
744
  const response = await fetch(apiUrl, {
670
745
  method: "GET",
671
746
  headers: {
672
- "Content-Type": "application/json",
673
- // GitHub API 要求 User-Agent 头
674
- "User-Agent": "unibest-cli"
747
+ "Content-Type": "application/json"
675
748
  }
676
749
  });
677
750
  if (response.ok) {
@@ -694,12 +767,12 @@ async function getUnibestVersionFromGithub() {
694
767
 
695
768
  // src/utils/beacon.ts
696
769
  import fetch2 from "node-fetch";
697
- import dayjs from "dayjs";
770
+ import dayjs2 from "dayjs";
698
771
  import os from "os";
699
772
  import crypto from "crypto";
700
773
  async function beacon(options) {
701
774
  try {
702
- const unibestVersion = await getUnibestVersionFromGithub();
775
+ const unibestVersion = await getUnibestVersionFromGitee();
703
776
  const deviceIdentifier = generateDeviceIdentifier();
704
777
  await fetch2("https://ukw0y1.laf.run/create-unibest-v3/beacon", {
705
778
  method: "POST",
@@ -710,7 +783,7 @@ async function beacon(options) {
710
783
  ...options,
711
784
  version: unibestVersion,
712
785
  cbVersion: package_default.version,
713
- createAt: dayjs().format("YYYY-MM-DD HH:mm:ss"),
786
+ createAt: dayjs2().format("YYYY-MM-DD HH:mm:ss"),
714
787
  nodeVersion: process.version,
715
788
  osPlatform: process.platform,
716
789
  cpuModel: os.cpus()[0]?.model || "unknown",
@@ -737,8 +810,8 @@ function generateDeviceIdentifier() {
737
810
  // src/commands/create.ts
738
811
  async function createCommand(args) {
739
812
  const projectName = args._[1] || args._[0];
740
- const versionUnibest = await getUnibestVersionFromGithub() || "4.0.0";
741
- intro(bold3(green3(`create-unibest@v${version} \u5FEB\u901F\u521B\u5EFA ${yellow3(`unibest@v${versionUnibest}`)} \u9879\u76EE`)));
813
+ const versionUnibest = await getUnibestVersionFromGitee() || "4.0.0";
814
+ intro(bold2(green3(`create-unibest@v${version} \u5FEB\u901F\u521B\u5EFA ${yellow3(`unibest@v${versionUnibest}`)} \u9879\u76EE`)));
742
815
  if (projectName) {
743
816
  const errorMessage = checkProjectNameExistAndValidate(projectName);
744
817
  if (errorMessage) {
@@ -757,12 +830,12 @@ async function createCommand(args) {
757
830
  }
758
831
 
759
832
  // src/utils/color.ts
760
- import { blue, green as green4, magenta as magenta2, red as red3, yellow as yellow4 } from "kolorist";
833
+ import { blue, green as green4, magenta as magenta2, red as red4, yellow as yellow4 } from "kolorist";
761
834
  var color = {
762
835
  blue,
763
836
  green: green4,
764
837
  magenta: magenta2,
765
- red: red3,
838
+ red: red4,
766
839
  yellow: yellow4
767
840
  };
768
841
 
@@ -770,29 +843,36 @@ var color = {
770
843
  function printHelp() {
771
844
  console.log(color.green("\ncreate-unibest - \u8DE8\u5E73\u53F0\u5F00\u53D1\u6846\u67B6\u811A\u624B\u67B6"));
772
845
  console.log("");
773
- console.log(color.blue("\u5168\u5C40\u5B89\u88C5:"));
774
- console.log(color.green(" npm i -g create-unibest \u5168\u5C40\u5B89\u88C5\uFF0C\u5F97\u5230 best \u547D\u4EE4"));
775
- console.log(color.green(" npm update -g create-unibest \u66F4\u65B0 create-unibest \u5305"));
776
- console.log("");
777
- console.log(color.green(" best <command> [options]"));
778
- console.log(color.green(" best new my-project \u521B\u5EFA\u65B0\u7684unibest\u9879\u76EE"));
779
- console.log(color.green(" best -v \u67E5\u770B\u7248\u672C\u4FE1\u606F"));
780
- console.log(color.green(" best -h \u67E5\u770B\u5E2E\u52A9\u4FE1\u606F"));
781
- console.log("");
782
- console.log("");
783
- console.log(color.blue("\u4E34\u65F6\u4F7F\u7528:"));
846
+ console.log(color.blue("\u5FEB\u901F\u4F7F\u7528:"));
784
847
  console.log(color.green(" pnpm create unibest <command> [options]"));
785
- console.log(color.green(" pnpm create unibest new my-project \u521B\u5EFA\u65B0\u7684unibest\u9879\u76EE"));
848
+ console.log(color.green(" pnpm create unibest my-project \u521B\u5EFA\u65B0\u7684unibest\u9879\u76EE"));
786
849
  console.log(color.green(" pnpm create unibest -v \u67E5\u770B\u7248\u672C\u4FE1\u606F"));
787
850
  console.log(color.green(" pnpm create unibest -h \u67E5\u770B\u5E2E\u52A9\u4FE1\u606F"));
788
851
  console.log("");
852
+ console.log(color.blue("\u9009\u9879:"));
853
+ console.log(" -p, --platform <type> \u6307\u5B9A\u5E73\u53F0 (h5, mp-weixin, app, mp-alipay, mp-toutiao)");
854
+ console.log(" \u652F\u6301\u591A\u9009: -p h5,mp-weixin \u6216 -p h5 -p mp-weixin");
855
+ console.log(" -u, --ui <library> \u6307\u5B9AUI\u5E93 (wot-ui, uview-pro, sard-uniapp, uv-ui, uview-plus, none)");
856
+ console.log(" -l, --login \u662F\u5426\u9700\u8981\u767B\u5F55\u7B56\u7565");
857
+ console.log(" -i, --i18n \u662F\u5426\u9700\u8981\u591A\u8BED\u8A00");
858
+ console.log("");
859
+ console.log(color.blue("\u793A\u4F8B:"));
860
+ console.log(" pnpm create unibest my-project -u wot-ui -p h5,mp-weixin");
861
+ console.log(" pnpm create unibest my-project -u uview-plus -l -i");
862
+ console.log(" pnpm create unibest my-project -u none -p h5,app,mp-weixin");
863
+ console.log("");
864
+ console.log(color.blue("\u5168\u5C40\u5B89\u88C5 (\u53EF\u9009):"));
865
+ console.log(color.green(" npm i -g create-unibest \u5168\u5C40\u5B89\u88C5\uFF0C\u5F97\u5230 best \u547D\u4EE4"));
866
+ console.log(color.green(" best <command> [options]"));
867
+ console.log(color.green(" best my-project \u521B\u5EFA\u65B0\u7684unibest\u9879\u76EE"));
868
+ console.log("");
789
869
  }
790
870
 
791
871
  // src/index.ts
792
872
  import { green as green5 } from "kolorist";
793
873
  import { yellow as yellow5 } from "kolorist";
794
874
  function main() {
795
- const args = minimist(process4.argv.slice(2));
875
+ const args = minimist(process5.argv.slice(2));
796
876
  const command = args._[0];
797
877
  debug("command:", command);
798
878
  debug("args:", args);
@@ -800,6 +880,10 @@ function main() {
800
880
  printVersion();
801
881
  return;
802
882
  }
883
+ if (args.h || args.help) {
884
+ printHelp();
885
+ return;
886
+ }
803
887
  switch (command) {
804
888
  case "create":
805
889
  case "new":
@@ -820,7 +904,7 @@ function main() {
820
904
  }
821
905
  async function printVersion() {
822
906
  const cliVersion = version;
823
- const latestVersion = await getUnibestVersionFromGithub();
907
+ const latestVersion = await getUnibestVersionFromGitee();
824
908
  if (latestVersion && latestVersion !== cliVersion) {
825
909
  console.log(`unibest-cli ${cliVersion} ${yellow5(`->`)} ${green5(`\u6700\u65B0\u7248\u672C: ${latestVersion}`)}`);
826
910
  console.log(`\u4F7F\u7528 ${green5(`npm update -g create-unibest`)} \u6216 ${green5(`pnpm add -g create-unibest`)} \u66F4\u65B0`);
package/package.json CHANGED
@@ -1,7 +1,8 @@
1
1
  {
2
2
  "name": "create-unibest",
3
3
  "type": "module",
4
- "version": "3.2.0",
4
+ "version": "3.3.0",
5
+ "updateTime": "2026-01-19",
5
6
  "packageManager": "pnpm@9.0.0",
6
7
  "description": "快速创建unibest项目的脚手架工具",
7
8
  "author": "",