@lark-apaas/fullstack-cli 1.1.40-alpha.9 → 1.1.41

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 fs27 from "fs";
3
+ import path23 from "path";
4
4
  import { fileURLToPath as fileURLToPath5 } from "url";
5
5
  import { config as dotenvConfig } from "dotenv";
6
6
 
@@ -2167,7 +2167,9 @@ async function run(options = {}) {
2167
2167
  process.exit(1);
2168
2168
  }
2169
2169
  const outputPath = options.output || process.env.DB_SCHEMA_OUTPUT || "server/database/schema.ts";
2170
- const OUT_DIR = path2.resolve(process.cwd(), "server/database/.introspect");
2170
+ const INTROSPECT_ROOT = path2.resolve(process.cwd(), "tmp/.introspect");
2171
+ fs4.mkdirSync(INTROSPECT_ROOT, { recursive: true });
2172
+ const OUT_DIR = fs4.mkdtempSync(path2.join(INTROSPECT_ROOT, "run-"));
2171
2173
  const SCHEMA_FILE = path2.resolve(process.cwd(), outputPath);
2172
2174
  console.log("[gen-db-schema] Starting...");
2173
2175
  const __filename = fileURLToPath2(import.meta.url);
@@ -3105,25 +3107,26 @@ async function run3(options = {}) {
3105
3107
 
3106
3108
  // src/commands/upgrade/deps/run.handler.ts
3107
3109
  import { spawnSync as spawnSync3 } from "child_process";
3108
- import fs11 from "fs";
3109
- import path9 from "path";
3110
+ import fs10 from "fs";
3111
+ import path8 from "path";
3110
3112
 
3111
3113
  // src/utils/grayscale/config.ts
3112
3114
  function getGrayscaleConfig(configJson) {
3113
- const raw = configJson || process.env.GRAYSCALE_CONFIG;
3114
- if (!raw) {
3115
+ if (!configJson) {
3115
3116
  return null;
3116
3117
  }
3117
3118
  try {
3118
- const parsed = JSON.parse(raw);
3119
- const config = parsed.config || parsed;
3120
- const tenantId = parsed.tenant_id != null ? String(parsed.tenant_id) : void 0;
3121
- const appId = parsed.app_id || void 0;
3122
- const xTtEnv = parsed.x_tt_env || void 0;
3123
- if (!config.enabled) {
3119
+ const parsed = JSON.parse(configJson);
3120
+ const config = parsed.config;
3121
+ if (!config || !config.enabled) {
3124
3122
  return null;
3125
3123
  }
3126
- return { config, tenantId, appId, xTtEnv };
3124
+ return {
3125
+ config,
3126
+ tenantId: parsed.tenant_id != null ? String(parsed.tenant_id) : void 0,
3127
+ appId: parsed.app_id || void 0,
3128
+ xTtEnv: parsed.x_tt_env || void 0
3129
+ };
3127
3130
  } catch {
3128
3131
  console.warn("[grayscale] Failed to parse grayscale config");
3129
3132
  return null;
@@ -3131,108 +3134,32 @@ function getGrayscaleConfig(configJson) {
3131
3134
  }
3132
3135
 
3133
3136
  // src/utils/grayscale/identity.ts
3134
- import fs10 from "fs";
3135
- import path8 from "path";
3136
- function readFromEnvVars() {
3137
- const appId = process.env.app_id || process.env.APP_ID;
3138
- const tenantId = process.env.tenant_id || process.env.TENANT_ID;
3139
- const xTtEnv = process.env.FORCE_FRAMEWORK_CLI_CANARY_ENV || process.env.x_tt_env;
3140
- return { appId, tenantId, xTtEnv };
3141
- }
3142
- function parseEnvFile(filePath) {
3143
- const result = {};
3144
- if (!fs10.existsSync(filePath)) {
3145
- return result;
3146
- }
3147
- try {
3148
- const content = fs10.readFileSync(filePath, "utf-8");
3149
- const lines = content.split("\n");
3150
- for (const line of lines) {
3151
- const trimmed = line.trim();
3152
- if (!trimmed || trimmed.startsWith("#")) {
3153
- continue;
3154
- }
3155
- const match = trimmed.match(/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=["']?(.+?)["']?$/);
3156
- if (match) {
3157
- result[match[1]] = match[2];
3158
- }
3159
- }
3160
- } catch {
3161
- }
3162
- return result;
3163
- }
3164
- function readFromForceEnvFile(cwd) {
3165
- const envPath2 = path8.join(cwd, ".force", "environment", "env");
3166
- const vars = parseEnvFile(envPath2);
3167
- return {
3168
- appId: vars.app_id || vars.APP_ID,
3169
- tenantId: vars.tenant_id || vars.TENANT_ID,
3170
- xTtEnv: vars.FORCE_FRAMEWORK_CLI_CANARY_ENV || vars.x_tt_env
3171
- };
3172
- }
3173
- function readFromClientBasePath() {
3174
- const basePath = process.env.CLIENT_BASE_PATH;
3175
- if (!basePath) {
3176
- return {};
3177
- }
3178
- const afMatch = basePath.match(/\/af\/p\/([^/]+)/);
3179
- if (afMatch) {
3180
- return { appId: afMatch[1] };
3181
- }
3182
- const appMatch = basePath.match(/\/app\/([^/]+)/);
3183
- if (appMatch) {
3184
- return { appId: appMatch[1] };
3185
- }
3186
- return {};
3187
- }
3188
- function readFromDotEnv(cwd) {
3189
- const envPath2 = path8.join(cwd, ".env");
3190
- const vars = parseEnvFile(envPath2);
3137
+ function readProjectIdentity() {
3191
3138
  return {
3192
- appId: vars.app_id || vars.APP_ID,
3193
- tenantId: vars.tenant_id || vars.TENANT_ID,
3194
- xTtEnv: vars.FORCE_FRAMEWORK_CLI_CANARY_ENV || vars.x_tt_env
3139
+ appId: process.env.app_id || process.env.APP_ID,
3140
+ tenantId: process.env.tenant_id || process.env.TENANT_ID,
3141
+ xTtEnv: process.env.FORCE_FRAMEWORK_CLI_CANARY_ENV || process.env.x_tt_env
3195
3142
  };
3196
3143
  }
3197
- function readFromPackageJson(cwd) {
3198
- const pkgPath = path8.join(cwd, "package.json");
3199
- if (!fs10.existsSync(pkgPath)) {
3200
- return {};
3201
- }
3202
- try {
3203
- const content = fs10.readFileSync(pkgPath, "utf-8");
3204
- const pkg2 = JSON.parse(content);
3205
- const appId = pkg2?.fullstack?.appId;
3206
- return appId ? { appId } : {};
3207
- } catch {
3208
- return {};
3209
- }
3210
- }
3211
- function readProjectIdentity(cwd) {
3212
- const sources = [
3213
- () => readFromEnvVars(),
3214
- () => readFromForceEnvFile(cwd),
3215
- () => readFromClientBasePath(),
3216
- () => readFromDotEnv(cwd),
3217
- () => readFromPackageJson(cwd)
3218
- ];
3219
- const merged = {};
3220
- for (const source of sources) {
3221
- const identity = source();
3222
- if (!merged.appId && identity.appId) {
3223
- merged.appId = identity.appId;
3224
- }
3225
- if (!merged.tenantId && identity.tenantId) {
3226
- merged.tenantId = identity.tenantId;
3227
- }
3228
- if (!merged.xTtEnv && identity.xTtEnv) {
3229
- merged.xTtEnv = identity.xTtEnv;
3230
- }
3231
- }
3232
- return merged;
3233
- }
3144
+
3145
+ // src/utils/grayscale/types.ts
3146
+ var RuleType = {
3147
+ TenantID: "tenant_id",
3148
+ AppID: "app_id",
3149
+ Canary: "canary",
3150
+ Percentage: "percentage"
3151
+ };
3234
3152
 
3235
3153
  // src/utils/grayscale/rules.ts
3154
+ var RULE_PRIORITY = {
3155
+ [RuleType.Canary]: 0,
3156
+ [RuleType.AppID]: 1,
3157
+ [RuleType.TenantID]: 2,
3158
+ [RuleType.Percentage]: 3
3159
+ };
3160
+ function sortRulesByPriority(rules) {
3161
+ return [...rules].sort((a, b) => (RULE_PRIORITY[a.type] ?? 99) - (RULE_PRIORITY[b.type] ?? 99));
3162
+ }
3236
3163
  function isInPercentage(tenantId, percentage) {
3237
3164
  if (percentage <= 0) return false;
3238
3165
  if (percentage >= 100) return true;
@@ -3242,33 +3169,29 @@ function isInPercentage(tenantId, percentage) {
3242
3169
  }
3243
3170
  function matchRule(rule, identity) {
3244
3171
  switch (rule.type) {
3245
- case "tenant_id": {
3172
+ case RuleType.TenantID:
3246
3173
  return !!identity.tenantId && !!rule.values && rule.values.includes(identity.tenantId);
3247
- }
3248
- case "app_id": {
3174
+ case RuleType.AppID:
3249
3175
  return !!identity.appId && !!rule.values && rule.values.includes(identity.appId);
3250
- }
3251
- case "canary": {
3176
+ case RuleType.Canary:
3252
3177
  return identity.xTtEnv === rule.value;
3253
- }
3254
- case "percentage": {
3178
+ case RuleType.Percentage:
3255
3179
  if (rule.value >= 100) return true;
3256
3180
  if (rule.value <= 0) return false;
3257
3181
  if (!identity.tenantId) return false;
3258
3182
  return isInPercentage(identity.tenantId, rule.value);
3259
- }
3260
3183
  default:
3261
3184
  return false;
3262
3185
  }
3263
3186
  }
3264
3187
  function isBlocked(channel, identity) {
3265
3188
  if (!channel.block_rules || channel.block_rules.length === 0) return false;
3266
- return channel.block_rules.some((rule) => matchRule(rule, identity));
3189
+ return sortRulesByPriority(channel.block_rules).some((rule) => matchRule(rule, identity));
3267
3190
  }
3268
3191
  function matchChannel(channel, identity) {
3269
3192
  if (isBlocked(channel, identity)) return false;
3270
3193
  if (!channel.rules || channel.rules.length === 0) return false;
3271
- return channel.rules.some((rule) => matchRule(rule, identity));
3194
+ return sortRulesByPriority(channel.rules).some((rule) => matchRule(rule, identity));
3272
3195
  }
3273
3196
  function resolveTargetVersions(config, identity) {
3274
3197
  const stableVersions = config.stable?.versions || {};
@@ -3289,23 +3212,19 @@ function resolveTargetVersions(config, identity) {
3289
3212
  }
3290
3213
 
3291
3214
  // src/utils/grayscale/index.ts
3292
- function resolveGrayscaleVersions(cwd, configJson) {
3215
+ function resolveGrayscaleVersions(_cwd, configJson) {
3293
3216
  const result = getGrayscaleConfig(configJson);
3294
3217
  if (!result) {
3295
3218
  console.log("[grayscale] Config not available, skipping grayscale");
3296
3219
  return null;
3297
3220
  }
3298
3221
  const { config, tenantId: payloadTenantId, appId: payloadAppId, xTtEnv: payloadXTtEnv } = result;
3299
- const identity = readProjectIdentity(cwd);
3300
- if (payloadTenantId) {
3301
- identity.tenantId = payloadTenantId;
3302
- }
3303
- if (payloadAppId) {
3304
- identity.appId = payloadAppId;
3305
- }
3306
- if (payloadXTtEnv) {
3307
- identity.xTtEnv = payloadXTtEnv;
3308
- }
3222
+ const envIdentity = readProjectIdentity();
3223
+ const identity = {
3224
+ appId: payloadAppId || envIdentity.appId,
3225
+ tenantId: payloadTenantId || envIdentity.tenantId,
3226
+ xTtEnv: payloadXTtEnv || envIdentity.xTtEnv
3227
+ };
3309
3228
  console.log(
3310
3229
  `[grayscale] Project identity: appId=${identity.appId || "N/A"}, tenantId=${identity.tenantId || "N/A"}, xTtEnv=${identity.xTtEnv || "N/A"}`
3311
3230
  );
@@ -3408,10 +3327,14 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
3408
3327
  if (version) {
3409
3328
  let current = "";
3410
3329
  try {
3411
- const installedPkgPath = path9.join(cwd, "node_modules", pkg2, "package.json");
3412
- const installedPkg = JSON.parse(fs11.readFileSync(installedPkgPath, "utf-8"));
3330
+ const installedPkgPath = path8.join(cwd, "node_modules", pkg2, "package.json");
3331
+ const installedPkg = JSON.parse(fs10.readFileSync(installedPkgPath, "utf-8"));
3413
3332
  current = installedPkg.version || "";
3414
- } catch {
3333
+ } catch (err) {
3334
+ const code = err?.code;
3335
+ if (code !== "ENOENT") {
3336
+ console.warn(`[fullstack-cli] Failed to read installed version of ${pkg2}: ${err instanceof Error ? err.message : String(err)}`);
3337
+ }
3415
3338
  }
3416
3339
  if (mode === "destroy") {
3417
3340
  if (!isRangeVersion(version) && current === version) {
@@ -3447,13 +3370,13 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
3447
3370
  return;
3448
3371
  }
3449
3372
  const targets = upgradePlan.map(({ pkg: pkg2, version }) => `${pkg2}@${version}`);
3450
- console.log(`[fullstack-cli] Installing ${targets.join(" ")}...`);
3373
+ console.log(`[fullstack-cli] Installing ${targets.join(" ")}...`);
3451
3374
  const result = spawnSync3("npm", ["install", ...targets], {
3452
3375
  cwd,
3453
3376
  stdio: "inherit"
3454
3377
  });
3455
3378
  if (result.error || result.status !== 0) {
3456
- console.warn(`[fullstack-cli] npm install failed`);
3379
+ console.warn(`[fullstack-cli] npm install failed: ${result.error?.message ?? `exit ${result.status}`}`);
3457
3380
  }
3458
3381
  }
3459
3382
  async function run4(options = {}) {
@@ -3468,7 +3391,13 @@ async function run4(options = {}) {
3468
3391
  }
3469
3392
  console.log(`[fullstack-cli] Found ${packages.length} @lark-apaas package(s):`);
3470
3393
  packages.forEach((p) => console.log(` - ${p}`));
3471
- if (!options.skipGrayscale && !options.version) {
3394
+ if (options.skipGrayscale) {
3395
+ console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (--skip-grayscale)");
3396
+ } else if (options.version) {
3397
+ console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (explicit --version provided)");
3398
+ } else if (!options.grayscaleConfig) {
3399
+ console.log("[fullstack-cli] Step 2/3: No grayscale config, falling back to default upgrade");
3400
+ } else {
3472
3401
  console.log("[fullstack-cli] Step 2/3: Checking grayscale config...");
3473
3402
  try {
3474
3403
  const grayscaleVersions = resolveGrayscaleVersions(cwd, options.grayscaleConfig);
@@ -3479,25 +3408,14 @@ async function run4(options = {}) {
3479
3408
  console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s) via grayscale`);
3480
3409
  console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
3481
3410
  }
3482
- return;
3483
- }
3484
- if (options.grayscaleConfig) {
3411
+ } else {
3485
3412
  console.log("[fullstack-cli] Grayscale config provided but not available, skip upgrade");
3486
- return;
3487
3413
  }
3488
- console.log("[fullstack-cli] Grayscale not available, falling back to default upgrade");
3489
3414
  } catch (error) {
3490
3415
  const msg = error instanceof Error ? error.message : String(error);
3491
- if (options.grayscaleConfig) {
3492
- console.warn(`[fullstack-cli] Grayscale check failed: ${msg}, skip upgrade`);
3493
- return;
3494
- }
3495
- console.warn(`[fullstack-cli] Grayscale check failed: ${msg}, falling back to default upgrade`);
3416
+ console.warn(`[fullstack-cli] Grayscale check failed: ${msg}, skip upgrade`);
3496
3417
  }
3497
- } else if (options.skipGrayscale) {
3498
- console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (--skip-grayscale)");
3499
- } else {
3500
- console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (explicit --version provided)");
3418
+ return;
3501
3419
  }
3502
3420
  if (options.dryRun) {
3503
3421
  console.log("[fullstack-cli] Dry run mode: would upgrade via npm update (no grayscale)");
@@ -3539,8 +3457,8 @@ var upgradeCommand = {
3539
3457
  };
3540
3458
 
3541
3459
  // src/commands/action-plugin/utils.ts
3542
- import fs12 from "fs";
3543
- import path10 from "path";
3460
+ import fs11 from "fs";
3461
+ import path9 from "path";
3544
3462
  import { spawnSync as spawnSync4, execSync as execSync2 } from "child_process";
3545
3463
  function parsePluginName(input) {
3546
3464
  const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
@@ -3558,18 +3476,18 @@ function getProjectRoot() {
3558
3476
  return process.cwd();
3559
3477
  }
3560
3478
  function getPackageJsonPath() {
3561
- return path10.join(getProjectRoot(), "package.json");
3479
+ return path9.join(getProjectRoot(), "package.json");
3562
3480
  }
3563
3481
  function getPluginPath(pluginName) {
3564
- return path10.join(getProjectRoot(), "node_modules", pluginName);
3482
+ return path9.join(getProjectRoot(), "node_modules", pluginName);
3565
3483
  }
3566
3484
  function readPackageJson2() {
3567
3485
  const pkgPath = getPackageJsonPath();
3568
- if (!fs12.existsSync(pkgPath)) {
3486
+ if (!fs11.existsSync(pkgPath)) {
3569
3487
  throw new Error("package.json not found in current directory");
3570
3488
  }
3571
3489
  try {
3572
- const content = fs12.readFileSync(pkgPath, "utf-8");
3490
+ const content = fs11.readFileSync(pkgPath, "utf-8");
3573
3491
  return JSON.parse(content);
3574
3492
  } catch {
3575
3493
  throw new Error("Failed to parse package.json");
@@ -3577,7 +3495,7 @@ function readPackageJson2() {
3577
3495
  }
3578
3496
  function writePackageJson2(pkg2) {
3579
3497
  const pkgPath = getPackageJsonPath();
3580
- fs12.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3498
+ fs11.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
3581
3499
  }
3582
3500
  function readActionPlugins() {
3583
3501
  const pkg2 = readPackageJson2();
@@ -3610,12 +3528,12 @@ function npmInstall(tgzPath) {
3610
3528
  }
3611
3529
  }
3612
3530
  function getPackageVersion(pluginName) {
3613
- const pkgJsonPath = path10.join(getPluginPath(pluginName), "package.json");
3614
- if (!fs12.existsSync(pkgJsonPath)) {
3531
+ const pkgJsonPath = path9.join(getPluginPath(pluginName), "package.json");
3532
+ if (!fs11.existsSync(pkgJsonPath)) {
3615
3533
  return null;
3616
3534
  }
3617
3535
  try {
3618
- const content = fs12.readFileSync(pkgJsonPath, "utf-8");
3536
+ const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3619
3537
  const pkg2 = JSON.parse(content);
3620
3538
  return pkg2.version || null;
3621
3539
  } catch {
@@ -3623,49 +3541,49 @@ function getPackageVersion(pluginName) {
3623
3541
  }
3624
3542
  }
3625
3543
  function readPluginPackageJson(pluginPath) {
3626
- const pkgJsonPath = path10.join(pluginPath, "package.json");
3627
- if (!fs12.existsSync(pkgJsonPath)) {
3544
+ const pkgJsonPath = path9.join(pluginPath, "package.json");
3545
+ if (!fs11.existsSync(pkgJsonPath)) {
3628
3546
  return null;
3629
3547
  }
3630
3548
  try {
3631
- const content = fs12.readFileSync(pkgJsonPath, "utf-8");
3549
+ const content = fs11.readFileSync(pkgJsonPath, "utf-8");
3632
3550
  return JSON.parse(content);
3633
3551
  } catch {
3634
3552
  return null;
3635
3553
  }
3636
3554
  }
3637
3555
  function extractTgzToNodeModules(tgzPath, pluginName) {
3638
- const nodeModulesPath = path10.join(getProjectRoot(), "node_modules");
3639
- const targetDir = path10.join(nodeModulesPath, pluginName);
3640
- const scopeDir = path10.dirname(targetDir);
3641
- if (!fs12.existsSync(scopeDir)) {
3642
- fs12.mkdirSync(scopeDir, { recursive: true });
3556
+ const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
3557
+ const targetDir = path9.join(nodeModulesPath, pluginName);
3558
+ const scopeDir = path9.dirname(targetDir);
3559
+ if (!fs11.existsSync(scopeDir)) {
3560
+ fs11.mkdirSync(scopeDir, { recursive: true });
3643
3561
  }
3644
- if (fs12.existsSync(targetDir)) {
3645
- fs12.rmSync(targetDir, { recursive: true });
3562
+ if (fs11.existsSync(targetDir)) {
3563
+ fs11.rmSync(targetDir, { recursive: true });
3646
3564
  }
3647
- const tempDir = path10.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3648
- if (fs12.existsSync(tempDir)) {
3649
- fs12.rmSync(tempDir, { recursive: true });
3565
+ const tempDir = path9.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
3566
+ if (fs11.existsSync(tempDir)) {
3567
+ fs11.rmSync(tempDir, { recursive: true });
3650
3568
  }
3651
- fs12.mkdirSync(tempDir, { recursive: true });
3569
+ fs11.mkdirSync(tempDir, { recursive: true });
3652
3570
  try {
3653
3571
  execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
3654
- const extractedDir = path10.join(tempDir, "package");
3655
- if (fs12.existsSync(extractedDir)) {
3656
- fs12.renameSync(extractedDir, targetDir);
3572
+ const extractedDir = path9.join(tempDir, "package");
3573
+ if (fs11.existsSync(extractedDir)) {
3574
+ fs11.renameSync(extractedDir, targetDir);
3657
3575
  } else {
3658
- const files = fs12.readdirSync(tempDir);
3576
+ const files = fs11.readdirSync(tempDir);
3659
3577
  if (files.length === 1) {
3660
- fs12.renameSync(path10.join(tempDir, files[0]), targetDir);
3578
+ fs11.renameSync(path9.join(tempDir, files[0]), targetDir);
3661
3579
  } else {
3662
3580
  throw new Error("Unexpected tgz structure");
3663
3581
  }
3664
3582
  }
3665
3583
  return targetDir;
3666
3584
  } finally {
3667
- if (fs12.existsSync(tempDir)) {
3668
- fs12.rmSync(tempDir, { recursive: true });
3585
+ if (fs11.existsSync(tempDir)) {
3586
+ fs11.rmSync(tempDir, { recursive: true });
3669
3587
  }
3670
3588
  }
3671
3589
  }
@@ -3674,10 +3592,10 @@ function checkMissingPeerDeps(peerDeps) {
3674
3592
  return [];
3675
3593
  }
3676
3594
  const missing = [];
3677
- const nodeModulesPath = path10.join(getProjectRoot(), "node_modules");
3595
+ const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
3678
3596
  for (const [depName, _version] of Object.entries(peerDeps)) {
3679
- const depPath = path10.join(nodeModulesPath, depName);
3680
- if (!fs12.existsSync(depPath)) {
3597
+ const depPath = path9.join(nodeModulesPath, depName);
3598
+ if (!fs11.existsSync(depPath)) {
3681
3599
  missing.push(depName);
3682
3600
  }
3683
3601
  }
@@ -3701,16 +3619,16 @@ function installMissingDeps(deps) {
3701
3619
  }
3702
3620
  function removePluginDirectory(pluginName) {
3703
3621
  const pluginPath = getPluginPath(pluginName);
3704
- if (fs12.existsSync(pluginPath)) {
3705
- fs12.rmSync(pluginPath, { recursive: true });
3622
+ if (fs11.existsSync(pluginPath)) {
3623
+ fs11.rmSync(pluginPath, { recursive: true });
3706
3624
  console.log(`[action-plugin] Removed ${pluginName}`);
3707
3625
  }
3708
3626
  }
3709
3627
 
3710
3628
  // src/commands/action-plugin/api-client.ts
3711
3629
  import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
3712
- import fs13 from "fs";
3713
- import path11 from "path";
3630
+ import fs12 from "fs";
3631
+ import path10 from "path";
3714
3632
  var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
3715
3633
  async function getPluginVersions(keys, latestOnly = true) {
3716
3634
  const client = getHttpClient();
@@ -3774,19 +3692,19 @@ async function downloadFromPublic(downloadURL) {
3774
3692
  return Buffer.from(arrayBuffer);
3775
3693
  }
3776
3694
  function getPluginCacheDir() {
3777
- return path11.join(process.cwd(), PLUGIN_CACHE_DIR);
3695
+ return path10.join(process.cwd(), PLUGIN_CACHE_DIR);
3778
3696
  }
3779
3697
  function ensureCacheDir() {
3780
3698
  const cacheDir = getPluginCacheDir();
3781
- if (!fs13.existsSync(cacheDir)) {
3782
- fs13.mkdirSync(cacheDir, { recursive: true });
3699
+ if (!fs12.existsSync(cacheDir)) {
3700
+ fs12.mkdirSync(cacheDir, { recursive: true });
3783
3701
  }
3784
3702
  }
3785
3703
  function getTempFilePath(pluginKey, version) {
3786
3704
  ensureCacheDir();
3787
3705
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3788
3706
  const filename = `${safeKey}@${version}.tgz`;
3789
- return path11.join(getPluginCacheDir(), filename);
3707
+ return path10.join(getPluginCacheDir(), filename);
3790
3708
  }
3791
3709
  var MAX_RETRIES = 2;
3792
3710
  async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
@@ -3823,7 +3741,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
3823
3741
  );
3824
3742
  }
3825
3743
  const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
3826
- fs13.writeFileSync(tgzPath, tgzBuffer);
3744
+ fs12.writeFileSync(tgzPath, tgzBuffer);
3827
3745
  console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
3828
3746
  return {
3829
3747
  tgzPath,
@@ -3837,18 +3755,18 @@ function getCachePath(pluginKey, version) {
3837
3755
  ensureCacheDir();
3838
3756
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3839
3757
  const filename = `${safeKey}@${version}.tgz`;
3840
- return path11.join(getPluginCacheDir(), filename);
3758
+ return path10.join(getPluginCacheDir(), filename);
3841
3759
  }
3842
3760
  function hasCachedPlugin(pluginKey, version) {
3843
3761
  const cachePath = getCachePath(pluginKey, version);
3844
- return fs13.existsSync(cachePath);
3762
+ return fs12.existsSync(cachePath);
3845
3763
  }
3846
3764
  function listCachedPlugins() {
3847
3765
  const cacheDir = getPluginCacheDir();
3848
- if (!fs13.existsSync(cacheDir)) {
3766
+ if (!fs12.existsSync(cacheDir)) {
3849
3767
  return [];
3850
3768
  }
3851
- const files = fs13.readdirSync(cacheDir);
3769
+ const files = fs12.readdirSync(cacheDir);
3852
3770
  const result = [];
3853
3771
  for (const file of files) {
3854
3772
  if (!file.endsWith(".tgz")) continue;
@@ -3856,8 +3774,8 @@ function listCachedPlugins() {
3856
3774
  if (!match) continue;
3857
3775
  const [, rawName, version] = match;
3858
3776
  const name = rawName.replace(/^_/, "@").replace(/_/, "/");
3859
- const filePath = path11.join(cacheDir, file);
3860
- const stat = fs13.statSync(filePath);
3777
+ const filePath = path10.join(cacheDir, file);
3778
+ const stat = fs12.statSync(filePath);
3861
3779
  result.push({
3862
3780
  name,
3863
3781
  version,
@@ -3870,14 +3788,14 @@ function listCachedPlugins() {
3870
3788
  }
3871
3789
  function cleanAllCache() {
3872
3790
  const cacheDir = getPluginCacheDir();
3873
- if (!fs13.existsSync(cacheDir)) {
3791
+ if (!fs12.existsSync(cacheDir)) {
3874
3792
  return 0;
3875
3793
  }
3876
- const files = fs13.readdirSync(cacheDir);
3794
+ const files = fs12.readdirSync(cacheDir);
3877
3795
  let count = 0;
3878
3796
  for (const file of files) {
3879
3797
  if (file.endsWith(".tgz")) {
3880
- fs13.unlinkSync(path11.join(cacheDir, file));
3798
+ fs12.unlinkSync(path10.join(cacheDir, file));
3881
3799
  count++;
3882
3800
  }
3883
3801
  }
@@ -3885,21 +3803,21 @@ function cleanAllCache() {
3885
3803
  }
3886
3804
  function cleanPluginCache(pluginKey, version) {
3887
3805
  const cacheDir = getPluginCacheDir();
3888
- if (!fs13.existsSync(cacheDir)) {
3806
+ if (!fs12.existsSync(cacheDir)) {
3889
3807
  return 0;
3890
3808
  }
3891
3809
  const safeKey = pluginKey.replace(/[/@]/g, "_");
3892
- const files = fs13.readdirSync(cacheDir);
3810
+ const files = fs12.readdirSync(cacheDir);
3893
3811
  let count = 0;
3894
3812
  for (const file of files) {
3895
3813
  if (version) {
3896
3814
  if (file === `${safeKey}@${version}.tgz`) {
3897
- fs13.unlinkSync(path11.join(cacheDir, file));
3815
+ fs12.unlinkSync(path10.join(cacheDir, file));
3898
3816
  count++;
3899
3817
  }
3900
3818
  } else {
3901
3819
  if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
3902
- fs13.unlinkSync(path11.join(cacheDir, file));
3820
+ fs12.unlinkSync(path10.join(cacheDir, file));
3903
3821
  count++;
3904
3822
  }
3905
3823
  }
@@ -4326,40 +4244,40 @@ var actionPluginCommandGroup = {
4326
4244
  };
4327
4245
 
4328
4246
  // src/commands/capability/utils.ts
4329
- import fs14 from "fs";
4247
+ import fs13 from "fs";
4330
4248
  import { createRequire as createRequire2 } from "module";
4331
- import path12 from "path";
4249
+ import path11 from "path";
4332
4250
  var CAPABILITIES_DIR = "server/capabilities";
4333
4251
  function getProjectRoot2() {
4334
4252
  return process.cwd();
4335
4253
  }
4336
4254
  function getCapabilitiesDir() {
4337
- return path12.join(getProjectRoot2(), CAPABILITIES_DIR);
4255
+ return path11.join(getProjectRoot2(), CAPABILITIES_DIR);
4338
4256
  }
4339
4257
  function getCapabilityPath(id) {
4340
- return path12.join(getCapabilitiesDir(), `${id}.json`);
4258
+ return path11.join(getCapabilitiesDir(), `${id}.json`);
4341
4259
  }
4342
4260
  function getPluginManifestPath(pluginKey) {
4343
- return path12.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4261
+ return path11.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
4344
4262
  }
4345
4263
  function capabilitiesDirExists() {
4346
- return fs14.existsSync(getCapabilitiesDir());
4264
+ return fs13.existsSync(getCapabilitiesDir());
4347
4265
  }
4348
4266
  function listCapabilityIds() {
4349
4267
  const dir = getCapabilitiesDir();
4350
- if (!fs14.existsSync(dir)) {
4268
+ if (!fs13.existsSync(dir)) {
4351
4269
  return [];
4352
4270
  }
4353
- const files = fs14.readdirSync(dir);
4271
+ const files = fs13.readdirSync(dir);
4354
4272
  return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
4355
4273
  }
4356
4274
  function readCapability(id) {
4357
4275
  const filePath = getCapabilityPath(id);
4358
- if (!fs14.existsSync(filePath)) {
4276
+ if (!fs13.existsSync(filePath)) {
4359
4277
  throw new Error(`Capability not found: ${id}`);
4360
4278
  }
4361
4279
  try {
4362
- const content = fs14.readFileSync(filePath, "utf-8");
4280
+ const content = fs13.readFileSync(filePath, "utf-8");
4363
4281
  return JSON.parse(content);
4364
4282
  } catch (error) {
4365
4283
  if (error instanceof SyntaxError) {
@@ -4386,11 +4304,11 @@ function readAllCapabilities() {
4386
4304
  }
4387
4305
  function readPluginManifest(pluginKey) {
4388
4306
  const manifestPath = getPluginManifestPath(pluginKey);
4389
- if (!fs14.existsSync(manifestPath)) {
4307
+ if (!fs13.existsSync(manifestPath)) {
4390
4308
  throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
4391
4309
  }
4392
4310
  try {
4393
- const content = fs14.readFileSync(manifestPath, "utf-8");
4311
+ const content = fs13.readFileSync(manifestPath, "utf-8");
4394
4312
  return JSON.parse(content);
4395
4313
  } catch (error) {
4396
4314
  if (error instanceof SyntaxError) {
@@ -4407,7 +4325,7 @@ function hasValidParamsSchema(paramsSchema) {
4407
4325
  }
4408
4326
  async function loadPlugin(pluginKey) {
4409
4327
  try {
4410
- const userRequire = createRequire2(path12.join(getProjectRoot2(), "package.json"));
4328
+ const userRequire = createRequire2(path11.join(getProjectRoot2(), "package.json"));
4411
4329
  const resolvedPath = userRequire.resolve(pluginKey);
4412
4330
  const pluginModule = await import(resolvedPath);
4413
4331
  const pluginPackage = pluginModule.default ?? pluginModule;
@@ -4570,8 +4488,8 @@ var capabilityCommandGroup = {
4570
4488
  import { execFile } from "child_process";
4571
4489
 
4572
4490
  // src/commands/component/registry-preparer.ts
4573
- import fs15 from "fs";
4574
- import path13 from "path";
4491
+ import fs14 from "fs";
4492
+ import path12 from "path";
4575
4493
  import os from "os";
4576
4494
 
4577
4495
  // src/commands/component/service.ts
@@ -4627,7 +4545,7 @@ async function sendInstallEvent(key) {
4627
4545
  }
4628
4546
 
4629
4547
  // src/commands/component/registry-preparer.ts
4630
- var REGISTRY_TEMP_DIR = path13.join(os.tmpdir(), "miaoda-registry");
4548
+ var REGISTRY_TEMP_DIR = path12.join(os.tmpdir(), "miaoda-registry");
4631
4549
  function parseComponentKey(key) {
4632
4550
  const match = key.match(/^@([^/]+)\/(.+)$/);
4633
4551
  if (!match) {
@@ -4639,11 +4557,11 @@ function parseComponentKey(key) {
4639
4557
  }
4640
4558
  function getLocalRegistryPath(key) {
4641
4559
  const { scope, name } = parseComponentKey(key);
4642
- return path13.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4560
+ return path12.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
4643
4561
  }
4644
4562
  function ensureDir(dirPath) {
4645
- if (!fs15.existsSync(dirPath)) {
4646
- fs15.mkdirSync(dirPath, { recursive: true });
4563
+ if (!fs14.existsSync(dirPath)) {
4564
+ fs14.mkdirSync(dirPath, { recursive: true });
4647
4565
  }
4648
4566
  }
4649
4567
  async function prepareRecursive(key, visited) {
@@ -4676,8 +4594,8 @@ async function prepareRecursive(key, visited) {
4676
4594
  registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
4677
4595
  };
4678
4596
  const localPath = getLocalRegistryPath(key);
4679
- ensureDir(path13.dirname(localPath));
4680
- fs15.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4597
+ ensureDir(path12.dirname(localPath));
4598
+ fs14.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
4681
4599
  debug("\u4FDD\u5B58\u5230: %s", localPath);
4682
4600
  }
4683
4601
  async function prepareComponentRegistryItems(id) {
@@ -4687,18 +4605,18 @@ async function prepareComponentRegistryItems(id) {
4687
4605
  }
4688
4606
  function cleanupTempDir() {
4689
4607
  try {
4690
- if (fs15.existsSync(REGISTRY_TEMP_DIR)) {
4691
- fs15.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4608
+ if (fs14.existsSync(REGISTRY_TEMP_DIR)) {
4609
+ fs14.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
4692
4610
  }
4693
4611
  } catch {
4694
4612
  }
4695
4613
  }
4696
4614
  function getDownloadedRegistryItem(itemId) {
4697
4615
  const localPath = getLocalRegistryPath(itemId);
4698
- if (!fs15.existsSync(localPath)) {
4616
+ if (!fs14.existsSync(localPath)) {
4699
4617
  return null;
4700
4618
  }
4701
- const content = fs15.readFileSync(localPath, "utf-8");
4619
+ const content = fs14.readFileSync(localPath, "utf-8");
4702
4620
  return JSON.parse(content);
4703
4621
  }
4704
4622
 
@@ -4866,58 +4784,58 @@ var componentCommandGroup = {
4866
4784
  };
4867
4785
 
4868
4786
  // src/commands/migration/version-manager.ts
4869
- import fs16 from "fs";
4870
- import path14 from "path";
4787
+ import fs15 from "fs";
4788
+ import path13 from "path";
4871
4789
  var PACKAGE_JSON = "package.json";
4872
4790
  var VERSION_FIELD = "migrationVersion";
4873
4791
  function getPackageJsonPath2() {
4874
- return path14.join(process.cwd(), PACKAGE_JSON);
4792
+ return path13.join(process.cwd(), PACKAGE_JSON);
4875
4793
  }
4876
4794
  function getCurrentVersion() {
4877
4795
  const pkgPath = getPackageJsonPath2();
4878
- if (!fs16.existsSync(pkgPath)) {
4796
+ if (!fs15.existsSync(pkgPath)) {
4879
4797
  throw new Error("package.json not found");
4880
4798
  }
4881
- const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
4799
+ const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
4882
4800
  return pkg2[VERSION_FIELD] ?? 0;
4883
4801
  }
4884
4802
  function setCurrentVersion(version) {
4885
4803
  const pkgPath = getPackageJsonPath2();
4886
- const pkg2 = JSON.parse(fs16.readFileSync(pkgPath, "utf-8"));
4804
+ const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
4887
4805
  pkg2[VERSION_FIELD] = version;
4888
- fs16.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4806
+ fs15.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
4889
4807
  }
4890
4808
 
4891
4809
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4892
- import fs18 from "fs";
4893
- import path16 from "path";
4894
-
4895
- // src/commands/migration/versions/v001_capability/utils.ts
4896
4810
  import fs17 from "fs";
4897
4811
  import path15 from "path";
4812
+
4813
+ // src/commands/migration/versions/v001_capability/utils.ts
4814
+ import fs16 from "fs";
4815
+ import path14 from "path";
4898
4816
  var CAPABILITIES_DIR2 = "server/capabilities";
4899
4817
  function getProjectRoot3() {
4900
4818
  return process.cwd();
4901
4819
  }
4902
4820
  function getCapabilitiesDir2() {
4903
- return path15.join(getProjectRoot3(), CAPABILITIES_DIR2);
4821
+ return path14.join(getProjectRoot3(), CAPABILITIES_DIR2);
4904
4822
  }
4905
4823
  function getPluginManifestPath2(pluginKey) {
4906
- return path15.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4824
+ return path14.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
4907
4825
  }
4908
4826
 
4909
4827
  // src/commands/migration/versions/v001_capability/json-migrator/detector.ts
4910
4828
  function detectJsonMigration() {
4911
4829
  const capabilitiesDir = getCapabilitiesDir2();
4912
- const oldFilePath = path16.join(capabilitiesDir, "capabilities.json");
4913
- if (!fs18.existsSync(oldFilePath)) {
4830
+ const oldFilePath = path15.join(capabilitiesDir, "capabilities.json");
4831
+ if (!fs17.existsSync(oldFilePath)) {
4914
4832
  return {
4915
4833
  needsMigration: false,
4916
4834
  reason: "capabilities.json not found"
4917
4835
  };
4918
4836
  }
4919
4837
  try {
4920
- const content = fs18.readFileSync(oldFilePath, "utf-8");
4838
+ const content = fs17.readFileSync(oldFilePath, "utf-8");
4921
4839
  const parsed = JSON.parse(content);
4922
4840
  if (!Array.isArray(parsed)) {
4923
4841
  return {
@@ -4968,8 +4886,8 @@ async function check(options) {
4968
4886
  }
4969
4887
 
4970
4888
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
4971
- import fs19 from "fs";
4972
- import path17 from "path";
4889
+ import fs18 from "fs";
4890
+ import path16 from "path";
4973
4891
 
4974
4892
  // src/commands/migration/versions/v001_capability/mapping.ts
4975
4893
  var DEFAULT_PLUGIN_VERSION = "1.0.0";
@@ -5199,18 +5117,18 @@ function transformCapabilities(oldCapabilities) {
5199
5117
  // src/commands/migration/versions/v001_capability/json-migrator/index.ts
5200
5118
  function loadExistingCapabilities() {
5201
5119
  const capabilitiesDir = getCapabilitiesDir2();
5202
- if (!fs19.existsSync(capabilitiesDir)) {
5120
+ if (!fs18.existsSync(capabilitiesDir)) {
5203
5121
  return [];
5204
5122
  }
5205
- const files = fs19.readdirSync(capabilitiesDir);
5123
+ const files = fs18.readdirSync(capabilitiesDir);
5206
5124
  const capabilities = [];
5207
5125
  for (const file of files) {
5208
5126
  if (file === "capabilities.json" || !file.endsWith(".json")) {
5209
5127
  continue;
5210
5128
  }
5211
5129
  try {
5212
- const filePath = path17.join(capabilitiesDir, file);
5213
- const content = fs19.readFileSync(filePath, "utf-8");
5130
+ const filePath = path16.join(capabilitiesDir, file);
5131
+ const content = fs18.readFileSync(filePath, "utf-8");
5214
5132
  const capability = JSON.parse(content);
5215
5133
  if (capability.id && capability.pluginKey) {
5216
5134
  capabilities.push(capability);
@@ -5268,9 +5186,9 @@ async function migrateJsonFiles(options) {
5268
5186
  }
5269
5187
  const capabilitiesDir = getCapabilitiesDir2();
5270
5188
  for (const cap of newCapabilities) {
5271
- const filePath = path17.join(capabilitiesDir, `${cap.id}.json`);
5189
+ const filePath = path16.join(capabilitiesDir, `${cap.id}.json`);
5272
5190
  const content = JSON.stringify(cap, null, 2);
5273
- fs19.writeFileSync(filePath, content, "utf-8");
5191
+ fs18.writeFileSync(filePath, content, "utf-8");
5274
5192
  console.log(` \u2713 Created: ${cap.id}.json`);
5275
5193
  }
5276
5194
  return {
@@ -5282,11 +5200,11 @@ async function migrateJsonFiles(options) {
5282
5200
  }
5283
5201
 
5284
5202
  // src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
5285
- import fs20 from "fs";
5203
+ import fs19 from "fs";
5286
5204
  function isPluginInstalled2(pluginKey) {
5287
5205
  const actionPlugins = readActionPlugins();
5288
5206
  const manifestPath = getPluginManifestPath2(pluginKey);
5289
- return fs20.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5207
+ return fs19.existsSync(manifestPath) && !!actionPlugins[pluginKey];
5290
5208
  }
5291
5209
  function detectPluginsToInstall(capabilities) {
5292
5210
  const pluginKeys = /* @__PURE__ */ new Set();
@@ -5362,12 +5280,12 @@ async function installPlugins(capabilities, options) {
5362
5280
  }
5363
5281
 
5364
5282
  // src/commands/migration/versions/v001_capability/code-migrator/index.ts
5365
- import path19 from "path";
5283
+ import path18 from "path";
5366
5284
  import { Project as Project3 } from "ts-morph";
5367
5285
 
5368
5286
  // src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
5369
- import fs21 from "fs";
5370
- import path18 from "path";
5287
+ import fs20 from "fs";
5288
+ import path17 from "path";
5371
5289
  var EXCLUDED_DIRS = [
5372
5290
  "node_modules",
5373
5291
  "dist",
@@ -5382,9 +5300,9 @@ var EXCLUDED_PATTERNS = [
5382
5300
  /\.d\.ts$/
5383
5301
  ];
5384
5302
  function scanDirectory(dir, files = []) {
5385
- const entries = fs21.readdirSync(dir, { withFileTypes: true });
5303
+ const entries = fs20.readdirSync(dir, { withFileTypes: true });
5386
5304
  for (const entry of entries) {
5387
- const fullPath = path18.join(dir, entry.name);
5305
+ const fullPath = path17.join(dir, entry.name);
5388
5306
  if (entry.isDirectory()) {
5389
5307
  if (EXCLUDED_DIRS.includes(entry.name)) {
5390
5308
  continue;
@@ -5400,14 +5318,14 @@ function scanDirectory(dir, files = []) {
5400
5318
  return files;
5401
5319
  }
5402
5320
  function scanServerFiles() {
5403
- const serverDir = path18.join(getProjectRoot3(), "server");
5404
- if (!fs21.existsSync(serverDir)) {
5321
+ const serverDir = path17.join(getProjectRoot3(), "server");
5322
+ if (!fs20.existsSync(serverDir)) {
5405
5323
  return [];
5406
5324
  }
5407
5325
  return scanDirectory(serverDir);
5408
5326
  }
5409
5327
  function hasCapabilityImport(filePath) {
5410
- const content = fs21.readFileSync(filePath, "utf-8");
5328
+ const content = fs20.readFileSync(filePath, "utf-8");
5411
5329
  return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
5412
5330
  }
5413
5331
  function scanFilesToMigrate() {
@@ -5784,7 +5702,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5784
5702
  const callSites = analyzeCallSites(sourceFile, imports);
5785
5703
  const classInfo = analyzeClass(sourceFile);
5786
5704
  const { canMigrate, reason } = canAutoMigrate(classInfo);
5787
- const relativePath = path19.relative(getProjectRoot3(), filePath);
5705
+ const relativePath = path18.relative(getProjectRoot3(), filePath);
5788
5706
  return {
5789
5707
  filePath: relativePath,
5790
5708
  imports,
@@ -5795,7 +5713,7 @@ function analyzeFile(project, filePath, actionNameMap) {
5795
5713
  };
5796
5714
  }
5797
5715
  function migrateFile(project, analysis, dryRun) {
5798
- const absolutePath = path19.join(getProjectRoot3(), analysis.filePath);
5716
+ const absolutePath = path18.join(getProjectRoot3(), analysis.filePath);
5799
5717
  if (!analysis.canAutoMigrate) {
5800
5718
  return {
5801
5719
  filePath: analysis.filePath,
@@ -5898,17 +5816,17 @@ function getSuggestion(analysis) {
5898
5816
  }
5899
5817
 
5900
5818
  // src/commands/migration/versions/v001_capability/cleanup.ts
5901
- import fs22 from "fs";
5902
- import path20 from "path";
5819
+ import fs21 from "fs";
5820
+ import path19 from "path";
5903
5821
  function cleanupOldFiles(capabilities, dryRun) {
5904
5822
  const deletedFiles = [];
5905
5823
  const errors = [];
5906
5824
  const capabilitiesDir = getCapabilitiesDir2();
5907
- const oldJsonPath = path20.join(capabilitiesDir, "capabilities.json");
5908
- if (fs22.existsSync(oldJsonPath)) {
5825
+ const oldJsonPath = path19.join(capabilitiesDir, "capabilities.json");
5826
+ if (fs21.existsSync(oldJsonPath)) {
5909
5827
  try {
5910
5828
  if (!dryRun) {
5911
- fs22.unlinkSync(oldJsonPath);
5829
+ fs21.unlinkSync(oldJsonPath);
5912
5830
  }
5913
5831
  deletedFiles.push("capabilities.json");
5914
5832
  } catch (error) {
@@ -5916,11 +5834,11 @@ function cleanupOldFiles(capabilities, dryRun) {
5916
5834
  }
5917
5835
  }
5918
5836
  for (const cap of capabilities) {
5919
- const tsFilePath = path20.join(capabilitiesDir, `${cap.id}.ts`);
5920
- if (fs22.existsSync(tsFilePath)) {
5837
+ const tsFilePath = path19.join(capabilitiesDir, `${cap.id}.ts`);
5838
+ if (fs21.existsSync(tsFilePath)) {
5921
5839
  try {
5922
5840
  if (!dryRun) {
5923
- fs22.unlinkSync(tsFilePath);
5841
+ fs21.unlinkSync(tsFilePath);
5924
5842
  }
5925
5843
  deletedFiles.push(`${cap.id}.ts`);
5926
5844
  } catch (error) {
@@ -5936,8 +5854,8 @@ function cleanupOldFiles(capabilities, dryRun) {
5936
5854
  }
5937
5855
 
5938
5856
  // src/commands/migration/versions/v001_capability/report-generator.ts
5939
- import fs23 from "fs";
5940
- import path21 from "path";
5857
+ import fs22 from "fs";
5858
+ import path20 from "path";
5941
5859
  var REPORT_FILE = "capability-migration-report.md";
5942
5860
  function printSummary(result) {
5943
5861
  const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
@@ -6100,15 +6018,15 @@ async function generateReport(result) {
6100
6018
  }
6101
6019
  lines.push("");
6102
6020
  const logDir = process.env.LOG_DIR || "logs";
6103
- if (!fs23.existsSync(logDir)) {
6021
+ if (!fs22.existsSync(logDir)) {
6104
6022
  return;
6105
6023
  }
6106
- const reportDir = path21.join(logDir, "migration");
6107
- if (!fs23.existsSync(reportDir)) {
6108
- fs23.mkdirSync(reportDir, { recursive: true });
6024
+ const reportDir = path20.join(logDir, "migration");
6025
+ if (!fs22.existsSync(reportDir)) {
6026
+ fs22.mkdirSync(reportDir, { recursive: true });
6109
6027
  }
6110
- const reportPath = path21.join(reportDir, REPORT_FILE);
6111
- fs23.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6028
+ const reportPath = path20.join(reportDir, REPORT_FILE);
6029
+ fs22.writeFileSync(reportPath, lines.join("\n"), "utf-8");
6112
6030
  console.log(`\u{1F4C4} Report generated: ${reportPath}`);
6113
6031
  }
6114
6032
 
@@ -6640,10 +6558,10 @@ var migrationCommand = {
6640
6558
  };
6641
6559
 
6642
6560
  // src/commands/read-logs/index.ts
6643
- import path22 from "path";
6561
+ import path21 from "path";
6644
6562
 
6645
6563
  // src/commands/read-logs/std-utils.ts
6646
- import fs24 from "fs";
6564
+ import fs23 from "fs";
6647
6565
  function formatStdPrefixTime(localTime) {
6648
6566
  const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
6649
6567
  if (!match) return localTime;
@@ -6673,11 +6591,11 @@ function stripPrefixFromStdLine(line) {
6673
6591
  return `[${time}] ${content}`;
6674
6592
  }
6675
6593
  function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
6676
- const stat = fs24.statSync(filePath);
6594
+ const stat = fs23.statSync(filePath);
6677
6595
  if (stat.size === 0) {
6678
6596
  return { lines: [], markerFound: false, totalLinesCount: 0 };
6679
6597
  }
6680
- const fd = fs24.openSync(filePath, "r");
6598
+ const fd = fs23.openSync(filePath, "r");
6681
6599
  const chunkSize = 64 * 1024;
6682
6600
  let position = stat.size;
6683
6601
  let remainder = "";
@@ -6691,7 +6609,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6691
6609
  const length = Math.min(chunkSize, position);
6692
6610
  position -= length;
6693
6611
  const buffer = Buffer.alloc(length);
6694
- fs24.readSync(fd, buffer, 0, length, position);
6612
+ fs23.readSync(fd, buffer, 0, length, position);
6695
6613
  let chunk = buffer.toString("utf8");
6696
6614
  if (remainder) {
6697
6615
  chunk += remainder;
@@ -6733,7 +6651,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
6733
6651
  }
6734
6652
  }
6735
6653
  } finally {
6736
- fs24.closeSync(fd);
6654
+ fs23.closeSync(fd);
6737
6655
  }
6738
6656
  return { lines: collected.reverse(), markerFound, totalLinesCount };
6739
6657
  }
@@ -6754,21 +6672,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
6754
6672
  }
6755
6673
 
6756
6674
  // src/commands/read-logs/tail.ts
6757
- import fs25 from "fs";
6675
+ import fs24 from "fs";
6758
6676
  function fileExists(filePath) {
6759
6677
  try {
6760
- fs25.accessSync(filePath, fs25.constants.F_OK | fs25.constants.R_OK);
6678
+ fs24.accessSync(filePath, fs24.constants.F_OK | fs24.constants.R_OK);
6761
6679
  return true;
6762
6680
  } catch {
6763
6681
  return false;
6764
6682
  }
6765
6683
  }
6766
6684
  function readFileTailLines(filePath, maxLines) {
6767
- const stat = fs25.statSync(filePath);
6685
+ const stat = fs24.statSync(filePath);
6768
6686
  if (stat.size === 0) {
6769
6687
  return [];
6770
6688
  }
6771
- const fd = fs25.openSync(filePath, "r");
6689
+ const fd = fs24.openSync(filePath, "r");
6772
6690
  const chunkSize = 64 * 1024;
6773
6691
  const chunks = [];
6774
6692
  let position = stat.size;
@@ -6778,13 +6696,13 @@ function readFileTailLines(filePath, maxLines) {
6778
6696
  const length = Math.min(chunkSize, position);
6779
6697
  position -= length;
6780
6698
  const buffer = Buffer.alloc(length);
6781
- fs25.readSync(fd, buffer, 0, length, position);
6699
+ fs24.readSync(fd, buffer, 0, length, position);
6782
6700
  chunks.unshift(buffer.toString("utf8"));
6783
6701
  const chunkLines = buffer.toString("utf8").split("\n").length - 1;
6784
6702
  collectedLines += chunkLines;
6785
6703
  }
6786
6704
  } finally {
6787
- fs25.closeSync(fd);
6705
+ fs24.closeSync(fd);
6788
6706
  }
6789
6707
  const content = chunks.join("");
6790
6708
  const allLines = content.split("\n");
@@ -6800,11 +6718,11 @@ function readFileTailLines(filePath, maxLines) {
6800
6718
  return allLines.slice(allLines.length - maxLines);
6801
6719
  }
6802
6720
  function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6803
- const stat = fs25.statSync(filePath);
6721
+ const stat = fs24.statSync(filePath);
6804
6722
  if (stat.size === 0) {
6805
6723
  return { lines: [], totalLinesCount: 0 };
6806
6724
  }
6807
- const fd = fs25.openSync(filePath, "r");
6725
+ const fd = fs24.openSync(filePath, "r");
6808
6726
  const chunkSize = 64 * 1024;
6809
6727
  let position = stat.size;
6810
6728
  let remainder = "";
@@ -6816,7 +6734,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6816
6734
  const length = Math.min(chunkSize, position);
6817
6735
  position -= length;
6818
6736
  const buffer = Buffer.alloc(length);
6819
- fs25.readSync(fd, buffer, 0, length, position);
6737
+ fs24.readSync(fd, buffer, 0, length, position);
6820
6738
  let chunk = buffer.toString("utf8");
6821
6739
  if (remainder) {
6822
6740
  chunk += remainder;
@@ -6847,7 +6765,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
6847
6765
  }
6848
6766
  }
6849
6767
  } finally {
6850
- fs25.closeSync(fd);
6768
+ fs24.closeSync(fd);
6851
6769
  }
6852
6770
  return { lines: collected.reverse(), totalLinesCount };
6853
6771
  }
@@ -6989,7 +6907,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
6989
6907
  }
6990
6908
 
6991
6909
  // src/commands/read-logs/json-lines.ts
6992
- import fs26 from "fs";
6910
+ import fs25 from "fs";
6993
6911
  function normalizePid(value) {
6994
6912
  if (typeof value === "number") {
6995
6913
  return String(value);
@@ -7040,11 +6958,11 @@ function buildWantedLevelSet(levels) {
7040
6958
  return set.size > 0 ? set : null;
7041
6959
  }
7042
6960
  function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7043
- const stat = fs26.statSync(filePath);
6961
+ const stat = fs25.statSync(filePath);
7044
6962
  if (stat.size === 0) {
7045
6963
  return { lines: [], totalLinesCount: 0 };
7046
6964
  }
7047
- const fd = fs26.openSync(filePath, "r");
6965
+ const fd = fs25.openSync(filePath, "r");
7048
6966
  const chunkSize = 64 * 1024;
7049
6967
  let position = stat.size;
7050
6968
  let remainder = "";
@@ -7059,7 +6977,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7059
6977
  const length = Math.min(chunkSize, position);
7060
6978
  position -= length;
7061
6979
  const buffer = Buffer.alloc(length);
7062
- fs26.readSync(fd, buffer, 0, length, position);
6980
+ fs25.readSync(fd, buffer, 0, length, position);
7063
6981
  let chunk = buffer.toString("utf8");
7064
6982
  if (remainder) {
7065
6983
  chunk += remainder;
@@ -7121,7 +7039,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
7121
7039
  }
7122
7040
  }
7123
7041
  } finally {
7124
- fs26.closeSync(fd);
7042
+ fs25.closeSync(fd);
7125
7043
  }
7126
7044
  return { lines: collected.reverse(), totalLinesCount };
7127
7045
  }
@@ -7164,11 +7082,11 @@ function extractTraceId(obj) {
7164
7082
  function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7165
7083
  const wanted = traceId.trim();
7166
7084
  if (!wanted) return { lines: [], totalLinesCount: 0 };
7167
- const stat = fs26.statSync(filePath);
7085
+ const stat = fs25.statSync(filePath);
7168
7086
  if (stat.size === 0) {
7169
7087
  return { lines: [], totalLinesCount: 0 };
7170
7088
  }
7171
- const fd = fs26.openSync(filePath, "r");
7089
+ const fd = fs25.openSync(filePath, "r");
7172
7090
  const chunkSize = 64 * 1024;
7173
7091
  let position = stat.size;
7174
7092
  let remainder = "";
@@ -7181,7 +7099,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7181
7099
  const length = Math.min(chunkSize, position);
7182
7100
  position -= length;
7183
7101
  const buffer = Buffer.alloc(length);
7184
- fs26.readSync(fd, buffer, 0, length, position);
7102
+ fs25.readSync(fd, buffer, 0, length, position);
7185
7103
  let chunk = buffer.toString("utf8");
7186
7104
  if (remainder) {
7187
7105
  chunk += remainder;
@@ -7234,7 +7152,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
7234
7152
  }
7235
7153
  }
7236
7154
  } finally {
7237
- fs26.closeSync(fd);
7155
+ fs25.closeSync(fd);
7238
7156
  }
7239
7157
  return { lines: collected.reverse(), totalLinesCount };
7240
7158
  }
@@ -7243,11 +7161,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7243
7161
  if (!wantedLevelSet) {
7244
7162
  return { lines: [], totalLinesCount: 0 };
7245
7163
  }
7246
- const stat = fs26.statSync(filePath);
7164
+ const stat = fs25.statSync(filePath);
7247
7165
  if (stat.size === 0) {
7248
7166
  return { lines: [], totalLinesCount: 0 };
7249
7167
  }
7250
- const fd = fs26.openSync(filePath, "r");
7168
+ const fd = fs25.openSync(filePath, "r");
7251
7169
  const chunkSize = 64 * 1024;
7252
7170
  let position = stat.size;
7253
7171
  let remainder = "";
@@ -7259,7 +7177,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7259
7177
  const length = Math.min(chunkSize, position);
7260
7178
  position -= length;
7261
7179
  const buffer = Buffer.alloc(length);
7262
- fs26.readSync(fd, buffer, 0, length, position);
7180
+ fs25.readSync(fd, buffer, 0, length, position);
7263
7181
  let chunk = buffer.toString("utf8");
7264
7182
  if (remainder) {
7265
7183
  chunk += remainder;
@@ -7306,7 +7224,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
7306
7224
  }
7307
7225
  }
7308
7226
  } finally {
7309
- fs26.closeSync(fd);
7227
+ fs25.closeSync(fd);
7310
7228
  }
7311
7229
  return { lines: collected.reverse(), totalLinesCount };
7312
7230
  }
@@ -7540,30 +7458,30 @@ async function readLogsJsonResult(options) {
7540
7458
  };
7541
7459
  }
7542
7460
  function resolveLogFilePath(logDir, type) {
7543
- const base = path22.isAbsolute(logDir) ? logDir : path22.join(process.cwd(), logDir);
7461
+ const base = path21.isAbsolute(logDir) ? logDir : path21.join(process.cwd(), logDir);
7544
7462
  if (type === "server") {
7545
- return path22.join(base, "server.log");
7463
+ return path21.join(base, "server.log");
7546
7464
  }
7547
7465
  if (type === "trace") {
7548
- return path22.join(base, "trace.log");
7466
+ return path21.join(base, "trace.log");
7549
7467
  }
7550
7468
  if (type === "server-std") {
7551
- return path22.join(base, "server.std.log");
7469
+ return path21.join(base, "server.std.log");
7552
7470
  }
7553
7471
  if (type === "client-std") {
7554
- return path22.join(base, "client.std.log");
7472
+ return path21.join(base, "client.std.log");
7555
7473
  }
7556
7474
  if (type === "dev") {
7557
- return path22.join(base, "dev.log");
7475
+ return path21.join(base, "dev.log");
7558
7476
  }
7559
7477
  if (type === "dev-std") {
7560
- return path22.join(base, "dev.std.log");
7478
+ return path21.join(base, "dev.std.log");
7561
7479
  }
7562
7480
  if (type === "install-dep-std") {
7563
- return path22.join(base, "install-dep.std.log");
7481
+ return path21.join(base, "install-dep.std.log");
7564
7482
  }
7565
7483
  if (type === "browser") {
7566
- return path22.join(base, "browser.log");
7484
+ return path21.join(base, "browser.log");
7567
7485
  }
7568
7486
  throw new Error(`Unsupported log type: ${type}`);
7569
7487
  }
@@ -7740,9 +7658,9 @@ function camelToKebab(str) {
7740
7658
  }
7741
7659
 
7742
7660
  // src/commands/build/upload-static.handler.ts
7743
- import * as fs27 from "fs";
7661
+ import * as fs26 from "fs";
7744
7662
  import * as os2 from "os";
7745
- import * as path23 from "path";
7663
+ import * as path22 from "path";
7746
7664
  import { execFileSync } from "child_process";
7747
7665
  function readCredentialsFromEnv() {
7748
7666
  const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
@@ -7766,8 +7684,8 @@ async function uploadStatic(options) {
7766
7684
  endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
7767
7685
  region = UPLOAD_STATIC_DEFAULTS.region
7768
7686
  } = options;
7769
- const resolvedStaticDir = path23.resolve(staticDir);
7770
- if (!fs27.existsSync(resolvedStaticDir)) {
7687
+ const resolvedStaticDir = path22.resolve(staticDir);
7688
+ if (!fs26.existsSync(resolvedStaticDir)) {
7771
7689
  console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
7772
7690
  return;
7773
7691
  }
@@ -7800,8 +7718,8 @@ async function uploadStatic(options) {
7800
7718
  ({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
7801
7719
  }
7802
7720
  console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
7803
- const confPath = path23.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7804
- fs27.writeFileSync(confPath, "");
7721
+ const confPath = path22.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
7722
+ fs26.writeFileSync(confPath, "");
7805
7723
  try {
7806
7724
  console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
7807
7725
  configureTosutil(resolvedTosutil, confPath, {
@@ -7815,7 +7733,7 @@ async function uploadStatic(options) {
7815
7733
  uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
7816
7734
  } finally {
7817
7735
  try {
7818
- fs27.unlinkSync(confPath);
7736
+ fs26.unlinkSync(confPath);
7819
7737
  } catch {
7820
7738
  }
7821
7739
  }
@@ -7835,8 +7753,8 @@ async function uploadStatic(options) {
7835
7753
  }
7836
7754
  }
7837
7755
  function resolveTosutilPath(tosutilPath) {
7838
- if (path23.isAbsolute(tosutilPath)) {
7839
- return fs27.existsSync(tosutilPath) ? tosutilPath : null;
7756
+ if (path22.isAbsolute(tosutilPath)) {
7757
+ return fs26.existsSync(tosutilPath) ? tosutilPath : null;
7840
7758
  }
7841
7759
  try {
7842
7760
  const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
@@ -7881,7 +7799,7 @@ async function resolveBucketId(appId) {
7881
7799
  return bucketId;
7882
7800
  }
7883
7801
  function isDirEmpty(dirPath) {
7884
- const entries = fs27.readdirSync(dirPath);
7802
+ const entries = fs26.readdirSync(dirPath);
7885
7803
  return entries.length === 0;
7886
7804
  }
7887
7805
 
@@ -7976,12 +7894,12 @@ var commands = [
7976
7894
  ];
7977
7895
 
7978
7896
  // src/index.ts
7979
- var envPath = path24.join(process.cwd(), ".env");
7980
- if (fs28.existsSync(envPath)) {
7897
+ var envPath = path23.join(process.cwd(), ".env");
7898
+ if (fs27.existsSync(envPath)) {
7981
7899
  dotenvConfig({ path: envPath });
7982
7900
  }
7983
- var __dirname = path24.dirname(fileURLToPath5(import.meta.url));
7984
- var pkg = JSON.parse(fs28.readFileSync(path24.join(__dirname, "../package.json"), "utf-8"));
7901
+ var __dirname = path23.dirname(fileURLToPath5(import.meta.url));
7902
+ var pkg = JSON.parse(fs27.readFileSync(path23.join(__dirname, "../package.json"), "utf-8"));
7985
7903
  var cli = new FullstackCLI(pkg.version);
7986
7904
  cli.useAll(commands);
7987
7905
  cli.run();