zixulu 1.70.0 → 1.70.2

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 (124) hide show
  1. package/dist/index.js +323 -322
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/utils/addStartScript.d.ts +1 -1
  4. package/dist/src/utils/addSyncPackageScript.d.ts +1 -1
  5. package/dist/src/utils/downloadFromWinget.d.ts +1 -1
  6. package/dist/src/utils/getEditorExtensions.d.ts +1 -1
  7. package/dist/src/utils/getFilename.d.ts +1 -1
  8. package/dist/src/utils/getPackageUpgradeVersion.d.ts +1 -1
  9. package/dist/src/utils/writeJson.d.ts +1 -1
  10. package/dist/src/utils/writePackageJson.d.ts +1 -1
  11. package/dist/src/utils/writeRsbuildConfig.d.ts +1 -1
  12. package/package.json +20 -18
  13. package/src/constant/index.ts +1 -0
  14. package/src/index.ts +265 -53
  15. package/src/utils/actionWithBackup.ts +16 -4
  16. package/src/utils/addAntd.ts +9 -1
  17. package/src/utils/addApi.ts +24 -9
  18. package/src/utils/addBuildDocker.ts +50 -17
  19. package/src/utils/addDependency.ts +24 -7
  20. package/src/utils/addEslint.ts +15 -3
  21. package/src/utils/addGitCommit.ts +7 -2
  22. package/src/utils/addPathAlias.ts +70 -14
  23. package/src/utils/addPostCSSConfig.ts +1 -0
  24. package/src/utils/addPrettier.ts +25 -7
  25. package/src/utils/addPrisma.ts +7 -2
  26. package/src/utils/addRuleToGitIgnore.ts +9 -2
  27. package/src/utils/addScript.ts +1 -0
  28. package/src/utils/addStartScript.ts +29 -6
  29. package/src/utils/addSyncPackageScript.ts +17 -2
  30. package/src/utils/addTailwind.ts +7 -1
  31. package/src/utils/addTailwindConfig.ts +1 -0
  32. package/src/utils/addTailwindToCss.ts +8 -2
  33. package/src/utils/arrowToFunction.ts +42 -5
  34. package/src/utils/backupFirst.ts +3 -0
  35. package/src/utils/betaVersion.ts +14 -1
  36. package/src/utils/clearDockerImage.ts +8 -2
  37. package/src/utils/clearDockerLog.ts +7 -4
  38. package/src/utils/code2Snippet.ts +20 -2
  39. package/src/utils/createEntryCss.ts +18 -3
  40. package/src/utils/createPrismaDebugger.ts +19 -7
  41. package/src/utils/download.ts +6 -3
  42. package/src/utils/download7Zip.ts +2 -1
  43. package/src/utils/downloadBun.ts +4 -1
  44. package/src/utils/downloadDeskGo.ts +4 -1
  45. package/src/utils/downloadFromPCQQ.ts +18 -7
  46. package/src/utils/downloadFromWinget.ts +35 -5
  47. package/src/utils/downloadGeekUninstaller.ts +1 -0
  48. package/src/utils/downloadHoneyview.ts +5 -1
  49. package/src/utils/downloadLatestSoftware.ts +14 -3
  50. package/src/utils/downloadNpm.ts +11 -1
  51. package/src/utils/downloadVscodeExts.ts +30 -7
  52. package/src/utils/generatePrisma.ts +4 -1
  53. package/src/utils/getEditorExtensions.ts +10 -2
  54. package/src/utils/getEntryCssDir.ts +3 -0
  55. package/src/utils/getFilename.ts +1 -1
  56. package/src/utils/getFiles.ts +8 -1
  57. package/src/utils/getHeaders.ts +7 -1
  58. package/src/utils/getLatestRelease.ts +4 -1
  59. package/src/utils/getPackageManager.ts +5 -2
  60. package/src/utils/getPackageRequiredVersion.ts +12 -2
  61. package/src/utils/getPackageUpgradeVersion.ts +13 -3
  62. package/src/utils/getPackageVersionInDependcy.ts +4 -1
  63. package/src/utils/getRegistry.ts +2 -0
  64. package/src/utils/getTsFile.ts +12 -1
  65. package/src/utils/getTypeInGenerics.ts +5 -0
  66. package/src/utils/getUpgradeDependencyConfig.ts +13 -2
  67. package/src/utils/hasDependency.ts +11 -2
  68. package/src/utils/initProject.ts +33 -6
  69. package/src/utils/insertWhen.ts +5 -1
  70. package/src/utils/installDependceny.ts +3 -2
  71. package/src/utils/installDocker.ts +21 -6
  72. package/src/utils/interfaceToType.ts +15 -3
  73. package/src/utils/isPositiveInteger.ts +9 -2
  74. package/src/utils/isUrl.ts +2 -1
  75. package/src/utils/json2type.ts +6 -1
  76. package/src/utils/killProcessByPort.ts +8 -0
  77. package/src/utils/pnpm.ts +2 -0
  78. package/src/utils/processInfo.ts +18 -3
  79. package/src/utils/readBunConfig.ts +1 -0
  80. package/src/utils/readPackageJson.ts +7 -2
  81. package/src/utils/readPackageJsonSync.ts +4 -1
  82. package/src/utils/readTsConfig.ts +7 -2
  83. package/src/utils/readZixuluCache.ts +2 -0
  84. package/src/utils/readZixuluSetting.ts +2 -0
  85. package/src/utils/removeComment.ts +1 -0
  86. package/src/utils/removeESLint.ts +5 -2
  87. package/src/utils/removeFileOrFolderFromGit.ts +4 -0
  88. package/src/utils/removeLock.ts +7 -1
  89. package/src/utils/replaceAssets.ts +59 -12
  90. package/src/utils/replaceCommitAuthor.ts +22 -7
  91. package/src/utils/retry.ts +13 -3
  92. package/src/utils/rollup.ts +16 -3
  93. package/src/utils/rsbuild.ts +34 -23
  94. package/src/utils/rslib.ts +25 -4
  95. package/src/utils/serverToAction.ts +4 -1
  96. package/src/utils/setDockerRegistry.ts +16 -2
  97. package/src/utils/setEnv.ts +5 -1
  98. package/src/utils/setFatherConfig.ts +17 -4
  99. package/src/utils/setGitProxy.ts +20 -4
  100. package/src/utils/setGlobalConfig.ts +3 -1
  101. package/src/utils/setRegistry.ts +4 -1
  102. package/src/utils/setShellProxy.ts +11 -2
  103. package/src/utils/setTsConfig.ts +18 -3
  104. package/src/utils/sortArrayOrObject.ts +7 -0
  105. package/src/utils/sortPackageJson.ts +6 -2
  106. package/src/utils/splitExtendsType.ts +5 -0
  107. package/src/utils/sudoCommand.ts +7 -1
  108. package/src/utils/syncCursorExtToCode.ts +9 -3
  109. package/src/utils/syncEditorSetting.ts +73 -20
  110. package/src/utils/syncVscode.ts +20 -4
  111. package/src/utils/tailwindPatch.ts +2 -1
  112. package/src/utils/tar.ts +4 -0
  113. package/src/utils/updateDockerCompose.ts +10 -4
  114. package/src/utils/upgradeDependency.ts +18 -5
  115. package/src/utils/upgradeRsbuild.ts +11 -5
  116. package/src/utils/upgradeTailwind.ts +13 -5
  117. package/src/utils/upgradeWorkspaceDependceny.ts +5 -2
  118. package/src/utils/verdaccio.ts +1 -0
  119. package/src/utils/winget.ts +7 -1
  120. package/src/utils/writeBunConfig.ts +1 -0
  121. package/src/utils/writeJson.ts +4 -1
  122. package/src/utils/writePackageJson.ts +4 -1
  123. package/src/utils/writeRsbuildConfig.ts +5 -1
  124. package/src/utils/writeTsConfig.ts +5 -1
package/dist/index.js CHANGED
@@ -56,13 +56,13 @@ var constant_Software = /*#__PURE__*/ function(Software) {
56
56
  return Software;
57
57
  }({});
58
58
  const CommitTypeMap = {
59
- ["feature"]: "\u2728feature: ",
60
- ["fix"]: "\uD83D\uDC1E fix: ",
61
- ["docs"]: "\uD83D\uDCC4 docs: ",
62
- ["wip"]: "\uD83D\uDDA5\uFE0F wip: ",
63
- ["perfs"]: "\uD83D\uDE85 perfs: ",
64
- ["rollback"]: "\u23EA rollback: ",
65
- ["other"]: "\uD83D\uDD35 other: "
59
+ ["feature"]: "✨feature: ",
60
+ ["fix"]: "🐞 fix: ",
61
+ ["docs"]: "📄 docs: ",
62
+ ["wip"]: "🖥️ wip: ",
63
+ ["perfs"]: "🚅 perfs: ",
64
+ ["rollback"]: " rollback: ",
65
+ ["other"]: "🔵 other: "
66
66
  };
67
67
  const agent = new HttpsProxyAgent("http://localhost:7890");
68
68
  const addedRules = [
@@ -93,7 +93,7 @@ async function getPackageManager(dir = ".") {
93
93
  const { manager } = await inquirer_0.prompt({
94
94
  type: "list",
95
95
  name: "manager",
96
- message: "\u8BF7\u9009\u62E9\u5305\u7BA1\u7406\u5668",
96
+ message: "请选择包管理器",
97
97
  choices: getEnumValues(constant_PackageManager)
98
98
  });
99
99
  globalThis.__ZIXULU_PACKAGE_MANAGER__ = manager;
@@ -133,10 +133,10 @@ async function getPackageRequiredVersion(packageName, versionRange) {
133
133
  if (result) return result;
134
134
  result = Object.keys(data.versions).filter((item)=>item.startsWith(version) && isStableVersion(item)).at(-1);
135
135
  if (result) return result;
136
- throw new Error(`${packageName} \u{6CA1}\u{6709}\u{7B26}\u{5408}\u{6761}\u{4EF6}\u{7684}\u{7248}\u{672C}`);
136
+ throw new Error(`${packageName} 没有符合条件的版本`);
137
137
  }
138
138
  const result = Object.keys(data.versions).filter((version)=>isStableVersion(version) && (!versionRange || semver.satisfies(version, versionRange))).at(-1);
139
- if (!result) throw new Error(`${packageName} \u{6CA1}\u{6709}\u{7B26}\u{5408}\u{6761}\u{4EF6}\u{7684}\u{7248}\u{672C}`);
139
+ if (!result) throw new Error(`${packageName} 没有符合条件的版本`);
140
140
  return result;
141
141
  }
142
142
  function getPackageJsonPath(dir = ".") {
@@ -148,8 +148,8 @@ async function readPackageJson(dir) {
148
148
  return result;
149
149
  } catch (error) {
150
150
  consola.error(error);
151
- consola.fail(`\u{8BFB}\u{53D6} ${getPackageJsonPath(dir)} \u{5931}\u{8D25}`);
152
- throw new Error("\u8BFB\u53D6 package.json \u5931\u8D25");
151
+ consola.fail(`读取 ${getPackageJsonPath(dir)} 失败`);
152
+ throw new Error("读取 package.json 失败");
153
153
  }
154
154
  }
155
155
  async function retry(actionOrConfig, countNumber) {
@@ -180,9 +180,9 @@ async function writePackageJson({ data, dir }) {
180
180
  data,
181
181
  output: getPackageJsonPath(dir)
182
182
  });
183
- consola.success("\u4FEE\u6539 package.json \u6210\u529F");
183
+ consola.success("修改 package.json 成功");
184
184
  } catch (error) {
185
- consola.fail("\u4FEE\u6539 package.json \u5931\u8D25");
185
+ consola.fail("修改 package.json 失败");
186
186
  throw error;
187
187
  }
188
188
  }
@@ -199,17 +199,17 @@ async function addDependency(config) {
199
199
  const addedPackages = {};
200
200
  for (const { packageName, versionRange } of packages){
201
201
  if (packageJson.dependencies?.[packageName] || packageJson.devDependencies?.[packageName] || packageJson.peerDependencies?.[packageName] || packageJson.optionalDependencies?.[packageName]) {
202
- consola.warn(`${packageName} \u{5DF2}\u{5B58}\u{5728}\u{4E8E}\u{4F9D}\u{8D56}\u{4E2D}`);
202
+ consola.warn(`${packageName} 已存在于依赖中`);
203
203
  continue;
204
204
  }
205
205
  const version = await retry({
206
206
  action: ()=>getPackageRequiredVersion(packageName, versionRange),
207
207
  count: 4,
208
- callback: (error, current)=>consola.error(`\u{83B7}\u{53D6} ${packageName} \u{7248}\u{672C}\u{5931}\u{8D25}\u{FF0C}\u{7B2C} ${current} \u{6B21}\u{91CD}\u{8BD5}`)
208
+ callback: (error, current)=>consola.error(`获取 ${packageName} 版本失败,第 ${current} 次重试`)
209
209
  });
210
210
  addedPackages[packageName] = version;
211
211
  packageJson[type][packageName] ??= `^${version}`;
212
- consola.success(`\u{6DFB}\u{52A0} ${packageName} \u{81F3}\u{4F9D}\u{8D56}\u{6210}\u{529F}`);
212
+ consola.success(`添加 ${packageName} 至依赖成功`);
213
213
  }
214
214
  const keys = Object.keys(packageJson[type]);
215
215
  keys.sort();
@@ -250,9 +250,9 @@ async function addPostCSSConfig() {
250
250
  force: true
251
251
  });
252
252
  await writeFile("postcss.config.mjs", postcssConfig, "utf-8");
253
- consola.success("\u6DFB\u52A0 postcss.config.mjs \u914D\u7F6E\u6210\u529F");
253
+ consola.success("添加 postcss.config.mjs 配置成功");
254
254
  } catch {
255
- consola.fail("\u6DFB\u52A0 postcss.config.mjs \u914D\u7F6E\u5931\u8D25");
255
+ consola.fail("添加 postcss.config.mjs 配置失败");
256
256
  }
257
257
  }
258
258
  async function hasDependency(dependency, dir) {
@@ -273,7 +273,7 @@ async function installDependceny(config) {
273
273
  const { install } = await inquirer_0.prompt({
274
274
  type: "confirm",
275
275
  name: "install",
276
- message: "\u5B89\u88C5\u4F9D\u8D56"
276
+ message: "安装依赖"
277
277
  });
278
278
  if (false === install) return false;
279
279
  }
@@ -311,7 +311,6 @@ const config = {
311
311
  semi: false,
312
312
  tabWidth: 4,
313
313
  arrowParens: "avoid",
314
- printWidth: 160,
315
314
  endOfLine: "lf",
316
315
  plugins: ["./prettier-plugin-sort-imports.mjs"],
317
316
  }
@@ -397,7 +396,10 @@ ${isReact ? `
397
396
  return "third-party"
398
397
  },
399
398
  sortGroup(a, b) {
400
- return Number(a.isSideEffect) - Number(b.isSideEffect) || compareGroupName(a.name, b.name)
399
+ return (
400
+ Number(a.isSideEffect) - Number(b.isSideEffect) ||
401
+ compareGroupName(a.name, b.name)
402
+ )
401
403
  },
402
404
  separator: "",
403
405
  sortSideEffect: true,
@@ -408,7 +410,7 @@ ${isReact ? `
408
410
  return config;
409
411
  }
410
412
  async function addPrettier() {
411
- consola.start("\u5F00\u59CB\u6DFB\u52A0 prettier \u914D\u7F6E");
413
+ consola.start("开始添加 prettier 配置");
412
414
  const packageJson = await readPackageJson();
413
415
  const isTailwind = Object.keys(packageJson.dependencies ?? {}).includes("tailwindcss") || Object.keys(packageJson.devDependencies ?? {}).includes("tailwindcss");
414
416
  const isReact = await hasDependency("react");
@@ -432,12 +434,12 @@ async function addPrettier() {
432
434
  const packageJson2 = await readPackageJson();
433
435
  packageJson2.scripts ??= {};
434
436
  packageJson2.scripts.format = "prettier --write .";
435
- packageJson2.scripts.fg = 'npm run format && git add . && git commit -m "\u2728feature: format"';
437
+ packageJson2.scripts.fg = 'npm run format && git add . && git commit -m "✨feature: format"';
436
438
  await writePackageJson({
437
439
  data: packageJson2
438
440
  });
439
441
  await installDependceny();
440
- consola.success("\u6DFB\u52A0 prettier \u914D\u7F6E\u6210\u529F");
442
+ consola.success("添加 prettier 配置成功");
441
443
  }
442
444
  const tailwindConfig = `import { Config } from "tailwindcss"
443
445
 
@@ -490,9 +492,9 @@ async function addTailwindConfig() {
490
492
  const hasHeroUi = await hasDependency(/^@heroui\//);
491
493
  const config = hasHeroUi ? tailwindConfigWithHeroUi : tailwindConfig;
492
494
  await writeFile("tailwind.config.ts", config, "utf-8");
493
- consola.success("\u6DFB\u52A0 tailwind.config.ts \u914D\u7F6E\u6210\u529F");
495
+ consola.success("添加 tailwind.config.ts 配置成功");
494
496
  } catch {
495
- consola.fail("\u6DFB\u52A0 tailwind.config.ts \u914D\u7F6E\u5931\u8D25");
497
+ consola.fail("添加 tailwind.config.ts 配置失败");
496
498
  }
497
499
  }
498
500
  async function getEntryCssDir(dir) {
@@ -563,20 +565,20 @@ async function addTailwindToCss() {
563
565
  const file = files[0];
564
566
  const { base } = parse(file);
565
567
  const css = await readFile(file, "utf-8");
566
- if (css.includes("@tailwind")) return void consola.warn(`${base} \u{5DF2}\u{7ECF}\u{5305}\u{542B} tailwind`);
568
+ if (css.includes("@tailwind")) return void consola.warn(`${base} 已经包含 tailwind`);
567
569
  await writeFile(file, `@tailwind base;
568
570
  @tailwind components;
569
571
  @tailwind utilities;
570
572
 
571
573
  ${css}`, "utf-8");
572
- consola.success(`\u{6DFB}\u{52A0} tailwind \u{6210}\u{529F}`);
574
+ consola.success(`添加 tailwind 成功`);
573
575
  } catch (error) {
574
576
  console.log(error);
575
- consola.fail(`\u{6DFB}\u{52A0} tailwind \u{5931}\u{8D25}`);
577
+ consola.fail(`添加 tailwind 失败`);
576
578
  }
577
579
  }
578
580
  async function addTailwind() {
579
- consola.start("\u5F00\u59CB\u6DFB\u52A0 tailwind \u914D\u7F6E");
581
+ consola.start("开始添加 tailwind 配置");
580
582
  await addDependency({
581
583
  package: [
582
584
  {
@@ -594,10 +596,10 @@ async function addTailwind() {
594
596
  await addPostCSSConfig();
595
597
  await addTailwindToCss();
596
598
  await addPrettier();
597
- consola.success("\u6DFB\u52A0 tailwind \u914D\u7F6E\u6210\u529F");
599
+ consola.success("添加 tailwind 配置成功");
598
600
  }
599
601
  async function addAntd() {
600
- consola.start("\u5F00\u59CB\u6DFB\u52A0 antd \u914D\u7F6E");
602
+ consola.start("开始添加 antd 配置");
601
603
  await addDependency({
602
604
  package: [
603
605
  "@ant-design/icons",
@@ -667,10 +669,10 @@ const Registry: FC<RegistryProps> = ({ children }) => {
667
669
 
668
670
  export default Registry
669
671
  `);
670
- consola.success("\u6DFB\u52A0 antd \u914D\u7F6E\u6210\u529F");
672
+ consola.success("添加 antd 配置成功");
671
673
  }
