@coze-arch/cli 0.0.1-alpha.e665f4 → 0.0.1-alpha.e70f72

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 (97) hide show
  1. package/README.md +1 -0
  2. package/lib/__templates__/expo/.cozeproj/scripts/server_dev_run.sh +1 -1
  3. package/lib/__templates__/expo/client/components/Screen.tsx +2 -2
  4. package/lib/__templates__/expo/client/eslint.config.mjs +4 -0
  5. package/lib/__templates__/expo/client/metro.config.js +3 -0
  6. package/lib/__templates__/expo/client/package.json +35 -35
  7. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +10 -10
  8. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/index.js +9 -0
  9. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/rule.js +112 -0
  10. package/lib/__templates__/expo/eslint-plugins/forbid-emoji/tech.md +94 -0
  11. package/lib/__templates__/expo/package.json +1 -1
  12. package/lib/__templates__/expo/pnpm-lock.yaml +394 -221
  13. package/lib/__templates__/expo/server/package.json +9 -7
  14. package/lib/__templates__/expo/server/src/index.ts +1 -0
  15. package/lib/__templates__/expo/template.config.js +1 -1
  16. package/lib/__templates__/native-static/.coze +11 -0
  17. package/lib/__templates__/native-static/index.html +33 -0
  18. package/lib/__templates__/native-static/styles/main.css +136 -0
  19. package/lib/__templates__/native-static/template.config.js +22 -0
  20. package/lib/__templates__/nextjs/README.md +5 -0
  21. package/lib/__templates__/nextjs/eslint.config.mjs +5 -0
  22. package/lib/__templates__/nextjs/next.config.ts +1 -2
  23. package/lib/__templates__/nextjs/package.json +5 -6
  24. package/lib/__templates__/nextjs/pnpm-lock.yaml +1145 -109
  25. package/lib/__templates__/nextjs/scripts/build.sh +4 -1
  26. package/lib/__templates__/nextjs/scripts/dev.sh +4 -4
  27. package/lib/__templates__/nextjs/scripts/start.sh +1 -1
  28. package/lib/__templates__/nextjs/src/app/layout.tsx +1 -1
  29. package/lib/__templates__/nextjs/src/app/page.tsx +4 -3
  30. package/lib/__templates__/nextjs/src/server.ts +35 -0
  31. package/lib/__templates__/nextjs/tsconfig.json +1 -1
  32. package/lib/__templates__/nuxt-vue/.coze +12 -0
  33. package/lib/__templates__/nuxt-vue/README.md +73 -0
  34. package/lib/__templates__/nuxt-vue/_gitignore +24 -0
  35. package/lib/__templates__/nuxt-vue/_npmrc +23 -0
  36. package/lib/__templates__/nuxt-vue/app/app.vue +6 -0
  37. package/lib/__templates__/nuxt-vue/app/pages/index.vue +23 -0
  38. package/lib/__templates__/nuxt-vue/assets/css/main.css +24 -0
  39. package/lib/__templates__/nuxt-vue/nuxt.config.ts +116 -0
  40. package/lib/__templates__/nuxt-vue/package.json +35 -0
  41. package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +8759 -0
  42. package/lib/__templates__/nuxt-vue/postcss.config.mjs +8 -0
  43. package/lib/__templates__/nuxt-vue/public/favicon.ico +0 -0
  44. package/lib/__templates__/nuxt-vue/public/robots.txt +2 -0
  45. package/lib/__templates__/nuxt-vue/scripts/build.sh +14 -0
  46. package/lib/__templates__/nuxt-vue/scripts/dev.sh +32 -0
  47. package/lib/__templates__/nuxt-vue/scripts/prepare.sh +14 -0
  48. package/lib/__templates__/nuxt-vue/scripts/start.sh +15 -0
  49. package/lib/__templates__/nuxt-vue/server/api/hello.ts +10 -0
  50. package/lib/__templates__/nuxt-vue/server/middleware/logger.ts +10 -0
  51. package/lib/__templates__/nuxt-vue/server/routes/health.ts +10 -0
  52. package/lib/__templates__/nuxt-vue/tailwind.config.js +13 -0
  53. package/lib/__templates__/nuxt-vue/template.config.js +87 -0
  54. package/lib/__templates__/nuxt-vue/tsconfig.json +18 -0
  55. package/lib/__templates__/taro/.cozeproj/scripts/deploy_build.sh +2 -2
  56. package/lib/__templates__/taro/.cozeproj/scripts/deploy_run.sh +4 -3
  57. package/lib/__templates__/taro/.cozeproj/scripts/dev_build.sh +0 -15
  58. package/lib/__templates__/taro/.cozeproj/scripts/dev_run.sh +117 -24
  59. package/lib/__templates__/taro/.cozeproj/scripts/pack.sh +24 -1
  60. package/lib/__templates__/taro/README.md +81 -17
  61. package/lib/__templates__/taro/config/index.ts +87 -37
  62. package/lib/__templates__/taro/config/prod.ts +4 -5
  63. package/lib/__templates__/taro/eslint.config.mjs +27 -4
  64. package/lib/__templates__/taro/package.json +16 -4
  65. package/lib/__templates__/taro/patches/@tarojs__plugin-mini-ci@4.1.9.patch +30 -0
  66. package/lib/__templates__/taro/pnpm-lock.yaml +785 -115
  67. package/lib/__templates__/taro/server/package.json +3 -1
  68. package/lib/__templates__/taro/server/src/main.ts +14 -2
  69. package/lib/__templates__/taro/src/app.css +18 -18
  70. package/lib/__templates__/taro/src/app.tsx +9 -0
  71. package/lib/__templates__/taro/src/index.html +20 -1
  72. package/lib/__templates__/taro/src/presets/dev-debug.ts +23 -0
  73. package/lib/__templates__/taro/src/presets/h5-container.tsx +15 -0
  74. package/lib/__templates__/taro/src/presets/h5-navbar.tsx +201 -0
  75. package/lib/__templates__/taro/src/presets/h5-styles.ts +142 -0
  76. package/lib/__templates__/taro/src/presets/index.tsx +18 -0
  77. package/lib/__templates__/templates.json +43 -0
  78. package/lib/__templates__/vite/README.md +190 -11
  79. package/lib/__templates__/vite/_gitignore +1 -0
  80. package/lib/__templates__/vite/eslint.config.mjs +6 -1
  81. package/lib/__templates__/vite/package.json +14 -3
  82. package/lib/__templates__/vite/pnpm-lock.yaml +820 -1593
  83. package/lib/__templates__/vite/scripts/build.sh +4 -1
  84. package/lib/__templates__/vite/scripts/dev.sh +5 -4
  85. package/lib/__templates__/vite/scripts/start.sh +3 -3
  86. package/lib/__templates__/vite/server/routes/index.ts +31 -0
  87. package/lib/__templates__/vite/server/server.ts +55 -0
  88. package/lib/__templates__/vite/server/vite.ts +71 -0
  89. package/lib/__templates__/vite/src/main.ts +2 -2
  90. package/lib/__templates__/vite/tsconfig.json +4 -3
  91. package/lib/__templates__/vite/vite.config.ts +1 -0
  92. package/lib/cli.js +123 -156
  93. package/package.json +7 -3
  94. package/lib/__templates__/taro/src/app.ts +0 -14
  95. package/lib/__templates__/taro/src/utils/h5-styles.ts +0 -22
  96. package/lib/__templates__/taro/src/utils/wx-debug.ts +0 -23
  97. /package/lib/__templates__/expo/patches/{expo@54.0.32.patch → expo@54.0.33.patch} +0 -0
