@coze-arch/cli 0.0.23-alpha.75ff0b → 0.0.24-alpha.4aa4c4
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.
- package/lib/__templates__/expo/_gitignore +1 -0
- package/lib/__templates__/expo/template.config.js +2 -5
- package/lib/__templates__/native-static/_gitignore +1 -0
- package/lib/__templates__/nextjs/_gitignore +1 -0
- package/lib/__templates__/nextjs/eslint.config.mjs +0 -1
- package/lib/__templates__/nextjs/template.config.js +2 -7
- package/lib/__templates__/nuxt-vue/_gitignore +1 -0
- package/lib/__templates__/nuxt-vue/eslint.config.mjs +0 -33
- package/lib/__templates__/nuxt-vue/package.json +0 -1
- package/lib/__templates__/nuxt-vue/pnpm-lock.yaml +9 -1013
- package/lib/__templates__/nuxt-vue/template.config.js +2 -8
- package/lib/__templates__/pi-agent/_gitignore +1 -0
- package/lib/__templates__/taro/_gitignore +1 -0
- package/lib/__templates__/taro/template.config.js +2 -8
- package/lib/__templates__/vite/_gitignore +1 -0
- package/lib/__templates__/vite/eslint.config.mjs +0 -17
- package/lib/__templates__/vite/package.json +0 -1
- package/lib/__templates__/vite/pnpm-lock.yaml +0 -1007
- package/lib/__templates__/vite/template.config.js +2 -7
- package/lib/cli.js +66 -30
- package/package.json +3 -3
|
@@ -60,13 +60,8 @@ const config = {
|
|
|
60
60
|
return context;
|
|
61
61
|
},
|
|
62
62
|
|
|
63
|
-
onAfterRender: async (_context,
|
|
64
|
-
|
|
65
|
-
console.log('\nConfiguration:');
|
|
66
|
-
console.log(' - Framework: vite');
|
|
67
|
-
console.log(' - TypeScript: enabled');
|
|
68
|
-
console.log(' - App Router: enabled');
|
|
69
|
-
console.log(` - Port: ${_context.port}`);
|
|
63
|
+
onAfterRender: async (_context, _outputPath) => {
|
|
64
|
+
// 输出由 init 命令统一处理
|
|
70
65
|
},
|
|
71
66
|
|
|
72
67
|
onComplete: async (_context, outputPath) => {
|
package/lib/cli.js
CHANGED
|
@@ -2107,7 +2107,7 @@ const EventBuilder = {
|
|
|
2107
2107
|
};
|
|
2108
2108
|
|
|
2109
2109
|
var name = "@coze-arch/cli";
|
|
2110
|
-
var version = "0.0.
|
|
2110
|
+
var version = "0.0.24-alpha.4aa4c4";
|
|
2111
2111
|
var description = "coze coding devtools cli";
|
|
2112
2112
|
var license = "MIT";
|
|
2113
2113
|
var author = "fanwenjie.fe@bytedance.com";
|
|
@@ -2180,7 +2180,7 @@ var devDependencies = {
|
|
|
2180
2180
|
"@types/minimist": "^1.2.5",
|
|
2181
2181
|
"@types/node": "^24",
|
|
2182
2182
|
"@types/shelljs": "^0.10.0",
|
|
2183
|
-
"@vitest/coverage-v8": "~4.1.
|
|
2183
|
+
"@vitest/coverage-v8": "~4.1.7",
|
|
2184
2184
|
knip: "^5.30.1",
|
|
2185
2185
|
minimatch: "^10.0.1",
|
|
2186
2186
|
playwright: "~1.60.0",
|
|
@@ -2188,7 +2188,7 @@ var devDependencies = {
|
|
|
2188
2188
|
sucrase: "^3.35.1",
|
|
2189
2189
|
"tree-kill": "^1.2.2",
|
|
2190
2190
|
tsx: "^4.21.0",
|
|
2191
|
-
vitest: "~4.1.
|
|
2191
|
+
vitest: "~4.1.7"
|
|
2192
2192
|
};
|
|
2193
2193
|
var publishConfig = {
|
|
2194
2194
|
access: "public",
|
|
@@ -9283,6 +9283,49 @@ const prepareFileInfo = async (options
|
|
|
9283
9283
|
return processedFileInfo;
|
|
9284
9284
|
};
|
|
9285
9285
|
|
|
9286
|
+
/**
|
|
9287
|
+
* 合并 .gitignore 文件内容
|
|
9288
|
+
* 将新内容中的条目合并到已有内容中,避免重复
|
|
9289
|
+
*
|
|
9290
|
+
* @param existingContent - 已有的 .gitignore 内容
|
|
9291
|
+
* @param newContent - 新的 .gitignore 内容
|
|
9292
|
+
* @returns 合并后的内容
|
|
9293
|
+
*/
|
|
9294
|
+
const mergeGitignoreContent = (
|
|
9295
|
+
existingContent,
|
|
9296
|
+
newContent,
|
|
9297
|
+
) => {
|
|
9298
|
+
const existingLines = new Set(
|
|
9299
|
+
existingContent
|
|
9300
|
+
.split('\n')
|
|
9301
|
+
.map(line => line.trim())
|
|
9302
|
+
.filter(line => line.length > 0),
|
|
9303
|
+
);
|
|
9304
|
+
|
|
9305
|
+
const newLines = newContent.split('\n');
|
|
9306
|
+
const linesToAppend = [];
|
|
9307
|
+
|
|
9308
|
+
for (const line of newLines) {
|
|
9309
|
+
const trimmed = line.trim();
|
|
9310
|
+
// 跳过空行和已存在的条目
|
|
9311
|
+
if (trimmed.length === 0 || existingLines.has(trimmed)) {
|
|
9312
|
+
continue;
|
|
9313
|
+
}
|
|
9314
|
+
linesToAppend.push(line);
|
|
9315
|
+
}
|
|
9316
|
+
|
|
9317
|
+
if (linesToAppend.length === 0) {
|
|
9318
|
+
return existingContent;
|
|
9319
|
+
}
|
|
9320
|
+
|
|
9321
|
+
// 确保已有内容以换行结尾
|
|
9322
|
+
const base = existingContent.endsWith('\n')
|
|
9323
|
+
? existingContent
|
|
9324
|
+
: existingContent + '\n';
|
|
9325
|
+
|
|
9326
|
+
return base + linesToAppend.join('\n') + '\n';
|
|
9327
|
+
};
|
|
9328
|
+
|
|
9286
9329
|
/**
|
|
9287
9330
|
* 写入渲染后的文件到目标路径
|
|
9288
9331
|
*
|
|
@@ -9315,9 +9358,21 @@ const writeRenderedFile = async (options
|
|
|
9315
9358
|
logger.verbose(' ✓ Written (binary, modified by hook)');
|
|
9316
9359
|
}
|
|
9317
9360
|
} else {
|
|
9318
|
-
//
|
|
9319
|
-
|
|
9320
|
-
|
|
9361
|
+
// .gitignore 文件:合并而非覆盖
|
|
9362
|
+
const fileName = path.basename(destPath);
|
|
9363
|
+
if (fileName === '.gitignore' && fs.existsSync(destPath)) {
|
|
9364
|
+
const existingContent = await fs$1.readFile(destPath, 'utf-8');
|
|
9365
|
+
const mergedContent = mergeGitignoreContent(
|
|
9366
|
+
existingContent,
|
|
9367
|
+
fileInfo.content,
|
|
9368
|
+
);
|
|
9369
|
+
await fs$1.writeFile(destPath, mergedContent, 'utf-8');
|
|
9370
|
+
logger.verbose(' ✓ Merged with existing .gitignore');
|
|
9371
|
+
} else {
|
|
9372
|
+
// 其他文本文件
|
|
9373
|
+
await fs$1.writeFile(destPath, fileInfo.content, 'utf-8');
|
|
9374
|
+
logger.verbose(' ✓ Rendered and written');
|
|
9375
|
+
}
|
|
9321
9376
|
}
|
|
9322
9377
|
};
|
|
9323
9378
|
// end_aigc
|
|
@@ -9711,26 +9766,24 @@ function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else {
|
|
|
9711
9766
|
*/
|
|
9712
9767
|
const runPnpmInstall = (projectPath) => {
|
|
9713
9768
|
logger.info('\nInstalling dependencies with pnpm...');
|
|
9714
|
-
logger.info(`Executing: pnpm install in ${projectPath}`);
|
|
9715
9769
|
|
|
9716
9770
|
const result = shelljs.exec('pnpm install', {
|
|
9717
9771
|
cwd: projectPath,
|
|
9718
|
-
silent: true,
|
|
9772
|
+
silent: true,
|
|
9719
9773
|
});
|
|
9720
9774
|
|
|
9721
|
-
//
|
|
9775
|
+
// verbose 模式下输出 pnpm install 的详细日志
|
|
9722
9776
|
if (result.stdout) {
|
|
9723
|
-
|
|
9777
|
+
logger.verbose(result.stdout);
|
|
9724
9778
|
}
|
|
9725
|
-
|
|
9726
|
-
// 输出 stderr
|
|
9727
9779
|
if (result.stderr) {
|
|
9728
|
-
|
|
9780
|
+
logger.verbose(result.stderr);
|
|
9729
9781
|
}
|
|
9730
9782
|
|
|
9731
9783
|
if (result.code === 0) {
|
|
9732
9784
|
logger.success('Dependencies installed successfully!');
|
|
9733
9785
|
} else {
|
|
9786
|
+
// 仅在失败时输出详细信息以便排查
|
|
9734
9787
|
const errorMessage = [
|
|
9735
9788
|
`pnpm install failed with exit code ${result.code}`,
|
|
9736
9789
|
result.stderr ? `\nStderr:\n${result.stderr}` : '',
|
|
@@ -9747,22 +9800,11 @@ const runPnpmInstall = (projectPath) => {
|
|
|
9747
9800
|
* 运行 git 命令的辅助函数
|
|
9748
9801
|
*/
|
|
9749
9802
|
const runGitCommand = (command, projectPath) => {
|
|
9750
|
-
logger.info(`Executing: ${command}`);
|
|
9751
|
-
|
|
9752
9803
|
const result = shelljs.exec(command, {
|
|
9753
9804
|
cwd: projectPath,
|
|
9754
9805
|
silent: true,
|
|
9755
9806
|
});
|
|
9756
9807
|
|
|
9757
|
-
// 输出命令的结果
|
|
9758
|
-
if (result.stdout) {
|
|
9759
|
-
process.stdout.write(result.stdout);
|
|
9760
|
-
}
|
|
9761
|
-
|
|
9762
|
-
if (result.stderr) {
|
|
9763
|
-
process.stderr.write(result.stderr);
|
|
9764
|
-
}
|
|
9765
|
-
|
|
9766
9808
|
if (result.code !== 0) {
|
|
9767
9809
|
const errorMessage = [
|
|
9768
9810
|
`${command} failed with exit code ${result.code}`,
|
|
@@ -9817,7 +9859,6 @@ const commitChanges = (projectPath) => {
|
|
|
9817
9859
|
}
|
|
9818
9860
|
|
|
9819
9861
|
try {
|
|
9820
|
-
logger.info('\nCommitting initialized files...');
|
|
9821
9862
|
runGitCommand('git add --all', projectPath);
|
|
9822
9863
|
runGitCommand('git commit -m "chore: init env"', projectPath);
|
|
9823
9864
|
logger.success('Changes committed successfully!');
|
|
@@ -9837,14 +9878,10 @@ const commitChanges = (projectPath) => {
|
|
|
9837
9878
|
* 使用 CLI 自己的 dev 命令(定义在 run.ts)而不是直接运行 npm run dev
|
|
9838
9879
|
*/
|
|
9839
9880
|
const runDev = (projectPath) => {
|
|
9840
|
-
logger.info('\nStarting development server in background...');
|
|
9841
|
-
|
|
9842
9881
|
// 获取当前 CLI 的可执行文件路径
|
|
9843
9882
|
// process.argv[0] 是 node,process.argv[1] 是 CLI 入口文件
|
|
9844
9883
|
const cliPath = process.argv[1];
|
|
9845
9884
|
|
|
9846
|
-
logger.info(`Executing: ${cliPath} dev in ${projectPath}`);
|
|
9847
|
-
|
|
9848
9885
|
try {
|
|
9849
9886
|
// 使用通用的后台执行函数启动开发服务器
|
|
9850
9887
|
// 调用 CLI 自己的 dev 命令
|
|
@@ -9855,7 +9892,6 @@ const runDev = (projectPath) => {
|
|
|
9855
9892
|
|
|
9856
9893
|
if (pid) {
|
|
9857
9894
|
logger.success('Development server started in background!');
|
|
9858
|
-
logger.info(`Process ID: ${pid}`);
|
|
9859
9895
|
logger.info(
|
|
9860
9896
|
'\nThe dev server is running independently. You can close this terminal.',
|
|
9861
9897
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coze-arch/cli",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24-alpha.4aa4c4",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "coze coding devtools cli",
|
|
6
6
|
"license": "MIT",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@types/minimist": "^1.2.5",
|
|
74
74
|
"@types/node": "^24",
|
|
75
75
|
"@types/shelljs": "^0.10.0",
|
|
76
|
-
"@vitest/coverage-v8": "~4.1.
|
|
76
|
+
"@vitest/coverage-v8": "~4.1.7",
|
|
77
77
|
"knip": "^5.30.1",
|
|
78
78
|
"minimatch": "^10.0.1",
|
|
79
79
|
"playwright": "~1.60.0",
|
|
@@ -81,7 +81,7 @@
|
|
|
81
81
|
"sucrase": "^3.35.1",
|
|
82
82
|
"tree-kill": "^1.2.2",
|
|
83
83
|
"tsx": "^4.21.0",
|
|
84
|
-
"vitest": "~4.1.
|
|
84
|
+
"vitest": "~4.1.7"
|
|
85
85
|
},
|
|
86
86
|
"publishConfig": {
|
|
87
87
|
"access": "public",
|