672
674
  async function addGitAttributes() {
673
- await writeFile(".gitattributes", `# \u{5C06}\u{6240}\u{6709}\u{6587}\u{672C}\u{6587}\u{4EF6}\u{5728}\u{63D0}\u{4EA4}\u{5230} Git \u{4ED3}\u{5E93}\u{65F6}\u{FF0C}\u{81EA}\u{52A8}\u{8F6C}\u{6362}\u{4E3A} LF \u{6362}\u{884C}\u{7B26}
675
+ await writeFile(".gitattributes", `# 将所有文本文件在提交到 Git 仓库时,自动转换为 LF 换行符
674
676
  * text=auto eol=lf`, "utf-8");
675
677
  }
676
678
  function getCommitMessage(type, message) {
@@ -678,7 +680,7 @@ function getCommitMessage(type, message) {
678
680
  }
679
681
  async function addRuleToGitIgnore(...rules) {
680
682
  const dir = await readdir(".");
681
- const message = getCommitMessage("feature", `\u{6DFB}\u{52A0} .gitignore \u{89C4}\u{5219} ${rules.join(", ")}`);
683
+ const message = getCommitMessage("feature", `添加 .gitignore 规则 ${rules.join(", ")}`);
682
684
  if (!dir.includes(".gitignore")) {
683
685
  await writeFile(".gitignore", rules.join("\n"), "utf-8");
684
686
  return message;
@@ -702,7 +704,7 @@ function getRelativePath_getRelativePath(path) {
702
704
  }
703
705
  function getTsFile(path) {
704
706
  const { ext } = parse(path);
705
- if ("" !== ext && ".ts" !== ext && ".tsx" !== ext) throw new Error("\u8BF7\u4F20\u5165 ts \u6216 tsx \u6587\u4EF6");
707
+ if ("" !== ext && ".ts" !== ext && ".tsx" !== ext) throw new Error("请传入 ts tsx 文件");
706
708
  if (".ts" === ext || ".tsx" === ext) return {
707
709
  depth: 0,
708
710
  ext: ext,
@@ -732,7 +734,7 @@ function getTsFile(path) {
732
734
  ext: ".tsx",
733
735
  path: path5
734
736
  };
735
- throw new Error(`\u{627E}\u{4E0D}\u{5230} ${path} \u{5BF9}\u{5E94}\u{7684} ts \u{6216} tsx \u{6587}\u{4EF6}`);
737
+ throw new Error(`找不到 ${path} 对应的 ts tsx 文件`);
736
738
  }
737
739
  function getTsConfigJsonPath(path) {
738
740
  return join(path ?? external_process_cwd(), "tsconfig.json");
@@ -742,7 +744,7 @@ async function readTsConfig(path) {
742
744
  const result = json5.parse(await readFile(getTsConfigJsonPath(path), "utf-8"));
743
745
  return result;
744
746
  } catch (error) {
745
- consola.fail("\u8BFB\u53D6 tsconfig.json \u5931\u8D25");
747
+ consola.fail("读取 tsconfig.json 失败");
746
748
  throw error;
747
749
  }
748
750
  }
@@ -827,7 +829,7 @@ async function addFolderPathAlias() {
827
829
  const { folder } = await inquirer_0.prompt({
828
830
  type: "input",
829
831
  name: "folder",
830
- message: "\u8BF7\u8F93\u5165\u6587\u4EF6\u5939\u8DEF\u5F84",
832
+ message: "请输入文件夹路径",
831
833
  default: "."
832
834
  });
833
835
  const dir = await getFiles_getFiles({
@@ -841,7 +843,7 @@ async function addFolderPathAlias() {
841
843
  const { result } = await inquirer_0.prompt({
842
844
  type: "checkbox",
843
845
  name: "result",
844
- message: "\u8BF7\u9009\u62E9\u8981\u6DFB\u52A0\u7684\u6587\u4EF6\u5939",
846
+ message: "请选择要添加的文件夹",
845
847
  choices: names,
846
848
  default: names.filter((item)=>"node_modules" !== item && ".git" !== item && ".vscode" !== item && "dist" !== item && "build" !== item)
847
849
  });
@@ -862,7 +864,7 @@ globalThis.__PRISMA__ ??= new PrismaClient()
862
864
  export const prisma = globalThis.__PRISMA__
863
865
  `;
864
866
  async function addPrisma(manager) {
865
- consola.start("\u5F00\u59CB\u6DFB\u52A0 Prisma \u914D\u7F6E");
867
+ consola.start("开始添加 Prisma 配置");
866
868
  await addDependency({
867
869
  package: "@prisma/client"
868
870
  });
@@ -889,10 +891,10 @@ async function addPrisma(manager) {
889
891
  stdio: "inherit"
890
892
  });
891
893
  await writeFile("prisma/index.ts", prismaFile, "utf-8");
892
- consola.success("\u6DFB\u52A0 Prisma \u914D\u7F6E\u6210\u529F");
894
+ consola.success("添加 Prisma 配置成功");
893
895
  }
894
896
  function getTypeInGenerics(str, start = 0) {
895
- if ("<" !== str[start]) throw new Error("\u65E0\u6548\u7684\u6CDB\u578B");
897
+ if ("<" !== str[start]) throw new Error("无效的泛型");
896
898
  let count = 1;
897
899
  let index;
898
900
  for(let i = start + 1; i < str.length; i++){
@@ -909,11 +911,11 @@ function getTypeInGenerics(str, start = 0) {
909
911
  }
910
912
  }
911
913
  }
912
- if (void 0 === index) throw new Error("\u65E0\u6548\u7684\u6CDB\u578B");
914
+ if (void 0 === index) throw new Error("无效的泛型");
913
915
  return str.slice(start + 1, index);
914
916
  }
