@lark-apaas/fullstack-cli 1.1.43 → 1.1.44-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.
Files changed (2) hide show
  1. package/dist/index.js +300 -194
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
- import fs27 from "fs";
3
- import path23 from "path";
2
+ import fs28 from "fs";
3
+ import path24 from "path";
4
4
  import { fileURLToPath as fileURLToPath5 } from "url";
5
5
  import { config as dotenvConfig } from "dotenv";
6
6
 
@@ -3444,6 +3444,111 @@ var depsCommand = {
3444
3444
  }
3445
3445
  };
3446
3446
 
3447
+ // src/commands/upgrade/global/run.handler.ts
3448
+ import { spawnSync as spawnSync4 } from "child_process";
3449
+ import fs11 from "fs";
3450
+ import path9 from "path";
3451
+ var MANAGED_GLOBAL_CLIS = [
3452
+ "@lark-apaas/fullstack-cli",
3453
+ "@lark-apaas/miaoda-cli"
3454
+ ];
3455
+ function readGlobalInstalledVersion(pkg2) {
3456
+ const candidates = [];
3457
+ if (process.env.npm_config_prefix) candidates.push(process.env.npm_config_prefix);
3458
+ if (process.env.NPM_CONFIG_PREFIX) candidates.push(process.env.NPM_CONFIG_PREFIX);
3459
+ candidates.push("/usr");
3460
+ candidates.push("/usr/local");
3461
+ if (process.env.HOME) candidates.push(path9.join(process.env.HOME, ".npm-global"));
3462
+ const seen = /* @__PURE__ */ new Set();
3463
+ for (const prefix of candidates) {
3464
+ if (seen.has(prefix)) continue;
3465
+ seen.add(prefix);
3466
+ try {
3467
+ const pkgPath = path9.join(prefix, "lib", "node_modules", pkg2, "package.json");
3468
+ if (fs11.existsSync(pkgPath)) {
3469
+ const meta = JSON.parse(fs11.readFileSync(pkgPath, "utf-8"));
3470
+ if (meta && typeof meta.version === "string") return meta.version;
3471
+ }
3472
+ } catch (err) {
3473
+ console.warn(
3474
+ `[fullstack-cli] readGlobalInstalledVersion(${pkg2}) failed at prefix=${prefix}: ${err instanceof Error ? err.message : String(err)}`
3475
+ );
3476
+ }
3477
+ }
3478
+ return "";
3479
+ }
3480
+ function buildGlobalUpgradePlan(managed, resolvedVersions, readVersion) {
3481
+ const plan = [];
3482
+ for (const pkg2 of managed) {
3483
+ const target = resolvedVersions.get(pkg2);
3484
+ if (!target) {
3485
+ console.log(`[fullstack-cli] ${pkg2}: no target version in grayscale config, skip`);
3486
+ continue;
3487
+ }
3488
+ const current = readVersion(pkg2);
3489
+ if (current && current === target) {
3490
+ console.log(`[fullstack-cli] ${pkg2}@${target} (already installed, skip)`);
3491
+ continue;
3492
+ }
3493
+ plan.push({ pkg: pkg2, current, target });
3494
+ }
3495
+ return plan;
3496
+ }
3497
+ async function run5(options = {}) {
3498
+ console.log("[fullstack-cli] Starting global CLI upgrade...");
3499
+ if (!options.grayscaleConfig) {
3500
+ console.log("[fullstack-cli] No grayscale config, skip global upgrade");
3501
+ return;
3502
+ }
3503
+ const grayscaleVersions = resolveGrayscaleVersions("/", options.grayscaleConfig);
3504
+ if (!grayscaleVersions) {
3505
+ console.log("[fullstack-cli] Grayscale config not available, skip global upgrade");
3506
+ return;
3507
+ }
3508
+ const plan = buildGlobalUpgradePlan(MANAGED_GLOBAL_CLIS, grayscaleVersions, readGlobalInstalledVersion);
3509
+ if (plan.length === 0) {
3510
+ console.log("[fullstack-cli] No global CLI upgrade needed");
3511
+ return;
3512
+ }
3513
+ console.log(`[fullstack-cli] Global upgrade plan (${plan.length} package(s)):`);
3514
+ plan.forEach(({ pkg: pkg2, current, target }) => {
3515
+ console.log(` - ${pkg2} ${current || "(not installed)"} -> ${target}`);
3516
+ });
3517
+ if (options.dryRun) {
3518
+ console.log("[fullstack-cli] Dry run mode, skipping actual installation");
3519
+ return;
3520
+ }
3521
+ const targets = plan.map(({ pkg: pkg2, target }) => `${pkg2}@${target}`);
3522
+ const npmArgs = ["install", "-g", ...targets];
3523
+ if (options.registry) {
3524
+ npmArgs.push("--registry", options.registry);
3525
+ }
3526
+ console.log(`[fullstack-cli] Running: npm ${npmArgs.join(" ")}`);
3527
+ const result = spawnSync4("npm", npmArgs, { stdio: "inherit" });
3528
+ if (result.error || result.status !== 0) {
3529
+ console.warn(
3530
+ `[fullstack-cli] npm install -g failed: ${result.error?.message ?? `exit ${result.status}`}`
3531
+ );
3532
+ process.exit(1);
3533
+ }
3534
+ console.log("[fullstack-cli] \u2713 Global CLI upgrade completed");
3535
+ }
3536
+
3537
+ // src/commands/upgrade/global/index.ts
3538
+ var globalCommand = {
3539
+ name: "global",
3540
+ description: "Upgrade global @lark-apaas CLIs (fullstack-cli, miaoda-cli) per grayscale config",
3541
+ register(parentCommand) {
3542
+ 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(
3543
+ "--registry <url>",
3544
+ "npm registry URL (default: https://registry.npmmirror.com/)",
3545
+ "https://registry.npmmirror.com/"
3546
+ ).action(async (options) => {
3547
+ await run5(options);
3548
+ });
3549
+ }
3550
+ };
3551
+
3447
3552
  // src/commands/upgrade/index.ts
3448
3553
  var upgradeCommand = {
3449
3554
  name: "upgrade",
@@ -3453,13 +3558,14 @@ var upgradeCommand = {
3453
3558
  await run3(options);
3454
3559
  });
3455
3560
  depsCommand.register(upgradeCmd);
3561
+ globalCommand.register(upgradeCmd);
3456
3562
  }
3457
3563
  };
3458
3564
 
3459
3565
  // src/commands/action-plugin/utils.ts
