axhub-make 1.0.5 → 1.0.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.
@@ -127,6 +127,9 @@ CLI 会检测目标目录是否包含:
127
127
  "src/**",
128
128
  "assets/**"
129
129
  ],
130
+ "alwaysOverwrite": [
131
+ "src/common/**"
132
+ ],
130
133
  "conflictCheck": [
131
134
  "package.json"
132
135
  ],
@@ -134,12 +137,17 @@ CLI 会检测目标目录是否包含:
134
137
  }
135
138
  ```
136
139
 
137
- **冲突文件分类:**
140
+ **冲突文件分类(优先级从高到低):**
141
+ - `alwaysOverwrite`:**最高优先级**,强制覆盖的文件
142
+ - 即使文件匹配 `neverOverwrite` 规则,也会被覆盖
143
+ - 当前配置:`src/common/**`(脚手架公共代码,需要保持同步)
144
+ - 使用场景:框架核心文件、类型定义等需要随模板更新的文件
138
145
  - `conflictCheck`:需要检查的文件(如配置文件)
139
146
  - 当前配置:`package.json`
140
147
  - 未来可能添加:`vite.config.ts`、`tsconfig.json` 等
141
148
  - `neverOverwrite`:永不覆盖的文件(如用户数据)
142
149
  - 当前配置:`src/**`、`assets/**`(用户业务代码和资源)
150
+ - 注意:会被 `alwaysOverwrite` 规则覆盖
143
151
  - `defaultOverwrite`:默认行为(true = 其他文件默认覆盖)
144
152
 
145
153
  **你的工作流程:**
@@ -243,9 +251,12 @@ CLI 会检测目标目录是否包含:
243
251
  原因:此文件在 conflictCheck 列表中,可能包含你的自定义依赖
244
252
 
245
253
  ℹ️ 以下文件会被保护,不会覆盖:
246
- • src/** - 你的业务代码
254
+ • src/** - 你的业务代码(除了 src/common/**)
247
255
  • assets/** - 你的资源文件
248
256
 
257
+ ℹ️ 以下文件会强制更新(保持与模板同步):
258
+ • src/common/** - 脚手架公共代码和类型定义
259
+
249
260
  请选择处理方式:
250
261
 
251
262
  1️⃣ 保留 - 保留你的本地版本(推荐,安全)
@@ -283,13 +294,14 @@ CLI 会检测目标目录是否包含:
283
294
  ✅ 会自动更新的文件:
284
295
  • vite.config.ts
285
296
  • tsconfig.json
297
+ • src/common/** - 脚手架公共代码(强制更新)
286
298
  • 其他脚手架文件
287
299
 
288
300
  ⚠️ 需要确认的冲突文件:
289
301
  • package.json(在 conflictCheck 列表中)
290
302
 
291
303
  🔒 永不覆盖的文件:
292
- • src/** - 你的业务代码
304
+ • src/** - 你的业务代码(除了 src/common/**)
293
305
  • assets/** - 你的资源文件
294
306
 
295
307
  当前冲突文件:package.json
package/bin/index.js CHANGED
@@ -55,6 +55,7 @@ async function readUpdateRules(tmpDir) {
55
55
  return {
56
56
  schemaVersion: 1,
57
57
  neverOverwrite: [],
58
+ alwaysOverwrite: [],
58
59
  conflictCheck: [],
59
60
  defaultOverwrite: true
60
61
  };
@@ -63,6 +64,7 @@ async function readUpdateRules(tmpDir) {
63
64
  return {
64
65
  schemaVersion: typeof rules.schemaVersion === 'number' ? rules.schemaVersion : 1,
65
66
  neverOverwrite: Array.isArray(rules.neverOverwrite) ? rules.neverOverwrite : [],
67
+ alwaysOverwrite: Array.isArray(rules.alwaysOverwrite) ? rules.alwaysOverwrite : [],
66
68
  conflictCheck: Array.isArray(rules.conflictCheck) ? rules.conflictCheck : [],
67
69
  defaultOverwrite: typeof rules.defaultOverwrite === 'boolean' ? rules.defaultOverwrite : true
68
70
  };
@@ -138,6 +140,12 @@ async function planUpdateFromTemplate(tmpDir, targetDir, rules, conflictMode) {
138
140
  continue;
139
141
  }
140
142
 
143
+ // alwaysOverwrite 优先级最高,即使匹配 neverOverwrite 也要覆盖
144
+ if (matchesAny(relPosix, rules.alwaysOverwrite)) {
145
+ copied.push(relPosix);
146
+ continue;
147
+ }
148
+
141
149
  if (matchesAny(relPosix, rules.neverOverwrite) && destExists) {
142
150
  skipped.push(relPosix);
143
151
  continue;
@@ -183,6 +191,14 @@ async function applyUpdateFromTemplate(tmpDir, targetDir, rules, conflictMode) {
183
191
  continue;
184
192
  }
185
193
 
194
+ // alwaysOverwrite 优先级最高,即使匹配 neverOverwrite 也要覆盖
195
+ if (matchesAny(relPosix, rules.alwaysOverwrite)) {
196
+ await fs.ensureDir(path.dirname(destPath));
197
+ await fs.copyFile(srcPath, destPath);
198
+ copied.push(relPosix);
199
+ continue;
200
+ }
201
+
186
202
  if (matchesAny(relPosix, rules.neverOverwrite) && destExists) {
187
203
  skipped.push(relPosix);
188
204
  continue;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "axhub-make",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Axhub Make scaffolding tool",
5
5
  "bin": {
6
6
  "axhub-make": "./bin/index.js"
@@ -10,13 +10,18 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "^4.1.2",
13
+ "class-variance-authority": "^0.7.1",
14
+ "clsx": "^2.1.1",
13
15
  "download-git-repo": "^3.0.2",
14
16
  "fs-extra": "^10.0.0",
15
- "inquirer": "^8.2.0"
17
+ "inquirer": "^8.2.0",
18
+ "tailwind-merge": "^3.4.0"
16
19
  },
17
20
  "author": "Lintendo",
18
21
  "license": "ISC",
19
22
  "devDependencies": {
20
- "execa": "^9.6.1"
23
+ "@tailwindcss/vite": "^4.1.18",
24
+ "execa": "^9.6.1",
25
+ "tailwindcss": "^4.1.18"
21
26
  }
22
27
  }
package/TEST.md DELETED
@@ -1,76 +0,0 @@
1
- # 测试指南
2
-
3
- ## 快速测试
4
-
5
- ```bash
6
- npm test
7
- # 或
8
- node test.js
9
- ```
10
-
11
- ## 测试覆盖
12
-
13
- 测试文件 `test.js` 覆盖以下功能:
14
-
15
- ### 1. 核心工具函数
16
- - ✅ `globToRegExp` - glob 模式转正则表达式
17
- - ✅ `matchesAny` - 文件路径匹配
18
- - ✅ `normalizeRelPath` - 路径标准化
19
-
20
- ### 2. 参数解析
21
- - ✅ 目录参数解析
22
- - ✅ 命令行选项(--no-install, --no-start, --pm, --conflict)
23
-
24
- ### 3. 文件操作
25
- - ✅ 临时目录创建和清理
26
- - ✅ 文件内容比较
27
-
28
- ## 手动测试
29
-
30
- ### 测试新项目创建
31
-
32
- ```bash
33
- # 在临时目录测试
34
- mkdir /tmp/test-axhub && cd /tmp/test-axhub
35
- npx axhub-make my-project --no-start
36
-
37
- # 验证项目结构
38
- ls -la my-project
39
- ```
40
-
41
- ### 测试项目更新
42
-
43
- ```bash
44
- # 在已有项目中测试
45
- cd existing-axhub-project
46
- npx axhub-make --no-start
47
-
48
- # 检查是否正确处理冲突文件
49
- ```
50
-
51
- ### 测试 GitHub 可访问性
52
-
53
- ```bash
54
- # 测试会自动检测 GitHub 连接并切换到 Gitee(如果需要)
55
- npx axhub-make test-project
56
- ```
57
-
58
- ### 测试冲突处理
59
-
60
- ```bash
61
- # 保持本地文件(默认)
62
- npx axhub-make --conflict keep
63
-
64
- # 覆盖冲突文件
65
- npx axhub-make --conflict overwrite
66
- ```
67
-
68
- ## 发布前检查清单
69
-
70
- - [ ] 运行 `npm test` 确保所有测试通过
71
- - [ ] 测试新项目创建
72
- - [ ] 测试项目更新
73
- - [ ] 测试 GitHub/Gitee 自动切换
74
- - [ ] 测试不同包管理器(npm, yarn, pnpm)
75
- - [ ] 检查 package.json 版本号
76
- - [ ] 更新 CHANGELOG