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

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