3460
- import fs11 from "fs";
3461
- import path9 from "path";
3462
- import { spawnSync as spawnSync4, execSync as execSync2 } from "child_process";
3566
+ import fs12 from "fs";
3567
+ import path10 from "path";
3568
+ import { spawnSync as spawnSync5, execSync as execSync2 } from "child_process";
3463
3569
  function parsePluginName(input) {
3464
3570
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
3465
3571
  if (!match) {
@@ -3476,18 +3582,18 @@ function getProjectRoot() {
3476
3582
  return process.cwd();
3477
3583
  }
3478
3584
  function getPackageJsonPath() {
3479
- return path9.join(getProjectRoot(), "package.json");
3585
+ return path10.join(getProjectRoot(), "package.json");
3480
3586
  }
3481
3587
  function getPluginPath(pluginName) {
3482
- return path9.join(getProjectRoot(), "node_modules", pluginName);
3588
+ return path10.join(getProjectRoot(), "node_modules", pluginName);
3483
3589
  }
3484
3590
  function readPackageJson2() {
3485
3591
  const pkgPath = getPackageJsonPath();
3486
- if (!fs11.existsSync(pkgPath)) {
3592
+ if (!fs12.existsSync(pkgPath)) {
3487
3593
  throw new Error("package.json not found in current directory");
3488
3594
  }
3489
3595
  try {
3490
- const content = fs11.readFileSync(pkgPath, "utf-8");
3596
+ const content = fs12.readFileSync(pkgPath, "utf-8");
3491
3597
  return JSON.parse(content);
3492
3598
  } catch {
3493
3599
  throw new Error("Failed to parse package.json");
@@ -3495,7 +3601,7 @@ function readPackageJson2() {
3495
3601
  }
3496
3602
  function writePackageJson2(pkg2) {
3497
3603
  const pkgPath = getPackageJsonPath();
3498
- fs11.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3604
+ fs12.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3499
3605
  }
3500
3606
  function readActionPlugins() {
3501
3607
  const pkg2 = readPackageJson2();
@@ -3516,7 +3622,7 @@ function getInstalledPluginVersion(pluginName) {
3516
3622
  }
3517
3623
  function npmInstall(tgzPath) {
3518
3624
  console.log(`[action-plugin] Running npm install ${tgzPath}...`);
3519
- const result = spawnSync4("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
3625
+ const result = spawnSync5("npm", ["install", tgzPath, "--no-save", "--no-package-lock", "--ignore-scripts"], {
3520
3626
  cwd: getProjectRoot(),
3521
3627
  stdio: "inherit"
3522
3628
  });
@@ -3528,12 +3634,12 @@ function npmInstall(tgzPath) {
3528
3634
  }
3529
3635
  }
3530
3636
  function getPackageVersion(pluginName) {
3531
- const pkgJsonPath = path9.join(getPluginPath(pluginName), "package.json");
3532
- if (!fs11.existsSync(pkgJsonPath)) {
3637
+ const pkgJsonPath = path10.join(getPluginPath(pluginName), "package.json");
3638
+ if (!fs12.existsSync(pkgJsonPath)) {
3533
3639
  return null;
3534
3640
  }
3535
3641
  try {
3536
- const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3642
+ const content = fs12.readFileSync(pkgJsonPath, "utf-8");
3537
3643
  const pkg2 = JSON.parse(content);
3538
3644
  return pkg2.version || null;
3539
3645
  } catch {
@@ -3541,49 +3647,49 @@ function getPackageVersion(pluginName) {
3541
3647
  }
3542
3648
  }
3543
3649
  function readPluginPackageJson(pluginPath) {
3544
- const pkgJsonPath = path9.join(pluginPath, "package.json");
3545
- if (!fs11.existsSync(pkgJsonPath)) {
3650
+ const pkgJsonPath = path10.join(pluginPath, "package.json");
3651
+ if (!fs12.existsSync(pkgJsonPath)) {
3546
3652
  return null;
3547
3653
  }
3548
3654
  try {
3549
- const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3655
+ const content = fs12.readFileSync(pkgJsonPath, "utf-8");
3550
3656
  return JSON.parse(content);
3551
3657
  } catch {
3552
3658
  return null;
3553
3659
  }
3554
3660
  }
3555
3661
  function extractTgzToNodeModules(tgzPath, pluginName) {
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 });
3662
+ const nodeModulesPath = path10.join(getProjectRoot(), "node_modules");
3663
+ const targetDir = path10.join(nodeModulesPath, pluginName);
3664
+ const scopeDir = path10.dirname(targetDir);
3665
+ if (!fs12.existsSync(scopeDir)) {
3666
+ fs12.mkdirSync(scopeDir, { recursive: true });
3561
3667
  }
3562
- if (fs11.existsSync(targetDir)) {
3563
- fs11.rmSync(targetDir, { recursive: true });
3668
+ if (fs12.existsSync(targetDir)) {
3669
+ fs12.rmSync(targetDir, { recursive: true });
3564
3670
  }
3565
- const tempDir = path9.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3566
- if (fs11.existsSync(tempDir)) {
3567
- fs11.rmSync(tempDir, { recursive: true });
3671
+ const tempDir = path10.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3672
+ if (fs12.existsSync(tempDir)) {
3673
+ fs12.rmSync(tempDir, { recursive: true });
3568
3674
  }
3569
- fs11.mkdirSync(tempDir, { recursive: true });
3675
+ fs12.mkdirSync(tempDir, { recursive: true });
3570
3676
  try {
3571
3677
  execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
3572
- const extractedDir = path9.join(tempDir, "package");
3573
- if (fs11.existsSync(extractedDir)) {
3574
- fs11.renameSync(extractedDir, targetDir);
3678
+ const extractedDir = path10.join(tempDir, "package");
3679
+ if (fs12.existsSync(extractedDir)) {
3680
+ fs12.renameSync(extractedDir, targetDir);
3575
3681
  } else {
3576
- const files = fs11.readdirSync(tempDir);
3682
+ const files = fs12.readdirSync(tempDir);
3577
3683
  if (files.length === 1) {
3578
- fs11.renameSync(path9.join(tempDir, files[0]), targetDir);
3684
+ fs12.renameSync(path10.join(tempDir, files[0]), targetDir);
3579
3685
  } else {
3580
3686
  throw new Error("Unexpected tgz structure");
3581
3687
  }
3582
3688
  }
3583
3689
  return targetDir;
3584
3690
  } finally {
3585
- if (fs11.existsSync(tempDir)) {
3586
- fs11.rmSync(tempDir, { recursive: true });
3691
+ if (fs12.existsSync(tempDir)) {
3692
+ fs12.rmSync(tempDir, { recursive: true });
3587
3693
  }
3588
3694
  }
3589
3695
  }
@@ -3592,10 +3698,10 @@ function checkMissingPeerDeps(peerDeps) {
3592
3698
  return [];
3593
3699
  }
3594
3700
  const missing = [];
3595
- const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
3701
+ const nodeModulesPath = path10.join(getProjectRoot(), "node_modules");
3596
3702
  for (const [depName, _version] of Object.entries(peerDeps)) {
3597
- const depPath = path9.join(nodeModulesPath, depName);
3598
- if (!fs11.existsSync(depPath)) {
3703
+ const depPath = path10.join(nodeModulesPath, depName);
3704
+ if (!fs12.existsSync(depPath)) {
3599
3705
  missing.push(depName);
3600
3706
  }
3601
3707
  }
@@ -3606,7 +3712,7 @@ function installMissingDeps(deps) {
3606
3712
  return;
3607
3713
  }
3608
3714
  console.log(`[action-plugin] Installing missing dependencies: ${deps.join(", ")}`);
3609
- const result = spawnSync4("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
3715
+ const result = spawnSync5("npm", ["install", ...deps, "--no-save", "--no-package-lock"], {
3610
3716
  cwd: getProjectRoot(),
3611
3717
  stdio: "inherit"
3612
3718
  });
@@ -3619,16 +3725,16 @@ function installMissingDeps(deps) {
3619
3725
  }
3620
3726
  function removePluginDirectory(pluginName) {
3621
3727
  const pluginPath = getPluginPath(pluginName);
3622
- if (fs11.existsSync(pluginPath)) {
3623
- fs11.rmSync(pluginPath, { recursive: true });
3728
+ if (fs12.existsSync(pluginPath)) {
3729
+ fs12.rmSync(pluginPath, { recursive: true });
3624
3730
  console.log(`[action-plugin] Removed ${pluginName}`);
3625
3731
  }
3626
3732
  }
3627
3733
 
3628
3734
  // src/commands/action-plugin/api-client.ts
3629
3735
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
3630
- import fs12 from "fs";
3631
- import path10 from "path";
3736
+ import fs13 from "fs";
3737
+ import path11 from "path";
3632
3738
  var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
3633
3739
  async function getPluginVersions(keys, latestOnly = true) {
3634
3740
  const client = getHttpClient();
@@ -3692,19 +3798,19 @@ async function downloadFromPublic(downloadURL) {
3692
3798
  return Buffer.from(arrayBuffer);
3693
3799
  }
3694
3800
  function getPluginCacheDir() {
3695
- return path10.join(process.cwd(), PLUGIN_CACHE_DIR);
3801
+ return path11.join(process.cwd(), PLUGIN_CACHE_DIR);
3696
3802
  }
3697
3803
  function ensureCacheDir() {
3698
3804
  const cacheDir = getPluginCacheDir();
3699
- if (!fs12.existsSync(cacheDir)) {
3700
- fs12.mkdirSync(cacheDir, { recursive: true });
3805
+ if (!fs13.existsSync(cacheDir)) {
3806
+ fs13.mkdirSync(cacheDir, { recursive: true });
3701
3807
  }
3702
3808
  }
3703
3809
  function getTempFilePath(pluginKey, version) {
3704
3810
  ensureCacheDir();
3705
3811
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3706
3812
  const filename = `${safeKey}@${version}.tgz`;
3707
- return path10.join(getPluginCacheDir(), filename);
3813
+ return path11.join(getPluginCacheDir(), filename);
3708
3814
  }
3709
3815
  var MAX_RETRIES = 2;
3710
3816
  async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
@@ -3741,7 +3847,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
3741
3847
  );
3742
3848
  }
3743
3849
  const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
3744
- fs12.writeFileSync(tgzPath, tgzBuffer);
3850
+ fs13.writeFileSync(tgzPath, tgzBuffer);
3745
3851
  console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
3746
3852
  return {
3747
3853
  tgzPath,
@@ -3755,18 +3861,18 @@ function getCachePath(pluginKey, version) {
3755
3861
  ensureCacheDir();
3756
3862
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3757
3863
  const filename = `${safeKey}@${version}.tgz`;
3758
- return path10.join(getPluginCacheDir(), filename);
3864
+ return path11.join(getPluginCacheDir(), filename);
3759
3865
  }
3760
3866
  function hasCachedPlugin(pluginKey, version) {
3761
3867
  const cachePath = getCachePath(pluginKey, version);
3762
- return fs12.existsSync(cachePath);
3868
+ return fs13.existsSync(cachePath);
3763
3869
  }
3764
3870
  function listCachedPlugins() {
3765
3871
  const cacheDir = getPluginCacheDir();
3766
- if (!fs12.existsSync(cacheDir)) {
3872
+ if (!fs13.existsSync(cacheDir)) {
3767
3873
  return [];
3768
3874
  }
3769
- const files = fs12.readdirSync(cacheDir);
3875
+ const files = fs13.readdirSync(cacheDir);
3770
3876
  const result = [];
3771
3877
  for (const file of files) {
3772
3878
  if (!file.endsWith(".tgz")) continue;
@@ -3774,8 +3880,8 @@ function listCachedPlugins() {
3774
3880
  if (!match) continue;
3775
3881
  const [, rawName, version] = match;
3776
3882
  const name = rawName.replace(/^_/, "@").replace(/_/, "/");
3777
- const filePath = path10.join(cacheDir, file);
3778
- const stat = fs12.statSync(filePath);
3883
+ const filePath = path11.join(cacheDir, file);
3884
+ const stat = fs13.statSync(filePath);
3779
3885
  result.push({
3780
3886
  name,
3781
3887
  version,
@@ -3788,14 +3894,14 @@ function listCachedPlugins() {
3788
3894
  }
3789
3895
  function cleanAllCache() {
3790
3896
  const cacheDir = getPluginCacheDir();
3791
- if (!fs12.existsSync(cacheDir)) {
3897
+ if (!fs13.existsSync(cacheDir)) {
3792
3898
  return 0;
3793
3899
  }
3794
- const files = fs12.readdirSync(cacheDir);
3900
+ const files = fs13.readdirSync(cacheDir);
3795
3901
  let count = 0;
3796
3902
  for (const file of files) {
3797
3903
  if (file.endsWith(".tgz")) {
3798
- fs12.unlinkSync(path10.join(cacheDir, file));
3904
+ fs13.unlinkSync(path11.join(cacheDir, file));
3799
3905
  count++;
3800
3906
  }
3801
3907
  }
@@ -3803,21 +3909,21 @@ function cleanAllCache() {
3803
3909
  }
3804
3910
  function cleanPluginCache(pluginKey, version) {
3805
3911
  const cacheDir = getPluginCacheDir();
3806
- if (!fs12.existsSync(cacheDir)) {
3912
+ if (!fs13.existsSync(cacheDir)) {
3807
3913
  return 0;
3808
3914
  }
3809
3915
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3810
- const files = fs12.readdirSync(cacheDir);
3916
+ const files = fs13.readdirSync(cacheDir);
3811
3917
  let count = 0;
3812
3918
  for (const file of files) {
3813
3919
  if (version) {
3814
3920
  if (file === `${safeKey}@${version}.tgz`) {
3815
- fs12.unlinkSync(path10.join(cacheDir, file));
3921
+ fs13.unlinkSync(path11.join(cacheDir, file));
3816
3922
  count++;
3817
3923
  }
3818
3924
  } else {
3819
3925
  if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
3820
- fs12.unlinkSync(path10.join(cacheDir, file));
3926
+ fs13.unlinkSync(path11.join(cacheDir, file));
3821
3927
  count++;
3822
3928
  }
3823
3929
  }
@@ -4244,40 +4350,40 @@ var actionPluginCommandGroup = {
4244
4350
  };
4245
4351
 
4246
4352
  // src/commands/capability/utils.ts
4247
- import fs13 from "fs";
4353
+ import fs14 from "fs";
4248
4354
  import { createRequire as createRequire2 } from "module";
4249
- import path11 from "path";
4355
+ import path12 from "path";
4250
4356
  var CAPABILITIES_DIR = "server/capabilities";
4251
4357
  function getProjectRoot2() {
4252
4358
  return process.cwd();
4253
4359
  }
4254
4360
  function getCapabilitiesDir() {
4255
- return path11.join(getProjectRoot2(), CAPABILITIES_DIR);
4361
+ return path12.join(getProjectRoot2(), CAPABILITIES_DIR);
4256
4362
  }
4257
4363
  function getCapabilityPath(id) {
4258
- return path11.join(getCapabilitiesDir(), `${id}.json`);
4364
+ return path12.join(getCapabilitiesDir(), `${id}.json`);
4259
4365
  }
4260
4366
  function getPluginManifestPath(pluginKey) {
4261
- return path11.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4367
+ return path12.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4262
4368
  }
4263
4369
  function capabilitiesDirExists() {
4264
- return fs13.existsSync(getCapabilitiesDir());
4370
+ return fs14.existsSync(getCapabilitiesDir());
4265
4371
  }
4266
4372
  function listCapabilityIds() {
4267
4373
  const dir = getCapabilitiesDir();
4268
- if (!fs13.existsSync(dir)) {
4374
+ if (!fs14.existsSync(dir)) {
4269
4375
  return [];
4270
4376
  }
4271
- const files = fs13.readdirSync(dir);
4377
+ const files = fs14.readdirSync(dir);
4272
4378
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
4273
4379
  }
4274
4380
  function readCapability(id) {
4275
4381
  const filePath = getCapabilityPath(id);
4276
- if (!fs13.existsSync(filePath)) {
4382
+ if (!fs14.existsSync(filePath)) {
4277
4383
  throw new Error(`Capability not found: ${id}`);
4278
4384
  }
4279
4385
  try {
4280
- const content = fs13.readFileSync(filePath, "utf-8");
4386
+ const content = fs14.readFileSync(filePath, "utf-8");
4281
4387
  return JSON.parse(content);
4282
4388
  } catch (error) {
4283
4389
  if (error instanceof SyntaxError) {
@@ -4304,11 +4410,11 @@ function readAllCapabilities() {
4304
4410
  }
4305
4411
  function readPluginManifest(pluginKey) {
4306
4412
  const manifestPath = getPluginManifestPath(pluginKey);
4307
- if (!fs13.existsSync(manifestPath)) {
4413
+ if (!fs14.existsSync(manifestPath)) {
4308
4414
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
4309
4415
  }
4310
4416
  try {
4311
- const content = fs13.readFileSync(manifestPath, "utf-8");
4417
+ const content = fs14.readFileSync(manifestPath, "utf-8");
4312
4418
  return JSON.parse(content);
4313
4419
  } catch (error) {
4314
4420
  if (error instanceof SyntaxError) {
@@ -4325,7 +4431,7 @@ function hasValidParamsSchema(paramsSchema) {
4325
4431
  }
4326
4432
  async function loadPlugin(pluginKey) {
4327
4433
  try {
4328
- const userRequire = createRequire2(path11.join(getProjectRoot2(), "package.json"));
4434
+ const userRequire = createRequire2(path12.join(getProjectRoot2(), "package.json"));
4329
4435
  const resolvedPath = userRequire.resolve(pluginKey);
4330
4436
  const pluginModule = await import(resolvedPath);
4331
4437
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -4488,8 +4594,8 @@ var capabilityCommandGroup = {
4488
4594
  import { execFile } from "child_process";
4489
4595
 
4490
4596
  // src/commands/component/registry-preparer.ts
4491
- import fs14 from "fs";
4492
- import path12 from "path";
4597
+ import fs15 from "fs";
4598
+ import path13 from "path";
4493
4599
  import os from "os";
4494
4600
 
4495
4601
  // src/commands/component/service.ts
@@ -4545,7 +4651,7 @@ async function sendInstallEvent(key) {
4545
4651
  }
4546
4652
 
4547
4653
  // src/commands/component/registry-preparer.ts
4548
- var REGISTRY_TEMP_DIR = path12.join(os.tmpdir(), "miaoda-registry");
4654
+ var REGISTRY_TEMP_DIR = path13.join(os.tmpdir(), "miaoda-registry");
4549
4655
  function parseComponentKey(key) {
4550
4656
  const match = key.match(/^@([^/]+)\/(.+)$/);
4551
4657
  if (!match) {
@@ -4557,11 +4663,11 @@ function parseComponentKey(key) {
4557
4663
  }
4558
4664
  function getLocalRegistryPath(key) {
4559
4665
  const { scope, name } = parseComponentKey(key);
4560
- return path12.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4666
+ return path13.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4561
4667
  }
4562
4668
  function ensureDir(dirPath) {
4563
- if (!fs14.existsSync(dirPath)) {
4564
- fs14.mkdirSync(dirPath, { recursive: true });
4669
+ if (!fs15.existsSync(dirPath)) {
4670
+ fs15.mkdirSync(dirPath, { recursive: true });
4565
4671
  }
4566
4672
  }
4567
4673
  async function prepareRecursive(key, visited) {
@@ -4594,8 +4700,8 @@ async function prepareRecursive(key, visited) {
4594
4700
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
4595
4701
  };
4596
4702
  const localPath = getLocalRegistryPath(key);
4597
- ensureDir(path12.dirname(localPath));
4598
- fs14.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4703
+ ensureDir(path13.dirname(localPath));
4704
+ fs15.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4599
4705
  debug("\u4FDD\u5B58\u5230: %s", localPath);
4600
4706
  }
4601
4707
  async function prepareComponentRegistryItems(id) {
@@ -4605,18 +4711,18 @@ async function prepareComponentRegistryItems(id) {
4605
4711
  }
4606
4712
  function cleanupTempDir() {
4607
4713
  try {
4608
- if (fs14.existsSync(REGISTRY_TEMP_DIR)) {
4609
- fs14.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4714
+ if (fs15.existsSync(REGISTRY_TEMP_DIR)) {
4715
+ fs15.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4610
4716
  }
4611
4717
  } catch {
4612
4718
  }
4613
4719
  }
4614
4720
  function getDownloadedRegistryItem(itemId) {
4615
4721
  const localPath = getLocalRegistryPath(itemId);
4616
- if (!fs14.existsSync(localPath)) {
4722
+ if (!fs15.existsSync(localPath)) {
4617
4723
  return null;
4618
4724
  }
4619
- const content = fs14.readFileSync(localPath, "utf-8");
4725
+ const content = fs15.readFileSync(localPath, "utf-8");
4620
4726
  return JSON.parse(content);
4621
4727
  }
4622
4728
 
@@ -4784,58 +4890,58 @@ var componentCommandGroup = {
4784
4890
  };
4785
4891
 
4786
4892
  // src/commands/migration/version-manager.ts
4787
- import fs15 from "fs";
4788
- import path13 from "path";
4893
+ import fs16 from "fs";
4894
+ import path14 from "path";
4789
4895
  var PACKAGE_JSON = "package.json";
4790
4896
  var VERSION_FIELD = "migrationVersion";
4791
4897
  function getPackageJsonPath2() {
4792
- return path13.join(process.cwd(), PACKAGE_JSON);
4898
+ return path14.join(process.cwd(), PACKAGE_JSON);
4793
4899
  }
4794
4900
  function getCurrentVersion() {
4795
4901
  const pkgPath = getPackageJsonPath2();
4796
- if (!fs15.existsSync(pkgPath)) {
4902
+ if (!fs16.existsSync(pkgPath)) {
4797
4903
  throw new Error("package.json not found");
4798
4904
  }
4799
- const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
4905
+ const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
4800
4906
  return pkg2[VERSION_FIELD] ?? 0;
4801
4907
  }
4802
4908
  function setCurrentVersion(version) {
4803
4909
  const pkgPath = getPackageJsonPath2();
4804
- const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
4910
+ const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
4805
4911
  pkg2[VERSION_FIELD] = version;
4806
- fs15.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4912
+ fs16.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4807
4913
  }
4808
4914
 
4809
4915
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4810
- import fs17 from "fs";
4811
- import path15 from "path";
4916
+ import fs18 from "fs";
4917
+ import path16 from "path";
4812
4918
 
4813
4919
  // src/commands/migration/versions/v001_capability/utils.ts
4814
- import fs16 from "fs";
4815
- import path14 from "path";
4920
+ import fs17 from "fs";
4921
+ import path15 from "path";
4816
4922
  var CAPABILITIES_DIR2 = "server/capabilities";
4817
4923
  function getProjectRoot3() {
4818
4924
  return process.cwd();
4819
4925
  }
4820
4926
  function getCapabilitiesDir2() {
4821
- return path14.join(getProjectRoot3(), CAPABILITIES_DIR2);
4927
+ return path15.join(getProjectRoot3(), CAPABILITIES_DIR2);
4822
4928
  }
4823
4929
  function getPluginManifestPath2(pluginKey) {
4824
- return path14.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4930
+ return path15.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4825
4931
  }
4826
4932
 
4827
4933
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4828
4934
  function detectJsonMigration() {
4829
4935
  const capabilitiesDir = getCapabilitiesDir2();
4830
- const oldFilePath = path15.join(capabilitiesDir, "capabilities.json");
4831
- if (!fs17.existsSync(oldFilePath)) {
4936
+ const oldFilePath = path16.join(capabilitiesDir, "capabilities.json");
4937
+ if (!fs18.existsSync(oldFilePath)) {
4832
4938
  return {
4833
4939
  needsMigration: false,
4834
4940
  reason: "capabilities.json not found"
4835
4941
  };
4836
4942
  }
4837
4943
  try {
4838
- const content = fs17.readFileSync(oldFilePath, "utf-8");
4944
+ const content = fs18.readFileSync(oldFilePath, "utf-8");
4839
4945
  const parsed = JSON.parse(content);
4840
4946
  if (!Array.isArray(parsed)) {
4841
4947
  return {
@@ -4886,8 +4992,8 @@ async function check(options) {
4886
4992
  }
4887
4993
 
4888
4994
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
4889
- import fs18 from "fs";
4890
- import path16 from "path";
4995
+ import fs19 from "fs";
4996
+ import path17 from "path";
4891
4997
 
4892
4998
  // src/commands/migration/versions/v001_capability/mapping.ts
4893
4999
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -5117,18 +5223,18 @@ function transformCapabilities(oldCapabilities) {
5117
5223
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5118
5224
  function loadExistingCapabilities() {
5119
5225
  const capabilitiesDir = getCapabilitiesDir2();
5120
- if (!fs18.existsSync(capabilitiesDir)) {
5226
+ if (!fs19.existsSync(capabilitiesDir)) {
5121
5227
  return [];
5122
5228
  }
5123
- const files = fs18.readdirSync(capabilitiesDir);
5229
+ const files = fs19.readdirSync(capabilitiesDir);
5124
5230
  const capabilities = [];
5125
5231
  for (const file of files) {
5126
5232
  if (file === "capabilities.json" || !file.endsWith(".json")) {
5127
5233
  continue;
5128
5234
  }
5129
5235
  try {
5130
- const filePath = path16.join(capabilitiesDir, file);
5131
- const content = fs18.readFileSync(filePath, "utf-8");
5236
+ const filePath = path17.join(capabilitiesDir, file);
5237
+ const content = fs19.readFileSync(filePath, "utf-8");
5132
5238
  const capability = JSON.parse(content);
5133
5239
  if (capability.id && capability.pluginKey) {
5134
5240
  capabilities.push(capability);
@@ -5186,9 +5292,9 @@ async function migrateJsonFiles(options) {
5186
5292
  }
5187
5293
  const capabilitiesDir = getCapabilitiesDir2();
5188
5294
  for (const cap of newCapabilities) {
5189
- const filePath = path16.join(capabilitiesDir, `${cap.id}.json`);
5295
+ const filePath = path17.join(capabilitiesDir, `${cap.id}.json`);
5190
5296
  const content = JSON.stringify(cap, null, 2);
5191
- fs18.writeFileSync(filePath, content, "utf-8");
5297
+ fs19.writeFileSync(filePath, content, "utf-8");
5192
5298
  console.log(` \u2713 Created: ${cap.id}.json`);
5193
5299
  }
5194
5300
  return {
@@ -5200,11 +5306,11 @@ async function migrateJsonFiles(options) {
5200
5306
  }
5201
5307
 
5202
5308
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
5203
- import fs19 from "fs";
5309
+ import fs20 from "fs";
5204
5310
  function isPluginInstalled2(pluginKey) {
5205
5311
  const actionPlugins = readActionPlugins();
5206
5312
  const manifestPath = getPluginManifestPath2(pluginKey);
5207
- return fs19.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5313
+ return fs20.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5208
5314
  }
5209
5315
  function detectPluginsToInstall(capabilities) {
5210
5316
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -5280,12 +5386,12 @@ async function installPlugins(capabilities, options) {
5280
5386
  }
5281
5387
 
5282
5388
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
5283
- import path18 from "path";
5389
+ import path19 from "path";
5284
5390
  import { Project as Project3 } from "ts-morph";
5285
5391
 
5286
5392
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
5287
- import fs20 from "fs";
5288
- import path17 from "path";
5393
+ import fs21 from "fs";
5394
+ import path18 from "path";
5289
5395
  var EXCLUDED_DIRS = [
5290
5396
  "node_modules",
5291
5397
  "dist",
@@ -5300,9 +5406,9 @@ var EXCLUDED_PATTERNS = [
5300
5406
  /\.d\.ts$/
5301
5407
  ];
5302
5408
  function scanDirectory(dir, files = []) {
5303
- const entries = fs20.readdirSync(dir, { withFileTypes: true });
5409
+ const entries = fs21.readdirSync(dir, { withFileTypes: true });
5304
5410
  for (const entry of entries) {
5305
- const fullPath = path17.join(dir, entry.name);
5411
+ const fullPath = path18.join(dir, entry.name);
5306
5412
  if (entry.isDirectory()) {
5307
5413
  if (EXCLUDED_DIRS.includes(entry.name)) {
5308
5414
  continue;
@@ -5318,14 +5424,14 @@ function scanDirectory(dir, files = []) {
5318
5424
  return files;
5319
5425
  }
5320
5426
  function scanServerFiles() {
5321
- const serverDir = path17.join(getProjectRoot3(), "server");
5322
- if (!fs20.existsSync(serverDir)) {
5427
+ const serverDir = path18.join(getProjectRoot3(), "server");
5428
+ if (!fs21.existsSync(serverDir)) {
5323
5429
  return [];
5324
5430
  }
5325
5431
  return scanDirectory(serverDir);
5326
5432
  }
5327
5433
  function hasCapabilityImport(filePath) {
5328
- const content = fs20.readFileSync(filePath, "utf-8");
5434
+ const content = fs21.readFileSync(filePath, "utf-8");
5329
5435
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
5330
5436
  }
5331
5437
  function scanFilesToMigrate() {
@@ -5702,7 +5808,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5702
5808
  const callSites = analyzeCallSites(sourceFile, imports);
5703
5809
  const classInfo = analyzeClass(sourceFile);
5704
5810
  const { canMigrate, reason } = canAutoMigrate(classInfo);
5705
- const relativePath = path18.relative(getProjectRoot3(), filePath);
5811
+ const relativePath = path19.relative(getProjectRoot3(), filePath);
5706
5812
  return {
5707
5813
  filePath: relativePath,
5708
5814
  imports,
@@ -5713,7 +5819,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5713
5819
  };
5714
5820
  }
5715
5821
  function migrateFile(project, analysis, dryRun) {
5716
- const absolutePath = path18.join(getProjectRoot3(), analysis.filePath);
5822
+ const absolutePath = path19.join(getProjectRoot3(), analysis.filePath);
5717
5823
  if (!analysis.canAutoMigrate) {
5718
5824
  return {
5719
5825
  filePath: analysis.filePath,
@@ -5816,17 +5922,17 @@ function getSuggestion(analysis) {
5816
5922
  }
5817
5923
 
5818
5924
  // src/commands/migration/versions/v001_capability/cleanup.ts
5819
- import fs21 from "fs";
5820
- import path19 from "path";
5925
+ import fs22 from "fs";
5926
+ import path20 from "path";
5821
5927
  function cleanupOldFiles(capabilities, dryRun) {
5822
5928
  const deletedFiles = [];
5823
5929
  const errors = [];
5824
5930
  const capabilitiesDir = getCapabilitiesDir2();
5825
- const oldJsonPath = path19.join(capabilitiesDir, "capabilities.json");
5826
- if (fs21.existsSync(oldJsonPath)) {
5931
+ const oldJsonPath = path20.join(capabilitiesDir, "capabilities.json");
5932
+ if (fs22.existsSync(oldJsonPath)) {
5827
5933
  try {
5828
5934
  if (!dryRun) {
5829
- fs21.unlinkSync(oldJsonPath);
5935
+ fs22.unlinkSync(oldJsonPath);
5830
5936
  }
5831
5937
  deletedFiles.push("capabilities.json");
5832
5938
  } catch (error) {
@@ -5834,11 +5940,11 @@ function cleanupOldFiles(capabilities, dryRun) {
5834
5940
  }
5835
5941
  }
5836
5942
  for (const cap of capabilities) {
5837
- const tsFilePath = path19.join(capabilitiesDir, `${cap.id}.ts`);
5838
- if (fs21.existsSync(tsFilePath)) {
5943
+ const tsFilePath = path20.join(capabilitiesDir, `${cap.id}.ts`);
5944
+ if (fs22.existsSync(tsFilePath)) {
5839
5945
  try {
5840
5946
  if (!dryRun) {
5841
- fs21.unlinkSync(tsFilePath);
5947
+ fs22.unlinkSync(tsFilePath);
5842
5948
  }
5843
5949
  deletedFiles.push(`${cap.id}.ts`);
5844
5950
  } catch (error) {
@@ -5854,8 +5960,8 @@ function cleanupOldFiles(capabilities, dryRun) {
5854
5960
  }
5855
5961
 
5856
5962
  // src/commands/migration/versions/v001_capability/report-generator.ts
5857
- import fs22 from "fs";
5858
- import path20 from "path";
5963
+ import fs23 from "fs";
5964
+ import path21 from "path";
5859
5965
  var REPORT_FILE = "capability-migration-report.md";
5860
5966
  function printSummary(result) {
5861
5967
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -6018,15 +6124,15 @@ async function generateReport(result) {
6018
6124
  }
6019
6125
  lines.push("");
6020
6126
  const logDir = process.env.LOG_DIR || "logs";
6021
- if (!fs22.existsSync(logDir)) {
6127
+ if (!fs23.existsSync(logDir)) {
6022
6128
  return;
6023
6129
  }
6024
- const reportDir = path20.join(logDir, "migration");
6025
- if (!fs22.existsSync(reportDir)) {
6026
- fs22.mkdirSync(reportDir, { recursive: true });
6130
+ const reportDir = path21.join(logDir, "migration");
6131
+ if (!fs23.existsSync(reportDir)) {
6132
+ fs23.mkdirSync(reportDir, { recursive: true });
6027
6133
  }
6028
- const reportPath = path20.join(reportDir, REPORT_FILE);
6029
- fs22.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6134
+ const reportPath = path21.join(reportDir, REPORT_FILE);
6135
+ fs23.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6030
6136
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
6031
6137
  }
6032
6138
 
@@ -6203,7 +6309,7 @@ function buildResult(jsonMigration, pluginInstallation, codeMigration, cleanup)
6203
6309
  }
6204
6310
 
6205
6311
  // src/commands/migration/versions/v001_capability/run.ts
6206
- async function run5(options) {
6312
+ async function run6(options) {
6207
6313
  try {
6208
6314
  const migrationOptions = {
6209
6315
  dryRun: options.dryRun ?? false
@@ -6268,7 +6374,7 @@ var v001CapabilityMigration = {
6268
6374
  name: "capability",
6269
6375
  description: "Migrate capability configurations from old format (capabilities.json array) to new format (individual JSON files)",
6270
6376
  check,
6271
- run: run5
6377
+ run: run6
6272
6378
  };
6273
6379
 
6274
6380
  // src/commands/migration/versions/index.ts
@@ -6558,10 +6664,10 @@ var migrationCommand = {
6558
6664
  };
6559
6665
 
6560
6666
  // src/commands/read-logs/index.ts
6561
- import path21 from "path";
6667
+ import path22 from "path";
6562
6668
 
6563
6669
  // src/commands/read-logs/std-utils.ts
6564
- import fs23 from "fs";
6670
+ import fs24 from "fs";
6565
6671
  function formatStdPrefixTime(localTime) {
6566
6672
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
6567
6673
  if (!match) return localTime;
@@ -6591,11 +6697,11 @@ function stripPrefixFromStdLine(line) {
6591
6697
  return `[${time}] ${content}`;
6592
6698
  }
6593
6699
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
6594
- const stat = fs23.statSync(filePath);
6700
+ const stat = fs24.statSync(filePath);
6595
6701
  if (stat.size === 0) {
6596
6702
  return { lines: [], markerFound: false, totalLinesCount: 0 };
6597
6703
  }
6598
- const fd = fs23.openSync(filePath, "r");
6704
+ const fd = fs24.openSync(filePath, "r");
6599
6705
  const chunkSize = 64 * 1024;
6600
6706
  let position = stat.size;
6601
6707
  let remainder = "";
@@ -6609,7 +6715,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6609
6715
  const length = Math.min(chunkSize, position);
6610
6716
  position -= length;
6611
6717
  const buffer = Buffer.alloc(length);
6612
- fs23.readSync(fd, buffer, 0, length, position);
6718
+ fs24.readSync(fd, buffer, 0, length, position);
6613
6719
  let chunk = buffer.toString("utf8");
6614
6720
  if (remainder) {
6615
6721
  chunk += remainder;
@@ -6651,7 +6757,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6651
6757
  }
6652
6758
  }
6653
6759
  } finally {
6654
- fs23.closeSync(fd);
6760
+ fs24.closeSync(fd);
6655
6761
  }
6656
6762
  return { lines: collected.reverse(), markerFound, totalLinesCount };
6657
6763
  }
@@ -6672,21 +6778,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
6672
6778
  }
6673
6779
 
6674
6780
  // src/commands/read-logs/tail.ts
6675
- import fs24 from "fs";
6781
+ import fs25 from "fs";
6676
6782
  function fileExists(filePath) {
6677
6783
  try {
6678
- fs24.accessSync(filePath, fs24.constants.F_OK | fs24.constants.R_OK);
6784
+ fs25.accessSync(filePath, fs25.constants.F_OK | fs25.constants.R_OK);
6679
6785
  return true;
6680
6786
  } catch {
6681
6787
  return false;
6682
6788
  }
6683
6789
  }
6684
6790
  function readFileTailLines(filePath, maxLines) {
6685
- const stat = fs24.statSync(filePath);
6791
+ const stat = fs25.statSync(filePath);
6686
6792
  if (stat.size === 0) {
6687
6793
  return [];
6688
6794
  }
6689
- const fd = fs24.openSync(filePath, "r");
6795
+ const fd = fs25.openSync(filePath, "r");
6690
6796
  const chunkSize = 64 * 1024;
6691
6797
  const chunks = [];
6692
6798
  let position = stat.size;
@@ -6696,13 +6802,13 @@ function readFileTailLines(filePath, maxLines) {
6696
6802
  const length = Math.min(chunkSize, position);
6697
6803
  position -= length;
6698
6804
  const buffer = Buffer.alloc(length);
6699
- fs24.readSync(fd, buffer, 0, length, position);
6805
+ fs25.readSync(fd, buffer, 0, length, position);
6700
6806
  chunks.unshift(buffer.toString("utf8"));
6701
6807
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
6702
6808
  collectedLines += chunkLines;
6703
6809
  }
6704
6810
  } finally {
6705
- fs24.closeSync(fd);
6811
+ fs25.closeSync(fd);
6706
6812
  }
6707
6813
  const content = chunks.join("");
6708
6814
  const allLines = content.split("\n");
@@ -6718,11 +6824,11 @@ function readFileTailLines(filePath, maxLines) {
6718
6824
  return allLines.slice(allLines.length - maxLines);
6719
6825
  }
6720
6826
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6721
- const stat = fs24.statSync(filePath);
6827
+ const stat = fs25.statSync(filePath);
6722
6828
  if (stat.size === 0) {
6723
6829
  return { lines: [], totalLinesCount: 0 };
6724
6830
  }
6725
- const fd = fs24.openSync(filePath, "r");
6831
+ const fd = fs25.openSync(filePath, "r");
6726
6832
  const chunkSize = 64 * 1024;
6727
6833
  let position = stat.size;
6728
6834
  let remainder = "";
@@ -6734,7 +6840,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6734
6840
  const length = Math.min(chunkSize, position);
6735
6841
  position -= length;
6736
6842
  const buffer = Buffer.alloc(length);
6737
- fs24.readSync(fd, buffer, 0, length, position);
6843
+ fs25.readSync(fd, buffer, 0, length, position);
6738
6844
  let chunk = buffer.toString("utf8");
6739
6845
  if (remainder) {
6740
6846
  chunk += remainder;
@@ -6765,7 +6871,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6765
6871
  }
6766
6872
  }
6767
6873
  } finally {
6768
- fs24.closeSync(fd);
6874
+ fs25.closeSync(fd);
6769
6875
  }
6770
6876
  return { lines: collected.reverse(), totalLinesCount };
6771
6877
  }
@@ -6907,7 +7013,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
6907
7013
  }
6908
7014
 
6909
7015
  // src/commands/read-logs/json-lines.ts
6910
- import fs25 from "fs";
7016
+ import fs26 from "fs";
6911
7017
  function normalizePid(value) {
6912
7018
  if (typeof value === "number") {
6913
7019
  return String(value);
@@ -6958,11 +7064,11 @@ function buildWantedLevelSet(levels) {
6958
7064
  return set.size > 0 ? set : null;
6959
7065
  }
6960
7066
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
6961
- const stat = fs25.statSync(filePath);
7067
+ const stat = fs26.statSync(filePath);
6962
7068
  if (stat.size === 0) {
6963
7069
  return { lines: [], totalLinesCount: 0 };
6964
7070
  }
6965
- const fd = fs25.openSync(filePath, "r");
7071
+ const fd = fs26.openSync(filePath, "r");
6966
7072
  const chunkSize = 64 * 1024;
6967
7073
  let position = stat.size;
6968
7074
  let remainder = "";
@@ -6977,7 +7083,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
6977
7083
  const length = Math.min(chunkSize, position);
6978
7084
  position -= length;
6979
7085
  const buffer = Buffer.alloc(length);
6980
- fs25.readSync(fd, buffer, 0, length, position);
7086
+ fs26.readSync(fd, buffer, 0, length, position);
6981
7087
  let chunk = buffer.toString("utf8");
6982
7088
  if (remainder) {
6983
7089
  chunk += remainder;
@@ -7039,7 +7145,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7039
7145
  }
7040
7146
  }
7041
7147
  } finally {
7042
- fs25.closeSync(fd);
7148
+ fs26.closeSync(fd);
7043
7149
  }
7044
7150
  return { lines: collected.reverse(), totalLinesCount };
7045
7151
  }
@@ -7082,11 +7188,11 @@ function extractTraceId(obj) {
7082
7188
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7083
7189
  const wanted = traceId.trim();
7084
7190
  if (!wanted) return { lines: [], totalLinesCount: 0 };
7085
- const stat = fs25.statSync(filePath);
7191
+ const stat = fs26.statSync(filePath);
7086
7192
  if (stat.size === 0) {
7087
7193
  return { lines: [], totalLinesCount: 0 };
7088
7194
  }
7089
- const fd = fs25.openSync(filePath, "r");
7195
+ const fd = fs26.openSync(filePath, "r");
7090
7196
  const chunkSize = 64 * 1024;
7091
7197
  let position = stat.size;
7092
7198
  let remainder = "";
@@ -7099,7 +7205,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7099
7205
  const length = Math.min(chunkSize, position);
7100
7206
  position -= length;
7101
7207
  const buffer = Buffer.alloc(length);
7102
- fs25.readSync(fd, buffer, 0, length, position);
7208
+ fs26.readSync(fd, buffer, 0, length, position);
7103
7209
  let chunk = buffer.toString("utf8");
7104
7210
  if (remainder) {
7105
7211
  chunk += remainder;
@@ -7152,7 +7258,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7152
7258
  }
7153
7259
  }
7154
7260
  } finally {
7155
- fs25.closeSync(fd);
7261
+ fs26.closeSync(fd);
7156
7262
  }
7157
7263
  return { lines: collected.reverse(), totalLinesCount };
7158
7264
  }
@@ -7161,11 +7267,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7161
7267
  if (!wantedLevelSet) {
7162
7268
  return { lines: [], totalLinesCount: 0 };
7163
7269
  }
7164
- const stat = fs25.statSync(filePath);
7270
+ const stat = fs26.statSync(filePath);
7165
7271
  if (stat.size === 0) {
7166
7272
  return { lines: [], totalLinesCount: 0 };
7167
7273
  }
7168
- const fd = fs25.openSync(filePath, "r");
7274
+ const fd = fs26.openSync(filePath, "r");
7169
7275
  const chunkSize = 64 * 1024;
7170
7276
  let position = stat.size;
7171
7277
  let remainder = "";
@@ -7177,7 +7283,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7177
7283
  const length = Math.min(chunkSize, position);
7178
7284
  position -= length;
7179
7285
  const buffer = Buffer.alloc(length);
7180
- fs25.readSync(fd, buffer, 0, length, position);
7286
+ fs26.readSync(fd, buffer, 0, length, position);
7181
7287
  let chunk = buffer.toString("utf8");
7182
7288
  if (remainder) {
7183
7289
  chunk += remainder;
@@ -7224,7 +7330,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7224
7330
  }
7225
7331
  }
7226
7332
  } finally {
7227
- fs25.closeSync(fd);
7333
+ fs26.closeSync(fd);
7228
7334
  }
7229
7335
  return { lines: collected.reverse(), totalLinesCount };
7230
7336
  }
@@ -7458,34 +7564,34 @@ async function readLogsJsonResult(options) {
7458
7564
  };
7459
7565
  }
7460
7566
  function resolveLogFilePath(logDir, type) {
7461
- const base = path21.isAbsolute(logDir) ? logDir : path21.join(process.cwd(), logDir);
7567
+ const base = path22.isAbsolute(logDir) ? logDir : path22.join(process.cwd(), logDir);
7462
7568
  if (type === "server") {
7463
- return path21.join(base, "server.log");
7569
+ return path22.join(base, "server.log");
7464
7570
  }
7465
7571
  if (type === "trace") {
7466
- return path21.join(base, "trace.log");
7572
+ return path22.join(base, "trace.log");
7467
7573
  }
7468
7574
  if (type === "server-std") {
7469
- return path21.join(base, "server.std.log");
7575
+ return path22.join(base, "server.std.log");
7470
7576
  }
7471
7577
  if (type === "client-std") {
7472
- return path21.join(base, "client.std.log");
7578
+ return path22.join(base, "client.std.log");
7473
7579
  }
7474
7580
  if (type === "dev") {
7475
- return path21.join(base, "dev.log");
7581
+ return path22.join(base, "dev.log");
7476
7582
  }
7477
7583
  if (type === "dev-std") {
7478
- return path21.join(base, "dev.std.log");
7584
+ return path22.join(base, "dev.std.log");
7479
7585
  }
7480
7586
  if (type === "install-dep-std") {
7481
- return path21.join(base, "install-dep.std.log");
7587
+ return path22.join(base, "install-dep.std.log");
7482
7588
  }
7483
7589
  if (type === "browser") {
7484
- return path21.join(base, "browser.log");
7590
+ return path22.join(base, "browser.log");
7485
7591
  }
7486
7592
  throw new Error(`Unsupported log type: ${type}`);
7487
7593
  }
7488
- async function run6(options) {
7594
+ async function run7(options) {
7489
7595
  const result = await readLogsJsonResult(options);
7490
7596
  process.stdout.write(JSON.stringify(result) + "\n");
7491
7597
  }
@@ -7527,7 +7633,7 @@ var readLogsCommand = {
7527
7633
  const offset = parseNonNegativeInt(rawOptions.offset, "--offset");
7528
7634
  const traceId = typeof rawOptions.traceId === "string" ? rawOptions.traceId : void 0;
7529
7635
  const levels = parseCommaSeparatedList(rawOptions.level);
7530
- await run6({ logDir, type, maxLines, offset, traceId, levels });
7636
+ await run7({ logDir, type, maxLines, offset, traceId, levels });
7531
7637
  } catch (error) {
7532
7638
  const message = error instanceof Error ? error.message : String(error);
7533
7639
  process.stderr.write(message + "\n");
@@ -7658,9 +7764,9 @@ function camelToKebab(str) {
7658
7764
  }
7659
7765
 
7660
7766
  // src/commands/build/upload-static.handler.ts
7661
- import * as fs26 from "fs";
7767
+ import * as fs27 from "fs";
7662
7768
  import * as os2 from "os";
7663
- import * as path22 from "path";
7769
+ import * as path23 from "path";
7664
7770
  import { execFileSync } from "child_process";
7665
7771
  function readCredentialsFromEnv() {
7666
7772
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -7684,8 +7790,8 @@ async function uploadStatic(options) {
7684
7790
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7685
7791
  region = UPLOAD_STATIC_DEFAULTS.region
7686
7792
  } = options;
7687
- const resolvedStaticDir = path22.resolve(staticDir);
7688
- if (!fs26.existsSync(resolvedStaticDir)) {
7793
+ const resolvedStaticDir = path23.resolve(staticDir);
7794
+ if (!fs27.existsSync(resolvedStaticDir)) {
7689
7795
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7690
7796
  return;
7691
7797
  }
@@ -7718,8 +7824,8 @@ async function uploadStatic(options) {
7718
7824
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7719
7825
  }
7720
7826
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7721
- const confPath = path22.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7722
- fs26.writeFileSync(confPath, "");
7827
+ const confPath = path23.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7828
+ fs27.writeFileSync(confPath, "");
7723
7829
  try {
7724
7830
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7725
7831
  configureTosutil(resolvedTosutil, confPath, {
@@ -7733,7 +7839,7 @@ async function uploadStatic(options) {
7733
7839
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7734
7840
  } finally {
7735
7841
  try {
7736
- fs26.unlinkSync(confPath);
7842
+ fs27.unlinkSync(confPath);
7737
7843
  } catch {
7738
7844
  }
7739
7845
  }
@@ -7753,8 +7859,8 @@ async function uploadStatic(options) {
7753
7859
  }
7754
7860
  }
7755
7861
  function resolveTosutilPath(tosutilPath) {
7756
- if (path22.isAbsolute(tosutilPath)) {
7757
- return fs26.existsSync(tosutilPath) ? tosutilPath : null;
7862
+ if (path23.isAbsolute(tosutilPath)) {
7863
+ return fs27.existsSync(tosutilPath) ? tosutilPath : null;
7758
7864
  }
7759
7865
  try {
7760
7866
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -7799,7 +7905,7 @@ async function resolveBucketId(appId) {
7799
7905
  return bucketId;
7800
7906
  }
7801
7907
  function isDirEmpty(dirPath) {
7802
- const entries = fs26.readdirSync(dirPath);
7908
+ const entries = fs27.readdirSync(dirPath);
7803
7909
  return entries.length === 0;
7804
7910
  }
7805
7911
 
@@ -7894,12 +8000,12 @@ var commands = [
7894
8000
  ];
7895
8001
 
7896
8002
  // src/index.ts
7897
- var envPath = path23.join(process.cwd(), ".env");
7898
- if (fs27.existsSync(envPath)) {
8003
+ var envPath = path24.join(process.cwd(), ".env");
8004
+ if (fs28.existsSync(envPath)) {
7899
8005
  dotenvConfig({ path: envPath });
7900
8006
  }
7901
- var __dirname = path23.dirname(fileURLToPath5(import.meta.url));
7902
- var pkg = JSON.parse(fs27.readFileSync(path23.join(__dirname, "../package.json"), "utf-8"));
8007
+ var __dirname = path24.dirname(fileURLToPath5(import.meta.url));
8008
+ var pkg = JSON.parse(fs28.readFileSync(path24.join(__dirname, "../package.json"), "utf-8"));
7903
8009
  var cli = new FullstackCLI(pkg.version);
7904
8010
  cli.useAll(commands);
7905
8011
  cli.run();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lark-apaas/fullstack-cli",
3
- "version": "1.1.43",
3
+ "version": "1.1.44-alpha.0",
4
4
  "description": "CLI tool for fullstack template management",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",