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