@lark-apaas/fullstack-cli 1.1.45-beta.0 → 1.1.46-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 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
 
@@ -2373,35 +2373,13 @@ import { fileURLToPath as fileURLToPath3 } from "url";
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. 同步 .githooks 目录(hook 入口,可执行 sh 脚本)
2384
- {
2385
- from: "templates/.githooks",
2386
- to: ".githooks",
2387
- type: "directory",
2388
- overwrite: true
2389
- },
2390
- // 1b. scripts.prepare:npm install 后自动激活 git hooks(原生 git,无第三方依赖)
2391
- // 直接写 core.hooksPath,并保底给 pre-commit 加执行位;非 git 仓库下静默退出
2392
- {
2393
- type: "add-script",
2394
- name: "prepare",
2395
- command: "chmod +x .githooks/pre-commit 2>/dev/null; git config core.hooksPath .githooks 2>/dev/null || true",
2396
- overwrite: false
2397
- },
2398
- // 1c. scripts.precommit = pre-commit 真正的执行体(跑 npm run lint)
2399
- {
2400
- type: "add-script",
2401
- name: "precommit",
2402
- command: "node scripts/hooks/run-precommit.js",
2403
- overwrite: false
2404
- },
2405
2383
  // 2. 智能合并 nest-cli.json 配置(保留用户自定义的 assets、plugins 等)
2406
2384
  {
2407
2385
  from: "templates/nest-cli.json",
@@ -2462,14 +2440,6 @@ var syncConfig = {
2462
2440
  to: ".spark_project",
2463
2441
  type: "file",
2464
2442
  overwrite: true
2465
- },
2466
- // 9. 把模板版本的 lint 脚本替换为支持 --files 的 runner
2467
- // 只识别平台模板生成的 `concurrently ...` 形态,用户真正改写过的脚本保持原样
2468
- {
2469
- type: "patch-script",
2470
- name: "lint",
2471
- to: "node ./scripts/lint.js",
2472
- ifStartsWith: "concurrently "
2473
2443
  }
2474
2444
  ],
2475
2445
  // 文件权限设置
@@ -2557,44 +2527,79 @@ function deepMergeJson(user, template, arrayMerge = {}, currentPath = "") {
2557
2527
  return result;
2558
2528
  }
2559
2529
 
2560
- // src/commands/sync/activate-hooks.ts
2530
+ // src/utils/package-json.ts
2561
2531
  import fs6 from "fs";
2562
2532
  import path4 from "path";
