@lark-apaas/fullstack-cli 1.1.45-alpha.1 → 1.1.45-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
- import fs29 from "fs";
3
- import path25 from "path";
2
+ import fs27 from "fs";
3
+ import path23 from "path";
4
4
  import { fileURLToPath as fileURLToPath5 } from "url";
5
5
  import { config as dotenvConfig } from "dotenv";
6
6
 
@@ -2365,48 +2365,21 @@ var genDbSchemaCommand = {
2365
2365
  };
2366
2366
 
2367
2367
  // src/commands/sync/run.handler.ts
2368
- import path6 from "path";
2369
- import fs8 from "fs";
2368
+ import 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 目录(总是覆盖;递归同步,包含 scripts/hooks/run-precommit.js)
2376
+ // 1. 派生 scripts 目录(总是覆盖)
2377
2377
  {
2378
2378
  from: "templates/scripts",
2379
2379
  to: "scripts",
2380
2380
  type: "directory",
2381
2381
  overwrite: true
2382
2382
  },
2383
- // 1a. 同步 .husky 目录(hook 入口,单行 `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
- },
2410
2383
  // 2. 智能合并 nest-cli.json 配置(保留用户自定义的 assets、plugins 等)
2411
2384
  {
2412
2385
  from: "templates/nest-cli.json",
@@ -2629,46 +2602,18 @@ function cleanupPackageJson(cwd = process.cwd()) {
2629
2602
  }
2630
2603
  }
2631
2604
 
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
-
2660
2605
  // src/commands/sync/run.handler.ts
