@lark-apaas/fullstack-cli 1.1.3 → 1.1.5-alpha.0

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.
@@ -53,6 +53,22 @@ export async function run(options) {
53
53
  * 执行单个同步规则
54
54
  */
55
55
  async function syncRule(rule, pluginRoot, userProjectRoot) {
56
+ // 处理删除操作(只需要 to 路径)
57
+ if (rule.type === 'delete-file' || rule.type === 'delete-directory') {
58
+ const destPath = path.join(userProjectRoot, rule.to);
59
+ if (rule.type === 'delete-file') {
60
+ deleteFile(destPath);
61
+ }
62
+ else {
63
+ deleteDirectory(destPath);
64
+ }
65
+ return;
66
+ }
67
+ // TypeScript 类型窄化:使用 'from' in rule 确保类型安全
68
+ if (!('from' in rule)) {
69
+ return;
70
+ }
71
+ // 处理需要源文件的操作(CopyRule 和 AppendRule)
56
72
  const srcPath = path.join(pluginRoot, rule.from);
57
73
  const destPath = path.join(userProjectRoot, rule.to);
58
74
  if (!fs.existsSync(srcPath)) {
@@ -69,8 +85,6 @@ async function syncRule(rule, pluginRoot, userProjectRoot) {
69
85
  case 'append':
70
86
  appendToFile(srcPath, destPath);
71
87
  break;
72
- default:
73
- console.warn(`[fullstack-cli] Unknown sync type: ${rule.type}`);
74
88
  }
75
89
  }
76
90
  /**
@@ -162,3 +176,29 @@ function setPermissions(permissions, projectRoot) {
162
176
  }
163
177
  }
164
178
  }
179
+ /**
180
+ * 删除单个文件
181
+ * @param filePath 要删除的文件路径
182
+ */
183
+ function deleteFile(filePath) {
184
+ if (fs.existsSync(filePath)) {
185
+ fs.unlinkSync(filePath);
186
+ console.log(`[fullstack-cli] ✓ ${path.basename(filePath)} (deleted)`);
187
+ }
188
+ else {
189
+ console.log(`[fullstack-cli] ○ ${path.basename(filePath)} (not found)`);
190
+ }
191
+ }
192
+ /**
193
+ * 删除整个目录
194
+ * @param dirPath 要删除的目录路径
195
+ */
196
+ function deleteDirectory(dirPath) {
197
+ if (fs.existsSync(dirPath)) {
198
+ fs.rmSync(dirPath, { recursive: true });
199
+ console.log(`[fullstack-cli] ✓ ${path.basename(dirPath)} (deleted)`);
200
+ }
201
+ else {
202
+ console.log(`[fullstack-cli] ○ ${path.basename(dirPath)} (not found)`);
203
+ }
204
+ }
@@ -2,16 +2,35 @@
2
2
  * fullstack-cli 派生配置
3
3
  * 定义哪些文件/目录需要同步到用户项目
4
4
  */
5
- export interface SyncRule {
5
+ /** 复制目录或文件规则 */
6
+ type CopyRule = {
6
7
  /** 源文件/目录路径(相对于插件根目录) */
7
8
  from: string;
8
9
  /** 目标文件/目录路径(相对于用户项目根目录) */
9
10
  to: string;
10
11
  /** 同步类型 */
11
- type: 'directory' | 'file' | 'append';
12
- /** 是否覆盖已存在的文件(仅 directory 和 file 类型有效) */
12
+ type: 'directory' | 'file';
13
+ /** 是否覆盖已存在的文件 */
13
14
  overwrite?: boolean;
14
- }
15
+ };
16
+ /** 追加内容规则 */
17
+ type AppendRule = {
18
+ /** 源文件路径(相对于插件根目录) */
19
+ from: string;
20
+ /** 目标文件路径(相对于用户项目根目录) */
21
+ to: string;
22
+ /** 同步类型 */
23
+ type: 'append';
24
+ };
25
+ /** 删除文件或目录规则 */
26
+ type DeleteRule = {
27
+ /** 目标文件/目录路径(相对于用户项目根目录) */
28
+ to: string;
29
+ /** 同步类型 */
30
+ type: 'delete-file' | 'delete-directory';
31
+ };
32
+ /** 同步规则联合类型 */
33
+ export type SyncRule = CopyRule | AppendRule | DeleteRule;
15
34
  export interface SyncConfig {
16
35
  /** 派生规则 */
17
36
  sync: SyncRule[];
@@ -21,3 +40,4 @@ export interface SyncConfig {
21
40
  export declare function genSyncConfig(perms?: {
22
41
  disableGenOpenapi?: boolean;
23
42
  }): SyncConfig;
43
+ export {};
@@ -24,6 +24,10 @@ const syncConfig = {
24
24
  // to: 'server/types/global.d.ts',
25
25
  // type: 'file',
26
26
  // },
27
+ {
28
+ type: 'delete-directory',
29
+ to: '.swc', // 删除 .swc 目录(如果存在)
30
+ },
27
31
  ],
28
32
  // 文件权限设置
29
33
  permissions: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.3",
3
+ "version": "1.1.5-alpha.0",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -29,7 +29,7 @@
29
29
  "access": "public"
30
30
  },
31
31
  "dependencies": {
32
- "@lark-apaas/devtool-kits": "^1.2.3",
32
+ "@lark-apaas/devtool-kits": "^1.2.8-alpha.2",
33
33
  "@vercel/nft": "^0.30.3",
34
34
  "cac": "^6.7.14",
35
35
  "dotenv": "^16.0.0",
@@ -24,8 +24,8 @@ async function generateOpenApi() {
24
24
  needSetupServer: false,
25
25
  needGenerateClientSdk: true,
26
26
  });
27
-
28
- await app.close();
27
+
28
+ process.exit(0); // 主动退出进程,不等待 app 关闭(用户存在场景,未释放 timer 导致 app 卡死问题)
29
29
  }
30
30
 
31
31
  generateOpenApi().catch((err) => {