2563
- import { spawnSync as spawnSync2 } from "child_process";
2564
- function activateGitHooks(userProjectRoot) {
2565
- if (!fs6.existsSync(path4.join(userProjectRoot, ".git"))) {
2566
- return { action: "skipped-no-git" };
2567
- }
2568
- const hookFile = path4.join(userProjectRoot, ".githooks", "pre-commit");
2569
- if (!fs6.existsSync(hookFile)) {
2570
- return { action: "skipped-no-hook-file" };
2571
- }
2572
- let changed = false;
2573
- const currentMode = fs6.statSync(hookFile).mode & 511;
2574
- if ((currentMode & 73) !== 73) {
2575
- fs6.chmodSync(hookFile, 493);
2576
- changed = true;
2577
- }
2578
- const probe = spawnSync2("git", ["config", "--get", "core.hooksPath"], {
2579
- cwd: userProjectRoot,
2580
- stdio: ["ignore", "pipe", "ignore"]
2581
- });
2582
- const currentHooksPath = probe.stdout ? probe.stdout.toString().trim() : "";
2583
- if (currentHooksPath !== ".githooks") {
2584
- const res = spawnSync2("git", ["config", "core.hooksPath", ".githooks"], {
2585
- cwd: userProjectRoot,
2586
- stdio: ["ignore", "inherit", "inherit"]
2587
- });
2588
- if (res.status !== 0) {
2589
- throw new Error(`git config core.hooksPath exited with ${String(res.status)}`);
2590
- }
2591
- changed = true;
2533
+ var LEGACY_LINT_SCRIPT = 'concurrently "npm run eslint" "npm run type:check" "npm run stylelint"';
2534
+ var PATCHED_LINT_SCRIPT = "node ./scripts/lint.js";
2535
+ function readPackageJson(cwd = process.cwd()) {
2536
+ const pkgPath = path4.join(cwd, "package.json");
2537
+ if (!fs6.existsSync(pkgPath)) {
2538
+ throw new Error(`package.json not found at ${pkgPath}`);
2539
+ }
2540
+ const content = fs6.readFileSync(pkgPath, "utf-8");
2541
+ return JSON.parse(content);
2542
+ }
2543
+ function writePackageJson(pkg2, cwd = process.cwd()) {
2544
+ const pkgPath = path4.join(cwd, "package.json");
2545
+ const content = JSON.stringify(pkg2, null, 2) + "\n";
2546
+ fs6.writeFileSync(pkgPath, content, "utf-8");
2547
+ }
2548
+ function patchLintScriptForFilesSupport(pkg2) {
2549
+ const currentLint = pkg2.scripts?.lint;
2550
+ if (!currentLint) {
2551
+ return "skipped-missing";
2552
+ }
2553
+ if (currentLint === PATCHED_LINT_SCRIPT || currentLint === "node scripts/lint.js") {
2554
+ return "already-patched";
2555
+ }
2556
+ if (currentLint !== LEGACY_LINT_SCRIPT) {
2557
+ return "skipped-custom";
2558
+ }
2559
+ pkg2.scripts = pkg2.scripts || {};
2560
+ pkg2.scripts.lint = PATCHED_LINT_SCRIPT;
2561
+ return "patched";
2562
+ }
2563
+ function removeUpgradeScript(pkg2) {
2564
+ if (!pkg2.scripts?.upgrade) {
2565
+ return false;
2566
+ }
2567
+ delete pkg2.scripts.upgrade;
2568
+ return true;
2569
+ }
2570
+ function cleanDevScript(pkg2) {
2571
+ if (!pkg2.scripts?.dev) {
2572
+ return false;
2592
2573
  }
2593
- if (changed) {
2594
- console.log("[fullstack-cli] \u2713 git hooks activated (core.hooksPath -> .githooks)");
2595
- return { action: "activated" };
2574
+ const originalDev = pkg2.scripts.dev;
2575
+ const cleanedDev = originalDev.replace(/npm\s+run\s+upgrade\s*&&\s*/g, "").replace(/npm\s+run\s+upgrade\s*$/g, "").trim();
2576
+ if (cleanedDev !== originalDev) {
2577
+ pkg2.scripts.dev = cleanedDev;
2578
+ return true;
2579
+ }
2580
+ return false;
2581
+ }
2582
+ function cleanupPackageJson(cwd = process.cwd()) {
2583
+ try {
2584
+ const pkg2 = readPackageJson(cwd);
2585
+ let changed = false;
2586
+ if (removeUpgradeScript(pkg2)) {
2587
+ console.log("[fullstack-cli] \u2713 Removed scripts.upgrade");
2588
+ changed = true;
2589
+ }
2590
+ if (cleanDevScript(pkg2)) {
2591
+ console.log("[fullstack-cli] \u2713 Cleaned scripts.dev (removed npm run upgrade)");
2592
+ changed = true;
2593
+ }
2594
+ if (changed) {
2595
+ writePackageJson(pkg2, cwd);
2596
+ }
2597
+ return changed;
2598
+ } catch (error) {
2599
+ const message = error instanceof Error ? error.message : String(error);
2600
+ console.log(`[fullstack-cli] \u26A0 Could not cleanup package.json: ${message}`);
2601
+ return false;
2596
2602
  }
2597
- return { action: "already-active" };
2598
2603
  }
2599
2604
 
2600
2605
  // src/commands/sync/run.handler.ts
@@ -2624,15 +2629,10 @@ async function run2(options) {
2624
2629
  for (const rule of config.sync) {
2625
2630
  await syncRule(rule, pluginRoot, userProjectRoot);
2626
2631
  }
2632
+ patchUserPackageJson(userProjectRoot);
2627
2633
  if (config.permissions) {
2628
2634
  setPermissions(config.permissions, userProjectRoot);
2629
2635
  }
2630
- try {
2631
- activateGitHooks(userProjectRoot);
2632
- } catch (error) {
2633
- const message = error instanceof Error ? error.message : String(error);
2634
- console.warn(`[fullstack-cli] \u26A0 Failed to activate git hooks: ${message}`);
2635
- }
2636
2636
  console.log("[fullstack-cli] Sync completed successfully \u2705");
2637
2637
  } catch (error) {
2638
2638
  const message = error instanceof Error ? error.message : String(error);
@@ -2640,6 +2640,29 @@ async function run2(options) {
2640
2640
  process.exit(1);
2641
2641
  }
2642
2642
  }
2643
+ function patchUserPackageJson(userProjectRoot) {
2644
+ try {
2645
+ const pkg2 = readPackageJson(userProjectRoot);
2646
+ const lintPatchResult = patchLintScriptForFilesSupport(pkg2);
2647
+ if (lintPatchResult === "patched") {
2648
+ writePackageJson(pkg2, userProjectRoot);
2649
+ console.log("[fullstack-cli] \u2713 Patched scripts.lint to support --files");
2650
+ return;
2651
+ }
2652
+ if (lintPatchResult === "already-patched") {
2653
+ console.log("[fullstack-cli] \u25CB scripts.lint already supports --files");
2654
+ return;
2655
+ }
2656
+ if (lintPatchResult === "skipped-custom") {
2657
+ console.warn(
2658
+ "[fullstack-cli] \u26A0 Skipped patching scripts.lint because it has been customized"
2659
+ );
2660
+ }
2661
+ } catch (error) {
2662
+ const message = error instanceof Error ? error.message : String(error);
2663
+ console.warn(`[fullstack-cli] \u26A0 Could not patch package.json: ${message}`);
2664
+ }
2665
+ }
2643
2666
  async function syncRule(rule, pluginRoot, userProjectRoot) {
2644
2667
  if (rule.type === "delete-file" || rule.type === "delete-directory") {
2645
2668
  const destPath2 = path5.join(userProjectRoot, rule.to);
@@ -2660,11 +2683,6 @@ async function syncRule(rule, pluginRoot, userProjectRoot) {
2660
2683
  addScript(packageJsonPath, rule.name, rule.command, rule.overwrite ?? false);
2661
2684
  return;
2662
2685
  }
2663
- if (rule.type === "patch-script") {
2664
- const packageJsonPath = path5.join(userProjectRoot, "package.json");
2665
- patchScript(packageJsonPath, rule.name, rule.to, rule.ifStartsWith);
2666
- return;
2667
- }
2668
2686
  if (rule.type === "add-line") {
2669
2687
  const destPath2 = path5.join(userProjectRoot, rule.to);
2670
2688
  addLineToFile(destPath2, rule.line);
@@ -2802,37 +2820,6 @@ function addScript(packageJsonPath, name, command, overwrite) {
2802
2820
  fs7.writeFileSync(packageJsonPath, JSON.stringify(pkg2, null, 2) + "\n");
2803
2821
  console.log(`[fullstack-cli] \u2713 scripts.${name}`);
2804
2822
  }
2805
- function patchScript(packageJsonPath, name, to, ifStartsWith) {
2806
- if (!fs7.existsSync(packageJsonPath)) {
2807
- console.log(`[fullstack-cli] \u25CB package.json (not found)`);
2808
- return;
2809
- }
2810
- try {
2811
- const content = fs7.readFileSync(packageJsonPath, "utf-8");
2812
- const pkg2 = JSON.parse(content);
2813
- const current = pkg2.scripts?.[name];
2814
- if (!current) {
2815
- console.log(`[fullstack-cli] \u25CB scripts.${name} (not present, skipped)`);
2816
- return;
2817
- }
2818
- if (current === to) {
2819
- console.log(`[fullstack-cli] \u25CB scripts.${name} (already patched)`);
2820
- return;
2821
- }
2822
- if (!current.startsWith(ifStartsWith)) {
2823
- console.warn(
2824
- `[fullstack-cli] \u26A0 Skipped patching scripts.${name} because it has been customized`
2825
- );
2826
- return;
2827
- }
2828
- pkg2.scripts[name] = to;
2829
- fs7.writeFileSync(packageJsonPath, JSON.stringify(pkg2, null, 2) + "\n");
2830
- console.log(`[fullstack-cli] \u2713 Patched scripts.${name}`);
2831
- } catch (error) {
2832
- const message = error instanceof Error ? error.message : String(error);
2833
- console.warn(`[fullstack-cli] \u26A0 Could not patch scripts.${name}: ${message}`);
2834
- }
2835
- }
2836
2823
  function addLineToFile(filePath, line) {
2837
2824
  const fileName = path5.basename(filePath);
2838
2825
  if (!fs7.existsSync(filePath)) {
@@ -2933,7 +2920,7 @@ async function reportCreateInstanceEvent(pluginKey, version) {
2933
2920
  }
2934
2921
 
2935
2922
  // src/utils/git.ts
2936
- import { execSync, spawnSync as spawnSync3 } from "child_process";
2923
+ import { execSync, spawnSync as spawnSync2 } from "child_process";
2937
2924
  import fs8 from "fs";
2938
2925
  import path6 from "path";
2939
2926
  function isGitRepository(cwd = process.cwd()) {
@@ -2942,7 +2929,7 @@ function isGitRepository(cwd = process.cwd()) {
2942
2929
  if (fs8.existsSync(gitDir)) {
2943
2930
  return true;
2944
2931
  }
2945
- const result = spawnSync3("git", ["rev-parse", "--git-dir"], {
2932
+ const result = spawnSync2("git", ["rev-parse", "--git-dir"], {
2946
2933
  cwd,
2947
2934
  stdio: "pipe",
2948
2935
  encoding: "utf-8"
@@ -2972,7 +2959,7 @@ function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
2972
2959
  filteredFiles.push(filePath);
2973
2960
  continue;
2974
2961
  }
2975
- const tracked = spawnSync3("git", ["ls-files", "--error-unmatch", "--", filePath], {
2962
+ const tracked = spawnSync2("git", ["ls-files", "--error-unmatch", "--", filePath], {
2976
2963
  cwd,
2977
2964
  stdio: "pipe",
2978
2965
  encoding: "utf-8"
@@ -2984,7 +2971,7 @@ function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
2984
2971
  if (filteredFiles.length === 0) {
2985
2972
  return;
2986
2973
  }
2987
- const result = spawnSync3("git", ["add", "--", ...filteredFiles], {
2974
+ const result = spawnSync2("git", ["add", "--", ...filteredFiles], {
2988
2975
  cwd,
2989
2976
  stdio: "pipe",
2990
2977
  encoding: "utf-8"
@@ -2995,7 +2982,7 @@ function gitAddUpgradeFiles(cwd = process.cwd(), filesToStage) {
2995
2982
  }
2996
2983
  }
2997
2984
  function hasStagedChanges(cwd = process.cwd()) {
2998
- const result = spawnSync3("git", ["diff", "--cached", "--quiet"], {
2985
+ const result = spawnSync2("git", ["diff", "--cached", "--quiet"], {
2999
2986
  cwd,
3000
2987
  stdio: "pipe",
3001
2988
  encoding: "utf-8"
@@ -3010,7 +2997,7 @@ function hasStagedChanges(cwd = process.cwd()) {
3010
2997
  throw new Error(`Failed to check staged changes: ${errorMsg}`);
3011
2998
  }
3012
2999
  function gitCommit(message, cwd = process.cwd()) {
3013
- const result = spawnSync3("git", ["commit", "-m", message], {
3000
+ const result = spawnSync2("git", ["commit", "-m", message], {
3014
3001
  cwd,
3015
3002
  stdio: "pipe",
3016
3003
  encoding: "utf-8"
@@ -3052,74 +3039,16 @@ Auto-committed by fullstack-cli`;
3052
3039
  }
3053
3040
  }
3054
3041
 
3055
- // src/utils/package-json.ts
3056
- import fs9 from "fs";
3057
- import path7 from "path";
3058
- function readPackageJson(cwd = process.cwd()) {
3059
- const pkgPath = path7.join(cwd, "package.json");
3060
- if (!fs9.existsSync(pkgPath)) {
3061
- throw new Error(`package.json not found at ${pkgPath}`);
3062
- }
3063
- const content = fs9.readFileSync(pkgPath, "utf-8");
3064
- return JSON.parse(content);
3065
- }
3066
- function writePackageJson(pkg2, cwd = process.cwd()) {
3067
- const pkgPath = path7.join(cwd, "package.json");
3068
- const content = JSON.stringify(pkg2, null, 2) + "\n";
3069
- fs9.writeFileSync(pkgPath, content, "utf-8");
3070
- }
3071
- function removeUpgradeScript(pkg2) {
3072
- if (!pkg2.scripts?.upgrade) {
3073
- return false;
3074
- }
3075
- delete pkg2.scripts.upgrade;
3076
- return true;
3077
- }
3078
- function cleanDevScript(pkg2) {
3079
- if (!pkg2.scripts?.dev) {
3080
- return false;
3081
- }
3082
- const originalDev = pkg2.scripts.dev;
3083
- const cleanedDev = originalDev.replace(/npm\s+run\s+upgrade\s*&&\s*/g, "").replace(/npm\s+run\s+upgrade\s*$/g, "").trim();
3084
- if (cleanedDev !== originalDev) {
3085
- pkg2.scripts.dev = cleanedDev;
3086
- return true;
3087
- }
3088
- return false;
3089
- }
3090
- function cleanupPackageJson(cwd = process.cwd()) {
3091
- try {
3092
- const pkg2 = readPackageJson(cwd);
3093
- let changed = false;
3094
- if (removeUpgradeScript(pkg2)) {
3095
- console.log("[fullstack-cli] \u2713 Removed scripts.upgrade");
3096
- changed = true;
3097
- }
3098
- if (cleanDevScript(pkg2)) {
3099
- console.log("[fullstack-cli] \u2713 Cleaned scripts.dev (removed npm run upgrade)");
3100
- changed = true;
3101
- }
3102
- if (changed) {
3103
- writePackageJson(pkg2, cwd);
3104
- }
3105
- return changed;
3106
- } catch (error) {
3107
- const message = error instanceof Error ? error.message : String(error);
3108
- console.log(`[fullstack-cli] \u26A0 Could not cleanup package.json: ${message}`);
3109
- return false;
3110
- }
3111
- }
3112
-
3113
3042
  // src/commands/upgrade/shared/utils.ts
3114
- import path8 from "path";
3115
- import fs10 from "fs";
3043
+ import path7 from "path";
3044
+ import fs9 from "fs";
3116
3045
  import { fileURLToPath as fileURLToPath4 } from "url";
3117
3046
  function getCliVersion() {
3118
3047
  try {
3119
3048
  const __filename = fileURLToPath4(import.meta.url);
3120
- const __dirname2 = path8.dirname(__filename);
3121
- const pkgPath = path8.resolve(__dirname2, "../../../package.json");
3122
- 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");
3123
3052
  const pkg2 = JSON.parse(pkgContent);
3124
3053
  return pkg2.version || "unknown";
3125
3054
  } catch {
@@ -3177,47 +3106,31 @@ async function run3(options = {}) {
3177
3106
  }
3178
3107
 
3179
3108
  // src/commands/upgrade/deps/run.handler.ts
3180
- import { spawnSync as spawnSync4 } from "child_process";
3181
- import fs11 from "fs";
3182
- import path9 from "path";
3109
+ import { spawnSync as spawnSync3 } from "child_process";
3110
+ import fs10 from "fs";
3111
+ import path8 from "path";
3183
3112
 
3184
3113
  // src/utils/grayscale/config.ts
3185
3114
  function getGrayscaleConfig(configJson) {
3186
3115
  if (!configJson) {
3187
3116
  return null;
3188
3117
  }
3189
- let parsed;
3190
3118
  try {
3191
- parsed = JSON.parse(configJson);
3192
- } catch {
3193
- console.warn("[grayscale] Failed to parse grayscale config");
3194
- return null;
3195
- }
3196
- if (parsed && parsed.target_versions && typeof parsed.target_versions === "object") {
3197
- const entries = Object.entries(parsed.target_versions).filter(
3198
- ([, v]) => typeof v === "string" && v.length > 0
3199
- );
3200
- if (entries.length === 0) {
3201
- 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) {
3202
3122
  return null;
3203
3123
  }
3204
3124
  return {
3205
- kind: "resolved",
3206
- targetVersions: new Map(entries),
3207
- 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
3208
3129
  };
3209
- }
3210
- const config = parsed?.config;
3211
- if (!config || !config.enabled) {
3130
+ } catch {
3131
+ console.warn("[grayscale] Failed to parse grayscale config");
3212
3132
  return null;
3213
3133
  }
3214
- return {
3215
- kind: "legacy",
3216
- config,
3217
- tenantId: parsed.tenant_id != null ? String(parsed.tenant_id) : void 0,
3218
- appId: parsed.app_id || void 0,
3219
- xTtEnv: parsed.x_tt_env || void 0
3220
- };
3221
3134
  }
3222
3135
 
3223
3136
  // src/utils/grayscale/identity.ts
@@ -3305,19 +3218,6 @@ function resolveGrayscaleVersions(_cwd, configJson) {
3305
3218
  console.log("[grayscale] Config not available, skipping grayscale");
3306
3219
  return null;
3307
3220
  }
3308
- if (result.kind === "resolved") {
3309
- console.log(
3310
- `[grayscale] Using server-resolved versions (matched channel: ${result.matchedChannel || "(stable)"})`
3311
- );
3312
- console.log(`[grayscale] Resolved ${result.targetVersions.size} package version(s):`);
3313
- for (const [pkg2, ver] of result.targetVersions) {
3314
- console.log(`[grayscale] ${pkg2} -> ${ver}`);
3315
- }
3316
- return result.targetVersions;
3317
- }
3318
- console.warn(
3319
- "[grayscale] Received legacy payload (full TCC config). This path is deprecated; sandbox_console should be upgraded to server-side resolution."
3320
- );
3321
3221
  const { config, tenantId: payloadTenantId, appId: payloadAppId, xTtEnv: payloadXTtEnv } = result;
3322
3222
  const envIdentity = readProjectIdentity();
3323
3223
  const identity = {
@@ -3398,7 +3298,7 @@ function upgradePackages(packages, version, cwd) {
3398
3298
  packages.forEach((pkg2) => {
3399
3299
  const target = `${pkg2}@${version}`;
3400
3300
  console.log(`[fullstack-cli] Installing ${target}...`);
3401
- const result = spawnSync4("npm", ["install", target], {
3301
+ const result = spawnSync3("npm", ["install", target], {
3402
3302
  cwd,
3403
3303
  stdio: "inherit"
3404
3304
  });
@@ -3410,7 +3310,7 @@ function upgradePackages(packages, version, cwd) {
3410
3310
  console.log("[fullstack-cli] Upgrading to latest compatible versions...");
3411
3311
  packages.forEach((pkg2) => {
3412
3312
  console.log(`[fullstack-cli] Updating ${pkg2}...`);
3413
- const result = spawnSync4("npm", ["update", pkg2], {
3313
+ const result = spawnSync3("npm", ["update", pkg2], {
3414
3314
  cwd,
3415
3315
  stdio: "inherit"
3416
3316
  });
@@ -3427,8 +3327,8 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
3427
3327
  if (version) {
3428
3328
  let current = "";
3429
3329
  try {
3430
- const installedPkgPath = path9.join(cwd, "node_modules", pkg2, "package.json");
3431
- 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"));
3432
3332
  current = installedPkg.version || "";
3433
3333
  } catch (err) {
3434
3334
  const code = err?.code;
@@ -3471,7 +3371,7 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
3471
3371
  }
3472
3372
  const targets = upgradePlan.map(({ pkg: pkg2, version }) => `${pkg2}@${version}`);
3473
3373
  console.log(`[fullstack-cli] Installing ${targets.join(" ")}...`);
3474
- const result = spawnSync4("npm", ["install", ...targets], {
3374
+ const result = spawnSync3("npm", ["install", ...targets], {
3475
3375
  cwd,
3476
3376
  stdio: "inherit"
3477
3377
  });
@@ -3544,111 +3444,6 @@ var depsCommand = {
3544
3444
  }
3545
3445
  };
3546
3446
 
3547
- // src/commands/upgrade/global-deps/run.handler.ts
3548
- import { spawnSync as spawnSync5 } from "child_process";
3549
- import fs12 from "fs";
3550
- import path10 from "path";
3551
- var MANAGED_GLOBAL_CLIS = [
3552
- "@lark-apaas/fullstack-cli",
3553
- "@lark-apaas/miaoda-cli"
3554
- ];
3555
- function readGlobalInstalledVersion(pkg2) {
3556
- const candidates = [];
3557
- if (process.env.npm_config_prefix) candidates.push(process.env.npm_config_prefix);
3558
- if (process.env.NPM_CONFIG_PREFIX) candidates.push(process.env.NPM_CONFIG_PREFIX);
3559
- candidates.push("/usr");
3560
- candidates.push("/usr/local");
3561
- if (process.env.HOME) candidates.push(path10.join(process.env.HOME, ".npm-global"));
3562
- const seen = /* @__PURE__ */ new Set();
3563
- for (const prefix of candidates) {
3564
- if (seen.has(prefix)) continue;
3565
- seen.add(prefix);
3566
- try {
3567
- const pkgPath = path10.join(prefix, "lib", "node_modules", pkg2, "package.json");
3568
- if (fs12.existsSync(pkgPath)) {
3569
- const meta = JSON.parse(fs12.readFileSync(pkgPath, "utf-8"));
3570
- if (meta && typeof meta.version === "string") return meta.version;
3571
- }
3572
- } catch (err) {
3573
- console.warn(
3574
- `[fullstack-cli] readGlobalInstalledVersion(${pkg2}) failed at prefix=${prefix}: ${err instanceof Error ? err.message : String(err)}`
3575
- );
3576
- }
3577
- }
3578
- return "";
3579
- }
3580
- function buildGlobalUpgradePlan(managed, resolvedVersions, readVersion) {
3581
- const plan = [];
3582
- for (const pkg2 of managed) {
3583
- const target = resolvedVersions.get(pkg2);
3584
- if (!target) {
3585
- console.log(`[fullstack-cli] ${pkg2}: no target version in grayscale config, skip`);
3586
- continue;
3587
- }
3588
- const current = readVersion(pkg2);
3589
- if (current && current === target) {
3590
- console.log(`[fullstack-cli] ${pkg2}@${target} (already installed, skip)`);
3591
- continue;
3592
- }
3593
- plan.push({ pkg: pkg2, current, target });
3594
- }
3595
- return plan;
3596
- }
3597
- async function run5(options = {}) {
3598
- console.log("[fullstack-cli] Starting global CLI upgrade...");
3599
- if (!options.grayscaleConfig) {
3600
- console.log("[fullstack-cli] No grayscale config, skip global upgrade");
3601
- return;
3602
- }
3603
- const grayscaleVersions = resolveGrayscaleVersions("/", options.grayscaleConfig);
3604
- if (!grayscaleVersions) {
3605
- console.log("[fullstack-cli] Grayscale config not available, skip global upgrade");
3606
- return;
3607
- }
3608
- const plan = buildGlobalUpgradePlan(MANAGED_GLOBAL_CLIS, grayscaleVersions, readGlobalInstalledVersion);
3609
- if (plan.length === 0) {
3610
- console.log("[fullstack-cli] No global CLI upgrade needed");
3611
- return;
3612
- }
3613
- console.log(`[fullstack-cli] Global upgrade plan (${plan.length} package(s)):`);
3614
- plan.forEach(({ pkg: pkg2, current, target }) => {
3615
- console.log(` - ${pkg2} ${current || "(not installed)"} -> ${target}`);
3616
- });
3617
- if (options.dryRun) {
3618
- console.log("[fullstack-cli] Dry run mode, skipping actual installation");
3619
- return;
3620
- }
3621
- const targets = plan.map(({ pkg: pkg2, target }) => `${pkg2}@${target}`);
3622
- const npmArgs = ["install", "-g", ...targets];
3623
- if (options.registry) {
3624
- npmArgs.push("--registry", options.registry);
3625
- }
3626
- console.log(`[fullstack-cli] Running: npm ${npmArgs.join(" ")}`);
3627
- const result = spawnSync5("npm", npmArgs, { stdio: "inherit" });
3628
- if (result.error || result.status !== 0) {
3629
- console.warn(
3630
- `[fullstack-cli] npm install -g failed: ${result.error?.message ?? `exit ${result.status}`}`
3631
- );
3632
- process.exit(1);
3633
- }
3634
- console.log("[fullstack-cli] \u2713 Global CLI upgrade completed");
3635
- }
3636
-
3637
- // src/commands/upgrade/global-deps/index.ts
3638
- var globalDepsCommand = {
3639
- name: "global-deps",
3640
- description: "Upgrade global @lark-apaas CLIs (fullstack-cli, miaoda-cli) per grayscale config",
3641
- register(parentCommand) {
3642
- 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(
3643
- "--registry <url>",
3644
- "npm registry URL (default: https://registry.npmmirror.com/)",
3645
- "https://registry.npmmirror.com/"
3646
- ).action(async (options) => {
3647
- await run5(options);
3648
- });
3649
- }
3650
- };
3651
-
3652
3447
  // src/commands/upgrade/index.ts
3653
3448
  var upgradeCommand = {
3654
3449
  name: "upgrade",
@@ -3658,14 +3453,13 @@ var upgradeCommand = {
3658
3453
  await run3(options);
3659
3454
  });
3660
3455
  depsCommand.register(upgradeCmd);
3661
- globalDepsCommand.register(upgradeCmd);
3662
3456
  }
3663
3457
  };
3664
3458
 
3665
3459
  // src/commands/action-plugin/utils.ts
3666
- import fs13 from "fs";
3667
- import path11 from "path";
3668
- 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";
3669
3463
  function parsePluginName(input) {
3670
3464
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
3671
3465
  if (!match) {
@@ -3682,18 +3476,18 @@ function getProjectRoot() {
3682
3476
  return process.cwd();
3683
3477
  }
3684
3478
  function getPackageJsonPath() {
3685
- return path11.join(getProjectRoot(), "package.json");
3479
+ return path9.join(getProjectRoot(), "package.json");
3686
3480
  }
3687
3481
  function getPluginPath(pluginName) {
3688
- return path11.join(getProjectRoot(), "node_modules", pluginName);
3482
+ return path9.join(getProjectRoot(), "node_modules", pluginName);
3689
3483
  }
3690
3484
  function readPackageJson2() {
3691
3485
  const pkgPath = getPackageJsonPath();
3692
- if (!fs13.existsSync(pkgPath)) {
3486
+ if (!fs11.existsSync(pkgPath)) {
3693
3487
  throw new Error("package.json not found in current directory");
3694
3488
  }
3695
3489
  try {
3696
- const content = fs13.readFileSync(pkgPath, "utf-8");
3490
+ const content = fs11.readFileSync(pkgPath, "utf-8");
3697
3491
  return JSON.parse(content);
3698
3492
  } catch {
3699
3493
  throw new Error("Failed to parse package.json");
@@ -3701,7 +3495,7 @@ function readPackageJson2() {
3701
3495
  }
3702
3496
  function writePackageJson2(pkg2) {
3703
3497
  const pkgPath = getPackageJsonPath();
3704
- fs13.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3498
+ fs11.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3705
3499
  }
3706
3500
  function readActionPlugins() {
3707
3501
  const pkg2 = readPackageJson2();
@@ -3722,7 +3516,7 @@ function getInstalledPluginVersion(pluginName) {
3722
3516
  }
3723
3517
  function npmInstall(tgzPath) {
3724
3518
  console.log(`[action-plugin] Running npm install ${tgzPath}...`);
3725
- 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"], {
3726
3520
  cwd: getProjectRoot(),
3727
3521
  stdio: "inherit"
3728
3522
  });
@@ -3734,12 +3528,12 @@ function npmInstall(tgzPath) {
3734
3528
  }
3735
3529
  }
3736
3530
  function getPackageVersion(pluginName) {
3737
- const pkgJsonPath = path11.join(getPluginPath(pluginName), "package.json");
3738
- if (!fs13.existsSync(pkgJsonPath)) {
3531
+ const pkgJsonPath = path9.join(getPluginPath(pluginName), "package.json");
3532
+ if (!fs11.existsSync(pkgJsonPath)) {
3739
3533
  return null;
3740
3534
  }
3741
3535
  try {
3742
- const content = fs13.readFileSync(pkgJsonPath, "utf-8");
3536
+ const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3743
3537
  const pkg2 = JSON.parse(content);
3744
3538
  return pkg2.version || null;
3745
3539
  } catch {
@@ -3747,49 +3541,49 @@ function getPackageVersion(pluginName) {
3747
3541
  }
3748
3542
  }
3749
3543
  function readPluginPackageJson(pluginPath) {
3750
- const pkgJsonPath = path11.join(pluginPath, "package.json");
3751
- if (!fs13.existsSync(pkgJsonPath)) {
3544
+ const pkgJsonPath = path9.join(pluginPath, "package.json");
3545
+ if (!fs11.existsSync(pkgJsonPath)) {
3752
3546
  return null;
3753
3547
  }
3754
3548
  try {
3755
- const content = fs13.readFileSync(pkgJsonPath, "utf-8");
3549
+ const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3756
3550
  return JSON.parse(content);
3757
3551
  } catch {
3758
3552
  return null;
3759
3553
  }
3760
3554
  }
3761
3555
  function extractTgzToNodeModules(tgzPath, pluginName) {
3762
- const nodeModulesPath = path11.join(getProjectRoot(), "node_modules");
3763
- const targetDir = path11.join(nodeModulesPath, pluginName);
3764
- const scopeDir = path11.dirname(targetDir);
3765
- if (!fs13.existsSync(scopeDir)) {
3766
- fs13.mkdirSync(scopeDir, { recursive: true });
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 });
3767
3561
  }
3768
- if (fs13.existsSync(targetDir)) {
3769
- fs13.rmSync(targetDir, { recursive: true });
3562
+ if (fs11.existsSync(targetDir)) {
3563
+ fs11.rmSync(targetDir, { recursive: true });
3770
3564
  }
3771
- const tempDir = path11.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3772
- if (fs13.existsSync(tempDir)) {
3773
- 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 });
3774
3568
  }
3775
- fs13.mkdirSync(tempDir, { recursive: true });
3569
+ fs11.mkdirSync(tempDir, { recursive: true });
3776
3570
  try {
3777
3571
  execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
3778
- const extractedDir = path11.join(tempDir, "package");
3779
- if (fs13.existsSync(extractedDir)) {
3780
- fs13.renameSync(extractedDir, targetDir);
3572
+ const extractedDir = path9.join(tempDir, "package");
3573
+ if (fs11.existsSync(extractedDir)) {
3574
+ fs11.renameSync(extractedDir, targetDir);
3781
3575
  } else {
3782
- const files = fs13.readdirSync(tempDir);
3576
+ const files = fs11.readdirSync(tempDir);
3783
3577
  if (files.length === 1) {
3784
- fs13.renameSync(path11.join(tempDir, files[0]), targetDir);
3578
+ fs11.renameSync(path9.join(tempDir, files[0]), targetDir);
3785
3579
  } else {
3786
3580
  throw new Error("Unexpected tgz structure");
3787
3581
  }
3788
3582
  }
3789
3583
  return targetDir;
3790
3584
  } finally {
3791
- if (fs13.existsSync(tempDir)) {
3792
- fs13.rmSync(tempDir, { recursive: true });
3585
+ if (fs11.existsSync(tempDir)) {
3586
+ fs11.rmSync(tempDir, { recursive: true });
3793
3587
  }
3794
3588
  }
3795
3589
  }
@@ -3798,10 +3592,10 @@ function checkMissingPeerDeps(peerDeps) {
3798
3592
  return [];
3799
3593
  }
3800
3594
  const missing = [];
3801
- const nodeModulesPath = path11.join(getProjectRoot(), "node_modules");
3595
+ const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
3802
3596
  for (const [depName, _version] of Object.entries(peerDeps)) {
3803
- const depPath = path11.join(nodeModulesPath, depName);
3804
- if (!fs13.existsSync(depPath)) {
3597
+ const depPath = path9.join(nodeModulesPath, depName);
3598
+ if (!fs11.existsSync(depPath)) {
3805
3599
  missing.push(depName);
3806
3600
  }
3807
3601
  }
@@ -3812,7 +3606,7 @@ function installMissingDeps(deps) {
3812
3606
  return;
3813
3607
  }
3814
3608
  console.log(`[action-plugin] Installing missing dependencies: ${deps.join(", ")}`);
3815
- const result = spawnSync6("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
3609
+ const result = spawnSync4("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
3816
3610
  cwd: getProjectRoot(),
3817
3611
  stdio: "inherit"
3818
3612
  });
@@ -3825,16 +3619,16 @@ function installMissingDeps(deps) {
3825
3619
  }
3826
3620
  function removePluginDirectory(pluginName) {
3827
3621
  const pluginPath = getPluginPath(pluginName);
3828
- if (fs13.existsSync(pluginPath)) {
3829
- fs13.rmSync(pluginPath, { recursive: true });
3622
+ if (fs11.existsSync(pluginPath)) {
3623
+ fs11.rmSync(pluginPath, { recursive: true });
3830
3624
  console.log(`[action-plugin] Removed ${pluginName}`);
3831
3625
  }
3832
3626
  }
3833
3627
 
3834
3628
  // src/commands/action-plugin/api-client.ts
3835
3629
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
3836
- import fs14 from "fs";
3837
- import path12 from "path";
3630
+ import fs12 from "fs";
3631
+ import path10 from "path";
3838
3632
  var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
3839
3633
  async function getPluginVersions(keys, latestOnly = true) {
3840
3634
  const client = getHttpClient();
@@ -3898,19 +3692,19 @@ async function downloadFromPublic(downloadURL) {
3898
3692
  return Buffer.from(arrayBuffer);
3899
3693
  }
3900
3694
  function getPluginCacheDir() {
3901
- return path12.join(process.cwd(), PLUGIN_CACHE_DIR);
3695
+ return path10.join(process.cwd(), PLUGIN_CACHE_DIR);
3902
3696
  }
3903
3697
  function ensureCacheDir() {
3904
3698
  const cacheDir = getPluginCacheDir();
3905
- if (!fs14.existsSync(cacheDir)) {
3906
- fs14.mkdirSync(cacheDir, { recursive: true });
3699
+ if (!fs12.existsSync(cacheDir)) {
3700
+ fs12.mkdirSync(cacheDir, { recursive: true });
3907
3701
  }
3908
3702
  }
3909
3703
  function getTempFilePath(pluginKey, version) {
3910
3704
  ensureCacheDir();
3911
3705
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3912
3706
  const filename = `${safeKey}@${version}.tgz`;
3913
- return path12.join(getPluginCacheDir(), filename);
3707
+ return path10.join(getPluginCacheDir(), filename);
3914
3708
  }
3915
3709
  var MAX_RETRIES = 2;
3916
3710
  async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
@@ -3947,7 +3741,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
3947
3741
  );
3948
3742
  }
3949
3743
  const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
3950
- fs14.writeFileSync(tgzPath, tgzBuffer);
3744
+ fs12.writeFileSync(tgzPath, tgzBuffer);
3951
3745
  console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
3952
3746
  return {
3953
3747
  tgzPath,
@@ -3961,18 +3755,18 @@ function getCachePath(pluginKey, version) {
3961
3755
  ensureCacheDir();
3962
3756
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3963
3757
  const filename = `${safeKey}@${version}.tgz`;
3964
- return path12.join(getPluginCacheDir(), filename);
3758
+ return path10.join(getPluginCacheDir(), filename);
3965
3759
  }
3966
3760
  function hasCachedPlugin(pluginKey, version) {
3967
3761
  const cachePath = getCachePath(pluginKey, version);
3968
- return fs14.existsSync(cachePath);
3762
+ return fs12.existsSync(cachePath);
3969
3763
  }
3970
3764
  function listCachedPlugins() {
3971
3765
  const cacheDir = getPluginCacheDir();
3972
- if (!fs14.existsSync(cacheDir)) {
3766
+ if (!fs12.existsSync(cacheDir)) {
3973
3767
  return [];
3974
3768
  }
3975
- const files = fs14.readdirSync(cacheDir);
3769
+ const files = fs12.readdirSync(cacheDir);
3976
3770
  const result = [];
3977
3771
  for (const file of files) {
3978
3772
  if (!file.endsWith(".tgz")) continue;
@@ -3980,8 +3774,8 @@ function listCachedPlugins() {
3980
3774
  if (!match) continue;
3981
3775
  const [, rawName, version] = match;
3982
3776
  const name = rawName.replace(/^_/, "@").replace(/_/, "/");
3983
- const filePath = path12.join(cacheDir, file);
3984
- const stat = fs14.statSync(filePath);
3777
+ const filePath = path10.join(cacheDir, file);
3778
+ const stat = fs12.statSync(filePath);
3985
3779
  result.push({
3986
3780
  name,
3987
3781
  version,
@@ -3994,14 +3788,14 @@ function listCachedPlugins() {
3994
3788
  }
3995
3789
  function cleanAllCache() {
3996
3790
  const cacheDir = getPluginCacheDir();
3997
- if (!fs14.existsSync(cacheDir)) {
3791
+ if (!fs12.existsSync(cacheDir)) {
3998
3792
  return 0;
3999
3793
  }
4000
- const files = fs14.readdirSync(cacheDir);
3794
+ const files = fs12.readdirSync(cacheDir);
4001
3795
  let count = 0;
4002
3796
  for (const file of files) {
4003
3797
  if (file.endsWith(".tgz")) {
4004
- fs14.unlinkSync(path12.join(cacheDir, file));
3798
+ fs12.unlinkSync(path10.join(cacheDir, file));
4005
3799
  count++;
4006
3800
  }
4007
3801
  }
@@ -4009,21 +3803,21 @@ function cleanAllCache() {
4009
3803
  }
4010
3804
  function cleanPluginCache(pluginKey, version) {
4011
3805
  const cacheDir = getPluginCacheDir();
4012
- if (!fs14.existsSync(cacheDir)) {
3806
+ if (!fs12.existsSync(cacheDir)) {
4013
3807
  return 0;
4014
3808
  }
4015
3809
  const safeKey = pluginKey.replace(/[/@]/g, "_");
4016
- const files = fs14.readdirSync(cacheDir);
3810
+ const files = fs12.readdirSync(cacheDir);
4017
3811
  let count = 0;
4018
3812
  for (const file of files) {
4019
3813
  if (version) {
4020
3814
  if (file === `${safeKey}@${version}.tgz`) {
4021
- fs14.unlinkSync(path12.join(cacheDir, file));
3815
+ fs12.unlinkSync(path10.join(cacheDir, file));
4022
3816
  count++;
4023
3817
  }
4024
3818
  } else {
4025
3819
  if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
4026
- fs14.unlinkSync(path12.join(cacheDir, file));
3820
+ fs12.unlinkSync(path10.join(cacheDir, file));
4027
3821
  count++;
4028
3822
  }
4029
3823
  }
@@ -4450,40 +4244,40 @@ var actionPluginCommandGroup = {
4450
4244
  };
4451
4245
 
4452
4246
  // src/commands/capability/utils.ts
4453
- import fs15 from "fs";
4247
+ import fs13 from "fs";
4454
4248
  import { createRequire as createRequire2 } from "module";
4455
- import path13 from "path";
4249
+ import path11 from "path";
4456
4250
  var CAPABILITIES_DIR = "server/capabilities";
4457
4251
  function getProjectRoot2() {
4458
4252
  return process.cwd();
4459
4253
  }
4460
4254
  function getCapabilitiesDir() {
4461
- return path13.join(getProjectRoot2(), CAPABILITIES_DIR);
4255
+ return path11.join(getProjectRoot2(), CAPABILITIES_DIR);
4462
4256
  }
4463
4257
  function getCapabilityPath(id) {
4464
- return path13.join(getCapabilitiesDir(), `${id}.json`);
4258
+ return path11.join(getCapabilitiesDir(), `${id}.json`);
4465
4259
  }
4466
4260
  function getPluginManifestPath(pluginKey) {
4467
- return path13.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4261
+ return path11.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4468
4262
  }
4469
4263
  function capabilitiesDirExists() {
4470
- return fs15.existsSync(getCapabilitiesDir());
4264
+ return fs13.existsSync(getCapabilitiesDir());
4471
4265
  }
4472
4266
  function listCapabilityIds() {
4473
4267
  const dir = getCapabilitiesDir();
4474
- if (!fs15.existsSync(dir)) {
4268
+ if (!fs13.existsSync(dir)) {
4475
4269
  return [];
4476
4270
  }
4477
- const files = fs15.readdirSync(dir);
4271
+ const files = fs13.readdirSync(dir);
4478
4272
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
4479
4273
  }
4480
4274
  function readCapability(id) {
4481
4275
  const filePath = getCapabilityPath(id);
4482
- if (!fs15.existsSync(filePath)) {
4276
+ if (!fs13.existsSync(filePath)) {
4483
4277
  throw new Error(`Capability not found: ${id}`);
4484
4278
  }
4485
4279
  try {
4486
- const content = fs15.readFileSync(filePath, "utf-8");
4280
+ const content = fs13.readFileSync(filePath, "utf-8");
4487
4281
  return JSON.parse(content);
4488
4282
  } catch (error) {
4489
4283
  if (error instanceof SyntaxError) {
@@ -4510,11 +4304,11 @@ function readAllCapabilities() {
4510
4304
  }
4511
4305
  function readPluginManifest(pluginKey) {
4512
4306
  const manifestPath = getPluginManifestPath(pluginKey);
4513
- if (!fs15.existsSync(manifestPath)) {
4307
+ if (!fs13.existsSync(manifestPath)) {
4514
4308
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
4515
4309
  }
4516
4310
  try {
4517
- const content = fs15.readFileSync(manifestPath, "utf-8");
4311
+ const content = fs13.readFileSync(manifestPath, "utf-8");
4518
4312
  return JSON.parse(content);
4519
4313
  } catch (error) {
4520
4314
  if (error instanceof SyntaxError) {
@@ -4531,7 +4325,7 @@ function hasValidParamsSchema(paramsSchema) {
4531
4325
  }
4532
4326
  async function loadPlugin(pluginKey) {
4533
4327
  try {
4534
- const userRequire = createRequire2(path13.join(getProjectRoot2(), "package.json"));
4328
+ const userRequire = createRequire2(path11.join(getProjectRoot2(), "package.json"));
4535
4329
  const resolvedPath = userRequire.resolve(pluginKey);
4536
4330
  const pluginModule = await import(resolvedPath);
4537
4331
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -4694,8 +4488,8 @@ var capabilityCommandGroup = {
4694
4488
  import { execFile } from "child_process";
4695
4489
 
4696
4490
  // src/commands/component/registry-preparer.ts
4697
- import fs16 from "fs";
4698
- import path14 from "path";
4491
+ import fs14 from "fs";
4492
+ import path12 from "path";
4699
4493
  import os from "os";
4700
4494
 
4701
4495
  // src/commands/component/service.ts
@@ -4751,7 +4545,7 @@ async function sendInstallEvent(key) {
4751
4545
  }
4752
4546
 
4753
4547
  // src/commands/component/registry-preparer.ts
4754
- var REGISTRY_TEMP_DIR = path14.join(os.tmpdir(), "miaoda-registry");
4548
+ var REGISTRY_TEMP_DIR = path12.join(os.tmpdir(), "miaoda-registry");
4755
4549
  function parseComponentKey(key) {
4756
4550
  const match = key.match(/^@([^/]+)\/(.+)$/);
4757
4551
  if (!match) {
@@ -4763,11 +4557,11 @@ function parseComponentKey(key) {
4763
4557
  }
4764
4558
  function getLocalRegistryPath(key) {
4765
4559
  const { scope, name } = parseComponentKey(key);
4766
- return path14.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4560
+ return path12.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4767
4561
  }
4768
4562
  function ensureDir(dirPath) {
4769
- if (!fs16.existsSync(dirPath)) {
4770
- fs16.mkdirSync(dirPath, { recursive: true });
4563
+ if (!fs14.existsSync(dirPath)) {
4564
+ fs14.mkdirSync(dirPath, { recursive: true });
4771
4565
  }
4772
4566
  }
4773
4567
  async function prepareRecursive(key, visited) {
@@ -4800,8 +4594,8 @@ async function prepareRecursive(key, visited) {
4800
4594
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
4801
4595
  };
4802
4596
  const localPath = getLocalRegistryPath(key);
4803
- ensureDir(path14.dirname(localPath));
4804
- 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");
4805
4599
  debug("\u4FDD\u5B58\u5230: %s", localPath);
4806
4600
  }
4807
4601
  async function prepareComponentRegistryItems(id) {
@@ -4811,18 +4605,18 @@ async function prepareComponentRegistryItems(id) {
4811
4605
  }
4812
4606
  function cleanupTempDir() {
4813
4607
  try {
4814
- if (fs16.existsSync(REGISTRY_TEMP_DIR)) {
4815
- 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 });
4816
4610
  }
4817
4611
  } catch {
4818
4612
  }
4819
4613
  }
4820
4614
  function getDownloadedRegistryItem(itemId) {
4821
4615
  const localPath = getLocalRegistryPath(itemId);
4822
- if (!fs16.existsSync(localPath)) {
4616
+ if (!fs14.existsSync(localPath)) {
4823
4617
  return null;
4824
4618
  }
4825
- const content = fs16.readFileSync(localPath, "utf-8");
4619
+ const content = fs14.readFileSync(localPath, "utf-8");
4826
4620
  return JSON.parse(content);
4827
4621
  }
4828
4622
 
@@ -4990,58 +4784,58 @@ var componentCommandGroup = {
4990
4784
  };
4991
4785
 
4992
4786
  // src/commands/migration/version-manager.ts
4993
- import fs17 from "fs";
4994
- import path15 from "path";
4787
+ import fs15 from "fs";
4788
+ import path13 from "path";
4995
4789
  var PACKAGE_JSON = "package.json";
4996
4790
  var VERSION_FIELD = "migrationVersion";
4997
4791
  function getPackageJsonPath2() {
4998
- return path15.join(process.cwd(), PACKAGE_JSON);
4792
+ return path13.join(process.cwd(), PACKAGE_JSON);
4999
4793
  }
5000
4794
  function getCurrentVersion() {
5001
4795
  const pkgPath = getPackageJsonPath2();
5002
- if (!fs17.existsSync(pkgPath)) {
4796
+ if (!fs15.existsSync(pkgPath)) {
5003
4797
  throw new Error("package.json not found");
5004
4798
  }
5005
- const pkg2 = JSON.parse(fs17.readFileSync(pkgPath, "utf-8"));
4799
+ const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
5006
4800
  return pkg2[VERSION_FIELD] ?? 0;
5007
4801
  }
5008
4802
  function setCurrentVersion(version) {
5009
4803
  const pkgPath = getPackageJsonPath2();
5010
- const pkg2 = JSON.parse(fs17.readFileSync(pkgPath, "utf-8"));
4804
+ const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
5011
4805
  pkg2[VERSION_FIELD] = version;
5012
- fs17.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4806
+ fs15.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
5013
4807
  }
5014
4808
 
5015
4809
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
5016
- import fs19 from "fs";
5017
- import path17 from "path";
4810
+ import fs17 from "fs";
4811
+ import path15 from "path";
5018
4812
 
5019
4813
  // src/commands/migration/versions/v001_capability/utils.ts
5020
- import fs18 from "fs";
5021
- import path16 from "path";
4814
+ import fs16 from "fs";
4815
+ import path14 from "path";
5022
4816
  var CAPABILITIES_DIR2 = "server/capabilities";
5023
4817
  function getProjectRoot3() {
5024
4818
  return process.cwd();
5025
4819
  }
5026
4820
  function getCapabilitiesDir2() {
5027
- return path16.join(getProjectRoot3(), CAPABILITIES_DIR2);
4821
+ return path14.join(getProjectRoot3(), CAPABILITIES_DIR2);
5028
4822
  }
5029
4823
  function getPluginManifestPath2(pluginKey) {
5030
- return path16.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4824
+ return path14.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
5031
4825
  }
5032
4826
 
5033
4827
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
5034
4828
  function detectJsonMigration() {
5035
4829
  const capabilitiesDir = getCapabilitiesDir2();
5036
- const oldFilePath = path17.join(capabilitiesDir, "capabilities.json");
5037
- if (!fs19.existsSync(oldFilePath)) {
4830
+ const oldFilePath = path15.join(capabilitiesDir, "capabilities.json");
4831
+ if (!fs17.existsSync(oldFilePath)) {
5038
4832
  return {
5039
4833
  needsMigration: false,
5040
4834
  reason: "capabilities.json not found"
5041
4835
  };
5042
4836
  }
5043
4837
  try {
5044
- const content = fs19.readFileSync(oldFilePath, "utf-8");
4838
+ const content = fs17.readFileSync(oldFilePath, "utf-8");
5045
4839
  const parsed = JSON.parse(content);
5046
4840
  if (!Array.isArray(parsed)) {
5047
4841
  return {
@@ -5092,8 +4886,8 @@ async function check(options) {
5092
4886
  }
5093
4887
 
5094
4888
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5095
- import fs20 from "fs";
5096
- import path18 from "path";
4889
+ import fs18 from "fs";
4890
+ import path16 from "path";
5097
4891
 
5098
4892
  // src/commands/migration/versions/v001_capability/mapping.ts
5099
4893
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -5323,18 +5117,18 @@ function transformCapabilities(oldCapabilities) {
5323
5117
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5324
5118
  function loadExistingCapabilities() {
5325
5119
  const capabilitiesDir = getCapabilitiesDir2();
5326
- if (!fs20.existsSync(capabilitiesDir)) {
5120
+ if (!fs18.existsSync(capabilitiesDir)) {
5327
5121
  return [];
5328
5122
  }
5329
- const files = fs20.readdirSync(capabilitiesDir);
5123
+ const files = fs18.readdirSync(capabilitiesDir);
5330
5124
  const capabilities = [];
5331
5125
  for (const file of files) {
5332
5126
  if (file === "capabilities.json" || !file.endsWith(".json")) {
5333
5127
  continue;
5334
5128
  }
5335
5129
  try {
5336
- const filePath = path18.join(capabilitiesDir, file);
5337
- const content = fs20.readFileSync(filePath, "utf-8");
5130
+ const filePath = path16.join(capabilitiesDir, file);
5131
+ const content = fs18.readFileSync(filePath, "utf-8");
5338
5132
  const capability = JSON.parse(content);
5339
5133
  if (capability.id && capability.pluginKey) {
5340
5134
  capabilities.push(capability);
@@ -5392,9 +5186,9 @@ async function migrateJsonFiles(options) {
5392
5186
  }
5393
5187
  const capabilitiesDir = getCapabilitiesDir2();
5394
5188
  for (const cap of newCapabilities) {
5395
- const filePath = path18.join(capabilitiesDir, `${cap.id}.json`);
5189
+ const filePath = path16.join(capabilitiesDir, `${cap.id}.json`);
5396
5190
  const content = JSON.stringify(cap, null, 2);
5397
- fs20.writeFileSync(filePath, content, "utf-8");
5191
+ fs18.writeFileSync(filePath, content, "utf-8");
5398
5192
  console.log(` \u2713 Created: ${cap.id}.json`);
5399
5193
  }
5400
5194
  return {
@@ -5406,11 +5200,11 @@ async function migrateJsonFiles(options) {
5406
5200
  }
5407
5201
 
5408
5202
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
5409
- import fs21 from "fs";
5203
+ import fs19 from "fs";
5410
5204
  function isPluginInstalled2(pluginKey) {
5411
5205
  const actionPlugins = readActionPlugins();
5412
5206
  const manifestPath = getPluginManifestPath2(pluginKey);
5413
- return fs21.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5207
+ return fs19.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5414
5208
  }
5415
5209
  function detectPluginsToInstall(capabilities) {
5416
5210
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -5486,12 +5280,12 @@ async function installPlugins(capabilities, options) {
5486
5280
  }
5487
5281
 
5488
5282
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
5489
- import path20 from "path";
5283
+ import path18 from "path";
5490
5284
  import { Project as Project3 } from "ts-morph";
5491
5285
 
5492
5286
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
5493
- import fs22 from "fs";
5494
- import path19 from "path";
5287
+ import fs20 from "fs";
5288
+ import path17 from "path";
5495
5289
  var EXCLUDED_DIRS = [
5496
5290
  "node_modules",
5497
5291
  "dist",
@@ -5506,9 +5300,9 @@ var EXCLUDED_PATTERNS = [
5506
5300
  /\.d\.ts$/
5507
5301
  ];
5508
5302
  function scanDirectory(dir, files = []) {
5509
- const entries = fs22.readdirSync(dir, { withFileTypes: true });
5303
+ const entries = fs20.readdirSync(dir, { withFileTypes: true });
5510
5304
  for (const entry of entries) {
5511
- const fullPath = path19.join(dir, entry.name);
5305
+ const fullPath = path17.join(dir, entry.name);
5512
5306
  if (entry.isDirectory()) {
5513
5307
  if (EXCLUDED_DIRS.includes(entry.name)) {
5514
5308
  continue;
@@ -5524,14 +5318,14 @@ function scanDirectory(dir, files = []) {
5524
5318
  return files;
5525
5319
  }
5526
5320
  function scanServerFiles() {
5527
- const serverDir = path19.join(getProjectRoot3(), "server");
5528
- if (!fs22.existsSync(serverDir)) {
5321
+ const serverDir = path17.join(getProjectRoot3(), "server");
5322
+ if (!fs20.existsSync(serverDir)) {
5529
5323
  return [];
5530
5324
  }
5531
5325
  return scanDirectory(serverDir);
5532
5326
  }
5533
5327
  function hasCapabilityImport(filePath) {
5534
- const content = fs22.readFileSync(filePath, "utf-8");
5328
+ const content = fs20.readFileSync(filePath, "utf-8");
5535
5329
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
5536
5330
  }
5537
5331
  function scanFilesToMigrate() {
@@ -5908,7 +5702,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5908
5702
  const callSites = analyzeCallSites(sourceFile, imports);
5909
5703
  const classInfo = analyzeClass(sourceFile);
5910
5704
  const { canMigrate, reason } = canAutoMigrate(classInfo);
5911
- const relativePath = path20.relative(getProjectRoot3(), filePath);
5705
+ const relativePath = path18.relative(getProjectRoot3(), filePath);
5912
5706
  return {
5913
5707
  filePath: relativePath,
5914
5708
  imports,
@@ -5919,7 +5713,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5919
5713
  };
5920
5714
  }
5921
5715
  function migrateFile(project, analysis, dryRun) {
5922
- const absolutePath = path20.join(getProjectRoot3(), analysis.filePath);
5716
+ const absolutePath = path18.join(getProjectRoot3(), analysis.filePath);
5923
5717
  if (!analysis.canAutoMigrate) {
5924
5718
  return {
5925
5719
  filePath: analysis.filePath,
@@ -6022,17 +5816,17 @@ function getSuggestion(analysis) {
6022
5816
  }
6023
5817
 
6024
5818
  // src/commands/migration/versions/v001_capability/cleanup.ts
6025
- import fs23 from "fs";
6026
- import path21 from "path";
5819
+ import fs21 from "fs";
5820
+ import path19 from "path";
6027
5821
  function cleanupOldFiles(capabilities, dryRun) {
6028
5822
  const deletedFiles = [];
6029
5823
  const errors = [];
6030
5824
  const capabilitiesDir = getCapabilitiesDir2();
6031
- const oldJsonPath = path21.join(capabilitiesDir, "capabilities.json");
6032
- if (fs23.existsSync(oldJsonPath)) {
5825
+ const oldJsonPath = path19.join(capabilitiesDir, "capabilities.json");
5826
+ if (fs21.existsSync(oldJsonPath)) {
6033
5827
  try {
6034
5828
  if (!dryRun) {
6035
- fs23.unlinkSync(oldJsonPath);
5829
+ fs21.unlinkSync(oldJsonPath);
6036
5830
  }
6037
5831
  deletedFiles.push("capabilities.json");
6038
5832
  } catch (error) {
@@ -6040,11 +5834,11 @@ function cleanupOldFiles(capabilities, dryRun) {
6040
5834
  }
6041
5835
  }
6042
5836
  for (const cap of capabilities) {
6043
- const tsFilePath = path21.join(capabilitiesDir, `${cap.id}.ts`);
6044
- if (fs23.existsSync(tsFilePath)) {
5837
+ const tsFilePath = path19.join(capabilitiesDir, `${cap.id}.ts`);
5838
+ if (fs21.existsSync(tsFilePath)) {
6045
5839
  try {
6046
5840
  if (!dryRun) {
6047
- fs23.unlinkSync(tsFilePath);
5841
+ fs21.unlinkSync(tsFilePath);
6048
5842
  }
6049
5843
  deletedFiles.push(`${cap.id}.ts`);
6050
5844
  } catch (error) {
@@ -6060,8 +5854,8 @@ function cleanupOldFiles(capabilities, dryRun) {
6060
5854
  }
6061
5855
 
6062
5856
  // src/commands/migration/versions/v001_capability/report-generator.ts
6063
- import fs24 from "fs";
6064
- import path22 from "path";
5857
+ import fs22 from "fs";
5858
+ import path20 from "path";
6065
5859
  var REPORT_FILE = "capability-migration-report.md";
6066
5860
  function printSummary(result) {
6067
5861
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -6224,15 +6018,15 @@ async function generateReport(result) {
6224
6018
  }
6225
6019
  lines.push("");
6226
6020
  const logDir = process.env.LOG_DIR || "logs";
6227
- if (!fs24.existsSync(logDir)) {
6021
+ if (!fs22.existsSync(logDir)) {
6228
6022
  return;
6229
6023
  }
6230
- const reportDir = path22.join(logDir, "migration");
6231
- if (!fs24.existsSync(reportDir)) {
6232
- fs24.mkdirSync(reportDir, { recursive: true });
6024
+ const reportDir = path20.join(logDir, "migration");
6025
+ if (!fs22.existsSync(reportDir)) {
6026
+ fs22.mkdirSync(reportDir, { recursive: true });
6233
6027
  }
6234
- const reportPath = path22.join(reportDir, REPORT_FILE);
6235
- 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");
6236
6030
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
6237
6031
  }
6238
6032
 
@@ -6409,7 +6203,7 @@ function buildResult(jsonMigration, pluginInstallation, codeMigration, cleanup)
6409
6203
  }
6410
6204
 
6411
6205
  // src/commands/migration/versions/v001_capability/run.ts
6412
- async function run6(options) {
6206
+ async function run5(options) {
6413
6207
  try {
6414
6208
  const migrationOptions = {
6415
6209
  dryRun: options.dryRun ?? false
@@ -6474,7 +6268,7 @@ var v001CapabilityMigration = {
6474
6268
  name: "capability",
6475
6269
  description: "Migrate capability configurations from old format (capabilities.json array) to new format (individual JSON files)",
6476
6270
  check,
6477
- run: run6
6271
+ run: run5
6478
6272
  };
6479
6273
 
6480
6274
  // src/commands/migration/versions/index.ts
@@ -6764,10 +6558,10 @@ var migrationCommand = {
6764
6558
  };
6765
6559
 
6766
6560
  // src/commands/read-logs/index.ts
6767
- import path23 from "path";
6561
+ import path21 from "path";
6768
6562
 
6769
6563
  // src/commands/read-logs/std-utils.ts
6770
- import fs25 from "fs";
6564
+ import fs23 from "fs";
6771
6565
  function formatStdPrefixTime(localTime) {
6772
6566
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
6773
6567
  if (!match) return localTime;
@@ -6797,11 +6591,11 @@ function stripPrefixFromStdLine(line) {
6797
6591
  return `[${time}] ${content}`;
6798
6592
  }
6799
6593
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
6800
- const stat = fs25.statSync(filePath);
6594
+ const stat = fs23.statSync(filePath);
6801
6595
  if (stat.size === 0) {
6802
6596
  return { lines: [], markerFound: false, totalLinesCount: 0 };
6803
6597
  }
6804
- const fd = fs25.openSync(filePath, "r");
6598
+ const fd = fs23.openSync(filePath, "r");
6805
6599
  const chunkSize = 64 * 1024;
6806
6600
  let position = stat.size;
6807
6601
  let remainder = "";
@@ -6815,7 +6609,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6815
6609
  const length = Math.min(chunkSize, position);
6816
6610
  position -= length;
6817
6611
  const buffer = Buffer.alloc(length);
6818
- fs25.readSync(fd, buffer, 0, length, position);
6612
+ fs23.readSync(fd, buffer, 0, length, position);
6819
6613
  let chunk = buffer.toString("utf8");
6820
6614
  if (remainder) {
6821
6615
  chunk += remainder;
@@ -6857,7 +6651,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6857
6651
  }
6858
6652
  }
6859
6653
  } finally {
6860
- fs25.closeSync(fd);
6654
+ fs23.closeSync(fd);
6861
6655
  }
6862
6656
  return { lines: collected.reverse(), markerFound, totalLinesCount };
6863
6657
  }
@@ -6878,21 +6672,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
6878
6672
  }
6879
6673
 
6880
6674
  // src/commands/read-logs/tail.ts
6881
- import fs26 from "fs";
6675
+ import fs24 from "fs";
6882
6676
  function fileExists(filePath) {
6883
6677
  try {
6884
- fs26.accessSync(filePath, fs26.constants.F_OK | fs26.constants.R_OK);
6678
+ fs24.accessSync(filePath, fs24.constants.F_OK | fs24.constants.R_OK);
6885
6679
  return true;
6886
6680
  } catch {
6887
6681
  return false;
6888
6682
  }
6889
6683
  }
6890
6684
  function readFileTailLines(filePath, maxLines) {
6891
- const stat = fs26.statSync(filePath);
6685
+ const stat = fs24.statSync(filePath);
6892
6686
  if (stat.size === 0) {
6893
6687
  return [];
6894
6688
  }
6895
- const fd = fs26.openSync(filePath, "r");
6689
+ const fd = fs24.openSync(filePath, "r");
6896
6690
  const chunkSize = 64 * 1024;
6897
6691
  const chunks = [];
6898
6692
  let position = stat.size;
@@ -6902,13 +6696,13 @@ function readFileTailLines(filePath, maxLines) {
6902
6696
  const length = Math.min(chunkSize, position);
6903
6697
  position -= length;
6904
6698
  const buffer = Buffer.alloc(length);
6905
- fs26.readSync(fd, buffer, 0, length, position);
6699
+ fs24.readSync(fd, buffer, 0, length, position);
6906
6700
  chunks.unshift(buffer.toString("utf8"));
6907
6701
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
6908
6702
  collectedLines += chunkLines;
6909
6703
  }
6910
6704
  } finally {
6911
- fs26.closeSync(fd);
6705
+ fs24.closeSync(fd);
6912
6706
  }
6913
6707
  const content = chunks.join("");
6914
6708
  const allLines = content.split("\n");
@@ -6924,11 +6718,11 @@ function readFileTailLines(filePath, maxLines) {
6924
6718
  return allLines.slice(allLines.length - maxLines);
6925
6719
  }
6926
6720
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6927
- const stat = fs26.statSync(filePath);
6721
+ const stat = fs24.statSync(filePath);
6928
6722
  if (stat.size === 0) {
6929
6723
  return { lines: [], totalLinesCount: 0 };
6930
6724
  }
6931
- const fd = fs26.openSync(filePath, "r");
6725
+ const fd = fs24.openSync(filePath, "r");
6932
6726
  const chunkSize = 64 * 1024;
6933
6727
  let position = stat.size;
6934
6728
  let remainder = "";
@@ -6940,7 +6734,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6940
6734
  const length = Math.min(chunkSize, position);
6941
6735
  position -= length;
6942
6736
  const buffer = Buffer.alloc(length);
6943
- fs26.readSync(fd, buffer, 0, length, position);
6737
+ fs24.readSync(fd, buffer, 0, length, position);
6944
6738
  let chunk = buffer.toString("utf8");
6945
6739
  if (remainder) {
6946
6740
  chunk += remainder;
@@ -6971,7 +6765,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6971
6765
  }
6972
6766
  }
6973
6767
  } finally {
6974
- fs26.closeSync(fd);
6768
+ fs24.closeSync(fd);
6975
6769
  }
6976
6770
  return { lines: collected.reverse(), totalLinesCount };
6977
6771
  }
@@ -7113,7 +6907,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
7113
6907
  }
7114
6908
 
7115
6909
  // src/commands/read-logs/json-lines.ts
7116
- import fs27 from "fs";
6910
+ import fs25 from "fs";
7117
6911
  function normalizePid(value) {
7118
6912
  if (typeof value === "number") {
7119
6913
  return String(value);
@@ -7164,11 +6958,11 @@ function buildWantedLevelSet(levels) {
7164
6958
  return set.size > 0 ? set : null;
7165
6959
  }
7166
6960
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7167
- const stat = fs27.statSync(filePath);
6961
+ const stat = fs25.statSync(filePath);
7168
6962
  if (stat.size === 0) {
7169
6963
  return { lines: [], totalLinesCount: 0 };
7170
6964
  }
7171
- const fd = fs27.openSync(filePath, "r");
6965
+ const fd = fs25.openSync(filePath, "r");
7172
6966
  const chunkSize = 64 * 1024;
7173
6967
  let position = stat.size;
7174
6968
  let remainder = "";
@@ -7183,7 +6977,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7183
6977
  const length = Math.min(chunkSize, position);
7184
6978
  position -= length;
7185
6979
  const buffer = Buffer.alloc(length);
7186
- fs27.readSync(fd, buffer, 0, length, position);
6980
+ fs25.readSync(fd, buffer, 0, length, position);
7187
6981
  let chunk = buffer.toString("utf8");
7188
6982
  if (remainder) {
7189
6983
  chunk += remainder;
@@ -7245,7 +7039,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7245
7039
  }
7246
7040
  }
7247
7041
  } finally {
7248
- fs27.closeSync(fd);
7042
+ fs25.closeSync(fd);
7249
7043
  }
7250
7044
  return { lines: collected.reverse(), totalLinesCount };
7251
7045
  }
@@ -7288,11 +7082,11 @@ function extractTraceId(obj) {
7288
7082
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7289
7083
  const wanted = traceId.trim();
7290
7084
  if (!wanted) return { lines: [], totalLinesCount: 0 };
7291
- const stat = fs27.statSync(filePath);
7085
+ const stat = fs25.statSync(filePath);
7292
7086
  if (stat.size === 0) {
7293
7087
  return { lines: [], totalLinesCount: 0 };
7294
7088
  }
7295
- const fd = fs27.openSync(filePath, "r");
7089
+ const fd = fs25.openSync(filePath, "r");
7296
7090
  const chunkSize = 64 * 1024;
7297
7091
  let position = stat.size;
7298
7092
  let remainder = "";
@@ -7305,7 +7099,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7305
7099
  const length = Math.min(chunkSize, position);
7306
7100
  position -= length;
7307
7101
  const buffer = Buffer.alloc(length);
7308
- fs27.readSync(fd, buffer, 0, length, position);
7102
+ fs25.readSync(fd, buffer, 0, length, position);
7309
7103
  let chunk = buffer.toString("utf8");
7310
7104
  if (remainder) {
7311
7105
  chunk += remainder;
@@ -7358,7 +7152,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7358
7152
  }
7359
7153
  }
7360
7154
  } finally {
7361
- fs27.closeSync(fd);
7155
+ fs25.closeSync(fd);
7362
7156
  }
7363
7157
  return { lines: collected.reverse(), totalLinesCount };
7364
7158
  }
@@ -7367,11 +7161,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7367
7161
  if (!wantedLevelSet) {
7368
7162
  return { lines: [], totalLinesCount: 0 };
7369
7163
  }
7370
- const stat = fs27.statSync(filePath);
7164
+ const stat = fs25.statSync(filePath);
7371
7165
  if (stat.size === 0) {
7372
7166
  return { lines: [], totalLinesCount: 0 };
7373
7167
  }
7374
- const fd = fs27.openSync(filePath, "r");
7168
+ const fd = fs25.openSync(filePath, "r");
7375
7169
  const chunkSize = 64 * 1024;
7376
7170
  let position = stat.size;
7377
7171
  let remainder = "";
@@ -7383,7 +7177,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7383
7177
  const length = Math.min(chunkSize, position);
7384
7178
  position -= length;
7385
7179
  const buffer = Buffer.alloc(length);
7386
- fs27.readSync(fd, buffer, 0, length, position);
7180
+ fs25.readSync(fd, buffer, 0, length, position);
7387
7181
  let chunk = buffer.toString("utf8");
7388
7182
  if (remainder) {
7389
7183
  chunk += remainder;
@@ -7430,7 +7224,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7430
7224
  }
7431
7225
  }
7432
7226
  } finally {
7433
- fs27.closeSync(fd);
7227
+ fs25.closeSync(fd);
7434
7228
  }
7435
7229
  return { lines: collected.reverse(), totalLinesCount };
7436
7230
  }
@@ -7664,34 +7458,34 @@ async function readLogsJsonResult(options) {
7664
7458
  };
7665
7459
  }
7666
7460
  function resolveLogFilePath(logDir, type) {
7667
- const base = path23.isAbsolute(logDir) ? logDir : path23.join(process.cwd(), logDir);
7461
+ const base = path21.isAbsolute(logDir) ? logDir : path21.join(process.cwd(), logDir);
7668
7462
  if (type === "server") {
7669
- return path23.join(base, "server.log");
7463
+ return path21.join(base, "server.log");
7670
7464
  }
7671
7465
  if (type === "trace") {
7672
- return path23.join(base, "trace.log");
7466
+ return path21.join(base, "trace.log");
7673
7467
  }
7674
7468
  if (type === "server-std") {
7675
- return path23.join(base, "server.std.log");
7469
+ return path21.join(base, "server.std.log");
7676
7470
  }
7677
7471
  if (type === "client-std") {
7678
- return path23.join(base, "client.std.log");
7472
+ return path21.join(base, "client.std.log");
7679
7473
  }
7680
7474
  if (type === "dev") {
7681
- return path23.join(base, "dev.log");
7475
+ return path21.join(base, "dev.log");
7682
7476
  }
7683
7477
  if (type === "dev-std") {
7684
- return path23.join(base, "dev.std.log");
7478
+ return path21.join(base, "dev.std.log");
7685
7479
  }
7686
7480
  if (type === "install-dep-std") {
7687
- return path23.join(base, "install-dep.std.log");
7481
+ return path21.join(base, "install-dep.std.log");
7688
7482
  }
7689
7483
  if (type === "browser") {
7690
- return path23.join(base, "browser.log");
7484
+ return path21.join(base, "browser.log");
7691
7485
  }
7692
7486
  throw new Error(`Unsupported log type: ${type}`);
7693
7487
  }
7694
- async function run7(options) {
7488
+ async function run6(options) {
7695
7489
  const result = await readLogsJsonResult(options);
7696
7490
  process.stdout.write(JSON.stringify(result) + "\n");
7697
7491
  }
@@ -7733,7 +7527,7 @@ var readLogsCommand = {
7733
7527
  const offset = parseNonNegativeInt(rawOptions.offset, "--offset");
7734
7528
  const traceId = typeof rawOptions.traceId === "string" ? rawOptions.traceId : void 0;
7735
7529
  const levels = parseCommaSeparatedList(rawOptions.level);
7736
- await run7({ logDir, type, maxLines, offset, traceId, levels });
7530
+ await run6({ logDir, type, maxLines, offset, traceId, levels });
7737
7531
  } catch (error) {
7738
7532
  const message = error instanceof Error ? error.message : String(error);
7739
7533
  process.stderr.write(message + "\n");
@@ -7864,9 +7658,9 @@ function camelToKebab(str) {
7864
7658
  }
7865
7659
 
7866
7660
  // src/commands/build/upload-static.handler.ts
7867
- import * as fs28 from "fs";
7661
+ import * as fs26 from "fs";
7868
7662
  import * as os2 from "os";
7869
- import * as path24 from "path";
7663
+ import * as path22 from "path";
7870
7664
  import { execFileSync } from "child_process";
7871
7665
  function readCredentialsFromEnv() {
7872
7666
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -7890,8 +7684,8 @@ async function uploadStatic(options) {
7890
7684
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7891
7685
  region = UPLOAD_STATIC_DEFAULTS.region
7892
7686
  } = options;
7893
- const resolvedStaticDir = path24.resolve(staticDir);
7894
- if (!fs28.existsSync(resolvedStaticDir)) {
7687
+ const resolvedStaticDir = path22.resolve(staticDir);
7688
+ if (!fs26.existsSync(resolvedStaticDir)) {
7895
7689
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7896
7690
  return;
7897
7691
  }
@@ -7924,8 +7718,8 @@ async function uploadStatic(options) {
7924
7718
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7925
7719
  }
7926
7720
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7927
- const confPath = path24.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7928
- fs28.writeFileSync(confPath, "");
7721
+ const confPath = path22.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7722
+ fs26.writeFileSync(confPath, "");
7929
7723
  try {
7930
7724
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7931
7725
  configureTosutil(resolvedTosutil, confPath, {
@@ -7939,7 +7733,7 @@ async function uploadStatic(options) {
7939
7733
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7940
7734
  } finally {
7941
7735
  try {
7942
- fs28.unlinkSync(confPath);
7736
+ fs26.unlinkSync(confPath);
7943
7737
  } catch {
7944
7738
  }
7945
7739
  }
@@ -7959,8 +7753,8 @@ async function uploadStatic(options) {
7959
7753
  }
7960
7754
  }
7961
7755
  function resolveTosutilPath(tosutilPath) {
7962
- if (path24.isAbsolute(tosutilPath)) {
7963
- return fs28.existsSync(tosutilPath) ? tosutilPath : null;
7756
+ if (path22.isAbsolute(tosutilPath)) {
7757
+ return fs26.existsSync(tosutilPath) ? tosutilPath : null;
7964
7758
  }
7965
7759
  try {
7966
7760
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -8005,7 +7799,7 @@ async function resolveBucketId(appId) {
8005
7799
  return bucketId;
8006
7800
  }
8007
7801
  function isDirEmpty(dirPath) {
8008
- const entries = fs28.readdirSync(dirPath);
7802
+ const entries = fs26.readdirSync(dirPath);
8009
7803
  return entries.length === 0;
8010
7804
  }
8011
7805
 
@@ -8100,12 +7894,12 @@ var commands = [
8100
7894
  ];
8101
7895
 
8102
7896
  // src/index.ts
8103
- var envPath = path25.join(process.cwd(), ".env");
8104
- if (fs29.existsSync(envPath)) {
7897
+ var envPath = path23.join(process.cwd(), ".env");
7898
+ if (fs27.existsSync(envPath)) {
8105
7899
  dotenvConfig({ path: envPath });
8106
7900
  }
8107
- var __dirname = path25.dirname(fileURLToPath5(import.meta.url));
8108
- 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"));
8109
7903
  var cli = new FullstackCLI(pkg.version);
8110
7904
  cli.useAll(commands);
8111
7905
  cli.run();