@lark-apaas/fullstack-cli 1.1.40-alpha.17 → 1.1.40-alpha.19

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 fs26 from "fs";
3
- import path22 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
 
@@ -2167,7 +2167,9 @@ async function run(options = {}) {
2167
2167
  process.exit(1);
2168
2168
  }
2169
2169
  const outputPath = options.output || process.env.DB_SCHEMA_OUTPUT || "server/database/schema.ts";
2170
- const OUT_DIR = path2.resolve(process.cwd(), "server/database/.introspect");
2170
+ const INTROSPECT_ROOT = path2.resolve(process.cwd(), "tmp/.introspect");
2171
+ fs4.mkdirSync(INTROSPECT_ROOT, { recursive: true });
2172
+ const OUT_DIR = fs4.mkdtempSync(path2.join(INTROSPECT_ROOT, "run-"));
2171
2173
  const SCHEMA_FILE = path2.resolve(process.cwd(), outputPath);
2172
2174
  console.log("[gen-db-schema] Starting...");
2173
2175
  const __filename = fileURLToPath2(import.meta.url);
@@ -3105,6 +3107,167 @@ async function run3(options = {}) {
3105
3107
 
3106
3108
  // src/commands/upgrade/deps/run.handler.ts
3107
3109
  import { spawnSync as spawnSync3 } from "child_process";
3110
+ import fs10 from "fs";
3111
+ import path8 from "path";
3112
+
3113
+ // src/utils/grayscale/config.ts
3114
+ function getGrayscaleConfig(configJson) {
3115
+ if (!configJson) {
3116
+ return null;
3117
+ }
3118
+ try {
3119
+ const parsed = JSON.parse(configJson);
3120
+ const config = parsed.config;
3121
+ if (!config || !config.enabled) {
3122
+ return null;
3123
+ }
3124
+ return {
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
3129
+ };
3130
+ } catch {
3131
+ console.warn("[grayscale] Failed to parse grayscale config");
3132
+ return null;
3133
+ }
3134
+ }
3135
+
3136
+ // src/utils/grayscale/identity.ts
3137
+ function readProjectIdentity() {
3138
+ return {
3139
+ appId: process.env.app_id || process.env.APP_ID,
3140
+ tenantId: process.env.tenant_id || process.env.TENANT_ID,
3141
+ xTtEnv: process.env.FORCE_FRAMEWORK_CLI_CANARY_ENV || process.env.x_tt_env
3142
+ };
3143
+ }
3144
+
3145
+ // src/utils/grayscale/types.ts
3146
+ var RuleType = {
3147
+ TenantID: "tenant_id",
3148
+ AppID: "app_id",
3149
+ Canary: "canary",
3150
+ Percentage: "percentage"
3151
+ };
3152
+
3153
+ // src/utils/grayscale/rules.ts
3154
+ var RULE_PRIORITY = {
3155
+ [RuleType.Canary]: 0,
3156
+ [RuleType.AppID]: 1,
3157
+ [RuleType.TenantID]: 2,
3158
+ [RuleType.Percentage]: 3
3159
+ };
3160
+ function sortRulesByPriority(rules) {
3161
+ return [...rules].sort((a, b) => (RULE_PRIORITY[a.type] ?? 99) - (RULE_PRIORITY[b.type] ?? 99));
3162
+ }
3163
+ function isInPercentage(tenantId, percentage) {
3164
+ if (percentage <= 0) return false;
3165
+ if (percentage >= 100) return true;
3166
+ const id = parseInt(tenantId, 10);
3167
+ if (isNaN(id)) return false;
3168
+ return id % 100 < percentage;
3169
+ }
3170
+ function matchRule(rule, identity) {
3171
+ switch (rule.type) {
3172
+ case RuleType.TenantID:
3173
+ return !!identity.tenantId && !!rule.values && rule.values.includes(identity.tenantId);
3174
+ case RuleType.AppID:
3175
+ return !!identity.appId && !!rule.values && rule.values.includes(identity.appId);
3176
+ case RuleType.Canary:
3177
+ return identity.xTtEnv === rule.value;
3178
+ case RuleType.Percentage:
3179
+ if (rule.value >= 100) return true;
3180
+ if (rule.value <= 0) return false;
3181
+ if (!identity.tenantId) return false;
3182
+ return isInPercentage(identity.tenantId, rule.value);
3183
+ default:
3184
+ return false;
3185
+ }
3186
+ }
3187
+ function isBlocked(channel, identity) {
3188
+ if (!channel.block_rules || channel.block_rules.length === 0) return false;
3189
+ return sortRulesByPriority(channel.block_rules).some((rule) => matchRule(rule, identity));
3190
+ }
3191
+ function matchChannel(channel, identity) {
3192
+ if (isBlocked(channel, identity)) return false;
3193
+ if (!channel.rules || channel.rules.length === 0) return false;
3194
+ return sortRulesByPriority(channel.rules).some((rule) => matchRule(rule, identity));
3195
+ }
3196
+ function resolveTargetVersions(config, identity) {
3197
+ const stableVersions = config.stable?.versions || {};
3198
+ const matchedChannel = (config.channels || []).find((ch) => matchChannel(ch, identity));
3199
+ const merged = /* @__PURE__ */ new Map();
3200
+ for (const [pkg2, version] of Object.entries(stableVersions)) {
3201
+ merged.set(pkg2, version);
3202
+ }
3203
+ if (matchedChannel) {
3204
+ console.log(`[grayscale] Matched channel: ${matchedChannel.name}`);
3205
+ for (const [pkg2, version] of Object.entries(matchedChannel.versions || {})) {
3206
+ merged.set(pkg2, version);
3207
+ }
3208
+ } else {
3209
+ console.log("[grayscale] No channel matched, use stable");
3210
+ }
3211
+ return merged.size > 0 ? merged : null;
3212
+ }
3213
+
3214
+ // src/utils/grayscale/index.ts
3215
+ function resolveGrayscaleVersions(_cwd, configJson) {
3216
+ const result = getGrayscaleConfig(configJson);
3217
+ if (!result) {
3218
+ console.log("[grayscale] Config not available, skipping grayscale");
3219
+ return null;
3220
+ }
3221
+ const { config, tenantId: payloadTenantId, appId: payloadAppId, xTtEnv: payloadXTtEnv } = result;
3222
+ const envIdentity = readProjectIdentity();
3223
+ const identity = {
3224
+ appId: payloadAppId || envIdentity.appId,
3225
+ tenantId: payloadTenantId || envIdentity.tenantId,
3226
+ xTtEnv: payloadXTtEnv || envIdentity.xTtEnv
3227
+ };
3228
+ console.log(
3229
+ `[grayscale] Project identity: appId=${identity.appId || "N/A"}, tenantId=${identity.tenantId || "N/A"}, xTtEnv=${identity.xTtEnv || "N/A"}`
3230
+ );
3231
+ const versions = resolveTargetVersions(config, identity);
3232
+ if (!versions || versions.size === 0) {
3233
+ console.log("[grayscale] No target versions resolved");
3234
+ return null;
3235
+ }
3236
+ console.log(`[grayscale] Resolved ${versions.size} package version(s):`);
3237
+ for (const [pkg2, ver] of versions) {
3238
+ console.log(`[grayscale] ${pkg2} -> ${ver}`);
3239
+ }
3240
+ return versions;
3241
+ }
3242
+
3243
+ // src/commands/upgrade/deps/run.handler.ts
3244
+ function parseSemver(version) {
3245
+ const match = version.match(/^(\d+)\.(\d+)\.(\d+)/);
3246
+ if (!match) return null;
3247
+ return [parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10)];
3248
+ }
3249
+ function compareSemver(a, b) {
3250
+ const va = parseSemver(a);
3251
+ const vb = parseSemver(b);
3252
+ if (!va || !vb) return 0;
3253
+ for (let i = 0; i < 3; i++) {
3254
+ if (va[i] < vb[i]) return -1;
3255
+ if (va[i] > vb[i]) return 1;
3256
+ }
3257
+ return 0;
3258
+ }
3259
+ function satisfiesCaret(installed, range) {
3260
+ const baseVersion = range.slice(1);
3261
+ const base = parseSemver(baseVersion);
3262
+ const inst = parseSemver(installed);
3263
+ if (!base || !inst) return false;
3264
+ if (compareSemver(installed, baseVersion) < 0) return false;
3265
+ if (inst[0] > base[0]) return false;
3266
+ return true;
3267
+ }
3268
+ function isRangeVersion(version) {
3269
+ return version.startsWith("^");
3270
+ }
3108
3271
  function findLarkAapaasPackages(cwd, filterPackages) {
3109
3272
  const pkg2 = readPackageJson(cwd);
3110
3273
  const allPackages = /* @__PURE__ */ new Set();
@@ -3157,11 +3320,70 @@ function upgradePackages(packages, version, cwd) {
3157
3320
  });
