@coze-arch/cli 0.0.1-beta.5 → 0.0.1-beta.6

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 (114) hide show
  1. package/lib/__templates__/expo/.cozeproj/scripts/deploy_run.sh +2 -2
  2. package/lib/__templates__/expo/app.json +1 -1
  3. package/lib/__templates__/expo/client/components/Screen.tsx +19 -19
  4. package/lib/__templates__/expo/client/index.js +2 -1
  5. package/lib/__templates__/expo/client/scripts/install-missing-deps.js +36 -12
  6. package/lib/__templates__/expo/metro.config.js +15 -15
  7. package/lib/__templates__/expo/package.json +22 -12
  8. package/lib/__templates__/expo/pnpm-lock.yaml +335 -4
  9. package/lib/__templates__/nextjs/.babelrc +15 -0
  10. package/lib/__templates__/nextjs/README.md +341 -19
  11. package/lib/__templates__/nextjs/components.json +21 -0
  12. package/lib/__templates__/nextjs/package.json +48 -1
  13. package/lib/__templates__/nextjs/pnpm-lock.yaml +6399 -1356
  14. package/lib/__templates__/nextjs/scripts/dev.sh +2 -1
  15. package/lib/__templates__/nextjs/server.mjs +50 -0
  16. package/lib/__templates__/nextjs/src/app/globals.css +99 -8
  17. package/lib/__templates__/nextjs/src/app/layout.tsx +55 -2
  18. package/lib/__templates__/nextjs/src/app/robots.ts +11 -0
  19. package/lib/__templates__/nextjs/src/components/ui/accordion.tsx +66 -0
  20. package/lib/__templates__/nextjs/src/components/ui/alert-dialog.tsx +157 -0
  21. package/lib/__templates__/nextjs/src/components/ui/alert.tsx +66 -0
  22. package/lib/__templates__/nextjs/src/components/ui/aspect-ratio.tsx +11 -0
  23. package/lib/__templates__/nextjs/src/components/ui/avatar.tsx +53 -0
  24. package/lib/__templates__/nextjs/src/components/ui/badge.tsx +46 -0
  25. package/lib/__templates__/nextjs/src/components/ui/breadcrumb.tsx +109 -0
  26. package/lib/__templates__/nextjs/src/components/ui/button-group.tsx +83 -0
  27. package/lib/__templates__/nextjs/src/components/ui/button.tsx +62 -0
  28. package/lib/__templates__/nextjs/src/components/ui/calendar.tsx +220 -0
  29. package/lib/__templates__/nextjs/src/components/ui/card.tsx +92 -0
  30. package/lib/__templates__/nextjs/src/components/ui/carousel.tsx +241 -0
  31. package/lib/__templates__/nextjs/src/components/ui/chart.tsx +357 -0
  32. package/lib/__templates__/nextjs/src/components/ui/checkbox.tsx +32 -0
  33. package/lib/__templates__/nextjs/src/components/ui/collapsible.tsx +33 -0
  34. package/lib/__templates__/nextjs/src/components/ui/command.tsx +184 -0
  35. package/lib/__templates__/nextjs/src/components/ui/context-menu.tsx +252 -0
  36. package/lib/__templates__/nextjs/src/components/ui/dialog.tsx +143 -0
  37. package/lib/__templates__/nextjs/src/components/ui/drawer.tsx +135 -0
  38. package/lib/__templates__/nextjs/src/components/ui/dropdown-menu.tsx +257 -0
  39. package/lib/__templates__/nextjs/src/components/ui/empty.tsx +104 -0
  40. package/lib/__templates__/nextjs/src/components/ui/field.tsx +248 -0
  41. package/lib/__templates__/nextjs/src/components/ui/form.tsx +167 -0
  42. package/lib/__templates__/nextjs/src/components/ui/hover-card.tsx +44 -0
  43. package/lib/__templates__/nextjs/src/components/ui/input-group.tsx +170 -0
  44. package/lib/__templates__/nextjs/src/components/ui/input-otp.tsx +77 -0
  45. package/lib/__templates__/nextjs/src/components/ui/input.tsx +21 -0
  46. package/lib/__templates__/nextjs/src/components/ui/item.tsx +193 -0
  47. package/lib/__templates__/nextjs/src/components/ui/kbd.tsx +28 -0
  48. package/lib/__templates__/nextjs/src/components/ui/label.tsx +24 -0
  49. package/lib/__templates__/nextjs/src/components/ui/menubar.tsx +276 -0
  50. package/lib/__templates__/nextjs/src/components/ui/navigation-menu.tsx +168 -0
  51. package/lib/__templates__/nextjs/src/components/ui/pagination.tsx +127 -0
  52. package/lib/__templates__/nextjs/src/components/ui/popover.tsx +48 -0
  53. package/lib/__templates__/nextjs/src/components/ui/progress.tsx +31 -0
  54. package/lib/__templates__/nextjs/src/components/ui/radio-group.tsx +45 -0
  55. package/lib/__templates__/nextjs/src/components/ui/resizable.tsx +56 -0
  56. package/lib/__templates__/nextjs/src/components/ui/scroll-area.tsx +58 -0
  57. package/lib/__templates__/nextjs/src/components/ui/select.tsx +190 -0
  58. package/lib/__templates__/nextjs/src/components/ui/separator.tsx +28 -0
  59. package/lib/__templates__/nextjs/src/components/ui/sheet.tsx +139 -0
  60. package/lib/__templates__/nextjs/src/components/ui/sidebar.tsx +726 -0
  61. package/lib/__templates__/nextjs/src/components/ui/skeleton.tsx +13 -0
  62. package/lib/__templates__/nextjs/src/components/ui/slider.tsx +63 -0
  63. package/lib/__templates__/nextjs/src/components/ui/sonner.tsx +40 -0
  64. package/lib/__templates__/nextjs/src/components/ui/spinner.tsx +16 -0
  65. package/lib/__templates__/nextjs/src/components/ui/switch.tsx +31 -0
  66. package/lib/__templates__/nextjs/src/components/ui/table.tsx +116 -0
  67. package/lib/__templates__/nextjs/src/components/ui/tabs.tsx +66 -0
  68. package/lib/__templates__/nextjs/src/components/ui/textarea.tsx +18 -0
  69. package/lib/__templates__/nextjs/src/components/ui/toggle-group.tsx +83 -0
  70. package/lib/__templates__/nextjs/src/components/ui/toggle.tsx +47 -0
  71. package/lib/__templates__/nextjs/src/components/ui/tooltip.tsx +61 -0
  72. package/lib/__templates__/nextjs/src/hooks/use-mobile.ts +19 -0
  73. package/lib/__templates__/nextjs/src/lib/utils.ts +6 -0
  74. package/lib/__templates__/nextjs/template.config.js +2 -2
  75. package/lib/__templates__/templates.json +2 -40
  76. package/lib/__templates__/vite/template.config.js +5 -3
  77. package/lib/cli.js +41 -4
  78. package/package.json +3 -3
  79. package/lib/__templates__/react-rsbuild/.coze +0 -11
  80. package/lib/__templates__/react-rsbuild/.vscode/settings.json +0 -121
  81. package/lib/__templates__/react-rsbuild/README.md +0 -61
  82. package/lib/__templates__/react-rsbuild/_gitignore +0 -97
  83. package/lib/__templates__/react-rsbuild/package.json +0 -31
  84. package/lib/__templates__/react-rsbuild/pnpm-lock.yaml +0 -997
  85. package/lib/__templates__/react-rsbuild/rsbuild.config.ts +0 -13
  86. package/lib/__templates__/react-rsbuild/scripts/build.sh +0 -14
  87. package/lib/__templates__/react-rsbuild/scripts/dev.sh +0 -51
  88. package/lib/__templates__/react-rsbuild/scripts/start.sh +0 -15
  89. package/lib/__templates__/react-rsbuild/src/App.tsx +0 -60
  90. package/lib/__templates__/react-rsbuild/src/index.css +0 -21
  91. package/lib/__templates__/react-rsbuild/src/index.html +0 -12
  92. package/lib/__templates__/react-rsbuild/src/index.tsx +0 -16
  93. package/lib/__templates__/react-rsbuild/tailwind.config.js +0 -9
  94. package/lib/__templates__/react-rsbuild/template.config.js +0 -54
  95. package/lib/__templates__/react-rsbuild/tsconfig.json +0 -17
  96. package/lib/__templates__/rsbuild/.coze +0 -11
  97. package/lib/__templates__/rsbuild/.vscode/settings.json +0 -7
  98. package/lib/__templates__/rsbuild/README.md +0 -61
  99. package/lib/__templates__/rsbuild/_gitignore +0 -97
  100. package/lib/__templates__/rsbuild/_npmrc +0 -22
  101. package/lib/__templates__/rsbuild/package.json +0 -24
  102. package/lib/__templates__/rsbuild/pnpm-lock.yaml +0 -888
  103. package/lib/__templates__/rsbuild/rsbuild.config.ts +0 -12
  104. package/lib/__templates__/rsbuild/scripts/build.sh +0 -14
  105. package/lib/__templates__/rsbuild/scripts/dev.sh +0 -51
  106. package/lib/__templates__/rsbuild/scripts/start.sh +0 -15
  107. package/lib/__templates__/rsbuild/src/index.css +0 -21
  108. package/lib/__templates__/rsbuild/src/index.html +0 -12
  109. package/lib/__templates__/rsbuild/src/index.ts +0 -5
  110. package/lib/__templates__/rsbuild/src/main.ts +0 -65
  111. package/lib/__templates__/rsbuild/tailwind.config.js +0 -9
  112. package/lib/__templates__/rsbuild/template.config.js +0 -54
  113. package/lib/__templates__/rsbuild/tsconfig.json +0 -16
  114. /package/lib/__templates__/{react-rsbuild → expo}/_npmrc +0 -0
