@lark-apaas/fullstack-cli 1.1.44 → 1.1.45-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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,48 @@ var genDbSchemaCommand = {
2365
2365
  };
2366
2366
 
2367
2367
  // src/commands/sync/run.handler.ts
2368
- import path5 from "path";
2369
- import fs7 from "fs";
2368
+ import path6 from "path";
2369
+ import fs8 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. 同步 .husky 目录(hook 入口,单行 `npm run precommit`)
2384
+ {
2385
+ from: "templates/.husky",
2386
+ to: ".husky",
2387
+ type: "directory",
2388
+ overwrite: true
2389
+ },
2390
+ // 1b. 合并 husky devDep 到 package.json
2391
+ {
2392
+ from: "templates/package.husky-patch.json",
2393
+ to: "package.json",
2394
+ type: "merge-json"
2395
+ },
2396
+ // 1c. scripts.prepare = husky(npm install 时自动跑,等价于 husky install)
2397
+ {
2398
+ type: "add-script",
2399
+ name: "prepare",
2400
+ command: "husky",
2401
+ overwrite: false
2402
+ },
2403
+ // 1d. scripts.precommit = pre-commit 真正的执行体(npm run lint + read-logs ×5)
2404
+ {
2405
+ type: "add-script",
2406
+ name: "precommit",
2407
+ command: "node scripts/hooks/run-precommit.js",
2408
+ overwrite: false
2409
+ },
2383
2410
  // 2. 智能合并 nest-cli.json 配置(保留用户自定义的 assets、plugins 等)
2384
2411
  {
2385
2412
  from: "templates/nest-cli.json",
@@ -2602,18 +2629,46 @@ function cleanupPackageJson(cwd = process.cwd()) {
2602
2629
  }
2603
2630
  }
2604
2631
 
2632
+ // src/commands/sync/install-husky.ts
2633
+ import fs7 from "fs";
2634
+ import path5 from "path";
2635
+ import { spawnSync as spawnSync2 } from "child_process";
2636
+ function ensureHuskyInstalled(userProjectRoot) {
2637
+ if (!fs7.existsSync(path5.join(userProjectRoot, ".git"))) {
2638
+ return { action: "skipped-no-git" };
2639
+ }
2640
+ const huskyBin = path5.join(userProjectRoot, "node_modules", "husky", "bin.js");
2641
+ if (!fs7.existsSync(huskyBin)) {
2642
+ console.log("[fullstack-cli] \u25CB husky not installed yet; will activate after next `npm install`");
2643
+ return { action: "skipped-no-husky" };
2644
+ }
2645
+ const huskyDir = path5.join(userProjectRoot, ".husky", "_");
2646
+ if (fs7.existsSync(huskyDir)) {
2647
+ return { action: "already-initialized" };
2648
+ }
2649
+ const res = spawnSync2("node", [huskyBin], {
2650
+ cwd: userProjectRoot,
2651
+ stdio: ["ignore", "inherit", "inherit"]
2652
+ });
2653
+ if (res.status !== 0) {
2654
+ throw new Error(`husky bootstrap exited with ${String(res.status)}`);
2655
+ }
2656
+ console.log("[fullstack-cli] \u2713 husky initialized (core.hooksPath set to .husky/)");
2657
+ return { action: "bootstrapped" };
2658
+ }
2659
+
2605
2660
  // src/commands/sync/run.handler.ts