3158
3321
  }
3159
3322
  }
3323
+ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode) {
3324
+ const upgradePlan = [];
3325
+ for (const pkg2 of packages) {
3326
+ const version = grayscaleVersions.get(pkg2);
3327
+ if (version) {
3328
+ let current = "";
3329
+ try {
3330
+ const installedPkgPath = path8.join(cwd, "node_modules", pkg2, "package.json");
3331
+ const installedPkg = JSON.parse(fs10.readFileSync(installedPkgPath, "utf-8"));
3332
+ current = installedPkg.version || "";
3333
+ } catch (err) {
3334
+ const code = err?.code;
3335
+ if (code !== "ENOENT") {
3336
+ console.warn(`[fullstack-cli] Failed to read installed version of ${pkg2}: ${err instanceof Error ? err.message : String(err)}`);
3337
+ }
3338
+ }
3339
+ if (mode === "destroy") {
3340
+ if (!isRangeVersion(version) && current === version) {
3341
+ console.log(`[fullstack-cli] ${pkg2}@${version} (already installed, skip)`);
3342
+ continue;
3343
+ }
3344
+ } else {
3345
+ if (isRangeVersion(version)) {
3346
+ if (current && satisfiesCaret(current, version)) {
3347
+ console.log(`[fullstack-cli] ${pkg2}@${current} satisfies ${version} (skip)`);
3348
+ continue;
3349
+ }
3350
+ } else {
3351
+ if (current === version) {
3352
+ console.log(`[fullstack-cli] ${pkg2}@${version} (already installed, skip)`);
3353
+ continue;
3354
+ }
3355
+ }
3356
+ }
3357
+ upgradePlan.push({ pkg: pkg2, version, current });
3358
+ }
3359
+ }
3360
+ if (upgradePlan.length === 0) {
3361
+ console.log("[fullstack-cli] No grayscale versions matched current packages");
3362
+ return;
3363
+ }
3364
+ console.log(`[fullstack-cli] Grayscale upgrade plan (${upgradePlan.length} package(s)):`);
3365
+ upgradePlan.forEach(({ pkg: pkg2, version, current }) => {
3366
+ console.log(` - ${pkg2} ${current} -> ${version}`);
3367
+ });
3368
+ if (dryRun) {
3369
+ console.log("[fullstack-cli] Dry run mode, skipping actual installation");
3370
+ return;
3371
+ }
3372
+ const targets = upgradePlan.map(({ pkg: pkg2, version }) => `${pkg2}@${version}`);
3373
+ console.log(`[fullstack-cli] Installing ${targets.join(" ")}...`);
3374
+ const result = spawnSync3("npm", ["install", ...targets], {
3375
+ cwd,
3376
+ stdio: "inherit"
3377
+ });
3378
+ if (result.error || result.status !== 0) {
3379
+ console.warn(`[fullstack-cli] npm install failed: ${result.error?.message ?? `exit ${result.status}`}`);
3380
+ }
3381
+ }
3160
3382
  async function run4(options = {}) {
3161
3383
  const cwd = process.env.INIT_CWD || process.cwd();
3162
3384
  console.log("[fullstack-cli] Starting dependencies upgrade...");
3163
3385
  try {
3164
- console.log("[fullstack-cli] Step 1/2: Scanning @lark-apaas dependencies...");
3386
+ console.log("[fullstack-cli] Step 1/3: Scanning @lark-apaas dependencies...");
3165
3387
  const packages = findLarkAapaasPackages(cwd, options.packages);
3166
3388
  if (packages.length === 0) {
3167
3389
  console.log("[fullstack-cli] No @lark-apaas packages found");
@@ -3169,7 +3391,38 @@ async function run4(options = {}) {
3169
3391
  }
3170
3392
  console.log(`[fullstack-cli] Found ${packages.length} @lark-apaas package(s):`);
3171
3393
  packages.forEach((p) => console.log(` - ${p}`));
3172
- console.log("[fullstack-cli] Step 2/2: Upgrading packages...");
3394
+ if (options.skipGrayscale) {
3395
+ console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (--skip-grayscale)");
3396
+ } else if (options.version) {
3397
+ console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (explicit --version provided)");
3398
+ } else if (!options.grayscaleConfig) {
3399
+ console.log("[fullstack-cli] Step 2/3: No grayscale config, falling back to default upgrade");
3400
+ } else {
3401
+ console.log("[fullstack-cli] Step 2/3: Checking grayscale config...");
3402
+ try {
3403
+ const grayscaleVersions = resolveGrayscaleVersions(cwd, options.grayscaleConfig);
3404
+ if (grayscaleVersions) {
3405
+ console.log("[fullstack-cli] Step 3/3: Applying grayscale versions...");
3406
+ installGrayscaleVersions(packages, grayscaleVersions, cwd, !!options.dryRun, options.mode || "rebuild");
3407
+ if (!options.dryRun) {
3408
+ console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s) via grayscale`);
3409
+ console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
3410
+ }
3411
+ } else {
3412
+ console.log("[fullstack-cli] Grayscale config provided but not available, skip upgrade");
3413
+ }
3414
+ } catch (error) {
3415
+ const msg = error instanceof Error ? error.message : String(error);
3416
+ console.warn(`[fullstack-cli] Grayscale check failed: ${msg}, skip upgrade`);
3417
+ }
3418
+ return;
3419
+ }
3420
+ if (options.dryRun) {
3421
+ console.log("[fullstack-cli] Dry run mode: would upgrade via npm update (no grayscale)");
3422
+ packages.forEach((p) => console.log(` - ${p} -> ${options.version || "latest compatible"}`));
3423
+ return;
3424
+ }
3425
+ console.log("[fullstack-cli] Step 3/3: Upgrading packages...");
3173
3426
  upgradePackages(packages, options.version, cwd);
3174
3427
  console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s)`);
3175
3428
  console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
@@ -3185,7 +3438,7 @@ var depsCommand = {
3185
3438
  name: "deps",
3186
3439
  description: "Upgrade @lark-apaas dependencies",
3187
3440
  register(parentCommand) {
3188
- parentCommand.command(this.name).description(this.description).option("--version <version>", "Upgrade to specific version").option("--packages <packages>", "Only upgrade specific packages (comma-separated)").action(async (options) => {
3441
+ parentCommand.command(this.name).description(this.description).option("--version <version>", "Upgrade to specific version").option("--packages <packages>", "Only upgrade specific packages (comma-separated)").option("--skip-grayscale", "Skip grayscale version check").option("--grayscale-config <json>", "Grayscale config JSON (injected by sandbox_console)").option("--dry-run", "Show upgrade plan without executing").option("--mode <mode>", "Execution mode: rebuild (default) or destroy", "rebuild").action(async (options) => {
3189
3442
  await run4(options);
3190
3443
  });
3191
3444
  }
@@ -3204,8 +3457,8 @@ var upgradeCommand = {
3204
3457
  };
3205
3458
 
3206
3459
  // src/commands/action-plugin/utils.ts
3207
- import fs10 from "fs";
3208
- import path8 from "path";
3460
+ import fs11 from "fs";
3461
+ import path9 from "path";
3209
3462
  import { spawnSync as spawnSync4, execSync as execSync2 } from "child_process";
3210
3463
  function parsePluginName(input) {
3211
3464
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
@@ -3223,18 +3476,18 @@ function getProjectRoot() {
3223
3476
  return process.cwd();
3224
3477
  }
3225
3478
  function getPackageJsonPath() {
3226
- return path8.join(getProjectRoot(), "package.json");
3479
+ return path9.join(getProjectRoot(), "package.json");
3227
3480
  }
3228
3481
  function getPluginPath(pluginName) {
3229
- return path8.join(getProjectRoot(), "node_modules", pluginName);
3482
+ return path9.join(getProjectRoot(), "node_modules", pluginName);
3230
3483
  }
3231
3484
  function readPackageJson2() {
3232
3485
  const pkgPath = getPackageJsonPath();
3233
- if (!fs10.existsSync(pkgPath)) {
3486
+ if (!fs11.existsSync(pkgPath)) {
3234
3487
  throw new Error("package.json not found in current directory");
3235
3488
  }
3236
3489
  try {
3237
- const content = fs10.readFileSync(pkgPath, "utf-8");
3490
+ const content = fs11.readFileSync(pkgPath, "utf-8");
3238
3491
  return JSON.parse(content);
3239
3492
  } catch {
3240
3493
  throw new Error("Failed to parse package.json");
@@ -3242,7 +3495,7 @@ function readPackageJson2() {
3242
3495
  }
3243
3496
  function writePackageJson2(pkg2) {
3244
3497
  const pkgPath = getPackageJsonPath();
3245
- fs10.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3498
+ fs11.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3246
3499
  }
3247
3500
  function readActionPlugins() {
3248
3501
  const pkg2 = readPackageJson2();
@@ -3275,12 +3528,12 @@ function npmInstall(tgzPath) {
3275
3528
  }
3276
3529
  }
3277
3530
  function getPackageVersion(pluginName) {
3278
- const pkgJsonPath = path8.join(getPluginPath(pluginName), "package.json");
3279
- if (!fs10.existsSync(pkgJsonPath)) {
3531
+ const pkgJsonPath = path9.join(getPluginPath(pluginName), "package.json");
3532
+ if (!fs11.existsSync(pkgJsonPath)) {
3280
3533
  return null;
3281
3534
  }
3282
3535
  try {
3283
- const content = fs10.readFileSync(pkgJsonPath, "utf-8");
3536
+ const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3284
3537
  const pkg2 = JSON.parse(content);
3285
3538
  return pkg2.version || null;
3286
3539
  } catch {
@@ -3288,49 +3541,49 @@ function getPackageVersion(pluginName) {
3288
3541
  }
3289
3542
  }
3290
3543
  function readPluginPackageJson(pluginPath) {
3291
- const pkgJsonPath = path8.join(pluginPath, "package.json");
3292
- if (!fs10.existsSync(pkgJsonPath)) {
3544
+ const pkgJsonPath = path9.join(pluginPath, "package.json");
3545
+ if (!fs11.existsSync(pkgJsonPath)) {
3293
3546
  return null;
3294
3547
  }
3295
3548
  try {
3296
- const content = fs10.readFileSync(pkgJsonPath, "utf-8");
3549
+ const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3297
3550
  return JSON.parse(content);
3298
3551
  } catch {
3299
3552
  return null;
3300
3553
  }
3301
3554
  }
3302
3555
  function extractTgzToNodeModules(tgzPath, pluginName) {
3303
- const nodeModulesPath = path8.join(getProjectRoot(), "node_modules");
3304
- const targetDir = path8.join(nodeModulesPath, pluginName);
3305
- const scopeDir = path8.dirname(targetDir);
3306
- if (!fs10.existsSync(scopeDir)) {
3307
- fs10.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 });
3308
3561
  }
3309
- if (fs10.existsSync(targetDir)) {
3310
- fs10.rmSync(targetDir, { recursive: true });
3562
+ if (fs11.existsSync(targetDir)) {
3563
+ fs11.rmSync(targetDir, { recursive: true });
3311
3564
  }
3312
- const tempDir = path8.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3313
- if (fs10.existsSync(tempDir)) {
3314
- fs10.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 });
3315
3568
  }
3316
- fs10.mkdirSync(tempDir, { recursive: true });
3569
+ fs11.mkdirSync(tempDir, { recursive: true });
3317
3570
  try {
3318
3571
  execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
3319
- const extractedDir = path8.join(tempDir, "package");
3320
- if (fs10.existsSync(extractedDir)) {
3321
- fs10.renameSync(extractedDir, targetDir);
3572
+ const extractedDir = path9.join(tempDir, "package");
3573
+ if (fs11.existsSync(extractedDir)) {
3574
+ fs11.renameSync(extractedDir, targetDir);
3322
3575
  } else {
3323
- const files = fs10.readdirSync(tempDir);
3576
+ const files = fs11.readdirSync(tempDir);
3324
3577
  if (files.length === 1) {
3325
- fs10.renameSync(path8.join(tempDir, files[0]), targetDir);
3578
+ fs11.renameSync(path9.join(tempDir, files[0]), targetDir);
3326
3579
  } else {
3327
3580
  throw new Error("Unexpected tgz structure");
3328
3581
  }
3329
3582
  }
3330
3583
  return targetDir;
3331
3584
  } finally {
3332
- if (fs10.existsSync(tempDir)) {
3333
- fs10.rmSync(tempDir, { recursive: true });
3585
+ if (fs11.existsSync(tempDir)) {
3586
+ fs11.rmSync(tempDir, { recursive: true });
3334
3587
  }
3335
3588
  }
3336
3589
  }
@@ -3339,10 +3592,10 @@ function checkMissingPeerDeps(peerDeps) {
3339
3592
  return [];
3340
3593
  }
3341
3594
  const missing = [];
3342
- const nodeModulesPath = path8.join(getProjectRoot(), "node_modules");
3595
+ const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
3343
3596
  for (const [depName, _version] of Object.entries(peerDeps)) {
3344
- const depPath = path8.join(nodeModulesPath, depName);
3345
- if (!fs10.existsSync(depPath)) {
3597
+ const depPath = path9.join(nodeModulesPath, depName);
3598
+ if (!fs11.existsSync(depPath)) {
3346
3599
  missing.push(depName);
3347
3600
  }
3348
3601
  }
@@ -3366,16 +3619,16 @@ function installMissingDeps(deps) {
3366
3619
  }
3367
3620
  function removePluginDirectory(pluginName) {
3368
3621
  const pluginPath = getPluginPath(pluginName);
3369
- if (fs10.existsSync(pluginPath)) {
3370
- fs10.rmSync(pluginPath, { recursive: true });
3622
+ if (fs11.existsSync(pluginPath)) {
3623
+ fs11.rmSync(pluginPath, { recursive: true });
3371
3624
  console.log(`[action-plugin] Removed ${pluginName}`);
3372
3625
  }
3373
3626
  }
3374
3627
 
3375
3628
  // src/commands/action-plugin/api-client.ts
3376
3629
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
3377
- import fs11 from "fs";
3378
- import path9 from "path";
3630
+ import fs12 from "fs";
3631
+ import path10 from "path";
3379
3632
  var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
3380
3633
  async function getPluginVersions(keys, latestOnly = true) {
3381
3634
  const client = getHttpClient();
@@ -3439,19 +3692,19 @@ async function downloadFromPublic(downloadURL) {
3439
3692
  return Buffer.from(arrayBuffer);
3440
3693
  }
3441
3694
  function getPluginCacheDir() {
3442
- return path9.join(process.cwd(), PLUGIN_CACHE_DIR);
3695
+ return path10.join(process.cwd(), PLUGIN_CACHE_DIR);
3443
3696
  }
3444
3697
  function ensureCacheDir() {
3445
3698
  const cacheDir = getPluginCacheDir();
3446
- if (!fs11.existsSync(cacheDir)) {
3447
- fs11.mkdirSync(cacheDir, { recursive: true });
3699
+ if (!fs12.existsSync(cacheDir)) {
3700
+ fs12.mkdirSync(cacheDir, { recursive: true });
3448
3701
  }
3449
3702
  }
3450
3703
  function getTempFilePath(pluginKey, version) {
3451
3704
  ensureCacheDir();
3452
3705
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3453
3706
  const filename = `${safeKey}@${version}.tgz`;
3454
- return path9.join(getPluginCacheDir(), filename);
3707
+ return path10.join(getPluginCacheDir(), filename);
3455
3708
  }
3456
3709
  var MAX_RETRIES = 2;
3457
3710
  async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
@@ -3488,7 +3741,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
3488
3741
  );
3489
3742
  }
3490
3743
  const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
3491
- fs11.writeFileSync(tgzPath, tgzBuffer);
3744
+ fs12.writeFileSync(tgzPath, tgzBuffer);
3492
3745
  console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
3493
3746
  return {
3494
3747
  tgzPath,
@@ -3502,18 +3755,18 @@ function getCachePath(pluginKey, version) {
3502
3755
  ensureCacheDir();
3503
3756
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3504
3757
  const filename = `${safeKey}@${version}.tgz`;
3505
- return path9.join(getPluginCacheDir(), filename);
3758
+ return path10.join(getPluginCacheDir(), filename);
3506
3759
  }
3507
3760
  function hasCachedPlugin(pluginKey, version) {
3508
3761
  const cachePath = getCachePath(pluginKey, version);
3509
- return fs11.existsSync(cachePath);
3762
+ return fs12.existsSync(cachePath);
3510
3763
  }
3511
3764
  function listCachedPlugins() {
3512
3765
  const cacheDir = getPluginCacheDir();
3513
- if (!fs11.existsSync(cacheDir)) {
3766
+ if (!fs12.existsSync(cacheDir)) {
3514
3767
  return [];
3515
3768
  }
3516
- const files = fs11.readdirSync(cacheDir);
3769
+ const files = fs12.readdirSync(cacheDir);
3517
3770
  const result = [];
3518
3771
  for (const file of files) {
3519
3772
  if (!file.endsWith(".tgz")) continue;
@@ -3521,8 +3774,8 @@ function listCachedPlugins() {
3521
3774
  if (!match) continue;
3522
3775
  const [, rawName, version] = match;
3523
3776
  const name = rawName.replace(/^_/, "@").replace(/_/, "/");
3524
- const filePath = path9.join(cacheDir, file);
3525
- const stat = fs11.statSync(filePath);
3777
+ const filePath = path10.join(cacheDir, file);
3778
+ const stat = fs12.statSync(filePath);
3526
3779
  result.push({
3527
3780
  name,
3528
3781
  version,
@@ -3535,14 +3788,14 @@ function listCachedPlugins() {
3535
3788
  }
3536
3789
  function cleanAllCache() {
3537
3790
  const cacheDir = getPluginCacheDir();
3538
- if (!fs11.existsSync(cacheDir)) {
3791
+ if (!fs12.existsSync(cacheDir)) {
3539
3792
  return 0;
3540
3793
  }
3541
- const files = fs11.readdirSync(cacheDir);
3794
+ const files = fs12.readdirSync(cacheDir);
3542
3795
  let count = 0;
3543
3796
  for (const file of files) {
3544
3797
  if (file.endsWith(".tgz")) {
3545
- fs11.unlinkSync(path9.join(cacheDir, file));
3798
+ fs12.unlinkSync(path10.join(cacheDir, file));
3546
3799
  count++;
3547
3800
  }
3548
3801
  }
@@ -3550,21 +3803,21 @@ function cleanAllCache() {
3550
3803
  }
3551
3804
  function cleanPluginCache(pluginKey, version) {
3552
3805
  const cacheDir = getPluginCacheDir();
3553
- if (!fs11.existsSync(cacheDir)) {
3806
+ if (!fs12.existsSync(cacheDir)) {
3554
3807
  return 0;
3555
3808
  }
3556
3809
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3557
- const files = fs11.readdirSync(cacheDir);
3810
+ const files = fs12.readdirSync(cacheDir);
3558
3811
  let count = 0;
3559
3812
  for (const file of files) {
3560
3813
  if (version) {
3561
3814
  if (file === `${safeKey}@${version}.tgz`) {
3562
- fs11.unlinkSync(path9.join(cacheDir, file));
3815
+ fs12.unlinkSync(path10.join(cacheDir, file));
3563
3816
  count++;
3564
3817
  }
3565
3818
  } else {
3566
3819
  if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
3567
- fs11.unlinkSync(path9.join(cacheDir, file));
3820
+ fs12.unlinkSync(path10.join(cacheDir, file));
3568
3821
  count++;
3569
3822
  }
3570
3823
  }
@@ -3991,40 +4244,40 @@ var actionPluginCommandGroup = {
3991
4244
  };
3992
4245
 
3993
4246
  // src/commands/capability/utils.ts
3994
- import fs12 from "fs";
4247
+ import fs13 from "fs";
3995
4248
  import { createRequire as createRequire2 } from "module";
3996
- import path10 from "path";
4249
+ import path11 from "path";
3997
4250
  var CAPABILITIES_DIR = "server/capabilities";
3998
4251
  function getProjectRoot2() {
3999
4252
  return process.cwd();
4000
4253
  }
4001
4254
  function getCapabilitiesDir() {
4002
- return path10.join(getProjectRoot2(), CAPABILITIES_DIR);
4255
+ return path11.join(getProjectRoot2(), CAPABILITIES_DIR);
4003
4256
  }
4004
4257
  function getCapabilityPath(id) {
4005
- return path10.join(getCapabilitiesDir(), `${id}.json`);
4258
+ return path11.join(getCapabilitiesDir(), `${id}.json`);
4006
4259
  }
4007
4260
  function getPluginManifestPath(pluginKey) {
4008
- return path10.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4261
+ return path11.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4009
4262
  }
4010
4263
  function capabilitiesDirExists() {
4011
- return fs12.existsSync(getCapabilitiesDir());
4264
+ return fs13.existsSync(getCapabilitiesDir());
4012
4265
  }
4013
4266
  function listCapabilityIds() {
4014
4267
  const dir = getCapabilitiesDir();
4015
- if (!fs12.existsSync(dir)) {
4268
+ if (!fs13.existsSync(dir)) {
4016
4269
  return [];
4017
4270
  }
4018
- const files = fs12.readdirSync(dir);
4271
+ const files = fs13.readdirSync(dir);
4019
4272
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
4020
4273
  }
4021
4274
  function readCapability(id) {
4022
4275
  const filePath = getCapabilityPath(id);
4023
- if (!fs12.existsSync(filePath)) {
4276
+ if (!fs13.existsSync(filePath)) {
4024
4277
  throw new Error(`Capability not found: ${id}`);
4025
4278
  }
4026
4279
  try {
4027
- const content = fs12.readFileSync(filePath, "utf-8");
4280
+ const content = fs13.readFileSync(filePath, "utf-8");
4028
4281
  return JSON.parse(content);
4029
4282
  } catch (error) {
4030
4283
  if (error instanceof SyntaxError) {
@@ -4051,11 +4304,11 @@ function readAllCapabilities() {
4051
4304
  }
4052
4305
  function readPluginManifest(pluginKey) {
4053
4306
  const manifestPath = getPluginManifestPath(pluginKey);
4054
- if (!fs12.existsSync(manifestPath)) {
4307
+ if (!fs13.existsSync(manifestPath)) {
4055
4308
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
4056
4309
  }
4057
4310
  try {
4058
- const content = fs12.readFileSync(manifestPath, "utf-8");
4311
+ const content = fs13.readFileSync(manifestPath, "utf-8");
4059
4312
  return JSON.parse(content);
4060
4313
  } catch (error) {
4061
4314
  if (error instanceof SyntaxError) {
@@ -4072,7 +4325,7 @@ function hasValidParamsSchema(paramsSchema) {
4072
4325
  }
4073
4326
  async function loadPlugin(pluginKey) {
4074
4327
  try {
4075
- const userRequire = createRequire2(path10.join(getProjectRoot2(), "package.json"));
4328
+ const userRequire = createRequire2(path11.join(getProjectRoot2(), "package.json"));
4076
4329
  const resolvedPath = userRequire.resolve(pluginKey);
4077
4330
  const pluginModule = await import(resolvedPath);
4078
4331
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -4235,8 +4488,8 @@ var capabilityCommandGroup = {
4235
4488
  import { execFile } from "child_process";
4236
4489
 
4237
4490
  // src/commands/component/registry-preparer.ts
4238
- import fs13 from "fs";
4239
- import path11 from "path";
4491
+ import fs14 from "fs";
4492
+ import path12 from "path";
4240
4493
  import os from "os";
4241
4494
 
4242
4495
  // src/commands/component/service.ts
@@ -4292,7 +4545,7 @@ async function sendInstallEvent(key) {
4292
4545
  }
4293
4546
 
4294
4547
  // src/commands/component/registry-preparer.ts
4295
- var REGISTRY_TEMP_DIR = path11.join(os.tmpdir(), "miaoda-registry");
4548
+ var REGISTRY_TEMP_DIR = path12.join(os.tmpdir(), "miaoda-registry");
4296
4549
  function parseComponentKey(key) {
4297
4550
  const match = key.match(/^@([^/]+)\/(.+)$/);
4298
4551
  if (!match) {
@@ -4304,11 +4557,11 @@ function parseComponentKey(key) {
4304
4557
  }
4305
4558
  function getLocalRegistryPath(key) {
4306
4559
  const { scope, name } = parseComponentKey(key);
4307
- return path11.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4560
+ return path12.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4308
4561
  }
4309
4562
  function ensureDir(dirPath) {
4310
- if (!fs13.existsSync(dirPath)) {
4311
- fs13.mkdirSync(dirPath, { recursive: true });
4563
+ if (!fs14.existsSync(dirPath)) {
4564
+ fs14.mkdirSync(dirPath, { recursive: true });
4312
4565
  }
4313
4566
  }
4314
4567
  async function prepareRecursive(key, visited) {
@@ -4341,8 +4594,8 @@ async function prepareRecursive(key, visited) {
4341
4594
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
4342
4595
  };
4343
4596
  const localPath = getLocalRegistryPath(key);
4344
- ensureDir(path11.dirname(localPath));
4345
- fs13.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");
4346
4599
  debug("\u4FDD\u5B58\u5230: %s", localPath);
4347
4600
  }
4348
4601
  async function prepareComponentRegistryItems(id) {
@@ -4352,18 +4605,18 @@ async function prepareComponentRegistryItems(id) {
4352
4605
  }
4353
4606
  function cleanupTempDir() {
4354
4607
  try {
4355
- if (fs13.existsSync(REGISTRY_TEMP_DIR)) {
4356
- fs13.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 });
4357
4610
  }
4358
4611
  } catch {
4359
4612
  }
4360
4613
  }
4361
4614
  function getDownloadedRegistryItem(itemId) {
4362
4615
  const localPath = getLocalRegistryPath(itemId);
4363
- if (!fs13.existsSync(localPath)) {
4616
+ if (!fs14.existsSync(localPath)) {
4364
4617
  return null;
4365
4618
  }
4366
- const content = fs13.readFileSync(localPath, "utf-8");
4619
+ const content = fs14.readFileSync(localPath, "utf-8");
4367
4620
  return JSON.parse(content);
4368
4621
  }
4369
4622
 
@@ -4531,58 +4784,58 @@ var componentCommandGroup = {
4531
4784
  };
4532
4785
 
4533
4786
  // src/commands/migration/version-manager.ts
4534
- import fs14 from "fs";
4535
- import path12 from "path";
4787
+ import fs15 from "fs";
4788
+ import path13 from "path";
4536
4789
  var PACKAGE_JSON = "package.json";
4537
4790
  var VERSION_FIELD = "migrationVersion";
4538
4791
  function getPackageJsonPath2() {
4539
- return path12.join(process.cwd(), PACKAGE_JSON);
4792
+ return path13.join(process.cwd(), PACKAGE_JSON);
4540
4793
  }
4541
4794
  function getCurrentVersion() {
4542
4795
  const pkgPath = getPackageJsonPath2();
4543
- if (!fs14.existsSync(pkgPath)) {
4796
+ if (!fs15.existsSync(pkgPath)) {
4544
4797
  throw new Error("package.json not found");
4545
4798
  }
4546
- const pkg2 = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
4799
+ const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
4547
4800
  return pkg2[VERSION_FIELD] ?? 0;
4548
4801
  }
4549
4802
  function setCurrentVersion(version) {
4550
4803
  const pkgPath = getPackageJsonPath2();
4551
- const pkg2 = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
4804
+ const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
4552
4805
  pkg2[VERSION_FIELD] = version;
4553
- fs14.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4806
+ fs15.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4554
4807
  }
4555
4808
 
4556
4809
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4557
- import fs16 from "fs";
4558
- import path14 from "path";
4810
+ import fs17 from "fs";
4811
+ import path15 from "path";
4559
4812
 
4560
4813
  // src/commands/migration/versions/v001_capability/utils.ts
4561
- import fs15 from "fs";
4562
- import path13 from "path";
4814
+ import fs16 from "fs";
4815
+ import path14 from "path";
4563
4816
  var CAPABILITIES_DIR2 = "server/capabilities";
4564
4817
  function getProjectRoot3() {
4565
4818
  return process.cwd();
4566
4819
  }
4567
4820
  function getCapabilitiesDir2() {
4568
- return path13.join(getProjectRoot3(), CAPABILITIES_DIR2);
4821
+ return path14.join(getProjectRoot3(), CAPABILITIES_DIR2);
4569
4822
  }
4570
4823
  function getPluginManifestPath2(pluginKey) {
4571
- return path13.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4824
+ return path14.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4572
4825
  }
4573
4826
 
4574
4827
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4575
4828
  function detectJsonMigration() {
4576
4829
  const capabilitiesDir = getCapabilitiesDir2();
4577
- const oldFilePath = path14.join(capabilitiesDir, "capabilities.json");
4578
- if (!fs16.existsSync(oldFilePath)) {
4830
+ const oldFilePath = path15.join(capabilitiesDir, "capabilities.json");
4831
+ if (!fs17.existsSync(oldFilePath)) {
4579
4832
  return {
4580
4833
  needsMigration: false,
4581
4834
  reason: "capabilities.json not found"
4582
4835
  };
4583
4836
  }
4584
4837
  try {
4585
- const content = fs16.readFileSync(oldFilePath, "utf-8");
4838
+ const content = fs17.readFileSync(oldFilePath, "utf-8");
4586
4839
  const parsed = JSON.parse(content);
4587
4840
  if (!Array.isArray(parsed)) {
4588
4841
  return {
@@ -4633,8 +4886,8 @@ async function check(options) {
4633
4886
  }
4634
4887
 
4635
4888
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
4636
- import fs17 from "fs";
4637
- import path15 from "path";
4889
+ import fs18 from "fs";
4890
+ import path16 from "path";
4638
4891
 
4639
4892
  // src/commands/migration/versions/v001_capability/mapping.ts
4640
4893
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -4864,18 +5117,18 @@ function transformCapabilities(oldCapabilities) {
4864
5117
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
4865
5118
  function loadExistingCapabilities() {
4866
5119
  const capabilitiesDir = getCapabilitiesDir2();
4867
- if (!fs17.existsSync(capabilitiesDir)) {
5120
+ if (!fs18.existsSync(capabilitiesDir)) {
4868
5121
  return [];
4869
5122
  }
4870
- const files = fs17.readdirSync(capabilitiesDir);
5123
+ const files = fs18.readdirSync(capabilitiesDir);
4871
5124
  const capabilities = [];
4872
5125
  for (const file of files) {
4873
5126
  if (file === "capabilities.json" || !file.endsWith(".json")) {
4874
5127
  continue;
4875
5128
  }
4876
5129
  try {
4877
- const filePath = path15.join(capabilitiesDir, file);
4878
- const content = fs17.readFileSync(filePath, "utf-8");
5130
+ const filePath = path16.join(capabilitiesDir, file);
5131
+ const content = fs18.readFileSync(filePath, "utf-8");
4879
5132
  const capability = JSON.parse(content);
4880
5133
  if (capability.id && capability.pluginKey) {
4881
5134
  capabilities.push(capability);
@@ -4933,9 +5186,9 @@ async function migrateJsonFiles(options) {
4933
5186
  }
4934
5187
  const capabilitiesDir = getCapabilitiesDir2();
4935
5188
  for (const cap of newCapabilities) {
4936
- const filePath = path15.join(capabilitiesDir, `${cap.id}.json`);
5189
+ const filePath = path16.join(capabilitiesDir, `${cap.id}.json`);
4937
5190
  const content = JSON.stringify(cap, null, 2);
4938
- fs17.writeFileSync(filePath, content, "utf-8");
5191
+ fs18.writeFileSync(filePath, content, "utf-8");
4939
5192
  console.log(` \u2713 Created: ${cap.id}.json`);
4940
5193
  }
4941
5194
  return {
@@ -4947,11 +5200,11 @@ async function migrateJsonFiles(options) {
4947
5200
  }
4948
5201
 
4949
5202
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
4950
- import fs18 from "fs";
5203
+ import fs19 from "fs";
4951
5204
  function isPluginInstalled2(pluginKey) {
4952
5205
  const actionPlugins = readActionPlugins();
4953
5206
  const manifestPath = getPluginManifestPath2(pluginKey);
4954
- return fs18.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5207
+ return fs19.existsSync(manifestPath) && !!actionPlugins[pluginKey];
4955
5208
  }
4956
5209
  function detectPluginsToInstall(capabilities) {
4957
5210
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -5027,12 +5280,12 @@ async function installPlugins(capabilities, options) {
5027
5280
  }
5028
5281
 
5029
5282
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
5030
- import path17 from "path";
5283
+ import path18 from "path";
5031
5284
  import { Project as Project3 } from "ts-morph";
5032
5285
 
5033
5286
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
5034
- import fs19 from "fs";
5035
- import path16 from "path";
5287
+ import fs20 from "fs";
5288
+ import path17 from "path";
5036
5289
  var EXCLUDED_DIRS = [
5037
5290
  "node_modules",
5038
5291
  "dist",
@@ -5047,9 +5300,9 @@ var EXCLUDED_PATTERNS = [
5047
5300
  /\.d\.ts$/
5048
5301
  ];
5049
5302
  function scanDirectory(dir, files = []) {
5050
- const entries = fs19.readdirSync(dir, { withFileTypes: true });
5303
+ const entries = fs20.readdirSync(dir, { withFileTypes: true });
5051
5304
  for (const entry of entries) {
5052
- const fullPath = path16.join(dir, entry.name);
5305
+ const fullPath = path17.join(dir, entry.name);
5053
5306
  if (entry.isDirectory()) {
5054
5307
  if (EXCLUDED_DIRS.includes(entry.name)) {
5055
5308
  continue;
@@ -5065,14 +5318,14 @@ function scanDirectory(dir, files = []) {
5065
5318
  return files;
5066
5319
  }
5067
5320
  function scanServerFiles() {
5068
- const serverDir = path16.join(getProjectRoot3(), "server");
5069
- if (!fs19.existsSync(serverDir)) {
5321
+ const serverDir = path17.join(getProjectRoot3(), "server");
5322
+ if (!fs20.existsSync(serverDir)) {
5070
5323
  return [];
5071
5324
  }
5072
5325
  return scanDirectory(serverDir);
5073
5326
  }
5074
5327
  function hasCapabilityImport(filePath) {
5075
- const content = fs19.readFileSync(filePath, "utf-8");
5328
+ const content = fs20.readFileSync(filePath, "utf-8");
5076
5329
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
5077
5330
  }
5078
5331
  function scanFilesToMigrate() {
@@ -5449,7 +5702,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5449
5702
  const callSites = analyzeCallSites(sourceFile, imports);
5450
5703
  const classInfo = analyzeClass(sourceFile);
5451
5704
  const { canMigrate, reason } = canAutoMigrate(classInfo);
5452
- const relativePath = path17.relative(getProjectRoot3(), filePath);
5705
+ const relativePath = path18.relative(getProjectRoot3(), filePath);
5453
5706
  return {
5454
5707
  filePath: relativePath,
5455
5708
  imports,
@@ -5460,7 +5713,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5460
5713
  };
5461
5714
  }
5462
5715
  function migrateFile(project, analysis, dryRun) {
5463
- const absolutePath = path17.join(getProjectRoot3(), analysis.filePath);
5716
+ const absolutePath = path18.join(getProjectRoot3(), analysis.filePath);
5464
5717
  if (!analysis.canAutoMigrate) {
5465
5718
  return {
5466
5719
  filePath: analysis.filePath,
@@ -5563,17 +5816,17 @@ function getSuggestion(analysis) {
5563
5816
  }
5564
5817
 
5565
5818
  // src/commands/migration/versions/v001_capability/cleanup.ts
5566
- import fs20 from "fs";
5567
- import path18 from "path";
5819
+ import fs21 from "fs";
5820
+ import path19 from "path";
5568
5821
  function cleanupOldFiles(capabilities, dryRun) {
5569
5822
  const deletedFiles = [];
5570
5823
  const errors = [];
5571
5824
  const capabilitiesDir = getCapabilitiesDir2();
5572
- const oldJsonPath = path18.join(capabilitiesDir, "capabilities.json");
5573
- if (fs20.existsSync(oldJsonPath)) {
5825
+ const oldJsonPath = path19.join(capabilitiesDir, "capabilities.json");
5826
+ if (fs21.existsSync(oldJsonPath)) {
5574
5827
  try {
5575
5828
  if (!dryRun) {
5576
- fs20.unlinkSync(oldJsonPath);
5829
+ fs21.unlinkSync(oldJsonPath);
5577
5830
  }
5578
5831
  deletedFiles.push("capabilities.json");
5579
5832
  } catch (error) {
@@ -5581,11 +5834,11 @@ function cleanupOldFiles(capabilities, dryRun) {
5581
5834
  }
5582
5835
  }
5583
5836
  for (const cap of capabilities) {
5584
- const tsFilePath = path18.join(capabilitiesDir, `${cap.id}.ts`);
5585
- if (fs20.existsSync(tsFilePath)) {
5837
+ const tsFilePath = path19.join(capabilitiesDir, `${cap.id}.ts`);
5838
+ if (fs21.existsSync(tsFilePath)) {
5586
5839
  try {
5587
5840
  if (!dryRun) {
5588
- fs20.unlinkSync(tsFilePath);
5841
+ fs21.unlinkSync(tsFilePath);
5589
5842
  }
5590
5843
  deletedFiles.push(`${cap.id}.ts`);
5591
5844
  } catch (error) {
@@ -5601,8 +5854,8 @@ function cleanupOldFiles(capabilities, dryRun) {
5601
5854
  }
5602
5855
 
5603
5856
  // src/commands/migration/versions/v001_capability/report-generator.ts
5604
- import fs21 from "fs";
5605
- import path19 from "path";
5857
+ import fs22 from "fs";
5858
+ import path20 from "path";
5606
5859
  var REPORT_FILE = "capability-migration-report.md";
5607
5860
  function printSummary(result) {
5608
5861
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -5765,15 +6018,15 @@ async function generateReport(result) {
5765
6018
  }
5766
6019
  lines.push("");
5767
6020
  const logDir = process.env.LOG_DIR || "logs";
5768
- if (!fs21.existsSync(logDir)) {
6021
+ if (!fs22.existsSync(logDir)) {
5769
6022
  return;
5770
6023
  }
5771
- const reportDir = path19.join(logDir, "migration");
5772
- if (!fs21.existsSync(reportDir)) {
5773
- fs21.mkdirSync(reportDir, { recursive: true });
6024
+ const reportDir = path20.join(logDir, "migration");
6025
+ if (!fs22.existsSync(reportDir)) {
6026
+ fs22.mkdirSync(reportDir, { recursive: true });
5774
6027
  }
5775
- const reportPath = path19.join(reportDir, REPORT_FILE);
5776
- fs21.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6028
+ const reportPath = path20.join(reportDir, REPORT_FILE);
6029
+ fs22.writeFileSync(reportPath, lines.join("\n"), "utf-8");
5777
6030
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
5778
6031
  }
5779
6032
 
@@ -6305,10 +6558,10 @@ var migrationCommand = {
6305
6558
  };
6306
6559
 
6307
6560
  // src/commands/read-logs/index.ts
6308
- import path20 from "path";
6561
+ import path21 from "path";
6309
6562
 
6310
6563
  // src/commands/read-logs/std-utils.ts
6311
- import fs22 from "fs";
6564
+ import fs23 from "fs";
6312
6565
  function formatStdPrefixTime(localTime) {
6313
6566
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
6314
6567
  if (!match) return localTime;
@@ -6338,11 +6591,11 @@ function stripPrefixFromStdLine(line) {
6338
6591
  return `[${time}] ${content}`;
6339
6592
  }
6340
6593
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
6341
- const stat = fs22.statSync(filePath);
6594
+ const stat = fs23.statSync(filePath);
6342
6595
  if (stat.size === 0) {
6343
6596
  return { lines: [], markerFound: false, totalLinesCount: 0 };
6344
6597
  }
6345
- const fd = fs22.openSync(filePath, "r");
6598
+ const fd = fs23.openSync(filePath, "r");
6346
6599
  const chunkSize = 64 * 1024;
6347
6600
  let position = stat.size;
6348
6601
  let remainder = "";
@@ -6356,7 +6609,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6356
6609
  const length = Math.min(chunkSize, position);
6357
6610
  position -= length;
6358
6611
  const buffer = Buffer.alloc(length);
6359
- fs22.readSync(fd, buffer, 0, length, position);
6612
+ fs23.readSync(fd, buffer, 0, length, position);
6360
6613
  let chunk = buffer.toString("utf8");
6361
6614
  if (remainder) {
6362
6615
  chunk += remainder;
@@ -6398,7 +6651,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6398
6651
  }
6399
6652
  }
6400
6653
  } finally {
6401
- fs22.closeSync(fd);
6654
+ fs23.closeSync(fd);
6402
6655
  }
6403
6656
  return { lines: collected.reverse(), markerFound, totalLinesCount };
6404
6657
  }
@@ -6419,21 +6672,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
6419
6672
  }
6420
6673
 
6421
6674
  // src/commands/read-logs/tail.ts
6422
- import fs23 from "fs";
6675
+ import fs24 from "fs";
6423
6676
  function fileExists(filePath) {
6424
6677
  try {
6425
- fs23.accessSync(filePath, fs23.constants.F_OK | fs23.constants.R_OK);
6678
+ fs24.accessSync(filePath, fs24.constants.F_OK | fs24.constants.R_OK);
6426
6679
  return true;
6427
6680
  } catch {
6428
6681
  return false;
6429
6682
  }
6430
6683
  }
6431
6684
  function readFileTailLines(filePath, maxLines) {
6432
- const stat = fs23.statSync(filePath);
6685
+ const stat = fs24.statSync(filePath);
6433
6686
  if (stat.size === 0) {
6434
6687
  return [];
6435
6688
  }
6436
- const fd = fs23.openSync(filePath, "r");
6689
+ const fd = fs24.openSync(filePath, "r");
6437
6690
  const chunkSize = 64 * 1024;
6438
6691
  const chunks = [];
6439
6692
  let position = stat.size;
@@ -6443,13 +6696,13 @@ function readFileTailLines(filePath, maxLines) {
6443
6696
  const length = Math.min(chunkSize, position);
6444
6697
  position -= length;
6445
6698
  const buffer = Buffer.alloc(length);
6446
- fs23.readSync(fd, buffer, 0, length, position);
6699
+ fs24.readSync(fd, buffer, 0, length, position);
6447
6700
  chunks.unshift(buffer.toString("utf8"));
6448
6701
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
6449
6702
  collectedLines += chunkLines;
6450
6703
  }
6451
6704
  } finally {
6452
- fs23.closeSync(fd);
6705
+ fs24.closeSync(fd);
6453
6706
  }
6454
6707
  const content = chunks.join("");
6455
6708
  const allLines = content.split("\n");
@@ -6465,11 +6718,11 @@ function readFileTailLines(filePath, maxLines) {
6465
6718
  return allLines.slice(allLines.length - maxLines);
6466
6719
  }
6467
6720
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6468
- const stat = fs23.statSync(filePath);
6721
+ const stat = fs24.statSync(filePath);
6469
6722
  if (stat.size === 0) {
6470
6723
  return { lines: [], totalLinesCount: 0 };
6471
6724
  }
6472
- const fd = fs23.openSync(filePath, "r");
6725
+ const fd = fs24.openSync(filePath, "r");
6473
6726
  const chunkSize = 64 * 1024;
6474
6727
  let position = stat.size;
6475
6728
  let remainder = "";
@@ -6481,7 +6734,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6481
6734
  const length = Math.min(chunkSize, position);
6482
6735
  position -= length;
6483
6736
  const buffer = Buffer.alloc(length);
6484
- fs23.readSync(fd, buffer, 0, length, position);
6737
+ fs24.readSync(fd, buffer, 0, length, position);
6485
6738
  let chunk = buffer.toString("utf8");
6486
6739
  if (remainder) {
6487
6740
  chunk += remainder;
@@ -6512,7 +6765,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6512
6765
  }
6513
6766
  }
6514
6767
  } finally {
6515
- fs23.closeSync(fd);
6768
+ fs24.closeSync(fd);
6516
6769
  }
6517
6770
  return { lines: collected.reverse(), totalLinesCount };
6518
6771
  }
@@ -6654,7 +6907,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
6654
6907
  }
6655
6908
 
6656
6909
  // src/commands/read-logs/json-lines.ts
6657
- import fs24 from "fs";
6910
+ import fs25 from "fs";
6658
6911
  function normalizePid(value) {
6659
6912
  if (typeof value === "number") {
6660
6913
  return String(value);
@@ -6705,11 +6958,11 @@ function buildWantedLevelSet(levels) {
6705
6958
  return set.size > 0 ? set : null;
6706
6959
  }
6707
6960
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
6708
- const stat = fs24.statSync(filePath);
6961
+ const stat = fs25.statSync(filePath);
6709
6962
  if (stat.size === 0) {
6710
6963
  return { lines: [], totalLinesCount: 0 };
6711
6964
  }
6712
- const fd = fs24.openSync(filePath, "r");
6965
+ const fd = fs25.openSync(filePath, "r");
6713
6966
  const chunkSize = 64 * 1024;
6714
6967
  let position = stat.size;
6715
6968
  let remainder = "";
@@ -6724,7 +6977,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
6724
6977
  const length = Math.min(chunkSize, position);
6725
6978
  position -= length;
6726
6979
  const buffer = Buffer.alloc(length);
6727
- fs24.readSync(fd, buffer, 0, length, position);
6980
+ fs25.readSync(fd, buffer, 0, length, position);
6728
6981
  let chunk = buffer.toString("utf8");
6729
6982
  if (remainder) {
6730
6983
  chunk += remainder;
@@ -6786,7 +7039,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
6786
7039
  }
6787
7040
  }
6788
7041
  } finally {
6789
- fs24.closeSync(fd);
7042
+ fs25.closeSync(fd);
6790
7043
  }
6791
7044
  return { lines: collected.reverse(), totalLinesCount };
6792
7045
  }
@@ -6829,11 +7082,11 @@ function extractTraceId(obj) {
6829
7082
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
6830
7083
  const wanted = traceId.trim();
6831
7084
  if (!wanted) return { lines: [], totalLinesCount: 0 };
6832
- const stat = fs24.statSync(filePath);
7085
+ const stat = fs25.statSync(filePath);
6833
7086
  if (stat.size === 0) {
6834
7087
  return { lines: [], totalLinesCount: 0 };
6835
7088
  }
6836
- const fd = fs24.openSync(filePath, "r");
7089
+ const fd = fs25.openSync(filePath, "r");
6837
7090
  const chunkSize = 64 * 1024;
6838
7091
  let position = stat.size;
6839
7092
  let remainder = "";
@@ -6846,7 +7099,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
6846
7099
  const length = Math.min(chunkSize, position);
6847
7100
  position -= length;
6848
7101
  const buffer = Buffer.alloc(length);
6849
- fs24.readSync(fd, buffer, 0, length, position);
7102
+ fs25.readSync(fd, buffer, 0, length, position);
6850
7103
  let chunk = buffer.toString("utf8");
6851
7104
  if (remainder) {
6852
7105
  chunk += remainder;
@@ -6899,7 +7152,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
6899
7152
  }
6900
7153
  }
6901
7154
  } finally {
6902
- fs24.closeSync(fd);
7155
+ fs25.closeSync(fd);
6903
7156
  }
6904
7157
  return { lines: collected.reverse(), totalLinesCount };
6905
7158
  }
@@ -6908,11 +7161,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
6908
7161
  if (!wantedLevelSet) {
6909
7162
  return { lines: [], totalLinesCount: 0 };
6910
7163
  }
6911
- const stat = fs24.statSync(filePath);
7164
+ const stat = fs25.statSync(filePath);
6912
7165
  if (stat.size === 0) {
6913
7166
  return { lines: [], totalLinesCount: 0 };
6914
7167
  }
6915
- const fd = fs24.openSync(filePath, "r");
7168
+ const fd = fs25.openSync(filePath, "r");
6916
7169
  const chunkSize = 64 * 1024;
6917
7170
  let position = stat.size;
6918
7171
  let remainder = "";
@@ -6924,7 +7177,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
6924
7177
  const length = Math.min(chunkSize, position);
6925
7178
  position -= length;
6926
7179
  const buffer = Buffer.alloc(length);
6927
- fs24.readSync(fd, buffer, 0, length, position);
7180
+ fs25.readSync(fd, buffer, 0, length, position);
6928
7181
  let chunk = buffer.toString("utf8");
6929
7182
  if (remainder) {
6930
7183
  chunk += remainder;
@@ -6971,7 +7224,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
6971
7224
  }
6972
7225
  }
6973
7226
  } finally {
6974
- fs24.closeSync(fd);
7227
+ fs25.closeSync(fd);
6975
7228
  }
6976
7229
  return { lines: collected.reverse(), totalLinesCount };
6977
7230
  }
@@ -7205,30 +7458,30 @@ async function readLogsJsonResult(options) {
7205
7458
  };
7206
7459
  }
7207
7460
  function resolveLogFilePath(logDir, type) {
7208
- const base = path20.isAbsolute(logDir) ? logDir : path20.join(process.cwd(), logDir);
7461
+ const base = path21.isAbsolute(logDir) ? logDir : path21.join(process.cwd(), logDir);
7209
7462
  if (type === "server") {
7210
- return path20.join(base, "server.log");
7463
+ return path21.join(base, "server.log");
7211
7464
  }
7212
7465
  if (type === "trace") {
7213
- return path20.join(base, "trace.log");
7466
+ return path21.join(base, "trace.log");
7214
7467
  }
7215
7468
  if (type === "server-std") {
7216
- return path20.join(base, "server.std.log");
7469
+ return path21.join(base, "server.std.log");
7217
7470
  }
7218
7471
  if (type === "client-std") {
7219
- return path20.join(base, "client.std.log");
7472
+ return path21.join(base, "client.std.log");
7220
7473
  }
7221
7474
  if (type === "dev") {
7222
- return path20.join(base, "dev.log");
7475
+ return path21.join(base, "dev.log");
7223
7476
  }
7224
7477
  if (type === "dev-std") {
7225
- return path20.join(base, "dev.std.log");
7478
+ return path21.join(base, "dev.std.log");
7226
7479
  }
7227
7480
  if (type === "install-dep-std") {
7228
- return path20.join(base, "install-dep.std.log");
7481
+ return path21.join(base, "install-dep.std.log");
7229
7482
  }
7230
7483
  if (type === "browser") {
7231
- return path20.join(base, "browser.log");
7484
+ return path21.join(base, "browser.log");
7232
7485
  }
7233
7486
  throw new Error(`Unsupported log type: ${type}`);
7234
7487
  }
@@ -7405,9 +7658,9 @@ function camelToKebab(str) {
7405
7658
  }
7406
7659
 
7407
7660
  // src/commands/build/upload-static.handler.ts
7408
- import * as fs25 from "fs";
7661
+ import * as fs26 from "fs";
7409
7662
  import * as os2 from "os";
7410
- import * as path21 from "path";
7663
+ import * as path22 from "path";
7411
7664
  import { execFileSync } from "child_process";
7412
7665
  function readCredentialsFromEnv() {
7413
7666
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -7431,8 +7684,8 @@ async function uploadStatic(options) {
7431
7684
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7432
7685
  region = UPLOAD_STATIC_DEFAULTS.region
7433
7686
  } = options;
7434
- const resolvedStaticDir = path21.resolve(staticDir);
7435
- if (!fs25.existsSync(resolvedStaticDir)) {
7687
+ const resolvedStaticDir = path22.resolve(staticDir);
7688
+ if (!fs26.existsSync(resolvedStaticDir)) {
7436
7689
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7437
7690
  return;
7438
7691
  }
@@ -7465,8 +7718,8 @@ async function uploadStatic(options) {
7465
7718
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7466
7719
  }
7467
7720
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7468
- const confPath = path21.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7469
- fs25.writeFileSync(confPath, "");
7721
+ const confPath = path22.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7722
+ fs26.writeFileSync(confPath, "");
7470
7723
  try {
7471
7724
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7472
7725
  configureTosutil(resolvedTosutil, confPath, {
@@ -7480,7 +7733,7 @@ async function uploadStatic(options) {
7480
7733
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7481
7734
  } finally {
7482
7735
  try {
7483
- fs25.unlinkSync(confPath);
7736
+ fs26.unlinkSync(confPath);
7484
7737
  } catch {
7485
7738
  }
7486
7739
  }
@@ -7500,8 +7753,8 @@ async function uploadStatic(options) {
7500
7753
  }
7501
7754
  }
7502
7755
  function resolveTosutilPath(tosutilPath) {
7503
- if (path21.isAbsolute(tosutilPath)) {
7504
- return fs25.existsSync(tosutilPath) ? tosutilPath : null;
7756
+ if (path22.isAbsolute(tosutilPath)) {
7757
+ return fs26.existsSync(tosutilPath) ? tosutilPath : null;
7505
7758
  }
7506
7759
  try {
7507
7760
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -7546,7 +7799,7 @@ async function resolveBucketId(appId) {
7546
7799
  return bucketId;
7547
7800
  }
7548
7801
  function isDirEmpty(dirPath) {
7549
- const entries = fs25.readdirSync(dirPath);
7802
+ const entries = fs26.readdirSync(dirPath);
7550
7803
  return entries.length === 0;
7551
7804
  }
7552
7805
 
@@ -7641,12 +7894,12 @@ var commands = [
7641
7894
  ];
7642
7895
 
7643
7896
  // src/index.ts
7644
- var envPath = path22.join(process.cwd(), ".env");
7645
- if (fs26.existsSync(envPath)) {
7897
+ var envPath = path23.join(process.cwd(), ".env");
7898
+ if (fs27.existsSync(envPath)) {
7646
7899
  dotenvConfig({ path: envPath });
7647
7900
  }
7648
- var __dirname = path22.dirname(fileURLToPath5(import.meta.url));
7649
- var pkg = JSON.parse(fs26.readFileSync(path22.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"));
7650
7903
  var cli = new FullstackCLI(pkg.version);
7651
7904
  cli.useAll(commands);
7652
7905
  cli.run();