package/lib/cli.js CHANGED
@@ -1047,6 +1047,27 @@ const ensureDir = async (dir) => {
1047
1047
  await fs$1.mkdir(dir, { recursive: true });
1048
1048
  };
1049
1049
 
1050
+ /**
1051
+ * 转换模板文件名(白名单机制)
1052
+ * 只对特定文件将 _ 开头转换为 . 开头
1053
+ *
1054
+ * @param filePath - 文件相对路径
1055
+ * @returns 转换后的文件路径
1056
+ */
1057
+ const convertDotfileName = (filePath) => {
1058
+ // 白名单:需要从 _ 开头转换为 . 开头的文件
1059
+ const dotfileWhitelist = ['_gitignore', '_npmrc'];
1060
+
1061
+ const fileName = path.basename(filePath);
1062
+
1063
+ // 只对白名单中的文件进行转换(如 _gitignore -> .gitignore)
1064
+ if (dotfileWhitelist.includes(fileName)) {
1065
+ return filePath.replace(/(^|\/|\\)_([^/\\]+)$/g, '$1.$2');
1066
+ }
1067
+
1068
+ return filePath;
1069
+ };
1070
+
1050
1071
  /**
1051
1072
  * 复制并处理模板文件到目标目录
1052
1073
  *
@@ -1091,8 +1112,7 @@ const processTemplateFiles = async (
1091
1112
  await Promise.all(
1092
1113
  files.map(async file => {
1093
1114
  const srcPath = path.join(templatePath, file);
1094
- // 将模板中 _ 开头的文件转换为 . 开头(如 _gitignore -> .gitignore)
1095
- const destFile = file.replace(/(^|\/|\\)_([^/\\]+)$/g, '$1.$2');
1115
+ const destFile = convertDotfileName(file);
1096
1116
  const destPath = path.join(outputPath, destFile);
1097
1117
 
1098
1118
  logger.verbose(
@@ -1151,6 +1171,7 @@ const processTemplateFiles = async (
1151
1171
 
1152
1172
  /**
1153
1173
  * 检查输出目录是否为空
1174
+ * 注意:.git 目录会被忽略,允许在已初始化 git 的目录中创建项目
1154
1175
  *
1155
1176
  * @param outputPath - 输出目录路径
1156
1177
  * @returns 是否为空
@@ -1160,7 +1181,9 @@ const isOutputDirEmpty = async (
1160
1181
  ) => {
1161
1182
  try {
1162
1183
  const entries = await fs$1.readdir(outputPath);
1163
- return entries.length === 0;
1184
+ // 过滤掉 .git 目录,允许在已初始化 git 的目录中创建项目
1185
+ const filteredEntries = entries.filter(entry => entry !== '.git');
1186
+ return filteredEntries.length === 0;
1164
1187
  } catch (e) {
1165
1188
  // 目录不存在,视为空
1166
1189
  return true;
@@ -1344,8 +1367,18 @@ const runPnpmInstall = (projectPath) => {
1344
1367
 
1345
1368
  /**
1346
1369
  * 初始化 git 仓库并创建初始提交
1370
+ * 如果目录中已存在 .git,则跳过初始化
1347
1371
  */
