@lark-apaas/fullstack-cli 1.1.6-alpha.6 → 1.1.6-alpha.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.6-alpha.6",
3
+ "version": "1.1.6-alpha.8",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -12,9 +12,7 @@
12
12
  "bin"
13
13
  ],
14
14
  "scripts": {
15
- "build": "tsup",
16
- "test": "vitest run",
17
- "test:watch": "vitest",
15
+ "build": "tsc",
18
16
  "prepublishOnly": "npm run build"
19
17
  },
20
18
  "keywords": [
@@ -32,20 +30,13 @@
32
30
  },
33
31
  "dependencies": {
34
32
  "@lark-apaas/devtool-kits": "^1.2.10",
35
- "@lark-apaas/http-client": "0.1.2",
36
33
  "@vercel/nft": "^0.30.3",
37
- "commander": "^13.0.0",
34
+ "cac": "^6.7.14",
38
35
  "dotenv": "^16.0.0",
39
- "drizzle-kit": "0.31.5",
40
- "zod-to-json-schema": "^3.24.1"
36
+ "drizzle-kit": "0.31.5"
41
37
  },
42
38
  "devDependencies": {
43
39
  "@types/node": "^22.0.0",
44
- "tsup": "^8.3.5",
45
- "typescript": "^5.9.2",
46
- "vitest": "^2.1.8"
47
- },
48
- "peerDependencies": {
49
40
  "typescript": "^5.9.2"
50
41
  }
51
42
  }
@@ -19,28 +19,21 @@ print_time() {
19
19
  }
20
20
 
21
21
  # ==================== 步骤 0 ====================
22
- echo "🗑️ [0/5] 安装插件"
23
- STEP_START=$(node -e "console.log(Date.now())")
24
- npx fullstack-cli action-plugin init
25
- print_time $STEP_START
26
- echo ""
27
-
28
- # ==================== 步骤 1 ====================
29
- echo "📝 [1/5] 更新 openapi 代码"
22
+ echo "📝 [0/4] 更新 openapi 代码"
30
23
  STEP_START=$(node -e "console.log(Date.now())")
31
24
  npm run gen:openapi
32
25
  print_time $STEP_START
33
26
  echo ""
34
27
 
35
- # ==================== 步骤 2 ====================
36
- echo "🗑️ [2/5] 清理 dist 目录"
28
+ # ==================== 步骤 1 ====================
29
+ echo "🗑️ [1/4] 清理 dist 目录"
37
30
  STEP_START=$(node -e "console.log(Date.now())")
38
31
  rm -rf "$ROOT_DIR/dist"
39
32
  print_time $STEP_START
40
33
  echo ""
41
34
 
42
- # ==================== 步骤 3 ====================
43
- echo "🔨 [3/5] 并行构建 server 和 client"
35
+ # ==================== 步骤 2 ====================
36
+ echo "🔨 [2/4] 并行构建 server 和 client"
44
37
  STEP_START=$(node -e "console.log(Date.now())")
45
38
 
46
39
  # 并行构建
@@ -77,8 +70,8 @@ echo " ✅ Client 构建完成"
77
70
  print_time $STEP_START
78
71
  echo ""
79
72
 
80
- # ==================== 步骤 4 ====================
81
- echo "📦 [4/5] 准备 server 依赖产物"
73
+ # ==================== 步骤 3 ====================
74
+ echo "📦 [3/4] 准备 server 依赖产物"
82
75
  STEP_START=$(node -e "console.log(Date.now())")
83
76
 
84
77
  mkdir -p "$OUT_DIR/dist/client"
@@ -96,8 +89,8 @@ rm -rf "$ROOT_DIR/dist/tsconfig.node.tsbuildinfo"
96
89
  print_time $STEP_START
97
90
  echo ""
98
91
 
99
- # ==================== 步骤 5 ====================
100
- echo "✂️ [5/5] 智能依赖裁剪"
92
+ # ==================== 步骤 4 ====================
93
+ echo "✂️ [4/4] 智能依赖裁剪"
101
94
  STEP_START=$(node -e "console.log(Date.now())")
102
95
 
103
96
  # 分析实际依赖、复制并裁剪 node_modules、生成精简的 package.json
@@ -38,4 +38,4 @@ mkdir -p "${LOG_DIR}"
38
38
 
39
39
  concurrently -p "[{time}] [{name}]" -t "yyyy-MM-dd HH:mm:ss" -n "server,client" -c "blue,green" \
40
40
  "npm run dev:server" \
41
- "sleep 2 && npm run dev:client" 2>&1 | split_logs "${LOG_DIR}"
41
+ "npm run dev:client" 2>&1 | split_logs "${LOG_DIR}"
@@ -178,41 +178,9 @@ async function smartPrune() {
178
178
  }
179
179
  }
180
180
 
