@lark-apaas/fullstack-cli 1.1.45-alpha.4 → 1.1.45-alpha.5

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/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
- import fs29 from "fs";
3
- import path25 from "path";
2
+ import fs28 from "fs";
3
+ import path24 from "path";
4
4
  import { fileURLToPath as fileURLToPath5 } from "url";
5
5
  import { config as dotenvConfig } from "dotenv";
6
6
 
@@ -2365,43 +2365,21 @@ var genDbSchemaCommand = {
2365
2365
  };
2366
2366
 
2367
2367
  // src/commands/sync/run.handler.ts
2368
- import path6 from "path";
2369
- import fs8 from "fs";
2368
+ import path4 from "path";
2369
+ import fs6 from "fs";
2370
2370
  import { fileURLToPath as fileURLToPath3 } from "url";
2371
2371
 
2372
2372
  // src/config/sync.ts
2373
2373
  var syncConfig = {
2374
2374
  // 派生规则
2375
2375
  sync: [
2376
- // 1. 派生 scripts 目录(总是覆盖;递归同步,包含 scripts/hooks/run-precommit.js)
2376
+ // 1. 派生 scripts 目录(总是覆盖)
2377
2377
  {
2378
2378
  from: "templates/scripts",
2379
2379
  to: "scripts",
2380
2380
  type: "directory",
2381
2381
  overwrite: true
2382
2382
  },
2383
- // 1a. 同步 .husky 目录(hook 入口,可执行 sh 脚本)
2384
- {
2385
- from: "templates/.husky",
2386
- to: ".husky",
2387
- type: "directory",
2388
- overwrite: true
2389
- },
2390
- // 1b. scripts.prepare:npm install 后自动激活 git hooks(不依赖 husky 库)
2391
- // 直接写 core.hooksPath,并保底给 pre-commit 加执行位;非 git 仓库下静默退出
2392
- {
2393
- type: "add-script",
2394
- name: "prepare",
2395
- command: "chmod +x .husky/pre-commit 2>/dev/null; git config core.hooksPath .husky 2>/dev/null || true",
2396
- overwrite: false
2397
- },
2398
- // 1c. scripts.precommit = pre-commit 真正的执行体(npm run lint + read-logs ×5)
2399
- {
2400
- type: "add-script",
2401
- name: "precommit",
2402
- command: "node scripts/hooks/run-precommit.js",
2403
- overwrite: false
2404
- },
2405
2383
  // 2. 智能合并 nest-cli.json 配置(保留用户自定义的 assets、plugins 等)
2406
2384
  {
2407
2385
  from: "templates/nest-cli.json",
@@ -2462,6 +2440,14 @@ var syncConfig = {
2462
2440
  to: ".spark_project",
2463
2441
  type: "file",
2464
2442
  overwrite: true
2443
+ },
2444
+ // 9. 把模板版本的 lint 脚本替换为支持 --files 的 runner
2445
+ // 只识别平台模板生成的 `concurrently ...` 形态,用户真正改写过的脚本保持原样
2446
+ {
2447
+ type: "patch-script",
2448
+ name: "lint",
2449
+ to: "node ./scripts/lint.js",
2450
+ ifStartsWith: "concurrently "
2465
2451
  }
2466
2452
  ],
2467
2453
  // 文件权限设置
@@ -2549,133 +2535,18 @@ function deepMergeJson(user, template, arrayMerge = {}, currentPath = "") {
2549
2535
  return result;
2550
2536
  }
2551
2537
 
2552
- // src/utils/package-json.ts
2553
- import fs6 from "fs";
2554
- import path4 from "path";
2555
- var LEGACY_LINT_SCRIPT = 'concurrently "npm run eslint" "npm run type:check" "npm run stylelint"';
2556
- var PATCHED_LINT_SCRIPT = "node ./scripts/lint.js";
2557
- function readPackageJson(cwd = process.cwd()) {
2558
- const pkgPath = path4.join(cwd, "package.json");
2559
- if (!fs6.existsSync(pkgPath)) {
2560
- throw new Error(`package.json not found at ${pkgPath}`);
2561
- }
2562
- const content = fs6.readFileSync(pkgPath, "utf-8");
2563
- return JSON.parse(content);
2564
- }
2565
- function writePackageJson(pkg2, cwd = process.cwd()) {
2566
- const pkgPath = path4.join(cwd, "package.json");
2567
- const content = JSON.stringify(pkg2, null, 2) + "\n";
2568
- fs6.writeFileSync(pkgPath, content, "utf-8");
2569
- }
2570
- function patchLintScriptForFilesSupport(pkg2) {
2571
- const currentLint = pkg2.scripts?.lint;
2572
- if (!currentLint) {
2573
- return "skipped-missing";
2574
- }
2575
- if (currentLint === PATCHED_LINT_SCRIPT || currentLint === "node scripts/lint.js") {
2576
- return "already-patched";
2577
- }
2578
- if (currentLint !== LEGACY_LINT_SCRIPT) {
2579
- return "skipped-custom";
2580
- }
2581
- pkg2.scripts = pkg2.scripts || {};
2582
- pkg2.scripts.lint = PATCHED_LINT_SCRIPT;
2583
- return "patched";
2584
- }
2585
- function removeUpgradeScript(pkg2) {
2586
- if (!pkg2.scripts?.upgrade) {
2587
- return false;
2588
- }
2589
- delete pkg2.scripts.upgrade;
2590
- return true;
2591
- }
2592
- function cleanDevScript(pkg2) {
2593
- if (!pkg2.scripts?.dev) {
2594
- return false;
2595
- }
2596
- const originalDev = pkg2.scripts.dev;
2597
- const cleanedDev = originalDev.replace(/npm\s+run\s+upgrade\s*&&\s*/g, "").replace(/npm\s+run\s+upgrade\s*$/g, "").trim();
2598
- if (cleanedDev !== originalDev) {
2599
- pkg2.scripts.dev = cleanedDev;
2600
- return true;
2601
- }
2602
- return false;
2603
- }
2604
- function cleanupPackageJson(cwd = process.cwd()) {
2605
- try {
2606
- const pkg2 = readPackageJson(cwd);
2607
- let changed = false;
2608
- if (removeUpgradeScript(pkg2)) {
2609
- console.log("[fullstack-cli] \u2713 Removed scripts.upgrade");
2610
- changed = true;
2611
- }
2612
- if (cleanDevScript(pkg2)) {
2613
- console.log("[fullstack-cli] \u2713 Cleaned scripts.dev (removed npm run upgrade)");
2614
- changed = true;
2615
- }
2616
- if (changed) {
2617
- writePackageJson(pkg2, cwd);
2618
- }
2619
- return changed;
2620
- } catch (error) {
2621
- const message = error instanceof Error ? error.message : String(error);
2622
- console.log(`[fullstack-cli] \u26A0 Could not cleanup package.json: ${message}`);
2623
- return false;
2624
- }
2625
- }
2626
-
2627
- // src/commands/sync/install-husky.ts
2628
- import fs7 from "fs";
2629
- import path5 from "path";
2630
- import { spawnSync as spawnSync2 } from "child_process";
2631
- function activateGitHooks(userProjectRoot) {
2632
- if (!fs7.existsSync(path5.join(userProjectRoot, ".git"))) {
2633
- return { action: "skipped-no-git" };
2634
- }
2635
- const hookFile = path5.join(userProjectRoot, ".husky", "pre-commit");
2636
- if (!fs7.existsSync(hookFile)) {
2637
- return { action: "skipped-no-hook-file" };
2638
- }
2639
- let changed = false;
2640
- const currentMode = fs7.statSync(hookFile).mode & 511;
2641
- if ((currentMode & 73) !== 73) {
2642
- fs7.chmodSync(hookFile, 493);
2643
- changed = true;
2644
- }
2645
- const probe = spawnSync2("git", ["config", "--get", "core.hooksPath"], {
2646
- cwd: userProjectRoot,
2647
- stdio: ["ignore", "pipe", "ignore"]
2648
- });
2649
- const currentHooksPath = probe.stdout ? probe.stdout.toString().trim() : "";
2650
- if (currentHooksPath !== ".husky") {
2651
- const res = spawnSync2("git", ["config", "core.hooksPath", ".husky"], {
2652
- cwd: userProjectRoot,
2653
- stdio: ["ignore", "inherit", "inherit"]
2654
- });
2655
- if (res.status !== 0) {
2656
- throw new Error(`git config core.hooksPath exited with ${String(res.status)}`);
2657
- }
2658
- changed = true;
2659
- }
2660
- if (changed) {
2661
- console.log("[fullstack-cli] \u2713 git hooks activated (core.hooksPath -> .husky)");
2662
- return { action: "activated" };
2663
- }
2664
- return { action: "already-active" };
2665
- }
2666
-
2667
2538
  // src/commands/sync/run.handler.ts
2668
2539
  async function run2(options) {
2669
2540
  const userProjectRoot = process.env.INIT_CWD || process.cwd();
2670
2541
  const __filename = fileURLToPath3(import.meta.url);
2671
- const __dirname2 = path6.dirname(__filename);
2672
- const pluginRoot = path6.resolve(__dirname2, "..");
2542
+ const __dirname2 = path4.dirname(__filename);
2543
+ const pluginRoot = path4.resolve(__dirname2, "..");
2673
2544
  if (userProjectRoot === pluginRoot) {
2674
2545
  console.log("[fullstack-cli] Skip syncing (installing plugin itself)");
2675
2546
  process.exit(0);
2676
2547
  }
2677
- const userPackageJson = path6.join(userProjectRoot, "package.json");
2678
- if (!fs8.existsSync(userPackageJson)) {
2548
+ const userPackageJson = path4.join(userProjectRoot, "package.json");
2549
+ if (!fs6.existsSync(userPackageJson)) {
2679
2550
  console.log("[fullstack-cli] Skip syncing (not a valid npm project)");
2680
2551
  process.exit(0);
2681
2552
  }
@@ -2691,16 +2562,9 @@ async function run2(options) {
2691
2562
  for (const rule of config.sync) {
2692
2563
  await syncRule(rule, pluginRoot, userProjectRoot);
2693
2564
  }
2694
- patchUserPackageJson(userProjectRoot);
2695
2565
  if (config.permissions) {
2696
2566
  setPermissions(config.permissions, userProjectRoot);
2697
2567
  }
2698
- try {
2699
- activateGitHooks(userProjectRoot);
2700
- } catch (error) {
2701
- const message = error instanceof Error ? error.message : String(error);
2702
- console.warn(`[fullstack-cli] \u26A0 Failed to activate git hooks: ${message}`);
2703
- }
2704
2568
  console.log("[fullstack-cli] Sync completed successfully \u2705");
2705
2569
  } catch (error) {
2706
2570
  const message = error instanceof Error ? error.message : String(error);
@@ -2708,32 +2572,9 @@ async function run2(options) {
2708
2572
  process.exit(1);
2709
2573
  }
2710
2574
  }
2711
- function patchUserPackageJson(userProjectRoot) {
2712
- try {
2713
- const pkg2 = readPackageJson(userProjectRoot);
2714
- const lintPatchResult = patchLintScriptForFilesSupport(pkg2);
2715
- if (lintPatchResult === "patched") {
2716
- writePackageJson(pkg2, userProjectRoot);
2717
- console.log("[fullstack-cli] \u2713 Patched scripts.lint to support --files");
2718
- return;
2719
- }
2720
- if (lintPatchResult === "already-patched") {
2721
- console.log("[fullstack-cli] \u25CB scripts.lint already supports --files");
2722
- return;
2723
- }
2724
- if (lintPatchResult === "skipped-custom") {
2725
- console.warn(
2726
- "[fullstack-cli] \u26A0 Skipped patching scripts.lint because it has been customized"
2727
- );
2728
- }
2729
- } catch (error) {
2730
- const message = error instanceof Error ? error.message : String(error);
2731
- console.warn(`[fullstack-cli] \u26A0 Could not patch package.json: ${message}`);
2732
- }
2733
- }
2734
2575
  async function syncRule(rule, pluginRoot, userProjectRoot) {
2735
2576
  if (rule.type === "delete-file" || rule.type === "delete-directory") {
2736
- const destPath2 = path6.join(userProjectRoot, rule.to);
2577
+ const destPath2 = path4.join(userProjectRoot, rule.to);
2737
2578
  if (rule.type === "delete-file") {
2738
2579
  deleteFile(destPath2);
2739
2580
  } else {
@@ -2742,32 +2583,37 @@ async function syncRule(rule, pluginRoot, userProjectRoot) {
2742
2583
  return;
2743
2584
  }
2744
2585
  if (rule.type === "remove-line") {
2745
- const destPath2 = path6.join(userProjectRoot, rule.to);
2586
+ const destPath2 = path4.join(userProjectRoot, rule.to);
2746
2587
  removeLineFromFile(destPath2, rule.pattern);
2747
2588
  return;
2748
2589
  }
2749
2590
  if (rule.type === "add-script") {
2750
- const packageJsonPath = path6.join(userProjectRoot, "package.json");
2591
+ const packageJsonPath = path4.join(userProjectRoot, "package.json");
2751
2592
  addScript(packageJsonPath, rule.name, rule.command, rule.overwrite ?? false);
2752
2593
  return;
2753
2594
  }
2595
+ if (rule.type === "patch-script") {
2596
+ const packageJsonPath = path4.join(userProjectRoot, "package.json");
2597
+ patchScript(packageJsonPath, rule.name, rule.to, rule.ifStartsWith);
2598
+ return;
2599
+ }
2754
2600
  if (rule.type === "add-line") {
2755
- const destPath2 = path6.join(userProjectRoot, rule.to);
2601
+ const destPath2 = path4.join(userProjectRoot, rule.to);
2756
2602
  addLineToFile(destPath2, rule.line);
2757
2603
  return;
2758
2604
  }
2759
2605
  if (rule.type === "merge-json") {
2760
- const srcPath2 = path6.join(pluginRoot, rule.from);
2761
- const destPath2 = path6.join(userProjectRoot, rule.to);
2606
+ const srcPath2 = path4.join(pluginRoot, rule.from);
2607
+ const destPath2 = path4.join(userProjectRoot, rule.to);
2762
2608
  mergeJsonFile(srcPath2, destPath2, rule.arrayMerge);
2763
2609
  return;
2764
2610
  }
2765
2611
  if (!("from" in rule)) {
2766
2612
  return;
2767
2613
  }
2768
- const srcPath = path6.join(pluginRoot, rule.from);
2769
- const destPath = path6.join(userProjectRoot, rule.to);
2770
- if (!fs8.existsSync(srcPath)) {
2614
+ const srcPath = path4.join(pluginRoot, rule.from);
2615
+ const destPath = path4.join(userProjectRoot, rule.to);
2616
+ if (!fs6.existsSync(srcPath)) {
2771
2617
  console.warn(`[fullstack-cli] Source not found: ${rule.from}`);
2772
2618
  return;
2773
2619
  }
@@ -2784,68 +2630,68 @@ async function syncRule(rule, pluginRoot, userProjectRoot) {
2784
2630
  }
2785
2631
  }
2786
2632
  function syncFile(src, dest, overwrite = true, onlyIfExists = false) {
2787
- if (onlyIfExists && !fs8.existsSync(dest)) {
2788
- console.log(`[fullstack-cli] \u25CB ${path6.basename(dest)} (skipped, target not exists)`);
2633
+ if (onlyIfExists && !fs6.existsSync(dest)) {
2634
+ console.log(`[fullstack-cli] \u25CB ${path4.basename(dest)} (skipped, target not exists)`);
2789
2635
  return;
2790
2636
  }
2791
- const destDir = path6.dirname(dest);
2792
- if (!fs8.existsSync(destDir)) {
2793
- fs8.mkdirSync(destDir, { recursive: true });
2637
+ const destDir = path4.dirname(dest);
2638
+ if (!fs6.existsSync(destDir)) {
2639
+ fs6.mkdirSync(destDir, { recursive: true });
2794
2640
  }
2795
- if (fs8.existsSync(dest) && !overwrite) {
2796
- console.log(`[fullstack-cli] \u25CB ${path6.basename(dest)} (skipped, already exists)`);
2641
+ if (fs6.existsSync(dest) && !overwrite) {
2642
+ console.log(`[fullstack-cli] \u25CB ${path4.basename(dest)} (skipped, already exists)`);
2797
2643
  return;
2798
2644
  }
2799
- fs8.copyFileSync(src, dest);
2800
- console.log(`[fullstack-cli] \u2713 ${path6.basename(dest)}`);
2645
+ fs6.copyFileSync(src, dest);
2646
+ console.log(`[fullstack-cli] \u2713 ${path4.basename(dest)}`);
2801
2647
  }
2802
2648
  function syncDirectory(src, dest, overwrite = true) {
2803
- if (!fs8.existsSync(dest)) {
2804
- fs8.mkdirSync(dest, { recursive: true });
2649
+ if (!fs6.existsSync(dest)) {
2650
+ fs6.mkdirSync(dest, { recursive: true });
2805
2651
  }
2806
- const files = fs8.readdirSync(src);
2652
+ const files = fs6.readdirSync(src);
2807
2653
  let count = 0;
2808
2654
  files.forEach((file) => {
2809
- const srcFile = path6.join(src, file);
2810
- const destFile = path6.join(dest, file);
2811
- const stats = fs8.statSync(srcFile);
2655
+ const srcFile = path4.join(src, file);
2656
+ const destFile = path4.join(dest, file);
2657
+ const stats = fs6.statSync(srcFile);
2812
2658
  if (stats.isDirectory()) {
2813
2659
  syncDirectory(srcFile, destFile, overwrite);
2814
2660
  } else {
2815
- if (overwrite || !fs8.existsSync(destFile)) {
2816
- fs8.copyFileSync(srcFile, destFile);
2817
- console.log(`[fullstack-cli] \u2713 ${path6.relative(dest, destFile)}`);
2661
+ if (overwrite || !fs6.existsSync(destFile)) {
2662
+ fs6.copyFileSync(srcFile, destFile);
2663
+ console.log(`[fullstack-cli] \u2713 ${path4.relative(dest, destFile)}`);
2818
2664
  count++;
2819
2665
  }
2820
2666
  }
2821
2667
  });
2822
2668
  if (count > 0) {
2823
- console.log(`[fullstack-cli] Synced ${count} files to ${path6.basename(dest)}/`);
2669
+ console.log(`[fullstack-cli] Synced ${count} files to ${path4.basename(dest)}/`);
2824
2670
  }
2825
2671
  }
2826
2672
  function appendToFile(src, dest) {
2827
- const content = fs8.readFileSync(src, "utf-8");
2673
+ const content = fs6.readFileSync(src, "utf-8");
2828
2674
  let existingContent = "";
2829
- if (fs8.existsSync(dest)) {
2830
- existingContent = fs8.readFileSync(dest, "utf-8");
2675
+ if (fs6.existsSync(dest)) {
2676
+ existingContent = fs6.readFileSync(dest, "utf-8");
2831
2677
  }
2832
2678
  if (existingContent.includes(content.trim())) {
2833
- console.log(`[fullstack-cli] \u25CB ${path6.basename(dest)} (already contains content)`);
2679
+ console.log(`[fullstack-cli] \u25CB ${path4.basename(dest)} (already contains content)`);
2834
2680
  return;
2835
2681
  }
2836
- fs8.appendFileSync(dest, content);
2837
- console.log(`[fullstack-cli] \u2713 ${path6.basename(dest)} (appended)`);
2682
+ fs6.appendFileSync(dest, content);
2683
+ console.log(`[fullstack-cli] \u2713 ${path4.basename(dest)} (appended)`);
2838
2684
  }
2839
2685
  function setPermissions(permissions, projectRoot) {
2840
2686
  for (const [pattern, mode] of Object.entries(permissions)) {
2841
2687
  if (pattern === "**/*.sh") {
2842
- const scriptsDir = path6.join(projectRoot, "scripts");
2843
- if (fs8.existsSync(scriptsDir)) {
2844
- const files = fs8.readdirSync(scriptsDir);
2688
+ const scriptsDir = path4.join(projectRoot, "scripts");
2689
+ if (fs6.existsSync(scriptsDir)) {
2690
+ const files = fs6.readdirSync(scriptsDir);
2845
2691
  files.forEach((file) => {
2846
2692
  if (file.endsWith(".sh")) {
2847
- const filePath = path6.join(scriptsDir, file);
2848
- fs8.chmodSync(filePath, mode);
2693
+ const filePath = path4.join(scriptsDir, file);
2694
+ fs6.chmodSync(filePath, mode);
2849
2695
  }
2850
2696
  });
2851
2697
  }
@@ -2853,27 +2699,27 @@ function setPermissions(permissions, projectRoot) {
2853
2699
  }
2854
2700
  }
2855
2701
  function deleteFile(filePath) {
2856
- if (fs8.existsSync(filePath)) {
2857
- fs8.unlinkSync(filePath);
2858
- console.log(`[fullstack-cli] \u2713 ${path6.basename(filePath)} (deleted)`);
2702
+ if (fs6.existsSync(filePath)) {
2703
+ fs6.unlinkSync(filePath);
2704
+ console.log(`[fullstack-cli] \u2713 ${path4.basename(filePath)} (deleted)`);
2859
2705
  } else {
2860
- console.log(`[fullstack-cli] \u25CB ${path6.basename(filePath)} (not found)`);
2706
+ console.log(`[fullstack-cli] \u25CB ${path4.basename(filePath)} (not found)`);
2861
2707
  }
2862
2708
  }
2863
2709
  function deleteDirectory(dirPath) {
2864
- if (fs8.existsSync(dirPath)) {
2865
- fs8.rmSync(dirPath, { recursive: true });
2866
- console.log(`[fullstack-cli] \u2713 ${path6.basename(dirPath)} (deleted)`);
2710
+ if (fs6.existsSync(dirPath)) {
2711
+ fs6.rmSync(dirPath, { recursive: true });
2712
+ console.log(`[fullstack-cli] \u2713 ${path4.basename(dirPath)} (deleted)`);
2867
2713
  } else {
2868
- console.log(`[fullstack-cli] \u25CB ${path6.basename(dirPath)} (not found)`);
2714
+ console.log(`[fullstack-cli] \u25CB ${path4.basename(dirPath)} (not found)`);
2869
2715
  }
2870
2716
  }
2871
2717
  function addScript(packageJsonPath, name, command, overwrite) {
2872
- if (!fs8.existsSync(packageJsonPath)) {
2718
+ if (!fs6.existsSync(packageJsonPath)) {
2873
2719
  console.log(`[fullstack-cli] \u25CB package.json (not found)`);
2874
2720
  return;
2875
2721
  }
2876
- const content = fs8.readFileSync(packageJsonPath, "utf-8");
2722
+ const content = fs6.readFileSync(packageJsonPath, "utf-8");
2877
2723
  const pkg2 = JSON.parse(content);
2878
2724
  if (!pkg2.scripts) {
2879
2725
  pkg2.scripts = {};
@@ -2885,42 +2731,73 @@ function addScript(packageJsonPath, name, command, overwrite) {
2885
2731
  }
2886
2732
  }
2887
2733
  pkg2.scripts[name] = command;
2888
- fs8.writeFileSync(packageJsonPath, JSON.stringify(pkg2, null, 2) + "\n");
2734
+ fs6.writeFileSync(packageJsonPath, JSON.stringify(pkg2, null, 2) + "\n");
2889
2735
  console.log(`[fullstack-cli] \u2713 scripts.${name}`);
2890
2736
  }
2737
+ function patchScript(packageJsonPath, name, to, ifStartsWith) {
2738
+ if (!fs6.existsSync(packageJsonPath)) {
2739
+ console.log(`[fullstack-cli] \u25CB package.json (not found)`);
2740
+ return;
2741
+ }
2742
+ try {
2743
+ const content = fs6.readFileSync(packageJsonPath, "utf-8");
2744
+ const pkg2 = JSON.parse(content);
2745
+ const current = pkg2.scripts?.[name];
2746
+ if (!current) {
2747
+ console.log(`[fullstack-cli] \u25CB scripts.${name} (not present, skipped)`);
2748
+ return;
2749
+ }
2750
+ if (current === to) {
2751
+ console.log(`[fullstack-cli] \u25CB scripts.${name} (already patched)`);
2752
+ return;
2753
+ }
2754
+ if (!current.startsWith(ifStartsWith)) {
2755
+ console.warn(
2756
+ `[fullstack-cli] \u26A0 Skipped patching scripts.${name} because it has been customized`
2757
+ );
2758
+ return;
2759
+ }
2760
+ pkg2.scripts[name] = to;
2761
+ fs6.writeFileSync(packageJsonPath, JSON.stringify(pkg2, null, 2) + "\n");
2762
+ console.log(`[fullstack-cli] \u2713 Patched scripts.${name}`);
2763
+ } catch (error) {
2764
+ const message = error instanceof Error ? error.message : String(error);
2765
+ console.warn(`[fullstack-cli] \u26A0 Could not patch scripts.${name}: ${message}`);
2766
+ }
2767
+ }
2891
2768
  function addLineToFile(filePath, line) {
2892
- const fileName = path6.basename(filePath);
2893
- if (!fs8.existsSync(filePath)) {
2769
+ const fileName = path4.basename(filePath);
2770
+ if (!fs6.existsSync(filePath)) {
2894
2771
  console.log(`[fullstack-cli] \u25CB ${fileName} (not found, skipped)`);
2895
2772
  return;
2896
2773
  }
2897
- const content = fs8.readFileSync(filePath, "utf-8");
2774
+ const content = fs6.readFileSync(filePath, "utf-8");
2898
2775
  const lines = content.split("\n").map((l) => l.trim());
2899
2776
  if (lines.includes(line)) {
2900
2777
  console.log(`[fullstack-cli] \u25CB ${fileName} (line already exists: ${line})`);
2901
2778
  return;
2902
2779
  }
2903
2780
  const appendContent = (content.endsWith("\n") ? "" : "\n") + line + "\n";
2904
- fs8.appendFileSync(filePath, appendContent);
2781
+ fs6.appendFileSync(filePath, appendContent);
2905
2782
  console.log(`[fullstack-cli] \u2713 ${fileName} (added: ${line})`);
2906
2783
  }
2907
2784
  function mergeJsonFile(src, dest, arrayMerge) {
2908
- const fileName = path6.basename(dest);
2909
- if (!fs8.existsSync(src)) {
2785
+ const fileName = path4.basename(dest);
2786
+ if (!fs6.existsSync(src)) {
2910
2787
  console.warn(`[fullstack-cli] Source not found: ${src}`);
2911
2788
  return;
2912
2789
  }
2913
- const templateContent = JSON.parse(fs8.readFileSync(src, "utf-8"));
2914
- if (!fs8.existsSync(dest)) {
2915
- const destDir = path6.dirname(dest);
2916
- if (!fs8.existsSync(destDir)) {
2917
- fs8.mkdirSync(destDir, { recursive: true });
2790
+ const templateContent = JSON.parse(fs6.readFileSync(src, "utf-8"));
2791
+ if (!fs6.existsSync(dest)) {
2792
+ const destDir = path4.dirname(dest);
2793
+ if (!fs6.existsSync(destDir)) {
2794
+ fs6.mkdirSync(destDir, { recursive: true });
2918
2795
  }
2919
- fs8.writeFileSync(dest, JSON.stringify(templateContent, null, 2) + "\n");
2796
+ fs6.writeFileSync(dest, JSON.stringify(templateContent, null, 2) + "\n");
2920
2797
  console.log(`[fullstack-cli] \u2713 ${fileName} (created)`);
2921
2798
  return;
2922
2799
  }
2923
- const userContent = JSON.parse(fs8.readFileSync(dest, "utf-8"));
2800
+ const userContent = JSON.parse(fs6.readFileSync(dest, "utf-8"));
2924
2801
  const merged = deepMergeJson(userContent, templateContent, arrayMerge ?? {});
2925
2802
  const userStr = JSON.stringify(userContent, null, 2);
2926
2803
  const mergedStr = JSON.stringify(merged, null, 2);
@@ -2928,7 +2805,7 @@ function mergeJsonFile(src, dest, arrayMerge) {
2928
2805
  console.log(`[fullstack-cli] \u25CB ${fileName} (already up to date)`);
2929
2806
  return;
2930
2807
  }
2931
- fs8.writeFileSync(dest, mergedStr + "\n");
2808
+ fs6.writeFileSync(dest, mergedStr + "\n");
2932
2809
  console.log(`[fullstack-cli] \u2713 ${fileName} (merged)`);
2933
2810
  }
2934
2811
 
@@ -2988,16 +2865,16 @@ async function reportCreateInstanceEvent(pluginKey, version) {
2988
2865
  }
2989
2866
 
2990
2867
  // src/utils/git.ts
2991
- import { execSync, spawnSync as spawnSync3 } from "child_process";
2992
- import fs9 from "fs";
2993
- import path7 from "path";
2868
+ import { execSync, spawnSync as spawnSync2 } from "child_process";
2869
+ import fs7 from "fs";
2870
+ import path5 from "path";
2994
2871
  function isGitRepository(cwd = process.cwd()) {
2995
2872
  try {
2996
- const gitDir = path7.join(cwd, ".git");
2997
- if (fs9.existsSync(gitDir)) {
2873
+ const gitDir = path5.join(cwd, ".git");
2874
+ if (fs7.existsSync(gitDir)) {
2998
2875
  return true;
2999
2876
  }
3000
- const result = spawnSync3("git", ["rev-parse", "--git-dir"], {
2877
+ const result = spawnSync2("git", ["rev-parse", "--git-dir"], {
3001
2878
  cwd,
3002
2879
  stdio: "pipe",
3003
2880
  encoding: "utf-8"
@@ -3023,11 +2900,11 @@ function getChangedFiles(cwd = process.cwd()) {
3023
2900
  function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
3024
2901
  const filteredFiles = [];
3025
2902
  for (const filePath of filesToStage) {
3026
- if (fs9.existsSync(path7.join(cwd, filePath))) {
2903
+ if (fs7.existsSync(path5.join(cwd, filePath))) {
3027
2904
  filteredFiles.push(filePath);
3028
2905
  continue;
3029
2906
  }
3030
- const tracked = spawnSync3("git", ["ls-files", "--error-unmatch", "--", filePath], {
2907
+ const tracked = spawnSync2("git", ["ls-files", "--error-unmatch", "--", filePath], {
3031
2908
  cwd,
3032
2909
  stdio: "pipe",
3033
2910
  encoding: "utf-8"
@@ -3039,7 +2916,7 @@ function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
3039
2916
  if (filteredFiles.length === 0) {
3040
2917
  return;
3041
2918
  }
3042
- const result = spawnSync3("git", ["add", "--", ...filteredFiles], {
2919
+ const result = spawnSync2("git", ["add", "--", ...filteredFiles], {
3043
2920
  cwd,
3044
2921
  stdio: "pipe",
3045
2922
  encoding: "utf-8"
@@ -3050,7 +2927,7 @@ function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
3050
2927
  }
3051
2928
  }
3052
2929
  function hasStagedChanges(cwd = process.cwd()) {
3053
- const result = spawnSync3("git", ["diff", "--cached", "--quiet"], {
2930
+ const result = spawnSync2("git", ["diff", "--cached", "--quiet"], {
3054
2931
  cwd,
3055
2932
  stdio: "pipe",
3056
2933
  encoding: "utf-8"
@@ -3065,7 +2942,7 @@ function hasStagedChanges(cwd = process.cwd()) {
3065
2942
  throw new Error(`Failed to check staged changes: ${errorMsg}`);
3066
2943
  }
3067
2944
  function gitCommit(message, cwd = process.cwd()) {
3068
- const result = spawnSync3("git", ["commit", "-m", message], {
2945
+ const result = spawnSync2("git", ["commit", "-m", message], {
3069
2946
  cwd,
3070
2947
  stdio: "pipe",
3071
2948
  encoding: "utf-8"
@@ -3107,16 +2984,74 @@ Auto-committed by fullstack-cli`;
3107
2984
  }
3108
2985
  }
3109
2986
 
2987
+ // src/utils/package-json.ts
2988
+ import fs8 from "fs";
2989
+ import path6 from "path";
2990
+ function readPackageJson(cwd = process.cwd()) {
2991
+ const pkgPath = path6.join(cwd, "package.json");
2992
+ if (!fs8.existsSync(pkgPath)) {
2993
+ throw new Error(`package.json not found at ${pkgPath}`);
2994
+ }
2995
+ const content = fs8.readFileSync(pkgPath, "utf-8");
2996
+ return JSON.parse(content);
2997
+ }
2998
+ function writePackageJson(pkg2, cwd = process.cwd()) {
2999
+ const pkgPath = path6.join(cwd, "package.json");
3000
+ const content = JSON.stringify(pkg2, null, 2) + "\n";
3001
+ fs8.writeFileSync(pkgPath, content, "utf-8");
3002
+ }
3003
+ function removeUpgradeScript(pkg2) {
3004
+ if (!pkg2.scripts?.upgrade) {
3005
+ return false;
3006
+ }
3007
+ delete pkg2.scripts.upgrade;
3008
+ return true;
3009
+ }
3010
+ function cleanDevScript(pkg2) {
3011
+ if (!pkg2.scripts?.dev) {
3012
+ return false;
3013
+ }
3014
+ const originalDev = pkg2.scripts.dev;
3015
+ const cleanedDev = originalDev.replace(/npm\s+run\s+upgrade\s*&&\s*/g, "").replace(/npm\s+run\s+upgrade\s*$/g, "").trim();
3016
+ if (cleanedDev !== originalDev) {
3017
+ pkg2.scripts.dev = cleanedDev;
3018
+ return true;
3019
+ }
3020
+ return false;
3021
+ }
3022
+ function cleanupPackageJson(cwd = process.cwd()) {
3023
+ try {
3024
+ const pkg2 = readPackageJson(cwd);
3025
+ let changed = false;
3026
+ if (removeUpgradeScript(pkg2)) {
3027
+ console.log("[fullstack-cli] \u2713 Removed scripts.upgrade");
3028
+ changed = true;
3029
+ }
3030
+ if (cleanDevScript(pkg2)) {
3031
+ console.log("[fullstack-cli] \u2713 Cleaned scripts.dev (removed npm run upgrade)");
3032
+ changed = true;
3033
+ }
3034
+ if (changed) {
3035
+ writePackageJson(pkg2, cwd);
3036
+ }
3037
+ return changed;
3038
+ } catch (error) {
3039
+ const message = error instanceof Error ? error.message : String(error);
3040
+ console.log(`[fullstack-cli] \u26A0 Could not cleanup package.json: ${message}`);
3041
+ return false;
3042
+ }
3043
+ }
3044
+
3110
3045
  // src/commands/upgrade/shared/utils.ts
3111
- import path8 from "path";
3112
- import fs10 from "fs";
3046
+ import path7 from "path";
3047
+ import fs9 from "fs";
3113
3048
  import { fileURLToPath as fileURLToPath4 } from "url";
3114
3049
  function getCliVersion() {
3115
3050
  try {
3116
3051
  const __filename = fileURLToPath4(import.meta.url);
3117
- const __dirname2 = path8.dirname(__filename);
3118
- const pkgPath = path8.resolve(__dirname2, "../../../package.json");
3119
- const pkgContent = fs10.readFileSync(pkgPath, "utf-8");
3052
+ const __dirname2 = path7.dirname(__filename);
3053
+ const pkgPath = path7.resolve(__dirname2, "../../../package.json");
3054
+ const pkgContent = fs9.readFileSync(pkgPath, "utf-8");
3120
3055
  const pkg2 = JSON.parse(pkgContent);
3121
3056
  return pkg2.version || "unknown";
3122
3057
  } catch {
@@ -3174,9 +3109,9 @@ async function run3(options = {}) {
3174
3109
  }
3175
3110
 
3176
3111
  // src/commands/upgrade/deps/run.handler.ts
3177
- import { spawnSync as spawnSync4 } from "child_process";
3178
- import fs11 from "fs";
3179
- import path9 from "path";
3112
+ import { spawnSync as spawnSync3 } from "child_process";
3113
+ import fs10 from "fs";
3114
+ import path8 from "path";
3180
3115
 
3181
3116
  // src/utils/grayscale/config.ts
3182
3117
  function getGrayscaleConfig(configJson) {
@@ -3395,7 +3330,7 @@ function upgradePackages(packages, version, cwd) {
3395
3330
  packages.forEach((pkg2) => {
3396
3331
  const target = `${pkg2}@${version}`;
3397
3332
  console.log(`[fullstack-cli] Installing ${target}...`);
3398
- const result = spawnSync4("npm", ["install", target], {
3333
+ const result = spawnSync3("npm", ["install", target], {
3399
3334
  cwd,
3400
3335
  stdio: "inherit"
3401
3336
  });
@@ -3407,7 +3342,7 @@ function upgradePackages(packages, version, cwd) {
3407
3342
  console.log("[fullstack-cli] Upgrading to latest compatible versions...");
3408
3343
  packages.forEach((pkg2) => {
3409
3344
  console.log(`[fullstack-cli] Updating ${pkg2}...`);
3410
- const result = spawnSync4("npm", ["update", pkg2], {
3345
+ const result = spawnSync3("npm", ["update", pkg2], {
3411
3346
  cwd,
3412
3347
  stdio: "inherit"
3413
3348
  });
@@ -3424,8 +3359,8 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
3424
3359
  if (version) {
3425
3360
  let current = "";
3426
3361
  try {
3427
- const installedPkgPath = path9.join(cwd, "node_modules", pkg2, "package.json");
3428
- const installedPkg = JSON.parse(fs11.readFileSync(installedPkgPath, "utf-8"));
3362
+ const installedPkgPath = path8.join(cwd, "node_modules", pkg2, "package.json");
3363
+ const installedPkg = JSON.parse(fs10.readFileSync(installedPkgPath, "utf-8"));
3429
3364
  current = installedPkg.version || "";
3430
3365
  } catch (err) {
3431
3366
  const code = err?.code;
@@ -3468,7 +3403,7 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
3468
3403
  }
3469
3404
  const targets = upgradePlan.map(({ pkg: pkg2, version }) => `${pkg2}@${version}`);
3470
3405
  console.log(`[fullstack-cli] Installing ${targets.join(" ")}...`);
3471
- const result = spawnSync4("npm", ["install", ...targets], {
3406
+ const result = spawnSync3("npm", ["install", ...targets], {
3472
3407
  cwd,
3473
3408
  stdio: "inherit"
3474
3409
  });
@@ -3542,9 +3477,9 @@ var depsCommand = {
3542
3477
  };
3543
3478
 
3544
3479
  // src/commands/upgrade/global-deps/run.handler.ts
3545
- import { spawnSync as spawnSync5 } from "child_process";
3546
- import fs12 from "fs";
3547
- import path10 from "path";
3480
+ import { spawnSync as spawnSync4 } from "child_process";
3481
+ import fs11 from "fs";
3482
+ import path9 from "path";
3548
3483
  var MANAGED_GLOBAL_CLIS = [
3549
3484
  "@lark-apaas/fullstack-cli",
3550
3485
  "@lark-apaas/miaoda-cli"
@@ -3555,15 +3490,15 @@ function readGlobalInstalledVersion(pkg2) {
3555
3490
  if (process.env.NPM_CONFIG_PREFIX) candidates.push(process.env.NPM_CONFIG_PREFIX);
3556
3491
  candidates.push("/usr");
3557
3492
  candidates.push("/usr/local");
3558
- if (process.env.HOME) candidates.push(path10.join(process.env.HOME, ".npm-global"));
3493
+ if (process.env.HOME) candidates.push(path9.join(process.env.HOME, ".npm-global"));
3559
3494
  const seen = /* @__PURE__ */ new Set();
3560
3495
  for (const prefix of candidates) {
3561
3496
  if (seen.has(prefix)) continue;
3562
3497
  seen.add(prefix);
3563
3498
  try {
3564
- const pkgPath = path10.join(prefix, "lib", "node_modules", pkg2, "package.json");
3565
- if (fs12.existsSync(pkgPath)) {
3566
- const meta = JSON.parse(fs12.readFileSync(pkgPath, "utf-8"));
3499
+ const pkgPath = path9.join(prefix, "lib", "node_modules", pkg2, "package.json");
3500
+ if (fs11.existsSync(pkgPath)) {
3501
+ const meta = JSON.parse(fs11.readFileSync(pkgPath, "utf-8"));
3567
3502
  if (meta && typeof meta.version === "string") return meta.version;
3568
3503
  }
3569
3504
  } catch (err) {
@@ -3621,7 +3556,7 @@ async function run5(options = {}) {
3621
3556
  npmArgs.push("--registry", options.registry);
3622
3557
  }
3623
3558
  console.log(`[fullstack-cli] Running: npm ${npmArgs.join(" ")}`);
3624
- const result = spawnSync5("npm", npmArgs, { stdio: "inherit" });
3559
+ const result = spawnSync4("npm", npmArgs, { stdio: "inherit" });
3625
3560
  if (result.error || result.status !== 0) {
3626
3561
  console.warn(
3627
3562
  `[fullstack-cli] npm install -g failed: ${result.error?.message ?? `exit ${result.status}`}`
@@ -3660,9 +3595,9 @@ var upgradeCommand = {
3660
3595
  };
3661
3596
 
3662
3597
  // src/commands/action-plugin/utils.ts
3663
- import fs13 from "fs";
3664
- import path11 from "path";
3665
- import { spawnSync as spawnSync6, execSync as execSync2 } from "child_process";
3598
+ import fs12 from "fs";
3599
+ import path10 from "path";
3600
+ import { spawnSync as spawnSync5, execSync as execSync2 } from "child_process";
3666
3601
  function parsePluginName(input) {
3667
3602
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
3668
3603
  if (!match) {
@@ -3679,18 +3614,18 @@ function getProjectRoot() {
3679
3614
  return process.cwd();
3680
3615
  }
3681
3616
  function getPackageJsonPath() {
3682
- return path11.join(getProjectRoot(), "package.json");
3617
+ return path10.join(getProjectRoot(), "package.json");
3683
3618
  }
3684
3619
  function getPluginPath(pluginName) {
3685
- return path11.join(getProjectRoot(), "node_modules", pluginName);
3620
+ return path10.join(getProjectRoot(), "node_modules", pluginName);
3686
3621
  }
3687
3622
  function readPackageJson2() {
3688
3623
  const pkgPath = getPackageJsonPath();
3689
- if (!fs13.existsSync(pkgPath)) {
3624
+ if (!fs12.existsSync(pkgPath)) {
3690
3625
  throw new Error("package.json not found in current directory");
3691
3626
  }
3692
3627
  try {
3693
- const content = fs13.readFileSync(pkgPath, "utf-8");
3628
+ const content = fs12.readFileSync(pkgPath, "utf-8");
3694
3629
  return JSON.parse(content);
3695
3630
  } catch {
3696
3631
  throw new Error("Failed to parse package.json");
@@ -3698,7 +3633,7 @@ function readPackageJson2() {
3698
3633
  }
3699
3634
  function writePackageJson2(pkg2) {
3700
3635
  const pkgPath = getPackageJsonPath();
3701
- fs13.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3636
+ fs12.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3702
3637
  }
3703
3638
  function readActionPlugins() {
3704
3639
  const pkg2 = readPackageJson2();
@@ -3719,7 +3654,7 @@ function getInstalledPluginVersion(pluginName) {
3719
3654
  }
3720
3655
  function npmInstall(tgzPath) {
3721
3656
  console.log(`[action-plugin] Running npm install ${tgzPath}...`);
3722
- const result = spawnSync6("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
3657
+ const result = spawnSync5("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
3723
3658
  cwd: getProjectRoot(),
3724
3659
  stdio: "inherit"
3725
3660
  });
@@ -3731,12 +3666,12 @@ function npmInstall(tgzPath) {
3731
3666
  }
3732
3667
  }
3733
3668
  function getPackageVersion(pluginName) {
3734
- const pkgJsonPath = path11.join(getPluginPath(pluginName), "package.json");
3735
- if (!fs13.existsSync(pkgJsonPath)) {
3669
+ const pkgJsonPath = path10.join(getPluginPath(pluginName), "package.json");
3670
+ if (!fs12.existsSync(pkgJsonPath)) {
3736
3671
  return null;
3737
3672
  }
3738
3673
  try {
3739
- const content = fs13.readFileSync(pkgJsonPath, "utf-8");
3674
+ const content = fs12.readFileSync(pkgJsonPath, "utf-8");
3740
3675
  const pkg2 = JSON.parse(content);
3741
3676
  return pkg2.version || null;
3742
3677
  } catch {
@@ -3744,49 +3679,49 @@ function getPackageVersion(pluginName) {
3744
3679
  }
3745
3680
  }
3746
3681
  function readPluginPackageJson(pluginPath) {
3747
- const pkgJsonPath = path11.join(pluginPath, "package.json");
3748
- if (!fs13.existsSync(pkgJsonPath)) {
3682
+ const pkgJsonPath = path10.join(pluginPath, "package.json");
3683
+ if (!fs12.existsSync(pkgJsonPath)) {
3749
3684
  return null;
3750
3685
  }
3751
3686
  try {
3752
- const content = fs13.readFileSync(pkgJsonPath, "utf-8");
3687
+ const content = fs12.readFileSync(pkgJsonPath, "utf-8");
3753
3688
  return JSON.parse(content);
3754
3689
  } catch {
3755
3690
  return null;
3756
3691
  }
3757
3692
  }
3758
3693
  function extractTgzToNodeModules(tgzPath, pluginName) {
3759
- const nodeModulesPath = path11.join(getProjectRoot(), "node_modules");
3760
- const targetDir = path11.join(nodeModulesPath, pluginName);
3761
- const scopeDir = path11.dirname(targetDir);
3762
- if (!fs13.existsSync(scopeDir)) {
3763
- fs13.mkdirSync(scopeDir, { recursive: true });
3694
+ const nodeModulesPath = path10.join(getProjectRoot(), "node_modules");
3695
+ const targetDir = path10.join(nodeModulesPath, pluginName);
3696
+ const scopeDir = path10.dirname(targetDir);
3697
+ if (!fs12.existsSync(scopeDir)) {
3698
+ fs12.mkdirSync(scopeDir, { recursive: true });
3764
3699
  }
3765
- if (fs13.existsSync(targetDir)) {
3766
- fs13.rmSync(targetDir, { recursive: true });
3700
+ if (fs12.existsSync(targetDir)) {
3701
+ fs12.rmSync(targetDir, { recursive: true });
3767
3702
  }
3768
- const tempDir = path11.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3769
- if (fs13.existsSync(tempDir)) {
3770
- fs13.rmSync(tempDir, { recursive: true });
3703
+ const tempDir = path10.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3704
+ if (fs12.existsSync(tempDir)) {
3705
+ fs12.rmSync(tempDir, { recursive: true });
3771
3706
  }
3772
- fs13.mkdirSync(tempDir, { recursive: true });
3707
+ fs12.mkdirSync(tempDir, { recursive: true });
3773
3708
  try {
3774
3709
  execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
3775
- const extractedDir = path11.join(tempDir, "package");
3776
- if (fs13.existsSync(extractedDir)) {
3777
- fs13.renameSync(extractedDir, targetDir);
3710
+ const extractedDir = path10.join(tempDir, "package");
3711
+ if (fs12.existsSync(extractedDir)) {
3712
+ fs12.renameSync(extractedDir, targetDir);
3778
3713
  } else {
3779
- const files = fs13.readdirSync(tempDir);
3714
+ const files = fs12.readdirSync(tempDir);
3780
3715
  if (files.length === 1) {
3781
- fs13.renameSync(path11.join(tempDir, files[0]), targetDir);
3716
+ fs12.renameSync(path10.join(tempDir, files[0]), targetDir);
3782
3717
  } else {
3783
3718
  throw new Error("Unexpected tgz structure");
3784
3719
  }
3785
3720
  }
3786
3721
  return targetDir;
3787
3722
  } finally {
3788
- if (fs13.existsSync(tempDir)) {
3789
- fs13.rmSync(tempDir, { recursive: true });
3723
+ if (fs12.existsSync(tempDir)) {
3724
+ fs12.rmSync(tempDir, { recursive: true });
3790
3725
  }
3791
3726
  }
3792
3727
  }
@@ -3795,10 +3730,10 @@ function checkMissingPeerDeps(peerDeps) {
3795
3730
  return [];
3796
3731
  }
3797
3732
  const missing = [];
3798
- const nodeModulesPath = path11.join(getProjectRoot(), "node_modules");
3733
+ const nodeModulesPath = path10.join(getProjectRoot(), "node_modules");
3799
3734
  for (const [depName, _version] of Object.entries(peerDeps)) {
3800
- const depPath = path11.join(nodeModulesPath, depName);
3801
- if (!fs13.existsSync(depPath)) {
3735
+ const depPath = path10.join(nodeModulesPath, depName);
3736
+ if (!fs12.existsSync(depPath)) {
3802
3737
  missing.push(depName);
3803
3738
  }
3804
3739
  }
@@ -3809,7 +3744,7 @@ function installMissingDeps(deps) {
3809
3744
  return;
3810
3745
  }
3811
3746
  console.log(`[action-plugin] Installing missing dependencies: ${deps.join(", ")}`);
3812
- const result = spawnSync6("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
3747
+ const result = spawnSync5("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
3813
3748
  cwd: getProjectRoot(),
3814
3749
  stdio: "inherit"
3815
3750
  });
@@ -3822,16 +3757,16 @@ function installMissingDeps(deps) {
3822
3757
  }
3823
3758
  function removePluginDirectory(pluginName) {
3824
3759
  const pluginPath = getPluginPath(pluginName);
3825
- if (fs13.existsSync(pluginPath)) {
3826
- fs13.rmSync(pluginPath, { recursive: true });
3760
+ if (fs12.existsSync(pluginPath)) {
3761
+ fs12.rmSync(pluginPath, { recursive: true });
3827
3762
  console.log(`[action-plugin] Removed ${pluginName}`);
3828
3763
  }
3829
3764
  }
3830
3765
 
3831
3766
  // src/commands/action-plugin/api-client.ts
3832
3767
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
3833
- import fs14 from "fs";
3834
- import path12 from "path";
3768
+ import fs13 from "fs";
3769
+ import path11 from "path";
3835
3770
  var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
3836
3771
  async function getPluginVersions(keys, latestOnly = true) {
3837
3772
  const client = getHttpClient();
@@ -3895,19 +3830,19 @@ async function downloadFromPublic(downloadURL) {
3895
3830
  return Buffer.from(arrayBuffer);
3896
3831
  }
3897
3832
  function getPluginCacheDir() {
3898
- return path12.join(process.cwd(), PLUGIN_CACHE_DIR);
3833
+ return path11.join(process.cwd(), PLUGIN_CACHE_DIR);
3899
3834
  }
3900
3835
  function ensureCacheDir() {
3901
3836
  const cacheDir = getPluginCacheDir();
3902
- if (!fs14.existsSync(cacheDir)) {
3903
- fs14.mkdirSync(cacheDir, { recursive: true });
3837
+ if (!fs13.existsSync(cacheDir)) {
3838
+ fs13.mkdirSync(cacheDir, { recursive: true });
3904
3839
  }
3905
3840
  }
3906
3841
  function getTempFilePath(pluginKey, version) {
3907
3842
  ensureCacheDir();
3908
3843
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3909
3844
  const filename = `${safeKey}@${version}.tgz`;
3910
- return path12.join(getPluginCacheDir(), filename);
3845
+ return path11.join(getPluginCacheDir(), filename);
3911
3846
  }
3912
3847
  var MAX_RETRIES = 2;
3913
3848
  async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
@@ -3944,7 +3879,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
3944
3879
  );
3945
3880
  }
3946
3881
  const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
3947
- fs14.writeFileSync(tgzPath, tgzBuffer);
3882
+ fs13.writeFileSync(tgzPath, tgzBuffer);
3948
3883
  console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
3949
3884
  return {
3950
3885
  tgzPath,
@@ -3958,18 +3893,18 @@ function getCachePath(pluginKey, version) {
3958
3893
  ensureCacheDir();
3959
3894
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3960
3895
  const filename = `${safeKey}@${version}.tgz`;
3961
- return path12.join(getPluginCacheDir(), filename);
3896
+ return path11.join(getPluginCacheDir(), filename);
3962
3897
  }
3963
3898
  function hasCachedPlugin(pluginKey, version) {
3964
3899
  const cachePath = getCachePath(pluginKey, version);
3965
- return fs14.existsSync(cachePath);
3900
+ return fs13.existsSync(cachePath);
3966
3901
  }
3967
3902
  function listCachedPlugins() {
3968
3903
  const cacheDir = getPluginCacheDir();
3969
- if (!fs14.existsSync(cacheDir)) {
3904
+ if (!fs13.existsSync(cacheDir)) {
3970
3905
  return [];
3971
3906
  }
3972
- const files = fs14.readdirSync(cacheDir);
3907
+ const files = fs13.readdirSync(cacheDir);
3973
3908
  const result = [];
3974
3909
  for (const file of files) {
3975
3910
  if (!file.endsWith(".tgz")) continue;
@@ -3977,8 +3912,8 @@ function listCachedPlugins() {
3977
3912
  if (!match) continue;
3978
3913
  const [, rawName, version] = match;
3979
3914
  const name = rawName.replace(/^_/, "@").replace(/_/, "/");
3980
- const filePath = path12.join(cacheDir, file);
3981
- const stat = fs14.statSync(filePath);
3915
+ const filePath = path11.join(cacheDir, file);
3916
+ const stat = fs13.statSync(filePath);
3982
3917
  result.push({
3983
3918
  name,
3984
3919
  version,
@@ -3991,14 +3926,14 @@ function listCachedPlugins() {
3991
3926
  }
3992
3927
  function cleanAllCache() {
3993
3928
  const cacheDir = getPluginCacheDir();
3994
- if (!fs14.existsSync(cacheDir)) {
3929
+ if (!fs13.existsSync(cacheDir)) {
3995
3930
  return 0;
3996
3931
  }
3997
- const files = fs14.readdirSync(cacheDir);
3932
+ const files = fs13.readdirSync(cacheDir);
3998
3933
  let count = 0;
3999
3934
  for (const file of files) {
4000
3935
  if (file.endsWith(".tgz")) {
4001
- fs14.unlinkSync(path12.join(cacheDir, file));
3936
+ fs13.unlinkSync(path11.join(cacheDir, file));
4002
3937
  count++;
4003
3938
  }
4004
3939
  }
@@ -4006,21 +3941,21 @@ function cleanAllCache() {
4006
3941
  }
4007
3942
  function cleanPluginCache(pluginKey, version) {
4008
3943
  const cacheDir = getPluginCacheDir();
4009
- if (!fs14.existsSync(cacheDir)) {
3944
+ if (!fs13.existsSync(cacheDir)) {
4010
3945
  return 0;
4011
3946
  }
4012
3947
  const safeKey = pluginKey.replace(/[/@]/g, "_");
4013
- const files = fs14.readdirSync(cacheDir);
3948
+ const files = fs13.readdirSync(cacheDir);
4014
3949
  let count = 0;
4015
3950
  for (const file of files) {
4016
3951
  if (version) {
4017
3952
  if (file === `${safeKey}@${version}.tgz`) {
4018
- fs14.unlinkSync(path12.join(cacheDir, file));
3953
+ fs13.unlinkSync(path11.join(cacheDir, file));
4019
3954
  count++;
4020
3955
  }
4021
3956
  } else {
4022
3957
  if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
4023
- fs14.unlinkSync(path12.join(cacheDir, file));
3958
+ fs13.unlinkSync(path11.join(cacheDir, file));
4024
3959
  count++;
4025
3960
  }
4026
3961
  }
@@ -4447,40 +4382,40 @@ var actionPluginCommandGroup = {
4447
4382
  };
4448
4383
 
4449
4384
  // src/commands/capability/utils.ts
4450
- import fs15 from "fs";
4385
+ import fs14 from "fs";
4451
4386
  import { createRequire as createRequire2 } from "module";
4452
- import path13 from "path";
4387
+ import path12 from "path";
4453
4388
  var CAPABILITIES_DIR = "server/capabilities";
4454
4389
  function getProjectRoot2() {
4455
4390
  return process.cwd();
4456
4391
  }
4457
4392
  function getCapabilitiesDir() {
4458
- return path13.join(getProjectRoot2(), CAPABILITIES_DIR);
4393
+ return path12.join(getProjectRoot2(), CAPABILITIES_DIR);
4459
4394
  }
4460
4395
  function getCapabilityPath(id) {
4461
- return path13.join(getCapabilitiesDir(), `${id}.json`);
4396
+ return path12.join(getCapabilitiesDir(), `${id}.json`);
4462
4397
  }
4463
4398
  function getPluginManifestPath(pluginKey) {
4464
- return path13.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4399
+ return path12.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4465
4400
  }
4466
4401
  function capabilitiesDirExists() {
4467
- return fs15.existsSync(getCapabilitiesDir());
4402
+ return fs14.existsSync(getCapabilitiesDir());
4468
4403
  }
4469
4404
  function listCapabilityIds() {
4470
4405
  const dir = getCapabilitiesDir();
4471
- if (!fs15.existsSync(dir)) {
4406
+ if (!fs14.existsSync(dir)) {
4472
4407
  return [];
4473
4408
  }
4474
- const files = fs15.readdirSync(dir);
4409
+ const files = fs14.readdirSync(dir);
4475
4410
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
4476
4411
  }
4477
4412
  function readCapability(id) {
4478
4413
  const filePath = getCapabilityPath(id);
4479
- if (!fs15.existsSync(filePath)) {
4414
+ if (!fs14.existsSync(filePath)) {
4480
4415
  throw new Error(`Capability not found: ${id}`);
4481
4416
  }
4482
4417
  try {
4483
- const content = fs15.readFileSync(filePath, "utf-8");
4418
+ const content = fs14.readFileSync(filePath, "utf-8");
4484
4419
  return JSON.parse(content);
4485
4420
  } catch (error) {
4486
4421
  if (error instanceof SyntaxError) {
@@ -4507,11 +4442,11 @@ function readAllCapabilities() {
4507
4442
  }
4508
4443
  function readPluginManifest(pluginKey) {
4509
4444
  const manifestPath = getPluginManifestPath(pluginKey);
4510
- if (!fs15.existsSync(manifestPath)) {
4445
+ if (!fs14.existsSync(manifestPath)) {
4511
4446
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
4512
4447
  }
4513
4448
  try {
4514
- const content = fs15.readFileSync(manifestPath, "utf-8");
4449
+ const content = fs14.readFileSync(manifestPath, "utf-8");
4515
4450
  return JSON.parse(content);
4516
4451
  } catch (error) {
4517
4452
  if (error instanceof SyntaxError) {
@@ -4528,7 +4463,7 @@ function hasValidParamsSchema(paramsSchema) {
4528
4463
  }
4529
4464
  async function loadPlugin(pluginKey) {
4530
4465
  try {
4531
- const userRequire = createRequire2(path13.join(getProjectRoot2(), "package.json"));
4466
+ const userRequire = createRequire2(path12.join(getProjectRoot2(), "package.json"));
4532
4467
  const resolvedPath = userRequire.resolve(pluginKey);
4533
4468
  const pluginModule = await import(resolvedPath);
4534
4469
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -4691,8 +4626,8 @@ var capabilityCommandGroup = {
4691
4626
  import { execFile } from "child_process";
4692
4627
 
4693
4628
  // src/commands/component/registry-preparer.ts
4694
- import fs16 from "fs";
4695
- import path14 from "path";
4629
+ import fs15 from "fs";
4630
+ import path13 from "path";
4696
4631
  import os from "os";
4697
4632
 
4698
4633
  // src/commands/component/service.ts
@@ -4748,7 +4683,7 @@ async function sendInstallEvent(key) {
4748
4683
  }
4749
4684
 
4750
4685
  // src/commands/component/registry-preparer.ts
4751
- var REGISTRY_TEMP_DIR = path14.join(os.tmpdir(), "miaoda-registry");
4686
+ var REGISTRY_TEMP_DIR = path13.join(os.tmpdir(), "miaoda-registry");
4752
4687
  function parseComponentKey(key) {
4753
4688
  const match = key.match(/^@([^/]+)\/(.+)$/);
4754
4689
  if (!match) {
@@ -4760,11 +4695,11 @@ function parseComponentKey(key) {
4760
4695
  }
4761
4696
  function getLocalRegistryPath(key) {
4762
4697
  const { scope, name } = parseComponentKey(key);
4763
- return path14.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4698
+ return path13.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4764
4699
  }
4765
4700
  function ensureDir(dirPath) {
4766
- if (!fs16.existsSync(dirPath)) {
4767
- fs16.mkdirSync(dirPath, { recursive: true });
4701
+ if (!fs15.existsSync(dirPath)) {
4702
+ fs15.mkdirSync(dirPath, { recursive: true });
4768
4703
  }
4769
4704
  }
4770
4705
  async function prepareRecursive(key, visited) {
@@ -4797,8 +4732,8 @@ async function prepareRecursive(key, visited) {
4797
4732
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
4798
4733
  };
4799
4734
  const localPath = getLocalRegistryPath(key);
4800
- ensureDir(path14.dirname(localPath));
4801
- fs16.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4735
+ ensureDir(path13.dirname(localPath));
4736
+ fs15.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4802
4737
  debug("\u4FDD\u5B58\u5230: %s", localPath);
4803
4738
  }
4804
4739
  async function prepareComponentRegistryItems(id) {
@@ -4808,18 +4743,18 @@ async function prepareComponentRegistryItems(id) {
4808
4743
  }
4809
4744
  function cleanupTempDir() {
4810
4745
  try {
4811
- if (fs16.existsSync(REGISTRY_TEMP_DIR)) {
4812
- fs16.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4746
+ if (fs15.existsSync(REGISTRY_TEMP_DIR)) {
4747
+ fs15.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4813
4748
  }
4814
4749
  } catch {
4815
4750
  }
4816
4751
  }
4817
4752
  function getDownloadedRegistryItem(itemId) {
4818
4753
  const localPath = getLocalRegistryPath(itemId);
4819
- if (!fs16.existsSync(localPath)) {
4754
+ if (!fs15.existsSync(localPath)) {
4820
4755
  return null;
4821
4756
  }
4822
- const content = fs16.readFileSync(localPath, "utf-8");
4757
+ const content = fs15.readFileSync(localPath, "utf-8");
4823
4758
  return JSON.parse(content);
4824
4759
  }
4825
4760
 
@@ -4987,58 +4922,58 @@ var componentCommandGroup = {
4987
4922
  };
4988
4923
 
4989
4924
  // src/commands/migration/version-manager.ts
4990
- import fs17 from "fs";
4991
- import path15 from "path";
4925
+ import fs16 from "fs";
4926
+ import path14 from "path";
4992
4927
  var PACKAGE_JSON = "package.json";
4993
4928
  var VERSION_FIELD = "migrationVersion";
4994
4929
  function getPackageJsonPath2() {
4995
- return path15.join(process.cwd(), PACKAGE_JSON);
4930
+ return path14.join(process.cwd(), PACKAGE_JSON);
4996
4931
  }
4997
4932
  function getCurrentVersion() {
4998
4933
  const pkgPath = getPackageJsonPath2();
4999
- if (!fs17.existsSync(pkgPath)) {
4934
+ if (!fs16.existsSync(pkgPath)) {
5000
4935
  throw new Error("package.json not found");
5001
4936
  }
5002
- const pkg2 = JSON.parse(fs17.readFileSync(pkgPath, "utf-8"));
4937
+ const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
5003
4938
  return pkg2[VERSION_FIELD] ?? 0;
5004
4939
  }
5005
4940
  function setCurrentVersion(version) {
5006
4941
  const pkgPath = getPackageJsonPath2();
5007
- const pkg2 = JSON.parse(fs17.readFileSync(pkgPath, "utf-8"));
4942
+ const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
5008
4943
  pkg2[VERSION_FIELD] = version;
5009
- fs17.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4944
+ fs16.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
5010
4945
  }
5011
4946
 
5012
4947
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
5013
- import fs19 from "fs";
5014
- import path17 from "path";
5015
-
5016
- // src/commands/migration/versions/v001_capability/utils.ts
5017
4948
  import fs18 from "fs";
5018
4949
  import path16 from "path";
4950
+
4951
+ // src/commands/migration/versions/v001_capability/utils.ts
4952
+ import fs17 from "fs";
4953
+ import path15 from "path";
5019
4954
  var CAPABILITIES_DIR2 = "server/capabilities";
5020
4955
  function getProjectRoot3() {
5021
4956
  return process.cwd();
5022
4957
  }
5023
4958
  function getCapabilitiesDir2() {
5024
- return path16.join(getProjectRoot3(), CAPABILITIES_DIR2);
4959
+ return path15.join(getProjectRoot3(), CAPABILITIES_DIR2);
5025
4960
  }
5026
4961
  function getPluginManifestPath2(pluginKey) {
5027
- return path16.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4962
+ return path15.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
5028
4963
  }
5029
4964
 
5030
4965
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
5031
4966
  function detectJsonMigration() {
5032
4967
  const capabilitiesDir = getCapabilitiesDir2();
5033
- const oldFilePath = path17.join(capabilitiesDir, "capabilities.json");
5034
- if (!fs19.existsSync(oldFilePath)) {
4968
+ const oldFilePath = path16.join(capabilitiesDir, "capabilities.json");
4969
+ if (!fs18.existsSync(oldFilePath)) {
5035
4970
  return {
5036
4971
  needsMigration: false,
5037
4972
  reason: "capabilities.json not found"
5038
4973
  };
5039
4974
  }
5040
4975
  try {
5041
- const content = fs19.readFileSync(oldFilePath, "utf-8");
4976
+ const content = fs18.readFileSync(oldFilePath, "utf-8");
5042
4977
  const parsed = JSON.parse(content);
5043
4978
  if (!Array.isArray(parsed)) {
5044
4979
  return {
@@ -5089,8 +5024,8 @@ async function check(options) {
5089
5024
  }
5090
5025
 
5091
5026
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5092
- import fs20 from "fs";
5093
- import path18 from "path";
5027
+ import fs19 from "fs";
5028
+ import path17 from "path";
5094
5029
 
5095
5030
  // src/commands/migration/versions/v001_capability/mapping.ts
5096
5031
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -5320,18 +5255,18 @@ function transformCapabilities(oldCapabilities) {
5320
5255
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5321
5256
  function loadExistingCapabilities() {
5322
5257
  const capabilitiesDir = getCapabilitiesDir2();
5323
- if (!fs20.existsSync(capabilitiesDir)) {
5258
+ if (!fs19.existsSync(capabilitiesDir)) {
5324
5259
  return [];
5325
5260
  }
5326
- const files = fs20.readdirSync(capabilitiesDir);
5261
+ const files = fs19.readdirSync(capabilitiesDir);
5327
5262
  const capabilities = [];
5328
5263
  for (const file of files) {
5329
5264
  if (file === "capabilities.json" || !file.endsWith(".json")) {
5330
5265
  continue;
5331
5266
  }
5332
5267
  try {
5333
- const filePath = path18.join(capabilitiesDir, file);
5334
- const content = fs20.readFileSync(filePath, "utf-8");
5268
+ const filePath = path17.join(capabilitiesDir, file);
5269
+ const content = fs19.readFileSync(filePath, "utf-8");
5335
5270
  const capability = JSON.parse(content);
5336
5271
  if (capability.id && capability.pluginKey) {
5337
5272
  capabilities.push(capability);
@@ -5389,9 +5324,9 @@ async function migrateJsonFiles(options) {
5389
5324
  }
5390
5325
  const capabilitiesDir = getCapabilitiesDir2();
5391
5326
  for (const cap of newCapabilities) {
5392
- const filePath = path18.join(capabilitiesDir, `${cap.id}.json`);
5327
+ const filePath = path17.join(capabilitiesDir, `${cap.id}.json`);
5393
5328
  const content = JSON.stringify(cap, null, 2);
5394
- fs20.writeFileSync(filePath, content, "utf-8");
5329
+ fs19.writeFileSync(filePath, content, "utf-8");
5395
5330
  console.log(` \u2713 Created: ${cap.id}.json`);
5396
5331
  }
5397
5332
  return {
@@ -5403,11 +5338,11 @@ async function migrateJsonFiles(options) {
5403
5338
  }
5404
5339
 
5405
5340
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
5406
- import fs21 from "fs";
5341
+ import fs20 from "fs";
5407
5342
  function isPluginInstalled2(pluginKey) {
5408
5343
  const actionPlugins = readActionPlugins();
5409
5344
  const manifestPath = getPluginManifestPath2(pluginKey);
5410
- return fs21.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5345
+ return fs20.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5411
5346
  }
5412
5347
  function detectPluginsToInstall(capabilities) {
5413
5348
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -5483,12 +5418,12 @@ async function installPlugins(capabilities, options) {
5483
5418
  }
5484
5419
 
5485
5420
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
5486
- import path20 from "path";
5421
+ import path19 from "path";
5487
5422
  import { Project as Project3 } from "ts-morph";
5488
5423
 
5489
5424
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
5490
- import fs22 from "fs";
5491
- import path19 from "path";
5425
+ import fs21 from "fs";
5426
+ import path18 from "path";
5492
5427
  var EXCLUDED_DIRS = [
5493
5428
  "node_modules",
5494
5429
  "dist",
@@ -5503,9 +5438,9 @@ var EXCLUDED_PATTERNS = [
5503
5438
  /\.d\.ts$/
5504
5439
  ];
5505
5440
  function scanDirectory(dir, files = []) {
5506
- const entries = fs22.readdirSync(dir, { withFileTypes: true });
5441
+ const entries = fs21.readdirSync(dir, { withFileTypes: true });
5507
5442
  for (const entry of entries) {
5508
- const fullPath = path19.join(dir, entry.name);
5443
+ const fullPath = path18.join(dir, entry.name);
5509
5444
  if (entry.isDirectory()) {
5510
5445
  if (EXCLUDED_DIRS.includes(entry.name)) {
5511
5446
  continue;
@@ -5521,14 +5456,14 @@ function scanDirectory(dir, files = []) {
5521
5456
  return files;
5522
5457
  }
5523
5458
  function scanServerFiles() {
5524
- const serverDir = path19.join(getProjectRoot3(), "server");
5525
- if (!fs22.existsSync(serverDir)) {
5459
+ const serverDir = path18.join(getProjectRoot3(), "server");
5460
+ if (!fs21.existsSync(serverDir)) {
5526
5461
  return [];
5527
5462
  }
5528
5463
  return scanDirectory(serverDir);
5529
5464
  }
5530
5465
  function hasCapabilityImport(filePath) {
5531
- const content = fs22.readFileSync(filePath, "utf-8");
5466
+ const content = fs21.readFileSync(filePath, "utf-8");
5532
5467
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
5533
5468
  }
5534
5469
  function scanFilesToMigrate() {
@@ -5905,7 +5840,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5905
5840
  const callSites = analyzeCallSites(sourceFile, imports);
5906
5841
  const classInfo = analyzeClass(sourceFile);
5907
5842
  const { canMigrate, reason } = canAutoMigrate(classInfo);
5908
- const relativePath = path20.relative(getProjectRoot3(), filePath);
5843
+ const relativePath = path19.relative(getProjectRoot3(), filePath);
5909
5844
  return {
5910
5845
  filePath: relativePath,
5911
5846
  imports,
@@ -5916,7 +5851,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5916
5851
  };
5917
5852
  }
5918
5853
  function migrateFile(project, analysis, dryRun) {
5919
- const absolutePath = path20.join(getProjectRoot3(), analysis.filePath);
5854
+ const absolutePath = path19.join(getProjectRoot3(), analysis.filePath);
5920
5855
  if (!analysis.canAutoMigrate) {
5921
5856
  return {
5922
5857
  filePath: analysis.filePath,
@@ -6019,17 +5954,17 @@ function getSuggestion(analysis) {
6019
5954
  }
6020
5955
 
6021
5956
  // src/commands/migration/versions/v001_capability/cleanup.ts
6022
- import fs23 from "fs";
6023
- import path21 from "path";
5957
+ import fs22 from "fs";
5958
+ import path20 from "path";
6024
5959
  function cleanupOldFiles(capabilities, dryRun) {
6025
5960
  const deletedFiles = [];
6026
5961
  const errors = [];
6027
5962
  const capabilitiesDir = getCapabilitiesDir2();
6028
- const oldJsonPath = path21.join(capabilitiesDir, "capabilities.json");
6029
- if (fs23.existsSync(oldJsonPath)) {
5963
+ const oldJsonPath = path20.join(capabilitiesDir, "capabilities.json");
5964
+ if (fs22.existsSync(oldJsonPath)) {
6030
5965
  try {
6031
5966
  if (!dryRun) {
6032
- fs23.unlinkSync(oldJsonPath);
5967
+ fs22.unlinkSync(oldJsonPath);
6033
5968
  }
6034
5969
  deletedFiles.push("capabilities.json");
6035
5970
  } catch (error) {
@@ -6037,11 +5972,11 @@ function cleanupOldFiles(capabilities, dryRun) {
6037
5972
  }
6038
5973
  }
6039
5974
  for (const cap of capabilities) {
6040
- const tsFilePath = path21.join(capabilitiesDir, `${cap.id}.ts`);
6041
- if (fs23.existsSync(tsFilePath)) {
5975
+ const tsFilePath = path20.join(capabilitiesDir, `${cap.id}.ts`);
5976
+ if (fs22.existsSync(tsFilePath)) {
6042
5977
  try {
6043
5978
  if (!dryRun) {
6044
- fs23.unlinkSync(tsFilePath);
5979
+ fs22.unlinkSync(tsFilePath);
6045
5980
  }
6046
5981
  deletedFiles.push(`${cap.id}.ts`);
6047
5982
  } catch (error) {
@@ -6057,8 +5992,8 @@ function cleanupOldFiles(capabilities, dryRun) {
6057
5992
  }
6058
5993
 
6059
5994
  // src/commands/migration/versions/v001_capability/report-generator.ts
6060
- import fs24 from "fs";
6061
- import path22 from "path";
5995
+ import fs23 from "fs";
5996
+ import path21 from "path";
6062
5997
  var REPORT_FILE = "capability-migration-report.md";
6063
5998
  function printSummary(result) {
6064
5999
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -6221,15 +6156,15 @@ async function generateReport(result) {
6221
6156
  }
6222
6157
  lines.push("");
6223
6158
  const logDir = process.env.LOG_DIR || "logs";
6224
- if (!fs24.existsSync(logDir)) {
6159
+ if (!fs23.existsSync(logDir)) {
6225
6160
  return;
6226
6161
  }
6227
- const reportDir = path22.join(logDir, "migration");
6228
- if (!fs24.existsSync(reportDir)) {
6229
- fs24.mkdirSync(reportDir, { recursive: true });
6162
+ const reportDir = path21.join(logDir, "migration");
6163
+ if (!fs23.existsSync(reportDir)) {
6164
+ fs23.mkdirSync(reportDir, { recursive: true });
6230
6165
  }
6231
- const reportPath = path22.join(reportDir, REPORT_FILE);
6232
- fs24.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6166
+ const reportPath = path21.join(reportDir, REPORT_FILE);
6167
+ fs23.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6233
6168
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
6234
6169
  }
6235
6170
 
@@ -6761,10 +6696,10 @@ var migrationCommand = {
6761
6696
  };
6762
6697
 
6763
6698
  // src/commands/read-logs/index.ts
6764
- import path23 from "path";
6699
+ import path22 from "path";
6765
6700
 
6766
6701
  // src/commands/read-logs/std-utils.ts
6767
- import fs25 from "fs";
6702
+ import fs24 from "fs";
6768
6703
  function formatStdPrefixTime(localTime) {
6769
6704
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
6770
6705
  if (!match) return localTime;
@@ -6794,11 +6729,11 @@ function stripPrefixFromStdLine(line) {
6794
6729
  return `[${time}] ${content}`;
6795
6730
  }
6796
6731
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
6797
- const stat = fs25.statSync(filePath);
6732
+ const stat = fs24.statSync(filePath);
6798
6733
  if (stat.size === 0) {
6799
6734
  return { lines: [], markerFound: false, totalLinesCount: 0 };
6800
6735
  }
6801
- const fd = fs25.openSync(filePath, "r");
6736
+ const fd = fs24.openSync(filePath, "r");
6802
6737
  const chunkSize = 64 * 1024;
6803
6738
  let position = stat.size;
6804
6739
  let remainder = "";
@@ -6812,7 +6747,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6812
6747
  const length = Math.min(chunkSize, position);
6813
6748
  position -= length;
6814
6749
  const buffer = Buffer.alloc(length);
6815
- fs25.readSync(fd, buffer, 0, length, position);
6750
+ fs24.readSync(fd, buffer, 0, length, position);
6816
6751
  let chunk = buffer.toString("utf8");
6817
6752
  if (remainder) {
6818
6753
  chunk += remainder;
@@ -6854,7 +6789,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6854
6789
  }
6855
6790
  }
6856
6791
  } finally {
6857
- fs25.closeSync(fd);
6792
+ fs24.closeSync(fd);
6858
6793
  }
6859
6794
  return { lines: collected.reverse(), markerFound, totalLinesCount };
6860
6795
  }
@@ -6875,21 +6810,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
6875
6810
  }
6876
6811
 
6877
6812
  // src/commands/read-logs/tail.ts
6878
- import fs26 from "fs";
6813
+ import fs25 from "fs";
6879
6814
  function fileExists(filePath) {
6880
6815
  try {
6881
- fs26.accessSync(filePath, fs26.constants.F_OK | fs26.constants.R_OK);
6816
+ fs25.accessSync(filePath, fs25.constants.F_OK | fs25.constants.R_OK);
6882
6817
  return true;
6883
6818
  } catch {
6884
6819
  return false;
6885
6820
  }
6886
6821
  }
6887
6822
  function readFileTailLines(filePath, maxLines) {
6888
- const stat = fs26.statSync(filePath);
6823
+ const stat = fs25.statSync(filePath);
6889
6824
  if (stat.size === 0) {
6890
6825
  return [];
6891
6826
  }
6892
- const fd = fs26.openSync(filePath, "r");
6827
+ const fd = fs25.openSync(filePath, "r");
6893
6828
  const chunkSize = 64 * 1024;
6894
6829
  const chunks = [];
6895
6830
  let position = stat.size;
@@ -6899,13 +6834,13 @@ function readFileTailLines(filePath, maxLines) {
6899
6834
  const length = Math.min(chunkSize, position);
6900
6835
  position -= length;
6901
6836
  const buffer = Buffer.alloc(length);
6902
- fs26.readSync(fd, buffer, 0, length, position);
6837
+ fs25.readSync(fd, buffer, 0, length, position);
6903
6838
  chunks.unshift(buffer.toString("utf8"));
6904
6839
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
6905
6840
  collectedLines += chunkLines;
6906
6841
  }
6907
6842
  } finally {
6908
- fs26.closeSync(fd);
6843
+ fs25.closeSync(fd);
6909
6844
  }
6910
6845
  const content = chunks.join("");
6911
6846
  const allLines = content.split("\n");
@@ -6921,11 +6856,11 @@ function readFileTailLines(filePath, maxLines) {
6921
6856
  return allLines.slice(allLines.length - maxLines);
6922
6857
  }
6923
6858
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6924
- const stat = fs26.statSync(filePath);
6859
+ const stat = fs25.statSync(filePath);
6925
6860
  if (stat.size === 0) {
6926
6861
  return { lines: [], totalLinesCount: 0 };
6927
6862
  }
6928
- const fd = fs26.openSync(filePath, "r");
6863
+ const fd = fs25.openSync(filePath, "r");
6929
6864
  const chunkSize = 64 * 1024;
6930
6865
  let position = stat.size;
6931
6866
  let remainder = "";
@@ -6937,7 +6872,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6937
6872
  const length = Math.min(chunkSize, position);
6938
6873
  position -= length;
6939
6874
  const buffer = Buffer.alloc(length);
6940
- fs26.readSync(fd, buffer, 0, length, position);
6875
+ fs25.readSync(fd, buffer, 0, length, position);
6941
6876
  let chunk = buffer.toString("utf8");
6942
6877
  if (remainder) {
6943
6878
  chunk += remainder;
@@ -6968,7 +6903,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6968
6903
  }
6969
6904
  }
6970
6905
  } finally {
6971
- fs26.closeSync(fd);
6906
+ fs25.closeSync(fd);
6972
6907
  }
6973
6908
  return { lines: collected.reverse(), totalLinesCount };
6974
6909
  }
@@ -7110,7 +7045,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
7110
7045
  }
7111
7046
 
7112
7047
  // src/commands/read-logs/json-lines.ts
7113
- import fs27 from "fs";
7048
+ import fs26 from "fs";
7114
7049
  function normalizePid(value) {
7115
7050
  if (typeof value === "number") {
7116
7051
  return String(value);
@@ -7161,11 +7096,11 @@ function buildWantedLevelSet(levels) {
7161
7096
  return set.size > 0 ? set : null;
7162
7097
  }
7163
7098
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7164
- const stat = fs27.statSync(filePath);
7099
+ const stat = fs26.statSync(filePath);
7165
7100
  if (stat.size === 0) {
7166
7101
  return { lines: [], totalLinesCount: 0 };
7167
7102
  }
7168
- const fd = fs27.openSync(filePath, "r");
7103
+ const fd = fs26.openSync(filePath, "r");
7169
7104
  const chunkSize = 64 * 1024;
7170
7105
  let position = stat.size;
7171
7106
  let remainder = "";
@@ -7180,7 +7115,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7180
7115
  const length = Math.min(chunkSize, position);
7181
7116
  position -= length;
7182
7117
  const buffer = Buffer.alloc(length);
7183
- fs27.readSync(fd, buffer, 0, length, position);
7118
+ fs26.readSync(fd, buffer, 0, length, position);
7184
7119
  let chunk = buffer.toString("utf8");
7185
7120
  if (remainder) {
7186
7121
  chunk += remainder;
@@ -7242,7 +7177,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7242
7177
  }
7243
7178
  }
7244
7179
  } finally {
7245
- fs27.closeSync(fd);
7180
+ fs26.closeSync(fd);
7246
7181
  }
7247
7182
  return { lines: collected.reverse(), totalLinesCount };
7248
7183
  }
@@ -7285,11 +7220,11 @@ function extractTraceId(obj) {
7285
7220
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7286
7221
  const wanted = traceId.trim();
7287
7222
  if (!wanted) return { lines: [], totalLinesCount: 0 };
7288
- const stat = fs27.statSync(filePath);
7223
+ const stat = fs26.statSync(filePath);
7289
7224
  if (stat.size === 0) {
7290
7225
  return { lines: [], totalLinesCount: 0 };
7291
7226
  }
7292
- const fd = fs27.openSync(filePath, "r");
7227
+ const fd = fs26.openSync(filePath, "r");
7293
7228
  const chunkSize = 64 * 1024;
7294
7229
  let position = stat.size;
7295
7230
  let remainder = "";
@@ -7302,7 +7237,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7302
7237
  const length = Math.min(chunkSize, position);
7303
7238
  position -= length;
7304
7239
  const buffer = Buffer.alloc(length);
7305
- fs27.readSync(fd, buffer, 0, length, position);
7240
+ fs26.readSync(fd, buffer, 0, length, position);
7306
7241
  let chunk = buffer.toString("utf8");
7307
7242
  if (remainder) {
7308
7243
  chunk += remainder;
@@ -7355,7 +7290,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7355
7290
  }
7356
7291
  }
7357
7292
  } finally {
7358
- fs27.closeSync(fd);
7293
+ fs26.closeSync(fd);
7359
7294
  }
7360
7295
  return { lines: collected.reverse(), totalLinesCount };
7361
7296
  }
@@ -7364,11 +7299,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7364
7299
  if (!wantedLevelSet) {
7365
7300
  return { lines: [], totalLinesCount: 0 };
7366
7301
  }
7367
- const stat = fs27.statSync(filePath);
7302
+ const stat = fs26.statSync(filePath);
7368
7303
  if (stat.size === 0) {
7369
7304
  return { lines: [], totalLinesCount: 0 };
7370
7305
  }
7371
- const fd = fs27.openSync(filePath, "r");
7306
+ const fd = fs26.openSync(filePath, "r");
7372
7307
  const chunkSize = 64 * 1024;
7373
7308
  let position = stat.size;
7374
7309
  let remainder = "";
@@ -7380,7 +7315,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7380
7315
  const length = Math.min(chunkSize, position);
7381
7316
  position -= length;
7382
7317
  const buffer = Buffer.alloc(length);
7383
- fs27.readSync(fd, buffer, 0, length, position);
7318
+ fs26.readSync(fd, buffer, 0, length, position);
7384
7319
  let chunk = buffer.toString("utf8");
7385
7320
  if (remainder) {
7386
7321
  chunk += remainder;
@@ -7427,7 +7362,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7427
7362
  }
7428
7363
  }
7429
7364
  } finally {
7430
- fs27.closeSync(fd);
7365
+ fs26.closeSync(fd);
7431
7366
  }
7432
7367
  return { lines: collected.reverse(), totalLinesCount };
7433
7368
  }
@@ -7661,30 +7596,30 @@ async function readLogsJsonResult(options) {
7661
7596
  };
7662
7597
  }
7663
7598
  function resolveLogFilePath(logDir, type) {
7664
- const base = path23.isAbsolute(logDir) ? logDir : path23.join(process.cwd(), logDir);
7599
+ const base = path22.isAbsolute(logDir) ? logDir : path22.join(process.cwd(), logDir);
7665
7600
  if (type === "server") {
7666
- return path23.join(base, "server.log");
7601
+ return path22.join(base, "server.log");
7667
7602
  }
7668
7603
  if (type === "trace") {
7669
- return path23.join(base, "trace.log");
7604
+ return path22.join(base, "trace.log");
7670
7605
  }
7671
7606
  if (type === "server-std") {
7672
- return path23.join(base, "server.std.log");
7607
+ return path22.join(base, "server.std.log");
7673
7608
  }
7674
7609
  if (type === "client-std") {
7675
- return path23.join(base, "client.std.log");
7610
+ return path22.join(base, "client.std.log");
7676
7611
  }
7677
7612
  if (type === "dev") {
7678
- return path23.join(base, "dev.log");
7613
+ return path22.join(base, "dev.log");
7679
7614
  }
7680
7615
  if (type === "dev-std") {
7681
- return path23.join(base, "dev.std.log");
7616
+ return path22.join(base, "dev.std.log");
7682
7617
  }
7683
7618
  if (type === "install-dep-std") {
7684
- return path23.join(base, "install-dep.std.log");
7619
+ return path22.join(base, "install-dep.std.log");
7685
7620
  }
7686
7621
  if (type === "browser") {
7687
- return path23.join(base, "browser.log");
7622
+ return path22.join(base, "browser.log");
7688
7623
  }
7689
7624
  throw new Error(`Unsupported log type: ${type}`);
7690
7625
  }
@@ -7861,9 +7796,9 @@ function camelToKebab(str) {
7861
7796
  }
7862
7797
 
7863
7798
  // src/commands/build/upload-static.handler.ts
7864
- import * as fs28 from "fs";
7799
+ import * as fs27 from "fs";
7865
7800
  import * as os2 from "os";
7866
- import * as path24 from "path";
7801
+ import * as path23 from "path";
7867
7802
  import { execFileSync } from "child_process";
7868
7803
  function readCredentialsFromEnv() {
7869
7804
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -7887,8 +7822,8 @@ async function uploadStatic(options) {
7887
7822
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7888
7823
  region = UPLOAD_STATIC_DEFAULTS.region
7889
7824
  } = options;
7890
- const resolvedStaticDir = path24.resolve(staticDir);
7891
- if (!fs28.existsSync(resolvedStaticDir)) {
7825
+ const resolvedStaticDir = path23.resolve(staticDir);
7826
+ if (!fs27.existsSync(resolvedStaticDir)) {
7892
7827
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7893
7828
  return;
7894
7829
  }
@@ -7921,8 +7856,8 @@ async function uploadStatic(options) {
7921
7856
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7922
7857
  }
7923
7858
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7924
- const confPath = path24.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7925
- fs28.writeFileSync(confPath, "");
7859
+ const confPath = path23.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7860
+ fs27.writeFileSync(confPath, "");
7926
7861
  try {
7927
7862
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7928
7863
  configureTosutil(resolvedTosutil, confPath, {
@@ -7936,7 +7871,7 @@ async function uploadStatic(options) {
7936
7871
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7937
7872
  } finally {
7938
7873
  try {
7939
- fs28.unlinkSync(confPath);
7874
+ fs27.unlinkSync(confPath);
7940
7875
  } catch {
7941
7876
  }
7942
7877
  }
@@ -7956,8 +7891,8 @@ async function uploadStatic(options) {
7956
7891
  }
7957
7892
  }
7958
7893
  function resolveTosutilPath(tosutilPath) {
7959
- if (path24.isAbsolute(tosutilPath)) {
7960
- return fs28.existsSync(tosutilPath) ? tosutilPath : null;
7894
+ if (path23.isAbsolute(tosutilPath)) {
7895
+ return fs27.existsSync(tosutilPath) ? tosutilPath : null;
7961
7896
  }
7962
7897
  try {
7963
7898
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -8002,7 +7937,7 @@ async function resolveBucketId(appId) {
8002
7937
  return bucketId;
8003
7938
  }
8004
7939
  function isDirEmpty(dirPath) {
8005
- const entries = fs28.readdirSync(dirPath);
7940
+ const entries = fs27.readdirSync(dirPath);
8006
7941
  return entries.length === 0;
8007
7942
  }
8008
7943
 
@@ -8097,12 +8032,12 @@ var commands = [
8097
8032
  ];
8098
8033
 
8099
8034
  // src/index.ts
8100
- var envPath = path25.join(process.cwd(), ".env");
8101
- if (fs29.existsSync(envPath)) {
8035
+ var envPath = path24.join(process.cwd(), ".env");
8036
+ if (fs28.existsSync(envPath)) {
8102
8037
  dotenvConfig({ path: envPath });
8103
8038
  }
8104
- var __dirname = path25.dirname(fileURLToPath5(import.meta.url));
8105
- var pkg = JSON.parse(fs29.readFileSync(path25.join(__dirname, "../package.json"), "utf-8"));
8039
+ var __dirname = path24.dirname(fileURLToPath5(import.meta.url));
8040
+ var pkg = JSON.parse(fs28.readFileSync(path24.join(__dirname, "../package.json"), "utf-8"));
8106
8041
  var cli = new FullstackCLI(pkg.version);
8107
8042
  cli.useAll(commands);
8108
8043
  cli.run();