@coze-arch/cli 0.0.1-alpha.9f719c → 0.0.1-alpha.a37c60

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.
@@ -2,6 +2,7 @@ import type { NextConfig } from 'next';
2
2
 
3
3
  const nextConfig: NextConfig = {
4
4
  /* config options here */
5
+ allowedDevOrigins: ['*.dev.coze.site'],
5
6
  };
6
7
 
7
8
  export default nextConfig;
@@ -1,59 +1,11 @@
1
1
  @import 'tailwindcss';
2
- @import "tw-animate-css";
2
+ @import 'tw-animate-css';
3
3
 
4
4
  @custom-variant dark (&:is(.dark *));
5
5
 
6
- :root {
7
- --background: 0 0% 100%;
8
- --foreground: 0 0% 9%;
9
- --card: 0 0% 100%;
10
- --card-foreground: 0 0% 9%;
11
- --popover: 0 0% 100%;
12
- --popover-foreground: 0 0% 9%;
13
- --primary: 0 0% 9%;
14
- --primary-foreground: 0 0% 98%;
15
- --secondary: 0 0% 96%;
16
- --secondary-foreground: 0 0% 9%;
17
- --muted: 0 0% 96%;
18
- --muted-foreground: 0 0% 45%;
19
- --accent: 0 0% 96%;
20
- --accent-foreground: 0 0% 9%;
21
- --destructive: 0 84% 60%;
22
- --destructive-foreground: 0 0% 98%;
23
- --border: 0 0% 90%;
24
- --input: 0 0% 90%;
25
- --ring: 0 0% 9%;
26
- --radius: 0.5rem;
27
- --sidebar: hsl(0 0% 98%);
28
- --sidebar-foreground: hsl(240 5.3% 26.1%);
29
- --sidebar-primary: hsl(240 5.9% 10%);
30
- --sidebar-primary-foreground: hsl(0 0% 98%);
31
- --sidebar-accent: hsl(240 4.8% 95.9%);
32
- --sidebar-accent-foreground: hsl(240 5.9% 10%);
33
- --sidebar-border: hsl(220 13% 91%);
34
- --sidebar-ring: hsl(217.2 91.2% 59.8%);
35
- }
36
-
37
6
  @theme inline {
38
- --color-background: hsl(var(--background));
39
- --color-foreground: hsl(var(--foreground));
40
- --color-card: hsl(var(--card));
41
- --color-card-foreground: hsl(var(--card-foreground));
42
- --color-popover: hsl(var(--popover));
43
- --color-popover-foreground: hsl(var(--popover-foreground));
44
- --color-primary: hsl(var(--primary));
45
- --color-primary-foreground: hsl(var(--primary-foreground));
46
- --color-secondary: hsl(var(--secondary));
47
- --color-secondary-foreground: hsl(var(--secondary-foreground));
48
- --color-muted: hsl(var(--muted));
49
- --color-muted-foreground: hsl(var(--muted-foreground));
50
- --color-accent: hsl(var(--accent));
51
- --color-accent-foreground: hsl(var(--accent-foreground));
52
- --color-destructive: hsl(var(--destructive));
53
- --color-destructive-foreground: hsl(var(--destructive-foreground));
54
- --color-border: hsl(var(--border));
55
- --color-input: hsl(var(--input));
56
- --color-ring: hsl(var(--ring));
7
+ --color-background: var(--background);
8
+ --color-foreground: var(--foreground);
57
9
  --font-sans: var(--font-geist-sans);
58
10
  --font-mono: var(--font-geist-mono);
59
11
  --color-sidebar-ring: var(--sidebar-ring);
@@ -64,47 +16,103 @@
64
16
  --color-sidebar-primary: var(--sidebar-primary);
65
17
  --color-sidebar-foreground: var(--sidebar-foreground);
66
18
  --color-sidebar: var(--sidebar);
19
+ --color-chart-5: var(--chart-5);
20
+ --color-chart-4: var(--chart-4);
21
+ --color-chart-3: var(--chart-3);
22
+ --color-chart-2: var(--chart-2);
23
+ --color-chart-1: var(--chart-1);
24
+ --color-ring: var(--ring);
25
+ --color-input: var(--input);
26
+ --color-border: var(--border);
27
+ --color-destructive: var(--destructive);
28
+ --color-accent-foreground: var(--accent-foreground);
29
+ --color-accent: var(--accent);
30
+ --color-muted-foreground: var(--muted-foreground);
31
+ --color-muted: var(--muted);
32
+ --color-secondary-foreground: var(--secondary-foreground);
33
+ --color-secondary: var(--secondary);
34
+ --color-primary-foreground: var(--primary-foreground);
35
+ --color-primary: var(--primary);
36
+ --color-popover-foreground: var(--popover-foreground);
37
+ --color-popover: var(--popover);
38
+ --color-card-foreground: var(--card-foreground);
39
+ --color-card: var(--card);
40
+ --radius-sm: calc(var(--radius) - 4px);
41
+ --radius-md: calc(var(--radius) - 2px);
42
+ --radius-lg: var(--radius);
43
+ --radius-xl: calc(var(--radius) + 4px);
44
+ --radius-2xl: calc(var(--radius) + 8px);
45
+ --radius-3xl: calc(var(--radius) + 12px);
46
+ --radius-4xl: calc(var(--radius) + 16px);
67
47
  }