915
917
  async function arrowToFunction() {
916
- consola.start("\u5F00\u59CB\u5C06\u8F6C\u6362\u7BAD\u5934\u51FD\u6570\u7EC4\u4EF6\u4E3A\u51FD\u6570\u7EC4\u4EF6");
918
+ consola.start("开始将转换箭头函数组件为函数组件");
917
919
  const files = await getFiles_getFiles({
918
920
  dir: "src",
919
921
  match: (path, stats)=>".tsx" === path.ext && stats.isFile()
@@ -922,7 +924,7 @@ async function arrowToFunction() {
922
924
  const { auto } = await inquirer_0.prompt({
923
925
  type: "confirm",
924
926
  name: "auto",
925
- message: "\u662F\u5426\u81EA\u52A8\u9009\u62E9\u8981\u8F6C\u6362\u7684\u7EC4\u4EF6"
927
+ message: "是否自动选择要转换的组件"
926
928
  });
927
929
  const warnFiles = new Set();
928
930
  const modifiedFiles = new Set();
@@ -969,8 +971,8 @@ async function arrowToFunction() {
969
971
  const typeIndex = match.indexOf("FC<");
970
972
  if (typeIndex > 0) {
971
973
  const type = getTypeInGenerics(match, typeIndex + 2);
972
- const name = `\u{25C6} ${match}
973
- \u{25C6} ${hasExport ? "export " : ""}function ${funName}(props: ${type}) {`;
974
+ const name = `◆ ${match}
975
+ ${hasExport ? "export " : ""}function ${funName}(props: ${type}) {`;
974
976
  prev.push({
975
977
  value: index.toString(),
976
978
  short: funName,
@@ -978,8 +980,8 @@ async function arrowToFunction() {
978
980
  checked: true
979
981
  });
980
982
  } else {
981
- const name = `\u{25C6} ${match}
982
- \u{25C6} ${hasExport ? "export " : ""}function ${funName}() {`;
983
+ const name = `◆ ${match}
984
+ ${hasExport ? "export " : ""}function ${funName}() {`;
983
985
  prev.push({
984
986
  value: index.toString(),
985
987
  short: funName,
@@ -995,7 +997,7 @@ async function arrowToFunction() {
995
997
  choice.name = choice.name.replace(/◆/g, ()=>{
996
998
  if (first) {
997
999
  first = false;
998
- return `\u{25C6} ${(index + 1).toString().padStart(length, "0")}.`;
1000
+ return `◆ ${(index + 1).toString().padStart(length, "0")}.`;
999
1001
  }
1000
1002
  return "".padStart(length + 3, " ");
1001
1003
  });
@@ -1029,12 +1031,8 @@ async function arrowToFunction() {
1029
1031
  console.log();
1030
1032
  await writeFile(file, code, "utf-8");
1031
1033
  }
1032
- if (modifiedFiles.size > 0) consola.success(`\u{4EE5}\u{4E0B}\u{6587}\u{4EF6}\u{4E2D}\u{7684}\u{7BAD}\u{5934}\u{51FD}\u{6570}\u{7EC4}\u{4EF6}\u{5DF2}\u{7ECF}\u{8F6C}\u{6362}\u{4E3A}\u{51FD}\u{6570}\u{7EC4}\u{4EF6}\u{FF1A}
1033
-
1034
- ${Array.from(modifiedFiles).join("\n")}`);
1035
- if (warnFiles.size > 0) consola.warn(`\u{4EE5}\u{4E0B}\u{6587}\u{4EF6}\u{4E2D}\u{5B58}\u{5728} memo \u{6216} forwardRef\u{FF0C}\u{8BF7}\u{624B}\u{52A8}\u{8F6C}\u{6362}\u{FF1A}
1036
-
1037
- ${Array.from(warnFiles).join("\n")}`);
1034
+ if (modifiedFiles.size > 0) consola.success(`以下文件中的箭头函数组件已经转换为函数组件:\n\n${Array.from(modifiedFiles).join("\n")}`);
1035
+ if (warnFiles.size > 0) consola.warn(`以下文件中存在 memo 或 forwardRef,请手动转换:\n\n${Array.from(warnFiles).join("\n")}`);
1038
1036
  }
1039
1037
  async function hasChangeNoCommit(cwd) {
1040
1038
  const status = await execAsync("git status", {
@@ -1050,7 +1048,7 @@ async function isRepository() {
1050
1048
  return false;
1051
1049
  }
1052
1050
  }
1053
- async function shouldContinue(message = "\u662F\u5426\u7EE7\u7EED") {
1051
+ async function shouldContinue(message = "是否继续") {
1054
1052
  const { continue: cont } = await inquirer_0.prompt({
1055
1053
  type: "confirm",
1056
1054
  name: "continue",
@@ -1061,16 +1059,16 @@ async function shouldContinue(message = "\u662F\u5426\u7EE7\u7EED") {
1061
1059
  async function backupFirst(forceRepo = false) {
1062
1060
  if (!await isRepository()) {
1063
1061
  if (forceRepo) {
1064
- consola.error("git \u4E0D\u53EF\u7528");
1065
- throw new Error("git \u4E0D\u53EF\u7528");
1062
+ consola.error("git 不可用");
1063
+ throw new Error("git 不可用");
1066
1064
  }
1067
- consola.warn("\u5EFA\u8BAE\u4F7F\u7528\u524D\u5907\u4EFD\u4EE3\u7801");
1065
+ consola.warn("建议使用前备份代码");
1068
1066
  const cont = await shouldContinue();
1069
1067
  if (!cont) exit();
1070
1068
  return;
1071
1069
  }
1072
1070
  if (await hasChangeNoCommit()) {
1073
- consola.warn("\u5EFA\u8BAE\u4F7F\u7528\u524D\u63D0\u4EA4\u4EE3\u7801");
1071
+ consola.warn("建议使用前提交代码");
1074
1072
  const cont = await shouldContinue();
1075
1073
  if (!cont) exit();
1076
1074
  return true;
@@ -1082,8 +1080,8 @@ async function getBetaVersion() {
1082
1080
  const reg = /^(\d+)\.(\d+)\.(\d+)(-beta\.(\d+))?$/;
1083
1081
  const match = version.match(reg);
1084
1082
  if (!match) {
1085
- consola.error("\u7248\u672C\u53F7\u4E0D\u7B26\u5408\u89C4\u8303");
1086
- throw new Error("\u7248\u672C\u53F7\u4E0D\u7B26\u5408\u89C4\u8303");
1083
+ consola.error("版本号不符合规范");
1084
+ throw new Error("版本号不符合规范");
1087
1085
  }
1088
1086
  const [, major, minor, patch, , beta] = match;
1089
1087
  if (beta) {
@@ -1094,7 +1092,7 @@ async function getBetaVersion() {
1094
1092
  const { level } = await inquirer_0.prompt({
1095
1093
  type: "list",
1096
1094
  name: "level",
1097
- message: "\u8BF7\u9009\u62E9\u5347\u7EA7\u7684\u7EA7\u522B",
1095
+ message: "请选择升级的级别",
1098
1096
  choices: [
1099
1097
  "major",
1100
1098
  "minor",
@@ -1137,7 +1135,7 @@ async function betaVersion() {
1137
1135
  const { publish } = await inquirer_0.prompt({
1138
1136
  type: "confirm",
1139
1137
  name: "publish",
1140
- message: "\u662F\u5426\u73B0\u5728\u53D1\u5E03"
1138
+ message: "是否现在发布"
1141
1139
  });
1142
1140
  if (publish) await spawnAsync("npm publish --tag beta", {
1143
1141
  shell: true,
@@ -1158,7 +1156,7 @@ async function code2Snippet(path) {
1158
1156
  let { placeholder } = await inquirer_0.prompt({
1159
1157
  type: "input",
1160
1158
  name: "placeholder",
1161
- message: "\u8BF7\u8F93\u5165\u9700\u8981\u66FF\u6362\u7684\u5360\u4F4D\u7B26\uFF0C\u8F93\u5165\u7A7A\u5B57\u7B26\u4E32\u7ED3\u675F"
1159
+ message: "请输入需要替换的占位符,输入空字符串结束"
1162
1160
  });
1163
1161
  placeholder = placeholder.trim();
1164
1162
  if (!placeholder) break;
@@ -1236,7 +1234,7 @@ async function downloadFromWinget({ name, id, dir, filter }) {
1236
1234
  const yaml = await response2.text();
1237
1235
  const pkg = yaml_0.parse(yaml);
1238
1236
  const installers = filter ? pkg.Installers.filter(filter) : pkg.Installers;
1239
- if (0 === installers.length) return void consola.warn(`\u{672A}\u{627E}\u{5230} ${name} \u{7684}\u{5B89}\u{88C5}\u{7A0B}\u{5E8F}`);
1237
+ if (0 === installers.length) return void consola.warn(`未找到 ${name} 的安装程序`);
1240
1238
  const result = [];
1241
1239
  for (const { InstallerUrl, Architecture } of installers){
1242
1240
  const filename = await download_download(InstallerUrl, dir);
@@ -1279,7 +1277,7 @@ async function getLatestRelease(owner, repo) {
1279
1277
  async function downloadBun(dir) {
1280
1278
  const release = await getLatestRelease("oven-sh", "bun");
1281
1279
  const url = release.assets.find((asset)=>"bun-windows-x64.zip" === asset.name)?.browser_download_url;
1282
- if (!url) throw new Error("\u672A\u627E\u5230 bun-windows-x64.zip");
1280
+ if (!url) throw new Error("未找到 bun-windows-x64.zip");
1283
1281
  await download_download(url, dir);
1284
1282
  await unzip({
1285
1283
  input: "bun-windows-x64.zip",
@@ -1436,14 +1434,14 @@ const SoftwareDownloadMap = {
1436
1434
  [constant_Software.PowerShell]: downloadPowerShell
1437
1435
  };
1438
1436
  async function downloadLatestSoftware() {
1439
- consola.start("\u5F00\u59CB\u4E0B\u8F7D\u8F6F\u4EF6");
1437
+ consola.start("开始下载软件");
1440
1438
  const dir = `softwares-${dayjs().format("YYYYMMDDHHmmss")}`;
1441
1439
  const setting = await readZixuluSetting();
1442
1440
  const softwareDownloadHistory = setting?.softwareDownloadHistory;
1443
1441
  const { softwares } = await inquirer_0.prompt({
1444
1442
  type: "checkbox",
1445
1443
  name: "softwares",
1446
- message: "\u8BF7\u9009\u62E9\u8981\u4E0B\u8F7D\u7684\u8F6F\u4EF6",
1444
+ message: "请选择要下载的软件",
1447
1445
  choices: Object.values(constant_Software),
1448
1446
  default: softwareDownloadHistory?.filter((software)=>Object.values(constant_Software).includes(software)) ?? Object.values(constant_Software)
1449
1447
  });
@@ -1454,10 +1452,10 @@ async function downloadLatestSoftware() {
1454
1452
  recursive: true
1455
1453
  });
1456
1454
  for (const software of softwares){
1457
- consola.start(`\u{6B63}\u{5728}\u{4E0B}\u{8F7D} ${software}`);
1455
+ consola.start(`正在下载 ${software}`);
1458
1456
  await SoftwareDownloadMap[software](dir);
1459
1457
  }
1460
- consola.success("\u8F6F\u4EF6\u4E0B\u8F7D\u5B8C\u6210");
1458
+ consola.success("软件下载完成");
1461
1459
  }
1462
1460
  async function getPackageVersionInDependcy(packageName, dir = ".") {
1463
1461
  const packageJson = await readPackageJson(dir);
@@ -1466,12 +1464,12 @@ async function getPackageVersionInDependcy(packageName, dir = ".") {
1466
1464
  return version.replace(/^\D+/, "");
1467
1465
  }
1468
1466
  async function downloadNpm(name) {
1469
- consola.start(`\u{5F00}\u{59CB}\u{4E0B}\u{8F7D} ${name}`);
1467
+ consola.start(`开始下载 ${name}`);
1470
1468
  const folder = `${name}-cache`;
1471
1469
  const dir = await readdir(".");
1472
1470
  if (dir.includes(folder)) {
1473
- consola.warn("\u6587\u4EF6\u5939\u5DF2\u5B58\u5728");
1474
- throw new Error("\u6587\u4EF6\u5939\u5DF2\u5B58\u5728");
1471
+ consola.warn("文件夹已存在");
1472
+ throw new Error("文件夹已存在");
1475
1473
  }
1476
1474
  await mkdir(folder, {
1477
1475
  recursive: true
@@ -1504,7 +1502,7 @@ async function downloadNpm(name) {
1504
1502
  await rm(folder, {
1505
1503
  recursive: true
1506
1504
  });
1507
- consola.success(`\u{4E0B}\u{8F7D} ${name} \u{5B8C}\u{6210}`);
1505
+ consola.success(`下载 ${name} 完成`);
1508
1506
  }
1509
1507
  async function generatePrisma() {
1510
1508
  await spawnAsync("npx prisma db push && npx prisma generate", {
@@ -1540,7 +1538,7 @@ async function addScript(scripts) {
1540
1538
  {
1541
1539
  type: "confirm",
1542
1540
  name: "replace",
1543
- message: `${key} \u{547D}\u{4EE4}\u{5DF2}\u{5B58}\u{5728} \`${packageJson.scripts[key]}\`\u{FF0C}\u{662F}\u{5426}\u{66FF}\u{6362}\u{4E3A} \`${scripts[key]}\``
1541
+ message: `${key} 命令已存在 \`${packageJson.scripts[key]}\`,是否替换为 \`${scripts[key]}\``
1544
1542
  }
1545
1543
  ]);
1546
1544
  if (!replace) continue;
@@ -1631,13 +1629,13 @@ firefox >= 78
1631
1629
  safari >= 14`, "utf-8");
1632
1630
  }
1633
1631
  async function next_next() {
1634
- consola.start("\u5F00\u59CB\u8BBE\u7F6E next \u914D\u7F6E");
1632
+ consola.start("开始设置 next 配置");
1635
1633
  const pkg = await readPackageJson();
1636
1634
  pkg.scripts.dev += " --hostname 0.0.0.0 --port 5173";
1637
1635
  await writePackageJson({
1638
1636
  data: pkg
1639
1637
  });
1640
- consola.success("\u8BBE\u7F6E next \u914D\u7F6E\u6210\u529F");
1638
+ consola.success("设置 next 配置成功");
1641
1639
  }
1642
1640
  async function getDependcy(name) {
1643
1641
  const packageJson = await readPackageJson();
@@ -1697,7 +1695,7 @@ export default defineConfig({
1697
1695
  await writeFile("rsbuild.config.ts", rsbuildConfig, "utf-8");
1698
1696
  }
1699
1697
  async function rsbuild() {
1700
- consola.start("\u5F00\u59CB\u8BBE\u7F6E rsbuild \u914D\u7F6E");
1698
+ consola.start("开始设置 rsbuild 配置");
1701
1699
  await addDependency({
1702
1700
  package: [
1703
1701
  "@rsbuild/plugin-svgr",
@@ -1718,19 +1716,19 @@ async function rsbuild() {
1718
1716
  {
1719
1717
  type: "input",
1720
1718
  name: "description",
1721
- message: "\u9879\u76EE\u63CF\u8FF0",
1719
+ message: "项目描述",
1722
1720
  default: "designed by someone"
1723
1721
  },
1724
1722
  {
1725
1723
  type: "input",
1726
1724
  name: "title",
1727
- message: "\u9879\u76EE\u6807\u9898",
1725
+ message: "项目标题",
1728
1726
  default: packageJson.name
1729
1727
  },
1730
1728
  {
1731
1729
  type: "input",
1732
1730
  name: "mountId",
1733
- message: "\u5165\u53E3 id",
1731
+ message: "入口 id",
1734
1732
  default: "root"
1735
1733
  }
1736
1734
  ]);
@@ -1767,7 +1765,7 @@ root.render(
1767
1765
  <App />
1768
1766
  </StrictMode>
1769
1767
  )`, "utf-8");
1770
- consola.success("\u8BBE\u7F6E rsbuild \u914D\u7F6E\u6210\u529F");
1768
+ consola.success("设置 rsbuild 配置成功");
1771
1769
  }
1772
1770
  var setTsConfig_Target = /*#__PURE__*/ function(Target) {
1773
1771
  Target["ES2015"] = "ES2015";
@@ -1817,7 +1815,7 @@ async function setTsConfig(key, value) {
1817
1815
  {
1818
1816
  const t = Object.values(setTsConfig_Target).find((t)=>t.toLowerCase() === value.trim().toLowerCase());
1819
1817
  if (!t) {
1820
- consola.fail("\u65E0\u6548\u7684 target \u9009\u9879");
1818
+ consola.fail("无效的 target 选项");
1821
1819
  exit();
1822
1820
  }
1823
1821
  tsconfig.compilerOptions.target = t;
@@ -1827,7 +1825,7 @@ async function setTsConfig(key, value) {
1827
1825
  {
1828
1826
  const m = Object.values(setTsConfig_Module).find((m)=>m.toLowerCase() === value.trim().toLowerCase());
1829
1827
  if (!m) {
1830
- consola.fail("\u65E0\u6548\u7684 module \u9009\u9879");
1828
+ consola.fail("无效的 module 选项");
1831
1829
  exit();
1832
1830
  }
1833
1831
  tsconfig.compilerOptions.module = m;
@@ -1837,7 +1835,7 @@ async function setTsConfig(key, value) {
1837
1835
  {
1838
1836
  const mr = Object.values(setTsConfig_ModuleResolution).find((mr)=>mr.toLowerCase() === value.trim().toLowerCase());
1839
1837
  if (!mr) {
1840
- consola.fail("\u65E0\u6548\u7684 moduleResolution \u9009\u9879");
1838
+ consola.fail("无效的 moduleResolution 选项");
1841
1839
  exit();
1842
1840
  }
1843
1841
  tsconfig.compilerOptions.moduleResolution = mr;
@@ -1847,14 +1845,14 @@ async function setTsConfig(key, value) {
1847
1845
  tsconfig.compilerOptions.noEmit = !!value;
1848
1846
  break;
1849
1847
  default:
1850
- consola.fail(`\u{6682}\u{4E0D}\u{652F}\u{6301} ${key} \u{9879}`);
1848
+ consola.fail(`暂不支持 ${key} 项`);
1851
1849
  exit();
1852
1850
  }
1853
1851
  await writeTsConfig(tsconfig);
1854
- consola.success(`\u{4FEE}\u{6539} ${key} \u{6210}\u{529F}`);
1852
+ consola.success(`修改 ${key} 成功`);
1855
1853
  }
1856
1854
  async function vite() {
1857
- consola.start("\u5F00\u59CB\u8BBE\u7F6E vite \u914D\u7F6E");
1855
+ consola.start("开始设置 vite 配置");
1858
1856
  await setTsConfig("noUnusedLocals");
1859
1857
  await setTsConfig("noUnusedParameters");
1860
1858
  const pkg = await readPackageJson();
@@ -1862,21 +1860,21 @@ async function vite() {
1862
1860
  await writePackageJson({
1863
1861
  data: pkg
1864
1862
  });
1865
- consola.success("\u8BBE\u7F6E vite \u914D\u7F6E\u6210\u529F");
1863
+ consola.success("设置 vite 配置成功");
1866
1864
  }
1867
1865
  async function initProject() {
1868
- consola.start("\u5F00\u59CB\u521D\u59CB\u5316\u9879\u76EE");
1866
+ consola.start("开始初始化项目");
1869
1867
  await createBrowserlistrc();
1870
1868
  await addEslint();
1871
1869
  const packageJson = await readPackageJson();
1872
1870
  const allDependcies = Object.keys(packageJson.dependencies || {}).concat(Object.keys(packageJson.devDependencies || {}));
1873
- if (!allDependcies.includes("react") || !allDependcies.includes("react-dom")) return void consola.error("\u4EC5\u652F\u6301 React \u9879\u76EE");
1871
+ if (!allDependcies.includes("react") || !allDependcies.includes("react-dom")) return void consola.error("仅支持 React 项目");
1874
1872
  let type;
1875
1873
  if (allDependcies.some((item)=>"next" === item)) type = "next";
1876
1874
  else if (allDependcies.some((item)=>"@remix-run/react" === item)) type = "remix";
1877
1875
  else if (allDependcies.some((item)=>"vite" === item)) type = "vite";
1878
1876
  else {
1879
- if (!allDependcies.some((item)=>"@rsbuild/core" === item)) return void consola.error("\u4EC5\u652F\u6301 Next\u3001Remix\u3001Vite\u3001Rsbuild \u9879\u76EE");
1877
+ if (!allDependcies.some((item)=>"@rsbuild/core" === item)) return void consola.error("仅支持 Next、Remix、Vite、Rsbuild 项目");
1880
1878
  type = "rsbuild";
1881
1879
  }
1882
1880
  await addGitignore();
@@ -1913,7 +1911,7 @@ async function initProject() {
1913
1911
  const { modules } = await inquirer_0.prompt({
1914
1912
  type: "checkbox",
1915
1913
  name: "modules",
1916
- message: "\u8BF7\u9009\u62E9\u8981\u6DFB\u52A0\u7684\u6A21\u5757",
1914
+ message: "请选择要添加的模块",
1917
1915
  choices,
1918
1916
  default: choices
1919
1917
  });
@@ -1959,7 +1957,7 @@ async function initProject() {
1959
1957
  manager
1960
1958
  });
1961
1959
  await setTsConfig("noEmit", true);
1962
- consola.success("\u9879\u76EE\u521D\u59CB\u5316\u5B8C\u6210");
1960
+ consola.success("项目初始化完成");
1963
1961
  }
1964
1962
  function splitExtendsType(str) {
1965
1963
  const types = [];
@@ -1980,7 +1978,7 @@ function splitExtendsType(str) {
1980
1978
  return types.map((v)=>v.trim()).filter((v)=>v);
1981
1979
  }
1982
1980
  async function interfaceToType() {
1983
- consola.start("\u5F00\u59CB\u5C06\u9879\u76EE\u4E2D\u7684 interface \u8F6C\u6362\u4E3A type");
1981
+ consola.start("开始将项目中的 interface 转换为 type");
1984
1982
  const files = await getFiles_getFiles({
1985
1983
  match: (path, stats)=>(".tsx" === path.ext || ".ts" === path.ext) && !path.base.endsWith(".d.ts") && stats.isFile(),
1986
1984
  exclude: (path, stats)=>stats.isDirectory() && "node_modules" === path.base
@@ -1988,7 +1986,7 @@ async function interfaceToType() {
1988
1986
  const { cont } = await inquirer_0.prompt({
1989
1987
  type: "confirm",
1990
1988
  name: "cont",
1991
- message: "\u662F\u5426\u7EE7\u7EED"
1989
+ message: "是否继续"
1992
1990
  });
1993
1991
  if (!cont) return;
1994
1992
  const reg = /(export )?interface (.+?) {/gm;
@@ -2011,12 +2009,10 @@ async function interfaceToType() {
2011
2009
  });
2012
2010
  await writeFile(file, newCode, "utf-8");
2013
2011
  }
2014
- if (modifiedFiles.size > 0) consola.success(`\u{4EE5}\u{4E0B}\u{6587}\u{4EF6}\u{4E2D}\u{7684} interface \u{5DF2}\u{7ECF}\u{8F6C}\u{6362}\u{4E3A} type\u{FF1A}
2015
-
2016
- ${Array.from(modifiedFiles).join("\n")}`);
2017
- consola.start("\u68C0\u67E5\u9879\u76EE\u662F\u5426\u5B58\u5728 TypeScript \u9519\u8BEF");
2012
+ if (modifiedFiles.size > 0) consola.success(`以下文件中的 interface 已经转换为 type:\n\n${Array.from(modifiedFiles).join("\n")}`);
2013
+ consola.start("检查项目是否存在 TypeScript 错误");
2018
2014
  await checkType();
2019
- consola.success("interface \u8F6C\u6362\u4E3A type \u5B8C\u6210");
2015
+ consola.success("interface 转换为 type 完成");
2020
2016
  }
2021
2017
  async function getProcessInfoFromPid(pid) {
2022
2018
  try {
@@ -2051,8 +2047,8 @@ async function getPidInfoFromPort(port) {
2051
2047
  async function killProcessByPort(port) {
2052
2048
  port = "string" == typeof port ? parseInt(port) : port;
2053
2049
  if (!Number.isInteger(port)) {
2054
- consola.error("\u65E0\u6548\u7684\u7AEF\u53E3\u53F7");
2055
- throw new Error("\u65E0\u6548\u7684\u7AEF\u53E3\u53F7");
2050
+ consola.error("无效的端口号");
2051
+ throw new Error("无效的端口号");
2056
2052
  }
2057
2053
  const pidInfos = await getPidInfoFromPort(port);
2058
2054
  const choices = [];
@@ -2063,11 +2059,11 @@ async function killProcessByPort(port) {
2063
2059
  value: pid
2064
2060
  });
2065
2061
  }
2066
- if (0 === choices.length) return void consola.warn("\u6CA1\u6709\u627E\u5230\u5BF9\u5E94\u7684\u8FDB\u7A0B");
2062
+ if (0 === choices.length) return void consola.warn("没有找到对应的进程");
2067
2063
  const { chosenPids } = await inquirer_0.prompt({
2068
2064
  type: "checkbox",
2069
2065
  name: "chosenPids",
2070
- message: "\u8BF7\u9009\u62E9\u8981\u7ED3\u675F\u7684\u8FDB\u7A0B",
2066
+ message: "请选择要结束的进程",
2071
2067
  choices,
2072
2068
  default: choices.map((choice)=>choice.value)
2073
2069
  });
@@ -2102,11 +2098,11 @@ async function reinstall() {
2102
2098
  });
2103
2099
  }
2104
2100
  async function removeComment(path) {
2105
- consola.start("\u5F00\u59CB\u5220\u9664\u6CE8\u91CA");
2101
+ consola.start("开始删除注释");
2106
2102
  const text = await readFile(path, "utf-8");
2107
2103
  const newText = text.replace(/^ *?\/\/.*?$/gm, "");
2108
2104
  await writeFile(path, newText, "utf-8");
2109
- consola.success("\u5220\u9664\u6CE8\u91CA\u6210\u529F");
2105
+ consola.success("删除注释成功");
2110
2106
  }
2111
2107
  async function removeFileOrFolderFromGit(input) {
2112
2108
  input = input.replace(/\\/g, "/");
@@ -2118,15 +2114,15 @@ async function removeFileOrFolderFromGit(input) {
2118
2114
  const answer = await inquirer_0.prompt({
2119
2115
  type: "confirm",
2120
2116
  name: "recursive",
2121
- message: "\u662F\u5426\u662F\u6587\u4EF6\u5939",
2117
+ message: "是否是文件夹",
2122
2118
  default: false
2123
2119
  });
2124
2120
  recursive = answer.recursive;
2125
2121
  }
2126
2122
  await backupFirst(true);
2127
- consola.start(`\u{5F00}\u{59CB}\u{4ECE} git \u{4E2D}\u{5220}\u{9664} ${input}`);
2123
+ consola.start(`开始从 git 中删除 ${input}`);
2128
2124
  await execAsync(`git filter-branch --force --index-filter "git rm${recursive ? " -r" : ""} --cached --ignore-unmatch ${input}" --prune-empty --tag-name-filter cat -- --all`);
2129
- consola.success(`\u{4ECE} git \u{4E2D}\u{5220}\u{9664} ${input} \u{6210}\u{529F}`);
2125
+ consola.success(`从 git 中删除 ${input} 成功`);
2130
2126
  }
2131
2127
  const rollupConfig = `import commonjs from "@rollup/plugin-commonjs"
2132
2128
  import json from "@rollup/plugin-json"
@@ -2202,7 +2198,7 @@ export default defineConfig({
2202
2198
  })
2203
2199
  `;
2204
2200
  async function setFatherConfig() {
2205
- consola.start("\u5F00\u59CB\u8BBE\u7F6E father \u914D\u7F6E");
2201
+ consola.start("开始设置 father 配置");
2206
2202
  let packageJson = await readPackageJson();
2207
2203
  packageJson.publishConfig ??= {};
2208
2204
  packageJson.publishConfig.access = "public";
@@ -2250,20 +2246,20 @@ async function setFatherConfig() {
2250
2246
  force: true
2251
2247
  });
2252
2248
  await writeFile("src/index.ts", "");
2253
- consola.success("\u8BBE\u7F6E father \u914D\u7F6E\u6210\u529F");
2249
+ consola.success("设置 father 配置成功");
2254
2250
  }
2255
2251
  async function setGitProxy() {
2256
2252
  const { global: global1 } = await inquirer_0.prompt({
2257
2253
  type: "list",
2258
2254
  name: "global",
2259
- message: "\u8BF7\u9009\u62E9",
2255
+ message: "请选择",
2260
2256
  choices: [
2261
2257
  {
2262
- name: "\u5168\u5C40\u4EE3\u7406",
2258
+ name: "全局代理",
2263
2259
  value: true
2264
2260
  },
2265
2261
  {
2266
- name: "\u5F53\u524D\u9879\u76EE",
2262
+ name: "当前项目",
2267
2263
  value: false
2268
2264
  }
2269
2265
  ]
@@ -2271,14 +2267,14 @@ async function setGitProxy() {
2271
2267
  const { open } = await inquirer_0.prompt({
2272
2268
  type: "list",
2273
2269
  name: "open",
2274
- message: "\u8BF7\u9009\u62E9",
2270
+ message: "请选择",
2275
2271
  choices: [
2276
2272
  {
2277
- name: "\u6253\u5F00\u4EE3\u7406",
2273
+ name: "打开代理",
2278
2274
  value: true
2279
2275
  },
2280
2276
  {
2281
- name: "\u5173\u95ED\u4EE3\u7406",
2277
+ name: "关闭代理",
2282
2278
  value: false
2283
2279
  }
2284
2280
  ]
@@ -2301,7 +2297,7 @@ async function setGitProxy() {
2301
2297
  const { proxy } = await inquirer_0.prompt({
2302
2298
  type: "input",
2303
2299
  name: "proxy",
2304
- message: "\u8BF7\u8F93\u5165\u4EE3\u7406\u5730\u5740",
2300
+ message: "请输入代理地址",
2305
2301
  default: "http://localhost:7890"
2306
2302
  });
2307
2303
  await spawnAsync(`git config${global1 ? " --global" : ""} http.proxy ${proxy}`, {
@@ -2321,13 +2317,13 @@ async function setRegistry() {
2321
2317
  const { manager } = await inquirer_0.prompt({
2322
2318
  type: "list",
2323
2319
  name: "manager",
2324
- message: "\u8BF7\u9009\u62E9\u5305\u7BA1\u7406\u5668",
2320
+ message: "请选择包管理器",
2325
2321
  choices: getEnumValues(constant_PackageManager)
2326
2322
  });
2327
2323
  const { registry } = await inquirer_0.prompt({
2328
2324
  type: "list",
2329
2325
  name: "registry",
2330
- message: "\u8BF7\u9009\u62E9\u8981\u66F4\u6362\u7684\u6E90",
2326
+ message: "请选择要更换的源",
2331
2327
  choices: getEnumKeys(constant_Registry)
2332
2328
  });
2333
2329
  if (manager === constant_PackageManager.bun) {
@@ -2349,7 +2345,7 @@ async function isShellProxy() {
2349
2345
  encoding: "gbk"
2350
2346
  }
2351
2347
  });
2352
- return !result.includes("\u76F4\u63A5\u8BBF\u95EE");
2348
+ return !result.includes("直接访问");
2353
2349
  }
2354
2350
  async function setShellProxy() {
2355
2351
  const isOpen = await isShellProxy();
@@ -2357,14 +2353,14 @@ async function setShellProxy() {
2357
2353
  const { open } = await inquirer_0.prompt({
2358
2354
  type: "list",
2359
2355
  name: "open",
2360
- message: "\u8BF7\u9009\u62E9",
2356
+ message: "请选择",
2361
2357
  choices: [
2362
2358
  {
2363
- name: "\u270F\uFE0F \u66F4\u6539\u5730\u5740",
2359
+ name: "✏️ 更改地址",
2364
2360
  value: true
2365
2361
  },
2366
2362
  {
2367
- name: "\uD83D\uDEAB \u5173\u95ED\u4EE3\u7406",
2363
+ name: "🚫 关闭代理",
2368
2364
  value: false
2369
2365
  }
2370
2366
  ]
@@ -2377,7 +2373,7 @@ async function setShellProxy() {
2377
2373
  const { proxy } = await inquirer_0.prompt({
2378
2374
  type: "input",
2379
2375
  name: "proxy",
2380
- message: "\u8BF7\u8F93\u5165\u4EE3\u7406\u5730\u5740",
2376
+ message: "请输入代理地址",
2381
2377
  default: "http://localhost:7890"
2382
2378
  });
2383
2379
  await spawnAsync(`netsh winhttp set proxy "${proxy}" "<local>"`, {
@@ -2386,7 +2382,7 @@ async function setShellProxy() {
2386
2382
  });
2387
2383
  }
2388
2384
  async function sortPackageJson() {
2389
- consola.start("\u5F00\u59CB\u6392\u5E8F package.json \u4E2D\u7684\u4F9D\u8D56");
2385
+ consola.start("开始排序 package.json 中的依赖");
2390
2386
  const packageJson = await readPackageJson();
2391
2387
  packageJson.dependencies = sortArrayOrObject(packageJson.dependencies);
2392
2388
  packageJson.devDependencies = sortArrayOrObject(packageJson.devDependencies);
@@ -2395,7 +2391,7 @@ async function sortPackageJson() {
2395
2391
  await writePackageJson({
2396
2392
  data: packageJson
2397
2393
  });
2398
- consola.success("\u6392\u5E8F package.json \u4E2D\u7684\u4F9D\u8D56\u6210\u529F");
2394
+ consola.success("排序 package.json 中的依赖成功");
2399
2395
  }
2400
2396
  async function getVscodeExtInfo(ext) {
2401
2397
  const response = await node_fetch(`https://marketplace.visualstudio.com/items?itemName=${ext}`, {
@@ -2430,7 +2426,7 @@ async function downloadVscodeExts(dir) {
2430
2426
  await mkdir(dir, {
2431
2427
  recursive: true
2432
2428
  });
2433
- consola.start("\u6B63\u5728\u83B7\u53D6 VS Code \u6269\u5C55\u5217\u8868");
2429
+ consola.start("正在获取 VS Code 扩展列表");
2434
2430
  const extList = await execAsync("code --list-extensions");
2435
2431
  const exts = await Promise.all(extList.split(/[\n\r]/).filter(Boolean).filter((item)=>!item.startsWith("anysphere.")).map((ext)=>getVscodeExtInfo(ext)));
2436
2432
  const setting = await readZixuluSetting();
@@ -2438,7 +2434,7 @@ async function downloadVscodeExts(dir) {
2438
2434
  const exts2 = await inquirer_0.prompt({
2439
2435
  type: "checkbox",
2440
2436
  name: "exts",
2441
- message: "\u9009\u62E9\u9700\u8981\u4E0B\u8F7D\u7684\u6269\u5C55",
2437
+ message: "选择需要下载的扩展",
2442
2438
  choices: exts.map((ext)=>({
2443
2439
  name: ext.name,
2444
2440
  value: ext.id
@@ -2450,16 +2446,16 @@ async function downloadVscodeExts(dir) {
2450
2446
  await Promise.all(exts.filter((ext)=>exts2.exts.includes(ext.id)).map((ext)=>retry(()=>download_download(ext.url, dir, `${ext.id}-${ext.version}.vsix`), 4)));
2451
2447
  }
2452
2448
  var syncVscode_VscodeSyncOption = /*#__PURE__*/ function(VscodeSyncOption) {
2453
- VscodeSyncOption["\u914D\u7F6E"] = "SETTING";
2454
- VscodeSyncOption["\u63D2\u4EF6"] = "EXTENSION";
2455
- VscodeSyncOption["\u8F6F\u4EF6"] = "SOFTWARE";
2449
+ VscodeSyncOption["配置"] = "SETTING";
2450
+ VscodeSyncOption["插件"] = "EXTENSION";
2451
+ VscodeSyncOption["软件"] = "SOFTWARE";
2456
2452
  return VscodeSyncOption;
2457
2453
  }({});
2458
2454
  async function syncVscode() {
2459
2455
  const options = (await inquirer_0.prompt({
2460
2456
  type: "checkbox",
2461
2457
  name: "options",
2462
- message: "\u8BF7\u9009\u62E9\u8981\u540C\u6B65\u7684\u5185\u5BB9",
2458
+ message: "请选择要同步的内容",
2463
2459
  choices: getEnumEntries(syncVscode_VscodeSyncOption).map(([name, value])=>({
2464
2460
  name,
2465
2461
  value
@@ -2480,15 +2476,15 @@ async function syncVscode() {
2480
2476
  await mkdir(snippetTarget, {
2481
2477
  recursive: true
2482
2478
  });
2483
- consola.start("\u5F00\u59CB\u4E0B\u8F7D\u6700\u65B0 VSCode \u914D\u7F6E");
2479
+ consola.start("开始下载最新 VSCode 配置");
2484
2480
  await copyFile(setting, join(dir, "settings.json"));
2485
2481
  const files = await readdir(snippetSource);
2486
2482
  for (const file of files)await copyFile(join(snippetSource, file), join(snippetTarget, file));
2487
- consola.success("\u4E0B\u8F7D\u6700\u65B0 VSCode \u914D\u7F6E\u5B8C\u6210");
2483
+ consola.success("下载最新 VSCode 配置完成");
2488
2484
  }
2489
2485
  if (options.includes("EXTENSION")) {
2490
2486
  await downloadVscodeExts(join(dir, "extensions"));
2491
- consola.success("\u4E0B\u8F7D\u6700\u65B0 VSCode \u63D2\u4EF6\u5B8C\u6210");
2487
+ consola.success("下载最新 VSCode 插件完成");
2492
2488
  }
2493
2489
  if (options.includes("SETTING") || options.includes("EXTENSION")) {
2494
2490
  const script = `// @ts-check
@@ -2532,15 +2528,15 @@ main()`;
2532
2528
  await writeFile(join(dir, "syncVscode.mjs"), script, "utf-8");
2533
2529
  }
2534
2530
  if (options.includes("SOFTWARE")) {
2535
- consola.start("\u5F00\u59CB\u4E0B\u8F7D\u6700\u65B0 VSCode");
2531
+ consola.start("开始下载最新 VSCode");
2536
2532
  await download_download("https://code.visualstudio.com/sha/download?build=stable&os=win32-x64", dir);
2537
- consola.success("\u4E0B\u8F7D\u6700\u65B0 VSCode \u5B8C\u6210");
2533
+ consola.success("下载最新 VSCode 完成");
2538
2534
  }
2539
2535
  } catch (error) {
2540
2536
  const { clear } = await inquirer_0.prompt({
2541
2537
  type: "confirm",
2542
2538
  name: "clear",
2543
- message: "\u68C0\u6D4B\u5230\u9519\u8BEF\uFF0C\u662F\u5426\u6E05\u7406\u4E0B\u8F7D\u7684\u6587\u4EF6",
2539
+ message: "检测到错误,是否清理下载的文件",
2544
2540
  default: true
2545
2541
  });
2546
2542
  if (clear) await rm(dir, {
@@ -2561,7 +2557,7 @@ async function getPackageUpgradeVersion({ packageName, version, level }) {
2561
2557
  const result = await retry({
2562
2558
  action: ()=>getPackageRequiredVersion(packageName, versionRange),
2563
2559
  count: 4,
2564
- callback: (error, current)=>consola.error(`\u{83B7}\u{53D6} ${packageName} \u{7248}\u{672C}\u{5931}\u{8D25}\u{FF0C}\u{7B2C} ${current} \u{6B21}\u{91CD}\u{8BD5}`)
2560
+ callback: (error, current)=>consola.error(`获取 ${packageName} 版本失败,第 ${current} 次重试`)
2565
2561
  });
2566
2562
  return result;
2567
2563
  }
@@ -2575,13 +2571,13 @@ async function getUpgradeDependencyConfig(...keys) {
2575
2571
  if (ks.includes("dir")) questions.push({
2576
2572
  type: "input",
2577
2573
  name: "dir",
2578
- message: "\u8BF7\u8F93\u5165\u5347\u7EA7\u7684\u76EE\u5F55",
2574
+ message: "请输入升级的目录",
2579
2575
  default: "."
2580
2576
  });
2581
2577
  if (ks.includes("types")) questions.push({
2582
2578
  type: "checkbox",
2583
2579
  name: "types",
2584
- message: "\u8BF7\u9009\u62E9\u8981\u5347\u7EA7\u7684\u4F9D\u8D56\u7C7B\u578B",
2580
+ message: "请选择要升级的依赖类型",
2585
2581
  choices: [
2586
2582
  "dependencies",
2587
2583
  "devDependencies"
@@ -2594,7 +2590,7 @@ async function getUpgradeDependencyConfig(...keys) {
2594
2590
  if (ks.includes("level")) questions.push({
2595
2591
  type: "list",
2596
2592
  name: "level",
2597
- message: "\u8BF7\u9009\u62E9\u5347\u7EA7\u7684\u7EA7\u522B",
2593
+ message: "请选择升级的级别",
2598
2594
  choices: [
2599
2595
  "major",
2600
2596
  "minor",
@@ -2642,7 +2638,7 @@ async function upgradeDependency(config) {
2642
2638
  const { pkgs } = await inquirer_0.prompt({
2643
2639
  type: "checkbox",
2644
2640
  name: "pkgs",
2645
- message: "\u8BF7\u9009\u62E9\u8981\u5347\u7EA7\u7684\u5305",
2641
+ message: "请选择要升级的包",
2646
2642
  choices,
2647
2643
  default: upgrades.map((upgrade)=>upgrade.package)
2648
2644
  });
@@ -2664,7 +2660,7 @@ async function addGitCommit(messageOrParams) {
2664
2660
  const { message, cwd } = "string" == typeof messageOrParams ? {
2665
2661
  message: messageOrParams
2666
2662
  } : messageOrParams;
2667
- consola.start("\u63D0\u4EA4\u4EE3\u7801");
2663
+ consola.start("提交代码");
2668
2664
  await execAsync("git add .", {
2669
2665
  cwd
2670
2666
  });
@@ -2680,7 +2676,7 @@ function actionWithBackup(action, message) {
2680
2676
  const { commit } = await inquirer_0.prompt({
2681
2677
  type: "confirm",
2682
2678
  name: "commit",
2683
- message: "\u662F\u5426\u81EA\u52A8\u63D0\u4EA4\u4EE3\u7801",
2679
+ message: "是否自动提交代码",
2684
2680
  default: true
2685
2681
  });
2686
2682
  if (!commit) return;
@@ -2688,8 +2684,8 @@ function actionWithBackup(action, message) {
2688
2684
  if ("string" == typeof message) commitMessage = message;
2689
2685
  else if ("string" == typeof msg) commitMessage = msg;
2690
2686
  else {
2691
- consola.warn("\u8BF7\u63D0\u4F9B\u63D0\u4EA4\u4FE1\u606F");
2692
- throw new Error("\u8BF7\u63D0\u4F9B\u63D0\u4EA4\u4FE1\u606F");
2687
+ consola.warn("请提供提交信息");
2688
+ throw new Error("请提供提交信息");
2693
2689
  }
2694
2690
  await addGitCommit(commitMessage);
2695
2691
  };
@@ -2700,7 +2696,7 @@ async function addApi_writeFile(...args) {
2700
2696
  const { override } = await inquirer_0.prompt({
2701
2697
  type: "confirm",
2702
2698
  name: "override",
2703
- message: `\u{6587}\u{4EF6} ${path} \u{5DF2}\u{5B58}\u{5728}\u{FF0C}\u{662F}\u{5426}\u{8986}\u{76D6}\u{FF1F}`
2699
+ message: `文件 ${path} 已存在,是否覆盖?`
2704
2700
  });
2705
2701
  if (!override) return;
2706
2702
  }
@@ -2720,7 +2716,7 @@ async function addApi({ type, api, hook }) {
2720
2716
  const { items } = await inquirer_0.prompt({
2721
2717
  type: "checkbox",
2722
2718
  name: "items",
2723
- message: `\u{8BF7}\u{9009}\u{62E9}\u{9700}\u{8981}\u{6DFB}\u{52A0}\u{7684}${type}\u{5B57}\u{6BB5}`,
2719
+ message: `请选择需要添加的${type}字段`,
2724
2720
  choices: [
2725
2721
  "query",
2726
2722
  "get",
@@ -2866,7 +2862,7 @@ export function useAdd${type}<TContext = never>({ onMutate, onSuccess, onError,
2866
2862
  message.open({
2867
2863
  key,
2868
2864
  type: "loading",
2869
- content: \`\u{65B0}\u{589E}\${${type}Name}\u{4E2D}...\`,
2865
+ content: \`新增\${${type}Name}中...\`,
2870
2866
  duration: 0,
2871
2867
  })
2872
2868
  return onMutate?.(variables)
@@ -2875,7 +2871,7 @@ export function useAdd${type}<TContext = never>({ onMutate, onSuccess, onError,
2875
2871
  message.open({
2876
2872
  key,
2877
2873
  type: "success",
2878
- content: \`\u{65B0}\u{589E}\${${type}Name}\u{6210}\u{529F}\`,
2874
+ content: \`新增\${${type}Name}成功\`,
2879
2875
  })
2880
2876
  return onSuccess?.(data, variables, context)
2881
2877
  },
@@ -2883,7 +2879,7 @@ export function useAdd${type}<TContext = never>({ onMutate, onSuccess, onError,
2883
2879
  message.open({
2884
2880
  key,
2885
2881
  type: "error",
2886
- content: \`\u{65B0}\u{589E}\${${type}Name}\u{5931}\u{8D25}\`,
2882
+ content: \`新增\${${type}Name}失败\`,
2887
2883
  })
2888
2884
  return onError?.(error, variables, context)
2889
2885
  },
@@ -2915,7 +2911,7 @@ export function useUpdate${type}<TContext = never>({ onMutate, onSuccess, onErro
2915
2911
  message.open({
2916
2912
  key,
2917
2913
  type: "loading",
2918
- content: \`\u{66F4}\u{65B0}\${${type}Name}\u{4E2D}...\`,
2914
+ content: \`更新\${${type}Name}中...\`,
2919
2915
  duration: 0,
2920
2916
  })
2921
2917
  return onMutate?.(variables)
@@ -2924,7 +2920,7 @@ export function useUpdate${type}<TContext = never>({ onMutate, onSuccess, onErro
2924
2920
  message.open({
2925
2921
  key,
2926
2922
  type: "success",
2927
- content: \`\u{66F4}\u{65B0}\${${type}Name}\u{6210}\u{529F}\`,
2923
+ content: \`更新\${${type}Name}成功\`,
2928
2924
  })
2929
2925
  return onSuccess?.(data, variables, context)
2930
2926
  },
@@ -2932,7 +2928,7 @@ export function useUpdate${type}<TContext = never>({ onMutate, onSuccess, onErro
2932
2928
  message.open({
2933
2929
  key,
2934
2930
  type: "error",
2935
- content: \`\u{66F4}\u{65B0}\${${type}Name}\u{5931}\u{8D25}\`,
2931
+ content: \`更新\${${type}Name}失败\`,
2936
2932
  })
2937
2933
  return onError?.(error, variables, context)
2938
2934
  },
@@ -2965,7 +2961,7 @@ export function useDelete${type}<TContext = never>({ onMutate, onSuccess, onErro
2965
2961
  message.open({
2966
2962
  key,
2967
2963
  type: "loading",
2968
- content: \`\u{5220}\u{9664}\${${type}Name}\u{4E2D}...\`,
2964
+ content: \`删除\${${type}Name}中...\`,
2969
2965
  duration: 0,
2970
2966
  })
2971
2967
  return onMutate?.(variables)
@@ -2974,7 +2970,7 @@ export function useDelete${type}<TContext = never>({ onMutate, onSuccess, onErro
2974
2970
  message.open({
2975
2971
  key,
2976
2972
  type: "success",
2977
- content: \`\u{5220}\u{9664}\${${type}Name}\u{6210}\u{529F}\`,
2973
+ content: \`删除\${${type}Name}成功\`,
2978
2974
  })
2979
2975
  return onSuccess?.(data, variables, context)
2980
2976
  },
@@ -2982,7 +2978,7 @@ export function useDelete${type}<TContext = never>({ onMutate, onSuccess, onErro
2982
2978
  message.open({
2983
2979
  key,
2984
2980
  type: "error",
2985
- content: \`\u{5220}\u{9664}\${${type}Name}\u{5931}\u{8D25}\`,
2981
+ content: \`删除\${${type}Name}失败\`,
2986
2982
  })
2987
2983
  return onError?.(error, variables, context)
2988
2984
  },
@@ -3163,25 +3159,25 @@ await spawnAsync(\`docker save \${name}:\${customTag} > \${join("${docker ?? "do
3163
3159
  ${insertWhen(buildLatest, `
3164
3160
  console.log()
3165
3161
  await spawnAsync(\`docker save \${name}:latest > \${join("${docker ?? "docker"}", \`\${name}-latest.tar\`)}\`, options)`)}`)}`;
3166
- const dockerFile = `# \u{4F7F}\u{7528}\u{5B98}\u{65B9} nginx \u{955C}\u{50CF}\u{4F5C}\u{4E3A}\u{57FA}\u{7840}\u{955C}\u{50CF}
3162
+ const dockerFile = `# 使用官方 nginx 镜像作为基础镜像
3167
3163
  FROM nginx:alpine
3168
3164
 
3169
- # \u{8BBE}\u{7F6E}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}
3165
+ # 设置工作目录
3170
3166
  WORKDIR /usr/share/nginx/html
3171
3167
 
3172
- # \u{5220}\u{9664}\u{9ED8}\u{8BA4}\u{7684} nginx \u{9759}\u{6001}\u{8D44}\u{6E90}
3168
+ # 删除默认的 nginx 静态资源
3173
3169
  RUN rm -rf ./*
3174
3170
 
3175
- # \u{5C06} dist \u{6587}\u{4EF6}\u{5939}\u{4E2D}\u{7684}\u{5185}\u{5BB9}\u{590D}\u{5236}\u{5230} nginx \u{7684} html \u{76EE}\u{5F55}\u{4E0B}
3171
+ # dist 文件夹中的内容复制到 nginx html 目录下
3176
3172
  COPY ${dist} .
3177
3173
 
3178
- # \u{53EF}\u{9009}\u{FF1A}\u{590D}\u{5236}\u{81EA}\u{5B9A}\u{4E49}\u{7684} nginx \u{914D}\u{7F6E}
3174
+ # 可选:复制自定义的 nginx 配置
3179
3175
  COPY nginx.conf /etc/nginx/nginx.conf
3180
3176
 
3181
- # \u{66B4}\u{9732}\u{7AEF}\u{53E3}
3177
+ # 暴露端口
3182
3178
  EXPOSE ${port}
3183
3179
 
3184
- # \u{542F}\u{52A8} nginx
3180
+ # 启动 nginx
3185
3181
  CMD ["nginx", "-g", "daemon off;"]
3186
3182
  `;
3187
3183
  const nginxFile = `worker_processes 1;
@@ -3204,7 +3200,7 @@ http {
3204
3200
  root /usr/share/nginx/html;
3205
3201
  index index.html index.htm;
3206
3202
  location / {
3207
- try_files $uri $uri/ /index.html; # \u{5BF9}\u{4E8E} SPA \u{5E94}\u{7528}\u{7684}\u{8DEF}\u{7531}\u{652F}\u{6301}
3203
+ try_files $uri $uri/ /index.html; # 对于 SPA 应用的路由支持
3208
3204
  }
3209
3205
  }
3210
3206
  }
@@ -3257,22 +3253,22 @@ http {
3257
3253
  await writeFile(".dockerignore", rules.join("\n"));
3258
3254
  }
3259
3255
  if (type === ApplicationType.Backend) {
3260
- const dockerFile = `# \u{4F7F}\u{7528} bun \u{7684} alpine \u{7248}\u{672C}\u{4F5C}\u{4E3A}\u{57FA}\u{7840}\u{955C}\u{50CF}
3256
+ const dockerFile = `# 使用 bun alpine 版本作为基础镜像
3261
3257
  FROM oven/bun:alpine
3262
3258
 
3263
- # \u{8BBE}\u{7F6E}\u{5DE5}\u{4F5C}\u{76EE}\u{5F55}
3259
+ # 设置工作目录
3264
3260
  WORKDIR /app
3265
3261
 
3266
- # \u{590D}\u{5236}\u{6E90}\u{4EE3}\u{7801}
3262
+ # 复制源代码
3267
3263
  COPY . .
3268
3264
 
3269
- # \u{5B89}\u{88C5}\u{4F9D}\u{8D56}
3265
+ # 安装依赖
3270
3266
  RUN bun install --registry=https://registry.npmmirror.com
3271
3267
 
3272
- # \u{66B4}\u{9732}\u{7AEF}\u{53E3}\u{FF08}\u{6839}\u{636E}\u{4F60}\u{7684}\u{5E94}\u{7528}\u{9700}\u{8981}\u{8C03}\u{6574}\u{FF09}
3268
+ # 暴露端口(根据你的应用需要调整)
3273
3269
  EXPOSE ${port}
3274
3270
 
3275
- # \u{8FD0}\u{884C}\u{5E94}\u{7528}
3271
+ # 运行应用
3276
3272
  CMD ["bun", "run", "index.ts"]
3277
3273
  `;
3278
3274
  await writeFile("Dockerfile", dockerFile);
@@ -3372,7 +3368,7 @@ function createServer() {
3372
3368
 
3373
3369
  async function main() {
3374
3370
  const ROOT = process.env.ROOT || "dist"
3375
- if (!!process.env.BASE && !process.env.BASE.startsWith("/")) throw new Error("BASE \u{5FC5}\u{987B}\u{4EE5} / \u{5F00}\u{5934}")
3371
+ if (!!process.env.BASE && !process.env.BASE.startsWith("/")) throw new Error("BASE 必须以 / 开头")
3376
3372
  const BASE = process.env.BASE || "/"
3377
3373
 
3378
3374
  const server = createServer()
@@ -3484,9 +3480,9 @@ async function addStartScript({ type, pemPath, port, core, hostname }) {
3484
3480
  await writePackageJson({
3485
3481
  data: packageJson
3486
3482
  });
3487
- consola.success("\u5DF2\u6DFB\u52A0\u542F\u52A8\u547D\u4EE4 start");
3483
+ consola.success("已添加启动命令 start");
3488
3484
  await installDependceny();
3489
- return getCommitMessage("feature", "\u6DFB\u52A0\u542F\u52A8\u547D\u4EE4");
3485
+ return getCommitMessage("feature", "添加启动命令");
3490
3486
  }
3491
3487
  async function addSyncPackageScript({ monorepo } = {}) {
3492
3488
  let dir;
@@ -3495,7 +3491,7 @@ async function addSyncPackageScript({ monorepo } = {}) {
3495
3491
  {
3496
3492
  type: "input",
3497
3493
  name: "dir",
3498
- message: "\u8BF7\u8F93\u5165\u5305\u76EE\u5F55",
3494
+ message: "请输入包目录",
3499
3495
  default: "packages"
3500
3496
  }
3501
3497
  ]);
@@ -3504,8 +3500,8 @@ async function addSyncPackageScript({ monorepo } = {}) {
3504
3500
  const syncPackageScript = `// @ts-check
3505
3501
 
3506
3502
  /**
3507
- * \u{540C}\u{6B65}\u{5305}
3508
- * @param {string} packageName \u{5305}\u{540D}
3503
+ * 同步包
3504
+ * @param {string} packageName 包名
3509
3505
  */
3510
3506
  function syncPackage(packageName) {
3511
3507
  return fetch(\`https://registry-direct.npmmirror.com/-/package/\${packageName}/syncs\`, {
@@ -3554,7 +3550,7 @@ main()
3554
3550
  {
3555
3551
  type: "confirm",
3556
3552
  name: "override",
3557
- message: "sync \u547D\u4EE4\u5DF2\u5B58\u5728\uFF0C\u662F\u5426\u8986\u76D6",
3553
+ message: "sync 命令已存在,是否覆盖",
3558
3554
  default: false
3559
3555
  }
3560
3556
  ]);
@@ -3563,7 +3559,7 @@ main()
3563
3559
  {
3564
3560
  type: "input",
3565
3561
  name: "name",
3566
- message: "\u8BF7\u8F93\u5165\u540C\u6B65\u5305\u811A\u672C\u540D\u79F0",
3562
+ message: "请输入同步包脚本名称",
3567
3563
  default: "syncPackage"
3568
3564
  }
3569
3565
  ]);
@@ -3576,7 +3572,7 @@ main()
3576
3572
  await writePackageJson({
3577
3573
  data: packageJson
3578
3574
  });
3579
- return getCommitMessage("feature", "\u6DFB\u52A0\u540C\u6B65\u5305\u811A\u672C");
3575
+ return getCommitMessage("feature", "添加同步包脚本");
3580
3576
  }
3581
3577
  const zipDistContent = `// @ts-check
3582
3578
  import { rm } from "fs/promises"
@@ -3611,18 +3607,18 @@ async function addZipDist({ install } = {}) {
3611
3607
  data: packageJson
3612
3608
  });
3613
3609
  if (install) await installDependceny();
3614
- return getCommitMessage("feature", "\u6DFB\u52A0\u538B\u7F29\u811A\u672C");
3610
+ return getCommitMessage("feature", "添加压缩脚本");
3615
3611
  }
3616
3612
  async function clearDockerImage(name) {
3617
3613
  name = name?.trim();
3618
3614
  const output = await execAsync(`docker images -f "dangling=true"${name ? ` -f "reference=*${name}*"` : ""}`);
3619
3615
  const outputs = output.split("\n").filter(Boolean);
3620
- if (1 === outputs.length) return void consola.warn("\u6CA1\u6709\u627E\u5230\u9700\u8981\u5220\u9664\u7684\u955C\u50CF");
3616
+ if (1 === outputs.length) return void consola.warn("没有找到需要删除的镜像");
3621
3617
  const images = outputs.slice(1).map((item)=>item.match(/<none> +([0-9a-f]{12}) +/)[1]);
3622
3618
  const { images: images2 } = await inquirer_0.prompt({
3623
3619
  type: "checkbox",
3624
3620
  name: "images",
3625
- message: "\u9009\u62E9\u8981\u5220\u9664\u7684\u955C\u50CF",
3621
+ message: "选择要删除的镜像",
3626
3622
  choices: outputs.map((item, index)=>({
3627
3623
  name: item,
3628
3624
  value: 0 === index ? "" : images[index - 1],
@@ -3633,19 +3629,19 @@ async function clearDockerImage(name) {
3633
3629
  for(let i = 0; i < images2.length; i++){
3634
3630
  const image = images2[i];
3635
3631
  try {
3636
- consola.ready(`\u{6B63}\u{5728}\u{5220}\u{9664} ${image}`);
3632
+ consola.ready(`正在删除 ${image}`);
3637
3633
  await spawnAsync(`docker rmi ${image}`, {
3638
3634
  shell: true,
3639
3635
  stdio: "inherit"
3640
3636
  });
3641
- consola.success(`\u{5220}\u{9664} ${image} \u{6210}\u{529F}`);
3637
+ consola.success(`删除 ${image} 成功`);
3642
3638
  } catch {
3643
- consola.error(`\u{5220}\u{9664} ${image} \u{5931}\u{8D25}`);
3639
+ consola.error(`删除 ${image} 失败`);
3644
3640
  if (i === images2.length - 1) break;
3645
3641
  const { next } = await inquirer_0.prompt({
3646
3642
  type: "confirm",
3647
3643
  name: "next",
3648
- message: "\u662F\u5426\u7EE7\u7EED\u5220\u9664\u4E0B\u4E00\u4E2A\u955C\u50CF",
3644
+ message: "是否继续删除下一个镜像",
3649
3645
  default: true
3650
3646
  });
3651
3647
  if (!next) break;
@@ -3685,7 +3681,7 @@ datasource db {
3685
3681
  }
3686
3682
 
3687
3683
  model User {
3688
- id String @id @default(uuid()) // \u{4E3B}\u{952E}ID
3684
+ id String @id @default(uuid()) // 主键ID
3689
3685
  name String
3690
3686
  }
3691
3687
  `;
@@ -3741,7 +3737,7 @@ async function getHeaders() {
3741
3737
  "const headers = new Headers()"
3742
3738
  ];
3743
3739
  const match = str.match(reg);
3744
- if (!match) throw new Error("headers \u683C\u5F0F\u9519\u8BEF");
3740
+ if (!match) throw new Error("headers 格式错误");
3745
3741
  Array.from(match).forEach((item)=>{
3746
3742
  const match2 = item.match(reg2);
3747
3743
  result.push(`headers.set("${match2[1].trim()}", \`${match2[2].trim()}\`)`);
@@ -3812,7 +3808,7 @@ async function writeZixuluCache(cache) {
3812
3808
  async function sudoCommand() {
3813
3809
  try {
3814
3810
  const cache = await readZixuluCache();
3815
- if (cache.sudoRequested) throw new Error("\u8BF7\u5728 sudo \u4E0B\u8FD0\u884C");
3811
+ if (cache.sudoRequested) throw new Error("请在 sudo 下运行");
3816
3812
  cache.sudoRequested = true;
3817
3813
  await writeZixuluCache(cache);
3818
3814
  await spawnAsync("sudo", [
@@ -3846,13 +3842,13 @@ async function setDockerRegistry() {
3846
3842
  {
3847
3843
  type: "input",
3848
3844
  name: "mirrors",
3849
- message: "\u8BF7\u8F93\u5165\u955C\u50CF\u5730\u5740\uFF0C\u591A\u4E2A\u7528\u9017\u53F7\u5206\u9694\uFF0C\u7559\u7A7A\u5219\u8DF3\u8FC7"
3845
+ message: "请输入镜像地址,多个用逗号分隔,留空则跳过"
3850
3846
  }
3851
3847
  ]);
3852
3848
  daemon["registry-mirrors"].push(...mirrors.split(/[,,]/).filter(isUrl));
3853
3849
  await writeFile("/etc/docker/daemon.json", JSON.stringify(daemon, void 0, 4), "utf-8");
3854
- consola.success("\u955C\u50CF\u5730\u5740\u8BBE\u7F6E\u6210\u529F");
3855
- consola.info("\u5EFA\u8BAE\u91CD\u542Fdocker\u670D\u52A1\uFF1A");
3850
+ consola.success("镜像地址设置成功");
3851
+ consola.info("建议重启docker服务:");
3856
3852
  consola.info("sudo systemctl daemon-reload");
3857
3853
  consola.info("sudo systemctl restart docker");
3858
3854
  }
@@ -3860,9 +3856,9 @@ async function installDocker() {
3860
3856
  if (!isSudo) return sudoCommand();
3861
3857
  const info = await execAsync("lsb_release -a");
3862
3858
  const distributorId = info.match(/Distributor ID:\s+(.+)/)?.[1];
3863
- if ("Ubuntu" !== distributorId) throw new Error("\u6682\u4E0D\u652F\u6301 Ubuntu \u4EE5\u5916\u7684\u7CFB\u7EDF");
3859
+ if ("Ubuntu" !== distributorId) throw new Error("暂不支持 Ubuntu 以外的系统");
3864
3860
  const codename = info.trim().match(/Codename:\s+(.+)/)?.[1];
3865
- if (!codename) throw new Error("\u65E0\u6CD5\u83B7\u53D6 codename");
3861
+ if (!codename) throw new Error("无法获取 codename");
3866
3862
  const response = await fetch(`https://download.docker.com/linux/ubuntu/dists/${codename}/pool/stable/amd64/`);
3867
3863
  const data = await response.text();
3868
3864
  const dom = new JSDOM(data);
@@ -3890,7 +3886,7 @@ async function installDocker() {
3890
3886
  {
3891
3887
  type: "confirm",
3892
3888
  name: "addMirrors",
3893
- message: "\u662F\u5426\u6DFB\u52A0\u955C\u50CF\u5730\u5740",
3889
+ message: "是否添加镜像地址",
3894
3890
  default: true
3895
3891
  }
3896
3892
  ]);
@@ -3902,11 +3898,11 @@ async function json2type_json2type(path) {
3902
3898
  try {
3903
3899
  JSON.parse(json);
3904
3900
  } catch {
3905
- consola.error(`\u{8BF7}\u{8F93}\u{5165}\u{6709}\u{6548}\u{7684} json \u{6587}\u{4EF6}\u{8DEF}\u{5F84}\u{6216}\u{590D}\u{5236}\u{6709}\u{6548}\u{7684} json \u{6587}\u{672C}`);
3901
+ consola.error(`请输入有效的 json 文件路径或复制有效的 json 文本`);
3906
3902
  }
3907
3903
  const type = json2type(json);
3908
3904
  await clipboardy.write(type);
3909
- consola.success("\u7C7B\u578B\u5DF2\u590D\u5236\u5230\u526A\u8D34\u677F");
3905
+ consola.success("类型已复制到剪贴板");
3910
3906
  }
3911
3907
  function readPackageJsonSync(dir) {
3912
3908
  try {
@@ -3914,8 +3910,8 @@ function readPackageJsonSync(dir) {
3914
3910
  return result;
3915
3911
  } catch (error) {
3916
3912
  consola.error(error);
3917
- consola.fail("\u8BFB\u53D6 package.json \u5931\u8D25");
3918
- throw new Error("\u8BFB\u53D6 package.json \u5931\u8D25");
3913
+ consola.fail("读取 package.json 失败");
3914
+ throw new Error("读取 package.json 失败");
3919
3915
  }
3920
3916
  }
3921
3917
  async function removeLock() {
@@ -3940,7 +3936,7 @@ async function removeLock() {
3940
3936
  recursive: true
3941
3937
  });
3942
3938
  await addRuleToGitIgnore("package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lockb", "bun.lock");
3943
- return getCommitMessage("feature", "\u5220\u9664\u5305\u7BA1\u7406 lock \u6587\u4EF6");
3939
+ return getCommitMessage("feature", "删除包管理 lock 文件");
3944
3940
  }
3945
3941
  function isAsset(url) {
3946
3942
  const lower = url.toLowerCase();
@@ -4077,17 +4073,17 @@ async function replaceAssets(options) {
4077
4073
  }
4078
4074
  }
4079
4075
  await replace(input);
4080
- consola.success(errors.size > 0 ? "\u66FF\u6362\u5B8C\u6210\uFF0C\u4EE5\u4E0B\u6587\u4EF6\u4E0B\u8F7D\u5931\u8D25\uFF1A" : "\u66FF\u6362\u5B8C\u6210");
4076
+ consola.success(errors.size > 0 ? "替换完成,以下文件下载失败:" : "替换完成");
4081
4077
  errors.forEach((url)=>consola.error(url));
4082
4078
  }
4083
4079
  const git = simple_git();
4084
4080
  async function replaceCommitAuthor({ prev: { name: prevName, email: prevEmail } = {}, next: { name: nextName, email: nextEmail } = {} }) {
4085
- if (!nextName && !nextEmail) throw new Error("\u65B0\u7684\u4F5C\u8005\u4FE1\u606F\u4E0D\u80FD\u4E3A\u7A7A\u3002\u8BF7\u63D0\u4F9B\u65B0\u7684\u4F5C\u8005\u540D\u79F0\u6216\u90AE\u7BB1\u3002");
4081
+ if (!nextName && !nextEmail) throw new Error("新的作者信息不能为空。请提供新的作者名称或邮箱。");
4086
4082
  const isRepo = await git.checkIsRepo();
4087
- if (!isRepo) throw new Error("\u5F53\u524D\u76EE\u5F55\u4E0D\u662F\u4E00\u4E2A Git \u4ED3\u5E93\u3002\u8BF7\u5728\u4E00\u4E2A\u6709\u6548\u7684 Git \u4ED3\u5E93\u4E2D\u8FD0\u884C\u6B64\u547D\u4EE4\u3002");
4083
+ if (!isRepo) throw new Error("当前目录不是一个 Git 仓库。请在一个有效的 Git 仓库中运行此命令。");
4088
4084
  const status = await git.status();
4089
- if (status.files.length) throw new Error("\u5F53\u524D Git \u4ED3\u5E93\u5B58\u5728\u672A\u63D0\u4EA4\u7684\u6587\u4EF6\u3002\u8BF7\u63D0\u4EA4\u6216\u6682\u5B58\u8FD9\u4E9B\u6587\u4EF6\u540E\u518D\u8BD5\u3002");
4090
- consola.start("\u5F00\u59CB\u4FEE\u6539 Git \u63D0\u4EA4\u5386\u53F2...");
4085
+ if (status.files.length) throw new Error("当前 Git 仓库存在未提交的文件。请提交或暂存这些文件后再试。");
4086
+ consola.start("开始修改 Git 提交历史...");
4091
4087
  console.log();
4092
4088
  const committerName = nextName ? ` export GIT_COMMITTER_NAME=\\"${nextName}\\"` : "";
4093
4089
  const committerEmail = nextEmail ? ` export GIT_COMMITTER_EMAIL=\\"${nextEmail}\\"` : "";
@@ -4103,8 +4099,8 @@ async function replaceCommitAuthor({ prev: { name: prevName, email: prevEmail }
4103
4099
  authorEmail
4104
4100
  ].filter(Boolean).join(" && ")}; fi" --tag-name-filter cat -- --branches --tags`);
4105
4101
  console.log();
4106
- consola.success("Git \u63D0\u4EA4\u5386\u53F2\u4FEE\u6539\u5B8C\u6210\uFF01");
4107
- consola.warn("\u8BF7\u5F3A\u5236\u63A8\u9001\u4EE5\u8986\u76D6\u8FDC\u7A0B\u4ED3\u5E93\uFF1Agit push -f");
4102
+ consola.success("Git 提交历史修改完成!");
4103
+ consola.warn("请强制推送以覆盖远程仓库:git push -f");
4108
4104
  }
4109
4105
  const rslibConfig = `import { defineConfig } from "@rslib/core"
4110
4106
 
@@ -4288,7 +4284,7 @@ async function setEnv(key, value) {
4288
4284
  await execAsync(`echo "export ${key}=${value}" >> ${config}`);
4289
4285
  await execAsync(`source ${config}`);
4290
4286
  }
4291
- consola.success(value ? `${key} \u{5DF2}\u{8BBE}\u{7F6E}\u{4E3A} ${value}` : `${key} \u{5DF2}\u{5220}\u{9664}`);
4287
+ consola.success(value ? `${key} 已设置为 ${value}` : `${key} 已删除`);
4292
4288
  }
4293
4289
  function setGlobalConfig({ registry, proxy }) {
4294
4290
  if (Object.keys(constant_Registry).includes(registry)) global.__ZIXULU_REGISTRY__ = constant_Registry[registry];
@@ -4304,7 +4300,7 @@ async function syncCursorExtToCode() {
4304
4300
  for (const ext of installExts)await execAsync(`code --install-extension ${ext}`);
4305
4301
  const uninstallExts = vscodeExts.difference(cursorExts);
4306
4302
  for (const ext of uninstallExts)await execAsync(`code --uninstall-extension ${ext}`);
4307
- consola.success("\u540C\u6B65\u5B8C\u6210");
4303
+ consola.success("同步完成");
4308
4304
  }
4309
4305
  async function getEditorExtensions({ source }) {
4310
4306
  let data = [];
@@ -4344,12 +4340,12 @@ async function syncEditorFile({ source, target }) {
4344
4340
  const code = await getFile(source);
4345
4341
  if (existsSync(target)) {
4346
4342
  const text = await readFile(target, "utf-8");
4347
- if (text === code) return void consola.success(`${target} \u{5DF2}\u{662F}\u{6700}\u{65B0}`);
4343
+ if (text === code) return void consola.success(`${target} 已是最新`);
4348
4344
  {
4349
4345
  const { backup } = await inquirer_0.prompt({
4350
4346
  type: "confirm",
4351
4347
  name: "backup",
4352
- message: `\u{662F}\u{5426}\u{5907}\u{4EFD}\u{539F}\u{6587}\u{4EF6}\u{FF08}${target}\u{FF09}`,
4348
+ message: `是否备份原文件(${target})`,
4353
4349
  default: setting.syncEditor?.fileConfigs?.[target]?.backup ?? true
4354
4350
  });
4355
4351
  setting.syncEditor ??= {};
@@ -4361,7 +4357,7 @@ async function syncEditorFile({ source, target }) {
4361
4357
  }
4362
4358
  }
4363
4359
  await writeFile(target, code, "utf-8");
4364
- consola.success(`${target} \u{540C}\u{6B65}\u{5B8C}\u{6210}`);
4360
+ consola.success(`${target} 同步完成`);
4365
4361
  }
4366
4362
  async function syncEditorSetting() {
4367
4363
  const setting = await readZixuluSetting();
@@ -4369,7 +4365,7 @@ async function syncEditorSetting() {
4369
4365
  {
4370
4366
  type: "list",
4371
4367
  name: "source",
4372
- message: "\u9009\u62E9\u540C\u6B65\u6765\u6E90",
4368
+ message: "选择同步来源",
4373
4369
  choices: [
4374
4370
  "Code",
4375
4371
  "Cursor",
@@ -4384,7 +4380,7 @@ async function syncEditorSetting() {
4384
4380
  {
4385
4381
  type: "checkbox",
4386
4382
  name: "targets",
4387
- message: "\u9009\u62E9\u540C\u6B65\u76EE\u6807",
4383
+ message: "选择同步目标",
4388
4384
  choices: [
4389
4385
  "Code",
4390
4386
  "Cursor",
@@ -4399,7 +4395,7 @@ async function syncEditorSetting() {
4399
4395
  {
4400
4396
  type: "checkbox",
4401
4397
  name: "types",
4402
- message: "\u9009\u62E9\u7684\u914D\u7F6E\u7C7B\u578B",
4398
+ message: "选择的配置类型",
4403
4399
  choices: [
4404
4400
  "settings",
4405
4401
  "snippets",
@@ -4418,7 +4414,7 @@ async function syncEditorSetting() {
4418
4414
  const { onlinePath } = await inquirer_0.prompt({
4419
4415
  type: "input",
4420
4416
  name: "onlinePath",
4421
- message: "\u8BF7\u8F93\u5165 blog \u6587\u4EF6\u5939\u7684\u8DEF\u5F84",
4417
+ message: "请输入 blog 文件夹的路径",
4422
4418
  default: setting.syncEditor?.onlinePath ?? "C:\\Users\\lenovo\\Desktop\\workspace\\blog"
4423
4419
  });
4424
4420
  setting.syncEditor.onlinePath = onlinePath;
@@ -4446,14 +4442,14 @@ async function syncEditorSetting() {
4446
4442
  console.log(`code --install-extension ${ext}`);
4447
4443
  await execAsync(`code --install-extension ${ext}`);
4448
4444
  } catch (error) {
4449
- console.error(`${ext} \u{5B89}\u{88C5}\u{5931}\u{8D25}`);
4445
+ console.error(`${ext} 安装失败`);
4450
4446
  }
4451
4447
  const uninstallExtensions = vscodeExtensions.difference(sourceExtensions);
4452
4448
  for (const ext of uninstallExtensions)try {
4453
4449
  console.log(`code --uninstall-extension ${ext}`);
4454
4450
  await execAsync(`code --uninstall-extension ${ext}`);
4455
4451
  } catch (error) {
4456
- console.error(`${ext} \u{5378}\u{8F7D}\u{5931}\u{8D25}`);
4452
+ console.error(`${ext} 卸载失败`);
4457
4453
  }
4458
4454
  }
4459
4455
  if (targets.includes("Cursor")) {
@@ -4462,23 +4458,28 @@ async function syncEditorSetting() {
4462
4458
  console.log(`cursor --install-extension ${ext}`);
4463
4459
  await execAsync(`cursor --install-extension ${ext}`);
4464
4460
  } catch (error) {
4465
- console.error(`${ext} \u{5B89}\u{88C5}\u{5931}\u{8D25}`);
4461
+ console.error(`${ext} 安装失败`);
4466
4462
  }
4467
4463
  const uninstallExtensions = cursorExtensions.difference(sourceExtensions);
4468
4464
  for (const ext of uninstallExtensions)try {
4469
4465
  console.log(`cursor --uninstall-extension ${ext}`);
4470
4466
  await execAsync(`cursor --uninstall-extension ${ext}`);
4471
4467
  } catch (error) {
4472
- console.error(`${ext} \u{5378}\u{8F7D}\u{5931}\u{8D25}`);
4468
+ console.error(`${ext} 卸载失败`);
4473
4469
  }
4474
4470
  }
4475
4471
  if (targets.includes("Online")) await writeFile(join(onlinePath, "static", "extensions.json"), JSON.stringify(Array.from(sourceExtensions), null, 4));
4476
4472
  }
4477
4473
  if (targets.includes("Online")) {
4478
- if (await hasChangeNoCommit(onlinePath)) await addGitCommit({
4479
- message: getCommitMessage("feature", "sync editor setting"),
4480
- cwd: onlinePath
4481
- });
4474
+ if (await hasChangeNoCommit(onlinePath)) {
4475
+ await addGitCommit({
4476
+ message: getCommitMessage("feature", "sync editor setting"),
4477
+ cwd: onlinePath
4478
+ });
4479
+ await execAsync("git push", {
4480
+ cwd: onlinePath
4481
+ });
4482
+ }
4482
4483
  }
4483
4484
  await writeZixuluSetting(setting);
4484
4485
  }
@@ -4504,7 +4505,7 @@ async function tar({ input, output }) {
4504
4505
  const { overwrite } = await inquirer_0.prompt({
4505
4506
  type: "confirm",
4506
4507
  name: "overwrite",
4507
- message: "\u6587\u4EF6\u5DF2\u5B58\u5728\uFF0C\u662F\u5426\u8986\u76D6"
4508
+ message: "文件已存在,是否覆盖"
4508
4509
  });
4509
4510
  if (!overwrite) return;
4510
4511
  }
@@ -4520,16 +4521,16 @@ async function test() {
4520
4521
  async function updateDockerCompose() {
4521
4522
  const dir = await readdir(".");
4522
4523
  const file = dir.find((item)=>"docker-compose.yml" === item || "docker-compose.yaml" === item);
4523
- if (!file) throw new Error("docker-compose.yml \u6216 docker-compose.yaml \u6587\u4EF6\u4E0D\u5B58\u5728");
4524
+ if (!file) throw new Error("docker-compose.yml docker-compose.yaml 文件不存在");
4524
4525
  const content = await readFile(file, "utf-8");
4525
4526
  const data = yaml_0.parse(content);
4526
4527
  const images = Object.values(data.services).map((service)=>service.image);
4527
- consola.start("\u5F00\u59CB\u66F4\u65B0\u955C\u50CF");
4528
+ consola.start("开始更新镜像");
4528
4529
  for (const image of images)await spawnAsync(`docker pull ${image}`, {
4529
4530
  shell: true,
4530
4531
  stdio: "inherit"
4531
4532
  });
4532
- consola.success("\u66F4\u65B0\u955C\u50CF\u5B8C\u6210");
4533
+ consola.success("更新镜像完成");
4533
4534
  await spawnAsync("docker compose down", {
4534
4535
  shell: true,
4535
4536
  stdio: "inherit"
@@ -4538,7 +4539,7 @@ async function updateDockerCompose() {
4538
4539
  shell: true,
4539
4540
  stdio: "inherit"
4540
4541
  });
4541
- consola.success("\u542F\u52A8\u5BB9\u5668\u5B8C\u6210");
4542
+ consola.success("启动容器完成");
4542
4543
  }
4543
4544
  async function getPackageLatestVersion(packageName) {
4544
4545
  const registry = await getRegistry();
@@ -4613,7 +4614,7 @@ async function upgradeWorkspaceDependceny() {
4613
4614
  {
4614
4615
  type: "checkbox",
4615
4616
  name: "packages3",
4616
- message: "\u8BF7\u9009\u62E9\u8981\u5347\u7EA7\u7684\u5305",
4617
+ message: "请选择要升级的包",
4617
4618
  choices: packages2,
4618
4619
  default: setting.upgradeWorkspaceDependcenyHistory?.[dir2]
4619
4620
  }
@@ -4622,7 +4623,7 @@ async function upgradeWorkspaceDependceny() {
4622
4623
  setting.upgradeWorkspaceDependcenyHistory[dir2] = packages3;
4623
4624
  await writeZixuluSetting(setting);
4624
4625
  for (const pkg of packages3){
4625
- consola.start(`\u{5F00}\u{59CB}\u{5347}\u{7EA7} ${pkg} \u{7684}\u{4F9D}\u{8D56}`);
4626
+ consola.start(`开始升级 ${pkg} 的依赖`);
4626
4627
  chdir(join(dir2, pkg));
4627
4628
  await actionWithBackup(()=>upgradeDependency({
4628
4629
  dir: ".",
@@ -4630,16 +4631,6 @@ async function upgradeWorkspaceDependceny() {
4630
4631
  }))();
4631
4632
  }
4632
4633
  }
4633
- async function winget() {
4634
- const args = [
4635
- "update",
4636
- "--accept-package-agreements",
4637
- "--accept-source-agreements",
4638
- "--all"
4639
- ];
4640
- if (global.__ZIXULU_PROXY__) args.push("--proxy", "http://127.0.0.1:7890");
4641
- spawnAsync("winget", args);
4642
- }
4643
4634
  const verdaccio_script = `import { spawnSync } from "child_process"
4644
4635
 
4645
4636
  spawnSync("docker compose down", { cwd: "verdaccio", shell: true, stdio: "inherit" })
@@ -4658,13 +4649,13 @@ async function verdaccio() {
4658
4649
  let { verdaccioPath } = await inquirer_0.prompt({
4659
4650
  type: "input",
4660
4651
  name: "verdaccioPath",
4661
- message: "\u8BF7\u8F93\u5165 verdaccio \u6587\u4EF6\u5939\u7684\u4F4D\u7F6E",
4652
+ message: "请输入 verdaccio 文件夹的位置",
4662
4653
  default: setting.verdaccioPath
4663
4654
  });
4664
4655
  verdaccioPath = verdaccioPath.replace(/^"|"$/g, "");
4665
4656
  verdaccioPath = external_path_resolve(verdaccioPath);
4666
4657
  const stats = await stat(verdaccioPath);
4667
- if (!stats.isDirectory()) throw new Error("verdaccio \u6587\u4EF6\u5939\u4E0D\u5B58\u5728");
4658
+ if (!stats.isDirectory()) throw new Error("verdaccio 文件夹不存在");
4668
4659
  setting.verdaccioPath = verdaccioPath;
4669
4660
  await writeZixuluSetting(setting);
4670
4661
  const { base } = parse(verdaccioPath);
@@ -4674,86 +4665,96 @@ async function verdaccio() {
4674
4665
  });
4675
4666
  await writeFile(join("verdaccio", "syncVerdaccio.mjs"), verdaccio_script, "utf-8");
4676
4667
  }
4668
+ async function winget() {
4669
+ const args = [
4670
+ "update",
4671
+ "--accept-package-agreements",
4672
+ "--accept-source-agreements",
4673
+ "--all"
4674
+ ];
4675
+ if (global.__ZIXULU_PROXY__) args.push("--proxy", "http://127.0.0.1:7890");
4676
+ spawnAsync("winget", args);
4677
+ }
4677
4678
  setDefaultOptions({
4678
4679
  shell: true,
4679
4680
  stdio: "inherit"
4680
4681
  });
4681
4682
  const program = new Command();
4682
4683
  const src_pkg = readPackageJsonSync("win32" === process.platform ? import.meta.resolve("../").replace(/^file:\/\/\//, "") : import.meta.resolve("../").replace(/^file:\/\//, ""));
4683
- program.name("\u683C\u6570\u79D1\u6280").version(src_pkg.version);
4684
+ program.name("格数科技").version(src_pkg.version);
4684
4685
  console.log(chalk.redBright.bold(`zixulu ${src_pkg.version}`));
4685
- program.command("eslint").description("\u6DFB\u52A0 ESLint \u76F8\u5173\u914D\u7F6E").action(actionWithBackup(addEslint, getCommitMessage("feature", "\u6DFB\u52A0 ESLint \u76F8\u5173\u914D\u7F6E")));
4686
- program.command("prettier").description("\u6DFB\u52A0 prettier \u914D\u7F6E").action(actionWithBackup(addPrettier, getCommitMessage("feature", "\u6DFB\u52A0 prettier \u914D\u7F6E\u6587\u4EF6")));
4687
- program.command("vite").description("\u521D\u59CB\u5316 vite \u914D\u7F6E").action(actionWithBackup(vite, getCommitMessage("feature", "\u521D\u59CB\u5316 vite \u914D\u7F6E")));
4688
- program.command("rsbuild").description("\u521D\u59CB\u5316 rsbuild \u914D\u7F6E").action(actionWithBackup(rsbuild, getCommitMessage("feature", "\u521D\u59CB\u5316 rsbuild \u914D\u7F6E")));
4689
- program.command("next").description("\u521D\u59CB\u5316 next \u914D\u7F6E").action(actionWithBackup(next_next, getCommitMessage("feature", "\u521D\u59CB\u5316 next \u914D\u7F6E")));
4690
- program.command("tailwind").description("\u6DFB\u52A0 tailwind \u914D\u7F6E").action(actionWithBackup(addTailwind, getCommitMessage("feature", "\u6DFB\u52A0 tailwind \u914D\u7F6E")));
4691
- program.command("remove-comment").description("\u5220\u9664\u6587\u4EF6\u6CE8\u91CA").argument("path", "\u6587\u4EF6\u8DEF\u5F84").action(actionWithBackup(removeComment, getCommitMessage("feature", "\u5220\u9664\u6587\u4EF6\u6CE8\u91CA")));
4692
- program.command("father").alias("fs").description("\u521D\u59CB\u5316 father \u9879\u76EE\u914D\u7F6E").action(actionWithBackup(setFatherConfig, getCommitMessage("feature", "\u521D\u59CB\u5316 father \u9879\u76EE\u914D\u7F6E")));
4693
- program.command("upgrade-dependency").alias("ud").description("\u5347\u7EA7\u9879\u76EE\u4F9D\u8D56").option("-r, --registry <registry>", "npm \u6E90\u5730\u5740\uFF0C\u53EF\u4EE5\u662F npm\u3001taobao\u3001tencent \u6216\u8005\u81EA\u5B9A\u4E49\u5730\u5740").option("-p, --proxy", "\u662F\u5426\u4F7F\u7528\u4EE3\u7406").action(async (optios)=>{
4686
+ program.command("eslint").description("添加 ESLint 相关配置").action(actionWithBackup(addEslint, getCommitMessage("feature", "添加 ESLint 相关配置")));
4687
+ program.command("prettier").description("添加 prettier 配置").action(actionWithBackup(addPrettier, getCommitMessage("feature", "添加 prettier 配置文件")));
4688
+ program.command("vite").description("初始化 vite 配置").action(actionWithBackup(vite, getCommitMessage("feature", "初始化 vite 配置")));
4689
+ program.command("rsbuild").description("初始化 rsbuild 配置").action(actionWithBackup(rsbuild, getCommitMessage("feature", "初始化 rsbuild 配置")));
4690
+ program.command("next").description("初始化 next 配置").action(actionWithBackup(next_next, getCommitMessage("feature", "初始化 next 配置")));
4691
+ program.command("tailwind").description("添加 tailwind 配置").action(actionWithBackup(addTailwind, getCommitMessage("feature", "添加 tailwind 配置")));
4692
+ program.command("remove-comment").description("删除文件注释").argument("path", "文件路径").action(actionWithBackup(removeComment, getCommitMessage("feature", "删除文件注释")));
4693
+ program.command("father").alias("fs").description("初始化 father 项目配置").action(actionWithBackup(setFatherConfig, getCommitMessage("feature", "初始化 father 项目配置")));
4694
+ program.command("upgrade-dependency").alias("ud").description("升级项目依赖").option("-r, --registry <registry>", "npm 源地址,可以是 npm、taobao、tencent 或者自定义地址").option("-p, --proxy", "是否使用代理").action(async (optios)=>{
4694
4695
  setGlobalConfig(optios);
4695
4696
  await actionWithBackup(()=>upgradeDependency())();
4696
4697
  });
4697
- program.command("upgrade-workspace-dependency").alias("uwd").description("\u5347\u7EA7\u5DE5\u4F5C\u533A\u9879\u76EE\u4F9D\u8D56").option("-r, --registry <registry>", "npm \u6E90\u5730\u5740\uFF0C\u53EF\u4EE5\u662F npm\u3001taobao\u3001tencent \u6216\u8005\u81EA\u5B9A\u4E49\u5730\u5740").option("-p, --proxy", "\u662F\u5426\u4F7F\u7528\u4EE3\u7406").action(async (options)=>{
4698
+ program.command("upgrade-workspace-dependency").alias("uwd").description("升级工作区项目依赖").option("-r, --registry <registry>", "npm 源地址,可以是 npm、taobao、tencent 或者自定义地址").option("-p, --proxy", "是否使用代理").action(async (options)=>{
4698
4699
  setGlobalConfig(options);
4699
4700
  await upgradeWorkspaceDependceny();
4700
4701
  });
4701
- program.command("registry").description("\u8BBE\u7F6E npm registry").action(setRegistry);
4702
- program.command("sort-package-json").alias("spj").description("\u5BF9 package.json \u4E2D\u7684\u4F9D\u8D56\u8FDB\u884C\u6392\u5E8F").action(actionWithBackup(sortPackageJson, getCommitMessage("feature", "\u5BF9 package.json \u4E2D\u7684\u4F9D\u8D56\u8FDB\u884C\u6392\u5E8F")));
4703
- program.command("arrow-to-function").alias("a2f").description("\u5C06\u7BAD\u5934\u51FD\u6570\u7EC4\u4EF6\u8F6C\u6362\u4E3A\u51FD\u6570\u7EC4\u4EF6").action(actionWithBackup(arrowToFunction, getCommitMessage("feature", "\u5C06\u7BAD\u5934\u51FD\u6570\u7EC4\u4EF6\u8F6C\u6362\u4E3A\u51FD\u6570\u7EC4\u4EF6")));
4704
- program.command("interface-to-type").alias("i2t").description("\u5C06 interface \u8F6C\u6362\u4E3A type").action(actionWithBackup(interfaceToType, getCommitMessage("feature", "\u5C06 interface \u8F6C\u6362\u4E3A type")));
4705
- program.command("gitignore").description("\u6DFB\u52A0 .gitignore \u914D\u7F6E").action(actionWithBackup(addGitignore));
4706
- program.command("git-proxy").alias("gp").description("\u8BBE\u7F6E git \u4EE3\u7406").action(setGitProxy);
4707
- program.command("shell-proxy").alias("sp").description("\u8BBE\u7F6E Shell \u4EE3\u7406").action(setShellProxy);
4708
- program.command("download-software").alias("ds").description("\u4E0B\u8F7D\u6700\u65B0\u7248\u8F6F\u4EF6").action(downloadLatestSoftware);
4709
- program.command("vscode").alias("vsc").description("\u540C\u6B65 VS Code \u914D\u7F6E").action(syncVscode);
4710
- program.command("kill-port").description("\u6839\u636E\u7AEF\u53E3\u53F7\u6740\u6B7B\u8FDB\u7A0B").argument("port", "\u7AEF\u53E3\u53F7").action(killProcessByPort);
4711
- program.command("rm-git").argument("path", "\u8981\u79FB\u9664\u7684\u6587\u4EF6\u6216\u6587\u4EF6\u5939").action(removeFileOrFolderFromGit);
4712
- program.command("npm-download").alias("nd").description("\u4E0B\u8F7D npm \u5305").argument("name", "\u5305\u540D").action(downloadNpm);
4713
- program.command("prisma").description("\u6DFB\u52A0 prisma \u914D\u7F6E").action(actionWithBackup(()=>addPrisma(), getCommitMessage("feature", "\u6DFB\u52A0 prisma \u914D\u7F6E")));
4714
- program.command("prisma-generate").alias("pg").description("\u751F\u6210 prisma client").action(generatePrisma);
4715
- program.command("antd").description("\u6DFB\u52A0 antd \u914D\u7F6E").action(actionWithBackup(addAntd, getCommitMessage("feature", "\u6DFB\u52A0 antd \u914D\u7F6E")));
4716
- program.command("init").description("\u521D\u59CB\u5316\u9879\u76EE").action(actionWithBackup(initProject, getCommitMessage("feature", "\u521D\u59CB\u5316\u9879\u76EE")));
4717
- program.command("tsc").description("\u7C7B\u578B\u68C0\u67E5").action(checkType);
4718
- program.command("beta-version").alias("bv").description("\u8BBE\u7F6E\u7248\u672C\u53F7").action(betaVersion);
4719
- program.command("reinstall").alias("ri").description("\u91CD\u65B0\u5B89\u88C5\u4F9D\u8D56").option("-r, --registry <registry>", "npm \u6E90\u5730\u5740\uFF0C\u53EF\u4EE5\u662F npm\u3001taobao\u3001tencent \u6216\u8005\u81EA\u5B9A\u4E49\u5730\u5740").action(async (options)=>{
4702
+ program.command("registry").description("设置 npm registry").action(setRegistry);
4703
+ program.command("sort-package-json").alias("spj").description(" package.json 中的依赖进行排序").action(actionWithBackup(sortPackageJson, getCommitMessage("feature", " package.json 中的依赖进行排序")));
4704
+ program.command("arrow-to-function").alias("a2f").description("将箭头函数组件转换为函数组件").action(actionWithBackup(arrowToFunction, getCommitMessage("feature", "将箭头函数组件转换为函数组件")));
4705
+ program.command("interface-to-type").alias("i2t").description(" interface 转换为 type").action(actionWithBackup(interfaceToType, getCommitMessage("feature", " interface 转换为 type")));
4706
+ program.command("gitignore").description("添加 .gitignore 配置").action(actionWithBackup(addGitignore));
4707
+ program.command("git-proxy").alias("gp").description("设置 git 代理").action(setGitProxy);
4708
+ program.command("shell-proxy").alias("sp").description("设置 Shell 代理").action(setShellProxy);
4709
+ program.command("download-software").alias("ds").description("下载最新版软件").action(downloadLatestSoftware);
4710
+ program.command("vscode").alias("vsc").description("同步 VS Code 配置").action(syncVscode);
4711
+ program.command("kill-port").description("根据端口号杀死进程").argument("port", "端口号").action(killProcessByPort);
4712
+ program.command("rm-git").argument("path", "要移除的文件或文件夹").action(removeFileOrFolderFromGit);
4713
+ program.command("npm-download").alias("nd").description("下载 npm ").argument("name", "包名").action(downloadNpm);
4714
+ program.command("prisma").description("添加 prisma 配置").action(actionWithBackup(()=>addPrisma(), getCommitMessage("feature", "添加 prisma 配置")));
4715
+ program.command("prisma-generate").alias("pg").description("生成 prisma client").action(generatePrisma);
4716
+ program.command("antd").description("添加 antd 配置").action(actionWithBackup(addAntd, getCommitMessage("feature", "添加 antd 配置")));
4717
+ program.command("init").description("初始化项目").action(actionWithBackup(initProject, getCommitMessage("feature", "初始化项目")));
4718
+ program.command("tsc").description("类型检查").action(checkType);
4719
+ program.command("beta-version").alias("bv").description("设置版本号").action(betaVersion);
4720
+ program.command("reinstall").alias("ri").description("重新安装依赖").option("-r, --registry <registry>", "npm 源地址,可以是 npm、taobao、tencent 或者自定义地址").action(async (options)=>{
4720
4721
  setGlobalConfig(options);
4721
4722
  reinstall();
4722
4723
  });
4723
- program.command("snippet").alias("sn").description("\u751F\u6210 vscode snippet").argument("path", "\u6587\u4EF6\u8DEF\u5F84").action(code2Snippet);
4724
- program.command("add-alias").alias("aa").description("\u6DFB\u52A0\u8DEF\u5F84\u522B\u540D").action(actionWithBackup(addFolderPathAlias));
4725
- program.command("replace-alias").alias("ra").description("\u66FF\u6362\u8DEF\u5F84\u522B\u540D").action(actionWithBackup(replacePathAlias));
4726
- program.command("pnpm").description("\u8BBE\u7F6E pnpm \u914D\u7F6E").action(pnpm);
4727
- program.command("rollup").description("rollup \u6253\u5305").action(rollup);
4728
- program.command("browserlistrc").alias("blr").description("\u6DFB\u52A0 browserlistrc \u914D\u7F6E").action(createBrowserlistrc);
4729
- program.command("asset").description("\u66FF\u6362\u6587\u4EF6\u4E2D\u7684\u8D44\u6E90\u5730\u5740").argument("input", "\u9759\u6001\u6587\u4EF6\u5939\u8DEF\u5F84").option("-b, --base <base>", "\u8D44\u6E90\u5730\u5740 BaseUrl").option("-o, --output <output>", "\u8F93\u51FA\u6587\u4EF6\u5939").option("-p, --proxy", "\u662F\u5426\u4F7F\u7528\u4EE3\u7406").action((input, { proxy, base, output })=>replaceAssets({
4724
+ program.command("snippet").alias("sn").description("生成 vscode snippet").argument("path", "文件路径").action(code2Snippet);
4725
+ program.command("add-alias").alias("aa").description("添加路径别名").action(actionWithBackup(addFolderPathAlias));
4726
+ program.command("replace-alias").alias("ra").description("替换路径别名").action(actionWithBackup(replacePathAlias));
4727
+ program.command("pnpm").description("设置 pnpm 配置").action(pnpm);
4728
+ program.command("rollup").description("rollup 打包").action(rollup);
4729
+ program.command("browserlistrc").alias("blr").description("添加 browserlistrc 配置").action(createBrowserlistrc);
4730
+ program.command("asset").description("替换文件中的资源地址").argument("input", "静态文件夹路径").option("-b, --base <base>", "资源地址 BaseUrl").option("-o, --output <output>", "输出文件夹").option("-p, --proxy", "是否使用代理").action((input, { proxy, base, output })=>replaceAssets({
4730
4731
  base,
4731
4732
  input,
4732
4733
  proxy,
4733
4734
  output
4734
4735
  }));
4735
- program.command("upgrade-rsbuild").alias("ur").description("\u5347\u7EA7 rsbuild").option("-r, --registry <registry>", "npm \u6E90\u5730\u5740\uFF0C\u53EF\u4EE5\u662F npm\u3001taobao\u3001tencent \u6216\u8005\u81EA\u5B9A\u4E49\u5730\u5740").option("-p, --proxy", "\u662F\u5426\u4F7F\u7528\u4EE3\u7406").action(async (options)=>{
4736
+ program.command("upgrade-rsbuild").alias("ur").description("升级 rsbuild").option("-r, --registry <registry>", "npm 源地址,可以是 npm、taobao、tencent 或者自定义地址").option("-p, --proxy", "是否使用代理").action(async (options)=>{
4736
4737
  setGlobalConfig(options);
4737
4738
  await actionWithBackup(()=>upgradeRsbuild())();
4738
4739
  });
4739
- program.command("add-start-script").alias("ass").argument("type", "\u542F\u52A8\u811A\u672C\u7C7B\u578B\uFF1Aexpress\u3001next").option("-p, --port <port>", "\u7AEF\u53E3\u5730\u5740").option("-c, --core <core>", "\u5B9E\u4F8B\u6570").option("-h, --hostname <hostname>", "\u4E3B\u673A\u540D").option("--pem <pemPath>", "\u8BC1\u4E66\u76EE\u5F55").description("\u6DFB\u52A0 express \u542F\u52A8\u811A\u672C").action(async (type, { port, core, pemPath })=>actionWithBackup(addStartScript)({
4740
+ program.command("add-start-script").alias("ass").argument("type", "启动脚本类型:express、next").option("-p, --port <port>", "端口地址").option("-c, --core <core>", "实例数").option("-h, --hostname <hostname>", "主机名").option("--pem <pemPath>", "证书目录").description("添加 express 启动脚本").action(async (type, { port, core, pemPath })=>actionWithBackup(addStartScript)({
4740
4741
  type,
4741
4742
  port,
4742
4743
  core,
4743
4744
  pemPath
4744
4745
  }));
4745
- program.command("headers").description("\u5C06\u6D4F\u89C8\u5668\u4E2D\u76F4\u63A5\u590D\u5236\u7684 headers \u8F6C\u6362\u4E3A\u5BF9\u8C61").action(getHeaders);
4746
- program.command("add-zip-dist").alias("azd").description("\u6DFB\u52A0\u5C06 dist \u538B\u7F29\u7684\u811A\u672C").action(actionWithBackup(()=>addZipDist({
4746
+ program.command("headers").description("将浏览器中直接复制的 headers 转换为对象").action(getHeaders);
4747
+ program.command("add-zip-dist").alias("azd").description("添加将 dist 压缩的脚本").action(actionWithBackup(()=>addZipDist({
4747
4748
  install: true
4748
4749
  })));
4749
- program.command("upgrade-tailwind").alias("ut").description("\u5347\u7EA7 tailwind").option("-r, --registry <registry>", "npm \u6E90\u5730\u5740\uFF0C\u53EF\u4EE5\u662F npm\u3001taobao\u3001tencent \u6216\u8005\u81EA\u5B9A\u4E49\u5730\u5740").option("-p, --proxy", "\u662F\u5426\u4F7F\u7528\u4EE3\u7406").action(async (options)=>{
4750
+ program.command("upgrade-tailwind").alias("ut").description("升级 tailwind").option("-r, --registry <registry>", "npm 源地址,可以是 npm、taobao、tencent 或者自定义地址").option("-p, --proxy", "是否使用代理").action(async (options)=>{
4750
4751
  setGlobalConfig(options);
4751
4752
  await actionWithBackup(()=>upgradeTailwind())();
4752
4753
  });
4753
- program.command("bun").description("\u8BBE\u7F6E bun").action(setBun);
4754
- program.command("tailwind-patch").alias("tp").description("tailwind \u8865\u4E01").action(tailwindPatch);
4755
- program.command("remove-lock").alias("rl").description("\u5220\u9664 lock \u6587\u4EF6").action(actionWithBackup(()=>removeLock()));
4756
- program.command("rename-commit-author").alias("rca").description("\u91CD\u5199 Git \u63D0\u4EA4\u5386\u53F2\u7684\u4F5C\u8005\u4FE1\u606F").arguments("[infos...]").action(async (infos)=>{
4754
+ program.command("bun").description("设置 bun").action(setBun);
4755
+ program.command("tailwind-patch").alias("tp").description("tailwind 补丁").action(tailwindPatch);
4756
+ program.command("remove-lock").alias("rl").description("删除 lock 文件").action(actionWithBackup(()=>removeLock()));
4757
+ program.command("rename-commit-author").alias("rca").description("重写 Git 提交历史的作者信息").arguments("[infos...]").action(async (infos)=>{
4757
4758
  let prev;
4758
4759
  let next;
4759
4760
  infos = infos.slice(0, 2);
@@ -4772,7 +4773,7 @@ program.command("rename-commit-author").alias("rca").description("\u91CD\u5199 G
4772
4773
  email: info.slice(index + 1)
4773
4774
  };
4774
4775
  }
4775
- if (0 === infos.length) throw new Error("\u8BF7\u8F93\u5165\u4F5C\u8005\u4FE1\u606F\uFF01");
4776
+ if (0 === infos.length) throw new Error("请输入作者信息!");
4776
4777
  if (1 === infos.length) next = getUsernameAndEmail(infos[0]);
4777
4778
  else {
4778
4779
  prev = getUsernameAndEmail(infos[0]);
@@ -4783,44 +4784,44 @@ program.command("rename-commit-author").alias("rca").description("\u91CD\u5199 G
4783
4784
  next
4784
4785
  });
4785
4786
  });
4786
- program.command("install-docker").alias("id").description("\u5B89\u88C5 Docker").action(installDocker);
4787
- program.command("set-docker-registry").alias("sdr").description("\u8BBE\u7F6E Docker \u955C\u50CF\u5730\u5740").action(setDockerRegistry);
4788
- program.command("add-sync").alias("asp").option("-m, --monorepo", "\u662F\u5426\u662F monorepo").description("\u6DFB\u52A0\u540C\u6B65\u5305\u811A\u672C").action(actionWithBackup(addSyncPackageScript));
4789
- program.command("winget").option("-p, --proxy", "\u662F\u5426\u4F7F\u7528\u4EE3\u7406").description("\u4F7F\u7528 winget \u66F4\u65B0\u8F6F\u4EF6").action(async (options)=>{
4787
+ program.command("install-docker").alias("id").description("安装 Docker").action(installDocker);
4788
+ program.command("set-docker-registry").alias("sdr").description("设置 Docker 镜像地址").action(setDockerRegistry);
4789
+ program.command("add-sync").alias("asp").option("-m, --monorepo", "是否是 monorepo").description("添加同步包脚本").action(actionWithBackup(addSyncPackageScript));
4790
+ program.command("winget").option("-p, --proxy", "是否使用代理").description("使用 winget 更新软件").action(async (options)=>{
4790
4791
  setGlobalConfig(options);
4791
4792
  await winget();
4792
4793
  });
4793
- program.command("test").description("\u8FD9\u662F\u4E00\u4E2A\u6D4B\u8BD5\u547D\u4EE4\uFF0C\u751F\u4EA7\u73AF\u5883\u4E2D\u4F7F\u7528\uFF0C\u975E\u5F00\u53D1\u4EBA\u5458\u8BF7\u52FF\u4F7F\u7528\uFF01").action(async ()=>{
4794
- consola.warn("\u8FD9\u662F\u4E00\u4E2A\u6D4B\u8BD5\u547D\u4EE4\uFF0C\u751F\u4EA7\u73AF\u5883\u4E2D\u4F7F\u7528\uFF0C\u975E\u5F00\u53D1\u4EBA\u5458\u8BF7\u52FF\u4F7F\u7528\uFF01");
4795
- consola.warn("\u8FD9\u662F\u4E00\u4E2A\u6D4B\u8BD5\u547D\u4EE4\uFF0C\u751F\u4EA7\u73AF\u5883\u4E2D\u4F7F\u7528\uFF0C\u975E\u5F00\u53D1\u4EBA\u5458\u8BF7\u52FF\u4F7F\u7528\uFF01");
4796
- consola.warn("\u8FD9\u662F\u4E00\u4E2A\u6D4B\u8BD5\u547D\u4EE4\uFF0C\u751F\u4EA7\u73AF\u5883\u4E2D\u4F7F\u7528\uFF0C\u975E\u5F00\u53D1\u4EBA\u5458\u8BF7\u52FF\u4F7F\u7528\uFF01");
4794
+ program.command("test").description("这是一个测试命令,生产环境中使用,非开发人员请勿使用!").action(async ()=>{
4795
+ consola.warn("这是一个测试命令,生产环境中使用,非开发人员请勿使用!");
4796
+ consola.warn("这是一个测试命令,生产环境中使用,非开发人员请勿使用!");
4797
+ consola.warn("这是一个测试命令,生产环境中使用,非开发人员请勿使用!");
4797
4798
  await test();
4798
4799
  });
4799
- program.command("sync-editor").alias("se").description("\u540C\u6B65\u7F16\u8F91\u5668\u914D\u7F6E").action(syncEditorSetting);
4800
- program.command("server-to-action").alias("sta").description("\u5C06 server \u6587\u4EF6\u5939\u4E0B\u7684\u6587\u4EF6\u8F6C\u6362\u4E3A action").action(serverToAction);
4801
- program.command("tar").description("\u538B\u7F29\u6587\u4EF6").argument("input", "\u8F93\u5165\u6587\u4EF6\u5939").option("-o, --output <output>", "\u8F93\u51FA\u6587\u4EF6").action(async (input, { output })=>tar({
4800
+ program.command("sync-editor").alias("se").description("同步编辑器配置").action(syncEditorSetting);
4801
+ program.command("server-to-action").alias("sta").description(" server 文件夹下的文件转换为 action").action(serverToAction);
4802
+ program.command("tar").description("压缩文件").argument("input", "输入文件夹").option("-o, --output <output>", "输出文件").action(async (input, { output })=>tar({
4802
4803
  input,
4803
4804
  output
4804
4805
  }));
4805
- program.command("set-env").description("\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF").argument("key", "\u73AF\u5883\u53D8\u91CF key").argument("[value]", "\u73AF\u5883\u53D8\u91CF value").action(async (key, value)=>{
4806
+ program.command("set-env").description("设置环境变量").argument("key", "环境变量 key").argument("[value]", "环境变量 value").action(async (key, value)=>{
4806
4807
  await setEnv(key, value);
4807
- consola.success("\u8BBE\u7F6E\u73AF\u5883\u53D8\u91CF\u6210\u529F");
4808
+ consola.success("设置环境变量成功");
4808
4809
  });
4809
- program.command("add-api").description("\u6DFB\u52A0 api \u6587\u4EF6").argument("type", "api \u7C7B\u578B").option("-a, --api <api>", "api \u6587\u4EF6\u5939\u8DEF\u5F84").option("-h, --hook <hook>", "hook \u6587\u4EF6\u5939\u8DEF\u5F84").action(async (type, { api, hook })=>addApi({
4810
+ program.command("add-api").description("添加 api 文件").argument("type", "api 类型").option("-a, --api <api>", "api 文件夹路径").option("-h, --hook <hook>", "hook 文件夹路径").action(async (type, { api, hook })=>addApi({
4810
4811
  type,
4811
4812
  api,
4812
4813
  hook
4813
4814
  }));
4814
- program.command("rslib").description("rslib \u914D\u7F6E").action(rslib);
4815
- program.command("init-node").description("\u521D\u59CB\u5316 node \u9879\u76EE").action(initNode);
4816
- program.command("add-build-docker").alias("abd").description("\u6DFB\u52A0\u6784\u5EFA docker \u955C\u50CF\u7684\u811A\u672C").action(addBuildDocker);
4817
- program.command("json2type").alias("j2t").argument("[path]", "json \u6587\u4EF6\u8DEF\u5F84").description("\u5C06 json \u8F6C\u6362\u4E3A type").action(json2type_json2type);
4818
- program.command("clear-docker-image").alias("cdi").description("\u6E05\u9664 docker \u60AC\u6302\u955C\u50CF").argument("[name]", "\u955C\u50CF\u540D\u79F0").action(clearDockerImage);
4819
- program.command("clear-docker-log").alias("cdl").description("\u6E05\u9664 docker \u5BB9\u5668\u65E5\u5FD7").argument("name", "\u5BB9\u5668\u540D\u79F0\u6216\u8005 ID").action(clearDockerLog);
4820
- program.command("update-docker-compose").alias("udc").description("\u66F4\u65B0 docker compose \u955C\u50CF").action(updateDockerCompose);
4821
- program.command("sync-cursor-ext-to-code").alias("sce2c").description("\u540C\u6B65 cursor \u6269\u5C55\u5230 vscode").action(syncCursorExtToCode);
4822
- program.command("create-prisma-debugger").alias("cpd").description("\u521B\u5EFA prisma \u8C03\u8BD5\u5668").action(createPrismaDebugger);
4823
- program.command("verdaccio").description("\u540C\u6B65 verdaccio \u914D\u7F6E").action(verdaccio);
4815
+ program.command("rslib").description("rslib 配置").action(rslib);
4816
+ program.command("init-node").description("初始化 node 项目").action(initNode);
4817
+ program.command("add-build-docker").alias("abd").description("添加构建 docker 镜像的脚本").action(addBuildDocker);
4818
+ program.command("json2type").alias("j2t").argument("[path]", "json 文件路径").description(" json 转换为 type").action(json2type_json2type);
4819
+ program.command("clear-docker-image").alias("cdi").description("清除 docker 悬挂镜像").argument("[name]", "镜像名称").action(clearDockerImage);
4820
+ program.command("clear-docker-log").alias("cdl").description("清除 docker 容器日志").argument("name", "容器名称或者 ID").action(clearDockerLog);
4821
+ program.command("update-docker-compose").alias("udc").description("更新 docker compose 镜像").action(updateDockerCompose);
4822
+ program.command("sync-cursor-ext-to-code").alias("sce2c").description("同步 cursor 扩展到 vscode").action(syncCursorExtToCode);
4823
+ program.command("create-prisma-debugger").alias("cpd").description("创建 prisma 调试器").action(createPrismaDebugger);
4824
+ program.command("verdaccio").description("同步 verdaccio 配置").action(verdaccio);
4824
4825
  program.parse();
4825
4826
 
4826
4827
  //# sourceMappingURL=index.js.map