zixulu 1.80.8 → 1.81.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/index.js +33 -41
  2. package/dist/index.js.map +1 -1
  3. package/dist/src/constant/index.d.ts +2 -11
  4. package/dist/src/utils/addPrisma.d.ts +1 -1
  5. package/dist/src/utils/getCommitMessage.d.ts +1 -1
  6. package/dist/src/utils/getFiles.d.ts +2 -2
  7. package/dist/src/utils/getPackageUpgradeVersion.d.ts +1 -1
  8. package/dist/src/utils/modifyJsonc.d.ts +1 -1
  9. package/dist/src/utils/readZixuluSetting.d.ts +1 -1
  10. package/dist/src/utils/removeOpenWith.d.ts +1 -1
  11. package/dist/src/utils/upgradeDependency.d.ts +1 -1
  12. package/dist/src/utils/writeBunConfig.d.ts +1 -1
  13. package/dist/src/utils/writeZixuluCache.d.ts +1 -1
  14. package/dist/src/utils/writeZixuluSetting.d.ts +1 -1
  15. package/package.json +6 -6
  16. package/src/constant/index.ts +2 -12
  17. package/src/index.ts +16 -16
  18. package/src/utils/addEslint.ts +3 -3
  19. package/src/utils/addHusky.ts +1 -1
  20. package/src/utils/addPathAlias.ts +2 -2
  21. package/src/utils/addPrettier.ts +3 -2
  22. package/src/utils/addPrisma.ts +1 -1
  23. package/src/utils/addRuleToGitIgnore.ts +1 -1
  24. package/src/utils/addRuleToPrettierIgnore.ts +1 -1
  25. package/src/utils/addStartScript.ts +1 -1
  26. package/src/utils/addSyncPackageScript.ts +1 -1
  27. package/src/utils/addTailwind.ts +21 -21
  28. package/src/utils/addZipDist.ts +1 -1
  29. package/src/utils/checkTailwind.ts +9 -9
  30. package/src/utils/checkType.ts +9 -9
  31. package/src/utils/clearDockerLog.ts +8 -8
  32. package/src/utils/download7Zip.ts +14 -14
  33. package/src/utils/downloadAnydesk.ts +14 -14
  34. package/src/utils/downloadChrome.ts +14 -14
  35. package/src/utils/downloadFirefox.ts +14 -14
  36. package/src/utils/downloadGit.ts +14 -14
  37. package/src/utils/downloadHoneyview.ts +9 -9
  38. package/src/utils/downloadNodeJS.ts +14 -14
  39. package/src/utils/downloadPeazip.ts +14 -14
  40. package/src/utils/downloadPotPlayer.ts +14 -14
  41. package/src/utils/downloadPowerToys.ts +14 -14
  42. package/src/utils/downloadVscode.ts +14 -14
  43. package/src/utils/getCommitMessage.ts +2 -2
  44. package/src/utils/getDependcy.ts +16 -16
  45. package/src/utils/getFiles.ts +2 -2
  46. package/src/utils/getPackageUpgradeVersion.ts +43 -43
  47. package/src/utils/getPackageVersionFromRange.ts +8 -8
  48. package/src/utils/getRelativePath.ts +11 -11
  49. package/src/utils/getUpgradeDependencyConfig.ts +1 -1
  50. package/src/utils/hasChangeNoCommit.ts +6 -6
  51. package/src/utils/isAsset.ts +26 -26
  52. package/src/utils/isShellProxy.ts +12 -12
  53. package/src/utils/isStableVersion.ts +3 -3
  54. package/src/utils/isUrl.ts +5 -5
  55. package/src/utils/modifyJsonc.ts +1 -1
  56. package/src/utils/next.ts +12 -12
  57. package/src/utils/readZixuluSetting.ts +1 -1
  58. package/src/utils/removeLock.ts +1 -1
  59. package/src/utils/removeOpenWith.ts +1 -1
  60. package/src/utils/replaceAssets.ts +1 -1
  61. package/src/utils/replaceCommitAuthor.ts +57 -57
  62. package/src/utils/rsbuild.ts +1 -1
  63. package/src/utils/setBun.ts +10 -10
  64. package/src/utils/setEnv.ts +24 -24
  65. package/src/utils/sleep.ts +3 -3
  66. package/src/utils/sortPackageJson.ts +16 -16
  67. package/src/utils/sudoCommand.ts +17 -17
  68. package/src/utils/syncAgentRules.ts +1 -1
  69. package/src/utils/syncEditorSetting.ts +1 -1
  70. package/src/utils/unique.ts +3 -3
  71. package/src/utils/upgradeDependency.ts +2 -2
  72. package/src/utils/upgradeRsbuild.ts +1 -1
  73. package/src/utils/upgradeTailwind.ts +1 -1
  74. package/src/utils/vite.ts +15 -15
  75. package/src/utils/writeBunConfig.ts +1 -1
  76. package/src/utils/writeZixuluCache.ts +1 -1
  77. package/src/utils/writeZixuluSetting.ts +1 -1