181
- console.log(`📦 静态分析需要 ${requiredPackages.size} 个 npm 包`);
181
+ console.log(`📦 实际需要 ${requiredPackages.size} 个 npm 包\n`);
182
182
 
183
- // 4. 处理 actionPlugins(动态加载的插件,无法被静态分析追踪)
184
- const originalPackage = JSON.parse(fs.readFileSync(ROOT_PACKAGE_JSON, 'utf8'));
185
- const actionPlugins = originalPackage.actionPlugins || {};
186
- const actionPluginNames = Object.keys(actionPlugins);
187
-
188
- if (actionPluginNames.length > 0) {
189
- console.log(`🔌 发现 ${actionPluginNames.length} 个 Action 插件,添加到依赖列表...`);
190
-
191
- for (const pluginName of actionPluginNames) {
192
- requiredPackages.add(pluginName);
193
-
194
- // 检查插件的 peerDependencies,也添加进去
195
- const pluginPkgPath = path.join(ROOT_NODE_MODULES, pluginName, 'package.json');
196
- if (fs.existsSync(pluginPkgPath)) {
197
- try {
198
- const pluginPkg = JSON.parse(fs.readFileSync(pluginPkgPath, 'utf8'));
199
- if (pluginPkg.peerDependencies) {
200
- for (const peerDep of Object.keys(pluginPkg.peerDependencies)) {
201
- requiredPackages.add(peerDep);
202
- }
203
- }
204
- } catch {
205
- // 忽略解析错误
206
- }
207
- }
208
- }
209
-
210
- console.log(` ✅ 插件: ${actionPluginNames.join(', ')}`);
211
- }
212
-
213
- console.log(`📦 总共需要 ${requiredPackages.size} 个 npm 包\n`);
214
-
215
- // 5. 选择性复制包(只复制需要的)
183
+ // 4. 选择性复制包(只复制需要的)
216
184
  console.log('📋 选择性复制 node_modules(仅复制需要的包)...');
217
185
  const copyStart = Date.now();
218
186
 
@@ -224,15 +192,16 @@ async function smartPrune() {
224
192
  console.log(` 成功: ${copiedCount.success} 个包,失败: ${copiedCount.failed} 个`);
225
193
  console.log(` 硬链接: ${fileStats.hardLinks} 个文件,复制: ${fileStats.copies} 个文件\n`);
226
194
 
227
- // 6. 生成精简版 package.json
195
+ // 5. 读取原始 package.json 并生成精简版本
196
+ const originalPackage = JSON.parse(fs.readFileSync(ROOT_PACKAGE_JSON, 'utf8'));
197
+
228
198
  // 优化:直接构建 dependencies,避免多次对象展开
229
199
  const prunedDependencies = {};
230
200
  const allDeps = originalPackage.dependencies || {};
231
201
  const allDevDeps = originalPackage.devDependencies || {};
232
202
 
233
203
  for (const pkg of requiredPackages) {
234
- // 优先从 dependencies/devDependencies 获取版本,其次从 actionPlugins 获取
235
- const version = allDeps[pkg] || allDevDeps[pkg] || actionPlugins[pkg];
204
+ const version = allDeps[pkg] || allDevDeps[pkg];
236
205
  if (version) {
237
206
  prunedDependencies[pkg] = version;
238
207
  }
@@ -253,14 +222,11 @@ async function smartPrune() {
253
222
 
254
223
  const totalElapsed = Date.now() - totalStartTime;
255
224
 
256
- // 7. 输出统计信息
225
+ // 6. 输出统计信息
257
226
  console.log('='.repeat(60));
258
227
  console.log('📊 智能裁剪统计:');
259
228
  console.log('='.repeat(60));
260
229
  console.log(` 需要的包数量: ${requiredPackages.size}`);
261
- if (actionPluginNames.length > 0) {
262
- console.log(` Action 插件: ${actionPluginNames.length} 个`);
263
- }
264
230
  console.log(` 成功复制: ${copiedCount.success} 个包`);
265
231
  console.log(` 失败: ${copiedCount.failed} 个包`);
266
232
  console.log(` 硬链接文件: ${fileStats.hardLinks} 个`);
@@ -1,25 +0,0 @@
1
- {
2
- "$schema": "https://json.schemastore.org/nest-cli",
3
- "collection": "@nestjs/schematics",
4
- "sourceRoot": "server",
5
- "compilerOptions": {
6
- "deleteOutDir": true,
7
- "tsConfigPath": "tsconfig.node.json",
8
- "assets": [
9
- {
10
- "include": "capabilities/**/*.json",
11
- "outDir": "dist/server",
12
- "watchAssets": true
13
- }
14
- ],
15
- "plugins": [
16
- {
17
- "name": "@nestjs/swagger",
18
- "options": {
19
- "introspectComments": true,
20
- "classValidatorShim": true
21
- }
22
- }
23
- ]
24
- }
25
- }