@lark-apaas/fullstack-cli 1.1.40-alpha.0 → 1.1.40-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
- import fs28 from "fs";
3
- import path24 from "path";
2
+ import fs26 from "fs";
3
+ import path22 from "path";
4
4
  import { fileURLToPath as fileURLToPath5 } from "url";
5
5
  import { config as dotenvConfig } from "dotenv";
6
6
 
@@ -3105,309 +3105,6 @@ async function run3(options = {}) {
3105
3105
 
3106
3106
  // src/commands/upgrade/deps/run.handler.ts
3107
3107
  import { spawnSync as spawnSync3 } from "child_process";
3108
-
3109
- // src/utils/grayscale/cache.ts
3110
- import fs10 from "fs";
3111
- import path8 from "path";
3112
- import os from "os";
3113
- var CACHE_PATH = path8.join(os.homedir(), ".fullstack", "grayscale-cache.json");
3114
- var NORMAL_TTL_MS = 30 * 60 * 1e3;
3115
- var FALLBACK_TTL_MS = 24 * 60 * 60 * 1e3;
3116
- function readLocalCache(fallback = false) {
3117
- try {
3118
- if (!fs10.existsSync(CACHE_PATH)) {
3119
- return null;
3120
- }
3121
- const content = fs10.readFileSync(CACHE_PATH, "utf-8");
3122
- const entry = JSON.parse(content);
3123
- if (!entry.config || !entry.timestamp) {
3124
- return null;
3125
- }
3126
- const ttl = fallback ? FALLBACK_TTL_MS : NORMAL_TTL_MS;
3127
- const age = Date.now() - entry.timestamp;
3128
- if (age > ttl) {
3129
- return null;
3130
- }
3131
- return entry.config;
3132
- } catch {
3133
- return null;
3134
- }
3135
- }
3136
- function writeLocalCache(config) {
3137
- try {
3138
- const dir = path8.dirname(CACHE_PATH);
3139
- if (!fs10.existsSync(dir)) {
3140
- fs10.mkdirSync(dir, { recursive: true });
3141
- }
3142
- const entry = {
3143
- config,
3144
- timestamp: Date.now()
3145
- };
3146
- fs10.writeFileSync(CACHE_PATH, JSON.stringify(entry, null, 2), "utf-8");
3147
- } catch {
3148
- }
3149
- }
3150
-
3151
- // src/utils/grayscale/config.ts
3152
- var memoryCache = null;
3153
- var MEMORY_TTL_MS = 60 * 1e3;
3154
- var API_TIMEOUT_MS = 3e3;
3155
- async function fetchFromApi() {
3156
- try {
3157
- const client = getHttpClient();
3158
- const controller = new AbortController();
3159
- const timer = setTimeout(() => controller.abort(), API_TIMEOUT_MS);
3160
- try {
3161
- const response = await client.post(
3162
- "/api/v1/studio/innerapi/get_grayscale_config",
3163
- {},
3164
- { signal: controller.signal }
3165
- );
3166
- if (!response.ok) {
3167
- console.warn(`[grayscale] API request failed: ${response.status} ${response.statusText}`);
3168
- return null;
3169
- }
3170
- const result = await response.json();
3171
- if (result.status_code !== "0") {
3172
- console.warn(`[grayscale] API error: ${result.message}`);
3173
- return null;
3174
- }
3175
- return result.data?.config ?? null;
3176
- } finally {
3177
- clearTimeout(timer);
3178
- }
3179
- } catch (error) {
3180
- const message = error instanceof Error ? error.message : String(error);
3181
- console.warn(`[grayscale] Failed to fetch config from API: ${message}`);
3182
- return null;
3183
- }
3184
- }
3185
- async function getGrayscaleConfig() {
3186
- if (memoryCache) {
3187
- const age = Date.now() - memoryCache.timestamp;
3188
- if (age <= MEMORY_TTL_MS) {
3189
- return memoryCache.config;
3190
- }
3191
- memoryCache = null;
3192
- }
3193
- const localNormal = readLocalCache(false);
3194
- if (localNormal) {
3195
- memoryCache = { config: localNormal, timestamp: Date.now() };
3196
- return localNormal;
3197
- }
3198
- const apiConfig = await fetchFromApi();
3199
- if (apiConfig) {
3200
- memoryCache = { config: apiConfig, timestamp: Date.now() };
3201
- writeLocalCache(apiConfig);
3202
- return apiConfig;
3203
- }
3204
- const localFallback = readLocalCache(true);
3205
- if (localFallback) {
3206
- memoryCache = { config: localFallback, timestamp: Date.now() };
3207
- return localFallback;
3208
- }
3209
- return null;
3210
- }
3211
-
3212
- // src/utils/grayscale/identity.ts
3213
- import fs11 from "fs";
3214
- import path9 from "path";
3215
- function readFromEnvVars() {
3216
- const appId = process.env.app_id || process.env.APP_ID;
3217
- const tenantId = process.env.tenant_id || process.env.TENANT_ID;
3218
- return { appId, tenantId };
3219
- }
3220
- function parseEnvFile(filePath) {
3221
- const result = {};
3222
- if (!fs11.existsSync(filePath)) {
3223
- return result;
3224
- }
3225
- try {
3226
- const content = fs11.readFileSync(filePath, "utf-8");
3227
- const lines = content.split("\n");
3228
- for (const line of lines) {
3229
- const trimmed = line.trim();
3230
- if (!trimmed || trimmed.startsWith("#")) {
3231
- continue;
3232
- }
3233
- const match = trimmed.match(/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=["']?(.+?)["']?$/);
3234
- if (match) {
3235
- result[match[1]] = match[2];
3236
- }
3237
- }
3238
- } catch {
3239
- }
3240
- return result;
3241
- }
3242
- function readFromForceEnvFile(cwd) {
3243
- const envPath2 = path9.join(cwd, ".force", "environment", "env");
3244
- const vars = parseEnvFile(envPath2);
3245
- return {
3246
- appId: vars.app_id || vars.APP_ID,
3247
- tenantId: vars.tenant_id || vars.TENANT_ID
3248
- };
3249
- }
3250
- function readFromClientBasePath() {
3251
- const basePath = process.env.CLIENT_BASE_PATH;
3252
- if (!basePath) {
3253
- return {};
3254
- }
3255
- const afMatch = basePath.match(/\/af\/p\/([^/]+)/);
3256
- if (afMatch) {
3257
- return { appId: afMatch[1] };
3258
- }
3259
- const appMatch = basePath.match(/\/app\/([^/]+)/);
3260
- if (appMatch) {
3261
- return { appId: appMatch[1] };
3262
- }
3263
- return {};
3264
- }
3265
- function readFromDotEnv(cwd) {
3266
- const envPath2 = path9.join(cwd, ".env");
3267
- const vars = parseEnvFile(envPath2);
3268
- return {
3269
- appId: vars.app_id || vars.APP_ID,
3270
- tenantId: vars.tenant_id || vars.TENANT_ID
3271
- };
3272
- }
3273
- function readFromPackageJson(cwd) {
3274
- const pkgPath = path9.join(cwd, "package.json");
3275
- if (!fs11.existsSync(pkgPath)) {
3276
- return {};
3277
- }
3278
- try {
3279
- const content = fs11.readFileSync(pkgPath, "utf-8");
3280
- const pkg2 = JSON.parse(content);
3281
- const appId = pkg2?.fullstack?.appId;
3282
- return appId ? { appId } : {};
3283
- } catch {
3284
- return {};
3285
- }
3286
- }
3287
- function readProjectIdentity(cwd) {
3288
- const sources = [
3289
- () => readFromEnvVars(),
3290
- () => readFromForceEnvFile(cwd),
3291
- () => readFromClientBasePath(),
3292
- () => readFromDotEnv(cwd),
3293
- () => readFromPackageJson(cwd)
3294
- ];
3295
- const merged = {};
3296
- for (const source of sources) {
3297
- const identity = source();
3298
- if (!merged.appId && identity.appId) {
3299
- merged.appId = identity.appId;
3300
- }
3301
- if (!merged.tenantId && identity.tenantId) {
3302
- merged.tenantId = identity.tenantId;
3303
- }
3304
- if (merged.appId && merged.tenantId) {
3305
- break;
3306
- }
3307
- }
3308
- return merged;
3309
- }
3310
-
3311
- // src/utils/grayscale/rules.ts
3312
- import { createHash } from "crypto";
3313
- function isInPercentage(key, percentage) {
3314
- if (percentage <= 0) return false;
3315
- if (percentage >= 100) return true;
3316
- const hash = createHash("md5").update(`grayscale:${key}`).digest("hex");
3317
- const value = parseInt(hash.substring(0, 8), 16) % 1e4;
3318
- const threshold = Math.floor(percentage * 100);
3319
- return value < threshold;
3320
- }
3321
- function matchConditions(rule, identity) {
3322
- const { conditions } = rule;
3323
- if (conditions.tenant_ids && conditions.tenant_ids.length > 0) {
3324
- if (identity.tenantId && conditions.tenant_ids.includes(identity.tenantId)) {
3325
- return true;
3326
- }
3327
- }
3328
- if (conditions.app_ids && conditions.app_ids.length > 0) {
3329
- if (identity.appId && conditions.app_ids.includes(identity.appId)) {
3330
- return true;
3331
- }
3332
- }
3333
- if (conditions.percentage != null && conditions.percentage > 0) {
3334
- const hashKey = conditions.hash_key || "app_id";
3335
- const hashValue = hashKey === "tenant_id" ? identity.tenantId : identity.appId;
3336
- if (hashValue && isInPercentage(hashValue, conditions.percentage)) {
3337
- return true;
3338
- }
3339
- }
3340
- const hasConditions = conditions.tenant_ids && conditions.tenant_ids.length > 0 || conditions.app_ids && conditions.app_ids.length > 0 || conditions.percentage != null && conditions.percentage > 0;
3341
- return !hasConditions;
3342
- }
3343
- function evaluateRules(config, identity) {
3344
- const enabledRules = config.rules.filter((rule) => rule.enabled).sort((a, b) => b.priority - a.priority);
3345
- for (const rule of enabledRules) {
3346
- if (matchConditions(rule, identity)) {
3347
- return rule;
3348
- }
3349
- }
3350
- return null;
3351
- }
3352
- function resolveTargetVersions(config, identity) {
3353
- const matchedRule = evaluateRules(config, identity);
3354
- const channelName = matchedRule?.channel || config.default_channel;
3355
- const channel = config.channels[channelName];
3356
- if (!channel) {
3357
- console.warn(`[grayscale] Channel "${channelName}" not found in config`);
3358
- return null;
3359
- }
3360
- const versions = /* @__PURE__ */ new Map();
3361
- for (const [pkgName, version] of Object.entries(channel.versions)) {
3362
- if (config.blocked_versions?.includes(version)) {
3363
- console.warn(`[grayscale] Version ${version} of ${pkgName} is blocked, skipping`);
3364
- continue;
3365
- }
3366
- versions.set(pkgName, version);
3367
- }
3368
- if (config.force_versions) {
3369
- for (const [pkgName, version] of Object.entries(config.force_versions)) {
3370
- versions.set(pkgName, version);
3371
- }
3372
- }
3373
- if (matchedRule) {
3374
- console.log(`[grayscale] Matched rule: "${matchedRule.name}" (id: ${matchedRule.id}), channel: ${channelName}`);
3375
- } else {
3376
- console.log(`[grayscale] No rule matched, using default channel: ${channelName}`);
3377
- }
3378
- return versions;
3379
- }
3380
-
3381
- // src/utils/grayscale/index.ts
3382
- async function resolveGrayscaleVersions(cwd) {
3383
- const config = await getGrayscaleConfig();
3384
- if (!config) {
3385
- console.log("[grayscale] Config not available, skipping grayscale");
3386
- return null;
3387
- }
3388
- if (!config.enabled) {
3389
- console.log("[grayscale] Grayscale is disabled");
3390
- return null;
3391
- }
3392
- const identity = readProjectIdentity(cwd);
3393
- if (!identity.appId && !identity.tenantId) {
3394
- console.log("[grayscale] No app_id or tenant_id found, skipping grayscale");
3395
- return null;
3396
- }
3397
- console.log(`[grayscale] Project identity: appId=${identity.appId || "N/A"}, tenantId=${identity.tenantId || "N/A"}`);
3398
- const versions = resolveTargetVersions(config, identity);
3399
- if (!versions || versions.size === 0) {
3400
- console.log("[grayscale] No target versions resolved");
3401
- return null;
3402
- }
3403
- console.log(`[grayscale] Resolved ${versions.size} package version(s):`);
3404
- for (const [pkg2, ver] of versions) {
3405
- console.log(`[grayscale] ${pkg2} -> ${ver}`);
3406
- }
3407
- return versions;
3408
- }
3409
-
3410
- // src/commands/upgrade/deps/run.handler.ts
3411
3108
  function findLarkAapaasPackages(cwd, filterPackages) {
3412
3109
  const pkg2 = readPackageJson(cwd);
3413
3110
  const allPackages = /* @__PURE__ */ new Set();
@@ -3460,43 +3157,11 @@ function upgradePackages(packages, version, cwd) {
3460
3157
  });
3461
3158
  }
3462
3159
  }
3463
- function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun) {
3464
- const upgradePlan = [];
3465
- for (const pkg2 of packages) {
3466
- const version = grayscaleVersions.get(pkg2);
3467
- if (version) {
3468
- upgradePlan.push({ pkg: pkg2, version });
3469
- }
3470
- }
3471
- if (upgradePlan.length === 0) {
3472
- console.log("[fullstack-cli] No grayscale versions matched current packages");
3473
- return;
3474
- }
3475
- console.log(`[fullstack-cli] Grayscale upgrade plan (${upgradePlan.length} package(s)):`);
3476
- upgradePlan.forEach(({ pkg: pkg2, version }) => {
3477
- console.log(` - ${pkg2} -> ${version}`);
3478
- });
3479
- if (dryRun) {
3480
- console.log("[fullstack-cli] Dry run mode, skipping actual installation");
3481
- return;
3482
- }
3483
- for (const { pkg: pkg2, version } of upgradePlan) {
3484
- const target = `${pkg2}@${version}`;
3485
- console.log(`[fullstack-cli] Installing ${target}...`);
3486
- const result = spawnSync3("npm", ["install", target], {
3487
- cwd,
3488
- stdio: "inherit"
3489
- });
3490
- if (result.error || result.status !== 0) {
3491
- throw new Error(`Failed to install ${target}`);
3492
- }
3493
- }
3494
- }
3495
3160
  async function run4(options = {}) {
3496
3161
  const cwd = process.env.INIT_CWD || process.cwd();
3497
3162
  console.log("[fullstack-cli] Starting dependencies upgrade...");
3498
3163
  try {
3499
- console.log("[fullstack-cli] Step 1/3: Scanning @lark-apaas dependencies...");
3164
+ console.log("[fullstack-cli] Step 1/2: Scanning @lark-apaas dependencies...");
3500
3165
  const packages = findLarkAapaasPackages(cwd, options.packages);
3501
3166
  if (packages.length === 0) {
3502
3167
  console.log("[fullstack-cli] No @lark-apaas packages found");
@@ -3504,35 +3169,7 @@ async function run4(options = {}) {
3504
3169
  }
3505
3170
  console.log(`[fullstack-cli] Found ${packages.length} @lark-apaas package(s):`);
3506
3171
  packages.forEach((p) => console.log(` - ${p}`));
3507
- if (!options.skipGrayscale && !options.version) {
3508
- console.log("[fullstack-cli] Step 2/3: Checking grayscale config...");
3509
- try {
3510
- const grayscaleVersions = await resolveGrayscaleVersions(cwd);
3511
- if (grayscaleVersions) {
3512
- console.log("[fullstack-cli] Step 3/3: Applying grayscale versions...");
3513
- installGrayscaleVersions(packages, grayscaleVersions, cwd, !!options.dryRun);
3514
- if (!options.dryRun) {
3515
- console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s) via grayscale`);
3516
- console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
3517
- }
3518
- return;
3519
- }
3520
- console.log("[fullstack-cli] Grayscale not available, falling back to default upgrade");
3521
- } catch (error) {
3522
- const msg = error instanceof Error ? error.message : String(error);
3523
- console.warn(`[fullstack-cli] Grayscale check failed: ${msg}, falling back to default upgrade`);
3524
- }
3525
- } else if (options.skipGrayscale) {
3526
- console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (--skip-grayscale)");
3527
- } else {
3528
- console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (explicit --version provided)");
3529
- }
3530
- if (options.dryRun) {
3531
- console.log("[fullstack-cli] Dry run mode: would upgrade via npm update (no grayscale)");
3532
- packages.forEach((p) => console.log(` - ${p} -> ${options.version || "latest compatible"}`));
3533
- return;
3534
- }
3535
- console.log("[fullstack-cli] Step 3/3: Upgrading packages...");
3172
+ console.log("[fullstack-cli] Step 2/2: Upgrading packages...");
3536
3173
  upgradePackages(packages, options.version, cwd);
3537
3174
  console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s)`);
3538
3175
  console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
@@ -3548,7 +3185,7 @@ var depsCommand = {
3548
3185
  name: "deps",
3549
3186
  description: "Upgrade @lark-apaas dependencies",
3550
3187
  register(parentCommand) {
3551
- 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("--dry-run", "Show upgrade plan without executing").action(async (options) => {
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) => {
3552
3189
  await run4(options);
3553
3190
  });
3554
3191
  }
@@ -3567,8 +3204,8 @@ var upgradeCommand = {
3567
3204
  };
3568
3205
 
3569
3206
  // src/commands/action-plugin/utils.ts
3570
- import fs12 from "fs";
3571
- import path10 from "path";
3207
+ import fs10 from "fs";
3208
+ import path8 from "path";
3572
3209
  import { spawnSync as spawnSync4, execSync as execSync2 } from "child_process";
3573
3210
  function parsePluginName(input) {
3574
3211
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
@@ -3586,18 +3223,18 @@ function getProjectRoot() {
3586
3223
  return process.cwd();
3587
3224
  }
3588
3225
  function getPackageJsonPath() {
3589
- return path10.join(getProjectRoot(), "package.json");
3226
+ return path8.join(getProjectRoot(), "package.json");
3590
3227
  }
3591
3228
  function getPluginPath(pluginName) {
3592
- return path10.join(getProjectRoot(), "node_modules", pluginName);
3229
+ return path8.join(getProjectRoot(), "node_modules", pluginName);
3593
3230
  }
3594
3231
  function readPackageJson2() {
3595
3232
  const pkgPath = getPackageJsonPath();
3596
- if (!fs12.existsSync(pkgPath)) {
3233
+ if (!fs10.existsSync(pkgPath)) {
3597
3234
  throw new Error("package.json not found in current directory");
3598
3235
  }
3599
3236
  try {
3600
- const content = fs12.readFileSync(pkgPath, "utf-8");
3237
+ const content = fs10.readFileSync(pkgPath, "utf-8");
3601
3238
  return JSON.parse(content);
3602
3239
  } catch {
3603
3240
  throw new Error("Failed to parse package.json");
@@ -3605,7 +3242,7 @@ function readPackageJson2() {
3605
3242
  }
3606
3243
  function writePackageJson2(pkg2) {
3607
3244
  const pkgPath = getPackageJsonPath();
3608
- fs12.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3245
+ fs10.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3609
3246
  }
3610
3247
  function readActionPlugins() {
3611
3248
  const pkg2 = readPackageJson2();
@@ -3638,12 +3275,12 @@ function npmInstall(tgzPath) {
3638
3275
  }
3639
3276
  }
3640
3277
  function getPackageVersion(pluginName) {
3641
- const pkgJsonPath = path10.join(getPluginPath(pluginName), "package.json");
3642
- if (!fs12.existsSync(pkgJsonPath)) {
3278
+ const pkgJsonPath = path8.join(getPluginPath(pluginName), "package.json");
3279
+ if (!fs10.existsSync(pkgJsonPath)) {
3643
3280
  return null;
3644
3281
  }
3645
3282
  try {
3646
- const content = fs12.readFileSync(pkgJsonPath, "utf-8");
3283
+ const content = fs10.readFileSync(pkgJsonPath, "utf-8");
3647
3284
  const pkg2 = JSON.parse(content);
3648
3285
  return pkg2.version || null;
3649
3286
  } catch {
@@ -3651,49 +3288,49 @@ function getPackageVersion(pluginName) {
3651
3288
  }
3652
3289
  }
3653
3290
  function readPluginPackageJson(pluginPath) {
3654
- const pkgJsonPath = path10.join(pluginPath, "package.json");
3655
- if (!fs12.existsSync(pkgJsonPath)) {
3291
+ const pkgJsonPath = path8.join(pluginPath, "package.json");
3292
+ if (!fs10.existsSync(pkgJsonPath)) {
3656
3293
  return null;
3657
3294
  }
3658
3295
  try {
3659
- const content = fs12.readFileSync(pkgJsonPath, "utf-8");
3296
+ const content = fs10.readFileSync(pkgJsonPath, "utf-8");
3660
3297
  return JSON.parse(content);
3661
3298
  } catch {
3662
3299
  return null;
3663
3300
  }
3664
3301
  }
3665
3302
  function extractTgzToNodeModules(tgzPath, pluginName) {
3666
- const nodeModulesPath = path10.join(getProjectRoot(), "node_modules");
3667
- const targetDir = path10.join(nodeModulesPath, pluginName);
3668
- const scopeDir = path10.dirname(targetDir);
3669
- if (!fs12.existsSync(scopeDir)) {
3670
- fs12.mkdirSync(scopeDir, { recursive: true });
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 });
3671
3308
  }
3672
- if (fs12.existsSync(targetDir)) {
3673
- fs12.rmSync(targetDir, { recursive: true });
3309
+ if (fs10.existsSync(targetDir)) {
3310
+ fs10.rmSync(targetDir, { recursive: true });
3674
3311
  }
3675
- const tempDir = path10.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3676
- if (fs12.existsSync(tempDir)) {
3677
- fs12.rmSync(tempDir, { recursive: true });
3312
+ const tempDir = path8.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3313
+ if (fs10.existsSync(tempDir)) {
3314
+ fs10.rmSync(tempDir, { recursive: true });
3678
3315
  }
3679
- fs12.mkdirSync(tempDir, { recursive: true });
3316
+ fs10.mkdirSync(tempDir, { recursive: true });
3680
3317
  try {
3681
3318
  execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
3682
- const extractedDir = path10.join(tempDir, "package");
3683
- if (fs12.existsSync(extractedDir)) {
3684
- fs12.renameSync(extractedDir, targetDir);
3319
+ const extractedDir = path8.join(tempDir, "package");
3320
+ if (fs10.existsSync(extractedDir)) {
3321
+ fs10.renameSync(extractedDir, targetDir);
3685
3322
  } else {
3686
- const files = fs12.readdirSync(tempDir);
3323
+ const files = fs10.readdirSync(tempDir);
3687
3324
  if (files.length === 1) {
3688
- fs12.renameSync(path10.join(tempDir, files[0]), targetDir);
3325
+ fs10.renameSync(path8.join(tempDir, files[0]), targetDir);
3689
3326
  } else {
3690
3327
  throw new Error("Unexpected tgz structure");
3691
3328
  }
3692
3329
  }
3693
3330
  return targetDir;
3694
3331
  } finally {
3695
- if (fs12.existsSync(tempDir)) {
3696
- fs12.rmSync(tempDir, { recursive: true });
3332
+ if (fs10.existsSync(tempDir)) {
3333
+ fs10.rmSync(tempDir, { recursive: true });
3697
3334
  }
3698
3335
  }
3699
3336
  }
@@ -3702,10 +3339,10 @@ function checkMissingPeerDeps(peerDeps) {
3702
3339
  return [];
3703
3340
  }
3704
3341
  const missing = [];
3705
- const nodeModulesPath = path10.join(getProjectRoot(), "node_modules");
3342
+ const nodeModulesPath = path8.join(getProjectRoot(), "node_modules");
3706
3343
  for (const [depName, _version] of Object.entries(peerDeps)) {
3707
- const depPath = path10.join(nodeModulesPath, depName);
3708
- if (!fs12.existsSync(depPath)) {
3344
+ const depPath = path8.join(nodeModulesPath, depName);
3345
+ if (!fs10.existsSync(depPath)) {
3709
3346
  missing.push(depName);
3710
3347
  }
3711
3348
  }
@@ -3729,16 +3366,16 @@ function installMissingDeps(deps) {
3729
3366
  }
3730
3367
  function removePluginDirectory(pluginName) {
3731
3368
  const pluginPath = getPluginPath(pluginName);
3732
- if (fs12.existsSync(pluginPath)) {
3733
- fs12.rmSync(pluginPath, { recursive: true });
3369
+ if (fs10.existsSync(pluginPath)) {
3370
+ fs10.rmSync(pluginPath, { recursive: true });
3734
3371
  console.log(`[action-plugin] Removed ${pluginName}`);
3735
3372
  }
3736
3373
  }
3737
3374
 
3738
3375
  // src/commands/action-plugin/api-client.ts
3739
3376
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
3740
- import fs13 from "fs";
3741
- import path11 from "path";
3377
+ import fs11 from "fs";
3378
+ import path9 from "path";
3742
3379
  var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
3743
3380
  async function getPluginVersions(keys, latestOnly = true) {
3744
3381
  const client = getHttpClient();
@@ -3802,19 +3439,19 @@ async function downloadFromPublic(downloadURL) {
3802
3439
  return Buffer.from(arrayBuffer);
3803
3440
  }
3804
3441
  function getPluginCacheDir() {
3805
- return path11.join(process.cwd(), PLUGIN_CACHE_DIR);
3442
+ return path9.join(process.cwd(), PLUGIN_CACHE_DIR);
3806
3443
  }
3807
3444
  function ensureCacheDir() {
3808
3445
  const cacheDir = getPluginCacheDir();
3809
- if (!fs13.existsSync(cacheDir)) {
3810
- fs13.mkdirSync(cacheDir, { recursive: true });
3446
+ if (!fs11.existsSync(cacheDir)) {
3447
+ fs11.mkdirSync(cacheDir, { recursive: true });
3811
3448
  }
3812
3449
  }
3813
3450
  function getTempFilePath(pluginKey, version) {
3814
3451
  ensureCacheDir();
3815
3452
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3816
3453
  const filename = `${safeKey}@${version}.tgz`;
3817
- return path11.join(getPluginCacheDir(), filename);
3454
+ return path9.join(getPluginCacheDir(), filename);
3818
3455
  }
3819
3456
  var MAX_RETRIES = 2;
3820
3457
  async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
@@ -3851,7 +3488,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
3851
3488
  );
3852
3489
  }
3853
3490
  const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
3854
- fs13.writeFileSync(tgzPath, tgzBuffer);
3491
+ fs11.writeFileSync(tgzPath, tgzBuffer);
3855
3492
  console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
3856
3493
  return {
3857
3494
  tgzPath,
@@ -3865,18 +3502,18 @@ function getCachePath(pluginKey, version) {
3865
3502
  ensureCacheDir();
3866
3503
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3867
3504
  const filename = `${safeKey}@${version}.tgz`;
3868
- return path11.join(getPluginCacheDir(), filename);
3505
+ return path9.join(getPluginCacheDir(), filename);
3869
3506
  }
3870
3507
  function hasCachedPlugin(pluginKey, version) {
3871
3508
  const cachePath = getCachePath(pluginKey, version);
3872
- return fs13.existsSync(cachePath);
3509
+ return fs11.existsSync(cachePath);
3873
3510
  }
3874
3511
  function listCachedPlugins() {
3875
3512
  const cacheDir = getPluginCacheDir();
3876
- if (!fs13.existsSync(cacheDir)) {
3513
+ if (!fs11.existsSync(cacheDir)) {
3877
3514
  return [];
3878
3515
  }
3879
- const files = fs13.readdirSync(cacheDir);
3516
+ const files = fs11.readdirSync(cacheDir);
3880
3517
  const result = [];
3881
3518
  for (const file of files) {
3882
3519
  if (!file.endsWith(".tgz")) continue;
@@ -3884,8 +3521,8 @@ function listCachedPlugins() {
3884
3521
  if (!match) continue;
3885
3522
  const [, rawName, version] = match;
3886
3523
  const name = rawName.replace(/^_/, "@").replace(/_/, "/");
3887
- const filePath = path11.join(cacheDir, file);
3888
- const stat = fs13.statSync(filePath);
3524
+ const filePath = path9.join(cacheDir, file);
3525
+ const stat = fs11.statSync(filePath);
3889
3526
  result.push({
3890
3527
  name,
3891
3528
  version,
@@ -3898,14 +3535,14 @@ function listCachedPlugins() {
3898
3535
  }
3899
3536
  function cleanAllCache() {
3900
3537
  const cacheDir = getPluginCacheDir();
3901
- if (!fs13.existsSync(cacheDir)) {
3538
+ if (!fs11.existsSync(cacheDir)) {
3902
3539
  return 0;
3903
3540
  }
3904
- const files = fs13.readdirSync(cacheDir);
3541
+ const files = fs11.readdirSync(cacheDir);
3905
3542
  let count = 0;
3906
3543
  for (const file of files) {
3907
3544
  if (file.endsWith(".tgz")) {
3908
- fs13.unlinkSync(path11.join(cacheDir, file));
3545
+ fs11.unlinkSync(path9.join(cacheDir, file));
3909
3546
  count++;
3910
3547
  }
3911
3548
  }
@@ -3913,21 +3550,21 @@ function cleanAllCache() {
3913
3550
  }
3914
3551
  function cleanPluginCache(pluginKey, version) {
3915
3552
  const cacheDir = getPluginCacheDir();
3916
- if (!fs13.existsSync(cacheDir)) {
3553
+ if (!fs11.existsSync(cacheDir)) {
3917
3554
  return 0;
3918
3555
  }
3919
3556
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3920
- const files = fs13.readdirSync(cacheDir);
3557
+ const files = fs11.readdirSync(cacheDir);
3921
3558
  let count = 0;
3922
3559
  for (const file of files) {
3923
3560
  if (version) {
3924
3561
  if (file === `${safeKey}@${version}.tgz`) {
3925
- fs13.unlinkSync(path11.join(cacheDir, file));
3562
+ fs11.unlinkSync(path9.join(cacheDir, file));
3926
3563
  count++;
3927
3564
  }
3928
3565
  } else {
3929
3566
  if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
3930
- fs13.unlinkSync(path11.join(cacheDir, file));
3567
+ fs11.unlinkSync(path9.join(cacheDir, file));
3931
3568
  count++;
3932
3569
  }
3933
3570
  }
@@ -4354,40 +3991,40 @@ var actionPluginCommandGroup = {
4354
3991
  };
4355
3992
 
4356
3993
  // src/commands/capability/utils.ts
4357
- import fs14 from "fs";
3994
+ import fs12 from "fs";
4358
3995
  import { createRequire as createRequire2 } from "module";
4359
- import path12 from "path";
3996
+ import path10 from "path";
4360
3997
  var CAPABILITIES_DIR = "server/capabilities";
4361
3998
  function getProjectRoot2() {
4362
3999
  return process.cwd();
4363
4000
  }
4364
4001
  function getCapabilitiesDir() {
4365
- return path12.join(getProjectRoot2(), CAPABILITIES_DIR);
4002
+ return path10.join(getProjectRoot2(), CAPABILITIES_DIR);
4366
4003
  }
4367
4004
  function getCapabilityPath(id) {
4368
- return path12.join(getCapabilitiesDir(), `${id}.json`);
4005
+ return path10.join(getCapabilitiesDir(), `${id}.json`);
4369
4006
  }
4370
4007
  function getPluginManifestPath(pluginKey) {
4371
- return path12.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4008
+ return path10.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4372
4009
  }
4373
4010
  function capabilitiesDirExists() {
4374
- return fs14.existsSync(getCapabilitiesDir());
4011
+ return fs12.existsSync(getCapabilitiesDir());
4375
4012
  }
4376
4013
  function listCapabilityIds() {
4377
4014
  const dir = getCapabilitiesDir();
4378
- if (!fs14.existsSync(dir)) {
4015
+ if (!fs12.existsSync(dir)) {
4379
4016
  return [];
4380
4017
  }
4381
- const files = fs14.readdirSync(dir);
4018
+ const files = fs12.readdirSync(dir);
4382
4019
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
4383
4020
  }
4384
4021
  function readCapability(id) {
4385
4022
  const filePath = getCapabilityPath(id);
4386
- if (!fs14.existsSync(filePath)) {
4023
+ if (!fs12.existsSync(filePath)) {
4387
4024
  throw new Error(`Capability not found: ${id}`);
4388
4025
  }
4389
4026
  try {
4390
- const content = fs14.readFileSync(filePath, "utf-8");
4027
+ const content = fs12.readFileSync(filePath, "utf-8");
4391
4028
  return JSON.parse(content);
4392
4029
  } catch (error) {
4393
4030
  if (error instanceof SyntaxError) {
@@ -4414,11 +4051,11 @@ function readAllCapabilities() {
4414
4051
  }
4415
4052
  function readPluginManifest(pluginKey) {
4416
4053
  const manifestPath = getPluginManifestPath(pluginKey);
4417
- if (!fs14.existsSync(manifestPath)) {
4054
+ if (!fs12.existsSync(manifestPath)) {
4418
4055
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
4419
4056
  }
4420
4057
  try {
4421
- const content = fs14.readFileSync(manifestPath, "utf-8");
4058
+ const content = fs12.readFileSync(manifestPath, "utf-8");
4422
4059
  return JSON.parse(content);
4423
4060
  } catch (error) {
4424
4061
  if (error instanceof SyntaxError) {
@@ -4435,7 +4072,7 @@ function hasValidParamsSchema(paramsSchema) {
4435
4072
  }
4436
4073
  async function loadPlugin(pluginKey) {
4437
4074
  try {
4438
- const userRequire = createRequire2(path12.join(getProjectRoot2(), "package.json"));
4075
+ const userRequire = createRequire2(path10.join(getProjectRoot2(), "package.json"));
4439
4076
  const resolvedPath = userRequire.resolve(pluginKey);
4440
4077
  const pluginModule = await import(resolvedPath);
4441
4078
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -4598,9 +4235,9 @@ var capabilityCommandGroup = {
4598
4235
  import { execFile } from "child_process";
4599
4236
 
4600
4237
  // src/commands/component/registry-preparer.ts
4601
- import fs15 from "fs";
4602
- import path13 from "path";
4603
- import os2 from "os";
4238
+ import fs13 from "fs";
4239
+ import path11 from "path";
4240
+ import os from "os";
4604
4241
 
4605
4242
  // src/commands/component/service.ts
4606
4243
  import { mapValues } from "es-toolkit";
@@ -4655,7 +4292,7 @@ async function sendInstallEvent(key) {
4655
4292
  }
4656
4293
 
4657
4294
  // src/commands/component/registry-preparer.ts
4658
- var REGISTRY_TEMP_DIR = path13.join(os2.tmpdir(), "miaoda-registry");
4295
+ var REGISTRY_TEMP_DIR = path11.join(os.tmpdir(), "miaoda-registry");
4659
4296
  function parseComponentKey(key) {
4660
4297
  const match = key.match(/^@([^/]+)\/(.+)$/);
4661
4298
  if (!match) {
@@ -4667,11 +4304,11 @@ function parseComponentKey(key) {
4667
4304
  }
4668
4305
  function getLocalRegistryPath(key) {
4669
4306
  const { scope, name } = parseComponentKey(key);
4670
- return path13.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4307
+ return path11.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4671
4308
  }
4672
4309
  function ensureDir(dirPath) {
4673
- if (!fs15.existsSync(dirPath)) {
4674
- fs15.mkdirSync(dirPath, { recursive: true });
4310
+ if (!fs13.existsSync(dirPath)) {
4311
+ fs13.mkdirSync(dirPath, { recursive: true });
4675
4312
  }
4676
4313
  }
4677
4314
  async function prepareRecursive(key, visited) {
@@ -4704,8 +4341,8 @@ async function prepareRecursive(key, visited) {
4704
4341
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
4705
4342
  };
4706
4343
  const localPath = getLocalRegistryPath(key);
4707
- ensureDir(path13.dirname(localPath));
4708
- fs15.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4344
+ ensureDir(path11.dirname(localPath));
4345
+ fs13.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4709
4346
  debug("\u4FDD\u5B58\u5230: %s", localPath);
4710
4347
  }
4711
4348
  async function prepareComponentRegistryItems(id) {
@@ -4715,18 +4352,18 @@ async function prepareComponentRegistryItems(id) {
4715
4352
  }
4716
4353
  function cleanupTempDir() {
4717
4354
  try {
4718
- if (fs15.existsSync(REGISTRY_TEMP_DIR)) {
4719
- fs15.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4355
+ if (fs13.existsSync(REGISTRY_TEMP_DIR)) {
4356
+ fs13.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4720
4357
  }
4721
4358
  } catch {
4722
4359
  }
4723
4360
  }
4724
4361
  function getDownloadedRegistryItem(itemId) {
4725
4362
  const localPath = getLocalRegistryPath(itemId);
4726
- if (!fs15.existsSync(localPath)) {
4363
+ if (!fs13.existsSync(localPath)) {
4727
4364
  return null;
4728
4365
  }
4729
- const content = fs15.readFileSync(localPath, "utf-8");
4366
+ const content = fs13.readFileSync(localPath, "utf-8");
4730
4367
  return JSON.parse(content);
4731
4368
  }
4732
4369
 
@@ -4894,58 +4531,58 @@ var componentCommandGroup = {
4894
4531
  };
4895
4532
 
4896
4533
  // src/commands/migration/version-manager.ts
4897
- import fs16 from "fs";
4898
- import path14 from "path";
4534
+ import fs14 from "fs";
4535
+ import path12 from "path";
4899
4536
  var PACKAGE_JSON = "package.json";
4900
4537
  var VERSION_FIELD = "migrationVersion";
4901
4538
  function getPackageJsonPath2() {
4902
- return path14.join(process.cwd(), PACKAGE_JSON);
4539
+ return path12.join(process.cwd(), PACKAGE_JSON);
4903
4540
  }
4904
4541
  function getCurrentVersion() {
4905
4542
  const pkgPath = getPackageJsonPath2();
4906
- if (!fs16.existsSync(pkgPath)) {
4543
+ if (!fs14.existsSync(pkgPath)) {
4907
4544
  throw new Error("package.json not found");
4908
4545
  }
4909
- const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
4546
+ const pkg2 = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
4910
4547
  return pkg2[VERSION_FIELD] ?? 0;
4911
4548
  }
4912
4549
  function setCurrentVersion(version) {
4913
4550
  const pkgPath = getPackageJsonPath2();
4914
- const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
4551
+ const pkg2 = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
4915
4552
  pkg2[VERSION_FIELD] = version;
4916
- fs16.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4553
+ fs14.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4917
4554
  }
4918
4555
 
4919
4556
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4920
- import fs18 from "fs";
4921
- import path16 from "path";
4557
+ import fs16 from "fs";
4558
+ import path14 from "path";
4922
4559
 
4923
4560
  // src/commands/migration/versions/v001_capability/utils.ts
4924
- import fs17 from "fs";
4925
- import path15 from "path";
4561
+ import fs15 from "fs";
4562
+ import path13 from "path";
4926
4563
  var CAPABILITIES_DIR2 = "server/capabilities";
4927
4564
  function getProjectRoot3() {
4928
4565
  return process.cwd();
4929
4566
  }
4930
4567
  function getCapabilitiesDir2() {
4931
- return path15.join(getProjectRoot3(), CAPABILITIES_DIR2);
4568
+ return path13.join(getProjectRoot3(), CAPABILITIES_DIR2);
4932
4569
  }
4933
4570
  function getPluginManifestPath2(pluginKey) {
4934
- return path15.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4571
+ return path13.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4935
4572
  }
4936
4573
 
4937
4574
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4938
4575
  function detectJsonMigration() {
4939
4576
  const capabilitiesDir = getCapabilitiesDir2();
4940
- const oldFilePath = path16.join(capabilitiesDir, "capabilities.json");
4941
- if (!fs18.existsSync(oldFilePath)) {
4577
+ const oldFilePath = path14.join(capabilitiesDir, "capabilities.json");
4578
+ if (!fs16.existsSync(oldFilePath)) {
4942
4579
  return {
4943
4580
  needsMigration: false,
4944
4581
  reason: "capabilities.json not found"
4945
4582
  };
4946
4583
  }
4947
4584
  try {
4948
- const content = fs18.readFileSync(oldFilePath, "utf-8");
4585
+ const content = fs16.readFileSync(oldFilePath, "utf-8");
4949
4586
  const parsed = JSON.parse(content);
4950
4587
  if (!Array.isArray(parsed)) {
4951
4588
  return {
@@ -4996,8 +4633,8 @@ async function check(options) {
4996
4633
  }
4997
4634
 
4998
4635
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
4999
- import fs19 from "fs";
5000
- import path17 from "path";
4636
+ import fs17 from "fs";
4637
+ import path15 from "path";
5001
4638
 
5002
4639
  // src/commands/migration/versions/v001_capability/mapping.ts
5003
4640
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -5227,18 +4864,18 @@ function transformCapabilities(oldCapabilities) {
5227
4864
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5228
4865
  function loadExistingCapabilities() {
5229
4866
  const capabilitiesDir = getCapabilitiesDir2();
5230
- if (!fs19.existsSync(capabilitiesDir)) {
4867
+ if (!fs17.existsSync(capabilitiesDir)) {
5231
4868
  return [];
5232
4869
  }
5233
- const files = fs19.readdirSync(capabilitiesDir);
4870
+ const files = fs17.readdirSync(capabilitiesDir);
5234
4871
  const capabilities = [];
5235
4872
  for (const file of files) {
5236
4873
  if (file === "capabilities.json" || !file.endsWith(".json")) {
5237
4874
  continue;
5238
4875
  }
5239
4876
  try {
5240
- const filePath = path17.join(capabilitiesDir, file);
5241
- const content = fs19.readFileSync(filePath, "utf-8");
4877
+ const filePath = path15.join(capabilitiesDir, file);
4878
+ const content = fs17.readFileSync(filePath, "utf-8");
5242
4879
  const capability = JSON.parse(content);
5243
4880
  if (capability.id && capability.pluginKey) {
5244
4881
  capabilities.push(capability);
@@ -5296,9 +4933,9 @@ async function migrateJsonFiles(options) {
5296
4933
  }
5297
4934
  const capabilitiesDir = getCapabilitiesDir2();
5298
4935
  for (const cap of newCapabilities) {
5299
- const filePath = path17.join(capabilitiesDir, `${cap.id}.json`);
4936
+ const filePath = path15.join(capabilitiesDir, `${cap.id}.json`);
5300
4937
  const content = JSON.stringify(cap, null, 2);
5301
- fs19.writeFileSync(filePath, content, "utf-8");
4938
+ fs17.writeFileSync(filePath, content, "utf-8");
5302
4939
  console.log(` \u2713 Created: ${cap.id}.json`);
5303
4940
  }
5304
4941
  return {
@@ -5310,11 +4947,11 @@ async function migrateJsonFiles(options) {
5310
4947
  }
5311
4948
 
5312
4949
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
5313
- import fs20 from "fs";
4950
+ import fs18 from "fs";
5314
4951
  function isPluginInstalled2(pluginKey) {
5315
4952
  const actionPlugins = readActionPlugins();
5316
4953
  const manifestPath = getPluginManifestPath2(pluginKey);
5317
- return fs20.existsSync(manifestPath) && !!actionPlugins[pluginKey];
4954
+ return fs18.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5318
4955
  }
5319
4956
  function detectPluginsToInstall(capabilities) {
5320
4957
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -5390,12 +5027,12 @@ async function installPlugins(capabilities, options) {
5390
5027
  }
5391
5028
 
5392
5029
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
5393
- import path19 from "path";
5030
+ import path17 from "path";
5394
5031
  import { Project as Project3 } from "ts-morph";
5395
5032
 
5396
5033
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
5397
- import fs21 from "fs";
5398
- import path18 from "path";
5034
+ import fs19 from "fs";
5035
+ import path16 from "path";
5399
5036
  var EXCLUDED_DIRS = [
5400
5037
  "node_modules",
5401
5038
  "dist",
@@ -5410,9 +5047,9 @@ var EXCLUDED_PATTERNS = [
5410
5047
  /\.d\.ts$/
5411
5048
  ];
5412
5049
  function scanDirectory(dir, files = []) {
5413
- const entries = fs21.readdirSync(dir, { withFileTypes: true });
5050
+ const entries = fs19.readdirSync(dir, { withFileTypes: true });
5414
5051
  for (const entry of entries) {
5415
- const fullPath = path18.join(dir, entry.name);
5052
+ const fullPath = path16.join(dir, entry.name);
5416
5053
  if (entry.isDirectory()) {
5417
5054
  if (EXCLUDED_DIRS.includes(entry.name)) {
5418
5055
  continue;
@@ -5428,14 +5065,14 @@ function scanDirectory(dir, files = []) {
5428
5065
  return files;
5429
5066
  }
5430
5067
  function scanServerFiles() {
5431
- const serverDir = path18.join(getProjectRoot3(), "server");
5432
- if (!fs21.existsSync(serverDir)) {
5068
+ const serverDir = path16.join(getProjectRoot3(), "server");
5069
+ if (!fs19.existsSync(serverDir)) {
5433
5070
  return [];
5434
5071
  }
5435
5072
  return scanDirectory(serverDir);
5436
5073
  }
5437
5074
  function hasCapabilityImport(filePath) {
5438
- const content = fs21.readFileSync(filePath, "utf-8");
5075
+ const content = fs19.readFileSync(filePath, "utf-8");
5439
5076
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
5440
5077
  }
5441
5078
  function scanFilesToMigrate() {
@@ -5812,7 +5449,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5812
5449
  const callSites = analyzeCallSites(sourceFile, imports);
5813
5450
  const classInfo = analyzeClass(sourceFile);
5814
5451
  const { canMigrate, reason } = canAutoMigrate(classInfo);
5815
- const relativePath = path19.relative(getProjectRoot3(), filePath);
5452
+ const relativePath = path17.relative(getProjectRoot3(), filePath);
5816
5453
  return {
5817
5454
  filePath: relativePath,
5818
5455
  imports,
@@ -5823,7 +5460,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5823
5460
  };
5824
5461
  }
5825
5462
  function migrateFile(project, analysis, dryRun) {
5826
- const absolutePath = path19.join(getProjectRoot3(), analysis.filePath);
5463
+ const absolutePath = path17.join(getProjectRoot3(), analysis.filePath);
5827
5464
  if (!analysis.canAutoMigrate) {
5828
5465
  return {
5829
5466
  filePath: analysis.filePath,
@@ -5926,17 +5563,17 @@ function getSuggestion(analysis) {
5926
5563
  }
5927
5564
 
5928
5565
  // src/commands/migration/versions/v001_capability/cleanup.ts
5929
- import fs22 from "fs";
5930
- import path20 from "path";
5566
+ import fs20 from "fs";
5567
+ import path18 from "path";
5931
5568
  function cleanupOldFiles(capabilities, dryRun) {
5932
5569
  const deletedFiles = [];
5933
5570
  const errors = [];
5934
5571
  const capabilitiesDir = getCapabilitiesDir2();
5935
- const oldJsonPath = path20.join(capabilitiesDir, "capabilities.json");
5936
- if (fs22.existsSync(oldJsonPath)) {
5572
+ const oldJsonPath = path18.join(capabilitiesDir, "capabilities.json");
5573
+ if (fs20.existsSync(oldJsonPath)) {
5937
5574
  try {
5938
5575
  if (!dryRun) {
5939
- fs22.unlinkSync(oldJsonPath);
5576
+ fs20.unlinkSync(oldJsonPath);
5940
5577
  }
5941
5578
  deletedFiles.push("capabilities.json");
5942
5579
  } catch (error) {
@@ -5944,11 +5581,11 @@ function cleanupOldFiles(capabilities, dryRun) {
5944
5581
  }
5945
5582
  }
5946
5583
  for (const cap of capabilities) {
5947
- const tsFilePath = path20.join(capabilitiesDir, `${cap.id}.ts`);
5948
- if (fs22.existsSync(tsFilePath)) {
5584
+ const tsFilePath = path18.join(capabilitiesDir, `${cap.id}.ts`);
5585
+ if (fs20.existsSync(tsFilePath)) {
5949
5586
  try {
5950
5587
  if (!dryRun) {
5951
- fs22.unlinkSync(tsFilePath);
5588
+ fs20.unlinkSync(tsFilePath);
5952
5589
  }
5953
5590
  deletedFiles.push(`${cap.id}.ts`);
5954
5591
  } catch (error) {
@@ -5964,8 +5601,8 @@ function cleanupOldFiles(capabilities, dryRun) {
5964
5601
  }
5965
5602
 
5966
5603
  // src/commands/migration/versions/v001_capability/report-generator.ts
5967
- import fs23 from "fs";
5968
- import path21 from "path";
5604
+ import fs21 from "fs";
5605
+ import path19 from "path";
5969
5606
  var REPORT_FILE = "capability-migration-report.md";
5970
5607
  function printSummary(result) {
5971
5608
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -6128,15 +5765,15 @@ async function generateReport(result) {
6128
5765
  }
6129
5766
  lines.push("");
6130
5767
  const logDir = process.env.LOG_DIR || "logs";
6131
- if (!fs23.existsSync(logDir)) {
5768
+ if (!fs21.existsSync(logDir)) {
6132
5769
  return;
6133
5770
  }
6134
- const reportDir = path21.join(logDir, "migration");
6135
- if (!fs23.existsSync(reportDir)) {
6136
- fs23.mkdirSync(reportDir, { recursive: true });
5771
+ const reportDir = path19.join(logDir, "migration");
5772
+ if (!fs21.existsSync(reportDir)) {
5773
+ fs21.mkdirSync(reportDir, { recursive: true });
6137
5774
  }
6138
- const reportPath = path21.join(reportDir, REPORT_FILE);
6139
- fs23.writeFileSync(reportPath, lines.join("\n"), "utf-8");
5775
+ const reportPath = path19.join(reportDir, REPORT_FILE);
5776
+ fs21.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6140
5777
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
6141
5778
  }
6142
5779
 
@@ -6668,10 +6305,10 @@ var migrationCommand = {
6668
6305
  };
6669
6306
 
6670
6307
  // src/commands/read-logs/index.ts
6671
- import path22 from "path";
6308
+ import path20 from "path";
6672
6309
 
6673
6310
  // src/commands/read-logs/std-utils.ts
6674
- import fs24 from "fs";
6311
+ import fs22 from "fs";
6675
6312
  function formatStdPrefixTime(localTime) {
6676
6313
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
6677
6314
  if (!match) return localTime;
@@ -6701,11 +6338,11 @@ function stripPrefixFromStdLine(line) {
6701
6338
  return `[${time}] ${content}`;
6702
6339
  }
6703
6340
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
6704
- const stat = fs24.statSync(filePath);
6341
+ const stat = fs22.statSync(filePath);
6705
6342
  if (stat.size === 0) {
6706
6343
  return { lines: [], markerFound: false, totalLinesCount: 0 };
6707
6344
  }
6708
- const fd = fs24.openSync(filePath, "r");
6345
+ const fd = fs22.openSync(filePath, "r");
6709
6346
  const chunkSize = 64 * 1024;
6710
6347
  let position = stat.size;
6711
6348
  let remainder = "";
@@ -6719,7 +6356,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6719
6356
  const length = Math.min(chunkSize, position);
6720
6357
  position -= length;
6721
6358
  const buffer = Buffer.alloc(length);
6722
- fs24.readSync(fd, buffer, 0, length, position);
6359
+ fs22.readSync(fd, buffer, 0, length, position);
6723
6360
  let chunk = buffer.toString("utf8");
6724
6361
  if (remainder) {
6725
6362
  chunk += remainder;
@@ -6761,7 +6398,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6761
6398
  }
6762
6399
  }
6763
6400
  } finally {
6764
- fs24.closeSync(fd);
6401
+ fs22.closeSync(fd);
6765
6402
  }
6766
6403
  return { lines: collected.reverse(), markerFound, totalLinesCount };
6767
6404
  }
@@ -6782,21 +6419,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
6782
6419
  }
6783
6420
 
6784
6421
  // src/commands/read-logs/tail.ts
6785
- import fs25 from "fs";
6422
+ import fs23 from "fs";
6786
6423
  function fileExists(filePath) {
6787
6424
  try {
6788
- fs25.accessSync(filePath, fs25.constants.F_OK | fs25.constants.R_OK);
6425
+ fs23.accessSync(filePath, fs23.constants.F_OK | fs23.constants.R_OK);
6789
6426
  return true;
6790
6427
  } catch {
6791
6428
  return false;
6792
6429
  }
6793
6430
  }
6794
6431
  function readFileTailLines(filePath, maxLines) {
6795
- const stat = fs25.statSync(filePath);
6432
+ const stat = fs23.statSync(filePath);
6796
6433
  if (stat.size === 0) {
6797
6434
  return [];
6798
6435
  }
6799
- const fd = fs25.openSync(filePath, "r");
6436
+ const fd = fs23.openSync(filePath, "r");
6800
6437
  const chunkSize = 64 * 1024;
6801
6438
  const chunks = [];
6802
6439
  let position = stat.size;
@@ -6806,13 +6443,13 @@ function readFileTailLines(filePath, maxLines) {
6806
6443
  const length = Math.min(chunkSize, position);
6807
6444
  position -= length;
6808
6445
  const buffer = Buffer.alloc(length);
6809
- fs25.readSync(fd, buffer, 0, length, position);
6446
+ fs23.readSync(fd, buffer, 0, length, position);
6810
6447
  chunks.unshift(buffer.toString("utf8"));
6811
6448
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
6812
6449
  collectedLines += chunkLines;
6813
6450
  }
6814
6451
  } finally {
6815
- fs25.closeSync(fd);
6452
+ fs23.closeSync(fd);
6816
6453
  }
6817
6454
  const content = chunks.join("");
6818
6455
  const allLines = content.split("\n");
@@ -6828,11 +6465,11 @@ function readFileTailLines(filePath, maxLines) {
6828
6465
  return allLines.slice(allLines.length - maxLines);
6829
6466
  }
6830
6467
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6831
- const stat = fs25.statSync(filePath);
6468
+ const stat = fs23.statSync(filePath);
6832
6469
  if (stat.size === 0) {
6833
6470
  return { lines: [], totalLinesCount: 0 };
6834
6471
  }
6835
- const fd = fs25.openSync(filePath, "r");
6472
+ const fd = fs23.openSync(filePath, "r");
6836
6473
  const chunkSize = 64 * 1024;
6837
6474
  let position = stat.size;
6838
6475
  let remainder = "";
@@ -6844,7 +6481,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6844
6481
  const length = Math.min(chunkSize, position);
6845
6482
  position -= length;
6846
6483
  const buffer = Buffer.alloc(length);
6847
- fs25.readSync(fd, buffer, 0, length, position);
6484
+ fs23.readSync(fd, buffer, 0, length, position);
6848
6485
  let chunk = buffer.toString("utf8");
6849
6486
  if (remainder) {
6850
6487
  chunk += remainder;
@@ -6875,7 +6512,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6875
6512
  }
6876
6513
  }
6877
6514
  } finally {
6878
- fs25.closeSync(fd);
6515
+ fs23.closeSync(fd);
6879
6516
  }
6880
6517
  return { lines: collected.reverse(), totalLinesCount };
6881
6518
  }
@@ -7017,7 +6654,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
7017
6654
  }
7018
6655
 
7019
6656
  // src/commands/read-logs/json-lines.ts
7020
- import fs26 from "fs";
6657
+ import fs24 from "fs";
7021
6658
  function normalizePid(value) {
7022
6659
  if (typeof value === "number") {
7023
6660
  return String(value);
@@ -7068,11 +6705,11 @@ function buildWantedLevelSet(levels) {
7068
6705
  return set.size > 0 ? set : null;
7069
6706
  }
7070
6707
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7071
- const stat = fs26.statSync(filePath);
6708
+ const stat = fs24.statSync(filePath);
7072
6709
  if (stat.size === 0) {
7073
6710
  return { lines: [], totalLinesCount: 0 };
7074
6711
  }
7075
- const fd = fs26.openSync(filePath, "r");
6712
+ const fd = fs24.openSync(filePath, "r");
7076
6713
  const chunkSize = 64 * 1024;
7077
6714
  let position = stat.size;
7078
6715
  let remainder = "";
@@ -7087,7 +6724,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7087
6724
  const length = Math.min(chunkSize, position);
7088
6725
  position -= length;
7089
6726
  const buffer = Buffer.alloc(length);
7090
- fs26.readSync(fd, buffer, 0, length, position);
6727
+ fs24.readSync(fd, buffer, 0, length, position);
7091
6728
  let chunk = buffer.toString("utf8");
7092
6729
  if (remainder) {
7093
6730
  chunk += remainder;
@@ -7149,7 +6786,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7149
6786
  }
7150
6787
  }
7151
6788
  } finally {
7152
- fs26.closeSync(fd);
6789
+ fs24.closeSync(fd);
7153
6790
  }
7154
6791
  return { lines: collected.reverse(), totalLinesCount };
7155
6792
  }
@@ -7192,11 +6829,11 @@ function extractTraceId(obj) {
7192
6829
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7193
6830
  const wanted = traceId.trim();
7194
6831
  if (!wanted) return { lines: [], totalLinesCount: 0 };
7195
- const stat = fs26.statSync(filePath);
6832
+ const stat = fs24.statSync(filePath);
7196
6833
  if (stat.size === 0) {
7197
6834
  return { lines: [], totalLinesCount: 0 };
7198
6835
  }
7199
- const fd = fs26.openSync(filePath, "r");
6836
+ const fd = fs24.openSync(filePath, "r");
7200
6837
  const chunkSize = 64 * 1024;
7201
6838
  let position = stat.size;
7202
6839
  let remainder = "";
@@ -7209,7 +6846,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7209
6846
  const length = Math.min(chunkSize, position);
7210
6847
  position -= length;
7211
6848
  const buffer = Buffer.alloc(length);
7212
- fs26.readSync(fd, buffer, 0, length, position);
6849
+ fs24.readSync(fd, buffer, 0, length, position);
7213
6850
  let chunk = buffer.toString("utf8");
7214
6851
  if (remainder) {
7215
6852
  chunk += remainder;
@@ -7262,7 +6899,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7262
6899
  }
7263
6900
  }
7264
6901
  } finally {
7265
- fs26.closeSync(fd);
6902
+ fs24.closeSync(fd);
7266
6903
  }
7267
6904
  return { lines: collected.reverse(), totalLinesCount };
7268
6905
  }
@@ -7271,11 +6908,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7271
6908
  if (!wantedLevelSet) {
7272
6909
  return { lines: [], totalLinesCount: 0 };
7273
6910
  }
7274
- const stat = fs26.statSync(filePath);
6911
+ const stat = fs24.statSync(filePath);
7275
6912
  if (stat.size === 0) {
7276
6913
  return { lines: [], totalLinesCount: 0 };
7277
6914
  }
7278
- const fd = fs26.openSync(filePath, "r");
6915
+ const fd = fs24.openSync(filePath, "r");
7279
6916
  const chunkSize = 64 * 1024;
7280
6917
  let position = stat.size;
7281
6918
  let remainder = "";
@@ -7287,7 +6924,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7287
6924
  const length = Math.min(chunkSize, position);
7288
6925
  position -= length;
7289
6926
  const buffer = Buffer.alloc(length);
7290
- fs26.readSync(fd, buffer, 0, length, position);
6927
+ fs24.readSync(fd, buffer, 0, length, position);
7291
6928
  let chunk = buffer.toString("utf8");
7292
6929
  if (remainder) {
7293
6930
  chunk += remainder;
@@ -7334,7 +6971,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7334
6971
  }
7335
6972
  }
7336
6973
  } finally {
7337
- fs26.closeSync(fd);
6974
+ fs24.closeSync(fd);
7338
6975
  }
7339
6976
  return { lines: collected.reverse(), totalLinesCount };
7340
6977
  }
@@ -7568,30 +7205,30 @@ async function readLogsJsonResult(options) {
7568
7205
  };
7569
7206
  }
7570
7207
  function resolveLogFilePath(logDir, type) {
7571
- const base = path22.isAbsolute(logDir) ? logDir : path22.join(process.cwd(), logDir);
7208
+ const base = path20.isAbsolute(logDir) ? logDir : path20.join(process.cwd(), logDir);
7572
7209
  if (type === "server") {
7573
- return path22.join(base, "server.log");
7210
+ return path20.join(base, "server.log");
7574
7211
  }
7575
7212
  if (type === "trace") {
7576
- return path22.join(base, "trace.log");
7213
+ return path20.join(base, "trace.log");
7577
7214
  }
7578
7215
  if (type === "server-std") {
7579
- return path22.join(base, "server.std.log");
7216
+ return path20.join(base, "server.std.log");
7580
7217
  }
7581
7218
  if (type === "client-std") {
7582
- return path22.join(base, "client.std.log");
7219
+ return path20.join(base, "client.std.log");
7583
7220
  }
7584
7221
  if (type === "dev") {
7585
- return path22.join(base, "dev.log");
7222
+ return path20.join(base, "dev.log");
7586
7223
  }
7587
7224
  if (type === "dev-std") {
7588
- return path22.join(base, "dev.std.log");
7225
+ return path20.join(base, "dev.std.log");
7589
7226
  }
7590
7227
  if (type === "install-dep-std") {
7591
- return path22.join(base, "install-dep.std.log");
7228
+ return path20.join(base, "install-dep.std.log");
7592
7229
  }
7593
7230
  if (type === "browser") {
7594
- return path22.join(base, "browser.log");
7231
+ return path20.join(base, "browser.log");
7595
7232
  }
7596
7233
  throw new Error(`Unsupported log type: ${type}`);
7597
7234
  }
@@ -7768,9 +7405,9 @@ function camelToKebab(str) {
7768
7405
  }
7769
7406
 
7770
7407
  // src/commands/build/upload-static.handler.ts
7771
- import * as fs27 from "fs";
7772
- import * as os3 from "os";
7773
- import * as path23 from "path";
7408
+ import * as fs25 from "fs";
7409
+ import * as os2 from "os";
7410
+ import * as path21 from "path";
7774
7411
  import { execFileSync } from "child_process";
7775
7412
  function readCredentialsFromEnv() {
7776
7413
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -7794,8 +7431,8 @@ async function uploadStatic(options) {
7794
7431
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7795
7432
  region = UPLOAD_STATIC_DEFAULTS.region
7796
7433
  } = options;
7797
- const resolvedStaticDir = path23.resolve(staticDir);
7798
- if (!fs27.existsSync(resolvedStaticDir)) {
7434
+ const resolvedStaticDir = path21.resolve(staticDir);
7435
+ if (!fs25.existsSync(resolvedStaticDir)) {
7799
7436
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7800
7437
  return;
7801
7438
  }
@@ -7828,8 +7465,8 @@ async function uploadStatic(options) {
7828
7465
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7829
7466
  }
7830
7467
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7831
- const confPath = path23.join(os3.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7832
- fs27.writeFileSync(confPath, "");
7468
+ const confPath = path21.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7469
+ fs25.writeFileSync(confPath, "");
7833
7470
  try {
7834
7471
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7835
7472
  configureTosutil(resolvedTosutil, confPath, {
@@ -7843,7 +7480,7 @@ async function uploadStatic(options) {
7843
7480
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7844
7481
  } finally {
7845
7482
  try {
7846
- fs27.unlinkSync(confPath);
7483
+ fs25.unlinkSync(confPath);
7847
7484
  } catch {
7848
7485
  }
7849
7486
  }
@@ -7863,8 +7500,8 @@ async function uploadStatic(options) {
7863
7500
  }
7864
7501
  }
7865
7502
  function resolveTosutilPath(tosutilPath) {
7866
- if (path23.isAbsolute(tosutilPath)) {
7867
- return fs27.existsSync(tosutilPath) ? tosutilPath : null;
7503
+ if (path21.isAbsolute(tosutilPath)) {
7504
+ return fs25.existsSync(tosutilPath) ? tosutilPath : null;
7868
7505
  }
7869
7506
  try {
7870
7507
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -7909,7 +7546,7 @@ async function resolveBucketId(appId) {
7909
7546
  return bucketId;
7910
7547
  }
7911
7548
  function isDirEmpty(dirPath) {
7912
- const entries = fs27.readdirSync(dirPath);
7549
+ const entries = fs25.readdirSync(dirPath);
7913
7550
  return entries.length === 0;
7914
7551
  }
7915
7552
 
@@ -8004,12 +7641,12 @@ var commands = [
8004
7641
  ];
8005
7642
 
8006
7643
  // src/index.ts
8007
- var envPath = path24.join(process.cwd(), ".env");
8008
- if (fs28.existsSync(envPath)) {
7644
+ var envPath = path22.join(process.cwd(), ".env");
7645
+ if (fs26.existsSync(envPath)) {
8009
7646
  dotenvConfig({ path: envPath });
8010
7647
  }
8011
- var __dirname = path24.dirname(fileURLToPath5(import.meta.url));
8012
- var pkg = JSON.parse(fs28.readFileSync(path24.join(__dirname, "../package.json"), "utf-8"));
7648
+ var __dirname = path22.dirname(fileURLToPath5(import.meta.url));
7649
+ var pkg = JSON.parse(fs26.readFileSync(path22.join(__dirname, "../package.json"), "utf-8"));
8013
7650
  var cli = new FullstackCLI(pkg.version);
8014
7651
  cli.useAll(commands);
8015
7652
  cli.run();