package/dist/index.js CHANGED
@@ -130,15 +130,6 @@ var constant_Software = /*#__PURE__*/ function(Software) {
130
130
  Software["PowerShell"] = "PowerShell";
131
131
  return Software;
132
132
  }({});
133
- const CommitTypeMap = {
134
- ["feature"]: "✨feature: ",
135
- ["fix"]: "🐞 fix: ",
136
- ["docs"]: "📄 docs: ",
137
- ["wip"]: "🖥️ wip: ",
138
- ["perfs"]: "🚅 perfs: ",
139
- ["rollback"]: "⏪ rollback: ",
140
- ["other"]: "🔵 other: "
141
- };
142
133
  const agent = await checkPort(7890, "127.0.0.1") ? void 0 : new HttpsProxyAgent("http://127.0.0.1:7890");
143
134
  const addedRules = [
144
135
  "package-lock.json",
@@ -669,11 +660,11 @@ export function useDelete${type}<TContext = never>({ onMutate, onSuccess, onErro
669
660
  if (items.includes("delete")) await addApi_writeFile(join(hook, `useDelete${type}.ts`), useDelete);
670
661
  }
671
662
  function getCommitMessage(type, message) {
672
- return `${CommitTypeMap[type]}${message}`;
663
+ return `${type}: ${message}`;
673
664
  }
674
665
  async function addRuleToGitIgnore(...rules) {
675
666
  const dir = await readdir(".");
676
- const message = getCommitMessage("feature", `添加 .gitignore 规则 ${rules.join(", ")}`);
667
+ const message = getCommitMessage("feat", `添加 .gitignore 规则 ${rules.join(", ")}`);
677
668
  if (!dir.includes(".gitignore")) {
678
669
  await writeFile(".gitignore", rules.join("\n"), "utf-8");
679
670
  return message;
@@ -1081,7 +1072,7 @@ async function installDependceny(config) {
1081
1072
  return true;
1082
1073
  }
1083
1074
  async function addEslint() {
1084
- await writeFile("eslint.config.mjs", `export { default } from "@1adybug/eslint"\n`);
1075
+ await writeFile("eslint.config.mjs", `// eslint-disable-next-line n/no-unpublished-import\nexport { default } from "@1adybug/eslint"\n`);
1085
1076
  const packages = [
1086
1077
  {
1087
1078
  packageName: "eslint",
@@ -1097,7 +1088,7 @@ async function addEslint() {
1097
1088
  await addScript({
1098
1089
  lint: "eslint ."
1099
1090
  });
1100
- return getCommitMessage("feature", "add eslint");
1091
+ return getCommitMessage("feat", "add eslint");
1101
1092
  }
1102
1093
  async function addGitAttributes() {
1103
1094
  await writeFile(".gitattributes", `# 将所有文本文件在提交到 Git 仓库时,自动转换为 LF 换行符
@@ -1308,7 +1299,7 @@ async function replacePathAlias() {
1308
1299
  });
1309
1300
  await writeFile(file, code, "utf-8");
1310
1301
  }
1311
- return getCommitMessage("feature", "replace path alias");
1302
+ return getCommitMessage("feat", "replace path alias");
1312
1303
  }
1313
1304
  async function addFolderPathAlias() {
1314
1305
  const { folder } = await inquirer_0.prompt({
@@ -1336,11 +1327,11 @@ async function addFolderPathAlias() {
1336
1327
  name: item,
1337
1328
  path: getRelativePath_getRelativePath(join(folder, item))
1338
1329
  })));
1339
- return getCommitMessage("feature", `add path alias: ${result.join(", ")}`);
1330
+ return getCommitMessage("feat", `add path alias: ${result.join(", ")}`);
1340
1331
  }
1341
1332
  async function addRuleToPrettierIgnore(...rules) {
1342
1333
  const dir = await readdir(".");
1343
- const message = getCommitMessage("feature", `添加 .prettierignore 规则 ${rules.join(", ")}`);
1334
+ const message = getCommitMessage("feat", `添加 .prettierignore 规则 ${rules.join(", ")}`);
1344
1335
  if (!dir.includes(".prettierignore")) {
1345
1336
  await writeFile(".prettierignore", rules.join("\n"), "utf-8");
1346
1337
  return message;
@@ -1379,6 +1370,7 @@ const config = {
1379
1370
  controlStatementBraces: "add",
1380
1371
  multiLineBraces: "add",
1381
1372
  nodeProtocol: "add",
1373
+ markTypeOnlyImports: true,
1382
1374
  }
1383
1375
 
1384
1376
  export default config
@@ -1398,7 +1390,7 @@ async function addPrettier() {
1398
1390
  const packageJson2 = await readPackageJson();
1399
1391
  packageJson2.scripts ??= {};
1400
1392
  packageJson2.scripts.format = "prettier --write .";
1401
- packageJson2.scripts.fg = 'npm run format && git add . && git commit -m "✨feature: format"';
1393
+ packageJson2.scripts.fg = 'npm run format && git add . && git commit -m "feat: format"';
1402
1394
  await writePackageJson({
1403
1395
  data: packageJson2
1404
1396
  });
@@ -1635,7 +1627,7 @@ async function addStartScript({ type, pemPath, port, core, hostname }) {
1635
1627
  });
1636
1628
  consola.success("已添加启动命令 start");
1637
1629
  await installDependceny();
1638
- return getCommitMessage("feature", "添加启动命令");
1630
+ return getCommitMessage("feat", "添加启动命令");
1639
1631
  }
1640
1632
  async function addSyncPackageScript({ monorepo } = {}) {
1641
1633
  let dir;
@@ -1725,7 +1717,7 @@ main()
1725
1717
  await writePackageJson({
1726
1718
  data: packageJson
1727
1719
  });
1728
- return getCommitMessage("feature", "添加同步包脚本");
1720
+ return getCommitMessage("feat", "添加同步包脚本");
1729
1721
  }
1730
1722
  const regexPlaceholders = [
1731
1723
  {
@@ -2565,7 +2557,7 @@ async function addZipDist({ install } = {}) {
2565
2557
  data: packageJson
2566
2558
  });
2567
2559
  if (install) await installDependceny();
2568
- return getCommitMessage("feature", "添加压缩脚本");
2560
+ return getCommitMessage("feat", "添加压缩脚本");
2569
2561
  }
2570
2562
  function getTypeInGenerics(str, start = 0) {
2571
2563
  if ("<" !== str[start]) throw new Error("无效的泛型");
@@ -3969,7 +3961,7 @@ async function removeLock() {
3969
3961
  recursive: true
3970
3962
  });
3971
3963
  await addRuleToGitIgnore("package-lock.json", "yarn.lock", "pnpm-lock.yaml", "bun.lockb", "bun.lock");
3972
- return getCommitMessage("feature", "删除包管理 lock 文件");
3964
+ return getCommitMessage("feat", "删除包管理 lock 文件");
3973
3965
  }
3974
3966
  async function removeTag({ reg, flags, push, remote = "origin" }) {
3975
3967
  const git = simpleGit();
@@ -4908,7 +4900,7 @@ async function asyncAgentRules() {
4908
4900
  });
4909
4901
  if (0 === selectedFiles.length) throw new Error("未选择 Agent 规则");
4910
4902
  await syncAgentsMdRules(rules.filter((rule)=>selectedFiles.includes(rule.filename)));
4911
- return getCommitMessage("feature", "同步 Agent 规则");
4903
+ return getCommitMessage("feat", "同步 Agent 规则");
4912
4904
  } finally{
4913
4905
  await rm(syncAgentRules_source, {
4914
4906
  recursive: true,
@@ -5338,7 +5330,7 @@ async function syncEditorSetting() {
5338
5330
  });
5339
5331
  if (await hasChangeNoCommit(onlinePath)) {
5340
5332
  await addGitCommit({
5341
- message: getCommitMessage("feature", "sync editor setting"),
5333
+ message: getCommitMessage("feat", "sync editor setting"),
5342
5334
  cwd: onlinePath
5343
5335
  });
5344
5336
  await execAsync("git push", {
@@ -5818,7 +5810,7 @@ async function upgradeDependency(config) {
5818
5810
  dir
5819
5811
  });
5820
5812
  await installDependceny();
5821
- return getCommitMessage("feature", `upgrade dependencies: ${upgradeLogs.join(", ")}`);
5813
+ return getCommitMessage("feat", `upgrade dependencies: ${upgradeLogs.join(", ")}`);
5822
5814
  }
5823
5815
  async function getPackageLatestVersion(packageName) {
5824
5816
  const registry = await getRegistry();
@@ -5852,7 +5844,7 @@ async function upgradeRsbuild() {
5852
5844
  await installDependceny();
5853
5845
  const upgradeLog = `upgrade dependencies: ${upgradeLogs.join(", ")}`;
5854
5846
  consola.success(upgradeLog);
5855
- return getCommitMessage("feature", upgradeLog);
5847
+ return getCommitMessage("feat", upgradeLog);
5856
5848
  }
5857
5849
  async function upgradeTailwind() {
5858
5850
  const version = await getPackageVersionInDependcy("tailwindcss");
@@ -5875,7 +5867,7 @@ async function upgradeTailwind() {
5875
5867
  await installDependceny();
5876
5868
  const upgradeLog = `upgrade dependencies: tailwindcss ${version} => ${newVersion}`;
5877
5869
  consola.success(upgradeLog);
5878
- return getCommitMessage("feature", upgradeLog);
5870
+ return getCommitMessage("feat", upgradeLog);
5879
5871
  }
5880
5872
  async function upgradeWorkspaceDependceny() {
5881
5873
  const { dir, ...rest } = await getUpgradeDependencyConfig();
@@ -6372,15 +6364,15 @@ const program = new Command();
6372
6364
  const src_pkg = readPackageJsonSync("win32" === process.platform ? import.meta.resolve("../").replace(/^file:\/\/\//, "") : import.meta.resolve("../").replace(/^file:\/\//, ""));
6373
6365
  program.name("格数科技").version(src_pkg.version);
6374
6366
  console.log(chalk.redBright.bold(`zixulu ${src_pkg.version}`));
6375
- program.command("eslint").description("添加 ESLint 相关配置").action(actionWithBackup(addEslint, getCommitMessage("feature", "添加 ESLint 相关配置")));
6376
- program.command("prettier").description("添加 prettier 配置").action(actionWithBackup(addPrettier, getCommitMessage("feature", "添加 prettier 配置文件")));
6377
- program.command("husky").description("添加 husky 配置").action(actionWithBackup(addHusky, getCommitMessage("feature", "添加 husky 配置")));
6378
- program.command("vite").description("初始化 vite 配置").action(actionWithBackup(vite, getCommitMessage("feature", "初始化 vite 配置")));
6379
- program.command("rsbuild").description("初始化 rsbuild 配置").action(actionWithBackup(rsbuild, getCommitMessage("feature", "初始化 rsbuild 配置")));
6380
- program.command("next").description("初始化 next 配置").action(actionWithBackup(next_next, getCommitMessage("feature", "初始化 next 配置")));
6381
- program.command("tailwind").description("添加 tailwind 配置").action(actionWithBackup(addTailwind, getCommitMessage("feature", "添加 tailwind 配置")));
6382
- program.command("remove-comment").description("删除文件注释").argument("path", "文件路径").action(actionWithBackup(removeComment, getCommitMessage("feature", "删除文件注释")));
6383
- program.command("father").alias("fs").description("初始化 father 项目配置").action(actionWithBackup(setFatherConfig, getCommitMessage("feature", "初始化 father 项目配置")));
6367
+ program.command("eslint").description("添加 ESLint 相关配置").action(actionWithBackup(addEslint, getCommitMessage("feat", "添加 ESLint 相关配置")));
6368
+ program.command("prettier").description("添加 prettier 配置").action(actionWithBackup(addPrettier, getCommitMessage("feat", "添加 prettier 配置文件")));
6369
+ program.command("husky").description("添加 husky 配置").action(actionWithBackup(addHusky, getCommitMessage("feat", "添加 husky 配置")));
6370
+ program.command("vite").description("初始化 vite 配置").action(actionWithBackup(vite, getCommitMessage("feat", "初始化 vite 配置")));
6371
+ program.command("rsbuild").description("初始化 rsbuild 配置").action(actionWithBackup(rsbuild, getCommitMessage("feat", "初始化 rsbuild 配置")));
6372
+ program.command("next").description("初始化 next 配置").action(actionWithBackup(next_next, getCommitMessage("feat", "初始化 next 配置")));
6373
+ program.command("tailwind").description("添加 tailwind 配置").action(actionWithBackup(addTailwind, getCommitMessage("feat", "添加 tailwind 配置")));
6374
+ program.command("remove-comment").description("删除文件注释").argument("path", "文件路径").action(actionWithBackup(removeComment, getCommitMessage("feat", "删除文件注释")));
6375
+ program.command("father").alias("fs").description("初始化 father 项目配置").action(actionWithBackup(setFatherConfig, getCommitMessage("feat", "初始化 father 项目配置")));
6384
6376
  program.command("upgrade-dependency").alias("ud").description("升级项目依赖").option("-r, --registry <registry>", "npm 源地址,可以是 npm、taobao、tencent 或者自定义地址").option("-p, --proxy", "是否使用代理").action(async (optios)=>{
6385
6377
  setGlobalConfig(optios);
6386
6378
  await actionWithBackup(()=>upgradeDependency())();
@@ -6390,9 +6382,9 @@ program.command("upgrade-workspace-dependency").alias("uwd").description("升级
6390
6382
  await upgradeWorkspaceDependceny();
6391
6383
  });
6392
6384
  program.command("registry").description("设置 npm registry").action(setRegistry);
6393
- program.command("sort-package-json").alias("spj").description("对 package.json 中的依赖进行排序").action(actionWithBackup(sortPackageJson, getCommitMessage("feature", "对 package.json 中的依赖进行排序")));
6394
- program.command("arrow-to-function").alias("a2f").description("将箭头函数组件转换为函数组件").action(actionWithBackup(arrowToFunction, getCommitMessage("feature", "将箭头函数组件转换为函数组件")));
6395
- program.command("interface-to-type").alias("i2t").description("将 interface 转换为 type").action(actionWithBackup(interfaceToType, getCommitMessage("feature", "将 interface 转换为 type")));
6385
+ program.command("sort-package-json").alias("spj").description("对 package.json 中的依赖进行排序").action(actionWithBackup(sortPackageJson, getCommitMessage("feat", "对 package.json 中的依赖进行排序")));
6386
+ program.command("arrow-to-function").alias("a2f").description("将箭头函数组件转换为函数组件").action(actionWithBackup(arrowToFunction, getCommitMessage("feat", "将箭头函数组件转换为函数组件")));
6387
+ program.command("interface-to-type").alias("i2t").description("将 interface 转换为 type").action(actionWithBackup(interfaceToType, getCommitMessage("feat", "将 interface 转换为 type")));
6396
6388
  program.command("gitignore").description("添加 .gitignore 配置").action(actionWithBackup(addGitignore));
6397
6389
  program.command("git-proxy").alias("gp").description("设置 git 代理").action(setGitProxy);
6398
6390
  program.command("shell-proxy").alias("sp").description("设置 Shell 代理").action(setShellProxy);
@@ -6401,10 +6393,10 @@ program.command("vscode").alias("vsc").description("同步 VS Code 配置").acti
6401
6393
  program.command("kill-port").description("根据端口号杀死进程").argument("port", "端口号").action(killProcessByPort);
6402
6394
  program.command("rm-git").argument("path", "要移除的文件或文件夹").action(removeFileOrFolderFromGit);
6403
6395
  program.command("npm-download").alias("nd").description("下载 npm 包").argument("name", "包名").action(downloadNpm);
6404
- program.command("prisma").description("添加 prisma 配置").action(actionWithBackup(()=>addPrisma(), getCommitMessage("feature", "添加 prisma 配置")));
6396
+ program.command("prisma").description("添加 prisma 配置").action(actionWithBackup(()=>addPrisma(), getCommitMessage("feat", "添加 prisma 配置")));
6405
6397
  program.command("prisma-generate").alias("pg").description("生成 prisma client").action(generatePrisma);
6406
- program.command("antd").description("添加 antd 配置").action(actionWithBackup(addAntd, getCommitMessage("feature", "添加 antd 配置")));
6407
- program.command("init").description("初始化项目").action(actionWithBackup(initProject, getCommitMessage("feature", "初始化项目")));
6398
+ program.command("antd").description("添加 antd 配置").action(actionWithBackup(addAntd, getCommitMessage("feat", "添加 antd 配置")));
6399
+ program.command("init").description("初始化项目").action(actionWithBackup(initProject, getCommitMessage("feat", "初始化项目")));
6408
6400
  program.command("tsc").description("类型检查").action(checkType);
6409
6401
  program.command("beta-version").alias("bv").description("设置版本号").action(betaVersion);
6410
6402
  program.command("reinstall").alias("ri").description("重新安装依赖").option("-r, --registry <registry>", "npm 源地址,可以是 npm、taobao、tencent 或者自定义地址").action(async (options)=>{