@lark-apaas/fullstack-cli 1.1.40-alpha.1 → 1.1.40-alpha.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +212 -465
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // src/index.ts
2
- import fs27 from "fs";
3
- import path23 from "path";
2
+ import 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
 
@@ -2152,6 +2152,24 @@ async function parseAndGenerateNestResourceTemplate(options) {
2152
2152
 
2153
2153
  // src/commands/db/schema.handler.ts
2154
2154
  var require2 = createRequire(import.meta.url);
2155
+ var STALE_RUN_DIR_MAX_AGE_MS = 60 * 60 * 1e3;
2156
+ function sweepStaleRunDirs(rootDir) {
2157
+ try {
2158
+ const now = Date.now();
2159
+ for (const name of fs4.readdirSync(rootDir)) {
2160
+ if (!name.startsWith("run-")) continue;
2161
+ const full = path2.join(rootDir, name);
2162
+ try {
2163
+ const stat = fs4.statSync(full);
2164
+ if (!stat.isDirectory()) continue;
2165
+ if (now - stat.mtimeMs < STALE_RUN_DIR_MAX_AGE_MS) continue;
2166
+ fs4.rmSync(full, { recursive: true, force: true });
2167
+ } catch {
2168
+ }
2169
+ }
2170
+ } catch {
2171
+ }
2172
+ }
2155
2173
  async function run(options = {}) {
2156
2174
  let exitCode = 0;
2157
2175
  const envPath2 = path2.resolve(process.cwd(), ".env");
@@ -2167,7 +2185,9 @@ async function run(options = {}) {
2167
2185
  process.exit(1);
2168
2186
  }
2169
2187
  const outputPath = options.output || process.env.DB_SCHEMA_OUTPUT || "server/database/schema.ts";
2170
- const OUT_DIR = path2.resolve(process.cwd(), "server/database/.introspect");
2188
+ const INTROSPECT_ROOT = path2.resolve(process.cwd(), "server/database/.introspect");
2189
+ fs4.mkdirSync(INTROSPECT_ROOT, { recursive: true });
2190
+ const OUT_DIR = fs4.mkdtempSync(path2.join(INTROSPECT_ROOT, "run-"));
2171
2191
  const SCHEMA_FILE = path2.resolve(process.cwd(), outputPath);
2172
2192
  console.log("[gen-db-schema] Starting...");
2173
2193
  const __filename = fileURLToPath2(import.meta.url);
@@ -2347,6 +2367,7 @@ async function run(options = {}) {
2347
2367
  if (fs4.existsSync(OUT_DIR)) {
2348
2368
  fs4.rmSync(OUT_DIR, { recursive: true, force: true });
2349
2369
  }
2370
+ sweepStaleRunDirs(INTROSPECT_ROOT);
2350
2371
  process.exit(exitCode);
2351
2372
  }
2352
2373
  }
@@ -3105,220 +3126,6 @@ async function run3(options = {}) {
3105
3126
 
3106
3127
  // src/commands/upgrade/deps/run.handler.ts
3107
3128
  import { spawnSync as spawnSync3 } from "child_process";
3108
-
3109
- // src/utils/grayscale/config.ts
3110
- function getGrayscaleConfig() {
3111
- const raw = process.env.GRAYSCALE_CONFIG;
3112
- if (!raw) {
3113
- return null;
3114
- }
3115
- try {
3116
- const config = JSON.parse(raw);
3117
- if (!config.enabled) {
3118
- return null;
3119
- }
3120
- return config;
3121
- } catch {
3122
- console.warn("[grayscale] Failed to parse GRAYSCALE_CONFIG env");
3123
- return null;
3124
- }
3125
- }
3126
-
3127
- // src/utils/grayscale/identity.ts
3128
- import fs10 from "fs";
3129
- import path8 from "path";
3130
- function readFromEnvVars() {
3131
- const appId = process.env.app_id || process.env.APP_ID;
3132
- const tenantId = process.env.tenant_id || process.env.TENANT_ID;
3133
- return { appId, tenantId };
3134
- }
3135
- function parseEnvFile(filePath) {
3136
- const result = {};
3137
- if (!fs10.existsSync(filePath)) {
3138
- return result;
3139
- }
3140
- try {
3141
- const content = fs10.readFileSync(filePath, "utf-8");
3142
- const lines = content.split("\n");
3143
- for (const line of lines) {
3144
- const trimmed = line.trim();
3145
- if (!trimmed || trimmed.startsWith("#")) {
3146
- continue;
3147
- }
3148
- const match = trimmed.match(/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=["']?(.+?)["']?$/);
3149
- if (match) {
3150
- result[match[1]] = match[2];
3151
- }
3152
- }
3153
- } catch {
3154
- }
3155
- return result;
3156
- }
3157
- function readFromForceEnvFile(cwd) {
3158
- const envPath2 = path8.join(cwd, ".force", "environment", "env");
3159
- const vars = parseEnvFile(envPath2);
3160
- return {
3161
- appId: vars.app_id || vars.APP_ID,
3162
- tenantId: vars.tenant_id || vars.TENANT_ID
3163
- };
3164
- }
3165
- function readFromClientBasePath() {
3166
- const basePath = process.env.CLIENT_BASE_PATH;
3167
- if (!basePath) {
3168
- return {};
3169
- }
3170
- const afMatch = basePath.match(/\/af\/p\/([^/]+)/);
3171
- if (afMatch) {
3172
- return { appId: afMatch[1] };
3173
- }
3174
- const appMatch = basePath.match(/\/app\/([^/]+)/);
3175
- if (appMatch) {
3176
- return { appId: appMatch[1] };
3177
- }
3178
- return {};
3179
- }
3180
- function readFromDotEnv(cwd) {
3181
- const envPath2 = path8.join(cwd, ".env");
3182
- const vars = parseEnvFile(envPath2);
3183
- return {
3184
- appId: vars.app_id || vars.APP_ID,
3185
- tenantId: vars.tenant_id || vars.TENANT_ID
3186
- };
3187
- }
3188
- function readFromPackageJson(cwd) {
3189
- const pkgPath = path8.join(cwd, "package.json");
3190
- if (!fs10.existsSync(pkgPath)) {
3191
- return {};
3192
- }
3193
- try {
3194
- const content = fs10.readFileSync(pkgPath, "utf-8");
3195
- const pkg2 = JSON.parse(content);
3196
- const appId = pkg2?.fullstack?.appId;
3197
- return appId ? { appId } : {};
3198
- } catch {
3199
- return {};
3200
- }
3201
- }
3202
- function readProjectIdentity(cwd) {
3203
- const sources = [
3204
- () => readFromEnvVars(),
3205
- () => readFromForceEnvFile(cwd),
3206
- () => readFromClientBasePath(),
3207
- () => readFromDotEnv(cwd),
3208
- () => readFromPackageJson(cwd)
3209
- ];
3210
- const merged = {};
3211
- for (const source of sources) {
3212
- const identity = source();
3213
- if (!merged.appId && identity.appId) {
3214
- merged.appId = identity.appId;
3215
- }
3216
- if (!merged.tenantId && identity.tenantId) {
3217
- merged.tenantId = identity.tenantId;
3218
- }
3219
- if (merged.appId && merged.tenantId) {
3220
- break;
3221
- }
3222
- }
3223
- return merged;
3224
- }
3225
-
3226
- // src/utils/grayscale/rules.ts
3227
- import { createHash } from "crypto";
3228
- function isInPercentage(key, percentage) {
3229
- if (percentage <= 0) return false;
3230
- if (percentage >= 100) return true;
3231
- const hash = createHash("md5").update(`grayscale:${key}`).digest("hex");
3232
- const value = parseInt(hash.substring(0, 8), 16) % 1e4;
3233
- const threshold = Math.floor(percentage * 100);
3234
- return value < threshold;
3235
- }
3236
- function matchConditions(rule, identity) {
3237
- const { conditions } = rule;
3238
- if (conditions.tenant_ids && conditions.tenant_ids.length > 0) {
3239
- if (identity.tenantId && conditions.tenant_ids.includes(identity.tenantId)) {
3240
- return true;
3241
- }
3242
- }
3243
- if (conditions.app_ids && conditions.app_ids.length > 0) {
3244
- if (identity.appId && conditions.app_ids.includes(identity.appId)) {
3245
- return true;
3246
- }
3247
- }
3248
- if (conditions.percentage != null && conditions.percentage > 0) {
3249
- const hashKey = conditions.hash_key || "app_id";
3250
- const hashValue = hashKey === "tenant_id" ? identity.tenantId : identity.appId;
3251
- if (hashValue && isInPercentage(hashValue, conditions.percentage)) {
3252
- return true;
3253
- }
3254
- }
3255
- const hasConditions = conditions.tenant_ids && conditions.tenant_ids.length > 0 || conditions.app_ids && conditions.app_ids.length > 0 || conditions.percentage != null && conditions.percentage > 0;
3256
- return !hasConditions;
3257
- }
3258
- function evaluateRules(config, identity) {
3259
- const enabledRules = config.rules.filter((rule) => rule.enabled).sort((a, b) => b.priority - a.priority);
3260
- for (const rule of enabledRules) {
3261
- if (matchConditions(rule, identity)) {
3262
- return rule;
3263
- }
3264
- }
3265
- return null;
3266
- }
3267
- function resolveTargetVersions(config, identity) {
3268
- const matchedRule = evaluateRules(config, identity);
3269
- const channelName = matchedRule?.channel || config.default_channel;
3270
- const channel = config.channels[channelName];
3271
- if (!channel) {
3272
- console.warn(`[grayscale] Channel "${channelName}" not found in config`);
3273
- return null;
3274
- }
3275
- const versions = /* @__PURE__ */ new Map();
3276
- for (const [pkgName, version] of Object.entries(channel.versions)) {
3277
- if (config.blocked_versions?.includes(version)) {
3278
- console.warn(`[grayscale] Version ${version} of ${pkgName} is blocked, skipping`);
3279
- continue;
3280
- }
3281
- versions.set(pkgName, version);
3282
- }
3283
- if (config.force_versions) {
3284
- for (const [pkgName, version] of Object.entries(config.force_versions)) {
3285
- versions.set(pkgName, version);
3286
- }
3287
- }
3288
- if (matchedRule) {
3289
- console.log(`[grayscale] Matched rule: "${matchedRule.name}" (id: ${matchedRule.id}), channel: ${channelName}`);
3290
- } else {
3291
- console.log(`[grayscale] No rule matched, using default channel: ${channelName}`);
3292
- }
3293
- return versions;
3294
- }
3295
-
3296
- // src/utils/grayscale/index.ts
3297
- function resolveGrayscaleVersions(cwd) {
3298
- const config = getGrayscaleConfig();
3299
- if (!config) {
3300
- console.log("[grayscale] Config not available, skipping grayscale");
3301
- return null;
3302
- }
3303
- const identity = readProjectIdentity(cwd);
3304
- if (!identity.appId && !identity.tenantId) {
3305
- console.log("[grayscale] No app_id or tenant_id found, skipping grayscale");
3306
- return null;
3307
- }
3308
- console.log(`[grayscale] Project identity: appId=${identity.appId || "N/A"}, tenantId=${identity.tenantId || "N/A"}`);
3309
- const versions = resolveTargetVersions(config, identity);
3310
- if (!versions || versions.size === 0) {
3311
- console.log("[grayscale] No target versions resolved");
3312
- return null;
3313
- }
3314
- console.log(`[grayscale] Resolved ${versions.size} package version(s):`);
3315
- for (const [pkg2, ver] of versions) {
3316
- console.log(`[grayscale] ${pkg2} -> ${ver}`);
3317
- }
3318
- return versions;
3319
- }
3320
-
3321
- // src/commands/upgrade/deps/run.handler.ts
3322
3129
  function findLarkAapaasPackages(cwd, filterPackages) {
3323
3130
  const pkg2 = readPackageJson(cwd);
3324
3131
  const allPackages = /* @__PURE__ */ new Set();
@@ -3371,43 +3178,11 @@ function upgradePackages(packages, version, cwd) {
3371
3178
  });
3372
3179
  }
3373
3180
  }
3374
- function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun) {
3375
- const upgradePlan = [];
3376
- for (const pkg2 of packages) {
3377
- const version = grayscaleVersions.get(pkg2);
3378
- if (version) {
3379
- upgradePlan.push({ pkg: pkg2, version });
3380
- }
3381
- }
3382
- if (upgradePlan.length === 0) {
3383
- console.log("[fullstack-cli] No grayscale versions matched current packages");
3384
- return;
3385
- }
3386
- console.log(`[fullstack-cli] Grayscale upgrade plan (${upgradePlan.length} package(s)):`);
3387
- upgradePlan.forEach(({ pkg: pkg2, version }) => {
3388
- console.log(` - ${pkg2} -> ${version}`);
3389
- });
3390
- if (dryRun) {
3391
- console.log("[fullstack-cli] Dry run mode, skipping actual installation");
3392
- return;
3393
- }
3394
- for (const { pkg: pkg2, version } of upgradePlan) {
3395
- const target = `${pkg2}@${version}`;
3396
- console.log(`[fullstack-cli] Installing ${target}...`);
3397
- const result = spawnSync3("npm", ["install", target], {
3398
- cwd,
3399
- stdio: "inherit"
3400
- });
3401
- if (result.error || result.status !== 0) {
3402
- throw new Error(`Failed to install ${target}`);
3403
- }
3404
- }
3405
- }
3406
3181
  async function run4(options = {}) {
3407
3182
  const cwd = process.env.INIT_CWD || process.cwd();
3408
3183
  console.log("[fullstack-cli] Starting dependencies upgrade...");
3409
3184
  try {
3410
- console.log("[fullstack-cli] Step 1/3: Scanning @lark-apaas dependencies...");
3185
+ console.log("[fullstack-cli] Step 1/2: Scanning @lark-apaas dependencies...");
3411
3186
  const packages = findLarkAapaasPackages(cwd, options.packages);
3412
3187
  if (packages.length === 0) {
3413
3188
  console.log("[fullstack-cli] No @lark-apaas packages found");
@@ -3415,35 +3190,7 @@ async function run4(options = {}) {
3415
3190
  }
3416
3191
  console.log(`[fullstack-cli] Found ${packages.length} @lark-apaas package(s):`);
3417
3192
  packages.forEach((p) => console.log(` - ${p}`));
3418
- if (!options.skipGrayscale && !options.version) {
3419
- console.log("[fullstack-cli] Step 2/3: Checking grayscale config...");
3420
- try {
3421
- const grayscaleVersions = resolveGrayscaleVersions(cwd);
3422
- if (grayscaleVersions) {
3423
- console.log("[fullstack-cli] Step 3/3: Applying grayscale versions...");
3424
- installGrayscaleVersions(packages, grayscaleVersions, cwd, !!options.dryRun);
3425
- if (!options.dryRun) {
3426
- console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s) via grayscale`);
3427
- console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
3428
- }
3429
- return;
3430
- }
3431
- console.log("[fullstack-cli] Grayscale not available, falling back to default upgrade");
3432
- } catch (error) {
3433
- const msg = error instanceof Error ? error.message : String(error);
3434
- console.warn(`[fullstack-cli] Grayscale check failed: ${msg}, falling back to default upgrade`);
3435
- }
3436
- } else if (options.skipGrayscale) {
3437
- console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (--skip-grayscale)");
3438
- } else {
3439
- console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (explicit --version provided)");
3440
- }
3441
- if (options.dryRun) {
3442
- console.log("[fullstack-cli] Dry run mode: would upgrade via npm update (no grayscale)");
3443
- packages.forEach((p) => console.log(` - ${p} -> ${options.version || "latest compatible"}`));
3444
- return;
3445
- }
3446
- console.log("[fullstack-cli] Step 3/3: Upgrading packages...");
3193
+ console.log("[fullstack-cli] Step 2/2: Upgrading packages...");
3447
3194
  upgradePackages(packages, options.version, cwd);
3448
3195
  console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s)`);
3449
3196
  console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
@@ -3459,7 +3206,7 @@ var depsCommand = {
3459
3206
  name: "deps",
3460
3207
  description: "Upgrade @lark-apaas dependencies",
3461
3208
  register(parentCommand) {
3462
- 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) => {
3209
+ 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) => {
3463
3210
  await run4(options);
3464
3211
  });
3465
3212
  }
@@ -3478,8 +3225,8 @@ var upgradeCommand = {
3478
3225
  };
3479
3226
 
3480
3227
  // src/commands/action-plugin/utils.ts
3481
- import fs11 from "fs";
3482
- import path9 from "path";
3228
+ import fs10 from "fs";
3229
+ import path8 from "path";
3483
3230
  import { spawnSync as spawnSync4, execSync as execSync2 } from "child_process";
3484
3231
  function parsePluginName(input) {
3485
3232
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
@@ -3497,18 +3244,18 @@ function getProjectRoot() {
3497
3244
  return process.cwd();
3498
3245
  }
3499
3246
  function getPackageJsonPath() {
3500
- return path9.join(getProjectRoot(), "package.json");
3247
+ return path8.join(getProjectRoot(), "package.json");
3501
3248
  }
3502
3249
  function getPluginPath(pluginName) {
3503
- return path9.join(getProjectRoot(), "node_modules", pluginName);
3250
+ return path8.join(getProjectRoot(), "node_modules", pluginName);
3504
3251
  }
3505
3252
  function readPackageJson2() {
3506
3253
  const pkgPath = getPackageJsonPath();
3507
- if (!fs11.existsSync(pkgPath)) {
3254
+ if (!fs10.existsSync(pkgPath)) {
3508
3255
  throw new Error("package.json not found in current directory");
3509
3256
  }
3510
3257
  try {
3511
- const content = fs11.readFileSync(pkgPath, "utf-8");
3258
+ const content = fs10.readFileSync(pkgPath, "utf-8");
3512
3259
  return JSON.parse(content);
3513
3260
  } catch {
3514
3261
  throw new Error("Failed to parse package.json");
@@ -3516,7 +3263,7 @@ function readPackageJson2() {
3516
3263
  }
3517
3264
  function writePackageJson2(pkg2) {
3518
3265
  const pkgPath = getPackageJsonPath();
3519
- fs11.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3266
+ fs10.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3520
3267
  }
3521
3268
  function readActionPlugins() {
3522
3269
  const pkg2 = readPackageJson2();
@@ -3549,12 +3296,12 @@ function npmInstall(tgzPath) {
3549
3296
  }
3550
3297
  }
3551
3298
  function getPackageVersion(pluginName) {
3552
- const pkgJsonPath = path9.join(getPluginPath(pluginName), "package.json");
3553
- if (!fs11.existsSync(pkgJsonPath)) {
3299
+ const pkgJsonPath = path8.join(getPluginPath(pluginName), "package.json");
3300
+ if (!fs10.existsSync(pkgJsonPath)) {
3554
3301
  return null;
3555
3302
  }
3556
3303
  try {
3557
- const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3304
+ const content = fs10.readFileSync(pkgJsonPath, "utf-8");
3558
3305
  const pkg2 = JSON.parse(content);
3559
3306
  return pkg2.version || null;
3560
3307
  } catch {
@@ -3562,49 +3309,49 @@ function getPackageVersion(pluginName) {
3562
3309
  }
3563
3310
  }
3564
3311
  function readPluginPackageJson(pluginPath) {
3565
- const pkgJsonPath = path9.join(pluginPath, "package.json");
3566
- if (!fs11.existsSync(pkgJsonPath)) {
3312
+ const pkgJsonPath = path8.join(pluginPath, "package.json");
3313
+ if (!fs10.existsSync(pkgJsonPath)) {
3567
3314
  return null;
3568
3315
  }
3569
3316
  try {
3570
- const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3317
+ const content = fs10.readFileSync(pkgJsonPath, "utf-8");
3571
3318
  return JSON.parse(content);
3572
3319
  } catch {
3573
3320
  return null;
3574
3321
  }
3575
3322
  }
3576
3323
  function extractTgzToNodeModules(tgzPath, pluginName) {
3577
- const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
3578
- const targetDir = path9.join(nodeModulesPath, pluginName);
3579
- const scopeDir = path9.dirname(targetDir);
3580
- if (!fs11.existsSync(scopeDir)) {
3581
- fs11.mkdirSync(scopeDir, { recursive: true });
3324
+ const nodeModulesPath = path8.join(getProjectRoot(), "node_modules");
3325
+ const targetDir = path8.join(nodeModulesPath, pluginName);
3326
+ const scopeDir = path8.dirname(targetDir);
3327
+ if (!fs10.existsSync(scopeDir)) {
3328
+ fs10.mkdirSync(scopeDir, { recursive: true });
3582
3329
  }
3583
- if (fs11.existsSync(targetDir)) {
3584
- fs11.rmSync(targetDir, { recursive: true });
3330
+ if (fs10.existsSync(targetDir)) {
3331
+ fs10.rmSync(targetDir, { recursive: true });
3585
3332
  }
3586
- const tempDir = path9.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3587
- if (fs11.existsSync(tempDir)) {
3588
- fs11.rmSync(tempDir, { recursive: true });
3333
+ const tempDir = path8.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3334
+ if (fs10.existsSync(tempDir)) {
3335
+ fs10.rmSync(tempDir, { recursive: true });
3589
3336
  }
3590
- fs11.mkdirSync(tempDir, { recursive: true });
3337
+ fs10.mkdirSync(tempDir, { recursive: true });
3591
3338
  try {
3592
3339
  execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
3593
- const extractedDir = path9.join(tempDir, "package");
3594
- if (fs11.existsSync(extractedDir)) {
3595
- fs11.renameSync(extractedDir, targetDir);
3340
+ const extractedDir = path8.join(tempDir, "package");
3341
+ if (fs10.existsSync(extractedDir)) {
3342
+ fs10.renameSync(extractedDir, targetDir);
3596
3343
  } else {
3597
- const files = fs11.readdirSync(tempDir);
3344
+ const files = fs10.readdirSync(tempDir);
3598
3345
  if (files.length === 1) {
3599
- fs11.renameSync(path9.join(tempDir, files[0]), targetDir);
3346
+ fs10.renameSync(path8.join(tempDir, files[0]), targetDir);
3600
3347
  } else {
3601
3348
  throw new Error("Unexpected tgz structure");
3602
3349
  }
3603
3350
  }
3604
3351
  return targetDir;
3605
3352
  } finally {
3606
- if (fs11.existsSync(tempDir)) {
3607
- fs11.rmSync(tempDir, { recursive: true });
3353
+ if (fs10.existsSync(tempDir)) {
3354
+ fs10.rmSync(tempDir, { recursive: true });
3608
3355
  }
3609
3356
  }
3610
3357
  }
@@ -3613,10 +3360,10 @@ function checkMissingPeerDeps(peerDeps) {
3613
3360
  return [];
3614
3361
  }
3615
3362
  const missing = [];
3616
- const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
3363
+ const nodeModulesPath = path8.join(getProjectRoot(), "node_modules");
3617
3364
  for (const [depName, _version] of Object.entries(peerDeps)) {
3618
- const depPath = path9.join(nodeModulesPath, depName);
3619
- if (!fs11.existsSync(depPath)) {
3365
+ const depPath = path8.join(nodeModulesPath, depName);
3366
+ if (!fs10.existsSync(depPath)) {
3620
3367
  missing.push(depName);
3621
3368
  }
3622
3369
  }
@@ -3640,16 +3387,16 @@ function installMissingDeps(deps) {
3640
3387
  }
3641
3388
  function removePluginDirectory(pluginName) {
3642
3389
  const pluginPath = getPluginPath(pluginName);
3643
- if (fs11.existsSync(pluginPath)) {
3644
- fs11.rmSync(pluginPath, { recursive: true });
3390
+ if (fs10.existsSync(pluginPath)) {
3391
+ fs10.rmSync(pluginPath, { recursive: true });
3645
3392
  console.log(`[action-plugin] Removed ${pluginName}`);
3646
3393
  }
3647
3394
  }
3648
3395
 
3649
3396
  // src/commands/action-plugin/api-client.ts
3650
3397
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
3651
- import fs12 from "fs";
3652
- import path10 from "path";
3398
+ import fs11 from "fs";
3399
+ import path9 from "path";
3653
3400
  var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
3654
3401
  async function getPluginVersions(keys, latestOnly = true) {
3655
3402
  const client = getHttpClient();
@@ -3713,19 +3460,19 @@ async function downloadFromPublic(downloadURL) {
3713
3460
  return Buffer.from(arrayBuffer);
3714
3461
  }
3715
3462
  function getPluginCacheDir() {
3716
- return path10.join(process.cwd(), PLUGIN_CACHE_DIR);
3463
+ return path9.join(process.cwd(), PLUGIN_CACHE_DIR);
3717
3464
  }
3718
3465
  function ensureCacheDir() {
3719
3466
  const cacheDir = getPluginCacheDir();
3720
- if (!fs12.existsSync(cacheDir)) {
3721
- fs12.mkdirSync(cacheDir, { recursive: true });
3467
+ if (!fs11.existsSync(cacheDir)) {
3468
+ fs11.mkdirSync(cacheDir, { recursive: true });
3722
3469
  }
3723
3470
  }
3724
3471
  function getTempFilePath(pluginKey, version) {
3725
3472
  ensureCacheDir();
3726
3473
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3727
3474
  const filename = `${safeKey}@${version}.tgz`;
3728
- return path10.join(getPluginCacheDir(), filename);
3475
+ return path9.join(getPluginCacheDir(), filename);
3729
3476
  }
3730
3477
  var MAX_RETRIES = 2;
3731
3478
  async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
@@ -3762,7 +3509,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
3762
3509
  );
3763
3510
  }
3764
3511
  const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
3765
- fs12.writeFileSync(tgzPath, tgzBuffer);
3512
+ fs11.writeFileSync(tgzPath, tgzBuffer);
3766
3513
  console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
3767
3514
  return {
3768
3515
  tgzPath,
@@ -3776,18 +3523,18 @@ function getCachePath(pluginKey, version) {
3776
3523
  ensureCacheDir();
3777
3524
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3778
3525
  const filename = `${safeKey}@${version}.tgz`;
3779
- return path10.join(getPluginCacheDir(), filename);
3526
+ return path9.join(getPluginCacheDir(), filename);
3780
3527
  }
3781
3528
  function hasCachedPlugin(pluginKey, version) {
3782
3529
  const cachePath = getCachePath(pluginKey, version);
3783
- return fs12.existsSync(cachePath);
3530
+ return fs11.existsSync(cachePath);
3784
3531
  }
3785
3532
  function listCachedPlugins() {
3786
3533
  const cacheDir = getPluginCacheDir();
3787
- if (!fs12.existsSync(cacheDir)) {
3534
+ if (!fs11.existsSync(cacheDir)) {
3788
3535
  return [];
3789
3536
  }
3790
- const files = fs12.readdirSync(cacheDir);
3537
+ const files = fs11.readdirSync(cacheDir);
3791
3538
  const result = [];
3792
3539
  for (const file of files) {
3793
3540
  if (!file.endsWith(".tgz")) continue;
@@ -3795,8 +3542,8 @@ function listCachedPlugins() {
3795
3542
  if (!match) continue;
3796
3543
  const [, rawName, version] = match;
3797
3544
  const name = rawName.replace(/^_/, "@").replace(/_/, "/");
3798
- const filePath = path10.join(cacheDir, file);
3799
- const stat = fs12.statSync(filePath);
3545
+ const filePath = path9.join(cacheDir, file);
3546
+ const stat = fs11.statSync(filePath);
3800
3547
  result.push({
3801
3548
  name,
3802
3549
  version,
@@ -3809,14 +3556,14 @@ function listCachedPlugins() {
3809
3556
  }
3810
3557
  function cleanAllCache() {
3811
3558
  const cacheDir = getPluginCacheDir();
3812
- if (!fs12.existsSync(cacheDir)) {
3559
+ if (!fs11.existsSync(cacheDir)) {
3813
3560
  return 0;
3814
3561
  }
3815
- const files = fs12.readdirSync(cacheDir);
3562
+ const files = fs11.readdirSync(cacheDir);
3816
3563
  let count = 0;
3817
3564
  for (const file of files) {
3818
3565
  if (file.endsWith(".tgz")) {
3819
- fs12.unlinkSync(path10.join(cacheDir, file));
3566
+ fs11.unlinkSync(path9.join(cacheDir, file));
3820
3567
  count++;
3821
3568
  }
3822
3569
  }
@@ -3824,21 +3571,21 @@ function cleanAllCache() {
3824
3571
  }
3825
3572
  function cleanPluginCache(pluginKey, version) {
3826
3573
  const cacheDir = getPluginCacheDir();
3827
- if (!fs12.existsSync(cacheDir)) {
3574
+ if (!fs11.existsSync(cacheDir)) {
3828
3575
  return 0;
3829
3576
  }
3830
3577
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3831
- const files = fs12.readdirSync(cacheDir);
3578
+ const files = fs11.readdirSync(cacheDir);
3832
3579
  let count = 0;
3833
3580
  for (const file of files) {
3834
3581
  if (version) {
3835
3582
  if (file === `${safeKey}@${version}.tgz`) {
3836
- fs12.unlinkSync(path10.join(cacheDir, file));
3583
+ fs11.unlinkSync(path9.join(cacheDir, file));
3837
3584
  count++;
3838
3585
  }
3839
3586
  } else {
3840
3587
  if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
3841
- fs12.unlinkSync(path10.join(cacheDir, file));
3588
+ fs11.unlinkSync(path9.join(cacheDir, file));
3842
3589
  count++;
3843
3590
  }
3844
3591
  }
@@ -4265,40 +4012,40 @@ var actionPluginCommandGroup = {
4265
4012
  };
4266
4013
 
4267
4014
  // src/commands/capability/utils.ts
4268
- import fs13 from "fs";
4015
+ import fs12 from "fs";
4269
4016
  import { createRequire as createRequire2 } from "module";
4270
- import path11 from "path";
4017
+ import path10 from "path";
4271
4018
  var CAPABILITIES_DIR = "server/capabilities";
4272
4019
  function getProjectRoot2() {
4273
4020
  return process.cwd();
4274
4021
  }
4275
4022
  function getCapabilitiesDir() {
4276
- return path11.join(getProjectRoot2(), CAPABILITIES_DIR);
4023
+ return path10.join(getProjectRoot2(), CAPABILITIES_DIR);
4277
4024
  }
4278
4025
  function getCapabilityPath(id) {
4279
- return path11.join(getCapabilitiesDir(), `${id}.json`);
4026
+ return path10.join(getCapabilitiesDir(), `${id}.json`);
4280
4027
  }
4281
4028
  function getPluginManifestPath(pluginKey) {
4282
- return path11.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4029
+ return path10.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4283
4030
  }
4284
4031
  function capabilitiesDirExists() {
4285
- return fs13.existsSync(getCapabilitiesDir());
4032
+ return fs12.existsSync(getCapabilitiesDir());
4286
4033
  }
4287
4034
  function listCapabilityIds() {
4288
4035
  const dir = getCapabilitiesDir();
4289
- if (!fs13.existsSync(dir)) {
4036
+ if (!fs12.existsSync(dir)) {
4290
4037
  return [];
4291
4038
  }
4292
- const files = fs13.readdirSync(dir);
4039
+ const files = fs12.readdirSync(dir);
4293
4040
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
4294
4041
  }
4295
4042
  function readCapability(id) {
4296
4043
  const filePath = getCapabilityPath(id);
4297
- if (!fs13.existsSync(filePath)) {
4044
+ if (!fs12.existsSync(filePath)) {
4298
4045
  throw new Error(`Capability not found: ${id}`);
4299
4046
  }
4300
4047
  try {
4301
- const content = fs13.readFileSync(filePath, "utf-8");
4048
+ const content = fs12.readFileSync(filePath, "utf-8");
4302
4049
  return JSON.parse(content);
4303
4050
  } catch (error) {
4304
4051
  if (error instanceof SyntaxError) {
@@ -4325,11 +4072,11 @@ function readAllCapabilities() {
4325
4072
  }
4326
4073
  function readPluginManifest(pluginKey) {
4327
4074
  const manifestPath = getPluginManifestPath(pluginKey);
4328
- if (!fs13.existsSync(manifestPath)) {
4075
+ if (!fs12.existsSync(manifestPath)) {
4329
4076
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
4330
4077
  }
4331
4078
  try {
4332
- const content = fs13.readFileSync(manifestPath, "utf-8");
4079
+ const content = fs12.readFileSync(manifestPath, "utf-8");
4333
4080
  return JSON.parse(content);
4334
4081
  } catch (error) {
4335
4082
  if (error instanceof SyntaxError) {
@@ -4346,7 +4093,7 @@ function hasValidParamsSchema(paramsSchema) {
4346
4093
  }
4347
4094
  async function loadPlugin(pluginKey) {
4348
4095
  try {
4349
- const userRequire = createRequire2(path11.join(getProjectRoot2(), "package.json"));
4096
+ const userRequire = createRequire2(path10.join(getProjectRoot2(), "package.json"));
4350
4097
  const resolvedPath = userRequire.resolve(pluginKey);
4351
4098
  const pluginModule = await import(resolvedPath);
4352
4099
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -4509,8 +4256,8 @@ var capabilityCommandGroup = {
4509
4256
  import { execFile } from "child_process";
4510
4257
 
4511
4258
  // src/commands/component/registry-preparer.ts
4512
- import fs14 from "fs";
4513
- import path12 from "path";
4259
+ import fs13 from "fs";
4260
+ import path11 from "path";
4514
4261
  import os from "os";
4515
4262
 
4516
4263
  // src/commands/component/service.ts
@@ -4566,7 +4313,7 @@ async function sendInstallEvent(key) {
4566
4313
  }
4567
4314
 
4568
4315
  // src/commands/component/registry-preparer.ts
4569
- var REGISTRY_TEMP_DIR = path12.join(os.tmpdir(), "miaoda-registry");
4316
+ var REGISTRY_TEMP_DIR = path11.join(os.tmpdir(), "miaoda-registry");
4570
4317
  function parseComponentKey(key) {
4571
4318
  const match = key.match(/^@([^/]+)\/(.+)$/);
4572
4319
  if (!match) {
@@ -4578,11 +4325,11 @@ function parseComponentKey(key) {
4578
4325
  }
4579
4326
  function getLocalRegistryPath(key) {
4580
4327
  const { scope, name } = parseComponentKey(key);
4581
- return path12.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4328
+ return path11.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4582
4329
  }
4583
4330
  function ensureDir(dirPath) {
4584
- if (!fs14.existsSync(dirPath)) {
4585
- fs14.mkdirSync(dirPath, { recursive: true });
4331
+ if (!fs13.existsSync(dirPath)) {
4332
+ fs13.mkdirSync(dirPath, { recursive: true });
4586
4333
  }
4587
4334
  }
4588
4335
  async function prepareRecursive(key, visited) {
@@ -4615,8 +4362,8 @@ async function prepareRecursive(key, visited) {
4615
4362
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
4616
4363
  };
4617
4364
  const localPath = getLocalRegistryPath(key);
4618
- ensureDir(path12.dirname(localPath));
4619
- fs14.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4365
+ ensureDir(path11.dirname(localPath));
4366
+ fs13.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4620
4367
  debug("\u4FDD\u5B58\u5230: %s", localPath);
4621
4368
  }
4622
4369
  async function prepareComponentRegistryItems(id) {
@@ -4626,18 +4373,18 @@ async function prepareComponentRegistryItems(id) {
4626
4373
  }
4627
4374
  function cleanupTempDir() {
4628
4375
  try {
4629
- if (fs14.existsSync(REGISTRY_TEMP_DIR)) {
4630
- fs14.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4376
+ if (fs13.existsSync(REGISTRY_TEMP_DIR)) {
4377
+ fs13.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4631
4378
  }
4632
4379
  } catch {
4633
4380
  }
4634
4381
  }
4635
4382
  function getDownloadedRegistryItem(itemId) {
4636
4383
  const localPath = getLocalRegistryPath(itemId);
4637
- if (!fs14.existsSync(localPath)) {
4384
+ if (!fs13.existsSync(localPath)) {
4638
4385
  return null;
4639
4386
  }
4640
- const content = fs14.readFileSync(localPath, "utf-8");
4387
+ const content = fs13.readFileSync(localPath, "utf-8");
4641
4388
  return JSON.parse(content);
4642
4389
  }
4643
4390
 
@@ -4805,58 +4552,58 @@ var componentCommandGroup = {
4805
4552
  };
4806
4553
 
4807
4554
  // src/commands/migration/version-manager.ts
4808
- import fs15 from "fs";
4809
- import path13 from "path";
4555
+ import fs14 from "fs";
4556
+ import path12 from "path";
4810
4557
  var PACKAGE_JSON = "package.json";
4811
4558
  var VERSION_FIELD = "migrationVersion";
4812
4559
  function getPackageJsonPath2() {
4813
- return path13.join(process.cwd(), PACKAGE_JSON);
4560
+ return path12.join(process.cwd(), PACKAGE_JSON);
4814
4561
  }
4815
4562
  function getCurrentVersion() {
4816
4563
  const pkgPath = getPackageJsonPath2();
4817
- if (!fs15.existsSync(pkgPath)) {
4564
+ if (!fs14.existsSync(pkgPath)) {
4818
4565
  throw new Error("package.json not found");
4819
4566
  }
4820
- const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
4567
+ const pkg2 = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
4821
4568
  return pkg2[VERSION_FIELD] ?? 0;
4822
4569
  }
4823
4570
  function setCurrentVersion(version) {
4824
4571
  const pkgPath = getPackageJsonPath2();
4825
- const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
4572
+ const pkg2 = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
4826
4573
  pkg2[VERSION_FIELD] = version;
4827
- fs15.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4574
+ fs14.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4828
4575
  }
4829
4576
 
4830
4577
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4831
- import fs17 from "fs";
4832
- import path15 from "path";
4833
-
4834
- // src/commands/migration/versions/v001_capability/utils.ts
4835
4578
  import fs16 from "fs";
4836
4579
  import path14 from "path";
4580
+
4581
+ // src/commands/migration/versions/v001_capability/utils.ts
4582
+ import fs15 from "fs";
4583
+ import path13 from "path";
4837
4584
  var CAPABILITIES_DIR2 = "server/capabilities";
4838
4585
  function getProjectRoot3() {
4839
4586
  return process.cwd();
4840
4587
  }
4841
4588
  function getCapabilitiesDir2() {
4842
- return path14.join(getProjectRoot3(), CAPABILITIES_DIR2);
4589
+ return path13.join(getProjectRoot3(), CAPABILITIES_DIR2);
4843
4590
  }
4844
4591
  function getPluginManifestPath2(pluginKey) {
4845
- return path14.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4592
+ return path13.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4846
4593
  }
4847
4594
 
4848
4595
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4849
4596
  function detectJsonMigration() {
4850
4597
  const capabilitiesDir = getCapabilitiesDir2();
4851
- const oldFilePath = path15.join(capabilitiesDir, "capabilities.json");
4852
- if (!fs17.existsSync(oldFilePath)) {
4598
+ const oldFilePath = path14.join(capabilitiesDir, "capabilities.json");
4599
+ if (!fs16.existsSync(oldFilePath)) {
4853
4600
  return {
4854
4601
  needsMigration: false,
4855
4602
  reason: "capabilities.json not found"
4856
4603
  };
4857
4604
  }
4858
4605
  try {
4859
- const content = fs17.readFileSync(oldFilePath, "utf-8");
4606
+ const content = fs16.readFileSync(oldFilePath, "utf-8");
4860
4607
  const parsed = JSON.parse(content);
4861
4608
  if (!Array.isArray(parsed)) {
4862
4609
  return {
@@ -4907,8 +4654,8 @@ async function check(options) {
4907
4654
  }
4908
4655
 
4909
4656
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
4910
- import fs18 from "fs";
4911
- import path16 from "path";
4657
+ import fs17 from "fs";
4658
+ import path15 from "path";
4912
4659
 
4913
4660
  // src/commands/migration/versions/v001_capability/mapping.ts
4914
4661
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -5138,18 +4885,18 @@ function transformCapabilities(oldCapabilities) {
5138
4885
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5139
4886
  function loadExistingCapabilities() {
5140
4887
  const capabilitiesDir = getCapabilitiesDir2();
5141
- if (!fs18.existsSync(capabilitiesDir)) {
4888
+ if (!fs17.existsSync(capabilitiesDir)) {
5142
4889
  return [];
5143
4890
  }
5144
- const files = fs18.readdirSync(capabilitiesDir);
4891
+ const files = fs17.readdirSync(capabilitiesDir);
5145
4892
  const capabilities = [];
5146
4893
  for (const file of files) {
5147
4894
  if (file === "capabilities.json" || !file.endsWith(".json")) {
5148
4895
  continue;
5149
4896
  }
5150
4897
  try {
5151
- const filePath = path16.join(capabilitiesDir, file);
5152
- const content = fs18.readFileSync(filePath, "utf-8");
4898
+ const filePath = path15.join(capabilitiesDir, file);
4899
+ const content = fs17.readFileSync(filePath, "utf-8");
5153
4900
  const capability = JSON.parse(content);
5154
4901
  if (capability.id && capability.pluginKey) {
5155
4902
  capabilities.push(capability);
@@ -5207,9 +4954,9 @@ async function migrateJsonFiles(options) {
5207
4954
  }
5208
4955
  const capabilitiesDir = getCapabilitiesDir2();
5209
4956
  for (const cap of newCapabilities) {
5210
- const filePath = path16.join(capabilitiesDir, `${cap.id}.json`);
4957
+ const filePath = path15.join(capabilitiesDir, `${cap.id}.json`);
5211
4958
  const content = JSON.stringify(cap, null, 2);
5212
- fs18.writeFileSync(filePath, content, "utf-8");
4959
+ fs17.writeFileSync(filePath, content, "utf-8");
5213
4960
  console.log(` \u2713 Created: ${cap.id}.json`);
5214
4961
  }
5215
4962
  return {
@@ -5221,11 +4968,11 @@ async function migrateJsonFiles(options) {
5221
4968
  }
5222
4969
 
5223
4970
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
5224
- import fs19 from "fs";
4971
+ import fs18 from "fs";
5225
4972
  function isPluginInstalled2(pluginKey) {
5226
4973
  const actionPlugins = readActionPlugins();
5227
4974
  const manifestPath = getPluginManifestPath2(pluginKey);
5228
- return fs19.existsSync(manifestPath) && !!actionPlugins[pluginKey];
4975
+ return fs18.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5229
4976
  }
5230
4977
  function detectPluginsToInstall(capabilities) {
5231
4978
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -5301,12 +5048,12 @@ async function installPlugins(capabilities, options) {
5301
5048
  }
5302
5049
 
5303
5050
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
5304
- import path18 from "path";
5051
+ import path17 from "path";
5305
5052
  import { Project as Project3 } from "ts-morph";
5306
5053
 
5307
5054
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
5308
- import fs20 from "fs";
5309
- import path17 from "path";
5055
+ import fs19 from "fs";
5056
+ import path16 from "path";
5310
5057
  var EXCLUDED_DIRS = [
5311
5058
  "node_modules",
5312
5059
  "dist",
@@ -5321,9 +5068,9 @@ var EXCLUDED_PATTERNS = [
5321
5068
  /\.d\.ts$/
5322
5069
  ];
5323
5070
  function scanDirectory(dir, files = []) {
5324
- const entries = fs20.readdirSync(dir, { withFileTypes: true });
5071
+ const entries = fs19.readdirSync(dir, { withFileTypes: true });
5325
5072
  for (const entry of entries) {
5326
- const fullPath = path17.join(dir, entry.name);
5073
+ const fullPath = path16.join(dir, entry.name);
5327
5074
  if (entry.isDirectory()) {
5328
5075
  if (EXCLUDED_DIRS.includes(entry.name)) {
5329
5076
  continue;
@@ -5339,14 +5086,14 @@ function scanDirectory(dir, files = []) {
5339
5086
  return files;
5340
5087
  }
5341
5088
  function scanServerFiles() {
5342
- const serverDir = path17.join(getProjectRoot3(), "server");
5343
- if (!fs20.existsSync(serverDir)) {
5089
+ const serverDir = path16.join(getProjectRoot3(), "server");
5090
+ if (!fs19.existsSync(serverDir)) {
5344
5091
  return [];
5345
5092
  }
5346
5093
  return scanDirectory(serverDir);
5347
5094
  }
5348
5095
  function hasCapabilityImport(filePath) {
5349
- const content = fs20.readFileSync(filePath, "utf-8");
5096
+ const content = fs19.readFileSync(filePath, "utf-8");
5350
5097
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
5351
5098
  }
5352
5099
  function scanFilesToMigrate() {
@@ -5723,7 +5470,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5723
5470
  const callSites = analyzeCallSites(sourceFile, imports);
5724
5471
  const classInfo = analyzeClass(sourceFile);
5725
5472
  const { canMigrate, reason } = canAutoMigrate(classInfo);
5726
- const relativePath = path18.relative(getProjectRoot3(), filePath);
5473
+ const relativePath = path17.relative(getProjectRoot3(), filePath);
5727
5474
  return {
5728
5475
  filePath: relativePath,
5729
5476
  imports,
@@ -5734,7 +5481,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5734
5481
  };
5735
5482
  }
5736
5483
  function migrateFile(project, analysis, dryRun) {
5737
- const absolutePath = path18.join(getProjectRoot3(), analysis.filePath);
5484
+ const absolutePath = path17.join(getProjectRoot3(), analysis.filePath);
5738
5485
  if (!analysis.canAutoMigrate) {
5739
5486
  return {
5740
5487
  filePath: analysis.filePath,
@@ -5837,17 +5584,17 @@ function getSuggestion(analysis) {
5837
5584
  }
5838
5585
 
5839
5586
  // src/commands/migration/versions/v001_capability/cleanup.ts
5840
- import fs21 from "fs";
5841
- import path19 from "path";
5587
+ import fs20 from "fs";
5588
+ import path18 from "path";
5842
5589
  function cleanupOldFiles(capabilities, dryRun) {
5843
5590
  const deletedFiles = [];
5844
5591
  const errors = [];
5845
5592
  const capabilitiesDir = getCapabilitiesDir2();
5846
- const oldJsonPath = path19.join(capabilitiesDir, "capabilities.json");
5847
- if (fs21.existsSync(oldJsonPath)) {
5593
+ const oldJsonPath = path18.join(capabilitiesDir, "capabilities.json");
5594
+ if (fs20.existsSync(oldJsonPath)) {
5848
5595
  try {
5849
5596
  if (!dryRun) {
5850
- fs21.unlinkSync(oldJsonPath);
5597
+ fs20.unlinkSync(oldJsonPath);
5851
5598
  }
5852
5599
  deletedFiles.push("capabilities.json");
5853
5600
  } catch (error) {
@@ -5855,11 +5602,11 @@ function cleanupOldFiles(capabilities, dryRun) {
5855
5602
  }
5856
5603
  }
5857
5604
  for (const cap of capabilities) {
5858
- const tsFilePath = path19.join(capabilitiesDir, `${cap.id}.ts`);
5859
- if (fs21.existsSync(tsFilePath)) {
5605
+ const tsFilePath = path18.join(capabilitiesDir, `${cap.id}.ts`);
5606
+ if (fs20.existsSync(tsFilePath)) {
5860
5607
  try {
5861
5608
  if (!dryRun) {
5862
- fs21.unlinkSync(tsFilePath);
5609
+ fs20.unlinkSync(tsFilePath);
5863
5610
  }
5864
5611
  deletedFiles.push(`${cap.id}.ts`);
5865
5612
  } catch (error) {
@@ -5875,8 +5622,8 @@ function cleanupOldFiles(capabilities, dryRun) {
5875
5622
  }
5876
5623
 
5877
5624
  // src/commands/migration/versions/v001_capability/report-generator.ts
5878
- import fs22 from "fs";
5879
- import path20 from "path";
5625
+ import fs21 from "fs";
5626
+ import path19 from "path";
5880
5627
  var REPORT_FILE = "capability-migration-report.md";
5881
5628
  function printSummary(result) {
5882
5629
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -6039,15 +5786,15 @@ async function generateReport(result) {
6039
5786
  }
6040
5787
  lines.push("");
6041
5788
  const logDir = process.env.LOG_DIR || "logs";
6042
- if (!fs22.existsSync(logDir)) {
5789
+ if (!fs21.existsSync(logDir)) {
6043
5790
  return;
6044
5791
  }
6045
- const reportDir = path20.join(logDir, "migration");
6046
- if (!fs22.existsSync(reportDir)) {
6047
- fs22.mkdirSync(reportDir, { recursive: true });
5792
+ const reportDir = path19.join(logDir, "migration");
5793
+ if (!fs21.existsSync(reportDir)) {
5794
+ fs21.mkdirSync(reportDir, { recursive: true });
6048
5795
  }
6049
- const reportPath = path20.join(reportDir, REPORT_FILE);
6050
- fs22.writeFileSync(reportPath, lines.join("\n"), "utf-8");
5796
+ const reportPath = path19.join(reportDir, REPORT_FILE);
5797
+ fs21.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6051
5798
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
6052
5799
  }
6053
5800
 
@@ -6579,10 +6326,10 @@ var migrationCommand = {
6579
6326
  };
6580
6327
 
6581
6328
  // src/commands/read-logs/index.ts
6582
- import path21 from "path";
6329
+ import path20 from "path";
6583
6330
 
6584
6331
  // src/commands/read-logs/std-utils.ts
6585
- import fs23 from "fs";
6332
+ import fs22 from "fs";
6586
6333
  function formatStdPrefixTime(localTime) {
6587
6334
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
6588
6335
  if (!match) return localTime;
@@ -6612,11 +6359,11 @@ function stripPrefixFromStdLine(line) {
6612
6359
  return `[${time}] ${content}`;
6613
6360
  }
6614
6361
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
6615
- const stat = fs23.statSync(filePath);
6362
+ const stat = fs22.statSync(filePath);
6616
6363
  if (stat.size === 0) {
6617
6364
  return { lines: [], markerFound: false, totalLinesCount: 0 };
6618
6365
  }
6619
- const fd = fs23.openSync(filePath, "r");
6366
+ const fd = fs22.openSync(filePath, "r");
6620
6367
  const chunkSize = 64 * 1024;
6621
6368
  let position = stat.size;
6622
6369
  let remainder = "";
@@ -6630,7 +6377,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6630
6377
  const length = Math.min(chunkSize, position);
6631
6378
  position -= length;
6632
6379
  const buffer = Buffer.alloc(length);
6633
- fs23.readSync(fd, buffer, 0, length, position);
6380
+ fs22.readSync(fd, buffer, 0, length, position);
6634
6381
  let chunk = buffer.toString("utf8");
6635
6382
  if (remainder) {
6636
6383
  chunk += remainder;
@@ -6672,7 +6419,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6672
6419
  }
6673
6420
  }
6674
6421
  } finally {
6675
- fs23.closeSync(fd);
6422
+ fs22.closeSync(fd);
6676
6423
  }
6677
6424
  return { lines: collected.reverse(), markerFound, totalLinesCount };
6678
6425
  }
@@ -6693,21 +6440,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
6693
6440
  }
6694
6441
 
6695
6442
  // src/commands/read-logs/tail.ts
6696
- import fs24 from "fs";
6443
+ import fs23 from "fs";
6697
6444
  function fileExists(filePath) {
6698
6445
  try {
6699
- fs24.accessSync(filePath, fs24.constants.F_OK | fs24.constants.R_OK);
6446
+ fs23.accessSync(filePath, fs23.constants.F_OK | fs23.constants.R_OK);
6700
6447
  return true;
6701
6448
  } catch {
6702
6449
  return false;
6703
6450
  }
6704
6451
  }
6705
6452
  function readFileTailLines(filePath, maxLines) {
6706
- const stat = fs24.statSync(filePath);
6453
+ const stat = fs23.statSync(filePath);
6707
6454
  if (stat.size === 0) {
6708
6455
  return [];
6709
6456
  }
6710
- const fd = fs24.openSync(filePath, "r");
6457
+ const fd = fs23.openSync(filePath, "r");
6711
6458
  const chunkSize = 64 * 1024;
6712
6459
  const chunks = [];
6713
6460
  let position = stat.size;
@@ -6717,13 +6464,13 @@ function readFileTailLines(filePath, maxLines) {
6717
6464
  const length = Math.min(chunkSize, position);
6718
6465
  position -= length;
6719
6466
  const buffer = Buffer.alloc(length);
6720
- fs24.readSync(fd, buffer, 0, length, position);
6467
+ fs23.readSync(fd, buffer, 0, length, position);
6721
6468
  chunks.unshift(buffer.toString("utf8"));
6722
6469
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
6723
6470
  collectedLines += chunkLines;
6724
6471
  }
6725
6472
  } finally {
6726
- fs24.closeSync(fd);
6473
+ fs23.closeSync(fd);
6727
6474
  }
6728
6475
  const content = chunks.join("");
6729
6476
  const allLines = content.split("\n");
@@ -6739,11 +6486,11 @@ function readFileTailLines(filePath, maxLines) {
6739
6486
  return allLines.slice(allLines.length - maxLines);
6740
6487
  }
6741
6488
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6742
- const stat = fs24.statSync(filePath);
6489
+ const stat = fs23.statSync(filePath);
6743
6490
  if (stat.size === 0) {
6744
6491
  return { lines: [], totalLinesCount: 0 };
6745
6492
  }
6746
- const fd = fs24.openSync(filePath, "r");
6493
+ const fd = fs23.openSync(filePath, "r");
6747
6494
  const chunkSize = 64 * 1024;
6748
6495
  let position = stat.size;
6749
6496
  let remainder = "";
@@ -6755,7 +6502,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6755
6502
  const length = Math.min(chunkSize, position);
6756
6503
  position -= length;
6757
6504
  const buffer = Buffer.alloc(length);
6758
- fs24.readSync(fd, buffer, 0, length, position);
6505
+ fs23.readSync(fd, buffer, 0, length, position);
6759
6506
  let chunk = buffer.toString("utf8");
6760
6507
  if (remainder) {
6761
6508
  chunk += remainder;
@@ -6786,7 +6533,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6786
6533
  }
6787
6534
  }
6788
6535
  } finally {
6789
- fs24.closeSync(fd);
6536
+ fs23.closeSync(fd);
6790
6537
  }
6791
6538
  return { lines: collected.reverse(), totalLinesCount };
6792
6539
  }
@@ -6928,7 +6675,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
6928
6675
  }
6929
6676
 
6930
6677
  // src/commands/read-logs/json-lines.ts
6931
- import fs25 from "fs";
6678
+ import fs24 from "fs";
6932
6679
  function normalizePid(value) {
6933
6680
  if (typeof value === "number") {
6934
6681
  return String(value);
@@ -6979,11 +6726,11 @@ function buildWantedLevelSet(levels) {
6979
6726
  return set.size > 0 ? set : null;
6980
6727
  }
6981
6728
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
6982
- const stat = fs25.statSync(filePath);
6729
+ const stat = fs24.statSync(filePath);
6983
6730
  if (stat.size === 0) {
6984
6731
  return { lines: [], totalLinesCount: 0 };
6985
6732
  }
6986
- const fd = fs25.openSync(filePath, "r");
6733
+ const fd = fs24.openSync(filePath, "r");
6987
6734
  const chunkSize = 64 * 1024;
6988
6735
  let position = stat.size;
6989
6736
  let remainder = "";
@@ -6998,7 +6745,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
6998
6745
  const length = Math.min(chunkSize, position);
6999
6746
  position -= length;
7000
6747
  const buffer = Buffer.alloc(length);
7001
- fs25.readSync(fd, buffer, 0, length, position);
6748
+ fs24.readSync(fd, buffer, 0, length, position);
7002
6749
  let chunk = buffer.toString("utf8");
7003
6750
  if (remainder) {
7004
6751
  chunk += remainder;
@@ -7060,7 +6807,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7060
6807
  }
7061
6808
  }
7062
6809
  } finally {
7063
- fs25.closeSync(fd);
6810
+ fs24.closeSync(fd);
7064
6811
  }
7065
6812
  return { lines: collected.reverse(), totalLinesCount };
7066
6813
  }
@@ -7103,11 +6850,11 @@ function extractTraceId(obj) {
7103
6850
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7104
6851
  const wanted = traceId.trim();
7105
6852
  if (!wanted) return { lines: [], totalLinesCount: 0 };
7106
- const stat = fs25.statSync(filePath);
6853
+ const stat = fs24.statSync(filePath);
7107
6854
  if (stat.size === 0) {
7108
6855
  return { lines: [], totalLinesCount: 0 };
7109
6856
  }
7110
- const fd = fs25.openSync(filePath, "r");
6857
+ const fd = fs24.openSync(filePath, "r");
7111
6858
  const chunkSize = 64 * 1024;
7112
6859
  let position = stat.size;
7113
6860
  let remainder = "";
@@ -7120,7 +6867,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7120
6867
  const length = Math.min(chunkSize, position);
7121
6868
  position -= length;
7122
6869
  const buffer = Buffer.alloc(length);
7123
- fs25.readSync(fd, buffer, 0, length, position);
6870
+ fs24.readSync(fd, buffer, 0, length, position);
7124
6871
  let chunk = buffer.toString("utf8");
7125
6872
  if (remainder) {
7126
6873
  chunk += remainder;
@@ -7173,7 +6920,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7173
6920
  }
7174
6921
  }
7175
6922
  } finally {
7176
- fs25.closeSync(fd);
6923
+ fs24.closeSync(fd);
7177
6924
  }
7178
6925
  return { lines: collected.reverse(), totalLinesCount };
7179
6926
  }
@@ -7182,11 +6929,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7182
6929
  if (!wantedLevelSet) {
7183
6930
  return { lines: [], totalLinesCount: 0 };
7184
6931
  }
7185
- const stat = fs25.statSync(filePath);
6932
+ const stat = fs24.statSync(filePath);
7186
6933
  if (stat.size === 0) {
7187
6934
  return { lines: [], totalLinesCount: 0 };
7188
6935
  }
7189
- const fd = fs25.openSync(filePath, "r");
6936
+ const fd = fs24.openSync(filePath, "r");
7190
6937
  const chunkSize = 64 * 1024;
7191
6938
  let position = stat.size;
7192
6939
  let remainder = "";
@@ -7198,7 +6945,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7198
6945
  const length = Math.min(chunkSize, position);
7199
6946
  position -= length;
7200
6947
  const buffer = Buffer.alloc(length);
7201
- fs25.readSync(fd, buffer, 0, length, position);
6948
+ fs24.readSync(fd, buffer, 0, length, position);
7202
6949
  let chunk = buffer.toString("utf8");
7203
6950
  if (remainder) {
7204
6951
  chunk += remainder;
@@ -7245,7 +6992,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7245
6992
  }
7246
6993
  }
7247
6994
  } finally {
7248
- fs25.closeSync(fd);
6995
+ fs24.closeSync(fd);
7249
6996
  }
7250
6997
  return { lines: collected.reverse(), totalLinesCount };
7251
6998
  }
@@ -7479,30 +7226,30 @@ async function readLogsJsonResult(options) {
7479
7226
  };
7480
7227
  }
7481
7228
  function resolveLogFilePath(logDir, type) {
7482
- const base = path21.isAbsolute(logDir) ? logDir : path21.join(process.cwd(), logDir);
7229
+ const base = path20.isAbsolute(logDir) ? logDir : path20.join(process.cwd(), logDir);
7483
7230
  if (type === "server") {
7484
- return path21.join(base, "server.log");
7231
+ return path20.join(base, "server.log");
7485
7232
  }
7486
7233
  if (type === "trace") {
7487
- return path21.join(base, "trace.log");
7234
+ return path20.join(base, "trace.log");
7488
7235
  }
7489
7236
  if (type === "server-std") {
7490
- return path21.join(base, "server.std.log");
7237
+ return path20.join(base, "server.std.log");
7491
7238
  }
7492
7239
  if (type === "client-std") {
7493
- return path21.join(base, "client.std.log");
7240
+ return path20.join(base, "client.std.log");
7494
7241
  }
7495
7242
  if (type === "dev") {
7496
- return path21.join(base, "dev.log");
7243
+ return path20.join(base, "dev.log");
7497
7244
  }
7498
7245
  if (type === "dev-std") {
7499
- return path21.join(base, "dev.std.log");
7246
+ return path20.join(base, "dev.std.log");
7500
7247
  }
7501
7248
  if (type === "install-dep-std") {
7502
- return path21.join(base, "install-dep.std.log");
7249
+ return path20.join(base, "install-dep.std.log");
7503
7250
  }
7504
7251
  if (type === "browser") {
7505
- return path21.join(base, "browser.log");
7252
+ return path20.join(base, "browser.log");
7506
7253
  }
7507
7254
  throw new Error(`Unsupported log type: ${type}`);
7508
7255
  }
@@ -7679,9 +7426,9 @@ function camelToKebab(str) {
7679
7426
  }
7680
7427
 
7681
7428
  // src/commands/build/upload-static.handler.ts
7682
- import * as fs26 from "fs";
7429
+ import * as fs25 from "fs";
7683
7430
  import * as os2 from "os";
7684
- import * as path22 from "path";
7431
+ import * as path21 from "path";
7685
7432
  import { execFileSync } from "child_process";
7686
7433
  function readCredentialsFromEnv() {
7687
7434
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -7705,8 +7452,8 @@ async function uploadStatic(options) {
7705
7452
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7706
7453
  region = UPLOAD_STATIC_DEFAULTS.region
7707
7454
  } = options;
7708
- const resolvedStaticDir = path22.resolve(staticDir);
7709
- if (!fs26.existsSync(resolvedStaticDir)) {
7455
+ const resolvedStaticDir = path21.resolve(staticDir);
7456
+ if (!fs25.existsSync(resolvedStaticDir)) {
7710
7457
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7711
7458
  return;
7712
7459
  }
@@ -7739,8 +7486,8 @@ async function uploadStatic(options) {
7739
7486
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7740
7487
  }
7741
7488
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7742
- const confPath = path22.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7743
- fs26.writeFileSync(confPath, "");
7489
+ const confPath = path21.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7490
+ fs25.writeFileSync(confPath, "");
7744
7491
  try {
7745
7492
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7746
7493
  configureTosutil(resolvedTosutil, confPath, {
@@ -7754,7 +7501,7 @@ async function uploadStatic(options) {
7754
7501
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7755
7502
  } finally {
7756
7503
  try {
7757
- fs26.unlinkSync(confPath);
7504
+ fs25.unlinkSync(confPath);
7758
7505
  } catch {
7759
7506
  }
7760
7507
  }
@@ -7774,8 +7521,8 @@ async function uploadStatic(options) {
7774
7521
  }
7775
7522
  }
7776
7523
  function resolveTosutilPath(tosutilPath) {
7777
- if (path22.isAbsolute(tosutilPath)) {
7778
- return fs26.existsSync(tosutilPath) ? tosutilPath : null;
7524
+ if (path21.isAbsolute(tosutilPath)) {
7525
+ return fs25.existsSync(tosutilPath) ? tosutilPath : null;
7779
7526
  }
7780
7527
  try {
7781
7528
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -7820,7 +7567,7 @@ async function resolveBucketId(appId) {
7820
7567
  return bucketId;
7821
7568
  }
7822
7569
  function isDirEmpty(dirPath) {
7823
- const entries = fs26.readdirSync(dirPath);
7570
+ const entries = fs25.readdirSync(dirPath);
7824
7571
  return entries.length === 0;
7825
7572
  }
7826
7573
 
@@ -7915,12 +7662,12 @@ var commands = [
7915
7662
  ];
7916
7663
 
7917
7664
  // src/index.ts
7918
- var envPath = path23.join(process.cwd(), ".env");
7919
- if (fs27.existsSync(envPath)) {
7665
+ var envPath = path22.join(process.cwd(), ".env");
7666
+ if (fs26.existsSync(envPath)) {
7920
7667
  dotenvConfig({ path: envPath });
7921
7668
  }
7922
- var __dirname = path23.dirname(fileURLToPath5(import.meta.url));
7923
- var pkg = JSON.parse(fs27.readFileSync(path23.join(__dirname, "../package.json"), "utf-8"));
7669
+ var __dirname = path22.dirname(fileURLToPath5(import.meta.url));
7670
+ var pkg = JSON.parse(fs26.readFileSync(path22.join(__dirname, "../package.json"), "utf-8"));
7924
7671
  var cli = new FullstackCLI(pkg.version);
7925
7672
  cli.useAll(commands);
7926
7673
  cli.run();