68
48
 
69
- @media (prefers-color-scheme: dark) {
70
- :root {
71
- --background: 0 0% 4%;
72
- --foreground: 0 0% 93%;
73
- --card: 0 0% 4%;
74
- --card-foreground: 0 0% 93%;
75
- --popover: 0 0% 4%;
76
- --popover-foreground: 0 0% 93%;
77
- --primary: 0 0% 98%;
78
- --primary-foreground: 0 0% 9%;
79
- --secondary: 0 0% 15%;
80
- --secondary-foreground: 0 0% 98%;
81
- --muted: 0 0% 15%;
82
- --muted-foreground: 0 0% 64%;
83
- --accent: 0 0% 15%;
84
- --accent-foreground: 0 0% 98%;
85
- --destructive: 0 63% 31%;
86
- --destructive-foreground: 0 0% 98%;
87
- --border: 0 0% 15%;
88
- --input: 0 0% 15%;
89
- --ring: 0 0% 83%;
90
- }
91
- }
92
-
93
- body {
94
- background: hsl(var(--background));
95
- color: hsl(var(--foreground));
96
- font-family: Arial, Helvetica, sans-serif;
49
+ :root {
50
+ --radius: 0.625rem;
51
+ --background: oklch(1 0 0);
52
+ --foreground: oklch(0.145 0 0);
53
+ --card: oklch(1 0 0);
54
+ --card-foreground: oklch(0.145 0 0);
55
+ --popover: oklch(1 0 0);
56
+ --popover-foreground: oklch(0.145 0 0);
57
+ --primary: oklch(0.205 0 0);
58
+ --primary-foreground: oklch(0.985 0 0);
59
+ --secondary: oklch(0.97 0 0);
60
+ --secondary-foreground: oklch(0.205 0 0);
61
+ --muted: oklch(0.97 0 0);
62
+ --muted-foreground: oklch(0.556 0 0);
63
+ --accent: oklch(0.97 0 0);
64
+ --accent-foreground: oklch(0.205 0 0);
65
+ --destructive: oklch(0.577 0.245 27.325);
66
+ --border: oklch(0.922 0 0);
67
+ --input: oklch(0.922 0 0);
68
+ --ring: oklch(0.708 0 0);
69
+ --chart-1: oklch(0.646 0.222 41.116);
70
+ --chart-2: oklch(0.6 0.118 184.704);
71
+ --chart-3: oklch(0.398 0.07 227.392);
72
+ --chart-4: oklch(0.828 0.189 84.429);
73
+ --chart-5: oklch(0.769 0.188 70.08);
74
+ --sidebar: oklch(0.985 0 0);
75
+ --sidebar-foreground: oklch(0.145 0 0);
76
+ --sidebar-primary: oklch(0.205 0 0);
77
+ --sidebar-primary-foreground: oklch(0.985 0 0);
78
+ --sidebar-accent: oklch(0.97 0 0);
79
+ --sidebar-accent-foreground: oklch(0.205 0 0);
80
+ --sidebar-border: oklch(0.922 0 0);
81
+ --sidebar-ring: oklch(0.708 0 0);
97
82
  }
98
83
 
99
84
  .dark {
100
- --sidebar: hsl(240 5.9% 10%);
101
- --sidebar-foreground: hsl(240 4.8% 95.9%);
102
- --sidebar-primary: hsl(224.3 76.3% 48%);
103
- --sidebar-primary-foreground: hsl(0 0% 100%);
104
- --sidebar-accent: hsl(240 3.7% 15.9%);
105
- --sidebar-accent-foreground: hsl(240 4.8% 95.9%);
106
- --sidebar-border: hsl(240 3.7% 15.9%);
107
- --sidebar-ring: hsl(217.2 91.2% 59.8%);
85
+ --background: oklch(0.145 0 0);
86
+ --foreground: oklch(0.985 0 0);
87
+ --card: oklch(0.205 0 0);
88
+ --card-foreground: oklch(0.985 0 0);
89
+ --popover: oklch(0.205 0 0);
90
+ --popover-foreground: oklch(0.985 0 0);
91
+ --primary: oklch(0.922 0 0);
92
+ --primary-foreground: oklch(0.205 0 0);
93
+ --secondary: oklch(0.269 0 0);
94
+ --secondary-foreground: oklch(0.985 0 0);
95
+ --muted: oklch(0.269 0 0);
96
+ --muted-foreground: oklch(0.708 0 0);
97
+ --accent: oklch(0.269 0 0);
98
+ --accent-foreground: oklch(0.985 0 0);
99
+ --destructive: oklch(0.704 0.191 22.216);
100
+ --border: oklch(1 0 0 / 10%);
101
+ --input: oklch(1 0 0 / 15%);
102
+ --ring: oklch(0.556 0 0);
103
+ --chart-1: oklch(0.488 0.243 264.376);
104
+ --chart-2: oklch(0.696 0.17 162.48);
105
+ --chart-3: oklch(0.769 0.188 70.08);
106
+ --chart-4: oklch(0.627 0.265 303.9);
107
+ --chart-5: oklch(0.645 0.246 16.439);
108
+ --sidebar: oklch(0.205 0 0);
109
+ --sidebar-foreground: oklch(0.985 0 0);
110
+ --sidebar-primary: oklch(0.488 0.243 264.376);
111
+ --sidebar-primary-foreground: oklch(0.985 0 0);
112
+ --sidebar-accent: oklch(0.269 0 0);
113
+ --sidebar-accent-foreground: oklch(0.985 0 0);
114
+ --sidebar-border: oklch(1 0 0 / 10%);
115
+ --sidebar-ring: oklch(0.556 0 0);
108
116
  }
109
117
 
110
118
  @layer base {
@@ -115,3 +123,7 @@ body {
115
123
  @apply bg-background text-foreground;
116
124
  }
117
125
  }
126
+
127
+ body {
128
+ @apply font-sans;
129
+ }
@@ -39,6 +39,33 @@
39
39
  }