1348
1372
  const runGitInit = (projectPath) => {
1373
+ // 检查是否已存在 .git 目录
1374
+ const gitDir = path.join(projectPath, '.git');
1375
+ if (fs.existsSync(gitDir)) {
1376
+ logger.info(
1377
+ '\n💡 Git repository already exists, skipping git initialization',
1378
+ );
1379
+ return;
1380
+ }
1381
+
1349
1382
  const runGitCommand = (command) => {
1350
1383
  logger.info(`Executing: ${command}`);
1351
1384
 
@@ -1548,6 +1581,10 @@ const registerCommand = program => {
1548
1581
  });
1549
1582
  };
1550
1583
 
1584
+ var version = "0.0.1-beta.6";
1585
+ var packageJson = {
1586
+ version: version};
1587
+
1551
1588
  const commands = [
1552
1589
  registerCommand,
1553
1590
  registerCommand$1,
@@ -1562,7 +1599,7 @@ const main = () => {
1562
1599
  .description(
1563
1600
  'Coze Coding CLI - Project template engine for frontend stacks',
1564
1601
  )
1565
- .version('1.0.0');
1602
+ .version(packageJson.version);
1566
1603
 
1567
1604
  commands.forEach(initCmd => initCmd(program));
1568
1605
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coze-arch/cli",
3
- "version": "0.0.1-beta.5",
3
+ "version": "0.0.1-beta.6",
4
4
  "private": false,
5
5
  "description": "coze coding devtools cli",
6
6
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "test": "vitest --run --passWithNoTests",
25
25
  "test:all": "bash scripts/test-coverage.sh",
26
26
  "test:cov": "vitest --run --passWithNoTests --coverage",
27
- "test:e2e": "vitest run --config vitest.e2e.config.ts",
27
+ "test:e2e": "bash scripts/e2e.sh",
28
28
  "test:perf": "vitest bench --run --config vitest.perf.config.ts",
29
29
  "test:perf:compare": "bash scripts/compare-perf.sh",
30
30
  "test:perf:save": "bash scripts/run-perf-with-output.sh"
@@ -67,4 +67,4 @@
67
67
  "coze": "bin/main"
68
68
  }
69
69
  }
