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

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