2661
2606
  async function run2(options) {
2662
2607
  const userProjectRoot = process.env.INIT_CWD || process.cwd();
2663
2608
  const __filename = fileURLToPath3(import.meta.url);
2664
- const __dirname2 = path6.dirname(__filename);
2665
- const pluginRoot = path6.resolve(__dirname2, "..");
2609
+ const __dirname2 = path5.dirname(__filename);
2610
+ const pluginRoot = path5.resolve(__dirname2, "..");
2666
2611
  if (userProjectRoot === pluginRoot) {
2667
2612
  console.log("[fullstack-cli] Skip syncing (installing plugin itself)");
2668
2613
  process.exit(0);
2669
2614
  }
2670
- const userPackageJson = path6.join(userProjectRoot, "package.json");
2671
- if (!fs8.existsSync(userPackageJson)) {
2615
+ const userPackageJson = path5.join(userProjectRoot, "package.json");
2616
+ if (!fs7.existsSync(userPackageJson)) {
2672
2617
  console.log("[fullstack-cli] Skip syncing (not a valid npm project)");
2673
2618
  process.exit(0);
2674
2619
  }
@@ -2688,12 +2633,6 @@ async function run2(options) {
2688
2633
  if (config.permissions) {
2689
2634
  setPermissions(config.permissions, userProjectRoot);
2690
2635
  }
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
- }
2697
2636
  console.log("[fullstack-cli] Sync completed successfully \u2705");
2698
2637
  } catch (error) {
2699
2638
  const message = error instanceof Error ? error.message : String(error);
@@ -2726,7 +2665,7 @@ function patchUserPackageJson(userProjectRoot) {
2726
2665
  }
2727
2666
  async function syncRule(rule, pluginRoot, userProjectRoot) {
2728
2667
  if (rule.type === "delete-file" || rule.type === "delete-directory") {
2729
- const destPath2 = path6.join(userProjectRoot, rule.to);
2668
+ const destPath2 = path5.join(userProjectRoot, rule.to);
2730
2669
  if (rule.type === "delete-file") {
2731
2670
  deleteFile(destPath2);
2732
2671
  } else {
@@ -2735,32 +2674,32 @@ async function syncRule(rule, pluginRoot, userProjectRoot) {
2735
2674
  return;
2736
2675
  }
2737
2676
  if (rule.type === "remove-line") {
2738
- const destPath2 = path6.join(userProjectRoot, rule.to);
2677
+ const destPath2 = path5.join(userProjectRoot, rule.to);
2739
2678
  removeLineFromFile(destPath2, rule.pattern);
2740
2679
  return;
2741
2680
  }
2742
2681
  if (rule.type === "add-script") {
2743
- const packageJsonPath = path6.join(userProjectRoot, "package.json");
2682
+ const packageJsonPath = path5.join(userProjectRoot, "package.json");
2744
2683
  addScript(packageJsonPath, rule.name, rule.command, rule.overwrite ?? false);
2745
2684
  return;
2746
2685
  }
2747
2686
  if (rule.type === "add-line") {
2748
- const destPath2 = path6.join(userProjectRoot, rule.to);
2687
+ const destPath2 = path5.join(userProjectRoot, rule.to);
2749
2688
  addLineToFile(destPath2, rule.line);
2750
2689
  return;
2751
2690
  }
2752
2691
  if (rule.type === "merge-json") {
2753
- const srcPath2 = path6.join(pluginRoot, rule.from);
2754
- const destPath2 = path6.join(userProjectRoot, rule.to);
2692
+ const srcPath2 = path5.join(pluginRoot, rule.from);
2693
+ const destPath2 = path5.join(userProjectRoot, rule.to);
2755
2694
  mergeJsonFile(srcPath2, destPath2, rule.arrayMerge);
2756
2695
  return;
2757
2696
  }
2758
2697
  if (!("from" in rule)) {
2759
2698
  return;
2760
2699
  }
2761
- const srcPath = path6.join(pluginRoot, rule.from);
2762
- const destPath = path6.join(userProjectRoot, rule.to);
2763
- if (!fs8.existsSync(srcPath)) {
2700
+ const srcPath = path5.join(pluginRoot, rule.from);
2701
+ const destPath = path5.join(userProjectRoot, rule.to);
2702
+ if (!fs7.existsSync(srcPath)) {
2764
2703
  console.warn(`[fullstack-cli] Source not found: ${rule.from}`);
2765
2704
  return;
2766
2705
  }
@@ -2777,68 +2716,68 @@ async function syncRule(rule, pluginRoot, userProjectRoot) {
2777
2716
  }
2778
2717
  }
2779
2718
  function syncFile(src, dest, overwrite = true, onlyIfExists = false) {
2780
- if (onlyIfExists && !fs8.existsSync(dest)) {
2781
- console.log(`[fullstack-cli] \u25CB ${path6.basename(dest)} (skipped, target not exists)`);
2719
+ if (onlyIfExists && !fs7.existsSync(dest)) {
2720
+ console.log(`[fullstack-cli] \u25CB ${path5.basename(dest)} (skipped, target not exists)`);
2782
2721
  return;
2783
2722
  }
2784
- const destDir = path6.dirname(dest);
2785
- if (!fs8.existsSync(destDir)) {
2786
- fs8.mkdirSync(destDir, { recursive: true });
2723
+ const destDir = path5.dirname(dest);
2724
+ if (!fs7.existsSync(destDir)) {
2725
+ fs7.mkdirSync(destDir, { recursive: true });
2787
2726
  }
2788
- if (fs8.existsSync(dest) && !overwrite) {
2789
- console.log(`[fullstack-cli] \u25CB ${path6.basename(dest)} (skipped, already exists)`);
2727
+ if (fs7.existsSync(dest) && !overwrite) {
2728
+ console.log(`[fullstack-cli] \u25CB ${path5.basename(dest)} (skipped, already exists)`);
2790
2729
  return;
2791
2730
  }
2792
- fs8.copyFileSync(src, dest);
2793
- console.log(`[fullstack-cli] \u2713 ${path6.basename(dest)}`);
2731
+ fs7.copyFileSync(src, dest);
2732
+ console.log(`[fullstack-cli] \u2713 ${path5.basename(dest)}`);
2794
2733
  }
2795
2734
  function syncDirectory(src, dest, overwrite = true) {
2796
- if (!fs8.existsSync(dest)) {
2797
- fs8.mkdirSync(dest, { recursive: true });
2735
+ if (!fs7.existsSync(dest)) {
2736
+ fs7.mkdirSync(dest, { recursive: true });
2798
2737
  }
2799
- const files = fs8.readdirSync(src);
2738
+ const files = fs7.readdirSync(src);
2800
2739
  let count = 0;
2801
2740
  files.forEach((file) => {
2802
- const srcFile = path6.join(src, file);
2803
- const destFile = path6.join(dest, file);
2804
- const stats = fs8.statSync(srcFile);
2741
+ const srcFile = path5.join(src, file);
2742
+ const destFile = path5.join(dest, file);
2743
+ const stats = fs7.statSync(srcFile);
2805
2744
  if (stats.isDirectory()) {
2806
2745
  syncDirectory(srcFile, destFile, overwrite);
2807
2746
  } else {
2808
- if (overwrite || !fs8.existsSync(destFile)) {
2809
- fs8.copyFileSync(srcFile, destFile);
2810
- console.log(`[fullstack-cli] \u2713 ${path6.relative(dest, destFile)}`);
2747
+ if (overwrite || !fs7.existsSync(destFile)) {
2748
+ fs7.copyFileSync(srcFile, destFile);
2749
+ console.log(`[fullstack-cli] \u2713 ${path5.relative(dest, destFile)}`);
2811
2750
  count++;
2812
2751
  }
2813
2752
  }
2814
2753
  });
2815
2754
  if (count > 0) {
2816
- console.log(`[fullstack-cli] Synced ${count} files to ${path6.basename(dest)}/`);
2755
+ console.log(`[fullstack-cli] Synced ${count} files to ${path5.basename(dest)}/`);
2817
2756
  }
2818
2757
  }
2819
2758
  function appendToFile(src, dest) {
2820
- const content = fs8.readFileSync(src, "utf-8");
2759
+ const content = fs7.readFileSync(src, "utf-8");
2821
2760
  let existingContent = "";
2822
- if (fs8.existsSync(dest)) {
2823
- existingContent = fs8.readFileSync(dest, "utf-8");
2761
+ if (fs7.existsSync(dest)) {
2762
+ existingContent = fs7.readFileSync(dest, "utf-8");
2824
2763
  }
2825
2764
  if (existingContent.includes(content.trim())) {
2826
- console.log(`[fullstack-cli] \u25CB ${path6.basename(dest)} (already contains content)`);
2765
+ console.log(`[fullstack-cli] \u25CB ${path5.basename(dest)} (already contains content)`);
2827
2766
  return;
2828
2767
  }
2829
- fs8.appendFileSync(dest, content);
2830
- console.log(`[fullstack-cli] \u2713 ${path6.basename(dest)} (appended)`);
2768
+ fs7.appendFileSync(dest, content);
2769
+ console.log(`[fullstack-cli] \u2713 ${path5.basename(dest)} (appended)`);
2831
2770
  }
2832
2771
  function setPermissions(permissions, projectRoot) {
2833
2772
  for (const [pattern, mode] of Object.entries(permissions)) {
2834
2773
  if (pattern === "**/*.sh") {
2835
- const scriptsDir = path6.join(projectRoot, "scripts");
2836
- if (fs8.existsSync(scriptsDir)) {
2837
- const files = fs8.readdirSync(scriptsDir);
2774
+ const scriptsDir = path5.join(projectRoot, "scripts");
2775
+ if (fs7.existsSync(scriptsDir)) {
2776
+ const files = fs7.readdirSync(scriptsDir);
2838
2777
  files.forEach((file) => {
2839
2778
  if (file.endsWith(".sh")) {
2840
- const filePath = path6.join(scriptsDir, file);
2841
- fs8.chmodSync(filePath, mode);
2779
+ const filePath = path5.join(scriptsDir, file);
2780
+ fs7.chmodSync(filePath, mode);
2842
2781
  }
2843
2782
  });
2844
2783
  }
@@ -2846,27 +2785,27 @@ function setPermissions(permissions, projectRoot) {
2846
2785
  }
2847
2786
  }
2848
2787
  function deleteFile(filePath) {
2849
- if (fs8.existsSync(filePath)) {
2850
- fs8.unlinkSync(filePath);
2851
- console.log(`[fullstack-cli] \u2713 ${path6.basename(filePath)} (deleted)`);
2788
+ if (fs7.existsSync(filePath)) {
2789
+ fs7.unlinkSync(filePath);
2790
+ console.log(`[fullstack-cli] \u2713 ${path5.basename(filePath)} (deleted)`);
2852
2791
  } else {
2853
- console.log(`[fullstack-cli] \u25CB ${path6.basename(filePath)} (not found)`);
2792
+ console.log(`[fullstack-cli] \u25CB ${path5.basename(filePath)} (not found)`);
2854
2793
  }
2855
2794
  }
2856
2795
  function deleteDirectory(dirPath) {
2857
- if (fs8.existsSync(dirPath)) {
2858
- fs8.rmSync(dirPath, { recursive: true });
2859
- console.log(`[fullstack-cli] \u2713 ${path6.basename(dirPath)} (deleted)`);
2796
+ if (fs7.existsSync(dirPath)) {
2797
+ fs7.rmSync(dirPath, { recursive: true });
2798
+ console.log(`[fullstack-cli] \u2713 ${path5.basename(dirPath)} (deleted)`);
2860
2799
  } else {
2861
- console.log(`[fullstack-cli] \u25CB ${path6.basename(dirPath)} (not found)`);
2800
+ console.log(`[fullstack-cli] \u25CB ${path5.basename(dirPath)} (not found)`);
2862
2801
  }
2863
2802
  }
2864
2803
  function addScript(packageJsonPath, name, command, overwrite) {
2865
- if (!fs8.existsSync(packageJsonPath)) {
2804
+ if (!fs7.existsSync(packageJsonPath)) {
2866
2805
  console.log(`[fullstack-cli] \u25CB package.json (not found)`);
2867
2806
  return;
2868
2807
  }
2869
- const content = fs8.readFileSync(packageJsonPath, "utf-8");
2808
+ const content = fs7.readFileSync(packageJsonPath, "utf-8");
2870
2809
  const pkg2 = JSON.parse(content);
2871
2810
  if (!pkg2.scripts) {
2872
2811
  pkg2.scripts = {};
@@ -2878,42 +2817,42 @@ function addScript(packageJsonPath, name, command, overwrite) {
2878
2817
  }
2879
2818
  }
2880
2819
  pkg2.scripts[name] = command;
2881
- fs8.writeFileSync(packageJsonPath, JSON.stringify(pkg2, null, 2) + "\n");
2820
+ fs7.writeFileSync(packageJsonPath, JSON.stringify(pkg2, null, 2) + "\n");
2882
2821
  console.log(`[fullstack-cli] \u2713 scripts.${name}`);
2883
2822
  }
2884
2823
  function addLineToFile(filePath, line) {
2885
- const fileName = path6.basename(filePath);
2886
- if (!fs8.existsSync(filePath)) {
2824
+ const fileName = path5.basename(filePath);
2825
+ if (!fs7.existsSync(filePath)) {
2887
2826
  console.log(`[fullstack-cli] \u25CB ${fileName} (not found, skipped)`);
2888
2827
  return;
2889
2828
  }
2890
- const content = fs8.readFileSync(filePath, "utf-8");
2829
+ const content = fs7.readFileSync(filePath, "utf-8");
2891
2830
  const lines = content.split("\n").map((l) => l.trim());
2892
2831
  if (lines.includes(line)) {
2893
2832
  console.log(`[fullstack-cli] \u25CB ${fileName} (line already exists: ${line})`);
2894
2833
  return;
2895
2834
  }
2896
2835
  const appendContent = (content.endsWith("\n") ? "" : "\n") + line + "\n";
2897
- fs8.appendFileSync(filePath, appendContent);
2836
+ fs7.appendFileSync(filePath, appendContent);
2898
2837
  console.log(`[fullstack-cli] \u2713 ${fileName} (added: ${line})`);
2899
2838
  }
2900
2839
  function mergeJsonFile(src, dest, arrayMerge) {
2901
- const fileName = path6.basename(dest);
2902
- if (!fs8.existsSync(src)) {
2840
+ const fileName = path5.basename(dest);
2841
+ if (!fs7.existsSync(src)) {
2903
2842
  console.warn(`[fullstack-cli] Source not found: ${src}`);
2904
2843
  return;
2905
2844
  }
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 });
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 });
2911
2850
  }
2912
- fs8.writeFileSync(dest, JSON.stringify(templateContent, null, 2) + "\n");
2851
+ fs7.writeFileSync(dest, JSON.stringify(templateContent, null, 2) + "\n");
2913
2852
  console.log(`[fullstack-cli] \u2713 ${fileName} (created)`);
2914
2853
  return;
2915
2854
  }
2916
- const userContent = JSON.parse(fs8.readFileSync(dest, "utf-8"));
2855
+ const userContent = JSON.parse(fs7.readFileSync(dest, "utf-8"));
2917
2856
  const merged = deepMergeJson(userContent, templateContent, arrayMerge ?? {});
2918
2857
  const userStr = JSON.stringify(userContent, null, 2);
2919
2858
  const mergedStr = JSON.stringify(merged, null, 2);
@@ -2921,7 +2860,7 @@ function mergeJsonFile(src, dest, arrayMerge) {
2921
2860
  console.log(`[fullstack-cli] \u25CB ${fileName} (already up to date)`);
2922
2861
  return;
2923
2862
  }
2924
- fs8.writeFileSync(dest, mergedStr + "\n");
2863
+ fs7.writeFileSync(dest, mergedStr + "\n");
2925
2864
  console.log(`[fullstack-cli] \u2713 ${fileName} (merged)`);
2926
2865
  }
2927
2866
 
@@ -2981,16 +2920,16 @@ async function reportCreateInstanceEvent(pluginKey, version) {
2981
2920
  }
2982
2921
 
2983
2922
  // src/utils/git.ts
2984
- import { execSync, spawnSync as spawnSync3 } from "child_process";
2985
- import fs9 from "fs";
2986
- import path7 from "path";
2923
+ import { execSync, spawnSync as spawnSync2 } from "child_process";
2924
+ import fs8 from "fs";
2925
+ import path6 from "path";
2987
2926
  function isGitRepository(cwd = process.cwd()) {
2988
2927
  try {
2989
- const gitDir = path7.join(cwd, ".git");
2990
- if (fs9.existsSync(gitDir)) {
2928
+ const gitDir = path6.join(cwd, ".git");
2929
+ if (fs8.existsSync(gitDir)) {
2991
2930
  return true;
2992
2931
  }
2993
- const result = spawnSync3("git", ["rev-parse", "--git-dir"], {
2932
+ const result = spawnSync2("git", ["rev-parse", "--git-dir"], {
2994
2933
  cwd,
2995
2934
  stdio: "pipe",
2996
2935
  encoding: "utf-8"
@@ -3016,11 +2955,11 @@ function getChangedFiles(cwd = process.cwd()) {
3016
2955
  function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
3017
2956
  const filteredFiles = [];
3018
2957
  for (const filePath of filesToStage) {
3019
- if (fs9.existsSync(path7.join(cwd, filePath))) {
2958
+ if (fs8.existsSync(path6.join(cwd, filePath))) {
3020
2959
  filteredFiles.push(filePath);
3021
2960
  continue;
3022
2961
  }
3023
- const tracked = spawnSync3("git", ["ls-files", "--error-unmatch", "--", filePath], {
2962
+ const tracked = spawnSync2("git", ["ls-files", "--error-unmatch", "--", filePath], {
3024
2963
  cwd,
3025
2964
  stdio: "pipe",
3026
2965
  encoding: "utf-8"
@@ -3032,7 +2971,7 @@ function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
3032
2971
  if (filteredFiles.length === 0) {
3033
2972
  return;
3034
2973
  }
3035
- const result = spawnSync3("git", ["add", "--", ...filteredFiles], {
2974
+ const result = spawnSync2("git", ["add", "--", ...filteredFiles], {
3036
2975
  cwd,
3037
2976
  stdio: "pipe",
3038
2977
  encoding: "utf-8"
@@ -3043,7 +2982,7 @@ function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
3043
2982
  }
3044
2983
  }
3045
2984
  function hasStagedChanges(cwd = process.cwd()) {
3046
- const result = spawnSync3("git", ["diff", "--cached", "--quiet"], {
2985
+ const result = spawnSync2("git", ["diff", "--cached", "--quiet"], {
3047
2986
  cwd,
3048
2987
  stdio: "pipe",
3049
2988
  encoding: "utf-8"
@@ -3058,7 +2997,7 @@ function hasStagedChanges(cwd = process.cwd()) {
3058
2997
  throw new Error(`Failed to check staged changes: ${errorMsg}`);
3059
2998
  }
3060
2999
  function gitCommit(message, cwd = process.cwd()) {
3061
- const result = spawnSync3("git", ["commit", "-m", message], {
3000
+ const result = spawnSync2("git", ["commit", "-m", message], {
3062
3001
  cwd,
3063
3002
  stdio: "pipe",
3064
3003
  encoding: "utf-8"
@@ -3101,15 +3040,15 @@ Auto-committed by fullstack-cli`;
3101
3040
  }
3102
3041
 
3103
3042
  // src/commands/upgrade/shared/utils.ts
3104
- import path8 from "path";
3105
- import fs10 from "fs";
3043
+ import path7 from "path";
3044
+ import fs9 from "fs";
3106
3045
  import { fileURLToPath as fileURLToPath4 } from "url";
3107
3046
  function getCliVersion() {
3108
3047
  try {
3109
3048
  const __filename = fileURLToPath4(import.meta.url);
3110
- const __dirname2 = path8.dirname(__filename);
3111
- const pkgPath = path8.resolve(__dirname2, "../../../package.json");
3112
- const pkgContent = fs10.readFileSync(pkgPath, "utf-8");
3049
+ const __dirname2 = path7.dirname(__filename);
3050
+ const pkgPath = path7.resolve(__dirname2, "../../../package.json");
3051
+ const pkgContent = fs9.readFileSync(pkgPath, "utf-8");
3113
3052
  const pkg2 = JSON.parse(pkgContent);
3114
3053
  return pkg2.version || "unknown";
3115
3054
  } catch {
@@ -3167,47 +3106,31 @@ async function run3(options = {}) {
3167
3106
  }
3168
3107
 
3169
3108
  // src/commands/upgrade/deps/run.handler.ts
3170
- import { spawnSync as spawnSync4 } from "child_process";
3171
- import fs11 from "fs";
3172
- import path9 from "path";
3109
+ import { spawnSync as spawnSync3 } from "child_process";
3110
+ import fs10 from "fs";
3111
+ import path8 from "path";
3173
3112
 
3174
3113
  // src/utils/grayscale/config.ts
3175
3114
  function getGrayscaleConfig(configJson) {
3176
3115
  if (!configJson) {
3177
3116
  return null;
3178
3117
  }
3179
- let parsed;
3180
3118
  try {
3181
- parsed = JSON.parse(configJson);
3182
- } catch {
3183
- console.warn("[grayscale] Failed to parse grayscale config");
3184
- return null;
3185
- }
3186
- if (parsed && parsed.target_versions && typeof parsed.target_versions === "object") {
3187
- const entries = Object.entries(parsed.target_versions).filter(
3188
- ([, v]) => typeof v === "string" && v.length > 0
3189
- );
3190
- if (entries.length === 0) {
3191
- console.log("[grayscale] target_versions present but empty, skip");
3119
+ const parsed = JSON.parse(configJson);
3120
+ const config = parsed.config;
3121
+ if (!config || !config.enabled) {
3192
3122
  return null;
3193
3123
  }
3194
3124
  return {
3195
- kind: "resolved",
3196
- targetVersions: new Map(entries),
3197
- matchedChannel: typeof parsed.matched_channel === "string" ? parsed.matched_channel : void 0
3125
+ config,
3126
+ tenantId: parsed.tenant_id != null ? String(parsed.tenant_id) : void 0,
3127
+ appId: parsed.app_id || void 0,
3128
+ xTtEnv: parsed.x_tt_env || void 0
3198
3129
  };
3199
- }
3200
- const config = parsed?.config;
3201
- if (!config || !config.enabled) {
3130
+ } catch {
3131
+ console.warn("[grayscale] Failed to parse grayscale config");
3202
3132
  return null;
3203
3133
  }
3204
- return {
3205
- kind: "legacy",
3206
- config,
3207
- tenantId: parsed.tenant_id != null ? String(parsed.tenant_id) : void 0,
3208
- appId: parsed.app_id || void 0,
3209
- xTtEnv: parsed.x_tt_env || void 0
3210
- };
3211
3134
  }
3212
3135
 
3213
3136
  // src/utils/grayscale/identity.ts
@@ -3295,19 +3218,6 @@ function resolveGrayscaleVersions(_cwd, configJson) {
3295
3218
  console.log("[grayscale] Config not available, skipping grayscale");
3296
3219
  return null;
3297
3220
  }
3298
- if (result.kind === "resolved") {
3299
- console.log(
3300
- `[grayscale] Using server-resolved versions (matched channel: ${result.matchedChannel || "(stable)"})`
3301
- );
3302
- console.log(`[grayscale] Resolved ${result.targetVersions.size} package version(s):`);
3303
- for (const [pkg2, ver] of result.targetVersions) {
3304
- console.log(`[grayscale] ${pkg2} -> ${ver}`);
3305
- }
3306
- return result.targetVersions;
3307
- }
3308
- console.warn(
3309
- "[grayscale] Received legacy payload (full TCC config). This path is deprecated; sandbox_console should be upgraded to server-side resolution."
3310
- );
3311
3221
  const { config, tenantId: payloadTenantId, appId: payloadAppId, xTtEnv: payloadXTtEnv } = result;
3312
3222
  const envIdentity = readProjectIdentity();
3313
3223
  const identity = {
@@ -3388,7 +3298,7 @@ function upgradePackages(packages, version, cwd) {
3388
3298
  packages.forEach((pkg2) => {
3389
3299
  const target = `${pkg2}@${version}`;
3390
3300
  console.log(`[fullstack-cli] Installing ${target}...`);
3391
- const result = spawnSync4("npm", ["install", target], {
3301
+ const result = spawnSync3("npm", ["install", target], {
3392
3302
  cwd,
3393
3303
  stdio: "inherit"
3394
3304
  });
@@ -3400,7 +3310,7 @@ function upgradePackages(packages, version, cwd) {
3400
3310
  console.log("[fullstack-cli] Upgrading to latest compatible versions...");
3401
3311
  packages.forEach((pkg2) => {
3402
3312
  console.log(`[fullstack-cli] Updating ${pkg2}...`);
3403
- const result = spawnSync4("npm", ["update", pkg2], {
3313
+ const result = spawnSync3("npm", ["update", pkg2], {
3404
3314
  cwd,
3405
3315
  stdio: "inherit"
3406
3316
  });
@@ -3417,8 +3327,8 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
3417
3327
  if (version) {
3418
3328
  let current = "";
3419
3329
  try {
3420
- const installedPkgPath = path9.join(cwd, "node_modules", pkg2, "package.json");
3421
- const installedPkg = JSON.parse(fs11.readFileSync(installedPkgPath, "utf-8"));
3330
+ const installedPkgPath = path8.join(cwd, "node_modules", pkg2, "package.json");
3331
+ const installedPkg = JSON.parse(fs10.readFileSync(installedPkgPath, "utf-8"));
3422
3332
  current = installedPkg.version || "";
3423
3333
  } catch (err) {
3424
3334
  const code = err?.code;
@@ -3461,7 +3371,7 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
3461
3371
  }
3462
3372
  const targets = upgradePlan.map(({ pkg: pkg2, version }) => `${pkg2}@${version}`);
3463
3373
  console.log(`[fullstack-cli] Installing ${targets.join(" ")}...`);
3464
- const result = spawnSync4("npm", ["install", ...targets], {
3374
+ const result = spawnSync3("npm", ["install", ...targets], {
3465
3375
  cwd,
3466
3376
  stdio: "inherit"
3467
3377
  });
@@ -3534,111 +3444,6 @@ var depsCommand = {
3534
3444
  }
3535
3445
  };
3536
3446
 
3537
- // src/commands/upgrade/global-deps/run.handler.ts
3538
- import { spawnSync as spawnSync5 } from "child_process";
3539
- import fs12 from "fs";
3540
- import path10 from "path";
3541
- var MANAGED_GLOBAL_CLIS = [
3542
- "@lark-apaas/fullstack-cli",
3543
- "@lark-apaas/miaoda-cli"
3544
- ];
3545
- function readGlobalInstalledVersion(pkg2) {
3546
- const candidates = [];
3547
- if (process.env.npm_config_prefix) candidates.push(process.env.npm_config_prefix);
3548
- if (process.env.NPM_CONFIG_PREFIX) candidates.push(process.env.NPM_CONFIG_PREFIX);
3549
- candidates.push("/usr");
3550
- candidates.push("/usr/local");
3551
- if (process.env.HOME) candidates.push(path10.join(process.env.HOME, ".npm-global"));
3552
- const seen = /* @__PURE__ */ new Set();
3553
- for (const prefix of candidates) {
3554
- if (seen.has(prefix)) continue;
3555
- seen.add(prefix);
3556
- try {
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"));
3560
- if (meta && typeof meta.version === "string") return meta.version;
3561
- }
3562
- } catch (err) {
3563
- console.warn(
3564
- `[fullstack-cli] readGlobalInstalledVersion(${pkg2}) failed at prefix=${prefix}: ${err instanceof Error ? err.message : String(err)}`
3565
- );
3566
- }
3567
- }
3568
- return "";
3569
- }
3570
- function buildGlobalUpgradePlan(managed, resolvedVersions, readVersion) {
3571
- const plan = [];
3572
- for (const pkg2 of managed) {
3573
- const target = resolvedVersions.get(pkg2);
3574
- if (!target) {
3575
- console.log(`[fullstack-cli] ${pkg2}: no target version in grayscale config, skip`);
3576
- continue;
3577
- }
3578
- const current = readVersion(pkg2);
3579
- if (current && current === target) {
3580
- console.log(`[fullstack-cli] ${pkg2}@${target} (already installed, skip)`);
3581
- continue;
3582
- }
3583
- plan.push({ pkg: pkg2, current, target });
3584
- }
3585
- return plan;
3586
- }
3587
- async function run5(options = {}) {
3588
- console.log("[fullstack-cli] Starting global CLI upgrade...");
3589
- if (!options.grayscaleConfig) {
3590
- console.log("[fullstack-cli] No grayscale config, skip global upgrade");
3591
- return;
3592
- }
3593
- const grayscaleVersions = resolveGrayscaleVersions("/", options.grayscaleConfig);
3594
- if (!grayscaleVersions) {
3595
- console.log("[fullstack-cli] Grayscale config not available, skip global upgrade");
3596
- return;
3597
- }
3598
- const plan = buildGlobalUpgradePlan(MANAGED_GLOBAL_CLIS, grayscaleVersions, readGlobalInstalledVersion);
3599
- if (plan.length === 0) {
3600
- console.log("[fullstack-cli] No global CLI upgrade needed");
3601
- return;
3602
- }
3603
- console.log(`[fullstack-cli] Global upgrade plan (${plan.length} package(s)):`);
3604
- plan.forEach(({ pkg: pkg2, current, target }) => {
3605
- console.log(` - ${pkg2} ${current || "(not installed)"} -> ${target}`);
3606
- });
3607
- if (options.dryRun) {
3608
- console.log("[fullstack-cli] Dry run mode, skipping actual installation");
3609
- return;
3610
- }
3611
- const targets = plan.map(({ pkg: pkg2, target }) => `${pkg2}@${target}`);
3612
- const npmArgs = ["install", "-g", ...targets];
3613
- if (options.registry) {
3614
- npmArgs.push("--registry", options.registry);
3615
- }
3616
- console.log(`[fullstack-cli] Running: npm ${npmArgs.join(" ")}`);
3617
- const result = spawnSync5("npm", npmArgs, { stdio: "inherit" });
3618
- if (result.error || result.status !== 0) {
3619
- console.warn(
3620
- `[fullstack-cli] npm install -g failed: ${result.error?.message ?? `exit ${result.status}`}`
3621
- );
3622
- process.exit(1);
3623
- }
3624
- console.log("[fullstack-cli] \u2713 Global CLI upgrade completed");
3625
- }
3626
-
3627
- // src/commands/upgrade/global-deps/index.ts
3628
- var globalDepsCommand = {
3629
- name: "global-deps",
3630
- description: "Upgrade global @lark-apaas CLIs (fullstack-cli, miaoda-cli) per grayscale config",
3631
- register(parentCommand) {
3632
- parentCommand.command(this.name).description(this.description).option("--grayscale-config <json>", "Grayscale config JSON (injected by sandbox_console)").option("--dry-run", "Show upgrade plan without executing").option(
3633
- "--registry <url>",
3634
- "npm registry URL (default: https://registry.npmmirror.com/)",
3635
- "https://registry.npmmirror.com/"
3636
- ).action(async (options) => {
3637
- await run5(options);
3638
- });
3639
- }
3640
- };
3641
-
3642
3447
  // src/commands/upgrade/index.ts
3643
3448
  var upgradeCommand = {
3644
3449
  name: "upgrade",
@@ -3648,14 +3453,13 @@ var upgradeCommand = {
3648
3453
  await run3(options);
3649
3454
  });
3650
3455
  depsCommand.register(upgradeCmd);
3651
- globalDepsCommand.register(upgradeCmd);
3652
3456
  }
3653
3457
  };
3654
3458
 
3655
3459
  // src/commands/action-plugin/utils.ts
3656
- import fs13 from "fs";
3657
- import path11 from "path";
3658
- import { spawnSync as spawnSync6, execSync as execSync2 } from "child_process";
3460
+ import fs11 from "fs";
3461
+ import path9 from "path";
3462
+ import { spawnSync as spawnSync4, execSync as execSync2 } from "child_process";
3659
3463
  function parsePluginName(input) {
3660
3464
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
3661
3465
  if (!match) {
@@ -3672,18 +3476,18 @@ function getProjectRoot() {
3672
3476
  return process.cwd();
3673
3477
  }
3674
3478
  function getPackageJsonPath() {
3675
- return path11.join(getProjectRoot(), "package.json");
3479
+ return path9.join(getProjectRoot(), "package.json");
3676
3480
  }
3677
3481
  function getPluginPath(pluginName) {
3678
- return path11.join(getProjectRoot(), "node_modules", pluginName);
3482
+ return path9.join(getProjectRoot(), "node_modules", pluginName);
3679
3483
  }
3680
3484
  function readPackageJson2() {
3681
3485
  const pkgPath = getPackageJsonPath();
3682
- if (!fs13.existsSync(pkgPath)) {
3486
+ if (!fs11.existsSync(pkgPath)) {
3683
3487
  throw new Error("package.json not found in current directory");
3684
3488
  }
3685
3489
  try {
3686
- const content = fs13.readFileSync(pkgPath, "utf-8");
3490
+ const content = fs11.readFileSync(pkgPath, "utf-8");
3687
3491
  return JSON.parse(content);
3688
3492
  } catch {
3689
3493
  throw new Error("Failed to parse package.json");
@@ -3691,7 +3495,7 @@ function readPackageJson2() {
3691
3495
  }
3692
3496
  function writePackageJson2(pkg2) {
3693
3497
  const pkgPath = getPackageJsonPath();
3694
- fs13.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3498
+ fs11.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3695
3499
  }
3696
3500
  function readActionPlugins() {
3697
3501
  const pkg2 = readPackageJson2();
@@ -3712,7 +3516,7 @@ function getInstalledPluginVersion(pluginName) {
3712
3516
  }
3713
3517
  function npmInstall(tgzPath) {
3714
3518
  console.log(`[action-plugin] Running npm install ${tgzPath}...`);
3715
- const result = spawnSync6("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
3519
+ const result = spawnSync4("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
3716
3520
  cwd: getProjectRoot(),
3717
3521
  stdio: "inherit"
3718
3522
  });
@@ -3724,12 +3528,12 @@ function npmInstall(tgzPath) {
3724
3528
  }
3725
3529
  }
3726
3530
  function getPackageVersion(pluginName) {
3727
- const pkgJsonPath = path11.join(getPluginPath(pluginName), "package.json");
3728
- if (!fs13.existsSync(pkgJsonPath)) {
3531
+ const pkgJsonPath = path9.join(getPluginPath(pluginName), "package.json");
3532
+ if (!fs11.existsSync(pkgJsonPath)) {
3729
3533
  return null;
3730
3534
  }
3731
3535
  try {
3732
- const content = fs13.readFileSync(pkgJsonPath, "utf-8");
3536
+ const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3733
3537
  const pkg2 = JSON.parse(content);
3734
3538
  return pkg2.version || null;
3735
3539
  } catch {
@@ -3737,49 +3541,49 @@ function getPackageVersion(pluginName) {
3737
3541
  }
3738
3542
  }
3739
3543
  function readPluginPackageJson(pluginPath) {
3740
- const pkgJsonPath = path11.join(pluginPath, "package.json");
3741
- if (!fs13.existsSync(pkgJsonPath)) {
3544
+ const pkgJsonPath = path9.join(pluginPath, "package.json");
3545
+ if (!fs11.existsSync(pkgJsonPath)) {
3742
3546
  return null;
3743
3547
  }
3744
3548
  try {
3745
- const content = fs13.readFileSync(pkgJsonPath, "utf-8");
3549
+ const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3746
3550
  return JSON.parse(content);
3747
3551
  } catch {
3748
3552
  return null;
3749
3553
  }
3750
3554
  }
3751
3555
  function extractTgzToNodeModules(tgzPath, pluginName) {
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 });
3556
+ const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
3557
+ const targetDir = path9.join(nodeModulesPath, pluginName);
3558
+ const scopeDir = path9.dirname(targetDir);
3559
+ if (!fs11.existsSync(scopeDir)) {
3560
+ fs11.mkdirSync(scopeDir, { recursive: true });
3757
3561
  }
3758
- if (fs13.existsSync(targetDir)) {
3759
- fs13.rmSync(targetDir, { recursive: true });
3562
+ if (fs11.existsSync(targetDir)) {
3563
+ fs11.rmSync(targetDir, { recursive: true });
3760
3564
  }
3761
- const tempDir = path11.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3762
- if (fs13.existsSync(tempDir)) {
3763
- fs13.rmSync(tempDir, { recursive: true });
3565
+ const tempDir = path9.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3566
+ if (fs11.existsSync(tempDir)) {
3567
+ fs11.rmSync(tempDir, { recursive: true });
3764
3568
  }
3765
- fs13.mkdirSync(tempDir, { recursive: true });
3569
+ fs11.mkdirSync(tempDir, { recursive: true });
3766
3570
  try {
3767
3571
  execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
3768
- const extractedDir = path11.join(tempDir, "package");
3769
- if (fs13.existsSync(extractedDir)) {
3770
- fs13.renameSync(extractedDir, targetDir);
3572
+ const extractedDir = path9.join(tempDir, "package");
3573
+ if (fs11.existsSync(extractedDir)) {
3574
+ fs11.renameSync(extractedDir, targetDir);
3771
3575
  } else {
3772
- const files = fs13.readdirSync(tempDir);
3576
+ const files = fs11.readdirSync(tempDir);
3773
3577
  if (files.length === 1) {
3774
- fs13.renameSync(path11.join(tempDir, files[0]), targetDir);
3578
+ fs11.renameSync(path9.join(tempDir, files[0]), targetDir);
3775
3579
  } else {
3776
3580
  throw new Error("Unexpected tgz structure");
3777
3581
  }
3778
3582
  }
3779
3583
  return targetDir;
3780
3584
  } finally {
3781
- if (fs13.existsSync(tempDir)) {
3782
- fs13.rmSync(tempDir, { recursive: true });
3585
+ if (fs11.existsSync(tempDir)) {
3586
+ fs11.rmSync(tempDir, { recursive: true });
3783
3587
  }
3784
3588
  }
3785
3589
  }
@@ -3788,10 +3592,10 @@ function checkMissingPeerDeps(peerDeps) {
3788
3592
  return [];
3789
3593
  }
3790
3594
  const missing = [];
3791
- const nodeModulesPath = path11.join(getProjectRoot(), "node_modules");
3595
+ const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
3792
3596
  for (const [depName, _version] of Object.entries(peerDeps)) {
3793
- const depPath = path11.join(nodeModulesPath, depName);
3794
- if (!fs13.existsSync(depPath)) {
3597
+ const depPath = path9.join(nodeModulesPath, depName);
3598
+ if (!fs11.existsSync(depPath)) {
3795
3599
  missing.push(depName);
3796
3600
  }
3797
3601
  }
@@ -3802,7 +3606,7 @@ function installMissingDeps(deps) {
3802
3606
  return;
3803
3607
  }
3804
3608
  console.log(`[action-plugin] Installing missing dependencies: ${deps.join(", ")}`);
3805
- const result = spawnSync6("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
3609
+ const result = spawnSync4("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
3806
3610
  cwd: getProjectRoot(),
3807
3611
  stdio: "inherit"
3808
3612
  });
@@ -3815,16 +3619,16 @@ function installMissingDeps(deps) {
3815
3619
  }
3816
3620
  function removePluginDirectory(pluginName) {
3817
3621
  const pluginPath = getPluginPath(pluginName);
3818
- if (fs13.existsSync(pluginPath)) {
3819
- fs13.rmSync(pluginPath, { recursive: true });
3622
+ if (fs11.existsSync(pluginPath)) {
3623
+ fs11.rmSync(pluginPath, { recursive: true });
3820
3624
  console.log(`[action-plugin] Removed ${pluginName}`);
3821
3625
  }
3822
3626
  }
3823
3627
 
3824
3628
  // src/commands/action-plugin/api-client.ts
3825
3629
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
3826
- import fs14 from "fs";
3827
- import path12 from "path";
3630
+ import fs12 from "fs";
3631
+ import path10 from "path";
3828
3632
  var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
3829
3633
  async function getPluginVersions(keys, latestOnly = true) {
3830
3634
  const client = getHttpClient();
@@ -3888,19 +3692,19 @@ async function downloadFromPublic(downloadURL) {
3888
3692
  return Buffer.from(arrayBuffer);
3889
3693
  }
3890
3694
  function getPluginCacheDir() {
3891
- return path12.join(process.cwd(), PLUGIN_CACHE_DIR);
3695
+ return path10.join(process.cwd(), PLUGIN_CACHE_DIR);
3892
3696
  }
3893
3697
  function ensureCacheDir() {
3894
3698
  const cacheDir = getPluginCacheDir();
3895
- if (!fs14.existsSync(cacheDir)) {
3896
- fs14.mkdirSync(cacheDir, { recursive: true });
3699
+ if (!fs12.existsSync(cacheDir)) {
3700
+ fs12.mkdirSync(cacheDir, { recursive: true });
3897
3701
  }
3898
3702
  }
3899
3703
  function getTempFilePath(pluginKey, version) {
3900
3704
  ensureCacheDir();
3901
3705
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3902
3706
  const filename = `${safeKey}@${version}.tgz`;
3903
- return path12.join(getPluginCacheDir(), filename);
3707
+ return path10.join(getPluginCacheDir(), filename);
3904
3708
  }
3905
3709
  var MAX_RETRIES = 2;
3906
3710
  async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
@@ -3937,7 +3741,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
3937
3741
  );
3938
3742
  }
3939
3743
  const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
3940
- fs14.writeFileSync(tgzPath, tgzBuffer);
3744
+ fs12.writeFileSync(tgzPath, tgzBuffer);
3941
3745
  console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
3942
3746
  return {
3943
3747
  tgzPath,
@@ -3951,18 +3755,18 @@ function getCachePath(pluginKey, version) {
3951
3755
  ensureCacheDir();
3952
3756
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3953
3757
  const filename = `${safeKey}@${version}.tgz`;
3954
- return path12.join(getPluginCacheDir(), filename);
3758
+ return path10.join(getPluginCacheDir(), filename);
3955
3759
  }
3956
3760
  function hasCachedPlugin(pluginKey, version) {
3957
3761
  const cachePath = getCachePath(pluginKey, version);
3958
- return fs14.existsSync(cachePath);
3762
+ return fs12.existsSync(cachePath);
3959
3763
  }
3960
3764
  function listCachedPlugins() {
3961
3765
  const cacheDir = getPluginCacheDir();
3962
- if (!fs14.existsSync(cacheDir)) {
3766
+ if (!fs12.existsSync(cacheDir)) {
3963
3767
  return [];
3964
3768
  }
3965
- const files = fs14.readdirSync(cacheDir);
3769
+ const files = fs12.readdirSync(cacheDir);
3966
3770
  const result = [];
3967
3771
  for (const file of files) {
3968
3772
  if (!file.endsWith(".tgz")) continue;
@@ -3970,8 +3774,8 @@ function listCachedPlugins() {
3970
3774
  if (!match) continue;
3971
3775
  const [, rawName, version] = match;
3972
3776
  const name = rawName.replace(/^_/, "@").replace(/_/, "/");
3973
- const filePath = path12.join(cacheDir, file);
3974
- const stat = fs14.statSync(filePath);
3777
+ const filePath = path10.join(cacheDir, file);
3778
+ const stat = fs12.statSync(filePath);
3975
3779
  result.push({
3976
3780
  name,
3977
3781
  version,
@@ -3984,14 +3788,14 @@ function listCachedPlugins() {
3984
3788
  }
3985
3789
  function cleanAllCache() {
3986
3790
  const cacheDir = getPluginCacheDir();
3987
- if (!fs14.existsSync(cacheDir)) {
3791
+ if (!fs12.existsSync(cacheDir)) {
3988
3792
  return 0;
3989
3793
  }
3990
- const files = fs14.readdirSync(cacheDir);
3794
+ const files = fs12.readdirSync(cacheDir);
3991
3795
  let count = 0;
3992
3796
  for (const file of files) {
3993
3797
  if (file.endsWith(".tgz")) {
3994
- fs14.unlinkSync(path12.join(cacheDir, file));
3798
+ fs12.unlinkSync(path10.join(cacheDir, file));
3995
3799
  count++;
3996
3800
  }
3997
3801
  }
@@ -3999,21 +3803,21 @@ function cleanAllCache() {
3999
3803
  }
4000
3804
  function cleanPluginCache(pluginKey, version) {
4001
3805
  const cacheDir = getPluginCacheDir();
4002
- if (!fs14.existsSync(cacheDir)) {
3806
+ if (!fs12.existsSync(cacheDir)) {
4003
3807
  return 0;
4004
3808
  }
4005
3809
  const safeKey = pluginKey.replace(/[/@]/g, "_");
4006
- const files = fs14.readdirSync(cacheDir);
3810
+ const files = fs12.readdirSync(cacheDir);
4007
3811
  let count = 0;
4008
3812
  for (const file of files) {
4009
3813
  if (version) {
4010
3814
  if (file === `${safeKey}@${version}.tgz`) {
4011
- fs14.unlinkSync(path12.join(cacheDir, file));
3815
+ fs12.unlinkSync(path10.join(cacheDir, file));
4012
3816
  count++;
4013
3817
  }
4014
3818
  } else {
4015
3819
  if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
4016
- fs14.unlinkSync(path12.join(cacheDir, file));
3820
+ fs12.unlinkSync(path10.join(cacheDir, file));
4017
3821
  count++;
4018
3822
  }
4019
3823
  }
@@ -4440,40 +4244,40 @@ var actionPluginCommandGroup = {
4440
4244
  };
4441
4245
 
4442
4246
  // src/commands/capability/utils.ts
4443
- import fs15 from "fs";
4247
+ import fs13 from "fs";
4444
4248
  import { createRequire as createRequire2 } from "module";
4445
- import path13 from "path";
4249
+ import path11 from "path";
4446
4250
  var CAPABILITIES_DIR = "server/capabilities";
4447
4251
  function getProjectRoot2() {
4448
4252
  return process.cwd();
4449
4253
  }
4450
4254
  function getCapabilitiesDir() {
4451
- return path13.join(getProjectRoot2(), CAPABILITIES_DIR);
4255
+ return path11.join(getProjectRoot2(), CAPABILITIES_DIR);
4452
4256
  }
4453
4257
  function getCapabilityPath(id) {
4454
- return path13.join(getCapabilitiesDir(), `${id}.json`);
4258
+ return path11.join(getCapabilitiesDir(), `${id}.json`);
4455
4259
  }
4456
4260
  function getPluginManifestPath(pluginKey) {
4457
- return path13.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4261
+ return path11.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4458
4262
  }
4459
4263
  function capabilitiesDirExists() {
4460
- return fs15.existsSync(getCapabilitiesDir());
4264
+ return fs13.existsSync(getCapabilitiesDir());
4461
4265
  }
4462
4266
  function listCapabilityIds() {
4463
4267
  const dir = getCapabilitiesDir();
4464
- if (!fs15.existsSync(dir)) {
4268
+ if (!fs13.existsSync(dir)) {
4465
4269
  return [];
4466
4270
  }
4467
- const files = fs15.readdirSync(dir);
4271
+ const files = fs13.readdirSync(dir);
4468
4272
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
4469
4273
  }
4470
4274
  function readCapability(id) {
4471
4275
  const filePath = getCapabilityPath(id);
4472
- if (!fs15.existsSync(filePath)) {
4276
+ if (!fs13.existsSync(filePath)) {
4473
4277
  throw new Error(`Capability not found: ${id}`);
4474
4278
  }
4475
4279
  try {
4476
- const content = fs15.readFileSync(filePath, "utf-8");
4280
+ const content = fs13.readFileSync(filePath, "utf-8");
4477
4281
  return JSON.parse(content);
4478
4282
  } catch (error) {
4479
4283
  if (error instanceof SyntaxError) {
@@ -4500,11 +4304,11 @@ function readAllCapabilities() {
4500
4304
  }
4501
4305
  function readPluginManifest(pluginKey) {
4502
4306
  const manifestPath = getPluginManifestPath(pluginKey);
4503
- if (!fs15.existsSync(manifestPath)) {
4307
+ if (!fs13.existsSync(manifestPath)) {
4504
4308
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
4505
4309
  }
4506
4310
  try {
4507
- const content = fs15.readFileSync(manifestPath, "utf-8");
4311
+ const content = fs13.readFileSync(manifestPath, "utf-8");
4508
4312
  return JSON.parse(content);
4509
4313
  } catch (error) {
4510
4314
  if (error instanceof SyntaxError) {
@@ -4521,7 +4325,7 @@ function hasValidParamsSchema(paramsSchema) {
4521
4325
  }
4522
4326
  async function loadPlugin(pluginKey) {
4523
4327
  try {
4524
- const userRequire = createRequire2(path13.join(getProjectRoot2(), "package.json"));
4328
+ const userRequire = createRequire2(path11.join(getProjectRoot2(), "package.json"));
4525
4329
  const resolvedPath = userRequire.resolve(pluginKey);
4526
4330
  const pluginModule = await import(resolvedPath);
4527
4331
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -4684,8 +4488,8 @@ var capabilityCommandGroup = {
4684
4488
  import { execFile } from "child_process";
4685
4489
 
4686
4490
  // src/commands/component/registry-preparer.ts
4687
- import fs16 from "fs";
4688
- import path14 from "path";
4491
+ import fs14 from "fs";
4492
+ import path12 from "path";
4689
4493
  import os from "os";
4690
4494
 
4691
4495
  // src/commands/component/service.ts
@@ -4741,7 +4545,7 @@ async function sendInstallEvent(key) {
4741
4545
  }
4742
4546
 
4743
4547
  // src/commands/component/registry-preparer.ts
4744
- var REGISTRY_TEMP_DIR = path14.join(os.tmpdir(), "miaoda-registry");
4548
+ var REGISTRY_TEMP_DIR = path12.join(os.tmpdir(), "miaoda-registry");
4745
4549
  function parseComponentKey(key) {
4746
4550
  const match = key.match(/^@([^/]+)\/(.+)$/);
4747
4551
  if (!match) {
@@ -4753,11 +4557,11 @@ function parseComponentKey(key) {
4753
4557
  }
4754
4558
  function getLocalRegistryPath(key) {
4755
4559
  const { scope, name } = parseComponentKey(key);
4756
- return path14.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4560
+ return path12.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4757
4561
  }
4758
4562
  function ensureDir(dirPath) {
4759
- if (!fs16.existsSync(dirPath)) {
4760
- fs16.mkdirSync(dirPath, { recursive: true });
4563
+ if (!fs14.existsSync(dirPath)) {
4564
+ fs14.mkdirSync(dirPath, { recursive: true });
4761
4565
  }
4762
4566
  }
4763
4567
  async function prepareRecursive(key, visited) {
@@ -4790,8 +4594,8 @@ async function prepareRecursive(key, visited) {
4790
4594
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
4791
4595
  };
4792
4596
  const localPath = getLocalRegistryPath(key);
4793
- ensureDir(path14.dirname(localPath));
4794
- fs16.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4597
+ ensureDir(path12.dirname(localPath));
4598
+ fs14.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4795
4599
  debug("\u4FDD\u5B58\u5230: %s", localPath);
4796
4600
  }
4797
4601
  async function prepareComponentRegistryItems(id) {
@@ -4801,18 +4605,18 @@ async function prepareComponentRegistryItems(id) {
4801
4605
  }
4802
4606
  function cleanupTempDir() {
4803
4607
  try {
4804
- if (fs16.existsSync(REGISTRY_TEMP_DIR)) {
4805
- fs16.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4608
+ if (fs14.existsSync(REGISTRY_TEMP_DIR)) {
4609
+ fs14.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4806
4610
  }
4807
4611
  } catch {
4808
4612
  }
4809
4613
  }
4810
4614
  function getDownloadedRegistryItem(itemId) {
4811
4615
  const localPath = getLocalRegistryPath(itemId);
4812
- if (!fs16.existsSync(localPath)) {
4616
+ if (!fs14.existsSync(localPath)) {
4813
4617
  return null;
4814
4618
  }
4815
- const content = fs16.readFileSync(localPath, "utf-8");
4619
+ const content = fs14.readFileSync(localPath, "utf-8");
4816
4620
  return JSON.parse(content);
4817
4621
  }
4818
4622
 
@@ -4980,58 +4784,58 @@ var componentCommandGroup = {
4980
4784
  };
4981
4785
 
4982
4786
  // src/commands/migration/version-manager.ts
4983
- import fs17 from "fs";
4984
- import path15 from "path";
4787
+ import fs15 from "fs";
4788
+ import path13 from "path";
4985
4789
  var PACKAGE_JSON = "package.json";
4986
4790
  var VERSION_FIELD = "migrationVersion";
4987
4791
  function getPackageJsonPath2() {
4988
- return path15.join(process.cwd(), PACKAGE_JSON);
4792
+ return path13.join(process.cwd(), PACKAGE_JSON);
4989
4793
  }
4990
4794
  function getCurrentVersion() {
4991
4795
  const pkgPath = getPackageJsonPath2();
4992
- if (!fs17.existsSync(pkgPath)) {
4796
+ if (!fs15.existsSync(pkgPath)) {
4993
4797
  throw new Error("package.json not found");
4994
4798
  }
4995
- const pkg2 = JSON.parse(fs17.readFileSync(pkgPath, "utf-8"));
4799
+ const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
4996
4800
  return pkg2[VERSION_FIELD] ?? 0;
4997
4801
  }
4998
4802
  function setCurrentVersion(version) {
4999
4803
  const pkgPath = getPackageJsonPath2();
5000
- const pkg2 = JSON.parse(fs17.readFileSync(pkgPath, "utf-8"));
4804
+ const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
5001
4805
  pkg2[VERSION_FIELD] = version;
5002
- fs17.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4806
+ fs15.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
5003
4807
  }
5004
4808
 
5005
4809
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
5006
- import fs19 from "fs";
5007
- import path17 from "path";
4810
+ import fs17 from "fs";
4811
+ import path15 from "path";
5008
4812
 
5009
4813
  // src/commands/migration/versions/v001_capability/utils.ts
5010
- import fs18 from "fs";
5011
- import path16 from "path";
4814
+ import fs16 from "fs";
4815
+ import path14 from "path";
5012
4816
  var CAPABILITIES_DIR2 = "server/capabilities";
5013
4817
  function getProjectRoot3() {
5014
4818
  return process.cwd();
5015
4819
  }
5016
4820
  function getCapabilitiesDir2() {
5017
- return path16.join(getProjectRoot3(), CAPABILITIES_DIR2);
4821
+ return path14.join(getProjectRoot3(), CAPABILITIES_DIR2);
5018
4822
  }
5019
4823
  function getPluginManifestPath2(pluginKey) {
5020
- return path16.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4824
+ return path14.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
5021
4825
  }
5022
4826
 
5023
4827
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
5024
4828
  function detectJsonMigration() {
5025
4829
  const capabilitiesDir = getCapabilitiesDir2();
5026
- const oldFilePath = path17.join(capabilitiesDir, "capabilities.json");
5027
- if (!fs19.existsSync(oldFilePath)) {
4830
+ const oldFilePath = path15.join(capabilitiesDir, "capabilities.json");
4831
+ if (!fs17.existsSync(oldFilePath)) {
5028
4832
  return {
5029
4833
  needsMigration: false,
5030
4834
  reason: "capabilities.json not found"
5031
4835
  };
5032
4836
  }
5033
4837
  try {
5034
- const content = fs19.readFileSync(oldFilePath, "utf-8");
4838
+ const content = fs17.readFileSync(oldFilePath, "utf-8");
5035
4839
  const parsed = JSON.parse(content);
5036
4840
  if (!Array.isArray(parsed)) {
5037
4841
  return {
@@ -5082,8 +4886,8 @@ async function check(options) {
5082
4886
  }
5083
4887
 
5084
4888
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5085
- import fs20 from "fs";
5086
- import path18 from "path";
4889
+ import fs18 from "fs";
4890
+ import path16 from "path";
5087
4891
 
5088
4892
  // src/commands/migration/versions/v001_capability/mapping.ts
5089
4893
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -5313,18 +5117,18 @@ function transformCapabilities(oldCapabilities) {
5313
5117
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5314
5118
  function loadExistingCapabilities() {
5315
5119
  const capabilitiesDir = getCapabilitiesDir2();
5316
- if (!fs20.existsSync(capabilitiesDir)) {
5120
+ if (!fs18.existsSync(capabilitiesDir)) {
5317
5121
  return [];
5318
5122
  }
5319
- const files = fs20.readdirSync(capabilitiesDir);
5123
+ const files = fs18.readdirSync(capabilitiesDir);
5320
5124
  const capabilities = [];
5321
5125
  for (const file of files) {
5322
5126
  if (file === "capabilities.json" || !file.endsWith(".json")) {
5323
5127
  continue;
5324
5128
  }
5325
5129
  try {
5326
- const filePath = path18.join(capabilitiesDir, file);
5327
- const content = fs20.readFileSync(filePath, "utf-8");
5130
+ const filePath = path16.join(capabilitiesDir, file);
5131
+ const content = fs18.readFileSync(filePath, "utf-8");
5328
5132
  const capability = JSON.parse(content);
5329
5133
  if (capability.id && capability.pluginKey) {
5330
5134
  capabilities.push(capability);
@@ -5382,9 +5186,9 @@ async function migrateJsonFiles(options) {
5382
5186
  }
5383
5187
  const capabilitiesDir = getCapabilitiesDir2();
5384
5188
  for (const cap of newCapabilities) {
5385
- const filePath = path18.join(capabilitiesDir, `${cap.id}.json`);
5189
+ const filePath = path16.join(capabilitiesDir, `${cap.id}.json`);
5386
5190
  const content = JSON.stringify(cap, null, 2);
5387
- fs20.writeFileSync(filePath, content, "utf-8");
5191
+ fs18.writeFileSync(filePath, content, "utf-8");
5388
5192
  console.log(` \u2713 Created: ${cap.id}.json`);
5389
5193
  }
5390
5194
  return {
@@ -5396,11 +5200,11 @@ async function migrateJsonFiles(options) {
5396
5200
  }
5397
5201
 
5398
5202
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
5399
- import fs21 from "fs";
5203
+ import fs19 from "fs";
5400
5204
  function isPluginInstalled2(pluginKey) {
5401
5205
  const actionPlugins = readActionPlugins();
5402
5206
  const manifestPath = getPluginManifestPath2(pluginKey);
5403
- return fs21.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5207
+ return fs19.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5404
5208
  }
5405
5209
  function detectPluginsToInstall(capabilities) {
5406
5210
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -5476,12 +5280,12 @@ async function installPlugins(capabilities, options) {
5476
5280
  }
5477
5281
 
5478
5282
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
5479
- import path20 from "path";
5283
+ import path18 from "path";
5480
5284
  import { Project as Project3 } from "ts-morph";
5481
5285
 
5482
5286
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
5483
- import fs22 from "fs";
5484
- import path19 from "path";
5287
+ import fs20 from "fs";
5288
+ import path17 from "path";
5485
5289
  var EXCLUDED_DIRS = [
5486
5290
  "node_modules",
5487
5291
  "dist",
@@ -5496,9 +5300,9 @@ var EXCLUDED_PATTERNS = [
5496
5300
  /\.d\.ts$/
5497
5301
  ];
5498
5302
  function scanDirectory(dir, files = []) {
5499
- const entries = fs22.readdirSync(dir, { withFileTypes: true });
5303
+ const entries = fs20.readdirSync(dir, { withFileTypes: true });
5500
5304
  for (const entry of entries) {
5501
- const fullPath = path19.join(dir, entry.name);
5305
+ const fullPath = path17.join(dir, entry.name);
5502
5306
  if (entry.isDirectory()) {
5503
5307
  if (EXCLUDED_DIRS.includes(entry.name)) {
5504
5308
  continue;
@@ -5514,14 +5318,14 @@ function scanDirectory(dir, files = []) {
5514
5318
  return files;
5515
5319
  }
5516
5320
  function scanServerFiles() {
5517
- const serverDir = path19.join(getProjectRoot3(), "server");
5518
- if (!fs22.existsSync(serverDir)) {
5321
+ const serverDir = path17.join(getProjectRoot3(), "server");
5322
+ if (!fs20.existsSync(serverDir)) {
5519
5323
  return [];
5520
5324
  }
5521
5325
  return scanDirectory(serverDir);
5522
5326
  }
5523
5327
  function hasCapabilityImport(filePath) {
5524
- const content = fs22.readFileSync(filePath, "utf-8");
5328
+ const content = fs20.readFileSync(filePath, "utf-8");
5525
5329
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
5526
5330
  }
5527
5331
  function scanFilesToMigrate() {
@@ -5898,7 +5702,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5898
5702
  const callSites = analyzeCallSites(sourceFile, imports);
5899
5703
  const classInfo = analyzeClass(sourceFile);
5900
5704
  const { canMigrate, reason } = canAutoMigrate(classInfo);
5901
- const relativePath = path20.relative(getProjectRoot3(), filePath);
5705
+ const relativePath = path18.relative(getProjectRoot3(), filePath);
5902
5706
  return {
5903
5707
  filePath: relativePath,
5904
5708
  imports,
@@ -5909,7 +5713,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5909
5713
  };
5910
5714
  }
5911
5715
  function migrateFile(project, analysis, dryRun) {
5912
- const absolutePath = path20.join(getProjectRoot3(), analysis.filePath);
5716
+ const absolutePath = path18.join(getProjectRoot3(), analysis.filePath);
5913
5717
  if (!analysis.canAutoMigrate) {
5914
5718
  return {
5915
5719
  filePath: analysis.filePath,
@@ -6012,17 +5816,17 @@ function getSuggestion(analysis) {
6012
5816
  }
6013
5817
 
6014
5818
  // src/commands/migration/versions/v001_capability/cleanup.ts
6015
- import fs23 from "fs";
6016
- import path21 from "path";
5819
+ import fs21 from "fs";
5820
+ import path19 from "path";
6017
5821
  function cleanupOldFiles(capabilities, dryRun) {
6018
5822
  const deletedFiles = [];
6019
5823
  const errors = [];
6020
5824
  const capabilitiesDir = getCapabilitiesDir2();
6021
- const oldJsonPath = path21.join(capabilitiesDir, "capabilities.json");
6022
- if (fs23.existsSync(oldJsonPath)) {
5825
+ const oldJsonPath = path19.join(capabilitiesDir, "capabilities.json");
5826
+ if (fs21.existsSync(oldJsonPath)) {
6023
5827
  try {
6024
5828
  if (!dryRun) {
6025
- fs23.unlinkSync(oldJsonPath);
5829
+ fs21.unlinkSync(oldJsonPath);
6026
5830
  }
6027
5831
  deletedFiles.push("capabilities.json");
6028
5832
  } catch (error) {
@@ -6030,11 +5834,11 @@ function cleanupOldFiles(capabilities, dryRun) {
6030
5834
  }
6031
5835
  }
6032
5836
  for (const cap of capabilities) {
6033
- const tsFilePath = path21.join(capabilitiesDir, `${cap.id}.ts`);
6034
- if (fs23.existsSync(tsFilePath)) {
5837
+ const tsFilePath = path19.join(capabilitiesDir, `${cap.id}.ts`);
5838
+ if (fs21.existsSync(tsFilePath)) {
6035
5839
  try {
6036
5840
  if (!dryRun) {
6037
- fs23.unlinkSync(tsFilePath);
5841
+ fs21.unlinkSync(tsFilePath);
6038
5842
  }
6039
5843
  deletedFiles.push(`${cap.id}.ts`);
6040
5844
  } catch (error) {
@@ -6050,8 +5854,8 @@ function cleanupOldFiles(capabilities, dryRun) {
6050
5854
  }
6051
5855
 
6052
5856
  // src/commands/migration/versions/v001_capability/report-generator.ts
6053
- import fs24 from "fs";
6054
- import path22 from "path";
5857
+ import fs22 from "fs";
5858
+ import path20 from "path";
6055
5859
  var REPORT_FILE = "capability-migration-report.md";
6056
5860
  function printSummary(result) {
6057
5861
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -6214,15 +6018,15 @@ async function generateReport(result) {
6214
6018
  }
6215
6019
  lines.push("");
6216
6020
  const logDir = process.env.LOG_DIR || "logs";
6217
- if (!fs24.existsSync(logDir)) {
6021
+ if (!fs22.existsSync(logDir)) {
6218
6022
  return;
6219
6023
  }
6220
- const reportDir = path22.join(logDir, "migration");
6221
- if (!fs24.existsSync(reportDir)) {
6222
- fs24.mkdirSync(reportDir, { recursive: true });
6024
+ const reportDir = path20.join(logDir, "migration");
6025
+ if (!fs22.existsSync(reportDir)) {
6026
+ fs22.mkdirSync(reportDir, { recursive: true });
6223
6027
  }
6224
- const reportPath = path22.join(reportDir, REPORT_FILE);
6225
- fs24.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6028
+ const reportPath = path20.join(reportDir, REPORT_FILE);
6029
+ fs22.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6226
6030
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
6227
6031
  }
6228
6032
 
@@ -6399,7 +6203,7 @@ function buildResult(jsonMigration, pluginInstallation, codeMigration, cleanup)
6399
6203
  }
6400
6204
 
6401
6205
  // src/commands/migration/versions/v001_capability/run.ts
6402
- async function run6(options) {
6206
+ async function run5(options) {
6403
6207
  try {
6404
6208
  const migrationOptions = {
6405
6209
  dryRun: options.dryRun ?? false
@@ -6464,7 +6268,7 @@ var v001CapabilityMigration = {
6464
6268
  name: "capability",
6465
6269
  description: "Migrate capability configurations from old format (capabilities.json array) to new format (individual JSON files)",
6466
6270
  check,
6467
- run: run6
6271
+ run: run5
6468
6272
  };
6469
6273
 
6470
6274
  // src/commands/migration/versions/index.ts
@@ -6754,10 +6558,10 @@ var migrationCommand = {
6754
6558
  };
6755
6559
 
6756
6560
  // src/commands/read-logs/index.ts
6757
- import path23 from "path";
6561
+ import path21 from "path";
6758
6562
 
6759
6563
  // src/commands/read-logs/std-utils.ts
6760
- import fs25 from "fs";
6564
+ import fs23 from "fs";
6761
6565
  function formatStdPrefixTime(localTime) {
6762
6566
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
6763
6567
  if (!match) return localTime;
@@ -6787,11 +6591,11 @@ function stripPrefixFromStdLine(line) {
6787
6591
  return `[${time}] ${content}`;
6788
6592
  }
6789
6593
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
6790
- const stat = fs25.statSync(filePath);
6594
+ const stat = fs23.statSync(filePath);
6791
6595
  if (stat.size === 0) {
6792
6596
  return { lines: [], markerFound: false, totalLinesCount: 0 };
6793
6597
  }
6794
- const fd = fs25.openSync(filePath, "r");
6598
+ const fd = fs23.openSync(filePath, "r");
6795
6599
  const chunkSize = 64 * 1024;
6796
6600
  let position = stat.size;
6797
6601
  let remainder = "";
@@ -6805,7 +6609,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6805
6609
  const length = Math.min(chunkSize, position);
6806
6610
  position -= length;
6807
6611
  const buffer = Buffer.alloc(length);
6808
- fs25.readSync(fd, buffer, 0, length, position);
6612
+ fs23.readSync(fd, buffer, 0, length, position);
6809
6613
  let chunk = buffer.toString("utf8");
6810
6614
  if (remainder) {
6811
6615
  chunk += remainder;
@@ -6847,7 +6651,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6847
6651
  }
6848
6652
  }
6849
6653
  } finally {
6850
- fs25.closeSync(fd);
6654
+ fs23.closeSync(fd);
6851
6655
  }
6852
6656
  return { lines: collected.reverse(), markerFound, totalLinesCount };
6853
6657
  }
@@ -6868,21 +6672,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
6868
6672
  }
6869
6673
 
6870
6674
  // src/commands/read-logs/tail.ts
6871
- import fs26 from "fs";
6675
+ import fs24 from "fs";
6872
6676
  function fileExists(filePath) {
6873
6677
  try {
6874
- fs26.accessSync(filePath, fs26.constants.F_OK | fs26.constants.R_OK);
6678
+ fs24.accessSync(filePath, fs24.constants.F_OK | fs24.constants.R_OK);
6875
6679
  return true;
6876
6680
  } catch {
6877
6681
  return false;
6878
6682
  }
6879
6683
  }
6880
6684
  function readFileTailLines(filePath, maxLines) {
6881
- const stat = fs26.statSync(filePath);
6685
+ const stat = fs24.statSync(filePath);
6882
6686
  if (stat.size === 0) {
6883
6687
  return [];
6884
6688
  }
6885
- const fd = fs26.openSync(filePath, "r");
6689
+ const fd = fs24.openSync(filePath, "r");
6886
6690
  const chunkSize = 64 * 1024;
6887
6691
  const chunks = [];
6888
6692
  let position = stat.size;
@@ -6892,13 +6696,13 @@ function readFileTailLines(filePath, maxLines) {
6892
6696
  const length = Math.min(chunkSize, position);
6893
6697
  position -= length;
6894
6698
  const buffer = Buffer.alloc(length);
6895
- fs26.readSync(fd, buffer, 0, length, position);
6699
+ fs24.readSync(fd, buffer, 0, length, position);
6896
6700
  chunks.unshift(buffer.toString("utf8"));
6897
6701
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
6898
6702
  collectedLines += chunkLines;
6899
6703
  }
6900
6704
  } finally {
6901
- fs26.closeSync(fd);
6705
+ fs24.closeSync(fd);
6902
6706
  }
6903
6707
  const content = chunks.join("");
6904
6708
  const allLines = content.split("\n");
@@ -6914,11 +6718,11 @@ function readFileTailLines(filePath, maxLines) {
6914
6718
  return allLines.slice(allLines.length - maxLines);
6915
6719
  }
6916
6720
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6917
- const stat = fs26.statSync(filePath);
6721
+ const stat = fs24.statSync(filePath);
6918
6722
  if (stat.size === 0) {
6919
6723
  return { lines: [], totalLinesCount: 0 };
6920
6724
  }
6921
- const fd = fs26.openSync(filePath, "r");
6725
+ const fd = fs24.openSync(filePath, "r");
6922
6726
  const chunkSize = 64 * 1024;
6923
6727
  let position = stat.size;
6924
6728
  let remainder = "";
@@ -6930,7 +6734,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6930
6734
  const length = Math.min(chunkSize, position);
6931
6735
  position -= length;
6932
6736
  const buffer = Buffer.alloc(length);
6933
- fs26.readSync(fd, buffer, 0, length, position);
6737
+ fs24.readSync(fd, buffer, 0, length, position);
6934
6738
  let chunk = buffer.toString("utf8");
6935
6739
  if (remainder) {
6936
6740
  chunk += remainder;
@@ -6961,7 +6765,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6961
6765
  }
6962
6766
  }
6963
6767
  } finally {
6964
- fs26.closeSync(fd);
6768
+ fs24.closeSync(fd);
6965
6769
  }
6966
6770
  return { lines: collected.reverse(), totalLinesCount };
6967
6771
  }
@@ -7103,7 +6907,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
7103
6907
  }
7104
6908
 
7105
6909
  // src/commands/read-logs/json-lines.ts
7106
- import fs27 from "fs";
6910
+ import fs25 from "fs";
7107
6911
  function normalizePid(value) {
7108
6912
  if (typeof value === "number") {
7109
6913
  return String(value);
@@ -7154,11 +6958,11 @@ function buildWantedLevelSet(levels) {
7154
6958
  return set.size > 0 ? set : null;
7155
6959
  }
7156
6960
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7157
- const stat = fs27.statSync(filePath);
6961
+ const stat = fs25.statSync(filePath);
7158
6962
  if (stat.size === 0) {
7159
6963
  return { lines: [], totalLinesCount: 0 };
7160
6964
  }
7161
- const fd = fs27.openSync(filePath, "r");
6965
+ const fd = fs25.openSync(filePath, "r");
7162
6966
  const chunkSize = 64 * 1024;
7163
6967
  let position = stat.size;
7164
6968
  let remainder = "";
@@ -7173,7 +6977,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7173
6977
  const length = Math.min(chunkSize, position);
7174
6978
  position -= length;
7175
6979
  const buffer = Buffer.alloc(length);
7176
- fs27.readSync(fd, buffer, 0, length, position);
6980
+ fs25.readSync(fd, buffer, 0, length, position);
7177
6981
  let chunk = buffer.toString("utf8");
7178
6982
  if (remainder) {
7179
6983
  chunk += remainder;
@@ -7235,7 +7039,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7235
7039
  }
7236
7040
  }
7237
7041
  } finally {
7238
- fs27.closeSync(fd);
7042
+ fs25.closeSync(fd);
7239
7043
  }
7240
7044
  return { lines: collected.reverse(), totalLinesCount };
7241
7045
  }
@@ -7278,11 +7082,11 @@ function extractTraceId(obj) {
7278
7082
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7279
7083
  const wanted = traceId.trim();
7280
7084
  if (!wanted) return { lines: [], totalLinesCount: 0 };
7281
- const stat = fs27.statSync(filePath);
7085
+ const stat = fs25.statSync(filePath);
7282
7086
  if (stat.size === 0) {
7283
7087
  return { lines: [], totalLinesCount: 0 };
7284
7088
  }
7285
- const fd = fs27.openSync(filePath, "r");
7089
+ const fd = fs25.openSync(filePath, "r");
7286
7090
  const chunkSize = 64 * 1024;
7287
7091
  let position = stat.size;
7288
7092
  let remainder = "";
@@ -7295,7 +7099,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7295
7099
  const length = Math.min(chunkSize, position);
7296
7100
  position -= length;
7297
7101
  const buffer = Buffer.alloc(length);
7298
- fs27.readSync(fd, buffer, 0, length, position);
7102
+ fs25.readSync(fd, buffer, 0, length, position);
7299
7103
  let chunk = buffer.toString("utf8");
7300
7104
  if (remainder) {
7301
7105
  chunk += remainder;
@@ -7348,7 +7152,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7348
7152
  }
7349
7153
  }
7350
7154
  } finally {
7351
- fs27.closeSync(fd);
7155
+ fs25.closeSync(fd);
7352
7156
  }
7353
7157
  return { lines: collected.reverse(), totalLinesCount };
7354
7158
  }
@@ -7357,11 +7161,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7357
7161
  if (!wantedLevelSet) {
7358
7162
  return { lines: [], totalLinesCount: 0 };
7359
7163
  }
7360
- const stat = fs27.statSync(filePath);
7164
+ const stat = fs25.statSync(filePath);
7361
7165
  if (stat.size === 0) {
7362
7166
  return { lines: [], totalLinesCount: 0 };
7363
7167
  }
7364
- const fd = fs27.openSync(filePath, "r");
7168
+ const fd = fs25.openSync(filePath, "r");
7365
7169
  const chunkSize = 64 * 1024;
7366
7170
  let position = stat.size;
7367
7171
  let remainder = "";
@@ -7373,7 +7177,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7373
7177
  const length = Math.min(chunkSize, position);
7374
7178
  position -= length;
7375
7179
  const buffer = Buffer.alloc(length);
7376
- fs27.readSync(fd, buffer, 0, length, position);
7180
+ fs25.readSync(fd, buffer, 0, length, position);
7377
7181
  let chunk = buffer.toString("utf8");
7378
7182
  if (remainder) {
7379
7183
  chunk += remainder;
@@ -7420,7 +7224,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7420
7224
  }
7421
7225
  }
7422
7226
  } finally {
7423
- fs27.closeSync(fd);
7227
+ fs25.closeSync(fd);
7424
7228
  }
7425
7229
  return { lines: collected.reverse(), totalLinesCount };
7426
7230
  }
@@ -7654,34 +7458,34 @@ async function readLogsJsonResult(options) {
7654
7458
  };
7655
7459
  }
7656
7460
  function resolveLogFilePath(logDir, type) {
7657
- const base = path23.isAbsolute(logDir) ? logDir : path23.join(process.cwd(), logDir);
7461
+ const base = path21.isAbsolute(logDir) ? logDir : path21.join(process.cwd(), logDir);
7658
7462
  if (type === "server") {
7659
- return path23.join(base, "server.log");
7463
+ return path21.join(base, "server.log");
7660
7464
  }
7661
7465
  if (type === "trace") {
7662
- return path23.join(base, "trace.log");
7466
+ return path21.join(base, "trace.log");
7663
7467
  }
7664
7468
  if (type === "server-std") {
7665
- return path23.join(base, "server.std.log");
7469
+ return path21.join(base, "server.std.log");
7666
7470
  }
7667
7471
  if (type === "client-std") {
7668
- return path23.join(base, "client.std.log");
7472
+ return path21.join(base, "client.std.log");
7669
7473
  }
7670
7474
  if (type === "dev") {
7671
- return path23.join(base, "dev.log");
7475
+ return path21.join(base, "dev.log");
7672
7476
  }
7673
7477
  if (type === "dev-std") {
7674
- return path23.join(base, "dev.std.log");
7478
+ return path21.join(base, "dev.std.log");
7675
7479
  }
7676
7480
  if (type === "install-dep-std") {
7677
- return path23.join(base, "install-dep.std.log");
7481
+ return path21.join(base, "install-dep.std.log");
7678
7482
  }
7679
7483
  if (type === "browser") {
7680
- return path23.join(base, "browser.log");
7484
+ return path21.join(base, "browser.log");
7681
7485
  }
7682
7486
  throw new Error(`Unsupported log type: ${type}`);
7683
7487
  }
7684
- async function run7(options) {
7488
+ async function run6(options) {
7685
7489
  const result = await readLogsJsonResult(options);
7686
7490
  process.stdout.write(JSON.stringify(result) + "\n");
7687
7491
  }
@@ -7723,7 +7527,7 @@ var readLogsCommand = {
7723
7527
  const offset = parseNonNegativeInt(rawOptions.offset, "--offset");
7724
7528
  const traceId = typeof rawOptions.traceId === "string" ? rawOptions.traceId : void 0;
7725
7529
  const levels = parseCommaSeparatedList(rawOptions.level);
7726
- await run7({ logDir, type, maxLines, offset, traceId, levels });
7530
+ await run6({ logDir, type, maxLines, offset, traceId, levels });
7727
7531
  } catch (error) {
7728
7532
  const message = error instanceof Error ? error.message : String(error);
7729
7533
  process.stderr.write(message + "\n");
@@ -7854,9 +7658,9 @@ function camelToKebab(str) {
7854
7658
  }
7855
7659
 
7856
7660
  // src/commands/build/upload-static.handler.ts
7857
- import * as fs28 from "fs";
7661
+ import * as fs26 from "fs";
7858
7662
  import * as os2 from "os";
7859
- import * as path24 from "path";
7663
+ import * as path22 from "path";
7860
7664
  import { execFileSync } from "child_process";
7861
7665
  function readCredentialsFromEnv() {
7862
7666
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -7880,8 +7684,8 @@ async function uploadStatic(options) {
7880
7684
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7881
7685
  region = UPLOAD_STATIC_DEFAULTS.region
7882
7686
  } = options;
7883
- const resolvedStaticDir = path24.resolve(staticDir);
7884
- if (!fs28.existsSync(resolvedStaticDir)) {
7687
+ const resolvedStaticDir = path22.resolve(staticDir);
7688
+ if (!fs26.existsSync(resolvedStaticDir)) {
7885
7689
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7886
7690
  return;
7887
7691
  }
@@ -7914,8 +7718,8 @@ async function uploadStatic(options) {
7914
7718
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7915
7719
  }
7916
7720
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7917
- const confPath = path24.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7918
- fs28.writeFileSync(confPath, "");
7721
+ const confPath = path22.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7722
+ fs26.writeFileSync(confPath, "");
7919
7723
  try {
7920
7724
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7921
7725
  configureTosutil(resolvedTosutil, confPath, {
@@ -7929,7 +7733,7 @@ async function uploadStatic(options) {
7929
7733
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7930
7734
  } finally {
7931
7735
  try {
7932
- fs28.unlinkSync(confPath);
7736
+ fs26.unlinkSync(confPath);
7933
7737
  } catch {
7934
7738
  }
7935
7739
  }
@@ -7949,8 +7753,8 @@ async function uploadStatic(options) {
7949
7753
  }
7950
7754
  }
7951
7755
  function resolveTosutilPath(tosutilPath) {
7952
- if (path24.isAbsolute(tosutilPath)) {
7953
- return fs28.existsSync(tosutilPath) ? tosutilPath : null;
7756
+ if (path22.isAbsolute(tosutilPath)) {
7757
+ return fs26.existsSync(tosutilPath) ? tosutilPath : null;
7954
7758
  }
7955
7759
  try {
7956
7760
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -7995,7 +7799,7 @@ async function resolveBucketId(appId) {
7995
7799
  return bucketId;
7996
7800
  }
7997
7801
  function isDirEmpty(dirPath) {
7998
- const entries = fs28.readdirSync(dirPath);
7802
+ const entries = fs26.readdirSync(dirPath);
7999
7803
  return entries.length === 0;
8000
7804
  }
8001
7805
 
@@ -8090,12 +7894,12 @@ var commands = [
8090
7894
  ];
8091
7895
 
8092
7896
  // src/index.ts
8093
- var envPath = path25.join(process.cwd(), ".env");
8094
- if (fs29.existsSync(envPath)) {
7897
+ var envPath = path23.join(process.cwd(), ".env");
7898
+ if (fs27.existsSync(envPath)) {
8095
7899
  dotenvConfig({ path: envPath });
8096
7900
  }
8097
- var __dirname = path25.dirname(fileURLToPath5(import.meta.url));
8098
- var pkg = JSON.parse(fs29.readFileSync(path25.join(__dirname, "../package.json"), "utf-8"));
7901
+ var __dirname = path23.dirname(fileURLToPath5(import.meta.url));
7902
+ var pkg = JSON.parse(fs27.readFileSync(path23.join(__dirname, "../package.json"), "utf-8"));
8099
7903
  var cli = new FullstackCLI(pkg.version);
8100
7904
  cli.useAll(commands);
8101
7905
  cli.run();