2606
2661
  async function run2(options) {
2607
2662
  const userProjectRoot = process.env.INIT_CWD || process.cwd();
2608
2663
  const __filename = fileURLToPath3(import.meta.url);
2609
- const __dirname2 = path5.dirname(__filename);
2610
- const pluginRoot = path5.resolve(__dirname2, "..");
2664
+ const __dirname2 = path6.dirname(__filename);
2665
+ const pluginRoot = path6.resolve(__dirname2, "..");
2611
2666
  if (userProjectRoot === pluginRoot) {
2612
2667
  console.log("[fullstack-cli] Skip syncing (installing plugin itself)");
2613
2668
  process.exit(0);
2614
2669
  }
2615
- const userPackageJson = path5.join(userProjectRoot, "package.json");
2616
- if (!fs7.existsSync(userPackageJson)) {
2670
+ const userPackageJson = path6.join(userProjectRoot, "package.json");
2671
+ if (!fs8.existsSync(userPackageJson)) {
2617
2672
  console.log("[fullstack-cli] Skip syncing (not a valid npm project)");
2618
2673
  process.exit(0);
2619
2674
  }
@@ -2633,6 +2688,12 @@ async function run2(options) {
2633
2688
  if (config.permissions) {
2634
2689
  setPermissions(config.permissions, userProjectRoot);
2635
2690
  }
2691
+ try {
2692
+ ensureHuskyInstalled(userProjectRoot);
2693
+ } catch (error) {
2694
+ const message = error instanceof Error ? error.message : String(error);
2695
+ console.warn(`[fullstack-cli] \u26A0 Failed to bootstrap husky: ${message}`);
2696
+ }
2636
2697
  console.log("[fullstack-cli] Sync completed successfully \u2705");
2637
2698
  } catch (error) {
2638
2699
  const message = error instanceof Error ? error.message : String(error);
@@ -2665,7 +2726,7 @@ function patchUserPackageJson(userProjectRoot) {
2665
2726
  }
2666
2727
  async function syncRule(rule, pluginRoot, userProjectRoot) {
2667
2728
  if (rule.type === "delete-file" || rule.type === "delete-directory") {
2668
- const destPath2 = path5.join(userProjectRoot, rule.to);
2729
+ const destPath2 = path6.join(userProjectRoot, rule.to);
2669
2730
  if (rule.type === "delete-file") {
2670
2731
  deleteFile(destPath2);
2671
2732
  } else {
@@ -2674,32 +2735,32 @@ async function syncRule(rule, pluginRoot, userProjectRoot) {
2674
2735
  return;
2675
2736
  }
2676
2737
  if (rule.type === "remove-line") {
2677
- const destPath2 = path5.join(userProjectRoot, rule.to);
2738
+ const destPath2 = path6.join(userProjectRoot, rule.to);
2678
2739
  removeLineFromFile(destPath2, rule.pattern);
2679
2740
  return;
2680
2741
  }
2681
2742
  if (rule.type === "add-script") {
2682
- const packageJsonPath = path5.join(userProjectRoot, "package.json");
2743
+ const packageJsonPath = path6.join(userProjectRoot, "package.json");
2683
2744
  addScript(packageJsonPath, rule.name, rule.command, rule.overwrite ?? false);
2684
2745
  return;
2685
2746
  }
2686
2747
  if (rule.type === "add-line") {
2687
- const destPath2 = path5.join(userProjectRoot, rule.to);
2748
+ const destPath2 = path6.join(userProjectRoot, rule.to);
2688
2749
  addLineToFile(destPath2, rule.line);
2689
2750
  return;
2690
2751
  }
2691
2752
  if (rule.type === "merge-json") {
2692
- const srcPath2 = path5.join(pluginRoot, rule.from);
2693
- const destPath2 = path5.join(userProjectRoot, rule.to);
2753
+ const srcPath2 = path6.join(pluginRoot, rule.from);
2754
+ const destPath2 = path6.join(userProjectRoot, rule.to);
2694
2755
  mergeJsonFile(srcPath2, destPath2, rule.arrayMerge);
2695
2756
  return;
2696
2757
  }
2697
2758
  if (!("from" in rule)) {
2698
2759
  return;
2699
2760
  }
2700
- const srcPath = path5.join(pluginRoot, rule.from);
2701
- const destPath = path5.join(userProjectRoot, rule.to);
2702
- if (!fs7.existsSync(srcPath)) {
2761
+ const srcPath = path6.join(pluginRoot, rule.from);
2762
+ const destPath = path6.join(userProjectRoot, rule.to);
2763
+ if (!fs8.existsSync(srcPath)) {
2703
2764
  console.warn(`[fullstack-cli] Source not found: ${rule.from}`);
2704
2765
  return;
2705
2766
  }
@@ -2716,68 +2777,68 @@ async function syncRule(rule, pluginRoot, userProjectRoot) {
2716
2777
  }
2717
2778
  }
2718
2779
  function syncFile(src, dest, overwrite = true, onlyIfExists = false) {
2719
- if (onlyIfExists && !fs7.existsSync(dest)) {
2720
- console.log(`[fullstack-cli] \u25CB ${path5.basename(dest)} (skipped, target not exists)`);
2780
+ if (onlyIfExists && !fs8.existsSync(dest)) {
2781
+ console.log(`[fullstack-cli] \u25CB ${path6.basename(dest)} (skipped, target not exists)`);
2721
2782
  return;
2722
2783
  }
2723
- const destDir = path5.dirname(dest);
2724
- if (!fs7.existsSync(destDir)) {
2725
- fs7.mkdirSync(destDir, { recursive: true });
2784
+ const destDir = path6.dirname(dest);
2785
+ if (!fs8.existsSync(destDir)) {
2786
+ fs8.mkdirSync(destDir, { recursive: true });
2726
2787
  }
2727
- if (fs7.existsSync(dest) && !overwrite) {
2728
- console.log(`[fullstack-cli] \u25CB ${path5.basename(dest)} (skipped, already exists)`);
2788
+ if (fs8.existsSync(dest) && !overwrite) {
2789
+ console.log(`[fullstack-cli] \u25CB ${path6.basename(dest)} (skipped, already exists)`);
2729
2790
  return;
2730
2791
  }
2731
- fs7.copyFileSync(src, dest);
2732
- console.log(`[fullstack-cli] \u2713 ${path5.basename(dest)}`);
2792
+ fs8.copyFileSync(src, dest);
2793
+ console.log(`[fullstack-cli] \u2713 ${path6.basename(dest)}`);
2733
2794
  }
2734
2795
  function syncDirectory(src, dest, overwrite = true) {
2735
- if (!fs7.existsSync(dest)) {
2736
- fs7.mkdirSync(dest, { recursive: true });
2796
+ if (!fs8.existsSync(dest)) {
2797
+ fs8.mkdirSync(dest, { recursive: true });
2737
2798
  }
2738
- const files = fs7.readdirSync(src);
2799
+ const files = fs8.readdirSync(src);
2739
2800
  let count = 0;
2740
2801
  files.forEach((file) => {
2741
- const srcFile = path5.join(src, file);
2742
- const destFile = path5.join(dest, file);
2743
- const stats = fs7.statSync(srcFile);
2802
+ const srcFile = path6.join(src, file);
2803
+ const destFile = path6.join(dest, file);
2804
+ const stats = fs8.statSync(srcFile);
2744
2805
  if (stats.isDirectory()) {
2745
2806
  syncDirectory(srcFile, destFile, overwrite);
2746
2807
  } else {
2747
- if (overwrite || !fs7.existsSync(destFile)) {
2748
- fs7.copyFileSync(srcFile, destFile);
2749
- console.log(`[fullstack-cli] \u2713 ${path5.relative(dest, destFile)}`);
2808
+ if (overwrite || !fs8.existsSync(destFile)) {
2809
+ fs8.copyFileSync(srcFile, destFile);
2810
+ console.log(`[fullstack-cli] \u2713 ${path6.relative(dest, destFile)}`);
2750
2811
  count++;
2751
2812
  }
2752
2813
  }
2753
2814
  });
2754
2815
  if (count > 0) {
2755
- console.log(`[fullstack-cli] Synced ${count} files to ${path5.basename(dest)}/`);
2816
+ console.log(`[fullstack-cli] Synced ${count} files to ${path6.basename(dest)}/`);
2756
2817
  }
2757
2818
  }
2758
2819
  function appendToFile(src, dest) {
2759
- const content = fs7.readFileSync(src, "utf-8");
2820
+ const content = fs8.readFileSync(src, "utf-8");
2760
2821
  let existingContent = "";
2761
- if (fs7.existsSync(dest)) {
2762
- existingContent = fs7.readFileSync(dest, "utf-8");
2822
+ if (fs8.existsSync(dest)) {
2823
+ existingContent = fs8.readFileSync(dest, "utf-8");
2763
2824
  }
2764
2825
  if (existingContent.includes(content.trim())) {
2765
- console.log(`[fullstack-cli] \u25CB ${path5.basename(dest)} (already contains content)`);
2826
+ console.log(`[fullstack-cli] \u25CB ${path6.basename(dest)} (already contains content)`);
2766
2827
  return;
2767
2828
  }
2768
- fs7.appendFileSync(dest, content);
2769
- console.log(`[fullstack-cli] \u2713 ${path5.basename(dest)} (appended)`);
2829
+ fs8.appendFileSync(dest, content);
2830
+ console.log(`[fullstack-cli] \u2713 ${path6.basename(dest)} (appended)`);
2770
2831
  }
2771
2832
  function setPermissions(permissions, projectRoot) {
2772
2833
  for (const [pattern, mode] of Object.entries(permissions)) {
2773
2834
  if (pattern === "**/*.sh") {
2774
- const scriptsDir = path5.join(projectRoot, "scripts");
2775
- if (fs7.existsSync(scriptsDir)) {
2776
- const files = fs7.readdirSync(scriptsDir);
2835
+ const scriptsDir = path6.join(projectRoot, "scripts");
2836
+ if (fs8.existsSync(scriptsDir)) {
2837
+ const files = fs8.readdirSync(scriptsDir);
2777
2838
  files.forEach((file) => {
2778
2839
  if (file.endsWith(".sh")) {
2779
- const filePath = path5.join(scriptsDir, file);
2780
- fs7.chmodSync(filePath, mode);
2840
+ const filePath = path6.join(scriptsDir, file);
2841
+ fs8.chmodSync(filePath, mode);
2781
2842
  }
2782
2843
  });
2783
2844
  }
@@ -2785,27 +2846,27 @@ function setPermissions(permissions, projectRoot) {
2785
2846
  }
2786
2847
  }
2787
2848
  function deleteFile(filePath) {
2788
- if (fs7.existsSync(filePath)) {
2789
- fs7.unlinkSync(filePath);
2790
- console.log(`[fullstack-cli] \u2713 ${path5.basename(filePath)} (deleted)`);
2849
+ if (fs8.existsSync(filePath)) {
2850
+ fs8.unlinkSync(filePath);
2851
+ console.log(`[fullstack-cli] \u2713 ${path6.basename(filePath)} (deleted)`);
2791
2852
  } else {
2792
- console.log(`[fullstack-cli] \u25CB ${path5.basename(filePath)} (not found)`);
2853
+ console.log(`[fullstack-cli] \u25CB ${path6.basename(filePath)} (not found)`);
2793
2854
  }
2794
2855
  }
2795
2856
  function deleteDirectory(dirPath) {
2796
- if (fs7.existsSync(dirPath)) {
2797
- fs7.rmSync(dirPath, { recursive: true });
2798
- console.log(`[fullstack-cli] \u2713 ${path5.basename(dirPath)} (deleted)`);
2857
+ if (fs8.existsSync(dirPath)) {
2858
+ fs8.rmSync(dirPath, { recursive: true });
2859
+ console.log(`[fullstack-cli] \u2713 ${path6.basename(dirPath)} (deleted)`);
2799
2860
  } else {
2800
- console.log(`[fullstack-cli] \u25CB ${path5.basename(dirPath)} (not found)`);
2861
+ console.log(`[fullstack-cli] \u25CB ${path6.basename(dirPath)} (not found)`);
2801
2862
  }
2802
2863
  }
2803
2864
  function addScript(packageJsonPath, name, command, overwrite) {
2804
- if (!fs7.existsSync(packageJsonPath)) {
2865
+ if (!fs8.existsSync(packageJsonPath)) {
2805
2866
  console.log(`[fullstack-cli] \u25CB package.json (not found)`);
2806
2867
  return;
2807
2868
  }
2808
- const content = fs7.readFileSync(packageJsonPath, "utf-8");
2869
+ const content = fs8.readFileSync(packageJsonPath, "utf-8");
2809
2870
  const pkg2 = JSON.parse(content);
2810
2871
  if (!pkg2.scripts) {
2811
2872
  pkg2.scripts = {};
@@ -2817,42 +2878,42 @@ function addScript(packageJsonPath, name, command, overwrite) {
2817
2878
  }
2818
2879
  }
2819
2880
  pkg2.scripts[name] = command;
2820
- fs7.writeFileSync(packageJsonPath, JSON.stringify(pkg2, null, 2) + "\n");
2881
+ fs8.writeFileSync(packageJsonPath, JSON.stringify(pkg2, null, 2) + "\n");
2821
2882
  console.log(`[fullstack-cli] \u2713 scripts.${name}`);
2822
2883
  }
2823
2884
  function addLineToFile(filePath, line) {
2824
- const fileName = path5.basename(filePath);
2825
- if (!fs7.existsSync(filePath)) {
2885
+ const fileName = path6.basename(filePath);
2886
+ if (!fs8.existsSync(filePath)) {
2826
2887
  console.log(`[fullstack-cli] \u25CB ${fileName} (not found, skipped)`);
2827
2888
  return;
2828
2889
  }
2829
- const content = fs7.readFileSync(filePath, "utf-8");
2890
+ const content = fs8.readFileSync(filePath, "utf-8");
2830
2891
  const lines = content.split("\n").map((l) => l.trim());
2831
2892
  if (lines.includes(line)) {
2832
2893
  console.log(`[fullstack-cli] \u25CB ${fileName} (line already exists: ${line})`);
2833
2894
  return;
2834
2895
  }
2835
2896
  const appendContent = (content.endsWith("\n") ? "" : "\n") + line + "\n";
2836
- fs7.appendFileSync(filePath, appendContent);
2897
+ fs8.appendFileSync(filePath, appendContent);
2837
2898
  console.log(`[fullstack-cli] \u2713 ${fileName} (added: ${line})`);
2838
2899
  }
2839
2900
  function mergeJsonFile(src, dest, arrayMerge) {
2840
- const fileName = path5.basename(dest);
2841
- if (!fs7.existsSync(src)) {
2901
+ const fileName = path6.basename(dest);
2902
+ if (!fs8.existsSync(src)) {
2842
2903
  console.warn(`[fullstack-cli] Source not found: ${src}`);
2843
2904
  return;
2844
2905
  }
2845
- const templateContent = JSON.parse(fs7.readFileSync(src, "utf-8"));
2846
- if (!fs7.existsSync(dest)) {
2847
- const destDir = path5.dirname(dest);
2848
- if (!fs7.existsSync(destDir)) {
2849
- fs7.mkdirSync(destDir, { recursive: true });
2906
+ const templateContent = JSON.parse(fs8.readFileSync(src, "utf-8"));
2907
+ if (!fs8.existsSync(dest)) {
2908
+ const destDir = path6.dirname(dest);
2909
+ if (!fs8.existsSync(destDir)) {
2910
+ fs8.mkdirSync(destDir, { recursive: true });
2850
2911
  }
2851
- fs7.writeFileSync(dest, JSON.stringify(templateContent, null, 2) + "\n");
2912
+ fs8.writeFileSync(dest, JSON.stringify(templateContent, null, 2) + "\n");
2852
2913
  console.log(`[fullstack-cli] \u2713 ${fileName} (created)`);
2853
2914
  return;
2854
2915
  }
2855
- const userContent = JSON.parse(fs7.readFileSync(dest, "utf-8"));
2916
+ const userContent = JSON.parse(fs8.readFileSync(dest, "utf-8"));
2856
2917
  const merged = deepMergeJson(userContent, templateContent, arrayMerge ?? {});
2857
2918
  const userStr = JSON.stringify(userContent, null, 2);
2858
2919
  const mergedStr = JSON.stringify(merged, null, 2);
@@ -2860,7 +2921,7 @@ function mergeJsonFile(src, dest, arrayMerge) {
2860
2921
  console.log(`[fullstack-cli] \u25CB ${fileName} (already up to date)`);
2861
2922
  return;
2862
2923
  }
2863
- fs7.writeFileSync(dest, mergedStr + "\n");
2924
+ fs8.writeFileSync(dest, mergedStr + "\n");
2864
2925
  console.log(`[fullstack-cli] \u2713 ${fileName} (merged)`);
2865
2926
  }
2866
2927
 
@@ -2920,16 +2981,16 @@ async function reportCreateInstanceEvent(pluginKey, version) {
2920
2981
  }
2921
2982
 
2922
2983
  // src/utils/git.ts
2923
- import { execSync, spawnSync as spawnSync2 } from "child_process";
2924
- import fs8 from "fs";
2925
- import path6 from "path";
2984
+ import { execSync, spawnSync as spawnSync3 } from "child_process";
2985
+ import fs9 from "fs";
2986
+ import path7 from "path";
2926
2987
  function isGitRepository(cwd = process.cwd()) {
2927
2988
  try {
2928
- const gitDir = path6.join(cwd, ".git");
2929
- if (fs8.existsSync(gitDir)) {
2989
+ const gitDir = path7.join(cwd, ".git");
2990
+ if (fs9.existsSync(gitDir)) {
2930
2991
  return true;
2931
2992
  }
2932
- const result = spawnSync2("git", ["rev-parse", "--git-dir"], {
2993
+ const result = spawnSync3("git", ["rev-parse", "--git-dir"], {
2933
2994
  cwd,
2934
2995
  stdio: "pipe",
2935
2996
  encoding: "utf-8"
@@ -2955,11 +3016,11 @@ function getChangedFiles(cwd = process.cwd()) {
2955
3016
  function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
2956
3017
  const filteredFiles = [];
2957
3018
  for (const filePath of filesToStage) {
2958
- if (fs8.existsSync(path6.join(cwd, filePath))) {
3019
+ if (fs9.existsSync(path7.join(cwd, filePath))) {
2959
3020
  filteredFiles.push(filePath);
2960
3021
  continue;
2961
3022
  }
2962
- const tracked = spawnSync2("git", ["ls-files", "--error-unmatch", "--", filePath], {
3023
+ const tracked = spawnSync3("git", ["ls-files", "--error-unmatch", "--", filePath], {
2963
3024
  cwd,
2964
3025
  stdio: "pipe",
2965
3026
  encoding: "utf-8"
@@ -2971,7 +3032,7 @@ function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
2971
3032
  if (filteredFiles.length === 0) {
2972
3033
  return;
2973
3034
  }
2974
- const result = spawnSync2("git", ["add", "--", ...filteredFiles], {
3035
+ const result = spawnSync3("git", ["add", "--", ...filteredFiles], {
2975
3036
  cwd,
2976
3037
  stdio: "pipe",
2977
3038
  encoding: "utf-8"
@@ -2982,7 +3043,7 @@ function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
2982
3043
  }
2983
3044
  }
2984
3045
  function hasStagedChanges(cwd = process.cwd()) {
2985
- const result = spawnSync2("git", ["diff", "--cached", "--quiet"], {
3046
+ const result = spawnSync3("git", ["diff", "--cached", "--quiet"], {
2986
3047
  cwd,
2987
3048
  stdio: "pipe",
2988
3049
  encoding: "utf-8"
@@ -2997,7 +3058,7 @@ function hasStagedChanges(cwd = process.cwd()) {
2997
3058
  throw new Error(`Failed to check staged changes: ${errorMsg}`);
2998
3059
  }
2999
3060
  function gitCommit(message, cwd = process.cwd()) {
3000
- const result = spawnSync2("git", ["commit", "-m", message], {
3061
+ const result = spawnSync3("git", ["commit", "-m", message], {
3001
3062
  cwd,
3002
3063
  stdio: "pipe",
3003
3064
  encoding: "utf-8"
@@ -3040,15 +3101,15 @@ Auto-committed by fullstack-cli`;
3040
3101
  }
3041
3102
 
3042
3103
  // src/commands/upgrade/shared/utils.ts
3043
- import path7 from "path";
3044
- import fs9 from "fs";
3104
+ import path8 from "path";
3105
+ import fs10 from "fs";
3045
3106
  import { fileURLToPath as fileURLToPath4 } from "url";
3046
3107
  function getCliVersion() {
3047
3108
  try {
3048
3109
  const __filename = fileURLToPath4(import.meta.url);
3049
- const __dirname2 = path7.dirname(__filename);
3050
- const pkgPath = path7.resolve(__dirname2, "../../../package.json");
3051
- const pkgContent = fs9.readFileSync(pkgPath, "utf-8");
3110
+ const __dirname2 = path8.dirname(__filename);
3111
+ const pkgPath = path8.resolve(__dirname2, "../../../package.json");
3112
+ const pkgContent = fs10.readFileSync(pkgPath, "utf-8");
3052
3113
  const pkg2 = JSON.parse(pkgContent);
3053
3114
  return pkg2.version || "unknown";
3054
3115
  } catch {
@@ -3106,9 +3167,9 @@ async function run3(options = {}) {
3106
3167
  }
3107
3168
 
3108
3169
  // src/commands/upgrade/deps/run.handler.ts
3109
- import { spawnSync as spawnSync3 } from "child_process";
3110
- import fs10 from "fs";
3111
- import path8 from "path";
3170
+ import { spawnSync as spawnSync4 } from "child_process";
3171
+ import fs11 from "fs";
3172
+ import path9 from "path";
3112
3173
 
3113
3174
  // src/utils/grayscale/config.ts
3114
3175
  function getGrayscaleConfig(configJson) {
@@ -3327,7 +3388,7 @@ function upgradePackages(packages, version, cwd) {
3327
3388
  packages.forEach((pkg2) => {
3328
3389
  const target = `${pkg2}@${version}`;
3329
3390
  console.log(`[fullstack-cli] Installing ${target}...`);
3330
- const result = spawnSync3("npm", ["install", target], {
3391
+ const result = spawnSync4("npm", ["install", target], {
3331
3392
  cwd,
3332
3393
  stdio: "inherit"
3333
3394
  });
@@ -3339,7 +3400,7 @@ function upgradePackages(packages, version, cwd) {
3339
3400
  console.log("[fullstack-cli] Upgrading to latest compatible versions...");
3340
3401
  packages.forEach((pkg2) => {
3341
3402
  console.log(`[fullstack-cli] Updating ${pkg2}...`);
3342
- const result = spawnSync3("npm", ["update", pkg2], {
3403
+ const result = spawnSync4("npm", ["update", pkg2], {
3343
3404
  cwd,
3344
3405
  stdio: "inherit"
3345
3406
  });
@@ -3356,8 +3417,8 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
3356
3417
  if (version) {
3357
3418
  let current = "";
3358
3419
  try {
3359
- const installedPkgPath = path8.join(cwd, "node_modules", pkg2, "package.json");
3360
- const installedPkg = JSON.parse(fs10.readFileSync(installedPkgPath, "utf-8"));
3420
+ const installedPkgPath = path9.join(cwd, "node_modules", pkg2, "package.json");
3421
+ const installedPkg = JSON.parse(fs11.readFileSync(installedPkgPath, "utf-8"));
3361
3422
  current = installedPkg.version || "";
3362
3423
  } catch (err) {
3363
3424
  const code = err?.code;
@@ -3400,7 +3461,7 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
3400
3461
  }
3401
3462
  const targets = upgradePlan.map(({ pkg: pkg2, version }) => `${pkg2}@${version}`);
3402
3463
  console.log(`[fullstack-cli] Installing ${targets.join(" ")}...`);
3403
- const result = spawnSync3("npm", ["install", ...targets], {
3464
+ const result = spawnSync4("npm", ["install", ...targets], {
3404
3465
  cwd,
3405
3466
  stdio: "inherit"
3406
3467
  });
@@ -3474,9 +3535,9 @@ var depsCommand = {
3474
3535
  };
3475
3536
 
3476
3537
  // src/commands/upgrade/global-deps/run.handler.ts
3477
- import { spawnSync as spawnSync4 } from "child_process";
3478
- import fs11 from "fs";
3479
- import path9 from "path";
3538
+ import { spawnSync as spawnSync5 } from "child_process";
3539
+ import fs12 from "fs";
3540
+ import path10 from "path";
3480
3541
  var MANAGED_GLOBAL_CLIS = [
3481
3542
  "@lark-apaas/fullstack-cli",
3482
3543
  "@lark-apaas/miaoda-cli"
@@ -3487,15 +3548,15 @@ function readGlobalInstalledVersion(pkg2) {
3487
3548
  if (process.env.NPM_CONFIG_PREFIX) candidates.push(process.env.NPM_CONFIG_PREFIX);
3488
3549
  candidates.push("/usr");
3489
3550
  candidates.push("/usr/local");
3490
- if (process.env.HOME) candidates.push(path9.join(process.env.HOME, ".npm-global"));
3551
+ if (process.env.HOME) candidates.push(path10.join(process.env.HOME, ".npm-global"));
3491
3552
  const seen = /* @__PURE__ */ new Set();
3492
3553
  for (const prefix of candidates) {
3493
3554
  if (seen.has(prefix)) continue;
3494
3555
  seen.add(prefix);
3495
3556
  try {
3496
- const pkgPath = path9.join(prefix, "lib", "node_modules", pkg2, "package.json");
3497
- if (fs11.existsSync(pkgPath)) {
3498
- const meta = JSON.parse(fs11.readFileSync(pkgPath, "utf-8"));
3557
+ const pkgPath = path10.join(prefix, "lib", "node_modules", pkg2, "package.json");
3558
+ if (fs12.existsSync(pkgPath)) {
3559
+ const meta = JSON.parse(fs12.readFileSync(pkgPath, "utf-8"));
3499
3560
  if (meta && typeof meta.version === "string") return meta.version;
3500
3561
  }
3501
3562
  } catch (err) {
@@ -3553,7 +3614,7 @@ async function run5(options = {}) {
3553
3614
  npmArgs.push("--registry", options.registry);
3554
3615
  }
3555
3616
  console.log(`[fullstack-cli] Running: npm ${npmArgs.join(" ")}`);
3556
- const result = spawnSync4("npm", npmArgs, { stdio: "inherit" });
3617
+ const result = spawnSync5("npm", npmArgs, { stdio: "inherit" });
3557
3618
  if (result.error || result.status !== 0) {
3558
3619
  console.warn(
3559
3620
  `[fullstack-cli] npm install -g failed: ${result.error?.message ?? `exit ${result.status}`}`
@@ -3592,9 +3653,9 @@ var upgradeCommand = {
3592
3653
  };
3593
3654
 
3594
3655
  // src/commands/action-plugin/utils.ts
3595
- import fs12 from "fs";
3596
- import path10 from "path";
3597
- import { spawnSync as spawnSync5, execSync as execSync2 } from "child_process";
3656
+ import fs13 from "fs";
3657
+ import path11 from "path";
3658
+ import { spawnSync as spawnSync6, execSync as execSync2 } from "child_process";
3598
3659
  function parsePluginName(input) {
3599
3660
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
3600
3661
  if (!match) {
@@ -3611,18 +3672,18 @@ function getProjectRoot() {
3611
3672
  return process.cwd();
3612
3673
  }
3613
3674
  function getPackageJsonPath() {
3614
- return path10.join(getProjectRoot(), "package.json");
3675
+ return path11.join(getProjectRoot(), "package.json");
3615
3676
  }
3616
3677
  function getPluginPath(pluginName) {
3617
- return path10.join(getProjectRoot(), "node_modules", pluginName);
3678
+ return path11.join(getProjectRoot(), "node_modules", pluginName);
3618
3679
  }
3619
3680
  function readPackageJson2() {
3620
3681
  const pkgPath = getPackageJsonPath();
3621
- if (!fs12.existsSync(pkgPath)) {
3682
+ if (!fs13.existsSync(pkgPath)) {
3622
3683
  throw new Error("package.json not found in current directory");
3623
3684
  }
3624
3685
  try {
3625
- const content = fs12.readFileSync(pkgPath, "utf-8");
3686
+ const content = fs13.readFileSync(pkgPath, "utf-8");
3626
3687
  return JSON.parse(content);
3627
3688
  } catch {
3628
3689
  throw new Error("Failed to parse package.json");
@@ -3630,7 +3691,7 @@ function readPackageJson2() {
3630
3691
  }
3631
3692
  function writePackageJson2(pkg2) {
3632
3693
  const pkgPath = getPackageJsonPath();
3633
- fs12.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3694
+ fs13.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3634
3695
  }
3635
3696
  function readActionPlugins() {
3636
3697
  const pkg2 = readPackageJson2();
@@ -3651,7 +3712,7 @@ function getInstalledPluginVersion(pluginName) {
3651
3712
  }
3652
3713
  function npmInstall(tgzPath) {
3653
3714
  console.log(`[action-plugin] Running npm install ${tgzPath}...`);
3654
- const result = spawnSync5("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
3715
+ const result = spawnSync6("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
3655
3716
  cwd: getProjectRoot(),
3656
3717
  stdio: "inherit"
3657
3718
  });
@@ -3663,12 +3724,12 @@ function npmInstall(tgzPath) {
3663
3724
  }
3664
3725
  }
3665
3726
  function getPackageVersion(pluginName) {
3666
- const pkgJsonPath = path10.join(getPluginPath(pluginName), "package.json");
3667
- if (!fs12.existsSync(pkgJsonPath)) {
3727
+ const pkgJsonPath = path11.join(getPluginPath(pluginName), "package.json");
3728
+ if (!fs13.existsSync(pkgJsonPath)) {
3668
3729
  return null;
3669
3730
  }
3670
3731
  try {
3671
- const content = fs12.readFileSync(pkgJsonPath, "utf-8");
3732
+ const content = fs13.readFileSync(pkgJsonPath, "utf-8");
3672
3733
  const pkg2 = JSON.parse(content);
3673
3734
  return pkg2.version || null;
3674
3735
  } catch {
@@ -3676,49 +3737,49 @@ function getPackageVersion(pluginName) {
3676
3737
  }
3677
3738
  }
3678
3739
  function readPluginPackageJson(pluginPath) {
3679
- const pkgJsonPath = path10.join(pluginPath, "package.json");
3680
- if (!fs12.existsSync(pkgJsonPath)) {
3740
+ const pkgJsonPath = path11.join(pluginPath, "package.json");
3741
+ if (!fs13.existsSync(pkgJsonPath)) {
3681
3742
  return null;
3682
3743
  }
3683
3744
  try {
3684
- const content = fs12.readFileSync(pkgJsonPath, "utf-8");
3745
+ const content = fs13.readFileSync(pkgJsonPath, "utf-8");
3685
3746
  return JSON.parse(content);
3686
3747
  } catch {
3687
3748
  return null;
3688
3749
  }
3689
3750
  }
3690
3751
  function extractTgzToNodeModules(tgzPath, pluginName) {
3691
- const nodeModulesPath = path10.join(getProjectRoot(), "node_modules");
3692
- const targetDir = path10.join(nodeModulesPath, pluginName);
3693
- const scopeDir = path10.dirname(targetDir);
3694
- if (!fs12.existsSync(scopeDir)) {
3695
- fs12.mkdirSync(scopeDir, { recursive: true });
3752
+ const nodeModulesPath = path11.join(getProjectRoot(), "node_modules");
3753
+ const targetDir = path11.join(nodeModulesPath, pluginName);
3754
+ const scopeDir = path11.dirname(targetDir);
3755
+ if (!fs13.existsSync(scopeDir)) {
3756
+ fs13.mkdirSync(scopeDir, { recursive: true });
3696
3757
  }
3697
- if (fs12.existsSync(targetDir)) {
3698
- fs12.rmSync(targetDir, { recursive: true });
3758
+ if (fs13.existsSync(targetDir)) {
3759
+ fs13.rmSync(targetDir, { recursive: true });
3699
3760
  }
3700
- const tempDir = path10.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3701
- if (fs12.existsSync(tempDir)) {
3702
- fs12.rmSync(tempDir, { recursive: true });
3761
+ const tempDir = path11.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3762
+ if (fs13.existsSync(tempDir)) {
3763
+ fs13.rmSync(tempDir, { recursive: true });
3703
3764
  }
3704
- fs12.mkdirSync(tempDir, { recursive: true });
3765
+ fs13.mkdirSync(tempDir, { recursive: true });
3705
3766
  try {
3706
3767
  execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
3707
- const extractedDir = path10.join(tempDir, "package");
3708
- if (fs12.existsSync(extractedDir)) {
3709
- fs12.renameSync(extractedDir, targetDir);
3768
+ const extractedDir = path11.join(tempDir, "package");
3769
+ if (fs13.existsSync(extractedDir)) {
3770
+ fs13.renameSync(extractedDir, targetDir);
3710
3771
  } else {
3711
- const files = fs12.readdirSync(tempDir);
3772
+ const files = fs13.readdirSync(tempDir);
3712
3773
  if (files.length === 1) {
3713
- fs12.renameSync(path10.join(tempDir, files[0]), targetDir);
3774
+ fs13.renameSync(path11.join(tempDir, files[0]), targetDir);
3714
3775
  } else {
3715
3776
  throw new Error("Unexpected tgz structure");
3716
3777
  }
3717
3778
  }
3718
3779
  return targetDir;
3719
3780
  } finally {
3720
- if (fs12.existsSync(tempDir)) {
3721
- fs12.rmSync(tempDir, { recursive: true });
3781
+ if (fs13.existsSync(tempDir)) {
3782
+ fs13.rmSync(tempDir, { recursive: true });
3722
3783
  }
3723
3784
  }
3724
3785
  }
@@ -3727,10 +3788,10 @@ function checkMissingPeerDeps(peerDeps) {
3727
3788
  return [];
3728
3789
  }
3729
3790
  const missing = [];
3730
- const nodeModulesPath = path10.join(getProjectRoot(), "node_modules");
3791
+ const nodeModulesPath = path11.join(getProjectRoot(), "node_modules");
3731
3792
  for (const [depName, _version] of Object.entries(peerDeps)) {
3732
- const depPath = path10.join(nodeModulesPath, depName);
3733
- if (!fs12.existsSync(depPath)) {
3793
+ const depPath = path11.join(nodeModulesPath, depName);
3794
+ if (!fs13.existsSync(depPath)) {
3734
3795
  missing.push(depName);
3735
3796
  }
3736
3797
  }
@@ -3741,7 +3802,7 @@ function installMissingDeps(deps) {
3741
3802
  return;
3742
3803
  }
3743
3804
  console.log(`[action-plugin] Installing missing dependencies: ${deps.join(", ")}`);
3744
- const result = spawnSync5("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
3805
+ const result = spawnSync6("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
3745
3806
  cwd: getProjectRoot(),
3746
3807
  stdio: "inherit"
3747
3808
  });
@@ -3754,16 +3815,16 @@ function installMissingDeps(deps) {
3754
3815
  }
3755
3816
  function removePluginDirectory(pluginName) {
3756
3817
  const pluginPath = getPluginPath(pluginName);
3757
- if (fs12.existsSync(pluginPath)) {
3758
- fs12.rmSync(pluginPath, { recursive: true });
3818
+ if (fs13.existsSync(pluginPath)) {
3819
+ fs13.rmSync(pluginPath, { recursive: true });
3759
3820
  console.log(`[action-plugin] Removed ${pluginName}`);
3760
3821
  }
3761
3822
  }
3762
3823
 
3763
3824
  // src/commands/action-plugin/api-client.ts
3764
3825
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
3765
- import fs13 from "fs";
3766
- import path11 from "path";
3826
+ import fs14 from "fs";
3827
+ import path12 from "path";
3767
3828
  var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
3768
3829
  async function getPluginVersions(keys, latestOnly = true) {
3769
3830
  const client = getHttpClient();
@@ -3827,19 +3888,19 @@ async function downloadFromPublic(downloadURL) {
3827
3888
  return Buffer.from(arrayBuffer);
3828
3889
  }
3829
3890
  function getPluginCacheDir() {
3830
- return path11.join(process.cwd(), PLUGIN_CACHE_DIR);
3891
+ return path12.join(process.cwd(), PLUGIN_CACHE_DIR);
3831
3892
  }
3832
3893
  function ensureCacheDir() {
3833
3894
  const cacheDir = getPluginCacheDir();
3834
- if (!fs13.existsSync(cacheDir)) {
3835
- fs13.mkdirSync(cacheDir, { recursive: true });
3895
+ if (!fs14.existsSync(cacheDir)) {
3896
+ fs14.mkdirSync(cacheDir, { recursive: true });
3836
3897
  }
3837
3898
  }
3838
3899
  function getTempFilePath(pluginKey, version) {
3839
3900
  ensureCacheDir();
3840
3901
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3841
3902
  const filename = `${safeKey}@${version}.tgz`;
3842
- return path11.join(getPluginCacheDir(), filename);
3903
+ return path12.join(getPluginCacheDir(), filename);
3843
3904
  }
3844
3905
  var MAX_RETRIES = 2;
3845
3906
  async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
@@ -3876,7 +3937,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
3876
3937
  );
3877
3938
  }
3878
3939
  const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
3879
- fs13.writeFileSync(tgzPath, tgzBuffer);
3940
+ fs14.writeFileSync(tgzPath, tgzBuffer);
3880
3941
  console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
3881
3942
  return {
3882
3943
  tgzPath,
@@ -3890,18 +3951,18 @@ function getCachePath(pluginKey, version) {
3890
3951
  ensureCacheDir();
3891
3952
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3892
3953
  const filename = `${safeKey}@${version}.tgz`;
3893
- return path11.join(getPluginCacheDir(), filename);
3954
+ return path12.join(getPluginCacheDir(), filename);
3894
3955
  }
3895
3956
  function hasCachedPlugin(pluginKey, version) {
3896
3957
  const cachePath = getCachePath(pluginKey, version);
3897
- return fs13.existsSync(cachePath);
3958
+ return fs14.existsSync(cachePath);
3898
3959
  }
3899
3960
  function listCachedPlugins() {
3900
3961
  const cacheDir = getPluginCacheDir();
3901
- if (!fs13.existsSync(cacheDir)) {
3962
+ if (!fs14.existsSync(cacheDir)) {
3902
3963
  return [];
3903
3964
  }
3904
- const files = fs13.readdirSync(cacheDir);
3965
+ const files = fs14.readdirSync(cacheDir);
3905
3966
  const result = [];
3906
3967
  for (const file of files) {
3907
3968
  if (!file.endsWith(".tgz")) continue;
@@ -3909,8 +3970,8 @@ function listCachedPlugins() {
3909
3970
  if (!match) continue;
3910
3971
  const [, rawName, version] = match;
3911
3972
  const name = rawName.replace(/^_/, "@").replace(/_/, "/");
3912
- const filePath = path11.join(cacheDir, file);
3913
- const stat = fs13.statSync(filePath);
3973
+ const filePath = path12.join(cacheDir, file);
3974
+ const stat = fs14.statSync(filePath);
3914
3975
  result.push({
3915
3976
  name,
3916
3977
  version,
@@ -3923,14 +3984,14 @@ function listCachedPlugins() {
3923
3984
  }
3924
3985
  function cleanAllCache() {
3925
3986
  const cacheDir = getPluginCacheDir();
3926
- if (!fs13.existsSync(cacheDir)) {
3987
+ if (!fs14.existsSync(cacheDir)) {
3927
3988
  return 0;
3928
3989
  }
3929
- const files = fs13.readdirSync(cacheDir);
3990
+ const files = fs14.readdirSync(cacheDir);
3930
3991
  let count = 0;
3931
3992
  for (const file of files) {
3932
3993
  if (file.endsWith(".tgz")) {
3933
- fs13.unlinkSync(path11.join(cacheDir, file));
3994
+ fs14.unlinkSync(path12.join(cacheDir, file));
3934
3995
  count++;
3935
3996
  }
3936
3997
  }
@@ -3938,21 +3999,21 @@ function cleanAllCache() {
3938
3999
  }
3939
4000
  function cleanPluginCache(pluginKey, version) {
3940
4001
  const cacheDir = getPluginCacheDir();
3941
- if (!fs13.existsSync(cacheDir)) {
4002
+ if (!fs14.existsSync(cacheDir)) {
3942
4003
  return 0;
3943
4004
  }
3944
4005
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3945
- const files = fs13.readdirSync(cacheDir);
4006
+ const files = fs14.readdirSync(cacheDir);
3946
4007
  let count = 0;
3947
4008
  for (const file of files) {
3948
4009
  if (version) {
3949
4010
  if (file === `${safeKey}@${version}.tgz`) {
3950
- fs13.unlinkSync(path11.join(cacheDir, file));
4011
+ fs14.unlinkSync(path12.join(cacheDir, file));
3951
4012
  count++;
3952
4013
  }
3953
4014
  } else {
3954
4015
  if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
3955
- fs13.unlinkSync(path11.join(cacheDir, file));
4016
+ fs14.unlinkSync(path12.join(cacheDir, file));
3956
4017
  count++;
3957
4018
  }
3958
4019
  }
@@ -4379,40 +4440,40 @@ var actionPluginCommandGroup = {
4379
4440
  };
4380
4441
 
4381
4442
  // src/commands/capability/utils.ts
4382
- import fs14 from "fs";
4443
+ import fs15 from "fs";
4383
4444
  import { createRequire as createRequire2 } from "module";
4384
- import path12 from "path";
4445
+ import path13 from "path";
4385
4446
  var CAPABILITIES_DIR = "server/capabilities";
4386
4447
  function getProjectRoot2() {
4387
4448
  return process.cwd();
4388
4449
  }
4389
4450
  function getCapabilitiesDir() {
4390
- return path12.join(getProjectRoot2(), CAPABILITIES_DIR);
4451
+ return path13.join(getProjectRoot2(), CAPABILITIES_DIR);
4391
4452
  }
4392
4453
  function getCapabilityPath(id) {
4393
- return path12.join(getCapabilitiesDir(), `${id}.json`);
4454
+ return path13.join(getCapabilitiesDir(), `${id}.json`);
4394
4455
  }
4395
4456
  function getPluginManifestPath(pluginKey) {
4396
- return path12.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4457
+ return path13.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4397
4458
  }
4398
4459
  function capabilitiesDirExists() {
4399
- return fs14.existsSync(getCapabilitiesDir());
4460
+ return fs15.existsSync(getCapabilitiesDir());
4400
4461
  }
4401
4462
  function listCapabilityIds() {
4402
4463
  const dir = getCapabilitiesDir();
4403
- if (!fs14.existsSync(dir)) {
4464
+ if (!fs15.existsSync(dir)) {
4404
4465
  return [];
4405
4466
  }
4406
- const files = fs14.readdirSync(dir);
4467
+ const files = fs15.readdirSync(dir);
4407
4468
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
4408
4469
  }
4409
4470
  function readCapability(id) {
4410
4471
  const filePath = getCapabilityPath(id);
4411
- if (!fs14.existsSync(filePath)) {
4472
+ if (!fs15.existsSync(filePath)) {
4412
4473
  throw new Error(`Capability not found: ${id}`);
4413
4474
  }
4414
4475
  try {
4415
- const content = fs14.readFileSync(filePath, "utf-8");
4476
+ const content = fs15.readFileSync(filePath, "utf-8");
4416
4477
  return JSON.parse(content);
4417
4478
  } catch (error) {
4418
4479
  if (error instanceof SyntaxError) {
@@ -4439,11 +4500,11 @@ function readAllCapabilities() {
4439
4500
  }
4440
4501
  function readPluginManifest(pluginKey) {
4441
4502
  const manifestPath = getPluginManifestPath(pluginKey);
4442
- if (!fs14.existsSync(manifestPath)) {
4503
+ if (!fs15.existsSync(manifestPath)) {
4443
4504
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
4444
4505
  }
4445
4506
  try {
4446
- const content = fs14.readFileSync(manifestPath, "utf-8");
4507
+ const content = fs15.readFileSync(manifestPath, "utf-8");
4447
4508
  return JSON.parse(content);
4448
4509
  } catch (error) {
4449
4510
  if (error instanceof SyntaxError) {
@@ -4460,7 +4521,7 @@ function hasValidParamsSchema(paramsSchema) {
4460
4521
  }
4461
4522
  async function loadPlugin(pluginKey) {
4462
4523
  try {
4463
- const userRequire = createRequire2(path12.join(getProjectRoot2(), "package.json"));
4524
+ const userRequire = createRequire2(path13.join(getProjectRoot2(), "package.json"));
4464
4525
  const resolvedPath = userRequire.resolve(pluginKey);
4465
4526
  const pluginModule = await import(resolvedPath);
4466
4527
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -4623,8 +4684,8 @@ var capabilityCommandGroup = {
4623
4684
  import { execFile } from "child_process";
4624
4685
 
4625
4686
  // src/commands/component/registry-preparer.ts
4626
- import fs15 from "fs";
4627
- import path13 from "path";
4687
+ import fs16 from "fs";
4688
+ import path14 from "path";
4628
4689
  import os from "os";
4629
4690
 
4630
4691
  // src/commands/component/service.ts
@@ -4680,7 +4741,7 @@ async function sendInstallEvent(key) {
4680
4741
  }
4681
4742
 
4682
4743
  // src/commands/component/registry-preparer.ts
4683
- var REGISTRY_TEMP_DIR = path13.join(os.tmpdir(), "miaoda-registry");
4744
+ var REGISTRY_TEMP_DIR = path14.join(os.tmpdir(), "miaoda-registry");
4684
4745
  function parseComponentKey(key) {
4685
4746
  const match = key.match(/^@([^/]+)\/(.+)$/);
4686
4747
  if (!match) {
@@ -4692,11 +4753,11 @@ function parseComponentKey(key) {
4692
4753
  }
4693
4754
  function getLocalRegistryPath(key) {
4694
4755
  const { scope, name } = parseComponentKey(key);
4695
- return path13.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4756
+ return path14.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4696
4757
  }
4697
4758
  function ensureDir(dirPath) {
4698
- if (!fs15.existsSync(dirPath)) {
4699
- fs15.mkdirSync(dirPath, { recursive: true });
4759
+ if (!fs16.existsSync(dirPath)) {
4760
+ fs16.mkdirSync(dirPath, { recursive: true });
4700
4761
  }
4701
4762
  }
4702
4763
  async function prepareRecursive(key, visited) {
@@ -4729,8 +4790,8 @@ async function prepareRecursive(key, visited) {
4729
4790
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
4730
4791
  };
4731
4792
  const localPath = getLocalRegistryPath(key);
4732
- ensureDir(path13.dirname(localPath));
4733
- fs15.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4793
+ ensureDir(path14.dirname(localPath));
4794
+ fs16.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4734
4795
  debug("\u4FDD\u5B58\u5230: %s", localPath);
4735
4796
  }
4736
4797
  async function prepareComponentRegistryItems(id) {
@@ -4740,18 +4801,18 @@ async function prepareComponentRegistryItems(id) {
4740
4801
  }
4741
4802
  function cleanupTempDir() {
4742
4803
  try {
4743
- if (fs15.existsSync(REGISTRY_TEMP_DIR)) {
4744
- fs15.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4804
+ if (fs16.existsSync(REGISTRY_TEMP_DIR)) {
4805
+ fs16.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4745
4806
  }
4746
4807
  } catch {
4747
4808
  }
4748
4809
  }
4749
4810
  function getDownloadedRegistryItem(itemId) {
4750
4811
  const localPath = getLocalRegistryPath(itemId);
4751
- if (!fs15.existsSync(localPath)) {
4812
+ if (!fs16.existsSync(localPath)) {
4752
4813
  return null;
4753
4814
  }
4754
- const content = fs15.readFileSync(localPath, "utf-8");
4815
+ const content = fs16.readFileSync(localPath, "utf-8");
4755
4816
  return JSON.parse(content);
4756
4817
  }
4757
4818
 
@@ -4919,58 +4980,58 @@ var componentCommandGroup = {
4919
4980
  };
4920
4981
 
4921
4982
  // src/commands/migration/version-manager.ts
4922
- import fs16 from "fs";
4923
- import path14 from "path";
4983
+ import fs17 from "fs";
4984
+ import path15 from "path";
4924
4985
  var PACKAGE_JSON = "package.json";
4925
4986
  var VERSION_FIELD = "migrationVersion";
4926
4987
  function getPackageJsonPath2() {
4927
- return path14.join(process.cwd(), PACKAGE_JSON);
4988
+ return path15.join(process.cwd(), PACKAGE_JSON);
4928
4989
  }
4929
4990
  function getCurrentVersion() {
4930
4991
  const pkgPath = getPackageJsonPath2();
4931
- if (!fs16.existsSync(pkgPath)) {
4992
+ if (!fs17.existsSync(pkgPath)) {
4932
4993
  throw new Error("package.json not found");
4933
4994
  }
4934
- const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
4995
+ const pkg2 = JSON.parse(fs17.readFileSync(pkgPath, "utf-8"));
4935
4996
  return pkg2[VERSION_FIELD] ?? 0;
4936
4997
  }
4937
4998
  function setCurrentVersion(version) {
4938
4999
  const pkgPath = getPackageJsonPath2();
4939
- const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
5000
+ const pkg2 = JSON.parse(fs17.readFileSync(pkgPath, "utf-8"));
4940
5001
  pkg2[VERSION_FIELD] = version;
4941
- fs16.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
5002
+ fs17.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4942
5003
  }
4943
5004
 
4944
5005
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4945
- import fs18 from "fs";
4946
- import path16 from "path";
5006
+ import fs19 from "fs";
5007
+ import path17 from "path";
4947
5008
 
4948
5009
  // src/commands/migration/versions/v001_capability/utils.ts
4949
- import fs17 from "fs";
4950
- import path15 from "path";
5010
+ import fs18 from "fs";
5011
+ import path16 from "path";
4951
5012
  var CAPABILITIES_DIR2 = "server/capabilities";
4952
5013
  function getProjectRoot3() {
4953
5014
  return process.cwd();
4954
5015
  }
4955
5016
  function getCapabilitiesDir2() {
4956
- return path15.join(getProjectRoot3(), CAPABILITIES_DIR2);
5017
+ return path16.join(getProjectRoot3(), CAPABILITIES_DIR2);
4957
5018
  }
4958
5019
  function getPluginManifestPath2(pluginKey) {
4959
- return path15.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
5020
+ return path16.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4960
5021
  }
4961
5022
 
4962
5023
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4963
5024
  function detectJsonMigration() {
4964
5025
  const capabilitiesDir = getCapabilitiesDir2();
4965
- const oldFilePath = path16.join(capabilitiesDir, "capabilities.json");
4966
- if (!fs18.existsSync(oldFilePath)) {
5026
+ const oldFilePath = path17.join(capabilitiesDir, "capabilities.json");
5027
+ if (!fs19.existsSync(oldFilePath)) {
4967
5028
  return {
4968
5029
  needsMigration: false,
4969
5030
  reason: "capabilities.json not found"
4970
5031
  };
4971
5032
  }
4972
5033
  try {
4973
- const content = fs18.readFileSync(oldFilePath, "utf-8");
5034
+ const content = fs19.readFileSync(oldFilePath, "utf-8");
4974
5035
  const parsed = JSON.parse(content);
4975
5036
  if (!Array.isArray(parsed)) {
4976
5037
  return {
@@ -5021,8 +5082,8 @@ async function check(options) {
5021
5082
  }
5022
5083
 
5023
5084
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5024
- import fs19 from "fs";
5025
- import path17 from "path";
5085
+ import fs20 from "fs";
5086
+ import path18 from "path";
5026
5087
 
5027
5088
  // src/commands/migration/versions/v001_capability/mapping.ts
5028
5089
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -5252,18 +5313,18 @@ function transformCapabilities(oldCapabilities) {
5252
5313
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5253
5314
  function loadExistingCapabilities() {
5254
5315
  const capabilitiesDir = getCapabilitiesDir2();
5255
- if (!fs19.existsSync(capabilitiesDir)) {
5316
+ if (!fs20.existsSync(capabilitiesDir)) {
5256
5317
  return [];
5257
5318
  }
5258
- const files = fs19.readdirSync(capabilitiesDir);
5319
+ const files = fs20.readdirSync(capabilitiesDir);
5259
5320
  const capabilities = [];
5260
5321
  for (const file of files) {
5261
5322
  if (file === "capabilities.json" || !file.endsWith(".json")) {
5262
5323
  continue;
5263
5324
  }
5264
5325
  try {
5265
- const filePath = path17.join(capabilitiesDir, file);
5266
- const content = fs19.readFileSync(filePath, "utf-8");
5326
+ const filePath = path18.join(capabilitiesDir, file);
5327
+ const content = fs20.readFileSync(filePath, "utf-8");
5267
5328
  const capability = JSON.parse(content);
5268
5329
  if (capability.id && capability.pluginKey) {
5269
5330
  capabilities.push(capability);
@@ -5321,9 +5382,9 @@ async function migrateJsonFiles(options) {
5321
5382
  }
5322
5383
  const capabilitiesDir = getCapabilitiesDir2();
5323
5384
  for (const cap of newCapabilities) {
5324
- const filePath = path17.join(capabilitiesDir, `${cap.id}.json`);
5385
+ const filePath = path18.join(capabilitiesDir, `${cap.id}.json`);
5325
5386
  const content = JSON.stringify(cap, null, 2);
5326
- fs19.writeFileSync(filePath, content, "utf-8");
5387
+ fs20.writeFileSync(filePath, content, "utf-8");
5327
5388
  console.log(` \u2713 Created: ${cap.id}.json`);
5328
5389
  }
5329
5390
  return {
@@ -5335,11 +5396,11 @@ async function migrateJsonFiles(options) {
5335
5396
  }
5336
5397
 
5337
5398
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
5338
- import fs20 from "fs";
5399
+ import fs21 from "fs";
5339
5400
  function isPluginInstalled2(pluginKey) {
5340
5401
  const actionPlugins = readActionPlugins();
5341
5402
  const manifestPath = getPluginManifestPath2(pluginKey);
5342
- return fs20.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5403
+ return fs21.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5343
5404
  }
5344
5405
  function detectPluginsToInstall(capabilities) {
5345
5406
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -5415,12 +5476,12 @@ async function installPlugins(capabilities, options) {
5415
5476
  }
5416
5477
 
5417
5478
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
5418
- import path19 from "path";
5479
+ import path20 from "path";
5419
5480
  import { Project as Project3 } from "ts-morph";
5420
5481
 
5421
5482
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
5422
- import fs21 from "fs";
5423
- import path18 from "path";
5483
+ import fs22 from "fs";
5484
+ import path19 from "path";
5424
5485
  var EXCLUDED_DIRS = [
5425
5486
  "node_modules",
5426
5487
  "dist",
@@ -5435,9 +5496,9 @@ var EXCLUDED_PATTERNS = [
5435
5496
  /\.d\.ts$/
5436
5497
  ];
5437
5498
  function scanDirectory(dir, files = []) {
5438
- const entries = fs21.readdirSync(dir, { withFileTypes: true });
5499
+ const entries = fs22.readdirSync(dir, { withFileTypes: true });
5439
5500
  for (const entry of entries) {
5440
- const fullPath = path18.join(dir, entry.name);
5501
+ const fullPath = path19.join(dir, entry.name);
5441
5502
  if (entry.isDirectory()) {
5442
5503
  if (EXCLUDED_DIRS.includes(entry.name)) {
5443
5504
  continue;
@@ -5453,14 +5514,14 @@ function scanDirectory(dir, files = []) {
5453
5514
  return files;
5454
5515
  }
5455
5516
  function scanServerFiles() {
5456
- const serverDir = path18.join(getProjectRoot3(), "server");
5457
- if (!fs21.existsSync(serverDir)) {
5517
+ const serverDir = path19.join(getProjectRoot3(), "server");
5518
+ if (!fs22.existsSync(serverDir)) {
5458
5519
  return [];
5459
5520
  }
5460
5521
  return scanDirectory(serverDir);
5461
5522
  }
5462
5523
  function hasCapabilityImport(filePath) {
5463
- const content = fs21.readFileSync(filePath, "utf-8");
5524
+ const content = fs22.readFileSync(filePath, "utf-8");
5464
5525
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
5465
5526
  }
5466
5527
  function scanFilesToMigrate() {
@@ -5837,7 +5898,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5837
5898
  const callSites = analyzeCallSites(sourceFile, imports);
5838
5899
  const classInfo = analyzeClass(sourceFile);
5839
5900
  const { canMigrate, reason } = canAutoMigrate(classInfo);
5840
- const relativePath = path19.relative(getProjectRoot3(), filePath);
5901
+ const relativePath = path20.relative(getProjectRoot3(), filePath);
5841
5902
  return {
5842
5903
  filePath: relativePath,
5843
5904
  imports,
@@ -5848,7 +5909,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5848
5909
  };
5849
5910
  }
5850
5911
  function migrateFile(project, analysis, dryRun) {
5851
- const absolutePath = path19.join(getProjectRoot3(), analysis.filePath);
5912
+ const absolutePath = path20.join(getProjectRoot3(), analysis.filePath);
5852
5913
  if (!analysis.canAutoMigrate) {
5853
5914
  return {
5854
5915
  filePath: analysis.filePath,
@@ -5951,17 +6012,17 @@ function getSuggestion(analysis) {
5951
6012
  }
5952
6013
 
5953
6014
  // src/commands/migration/versions/v001_capability/cleanup.ts
5954
- import fs22 from "fs";
5955
- import path20 from "path";
6015
+ import fs23 from "fs";
6016
+ import path21 from "path";
5956
6017
  function cleanupOldFiles(capabilities, dryRun) {
5957
6018
  const deletedFiles = [];
5958
6019
  const errors = [];
5959
6020
  const capabilitiesDir = getCapabilitiesDir2();
5960
- const oldJsonPath = path20.join(capabilitiesDir, "capabilities.json");
5961
- if (fs22.existsSync(oldJsonPath)) {
6021
+ const oldJsonPath = path21.join(capabilitiesDir, "capabilities.json");
6022
+ if (fs23.existsSync(oldJsonPath)) {
5962
6023
  try {
5963
6024
  if (!dryRun) {
5964
- fs22.unlinkSync(oldJsonPath);
6025
+ fs23.unlinkSync(oldJsonPath);
5965
6026
  }
5966
6027
  deletedFiles.push("capabilities.json");
5967
6028
  } catch (error) {
@@ -5969,11 +6030,11 @@ function cleanupOldFiles(capabilities, dryRun) {
5969
6030
  }
5970
6031
  }
5971
6032
  for (const cap of capabilities) {
5972
- const tsFilePath = path20.join(capabilitiesDir, `${cap.id}.ts`);
5973
- if (fs22.existsSync(tsFilePath)) {
6033
+ const tsFilePath = path21.join(capabilitiesDir, `${cap.id}.ts`);
6034
+ if (fs23.existsSync(tsFilePath)) {
5974
6035
  try {
5975
6036
  if (!dryRun) {
5976
- fs22.unlinkSync(tsFilePath);
6037
+ fs23.unlinkSync(tsFilePath);
5977
6038
  }
5978
6039
  deletedFiles.push(`${cap.id}.ts`);
5979
6040
  } catch (error) {
@@ -5989,8 +6050,8 @@ function cleanupOldFiles(capabilities, dryRun) {
5989
6050
  }
5990
6051
 
5991
6052
  // src/commands/migration/versions/v001_capability/report-generator.ts
5992
- import fs23 from "fs";
5993
- import path21 from "path";
6053
+ import fs24 from "fs";
6054
+ import path22 from "path";
5994
6055
  var REPORT_FILE = "capability-migration-report.md";
5995
6056
  function printSummary(result) {
5996
6057
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -6153,15 +6214,15 @@ async function generateReport(result) {
6153
6214
  }
6154
6215
  lines.push("");
6155
6216
  const logDir = process.env.LOG_DIR || "logs";
6156
- if (!fs23.existsSync(logDir)) {
6217
+ if (!fs24.existsSync(logDir)) {
6157
6218
  return;
6158
6219
  }
6159
- const reportDir = path21.join(logDir, "migration");
6160
- if (!fs23.existsSync(reportDir)) {
6161
- fs23.mkdirSync(reportDir, { recursive: true });
6220
+ const reportDir = path22.join(logDir, "migration");
6221
+ if (!fs24.existsSync(reportDir)) {
6222
+ fs24.mkdirSync(reportDir, { recursive: true });
6162
6223
  }
6163
- const reportPath = path21.join(reportDir, REPORT_FILE);
6164
- fs23.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6224
+ const reportPath = path22.join(reportDir, REPORT_FILE);
6225
+ fs24.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6165
6226
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
6166
6227
  }
6167
6228
 
@@ -6693,10 +6754,10 @@ var migrationCommand = {
6693
6754
  };
6694
6755
 
6695
6756
  // src/commands/read-logs/index.ts
6696
- import path22 from "path";
6757
+ import path23 from "path";
6697
6758
 
6698
6759
  // src/commands/read-logs/std-utils.ts
6699
- import fs24 from "fs";
6760
+ import fs25 from "fs";
6700
6761
  function formatStdPrefixTime(localTime) {
6701
6762
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
6702
6763
  if (!match) return localTime;
@@ -6726,11 +6787,11 @@ function stripPrefixFromStdLine(line) {
6726
6787
  return `[${time}] ${content}`;
6727
6788
  }
6728
6789
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
6729
- const stat = fs24.statSync(filePath);
6790
+ const stat = fs25.statSync(filePath);
6730
6791
  if (stat.size === 0) {
6731
6792
  return { lines: [], markerFound: false, totalLinesCount: 0 };
6732
6793
  }
6733
- const fd = fs24.openSync(filePath, "r");
6794
+ const fd = fs25.openSync(filePath, "r");
6734
6795
  const chunkSize = 64 * 1024;
6735
6796
  let position = stat.size;
6736
6797
  let remainder = "";
@@ -6744,7 +6805,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6744
6805
  const length = Math.min(chunkSize, position);
6745
6806
  position -= length;
6746
6807
  const buffer = Buffer.alloc(length);
6747
- fs24.readSync(fd, buffer, 0, length, position);
6808
+ fs25.readSync(fd, buffer, 0, length, position);
6748
6809
  let chunk = buffer.toString("utf8");
6749
6810
  if (remainder) {
6750
6811
  chunk += remainder;
@@ -6786,7 +6847,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6786
6847
  }
6787
6848
  }
6788
6849
  } finally {
6789
- fs24.closeSync(fd);
6850
+ fs25.closeSync(fd);
6790
6851
  }
6791
6852
  return { lines: collected.reverse(), markerFound, totalLinesCount };
6792
6853
  }
@@ -6807,21 +6868,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
6807
6868
  }
6808
6869
 
6809
6870
  // src/commands/read-logs/tail.ts
6810
- import fs25 from "fs";
6871
+ import fs26 from "fs";
6811
6872
  function fileExists(filePath) {
6812
6873
  try {
6813
- fs25.accessSync(filePath, fs25.constants.F_OK | fs25.constants.R_OK);
6874
+ fs26.accessSync(filePath, fs26.constants.F_OK | fs26.constants.R_OK);
6814
6875
  return true;
6815
6876
  } catch {
6816
6877
  return false;
6817
6878
  }
6818
6879
  }
6819
6880
  function readFileTailLines(filePath, maxLines) {
6820
- const stat = fs25.statSync(filePath);
6881
+ const stat = fs26.statSync(filePath);
6821
6882
  if (stat.size === 0) {
6822
6883
  return [];
6823
6884
  }
6824
- const fd = fs25.openSync(filePath, "r");
6885
+ const fd = fs26.openSync(filePath, "r");
6825
6886
  const chunkSize = 64 * 1024;
6826
6887
  const chunks = [];
6827
6888
  let position = stat.size;
@@ -6831,13 +6892,13 @@ function readFileTailLines(filePath, maxLines) {
6831
6892
  const length = Math.min(chunkSize, position);
6832
6893
  position -= length;
6833
6894
  const buffer = Buffer.alloc(length);
6834
- fs25.readSync(fd, buffer, 0, length, position);
6895
+ fs26.readSync(fd, buffer, 0, length, position);
6835
6896
  chunks.unshift(buffer.toString("utf8"));
6836
6897
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
6837
6898
  collectedLines += chunkLines;
6838
6899
  }
6839
6900
  } finally {
6840
- fs25.closeSync(fd);
6901
+ fs26.closeSync(fd);
6841
6902
  }
6842
6903
  const content = chunks.join("");
6843
6904
  const allLines = content.split("\n");
@@ -6853,11 +6914,11 @@ function readFileTailLines(filePath, maxLines) {
6853
6914
  return allLines.slice(allLines.length - maxLines);
6854
6915
  }
6855
6916
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6856
- const stat = fs25.statSync(filePath);
6917
+ const stat = fs26.statSync(filePath);
6857
6918
  if (stat.size === 0) {
6858
6919
  return { lines: [], totalLinesCount: 0 };
6859
6920
  }
6860
- const fd = fs25.openSync(filePath, "r");
6921
+ const fd = fs26.openSync(filePath, "r");
6861
6922
  const chunkSize = 64 * 1024;
6862
6923
  let position = stat.size;
6863
6924
  let remainder = "";
@@ -6869,7 +6930,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6869
6930
  const length = Math.min(chunkSize, position);
6870
6931
  position -= length;
6871
6932
  const buffer = Buffer.alloc(length);
6872
- fs25.readSync(fd, buffer, 0, length, position);
6933
+ fs26.readSync(fd, buffer, 0, length, position);
6873
6934
  let chunk = buffer.toString("utf8");
6874
6935
  if (remainder) {
6875
6936
  chunk += remainder;
@@ -6900,7 +6961,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6900
6961
  }
6901
6962
  }
6902
6963
  } finally {
6903
- fs25.closeSync(fd);
6964
+ fs26.closeSync(fd);
6904
6965
  }
6905
6966
  return { lines: collected.reverse(), totalLinesCount };
6906
6967
  }
@@ -7042,7 +7103,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
7042
7103
  }
7043
7104
 
7044
7105
  // src/commands/read-logs/json-lines.ts
7045
- import fs26 from "fs";
7106
+ import fs27 from "fs";
7046
7107
  function normalizePid(value) {
7047
7108
  if (typeof value === "number") {
7048
7109
  return String(value);
@@ -7093,11 +7154,11 @@ function buildWantedLevelSet(levels) {
7093
7154
  return set.size > 0 ? set : null;
7094
7155
  }
7095
7156
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7096
- const stat = fs26.statSync(filePath);
7157
+ const stat = fs27.statSync(filePath);
7097
7158
  if (stat.size === 0) {
7098
7159
  return { lines: [], totalLinesCount: 0 };
7099
7160
  }
7100
- const fd = fs26.openSync(filePath, "r");
7161
+ const fd = fs27.openSync(filePath, "r");
7101
7162
  const chunkSize = 64 * 1024;
7102
7163
  let position = stat.size;
7103
7164
  let remainder = "";
@@ -7112,7 +7173,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7112
7173
  const length = Math.min(chunkSize, position);
7113
7174
  position -= length;
7114
7175
  const buffer = Buffer.alloc(length);
7115
- fs26.readSync(fd, buffer, 0, length, position);
7176
+ fs27.readSync(fd, buffer, 0, length, position);
7116
7177
  let chunk = buffer.toString("utf8");
7117
7178
  if (remainder) {
7118
7179
  chunk += remainder;
@@ -7174,7 +7235,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7174
7235
  }
7175
7236
  }
7176
7237
  } finally {
7177
- fs26.closeSync(fd);
7238
+ fs27.closeSync(fd);
7178
7239
  }
7179
7240
  return { lines: collected.reverse(), totalLinesCount };
7180
7241
  }
@@ -7217,11 +7278,11 @@ function extractTraceId(obj) {
7217
7278
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7218
7279
  const wanted = traceId.trim();
7219
7280
  if (!wanted) return { lines: [], totalLinesCount: 0 };
7220
- const stat = fs26.statSync(filePath);
7281
+ const stat = fs27.statSync(filePath);
7221
7282
  if (stat.size === 0) {
7222
7283
  return { lines: [], totalLinesCount: 0 };
7223
7284
  }
7224
- const fd = fs26.openSync(filePath, "r");
7285
+ const fd = fs27.openSync(filePath, "r");
7225
7286
  const chunkSize = 64 * 1024;
7226
7287
  let position = stat.size;
7227
7288
  let remainder = "";
@@ -7234,7 +7295,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7234
7295
  const length = Math.min(chunkSize, position);
7235
7296
  position -= length;
7236
7297
  const buffer = Buffer.alloc(length);
7237
- fs26.readSync(fd, buffer, 0, length, position);
7298
+ fs27.readSync(fd, buffer, 0, length, position);
7238
7299
  let chunk = buffer.toString("utf8");
7239
7300
  if (remainder) {
7240
7301
  chunk += remainder;
@@ -7287,7 +7348,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7287
7348
  }
7288
7349
  }
7289
7350
  } finally {
7290
- fs26.closeSync(fd);
7351
+ fs27.closeSync(fd);
7291
7352
  }
7292
7353
  return { lines: collected.reverse(), totalLinesCount };
7293
7354
  }
@@ -7296,11 +7357,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7296
7357
  if (!wantedLevelSet) {
7297
7358
  return { lines: [], totalLinesCount: 0 };
7298
7359
  }
7299
- const stat = fs26.statSync(filePath);
7360
+ const stat = fs27.statSync(filePath);
7300
7361
  if (stat.size === 0) {
7301
7362
  return { lines: [], totalLinesCount: 0 };
7302
7363
  }
7303
- const fd = fs26.openSync(filePath, "r");
7364
+ const fd = fs27.openSync(filePath, "r");
7304
7365
  const chunkSize = 64 * 1024;
7305
7366
  let position = stat.size;
7306
7367
  let remainder = "";
@@ -7312,7 +7373,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7312
7373
  const length = Math.min(chunkSize, position);
7313
7374
  position -= length;
7314
7375
  const buffer = Buffer.alloc(length);
7315
- fs26.readSync(fd, buffer, 0, length, position);
7376
+ fs27.readSync(fd, buffer, 0, length, position);
7316
7377
  let chunk = buffer.toString("utf8");
7317
7378
  if (remainder) {
7318
7379
  chunk += remainder;
@@ -7359,7 +7420,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7359
7420
  }
7360
7421
  }
7361
7422
  } finally {
7362
- fs26.closeSync(fd);
7423
+ fs27.closeSync(fd);
7363
7424
  }
7364
7425
  return { lines: collected.reverse(), totalLinesCount };
7365
7426
  }
@@ -7593,30 +7654,30 @@ async function readLogsJsonResult(options) {
7593
7654
  };
7594
7655
  }
7595
7656
  function resolveLogFilePath(logDir, type) {
7596
- const base = path22.isAbsolute(logDir) ? logDir : path22.join(process.cwd(), logDir);
7657
+ const base = path23.isAbsolute(logDir) ? logDir : path23.join(process.cwd(), logDir);
7597
7658
  if (type === "server") {
7598
- return path22.join(base, "server.log");
7659
+ return path23.join(base, "server.log");
7599
7660
  }
7600
7661
  if (type === "trace") {
7601
- return path22.join(base, "trace.log");
7662
+ return path23.join(base, "trace.log");
7602
7663
  }
7603
7664
  if (type === "server-std") {
7604
- return path22.join(base, "server.std.log");
7665
+ return path23.join(base, "server.std.log");
7605
7666
  }
7606
7667
  if (type === "client-std") {
7607
- return path22.join(base, "client.std.log");
7668
+ return path23.join(base, "client.std.log");
7608
7669
  }
7609
7670
  if (type === "dev") {
7610
- return path22.join(base, "dev.log");
7671
+ return path23.join(base, "dev.log");
7611
7672
  }
7612
7673
  if (type === "dev-std") {
7613
- return path22.join(base, "dev.std.log");
7674
+ return path23.join(base, "dev.std.log");
7614
7675
  }
7615
7676
  if (type === "install-dep-std") {
7616
- return path22.join(base, "install-dep.std.log");
7677
+ return path23.join(base, "install-dep.std.log");
7617
7678
  }
7618
7679
  if (type === "browser") {
7619
- return path22.join(base, "browser.log");
7680
+ return path23.join(base, "browser.log");
7620
7681
  }
7621
7682
  throw new Error(`Unsupported log type: ${type}`);
7622
7683
  }
@@ -7793,9 +7854,9 @@ function camelToKebab(str) {
7793
7854
  }
7794
7855
 
7795
7856
  // src/commands/build/upload-static.handler.ts
7796
- import * as fs27 from "fs";
7857
+ import * as fs28 from "fs";
7797
7858
  import * as os2 from "os";
7798
- import * as path23 from "path";
7859
+ import * as path24 from "path";
7799
7860
  import { execFileSync } from "child_process";
7800
7861
  function readCredentialsFromEnv() {
7801
7862
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -7819,8 +7880,8 @@ async function uploadStatic(options) {
7819
7880
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7820
7881
  region = UPLOAD_STATIC_DEFAULTS.region
7821
7882
  } = options;
7822
- const resolvedStaticDir = path23.resolve(staticDir);
7823
- if (!fs27.existsSync(resolvedStaticDir)) {
7883
+ const resolvedStaticDir = path24.resolve(staticDir);
7884
+ if (!fs28.existsSync(resolvedStaticDir)) {
7824
7885
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7825
7886
  return;
7826
7887
  }
@@ -7853,8 +7914,8 @@ async function uploadStatic(options) {
7853
7914
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7854
7915
  }
7855
7916
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7856
- const confPath = path23.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7857
- fs27.writeFileSync(confPath, "");
7917
+ const confPath = path24.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7918
+ fs28.writeFileSync(confPath, "");
7858
7919
  try {
7859
7920
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7860
7921
  configureTosutil(resolvedTosutil, confPath, {
@@ -7868,7 +7929,7 @@ async function uploadStatic(options) {
7868
7929
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7869
7930
  } finally {
7870
7931
  try {
7871
- fs27.unlinkSync(confPath);
7932
+ fs28.unlinkSync(confPath);
7872
7933
  } catch {
7873
7934
  }
7874
7935
  }
@@ -7888,8 +7949,8 @@ async function uploadStatic(options) {
7888
7949
  }
7889
7950
  }
7890
7951
  function resolveTosutilPath(tosutilPath) {
7891
- if (path23.isAbsolute(tosutilPath)) {
7892
- return fs27.existsSync(tosutilPath) ? tosutilPath : null;
7952
+ if (path24.isAbsolute(tosutilPath)) {
7953
+ return fs28.existsSync(tosutilPath) ? tosutilPath : null;
7893
7954
  }
7894
7955
  try {
7895
7956
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -7934,7 +7995,7 @@ async function resolveBucketId(appId) {
7934
7995
  return bucketId;
7935
7996
  }
7936
7997
  function isDirEmpty(dirPath) {
7937
- const entries = fs27.readdirSync(dirPath);
7998
+ const entries = fs28.readdirSync(dirPath);
7938
7999
  return entries.length === 0;
7939
8000
  }
7940
8001
 
@@ -8029,12 +8090,12 @@ var commands = [
8029
8090
  ];
8030
8091
 
8031
8092
  // src/index.ts
8032
- var envPath = path24.join(process.cwd(), ".env");
8033
- if (fs28.existsSync(envPath)) {
8093
+ var envPath = path25.join(process.cwd(), ".env");
8094
+ if (fs29.existsSync(envPath)) {
8034
8095
  dotenvConfig({ path: envPath });
8035
8096
  }
8036
- var __dirname = path24.dirname(fileURLToPath5(import.meta.url));
8037
- var pkg = JSON.parse(fs28.readFileSync(path24.join(__dirname, "../package.json"), "utf-8"));
8097
+ var __dirname = path25.dirname(fileURLToPath5(import.meta.url));
8098
+ var pkg = JSON.parse(fs29.readFileSync(path25.join(__dirname, "../package.json"), "utf-8"));
8038
8099
  var cli = new FullstackCLI(pkg.version);
8039
8100
  cli.useAll(commands);
8040
8101
  cli.run();