70
- }
70
+ }
@@ -1,11 +0,0 @@
1
- [project]
2
- requires = ["nodejs-24"]
3
-
4
- [dev]
5
- run = ["npm", "run", "dev"]
6
- deps = ["git"] # -> apt install git
7
-
8
- [deploy]
9
- build = ["npm", "run", "build"]
10
- run = ["npm", "run", "start"]
11
- deps = ["git"] # -> apt install git
@@ -1,121 +0,0 @@
1
- {
2
- "[css]": {
3
- "editor.defaultFormatter": "esbenp.prettier-vscode"
4
- },
5
- "[dotenv]": {
6
- "editor.defaultFormatter": "foxundermoon.shell-format"
7
- },
8
- "[html]": {
9
- "editor.defaultFormatter": "esbenp.prettier-vscode"
10
- },
11
- "[ignore]": {
12
- "editor.defaultFormatter": "foxundermoon.shell-format"
13
- },
14
- "[javascript]": {
15
- "editor.defaultFormatter": "esbenp.prettier-vscode"
16
- },
17
- "[javascriptreact]": {
18
- "editor.defaultFormatter": "esbenp.prettier-vscode"
19
- },
20
- "[json]": {
21
- "editor.defaultFormatter": "esbenp.prettier-vscode"
22
- },
23
- "[jsonc]": {
24
- "editor.defaultFormatter": "esbenp.prettier-vscode"
25
- },
26
- "[less]": {
27
- "editor.defaultFormatter": "stylelint.vscode-stylelint"
28
- },
29
- "[scss]": {
30
- "editor.defaultFormatter": "esbenp.prettier-vscode"
31
- },
32
- "[shellscript]": {
33
- "editor.defaultFormatter": "foxundermoon.shell-format"
34
- },
35
- "[sql]": {
36
- "editor.defaultFormatter": "adpyke.vscode-sql-formatter"
37
- },
38
- "[svg]": {
39
- "editor.defaultFormatter": "jock.svg"
40
- },
41
- "[typescript]": {
42
- "editor.defaultFormatter": "esbenp.prettier-vscode"
43
- },
44
- "[typescriptreact]": {
45
- "editor.defaultFormatter": "esbenp.prettier-vscode"
46
- },
47
- "[xml]": {
48
- "editor.defaultFormatter": "mblode.pretty-formatter"
49
- },
50
- "[yaml]": {
51
- "editor.defaultFormatter": "esbenp.prettier-vscode"
52
- },
53
- "cSpell.diagnosticLevel": "Warning",
54
- "css.validate": false,
55
- "editor.codeActionsOnSave": {
56
- "source.fixAll": "never",
57
- "source.fixAll.eslint": "explicit",
58
- "source.organizeImports": "never",
59
- "source.removeUnused": "never",
60
- "source.removeUnused.ts": "never",
61
- "source.removeUnusedImports": "never",
62
- "source.sort.json": "never"
63
- // "source.sortImports": "always"
64
- },
65
- "editor.defaultFormatter": "esbenp.prettier-vscode",
66
- "editor.formatOnPaste": false,
67
- "editor.formatOnSave": true,
68
- "editor.formatOnType": false,
69
- "editor.insertSpaces": true,
70
- "editor.minimap.enabled": true,
71
- //
72
- "editor.rulers": [80, 120],
73
- "editor.semanticHighlighting.enabled": false,
74
- "editor.tabSize": 2,
75
- "emmet.triggerExpansionOnTab": true,
76
- "files.associations": {
77
- ".babelrc": "json",
78
- ".code-workspace": "jsonc",
79
- ".eslintrc": "jsonc",
80
- ".eslintrc*.json": "jsonc",
81
- ".htmlhintrc": "jsonc",
82
- ".stylelintrc": "javascript",
83
- "*.json": "jsonc",
84
- "*.log": "plaintext",
85
- "*.map": "plaintext",
86
- "**/coverage/**/*.*": "plaintext",
87
- "**/pnpm-lock.yaml": "plaintext",
88
- "htmlhintrc": "jsonc",
89
- "package.json": "json",
90
- "README": "markdown",
91
- "stylelintrc": "jsonc",
92
- ".coze": "toml"
93
- },
94
- "files.defaultLanguage": "plaintext",
95
- "files.eol": "\n",
96
- "files.exclude": {
97
- "**/.DS_Store": true,
98
- "**/.git": true,
99
- "**/.hg": true,
100
- "**/.svn": true,
101
- // "**/.lintcache": true,
102
- "**/.swc": true,
103
- "**/CVS": true,
104
- "**/Thumbs.db": true
105
- },
106
- "files.insertFinalNewline": true,
107
- "files.trimTrailingWhitespace": true,
108
- "files.watcherExclude": {
109
- "**/.git/objects/**": true,
110
- "**/.git/subtree-cache/**": true,
111
- "**/node_modules/*/**": true
112
- },
113
- "git.openRepositoryInParentFolders": "always",
114
- "search.exclude": {
115
- "**/dist": true,
116
- "**/node_modules": true
117
- },
118
- // "editor.formatOnSaveMode": "modificationsIfAvailable",
119
- "search.followSymlinks": false,
120
- "search.useIgnoreFiles": true
121
- }
@@ -1,61 +0,0 @@
1
- # <%= appName %>
2
-
3
- React + TypeScript application built with Rsbuild.
4
-
5
- ## Getting Started
6
-
7
- Install dependencies:
8
-
9
- ```bash
10
- npm install
11
- ```
12
-
13
- Start development server:
14
-
15
- ```bash
16
- npm run dev
17
- ```
18
-
19
- Or use coze-coding CLI:
20
-
21
- ```bash
22
- coze-coding dev
23
- ```
24
-
25
- ## Build
26
-
27
- Build for production:
28
-
29
- ```bash
30
- npm run build
31
- ```
32
-
33
- Or:
34
-
35
- ```bash
36
- coze-coding build
37
- ```
38
-
39
- ## Preview
40
-
41
- Preview production build:
42
-
43
- ```bash
44
- npm run preview
45
- ```
46
-
47
- Or:
48
-
49
- ```bash
50
- coze-coding start
51
- ```
52
-
53
- ## Configuration
54
-
55
- - Dev Server Port: <%= port %>
56
-
57
- ## Tech Stack
58
-
59
- - React 18
60
- - TypeScript
61
- - Rsbuild
@@ -1,97 +0,0 @@
1
- # Dependencies
2
- node_modules/
3
- .pnp
4
- .pnp.js
5
-
6
- # Production build
7
- dist/
8
- build/
9
- out/
10
- .next/
11
- .rsbuild/
12
-
13
- # Testing
14
- coverage/
15
- *.lcov
16
- .nyc_output
17
-
18
- # Environment variables
19
- .env
20
- .env.local
21
- .env.development.local
22
- .env.test.local
23
- .env.production.local
24
-
25
- # Logs
26
- logs/
27
- *.log
28
- npm-debug.log*
29
- yarn-debug.log*
30
- yarn-error.log*
31
- pnpm-debug.log*
32
- lerna-debug.log*
33
-
34
- # Runtime data
35
- pids
36
- *.pid
37
- *.seed
38
- *.pid.lock
39
-
40
- # Diagnostic reports
41
- report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
42
-
43
- # Cache
44
- .cache/
45
- .parcel-cache/
46
- .eslintcache
47
- .stylelintcache
48
- .npm
49
- .yarn/cache
50
- .yarn/unplugged
51
- .yarn/build-state.yml
52
- .yarn/install-state.gz
53
-
54
- # Editor directories and files
55
- .vscode/*
56
- !.vscode/extensions.json
57
- !.vscode/settings.json
58
- .idea/
59
- *.suo
60
- *.ntvs*
61
- *.njsproj
62
- *.sln
63
- *.sw?
64
- *.swp
65
- *.swo
66
- *~
67
-
68
- # OS files
69
- .DS_Store
70
- .DS_Store?
71
- ._*
72
- .Spotlight-V100
73
- .Trashes
74
- ehthumbs.db
75
- Thumbs.db
76
- Desktop.ini
77
-
78
- # Temporary files
79
- *.tmp
80
- *.temp
81
- .tmp/
82
- .temp/
83
-
84
- # Optional files
85
- *.tgz
86
- *.gz
87
- *.zip
88
- *.tar
89
-
90
- # TypeScript
91
- *.tsbuildinfo
92
-
93
- # Misc
94
- .vercel
95
- .turbo
96
-
97
- .coze-logs
@@ -1,31 +0,0 @@
1
- {
2
- "name": "<%= appName %>",
3
- "version": "1.0.0",
4
- "private": true,
5
- "description": "React application with Rsbuild",
6
- "scripts": {
7
- "build": "bash ./scripts/build.sh",
8
- "dev": "bash ./scripts/dev.sh",
9
- "preinstall": "npx only-allow pnpm",
10
- "lint": "eslint",
11
- "start": "bash ./scripts/start.sh"
12
- },
13
- "dependencies": {
14
- "react": "^19",
15
- "react-dom": "^19"
16
- },
17
- "devDependencies": {
18
- "@rsbuild/core": "^1.1.0",
19
- "@rsbuild/plugin-react": "^1.0.2",
20
- "@types/react": "^19",
21
- "@types/react-dom": "^19",
22
- "only-allow": "^1.2.2",
23
- "rsbuild-plugin-tailwindcss": "^0.2.1",
24
- "tailwindcss": "^3.4.17",
25
- "typescript": "^5.6.0"
26
- },
27
- "packageManager": "pnpm@9.0.0",
28
- "engines": {
29
- "pnpm": ">=9.0.0"
30
- }
31
- }