40
40
  }
41
41
  },
42
+ {
43
+ "name": "test-only",
44
+ "description": "test-only template",
45
+ "location": "./test-only",
46
+ "paramsSchema": {
47
+ "appName": {
48
+ "type": "string",
49
+ "description": "Application name (lowercase, alphanumeric and hyphens only)",
50
+ "pattern": "^[a-z0-9-]+$"
51
+ },
52
+ "port": {
53
+ "type": "number",
54
+ "description": "Development server port",
55
+ "default": 5000,
56
+ "minimum": 1024,
57
+ "maximum": 65535
58
+ },
59
+ "includeTests": {
60
+ "type": "boolean",
61
+ "description": "Include test files"
62
+ },
63
+ "addCopyright": {
64
+ "type": "boolean",
65
+ "description": "Add copyright header to source files"
66
+ }
67
+ }
68
+ },
42
69
  {
43
70
  "name": "vite",
44
71
  "description": "vite template",
package/lib/cli.js CHANGED
@@ -1248,17 +1248,139 @@ const convertDotfileName = (filePath) => {
1248
1248
  };
1249
1249
 
1250
1250
  /**
1251
- * 复制并处理模板文件到目标目录
1251
+ * 执行文件渲染钩子
1252
1252
  *
1253
- * @param templatePath - 模板目录路径
1254
- * @param outputPath - 输出目录路径
1253
+ * @param templateConfig - 模板配置
1254
+ * @param fileInfo - 文件渲染信息
1255
1255
  * @param context - 模板上下文
1256
+ * @returns 处理后的文件信息,或 null 表示跳过该文件
1256
1257
  */
1257
- const processTemplateFiles = async (
1258
- templatePath,
1259
- outputPath,
1258
+ const executeFileRenderHook = async (
1259
+ templateConfig,
1260
+ fileInfo,
1260
1261
  context,
1261
1262
  ) => {
1263
+ if (!templateConfig.onFileRender) {
1264
+ return fileInfo;
1265
+ }
1266
+
1267
+ const result = await templateConfig.onFileRender(
1268
+ fileInfo,
1269
+ context,
1270
+ );
1271
+
1272
+ // false: 跳过文件
1273
+ if (result === false) {
1274
+ return null;
1275
+ }
1276
+
1277
+ // undefined/void: 使用默认内容
1278
+ if (result === undefined || result === null) {
1279
+ return fileInfo;
1280
+ }
1281
+
1282
+ // string: 作为 content,其他不变
1283
+ if (typeof result === 'string') {
1284
+ return {
1285
+ ...fileInfo,
1286
+ content: result,
1287
+ };
1288
+ }
1289
+
1290
+ // FileRenderInfo: 使用新对象的信息
1291
+ return result;
1292
+ };
1293
+
1294
+ /**
1295
+ * 处理单个文件
1296
+ */
1297
+ const processSingleFile = async (options
1298
+
1299
+
1300
+
1301
+
1302
+
1303
+ ) => {
1304
+ const { file, templatePath, outputPath, context, templateConfig } = options;
1305
+
1306
+ const srcPath = path.join(templatePath, file);
1307
+ const destFile = convertDotfileName(file);
1308
+
1309
+ logger.verbose(
1310
+ ` - Processing: ${file}${destFile !== file ? ` -> ${destFile}` : ''}`,
1311
+ );
1312
+
1313
+ // 判断是否为二进制文件
1314
+ const isBinary = !shouldRenderFile(srcPath);
1315
+ let content;
1316
+ let wasRendered = false;
1317
+
1318
+ if (isBinary) {
1319
+ // 二进制文件,读取为 buffer 然后转为 base64
1320
+ const buffer = await fs$1.readFile(srcPath);
1321
+ content = buffer.toString('base64');
1322
+ } else {
1323
+ // 文本文件,渲染后的内容
1324
+ content = await renderTemplate(srcPath, context);
1325
+ wasRendered = true;
1326
+ }
1327
+
1328
+ // 构造文件信息对象
1329
+ const fileInfo = {
1330
+ path: file,
1331
+ destPath: destFile,
1332
+ content,
1333
+ isBinary,
1334
+ wasRendered,
1335
+ };
1336
+
1337
+ // 执行文件渲染钩子
1338
+ const processedFileInfo = await executeFileRenderHook(
1339
+ templateConfig,
1340
+ fileInfo,
1341
+ context,
1342
+ );
1343
+
1344
+ // 如果返回 null,跳过该文件
1345
+ if (processedFileInfo === null) {
1346
+ logger.verbose(' ⊘ Skipped by onFileRender hook');
1347
+ return;
1348
+ }
1349
+
1350
+ // 使用处理后的目标路径
1351
+ const finalDestPath = path.join(outputPath, processedFileInfo.destPath);
1352
+
1353
+ // 确保目标目录存在
1354
+ await ensureDir(path.dirname(finalDestPath));
1355
+
1356
+ // 写入文件
1357
+ if (processedFileInfo.isBinary) {
1358
+ // 二进制文件:如果内容没变,直接复制;否则从 base64 解码写入
1359
+ if (processedFileInfo.content === content) {
1360
+ await fs$1.copyFile(srcPath, finalDestPath);
1361
+ logger.verbose(' ✓ Copied (binary)');
1362
+ } else {
1363
+ const buffer = Buffer.from(processedFileInfo.content, 'base64');
1364
+ await fs$1.writeFile(finalDestPath, buffer);
1365
+ logger.verbose(' ✓ Written (binary, modified by hook)');
1366
+ }
1367
+ } else {
1368
+ // 文本文件
1369
+ await fs$1.writeFile(finalDestPath, processedFileInfo.content, 'utf-8');
1370
+ logger.verbose(' ✓ Rendered and written');
1371
+ }
1372
+ };
1373
+
1374
+ /**
1375
+ * 复制并处理模板文件到目标目录
1376
+ */
1377
+ const processTemplateFiles = async (options
1378
+
1379
+
1380
+
1381
+
1382
+ ) => {
1383
+ const { templatePath, outputPath, context, templateConfig } = options;
1262
1384
  logger.verbose('Processing template files:');
1263
1385
  logger.verbose(` - Template path: ${templatePath}`);
1264
1386
  logger.verbose(` - Output path: ${outputPath}`);
@@ -1289,29 +1411,15 @@ const processTemplateFiles = async (
1289
1411
  }
1290
1412
 
1291
1413
  await Promise.all(
1292
- files.map(async file => {
1293
- const srcPath = path.join(templatePath, file);
1294
- const destFile = convertDotfileName(file);
1295
- const destPath = path.join(outputPath, destFile);
1296
-
1297
- logger.verbose(
1298
- ` - Processing: ${file}${destFile !== file ? ` -> ${destFile}` : ''}`,
1299
- );
1300
-
1301
- // 确保目标目录存在
1302
- await ensureDir(path.dirname(destPath));
1303
-
1304
- if (shouldRenderFile(srcPath)) {
1305
- // 渲染文本文件
1306
- const rendered = await renderTemplate(srcPath, context);
1307
- await fs$1.writeFile(destPath, rendered, 'utf-8');
1308
- logger.verbose(' ✓ Rendered and written');
1309
- } else {
1310
- // 直接复制二进制文件
1311
- await fs$1.copyFile(srcPath, destPath);
1312
- logger.verbose(' ✓ Copied');
1313
- }
1314
- }),
1414
+ files.map(file =>
1415
+ processSingleFile({
1416
+ file,
1417
+ templatePath,
1418
+ outputPath,
1419
+ context,
1420
+ templateConfig,
1421
+ }),
1422
+ ),
1315
1423
  );
1316
1424
 
1317
1425
  logger.verbose('✓ All files processed successfully');
@@ -1498,7 +1606,12 @@ const execute = async (
1498
1606
  const absoluteOutputPath = await prepareOutputDirectory(outputPath);
1499
1607
 
1500
1608
  // 6. 处理模板文件
1501
- await processTemplateFiles(templatePath, absoluteOutputPath, context);
1609
+ await processTemplateFiles({
1610
+ templatePath,
1611
+ outputPath: absoluteOutputPath,
1612
+ context,
1613
+ templateConfig,
1614
+ });
1502
1615
 
1503
1616
  // 7. 执行 onAfterRender 钩子
1504
1617
  await executeAfterRenderHook(templateConfig, context, absoluteOutputPath);
@@ -1741,7 +1854,7 @@ const registerCommand = program => {
1741
1854
  });
1742
1855
  };
1743
1856
 
1744
- var version = "0.0.1-alpha.9f719c";
1857
+ var version = "0.0.1-alpha.a37c60";
1745
1858
  var packageJson = {
1746
1859
  version: version};
1747
1860
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.0.1-alpha.9f719c",
3
+ "version": "0.0.1-alpha.a37c60",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",
@@ -19,12 +19,13 @@
19
19
  "scripts": {
20
20
  "prebuild": "tsx scripts/prebuild.ts",
21
21
  "build": "tsx scripts/build.ts",
22
+ "create": "tsx scripts/create-template.ts",
22
23
  "lint": "eslint ./ --cache",
23
24
  "postpublish": "bash scripts/sync-npmmirror.sh",
24
25
  "test": "vitest --run --passWithNoTests",
25
26
  "test:all": "bash scripts/test-coverage.sh",
26
27
  "test:cov": "vitest --run --passWithNoTests --coverage",
27
- "test:e2e": "bash scripts/e2e.sh",
28
+ "test:e2e": "NODE_ENV=test bash scripts/e2e.sh",
28
29
  "test:perf": "vitest bench --run --config vitest.perf.config.ts",
29
30
  "test:perf:compare": "bash scripts/compare-perf.sh",
30
31
  "test:perf:save": "bash scripts/run-perf-with-output.sh"
@@ -48,21 +49,25 @@
48
49
  "@coze-arch/ts-config": "workspace:*",
49
50
  "@coze-arch/vitest-config": "workspace:*",
50
51
  "@coze-coding/lambda": "workspace:*",
52
+ "@inquirer/prompts": "^3.2.0",
51
53
  "@types/ejs": "^3.1.5",
52
54
  "@types/iarna__toml": "^2.0.5",
53
55
  "@types/js-yaml": "^4.0.9",
56
+ "@types/minimatch": "^5.1.2",
54
57
  "@types/minimist": "^1.2.5",
55
58
  "@types/node": "^24",
56
59
  "@types/shelljs": "^0.10.0",
57
60
  "@vitest/coverage-v8": "~4.0.16",
58
61
  "json-schema-to-typescript": "^15.0.3",
62
+ "minimatch": "^10.0.1",
59
63
  "rollup": "^4.41.1",
60
64
  "sucrase": "^3.35.0",
61
65
  "tsx": "^4.20.6",
62
66
  "vitest": "~4.0.16"
63
67
  },
64
68
  "publishConfig": {
65
- "access": "public"
69
+ "access": "public",
70
+ "registry": "https://registry.npmjs.org"
66
71
  },
67
72
  "cozePublishConfig": {
68
73
  "bin": {