package/lib/cli.js CHANGED
@@ -4,6 +4,8 @@
4
4
  var commander = require('commander');
5
5
  var path = require('path');
6
6
  var fs = require('fs');
7
+ var node_path = require('node:path');
8
+ var node_fs = require('node:fs');
7
9
  var shelljs = require('shelljs');
8
10
  var perf_hooks = require('perf_hooks');
9
11
  var fs$1 = require('fs/promises');
@@ -481,6 +483,14 @@ const warmupTemplate = (templatePath, templateName) => {
481
483
  logger.info(`\nWarming up template: ${templateName}`);
482
484
  logger.info(` Path: ${templatePath}`);
483
485
 
486
+ // 检查是否存在 package.json
487
+ const packageJsonPath = node_path.join(templatePath, 'package.json');
488
+ // eslint-disable-next-line security/detect-non-literal-fs-filename
489
+ if (!node_fs.existsSync(packageJsonPath)) {
490
+ logger.info(` ⊘ Skipping ${templateName} (no package.json found)`);
491
+ return;
492
+ }
493
+
484
494
  const result = shelljs.exec('pnpm install', {
485
495
  cwd: templatePath,
486
496
  silent: true,
@@ -514,13 +524,7 @@ const warmupTemplate = (templatePath, templateName) => {
514
524
  /**
515
525
  * 执行 warmup 命令的内部实现
516
526
  */
517
- const executeWarmup = async (
518
- options
519
-
520
- ,
521
-
522
- command,
523
- ) => {
527
+ const executeWarmup = async (options) => {
524
528
  const timer = new TimeTracker();
525
529
 
526
530
  try {
@@ -590,7 +594,7 @@ const registerCommand$4 = program => {
590
594
  .command('warmup')
591
595
  .description('Pre-install dependencies for templates to speed up init')
592
596
  .option('-t, --template <name>', 'Warmup a specific template only')
593
- .action(async (options, command) => {
597
+ .action(async options => {
594
598
  await executeWarmup(options);
595
599
  });
596
600
  };
@@ -1511,46 +1515,6 @@ const convertDotfileName = (filePath) => {
1511
1515
 
1512
1516
  return filePath;
1513
1517
  };
1514
-
1515
- /**
1516
- * 复制 node_modules 目录(如果存在)
1517
- *
1518
- * @param sourceNodeModules - 源 node_modules 路径
1519
- * @param targetNodeModules - 目标 node_modules 路径
1520
- */
1521
- const copyNodeModules = (
1522
- sourceNodeModules,
1523
- targetNodeModules,
1524
- ) => {
1525
- if (!fs.existsSync(sourceNodeModules)) {
1526
- return;
1527
- }
1528
-
1529
- logger.info('\nCopying node_modules from pre-warmed template...');
1530
- logger.verbose(` From: ${sourceNodeModules}`);
1531
- logger.verbose(` To: ${targetNodeModules}`);
1532
-
1533
- const result = shelljs.exec(`cp -R "${sourceNodeModules}" "${targetNodeModules}"`, {
1534
- silent: true,
1535
- });
1536
-
1537
- if (result.stdout) {
1538
- process.stdout.write(result.stdout);
1539
- }
1540
-
1541
- if (result.stderr) {
1542
- process.stderr.write(result.stderr);
1543
- }
1544
-
1545
- if (result.code === 0) {
1546
- logger.success('✓ node_modules copied successfully');
1547
- } else {
1548
- logger.warn(
1549
- `Failed to copy node_modules: ${result.stderr || 'unknown error'}`,
1550
- );
1551
- logger.info('Will need to run pnpm install manually');
1552
- }
1553
- };
1554
1518
  // end_aigc
1555
1519
 
1556
1520
  // ABOUTME: File rendering utilities for template processing
@@ -1758,38 +1722,6 @@ const collectFilesToRender = async (options
1758
1722
 
1759
1723
  return filesToWrite;
1760
1724
  };
1761
-
1762
- /**
1763
- * 检测文件冲突
1764
- *
1765
- * @param outputPath - 输出目录路径
1766
- * @param filesToWrite - 将要写入的文件路径列表
1767
- * @returns 冲突的文件路径列表
1768
- */
1769
- const detectFileConflicts = (
1770
- outputPath,
1771
- filesToWrite,
1772
- ) => {
1773
- logger.verbose('\nChecking for file conflicts...');
1774
-
1775
- const conflicts = [];
1776
-
1777
- for (const file of filesToWrite) {
1778
- const fullPath = path.join(outputPath, file);
1779
- if (fs.existsSync(fullPath)) {
1780
- conflicts.push(file);
1781
- logger.verbose(` ⚠ Conflict detected: ${file}`);
1782
- }
1783
- }
1784
-
1785
- if (conflicts.length === 0) {
1786
- logger.verbose(' ✓ No conflicts detected');
1787
- } else {
1788
- logger.verbose(` ⚠ ${conflicts.length} conflicts detected`);
1789
- }
1790
-
1791
- return conflicts;
1792
- };
1793
1725
  // end_aigc
1794
1726
 
1795
1727
  // ABOUTME: Main file processing orchestration for template rendering
@@ -1845,7 +1777,7 @@ const processSingleFile = async (options
1845
1777
  * 1. 验证模板目录
1846
1778
  * 2. 扫描所有模板文件
1847
1779
  * 3. Dry-run:收集将要写入的文件列表(考虑 hooks 影响)
1848
- * 4. 冲突检测:检查是否有文件会被覆盖
1780
+ * 4. 冲突检测:检查是否有文件会被覆盖(可通过 force 跳过)
1849
1781
  * 5. 实际写入:渲染并写入所有文件
1850
1782
  * 6. 复制 node_modules(如果存在)
1851
1783
  *
@@ -1856,8 +1788,9 @@ const processTemplateFiles = async (options
1856
1788
 
1857
1789
 
1858
1790
 
1791
+
1859
1792
  ) => {
1860
- const { templatePath, outputPath, context, templateConfig } = options;
1793
+ const { templatePath, outputPath, context, templateConfig} = options;
1861
1794
  logger.verbose('Processing template files:');
1862
1795
  logger.verbose(` - Template path: ${templatePath}`);
1863
1796
  logger.verbose(` - Output path: ${outputPath}`);
@@ -1889,23 +1822,17 @@ const processTemplateFiles = async (options
1889
1822
  }
1890
1823
 
1891
1824
  // 阶段 2: Dry-run - 收集所有将要写入的文件
1892
- const filesToWrite = await collectFilesToRender({
1825
+ await collectFilesToRender({
1893
1826
  files,
1894
1827
  templatePath,
1895
1828
  context,
1896
1829
  templateConfig,
1897
1830
  });
1898
1831
 
1899
- // 阶段 3: 冲突检测
1900
- const conflicts = detectFileConflicts(outputPath, filesToWrite);
1901
-
1902
- if (conflicts.length > 0) {
1903
- // 有冲突,抛出详细的错误信息
1904
- const conflictList = conflicts.map(f => ` - ${f}`).join('\n');
1905
- throw new Error(
1906
- `File conflicts detected in output directory: ${outputPath}\n\n` +
1907
- `The following files already exist and would be overwritten:\n${conflictList}\n\n` +
1908
- 'Please remove these files or use a different output directory.',
1832
+ // 阶段 3: 冲突检测(force 为 true 时跳过)
1833
+ {
1834
+ logger.verbose(
1835
+ ' - Force mode enabled, skipping conflict detection. Existing files will be overwritten.',
1909
1836
  );
1910
1837
  }
1911
1838
 
@@ -1925,11 +1852,7 @@ const processTemplateFiles = async (options
1925
1852
 
1926
1853
  logger.verbose('✓ All files processed successfully');
1927
1854
 
1928
- // 阶段 5: 单独处理 node_modules 目录(如果存在)
1929
- const sourceNodeModules = path.join(templatePath, 'node_modules');
1930
- const targetNodeModules = path.join(outputPath, 'node_modules');
1931
-
1932
- copyNodeModules(sourceNodeModules, targetNodeModules);
1855
+ // node_modules 将由 pnpm install 处理(利用缓存和硬链接机制)
1933
1856
  };
1934
1857
  // end_aigc
1935
1858
 
@@ -1942,6 +1865,7 @@ const processTemplateFiles = async (options
1942
1865
 
1943
1866
 
1944
1867
 
1868
+
1945
1869
  /**
1946
1870
  * 加载模板元数据和路径
1947
1871
  */
@@ -2051,7 +1975,7 @@ const prepareOutputDirectory = (outputPath) => {
2051
1975
  const execute = async (
2052
1976
  options,
2053
1977
  ) => {
2054
- const { templateName, outputPath, command } = options;
1978
+ const { templateName, outputPath, command} = options;
2055
1979
 
2056
1980
  // 1. 加载模板
2057
1981
  const { templatePath } = await loadTemplateMetadata(templateName);
@@ -2075,8 +1999,7 @@ const execute = async (
2075
1999
  templatePath,
2076
2000
  outputPath: absoluteOutputPath,
2077
2001
  context,
2078
- templateConfig,
2079
- });
2002
+ templateConfig});
2080
2003
 
2081
2004
  // 7. 执行 onAfterRender 钩子
2082
2005
  await executeAfterRenderHook(templateConfig, context, absoluteOutputPath);
@@ -2127,7 +2050,40 @@ const runPnpmInstall = (projectPath) => {
2127
2050
  };
2128
2051
 
2129
2052
  /**
2130
- * 初始化 git 仓库并创建初始提交
2053
+ * 运行 git 命令的辅助函数
2054
+ */
2055
+ const runGitCommand = (command, projectPath) => {
2056
+ logger.info(`Executing: ${command}`);
2057
+
2058
+ const result = shelljs.exec(command, {
2059
+ cwd: projectPath,
2060
+ silent: true,
2061
+ });
2062
+
2063
+ // 输出命令的结果
2064
+ if (result.stdout) {
2065
+ process.stdout.write(result.stdout);
2066
+ }
2067
+
2068
+ if (result.stderr) {
2069
+ process.stderr.write(result.stderr);
2070
+ }
2071
+
2072
+ if (result.code !== 0) {
2073
+ const errorMessage = [
2074
+ `${command} failed with exit code ${result.code}`,
2075
+ result.stderr ? `\nStderr:\n${result.stderr}` : '',
2076
+ result.stdout ? `\nStdout:\n${result.stdout}` : '',
2077
+ ]
2078
+ .filter(Boolean)
2079
+ .join('');
2080
+
2081
+ throw new Error(errorMessage);
2082
+ }
2083
+ };
2084
+
2085
+ /**
2086
+ * 初始化 git 仓库
2131
2087
  * 如果目录中已存在 .git,则跳过初始化
2132
2088
  */
2133
2089
  const runGitInit = (projectPath) => {
@@ -2140,46 +2096,9 @@ const runGitInit = (projectPath) => {
2140
2096
  return;
2141
2097
  }
2142
2098
 
2143
- const runGitCommand = (command) => {
2144
- logger.info(`Executing: ${command}`);
2145
-
2146
- const result = shelljs.exec(command, {
2147
- cwd: projectPath,
2148
- silent: true,
2149
- });
2150
-
2151
- // 输出命令的结果
2152
- if (result.stdout) {
2153
- process.stdout.write(result.stdout);
2154
- }
2155
-
2156
- if (result.stderr) {
2157
- process.stderr.write(result.stderr);
2158
- }
2159
-
2160
- if (result.code !== 0) {
2161
- const errorMessage = [
2162
- `${command} failed with exit code ${result.code}`,
2163
- result.stderr ? `\nStderr:\n${result.stderr}` : '',
2164
- result.stdout ? `\nStdout:\n${result.stdout}` : '',
2165
- ]
2166
- .filter(Boolean)
2167
- .join('');
2168
-
2169
- throw new Error(errorMessage);
2170
- }
2171
- };
2172
-
2173
2099
  try {
2174
2100
  logger.info('\nInitializing git repository...');
2175
- runGitCommand('git init');
2176
-
2177
- logger.info('Adding files to git...');
2178
- runGitCommand('git add .');
2179
-
2180
- logger.info('Creating initial commit...');
2181
- runGitCommand('git commit -m "chore: initial commit"');
2182
-
2101
+ runGitCommand('git init', projectPath);
2183
2102
  logger.success('Git repository initialized successfully!');
2184
2103
  } catch (error) {
2185
2104
  // Git 初始化失败不应该导致整个流程失败
@@ -2190,6 +2109,35 @@ const runGitInit = (projectPath) => {
2190
2109
  }
2191
2110
  };
2192
2111
 
2112
+ /**
2113
+ * 提交初始化生成的所有文件
2114
+ */
2115
+ const commitChanges = (projectPath) => {
2116
+ // 检查是否存在 .git 目录
2117
+ const gitDir = path.join(projectPath, '.git');
2118
+ if (!fs.existsSync(gitDir)) {
2119
+ logger.warn(
2120
+ '\n⚠️ Git repository does not exist, skipping commit. Run git init first.',
2121
+ );
2122
+ return;
2123
+ }
2124
+
2125
+ try {
2126
+ logger.info('\nCommitting initialized files...');
2127
+ runGitCommand('git add --all', projectPath);
2128
+ runGitCommand('git commit -m "chore: init env"', projectPath);
2129
+ logger.success('Changes committed successfully!');
2130
+ } catch (error) {
2131
+ // Commit 失败不应该导致整个流程失败
2132
+ logger.warn(
2133
+ `Git commit failed: ${error instanceof Error ? error.message : String(error)}`,
2134
+ );
2135
+ logger.info(
2136
+ 'You can manually commit later with: git add --all && git commit -m "chore: init env"',
2137
+ );
2138
+ }
2139
+ };
2140
+
2193
2141
  /**
2194
2142
  * 运行开发服务器(后台模式)
2195
2143
  * 启动后台子进程运行开发服务器,父进程可以直接退出
@@ -2231,6 +2179,8 @@ const executeInit = async (
2231
2179
 
2232
2180
 
2233
2181
 
2182
+
2183
+
2234
2184
  ,
2235
2185
  command,
2236
2186
  ) => {
@@ -2242,7 +2192,9 @@ const executeInit = async (
2242
2192
  output: outputPath,
2243
2193
  skipInstall,
2244
2194
  skipGit,
2195
+ skipCommit,
2245
2196
  skipDev,
2197
+ force,
2246
2198
  } = options;
2247
2199
 
2248
2200
  logger.info(`Initializing project with template: ${templateName}`);
@@ -2253,25 +2205,26 @@ const executeInit = async (
2253
2205
  templateName,
2254
2206
  outputPath,
2255
2207
  command,
2208
+ force,
2256
2209
  });
2257
2210
  const { outputPath: absoluteOutputPath, templateConfig, context } = result;
2258
2211
 
2259
2212
  timer.logPhase('Template engine execution');
2260
2213
  logger.success('Project created successfully!');
2261
2214
 
2262
- // 如果没有跳过安装,检查是否需要运行 pnpm install
2263
- if (!skipInstall) {
2264
- const nodeModulesPath = path.join(absoluteOutputPath, 'node_modules');
2265
- const hasNodeModules = fs.existsSync(nodeModulesPath);
2215
+ // 检查是否存在 package.json
2216
+ const packageJsonPath = path.join(absoluteOutputPath, 'package.json');
2217
+ const hasPackageJson = fs.existsSync(packageJsonPath);
2266
2218
 
2267
- if (hasNodeModules) {
2268
- logger.info(
2269
- '\n💡 Using pre-warmed node_modules, skipping pnpm install',
2270
- );
2271
- timer.logPhase('Node modules (pre-warmed)');
2272
- } else {
2219
+ // 安装依赖(始终使用 pnpm install,利用缓存机制)
2220
+ if (!skipInstall) {
2221
+ if (hasPackageJson) {
2273
2222
  runPnpmInstall(absoluteOutputPath);
2274
2223
  timer.logPhase('Dependencies installation');
2224
+ } else {
2225
+ logger.info(
2226
+ '\n💡 No package.json found, skipping dependency installation',
2227
+ );
2275
2228
  }
2276
2229
  }
2277
2230
 
@@ -2285,6 +2238,12 @@ const executeInit = async (
2285
2238
  timer.logPhase('Git initialization');
2286
2239
  }
2287
2240
 
2241
+ // 如果没有跳过 commit,则提交初始化生成的文件
2242
+ if (!skipCommit) {
2243
+ commitChanges(absoluteOutputPath);
2244
+ timer.logPhase('Git commit');
2245
+ }
2246
+
2288
2247
  // 如果没有跳过 dev,则启动开发服务器
2289
2248
  if (!skipDev) {
2290
2249
  runDev(absoluteOutputPath);
@@ -2293,13 +2252,14 @@ const executeInit = async (
2293
2252
  // 只有跳过 dev 时才显示 Next steps
2294
2253
  logger.info('\nNext steps:');
2295
2254
  logger.info(` cd ${outputPath}`);
2296
- if (skipInstall) {
2255
+ if (skipInstall && hasPackageJson) {
2297
2256
  logger.info(' pnpm install');
2298
2257
  }
2299
2258
  if (skipGit) {
2300
- logger.info(
2301
- ' git init && git add . && git commit -m "initial commit"',
2302
- );
2259
+ logger.info(' git init');
2260
+ }
2261
+ if (skipCommit) {
2262
+ logger.info(' git add --all && git commit -m "chore: init env"');
2303
2263
  }
2304
2264
  logger.info(' coze dev');
2305
2265
  }
@@ -2326,12 +2286,19 @@ const registerCommand$1 = program => {
2326
2286
  .option('-o, --output <path>', 'Output directory', process.cwd())
2327
2287
  .option('--skip-install', 'Skip automatic pnpm install', false)
2328
2288
  .option('--skip-git', 'Skip automatic git initialization', false)
2289
+ .option(
2290
+ '--skip-commit',
2291
+ 'Skip automatic git commit after initialization',
2292
+ false,
2293
+ )
2329
2294
  .option('--skip-dev', 'Skip automatic dev server start', false)
2330
2295
  .allowUnknownOption() // 允许透传参数
2331
2296
  .action(async (directory, options, command) => {
2332
2297
  // 位置参数优先级高于 --output 选项
2333
2298
  const outputPath = _nullishCoalesce(directory, () => ( options.output));
2334
- await executeInit({ ...options, output: outputPath }, command);
2299
+ // Always use force mode - overwrite existing files without conflict check
2300
+ const force = true;
2301
+ await executeInit({ ...options, output: outputPath, force }, command);
2335
2302
  });
2336
2303
  };
2337
2304
 
@@ -2631,7 +2598,7 @@ const registerCommand = program => {
2631
2598
  });
2632
2599
  };
2633
2600
 
2634
- var version = "0.0.1-alpha.e665f4";
2601
+ var version = "0.0.1-alpha.e70f72";
2635
2602
  var packageJson = {
2636
2603
  version: version};
2637
2604
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.0.1-alpha.e665f4",
3
+ "version": "0.0.1-alpha.e70f72",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",
@@ -50,6 +50,7 @@
50
50
  "@coze-arch/vitest-config": "workspace:*",
51
51
  "@coze-coding/lambda": "workspace:*",
52
52
  "@inquirer/prompts": "^3.2.0",
53
+ "@playwright/test": "~1.55.0",
53
54
  "@types/ejs": "^3.1.5",
54
55
  "@types/iarna__toml": "^2.0.5",
55
56
  "@types/js-yaml": "^4.0.9",
@@ -57,13 +58,16 @@
57
58
  "@types/minimist": "^1.2.5",
58
59
  "@types/node": "^24",
59
60
  "@types/shelljs": "^0.10.0",
60
- "@vitest/coverage-v8": "~4.0.16",
61
+ "@vitest/coverage-v8": "~4.0.18",
61
62
  "json-schema-to-typescript": "^15.0.3",
62
63
  "minimatch": "^10.0.1",
64
+ "playwright": "~1.55.0",
63
65
  "rollup": "^4.41.1",
64
66
  "sucrase": "^3.35.0",
67
+ "tree-kill": "^1.2.2",
65
68
  "tsx": "^4.20.6",
66
- "vitest": "~4.0.16"
69
+ "vite-tsconfig-paths": "^4.2.1",
70
+ "vitest": "~4.0.18"
67
71
  },
68
72
  "publishConfig": {
69
73
  "access": "public",
@@ -1,14 +0,0 @@
1
- import { PropsWithChildren } from 'react';
2
- import { useLaunch } from '@tarojs/taro';
3
- import { injectH5Styles } from '@/utils/h5-styles';
4
- import { enableWxDebugIfNeeded } from '@/utils/wx-debug';
5
- import '@/app.css';
6
-
7
- export default ({ children }: PropsWithChildren<any>) => {
8
- useLaunch(() => {
9
- enableWxDebugIfNeeded();
10
- injectH5Styles();
11
- });
12
-
13
- return children;
14
- };
@@ -1,22 +0,0 @@
1
- /**
2
- * H5 端特殊样式注入
3
- * 如无必要,请勿修改本文件
4
- */
5
- export function injectH5Styles() {
6
- if (TARO_ENV !== 'h5') return
7
-
8
- const style = document.createElement('style')
9
- style.innerHTML = `
10
- /* H5 端隐藏 TabBar 空图标(只隐藏没有 src 的图标) */
11
- .weui-tabbar__icon:not([src]),
12
- .weui-tabbar__icon[src=''] {
13
- display: none !important;
14
- }
15
-
16
- .weui-tabbar__item:has(.weui-tabbar__icon:not([src])) .weui-tabbar__label,
17
- .weui-tabbar__item:has(.weui-tabbar__icon[src='']) .weui-tabbar__label {
18
- margin-top: 0 !important;
19
- }
20
- `
21
- document.head.appendChild(style)
22
- }
@@ -1,23 +0,0 @@
1
- import Taro from '@tarojs/taro'
2
-
3
- /**
4
- * 微信小程序调试工具
5
- * 在开发版/体验版自动开启调试模式
6
- */
7
- export function enableWxDebugIfNeeded() {
8
- // 仅在微信小程序环境执行
9
- if (Taro.getEnv() === Taro.ENV_TYPE.WEAPP) {
10
- try {
11
- const accountInfo = Taro.getAccountInfoSync()
12
- const envVersion = accountInfo.miniProgram.envVersion
13
- console.log('[Debug] envVersion:', envVersion)
14
-
15
- // 开发版/体验版自动开启调试
16
- if (envVersion !== 'release') {
17
- Taro.setEnableDebug({ enableDebug: true })
18
- }
19
- } catch (error) {
20
- console.error('[Debug] 开启调试模式失败:', error)
21
- }
22
- }
23
- }