@lark-apaas/fullstack-cli 1.1.39 → 1.1.40-alpha.1
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 +464 -190
- 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,6 +3105,220 @@ async function run3(options = {}) {
|
|
|
3105
3105
|
|
|
3106
3106
|
// src/commands/upgrade/deps/run.handler.ts
|
|
3107
3107
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
3108
|
+
|
|
3109
|
+
// src/utils/grayscale/config.ts
|
|
3110
|
+
function getGrayscaleConfig() {
|
|
3111
|
+
const raw = process.env.GRAYSCALE_CONFIG;
|
|
3112
|
+
if (!raw) {
|
|
3113
|
+
return null;
|
|
3114
|
+
}
|
|
3115
|
+
try {
|
|
3116
|
+
const config = JSON.parse(raw);
|
|
3117
|
+
if (!config.enabled) {
|
|
3118
|
+
return null;
|
|
3119
|
+
}
|
|
3120
|
+
return config;
|
|
3121
|
+
} catch {
|
|
3122
|
+
console.warn("[grayscale] Failed to parse GRAYSCALE_CONFIG env");
|
|
3123
|
+
return null;
|
|
3124
|
+
}
|
|
3125
|
+
}
|
|
3126
|
+
|
|
3127
|
+
// src/utils/grayscale/identity.ts
|
|
3128
|
+
import fs10 from "fs";
|
|
3129
|
+
import path8 from "path";
|
|
3130
|
+
function readFromEnvVars() {
|
|
3131
|
+
const appId = process.env.app_id || process.env.APP_ID;
|
|
3132
|
+
const tenantId = process.env.tenant_id || process.env.TENANT_ID;
|
|
3133
|
+
return { appId, tenantId };
|
|
3134
|
+
}
|
|
3135
|
+
function parseEnvFile(filePath) {
|
|
3136
|
+
const result = {};
|
|
3137
|
+
if (!fs10.existsSync(filePath)) {
|
|
3138
|
+
return result;
|
|
3139
|
+
}
|
|
3140
|
+
try {
|
|
3141
|
+
const content = fs10.readFileSync(filePath, "utf-8");
|
|
3142
|
+
const lines = content.split("\n");
|
|
3143
|
+
for (const line of lines) {
|
|
3144
|
+
const trimmed = line.trim();
|
|
3145
|
+
if (!trimmed || trimmed.startsWith("#")) {
|
|
3146
|
+
continue;
|
|
3147
|
+
}
|
|
3148
|
+
const match = trimmed.match(/^(?:export\s+)?([A-Za-z_][A-Za-z0-9_]*)=["']?(.+?)["']?$/);
|
|
3149
|
+
if (match) {
|
|
3150
|
+
result[match[1]] = match[2];
|
|
3151
|
+
}
|
|
3152
|
+
}
|
|
3153
|
+
} catch {
|
|
3154
|
+
}
|
|
3155
|
+
return result;
|
|
3156
|
+
}
|
|
3157
|
+
function readFromForceEnvFile(cwd) {
|
|
3158
|
+
const envPath2 = path8.join(cwd, ".force", "environment", "env");
|
|
3159
|
+
const vars = parseEnvFile(envPath2);
|
|
3160
|
+
return {
|
|
3161
|
+
appId: vars.app_id || vars.APP_ID,
|
|
3162
|
+
tenantId: vars.tenant_id || vars.TENANT_ID
|
|
3163
|
+
};
|
|
3164
|
+
}
|
|
3165
|
+
function readFromClientBasePath() {
|
|
3166
|
+
const basePath = process.env.CLIENT_BASE_PATH;
|
|
3167
|
+
if (!basePath) {
|
|
3168
|
+
return {};
|
|
3169
|
+
}
|
|
3170
|
+
const afMatch = basePath.match(/\/af\/p\/([^/]+)/);
|
|
3171
|
+
if (afMatch) {
|
|
3172
|
+
return { appId: afMatch[1] };
|
|
3173
|
+
}
|
|
3174
|
+
const appMatch = basePath.match(/\/app\/([^/]+)/);
|
|
3175
|
+
if (appMatch) {
|
|
3176
|
+
return { appId: appMatch[1] };
|
|
3177
|
+
}
|
|
3178
|
+
return {};
|
|
3179
|
+
}
|
|
3180
|
+
function readFromDotEnv(cwd) {
|
|
3181
|
+
const envPath2 = path8.join(cwd, ".env");
|
|
3182
|
+
const vars = parseEnvFile(envPath2);
|
|
3183
|
+
return {
|
|
3184
|
+
appId: vars.app_id || vars.APP_ID,
|
|
3185
|
+
tenantId: vars.tenant_id || vars.TENANT_ID
|
|
3186
|
+
};
|
|
3187
|
+
}
|
|
3188
|
+
function readFromPackageJson(cwd) {
|
|
3189
|
+
const pkgPath = path8.join(cwd, "package.json");
|
|
3190
|
+
if (!fs10.existsSync(pkgPath)) {
|
|
3191
|
+
return {};
|
|
3192
|
+
}
|
|
3193
|
+
try {
|
|
3194
|
+
const content = fs10.readFileSync(pkgPath, "utf-8");
|
|
3195
|
+
const pkg2 = JSON.parse(content);
|
|
3196
|
+
const appId = pkg2?.fullstack?.appId;
|
|
3197
|
+
return appId ? { appId } : {};
|
|
3198
|
+
} catch {
|
|
3199
|
+
return {};
|
|
3200
|
+
}
|
|
3201
|
+
}
|
|
3202
|
+
function readProjectIdentity(cwd) {
|
|
3203
|
+
const sources = [
|
|
3204
|
+
() => readFromEnvVars(),
|
|
3205
|
+
() => readFromForceEnvFile(cwd),
|
|
3206
|
+
() => readFromClientBasePath(),
|
|
3207
|
+
() => readFromDotEnv(cwd),
|
|
3208
|
+
() => readFromPackageJson(cwd)
|
|
3209
|
+
];
|
|
3210
|
+
const merged = {};
|
|
3211
|
+
for (const source of sources) {
|
|
3212
|
+
const identity = source();
|
|
3213
|
+
if (!merged.appId && identity.appId) {
|
|
3214
|
+
merged.appId = identity.appId;
|
|
3215
|
+
}
|
|
3216
|
+
if (!merged.tenantId && identity.tenantId) {
|
|
3217
|
+
merged.tenantId = identity.tenantId;
|
|
3218
|
+
}
|
|
3219
|
+
if (merged.appId && merged.tenantId) {
|
|
3220
|
+
break;
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
return merged;
|
|
3224
|
+
}
|
|
3225
|
+
|
|
3226
|
+
// src/utils/grayscale/rules.ts
|
|
3227
|
+
import { createHash } from "crypto";
|
|
3228
|
+
function isInPercentage(key, percentage) {
|
|
3229
|
+
if (percentage <= 0) return false;
|
|
3230
|
+
if (percentage >= 100) return true;
|
|
3231
|
+
const hash = createHash("md5").update(`grayscale:${key}`).digest("hex");
|
|
3232
|
+
const value = parseInt(hash.substring(0, 8), 16) % 1e4;
|
|
3233
|
+
const threshold = Math.floor(percentage * 100);
|
|
3234
|
+
return value < threshold;
|
|
3235
|
+
}
|
|
3236
|
+
function matchConditions(rule, identity) {
|
|
3237
|
+
const { conditions } = rule;
|
|
3238
|
+
if (conditions.tenant_ids && conditions.tenant_ids.length > 0) {
|
|
3239
|
+
if (identity.tenantId && conditions.tenant_ids.includes(identity.tenantId)) {
|
|
3240
|
+
return true;
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
3243
|
+
if (conditions.app_ids && conditions.app_ids.length > 0) {
|
|
3244
|
+
if (identity.appId && conditions.app_ids.includes(identity.appId)) {
|
|
3245
|
+
return true;
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
if (conditions.percentage != null && conditions.percentage > 0) {
|
|
3249
|
+
const hashKey = conditions.hash_key || "app_id";
|
|
3250
|
+
const hashValue = hashKey === "tenant_id" ? identity.tenantId : identity.appId;
|
|
3251
|
+
if (hashValue && isInPercentage(hashValue, conditions.percentage)) {
|
|
3252
|
+
return true;
|
|
3253
|
+
}
|
|
3254
|
+
}
|
|
3255
|
+
const hasConditions = conditions.tenant_ids && conditions.tenant_ids.length > 0 || conditions.app_ids && conditions.app_ids.length > 0 || conditions.percentage != null && conditions.percentage > 0;
|
|
3256
|
+
return !hasConditions;
|
|
3257
|
+
}
|
|
3258
|
+
function evaluateRules(config, identity) {
|
|
3259
|
+
const enabledRules = config.rules.filter((rule) => rule.enabled).sort((a, b) => b.priority - a.priority);
|
|
3260
|
+
for (const rule of enabledRules) {
|
|
3261
|
+
if (matchConditions(rule, identity)) {
|
|
3262
|
+
return rule;
|
|
3263
|
+
}
|
|
3264
|
+
}
|
|
3265
|
+
return null;
|
|
3266
|
+
}
|
|
3267
|
+
function resolveTargetVersions(config, identity) {
|
|
3268
|
+
const matchedRule = evaluateRules(config, identity);
|
|
3269
|
+
const channelName = matchedRule?.channel || config.default_channel;
|
|
3270
|
+
const channel = config.channels[channelName];
|
|
3271
|
+
if (!channel) {
|
|
3272
|
+
console.warn(`[grayscale] Channel "${channelName}" not found in config`);
|
|
3273
|
+
return null;
|
|
3274
|
+
}
|
|
3275
|
+
const versions = /* @__PURE__ */ new Map();
|
|
3276
|
+
for (const [pkgName, version] of Object.entries(channel.versions)) {
|
|
3277
|
+
if (config.blocked_versions?.includes(version)) {
|
|
3278
|
+
console.warn(`[grayscale] Version ${version} of ${pkgName} is blocked, skipping`);
|
|
3279
|
+
continue;
|
|
3280
|
+
}
|
|
3281
|
+
versions.set(pkgName, version);
|
|
3282
|
+
}
|
|
3283
|
+
if (config.force_versions) {
|
|
3284
|
+
for (const [pkgName, version] of Object.entries(config.force_versions)) {
|
|
3285
|
+
versions.set(pkgName, version);
|
|
3286
|
+
}
|
|
3287
|
+
}
|
|
3288
|
+
if (matchedRule) {
|
|
3289
|
+
console.log(`[grayscale] Matched rule: "${matchedRule.name}" (id: ${matchedRule.id}), channel: ${channelName}`);
|
|
3290
|
+
} else {
|
|
3291
|
+
console.log(`[grayscale] No rule matched, using default channel: ${channelName}`);
|
|
3292
|
+
}
|
|
3293
|
+
return versions;
|
|
3294
|
+
}
|
|
3295
|
+
|
|
3296
|
+
// src/utils/grayscale/index.ts
|
|
3297
|
+
function resolveGrayscaleVersions(cwd) {
|
|
3298
|
+
const config = getGrayscaleConfig();
|
|
3299
|
+
if (!config) {
|
|
3300
|
+
console.log("[grayscale] Config not available, skipping grayscale");
|
|
3301
|
+
return null;
|
|
3302
|
+
}
|
|
3303
|
+
const identity = readProjectIdentity(cwd);
|
|
3304
|
+
if (!identity.appId && !identity.tenantId) {
|
|
3305
|
+
console.log("[grayscale] No app_id or tenant_id found, skipping grayscale");
|
|
3306
|
+
return null;
|
|
3307
|
+
}
|
|
3308
|
+
console.log(`[grayscale] Project identity: appId=${identity.appId || "N/A"}, tenantId=${identity.tenantId || "N/A"}`);
|
|
3309
|
+
const versions = resolveTargetVersions(config, identity);
|
|
3310
|
+
if (!versions || versions.size === 0) {
|
|
3311
|
+
console.log("[grayscale] No target versions resolved");
|
|
3312
|
+
return null;
|
|
3313
|
+
}
|
|
3314
|
+
console.log(`[grayscale] Resolved ${versions.size} package version(s):`);
|
|
3315
|
+
for (const [pkg2, ver] of versions) {
|
|
3316
|
+
console.log(`[grayscale] ${pkg2} -> ${ver}`);
|
|
3317
|
+
}
|
|
3318
|
+
return versions;
|
|
3319
|
+
}
|
|
3320
|
+
|
|
3321
|
+
// src/commands/upgrade/deps/run.handler.ts
|
|
3108
3322
|
function findLarkAapaasPackages(cwd, filterPackages) {
|
|
3109
3323
|
const pkg2 = readPackageJson(cwd);
|
|
3110
3324
|
const allPackages = /* @__PURE__ */ new Set();
|
|
@@ -3157,11 +3371,43 @@ function upgradePackages(packages, version, cwd) {
|
|
|
3157
3371
|
});
|
|
3158
3372
|
}
|
|
3159
3373
|
}
|
|
3374
|
+
function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun) {
|
|
3375
|
+
const upgradePlan = [];
|
|
3376
|
+
for (const pkg2 of packages) {
|
|
3377
|
+
const version = grayscaleVersions.get(pkg2);
|
|
3378
|
+
if (version) {
|
|
3379
|
+
upgradePlan.push({ pkg: pkg2, version });
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3382
|
+
if (upgradePlan.length === 0) {
|
|
3383
|
+
console.log("[fullstack-cli] No grayscale versions matched current packages");
|
|
3384
|
+
return;
|
|
3385
|
+
}
|
|
3386
|
+
console.log(`[fullstack-cli] Grayscale upgrade plan (${upgradePlan.length} package(s)):`);
|
|
3387
|
+
upgradePlan.forEach(({ pkg: pkg2, version }) => {
|
|
3388
|
+
console.log(` - ${pkg2} -> ${version}`);
|
|
3389
|
+
});
|
|
3390
|
+
if (dryRun) {
|
|
3391
|
+
console.log("[fullstack-cli] Dry run mode, skipping actual installation");
|
|
3392
|
+
return;
|
|
3393
|
+
}
|
|
3394
|
+
for (const { pkg: pkg2, version } of upgradePlan) {
|
|
3395
|
+
const target = `${pkg2}@${version}`;
|
|
3396
|
+
console.log(`[fullstack-cli] Installing ${target}...`);
|
|
3397
|
+
const result = spawnSync3("npm", ["install", target], {
|
|
3398
|
+
cwd,
|
|
3399
|
+
stdio: "inherit"
|
|
3400
|
+
});
|
|
3401
|
+
if (result.error || result.status !== 0) {
|
|
3402
|
+
throw new Error(`Failed to install ${target}`);
|
|
3403
|
+
}
|
|
3404
|
+
}
|
|
3405
|
+
}
|
|
3160
3406
|
async function run4(options = {}) {
|
|
3161
3407
|
const cwd = process.env.INIT_CWD || process.cwd();
|
|
3162
3408
|
console.log("[fullstack-cli] Starting dependencies upgrade...");
|
|
3163
3409
|
try {
|
|
3164
|
-
console.log("[fullstack-cli] Step 1/
|
|
3410
|
+
console.log("[fullstack-cli] Step 1/3: Scanning @lark-apaas dependencies...");
|
|
3165
3411
|
const packages = findLarkAapaasPackages(cwd, options.packages);
|
|
3166
3412
|
if (packages.length === 0) {
|
|
3167
3413
|
console.log("[fullstack-cli] No @lark-apaas packages found");
|
|
@@ -3169,7 +3415,35 @@ async function run4(options = {}) {
|
|
|
3169
3415
|
}
|
|
3170
3416
|
console.log(`[fullstack-cli] Found ${packages.length} @lark-apaas package(s):`);
|
|
3171
3417
|
packages.forEach((p) => console.log(` - ${p}`));
|
|
3172
|
-
|
|
3418
|
+
if (!options.skipGrayscale && !options.version) {
|
|
3419
|
+
console.log("[fullstack-cli] Step 2/3: Checking grayscale config...");
|
|
3420
|
+
try {
|
|
3421
|
+
const grayscaleVersions = resolveGrayscaleVersions(cwd);
|
|
3422
|
+
if (grayscaleVersions) {
|
|
3423
|
+
console.log("[fullstack-cli] Step 3/3: Applying grayscale versions...");
|
|
3424
|
+
installGrayscaleVersions(packages, grayscaleVersions, cwd, !!options.dryRun);
|
|
3425
|
+
if (!options.dryRun) {
|
|
3426
|
+
console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s) via grayscale`);
|
|
3427
|
+
console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
|
|
3428
|
+
}
|
|
3429
|
+
return;
|
|
3430
|
+
}
|
|
3431
|
+
console.log("[fullstack-cli] Grayscale not available, falling back to default upgrade");
|
|
3432
|
+
} catch (error) {
|
|
3433
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
3434
|
+
console.warn(`[fullstack-cli] Grayscale check failed: ${msg}, falling back to default upgrade`);
|
|
3435
|
+
}
|
|
3436
|
+
} else if (options.skipGrayscale) {
|
|
3437
|
+
console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (--skip-grayscale)");
|
|
3438
|
+
} else {
|
|
3439
|
+
console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (explicit --version provided)");
|
|
3440
|
+
}
|
|
3441
|
+
if (options.dryRun) {
|
|
3442
|
+
console.log("[fullstack-cli] Dry run mode: would upgrade via npm update (no grayscale)");
|
|
3443
|
+
packages.forEach((p) => console.log(` - ${p} -> ${options.version || "latest compatible"}`));
|
|
3444
|
+
return;
|
|
3445
|
+
}
|
|
3446
|
+
console.log("[fullstack-cli] Step 3/3: Upgrading packages...");
|
|
3173
3447
|
upgradePackages(packages, options.version, cwd);
|
|
3174
3448
|
console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s)`);
|
|
3175
3449
|
console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
|
|
@@ -3185,7 +3459,7 @@ var depsCommand = {
|
|
|
3185
3459
|
name: "deps",
|
|
3186
3460
|
description: "Upgrade @lark-apaas dependencies",
|
|
3187
3461
|
register(parentCommand) {
|
|
3188
|
-
parentCommand.command(this.name).description(this.description).option("--version <version>", "Upgrade to specific version").option("--packages <packages>", "Only upgrade specific packages (comma-separated)").action(async (options) => {
|
|
3462
|
+
parentCommand.command(this.name).description(this.description).option("--version <version>", "Upgrade to specific version").option("--packages <packages>", "Only upgrade specific packages (comma-separated)").option("--skip-grayscale", "Skip grayscale version check").option("--dry-run", "Show upgrade plan without executing").action(async (options) => {
|
|
3189
3463
|
await run4(options);
|
|
3190
3464
|
});
|
|
3191
3465
|
}
|
|
@@ -3204,8 +3478,8 @@ var upgradeCommand = {
|
|
|
3204
3478
|
};
|
|
3205
3479
|
|
|
3206
3480
|
// src/commands/action-plugin/utils.ts
|
|
3207
|
-
import
|
|
3208
|
-
import
|
|
3481
|
+
import fs11 from "fs";
|
|
3482
|
+
import path9 from "path";
|
|
3209
3483
|
import { spawnSync as spawnSync4, execSync as execSync2 } from "child_process";
|
|
3210
3484
|
function parsePluginName(input) {
|
|
3211
3485
|
const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
|
|
@@ -3223,18 +3497,18 @@ function getProjectRoot() {
|
|
|
3223
3497
|
return process.cwd();
|
|
3224
3498
|
}
|
|
3225
3499
|
function getPackageJsonPath() {
|
|
3226
|
-
return
|
|
3500
|
+
return path9.join(getProjectRoot(), "package.json");
|
|
3227
3501
|
}
|
|
3228
3502
|
function getPluginPath(pluginName) {
|
|
3229
|
-
return
|
|
3503
|
+
return path9.join(getProjectRoot(), "node_modules", pluginName);
|
|
3230
3504
|
}
|
|
3231
3505
|
function readPackageJson2() {
|
|
3232
3506
|
const pkgPath = getPackageJsonPath();
|
|
3233
|
-
if (!
|
|
3507
|
+
if (!fs11.existsSync(pkgPath)) {
|
|
3234
3508
|
throw new Error("package.json not found in current directory");
|
|
3235
3509
|
}
|
|
3236
3510
|
try {
|
|
3237
|
-
const content =
|
|
3511
|
+
const content = fs11.readFileSync(pkgPath, "utf-8");
|
|
3238
3512
|
return JSON.parse(content);
|
|
3239
3513
|
} catch {
|
|
3240
3514
|
throw new Error("Failed to parse package.json");
|
|
@@ -3242,7 +3516,7 @@ function readPackageJson2() {
|
|
|
3242
3516
|
}
|
|
3243
3517
|
function writePackageJson2(pkg2) {
|
|
3244
3518
|
const pkgPath = getPackageJsonPath();
|
|
3245
|
-
|
|
3519
|
+
fs11.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
|
|
3246
3520
|
}
|
|
3247
3521
|
function readActionPlugins() {
|
|
3248
3522
|
const pkg2 = readPackageJson2();
|
|
@@ -3275,12 +3549,12 @@ function npmInstall(tgzPath) {
|
|
|
3275
3549
|
}
|
|
3276
3550
|
}
|
|
3277
3551
|
function getPackageVersion(pluginName) {
|
|
3278
|
-
const pkgJsonPath =
|
|
3279
|
-
if (!
|
|
3552
|
+
const pkgJsonPath = path9.join(getPluginPath(pluginName), "package.json");
|
|
3553
|
+
if (!fs11.existsSync(pkgJsonPath)) {
|
|
3280
3554
|
return null;
|
|
3281
3555
|
}
|
|
3282
3556
|
try {
|
|
3283
|
-
const content =
|
|
3557
|
+
const content = fs11.readFileSync(pkgJsonPath, "utf-8");
|
|
3284
3558
|
const pkg2 = JSON.parse(content);
|
|
3285
3559
|
return pkg2.version || null;
|
|
3286
3560
|
} catch {
|
|
@@ -3288,49 +3562,49 @@ function getPackageVersion(pluginName) {
|
|
|
3288
3562
|
}
|
|
3289
3563
|
}
|
|
3290
3564
|
function readPluginPackageJson(pluginPath) {
|
|
3291
|
-
const pkgJsonPath =
|
|
3292
|
-
if (!
|
|
3565
|
+
const pkgJsonPath = path9.join(pluginPath, "package.json");
|
|
3566
|
+
if (!fs11.existsSync(pkgJsonPath)) {
|
|
3293
3567
|
return null;
|
|
3294
3568
|
}
|
|
3295
3569
|
try {
|
|
3296
|
-
const content =
|
|
3570
|
+
const content = fs11.readFileSync(pkgJsonPath, "utf-8");
|
|
3297
3571
|
return JSON.parse(content);
|
|
3298
3572
|
} catch {
|
|
3299
3573
|
return null;
|
|
3300
3574
|
}
|
|
3301
3575
|
}
|
|
3302
3576
|
function extractTgzToNodeModules(tgzPath, pluginName) {
|
|
3303
|
-
const nodeModulesPath =
|
|
3304
|
-
const targetDir =
|
|
3305
|
-
const scopeDir =
|
|
3306
|
-
if (!
|
|
3307
|
-
|
|
3577
|
+
const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
|
|
3578
|
+
const targetDir = path9.join(nodeModulesPath, pluginName);
|
|
3579
|
+
const scopeDir = path9.dirname(targetDir);
|
|
3580
|
+
if (!fs11.existsSync(scopeDir)) {
|
|
3581
|
+
fs11.mkdirSync(scopeDir, { recursive: true });
|
|
3308
3582
|
}
|
|
3309
|
-
if (
|
|
3310
|
-
|
|
3583
|
+
if (fs11.existsSync(targetDir)) {
|
|
3584
|
+
fs11.rmSync(targetDir, { recursive: true });
|
|
3311
3585
|
}
|
|
3312
|
-
const tempDir =
|
|
3313
|
-
if (
|
|
3314
|
-
|
|
3586
|
+
const tempDir = path9.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
|
|
3587
|
+
if (fs11.existsSync(tempDir)) {
|
|
3588
|
+
fs11.rmSync(tempDir, { recursive: true });
|
|
3315
3589
|
}
|
|
3316
|
-
|
|
3590
|
+
fs11.mkdirSync(tempDir, { recursive: true });
|
|
3317
3591
|
try {
|
|
3318
3592
|
execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
|
|
3319
|
-
const extractedDir =
|
|
3320
|
-
if (
|
|
3321
|
-
|
|
3593
|
+
const extractedDir = path9.join(tempDir, "package");
|
|
3594
|
+
if (fs11.existsSync(extractedDir)) {
|
|
3595
|
+
fs11.renameSync(extractedDir, targetDir);
|
|
3322
3596
|
} else {
|
|
3323
|
-
const files =
|
|
3597
|
+
const files = fs11.readdirSync(tempDir);
|
|
3324
3598
|
if (files.length === 1) {
|
|
3325
|
-
|
|
3599
|
+
fs11.renameSync(path9.join(tempDir, files[0]), targetDir);
|
|
3326
3600
|
} else {
|
|
3327
3601
|
throw new Error("Unexpected tgz structure");
|
|
3328
3602
|
}
|
|
3329
3603
|
}
|
|
3330
3604
|
return targetDir;
|
|
3331
3605
|
} finally {
|
|
3332
|
-
if (
|
|
3333
|
-
|
|
3606
|
+
if (fs11.existsSync(tempDir)) {
|
|
3607
|
+
fs11.rmSync(tempDir, { recursive: true });
|
|
3334
3608
|
}
|
|
3335
3609
|
}
|
|
3336
3610
|
}
|
|
@@ -3339,10 +3613,10 @@ function checkMissingPeerDeps(peerDeps) {
|
|
|
3339
3613
|
return [];
|
|
3340
3614
|
}
|
|
3341
3615
|
const missing = [];
|
|
3342
|
-
const nodeModulesPath =
|
|
3616
|
+
const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
|
|
3343
3617
|
for (const [depName, _version] of Object.entries(peerDeps)) {
|
|
3344
|
-
const depPath =
|
|
3345
|
-
if (!
|
|
3618
|
+
const depPath = path9.join(nodeModulesPath, depName);
|
|
3619
|
+
if (!fs11.existsSync(depPath)) {
|
|
3346
3620
|
missing.push(depName);
|
|
3347
3621
|
}
|
|
3348
3622
|
}
|
|
@@ -3366,16 +3640,16 @@ function installMissingDeps(deps) {
|
|
|
3366
3640
|
}
|
|
3367
3641
|
function removePluginDirectory(pluginName) {
|
|
3368
3642
|
const pluginPath = getPluginPath(pluginName);
|
|
3369
|
-
if (
|
|
3370
|
-
|
|
3643
|
+
if (fs11.existsSync(pluginPath)) {
|
|
3644
|
+
fs11.rmSync(pluginPath, { recursive: true });
|
|
3371
3645
|
console.log(`[action-plugin] Removed ${pluginName}`);
|
|
3372
3646
|
}
|
|
3373
3647
|
}
|
|
3374
3648
|
|
|
3375
3649
|
// src/commands/action-plugin/api-client.ts
|
|
3376
3650
|
import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
|
|
3377
|
-
import
|
|
3378
|
-
import
|
|
3651
|
+
import fs12 from "fs";
|
|
3652
|
+
import path10 from "path";
|
|
3379
3653
|
var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
|
|
3380
3654
|
async function getPluginVersions(keys, latestOnly = true) {
|
|
3381
3655
|
const client = getHttpClient();
|
|
@@ -3439,19 +3713,19 @@ async function downloadFromPublic(downloadURL) {
|
|
|
3439
3713
|
return Buffer.from(arrayBuffer);
|
|
3440
3714
|
}
|
|
3441
3715
|
function getPluginCacheDir() {
|
|
3442
|
-
return
|
|
3716
|
+
return path10.join(process.cwd(), PLUGIN_CACHE_DIR);
|
|
3443
3717
|
}
|
|
3444
3718
|
function ensureCacheDir() {
|
|
3445
3719
|
const cacheDir = getPluginCacheDir();
|
|
3446
|
-
if (!
|
|
3447
|
-
|
|
3720
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3721
|
+
fs12.mkdirSync(cacheDir, { recursive: true });
|
|
3448
3722
|
}
|
|
3449
3723
|
}
|
|
3450
3724
|
function getTempFilePath(pluginKey, version) {
|
|
3451
3725
|
ensureCacheDir();
|
|
3452
3726
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
3453
3727
|
const filename = `${safeKey}@${version}.tgz`;
|
|
3454
|
-
return
|
|
3728
|
+
return path10.join(getPluginCacheDir(), filename);
|
|
3455
3729
|
}
|
|
3456
3730
|
var MAX_RETRIES = 2;
|
|
3457
3731
|
async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
|
|
@@ -3488,7 +3762,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
|
|
|
3488
3762
|
);
|
|
3489
3763
|
}
|
|
3490
3764
|
const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
|
|
3491
|
-
|
|
3765
|
+
fs12.writeFileSync(tgzPath, tgzBuffer);
|
|
3492
3766
|
console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
|
|
3493
3767
|
return {
|
|
3494
3768
|
tgzPath,
|
|
@@ -3502,18 +3776,18 @@ function getCachePath(pluginKey, version) {
|
|
|
3502
3776
|
ensureCacheDir();
|
|
3503
3777
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
3504
3778
|
const filename = `${safeKey}@${version}.tgz`;
|
|
3505
|
-
return
|
|
3779
|
+
return path10.join(getPluginCacheDir(), filename);
|
|
3506
3780
|
}
|
|
3507
3781
|
function hasCachedPlugin(pluginKey, version) {
|
|
3508
3782
|
const cachePath = getCachePath(pluginKey, version);
|
|
3509
|
-
return
|
|
3783
|
+
return fs12.existsSync(cachePath);
|
|
3510
3784
|
}
|
|
3511
3785
|
function listCachedPlugins() {
|
|
3512
3786
|
const cacheDir = getPluginCacheDir();
|
|
3513
|
-
if (!
|
|
3787
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3514
3788
|
return [];
|
|
3515
3789
|
}
|
|
3516
|
-
const files =
|
|
3790
|
+
const files = fs12.readdirSync(cacheDir);
|
|
3517
3791
|
const result = [];
|
|
3518
3792
|
for (const file of files) {
|
|
3519
3793
|
if (!file.endsWith(".tgz")) continue;
|
|
@@ -3521,8 +3795,8 @@ function listCachedPlugins() {
|
|
|
3521
3795
|
if (!match) continue;
|
|
3522
3796
|
const [, rawName, version] = match;
|
|
3523
3797
|
const name = rawName.replace(/^_/, "@").replace(/_/, "/");
|
|
3524
|
-
const filePath =
|
|
3525
|
-
const stat =
|
|
3798
|
+
const filePath = path10.join(cacheDir, file);
|
|
3799
|
+
const stat = fs12.statSync(filePath);
|
|
3526
3800
|
result.push({
|
|
3527
3801
|
name,
|
|
3528
3802
|
version,
|
|
@@ -3535,14 +3809,14 @@ function listCachedPlugins() {
|
|
|
3535
3809
|
}
|
|
3536
3810
|
function cleanAllCache() {
|
|
3537
3811
|
const cacheDir = getPluginCacheDir();
|
|
3538
|
-
if (!
|
|
3812
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3539
3813
|
return 0;
|
|
3540
3814
|
}
|
|
3541
|
-
const files =
|
|
3815
|
+
const files = fs12.readdirSync(cacheDir);
|
|
3542
3816
|
let count = 0;
|
|
3543
3817
|
for (const file of files) {
|
|
3544
3818
|
if (file.endsWith(".tgz")) {
|
|
3545
|
-
|
|
3819
|
+
fs12.unlinkSync(path10.join(cacheDir, file));
|
|
3546
3820
|
count++;
|
|
3547
3821
|
}
|
|
3548
3822
|
}
|
|
@@ -3550,21 +3824,21 @@ function cleanAllCache() {
|
|
|
3550
3824
|
}
|
|
3551
3825
|
function cleanPluginCache(pluginKey, version) {
|
|
3552
3826
|
const cacheDir = getPluginCacheDir();
|
|
3553
|
-
if (!
|
|
3827
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3554
3828
|
return 0;
|
|
3555
3829
|
}
|
|
3556
3830
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
3557
|
-
const files =
|
|
3831
|
+
const files = fs12.readdirSync(cacheDir);
|
|
3558
3832
|
let count = 0;
|
|
3559
3833
|
for (const file of files) {
|
|
3560
3834
|
if (version) {
|
|
3561
3835
|
if (file === `${safeKey}@${version}.tgz`) {
|
|
3562
|
-
|
|
3836
|
+
fs12.unlinkSync(path10.join(cacheDir, file));
|
|
3563
3837
|
count++;
|
|
3564
3838
|
}
|
|
3565
3839
|
} else {
|
|
3566
3840
|
if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
|
|
3567
|
-
|
|
3841
|
+
fs12.unlinkSync(path10.join(cacheDir, file));
|
|
3568
3842
|
count++;
|
|
3569
3843
|
}
|
|
3570
3844
|
}
|
|
@@ -3991,40 +4265,40 @@ var actionPluginCommandGroup = {
|
|
|
3991
4265
|
};
|
|
3992
4266
|
|
|
3993
4267
|
// src/commands/capability/utils.ts
|
|
3994
|
-
import
|
|
4268
|
+
import fs13 from "fs";
|
|
3995
4269
|
import { createRequire as createRequire2 } from "module";
|
|
3996
|
-
import
|
|
4270
|
+
import path11 from "path";
|
|
3997
4271
|
var CAPABILITIES_DIR = "server/capabilities";
|
|
3998
4272
|
function getProjectRoot2() {
|
|
3999
4273
|
return process.cwd();
|
|
4000
4274
|
}
|
|
4001
4275
|
function getCapabilitiesDir() {
|
|
4002
|
-
return
|
|
4276
|
+
return path11.join(getProjectRoot2(), CAPABILITIES_DIR);
|
|
4003
4277
|
}
|
|
4004
4278
|
function getCapabilityPath(id) {
|
|
4005
|
-
return
|
|
4279
|
+
return path11.join(getCapabilitiesDir(), `${id}.json`);
|
|
4006
4280
|
}
|
|
4007
4281
|
function getPluginManifestPath(pluginKey) {
|
|
4008
|
-
return
|
|
4282
|
+
return path11.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
|
|
4009
4283
|
}
|
|
4010
4284
|
function capabilitiesDirExists() {
|
|
4011
|
-
return
|
|
4285
|
+
return fs13.existsSync(getCapabilitiesDir());
|
|
4012
4286
|
}
|
|
4013
4287
|
function listCapabilityIds() {
|
|
4014
4288
|
const dir = getCapabilitiesDir();
|
|
4015
|
-
if (!
|
|
4289
|
+
if (!fs13.existsSync(dir)) {
|
|
4016
4290
|
return [];
|
|
4017
4291
|
}
|
|
4018
|
-
const files =
|
|
4292
|
+
const files = fs13.readdirSync(dir);
|
|
4019
4293
|
return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
|
|
4020
4294
|
}
|
|
4021
4295
|
function readCapability(id) {
|
|
4022
4296
|
const filePath = getCapabilityPath(id);
|
|
4023
|
-
if (!
|
|
4297
|
+
if (!fs13.existsSync(filePath)) {
|
|
4024
4298
|
throw new Error(`Capability not found: ${id}`);
|
|
4025
4299
|
}
|
|
4026
4300
|
try {
|
|
4027
|
-
const content =
|
|
4301
|
+
const content = fs13.readFileSync(filePath, "utf-8");
|
|
4028
4302
|
return JSON.parse(content);
|
|
4029
4303
|
} catch (error) {
|
|
4030
4304
|
if (error instanceof SyntaxError) {
|
|
@@ -4051,11 +4325,11 @@ function readAllCapabilities() {
|
|
|
4051
4325
|
}
|
|
4052
4326
|
function readPluginManifest(pluginKey) {
|
|
4053
4327
|
const manifestPath = getPluginManifestPath(pluginKey);
|
|
4054
|
-
if (!
|
|
4328
|
+
if (!fs13.existsSync(manifestPath)) {
|
|
4055
4329
|
throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
|
|
4056
4330
|
}
|
|
4057
4331
|
try {
|
|
4058
|
-
const content =
|
|
4332
|
+
const content = fs13.readFileSync(manifestPath, "utf-8");
|
|
4059
4333
|
return JSON.parse(content);
|
|
4060
4334
|
} catch (error) {
|
|
4061
4335
|
if (error instanceof SyntaxError) {
|
|
@@ -4072,7 +4346,7 @@ function hasValidParamsSchema(paramsSchema) {
|
|
|
4072
4346
|
}
|
|
4073
4347
|
async function loadPlugin(pluginKey) {
|
|
4074
4348
|
try {
|
|
4075
|
-
const userRequire = createRequire2(
|
|
4349
|
+
const userRequire = createRequire2(path11.join(getProjectRoot2(), "package.json"));
|
|
4076
4350
|
const resolvedPath = userRequire.resolve(pluginKey);
|
|
4077
4351
|
const pluginModule = await import(resolvedPath);
|
|
4078
4352
|
const pluginPackage = pluginModule.default ?? pluginModule;
|
|
@@ -4235,8 +4509,8 @@ var capabilityCommandGroup = {
|
|
|
4235
4509
|
import { execFile } from "child_process";
|
|
4236
4510
|
|
|
4237
4511
|
// src/commands/component/registry-preparer.ts
|
|
4238
|
-
import
|
|
4239
|
-
import
|
|
4512
|
+
import fs14 from "fs";
|
|
4513
|
+
import path12 from "path";
|
|
4240
4514
|
import os from "os";
|
|
4241
4515
|
|
|
4242
4516
|
// src/commands/component/service.ts
|
|
@@ -4292,7 +4566,7 @@ async function sendInstallEvent(key) {
|
|
|
4292
4566
|
}
|
|
4293
4567
|
|
|
4294
4568
|
// src/commands/component/registry-preparer.ts
|
|
4295
|
-
var REGISTRY_TEMP_DIR =
|
|
4569
|
+
var REGISTRY_TEMP_DIR = path12.join(os.tmpdir(), "miaoda-registry");
|
|
4296
4570
|
function parseComponentKey(key) {
|
|
4297
4571
|
const match = key.match(/^@([^/]+)\/(.+)$/);
|
|
4298
4572
|
if (!match) {
|
|
@@ -4304,11 +4578,11 @@ function parseComponentKey(key) {
|
|
|
4304
4578
|
}
|
|
4305
4579
|
function getLocalRegistryPath(key) {
|
|
4306
4580
|
const { scope, name } = parseComponentKey(key);
|
|
4307
|
-
return
|
|
4581
|
+
return path12.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
|
|
4308
4582
|
}
|
|
4309
4583
|
function ensureDir(dirPath) {
|
|
4310
|
-
if (!
|
|
4311
|
-
|
|
4584
|
+
if (!fs14.existsSync(dirPath)) {
|
|
4585
|
+
fs14.mkdirSync(dirPath, { recursive: true });
|
|
4312
4586
|
}
|
|
4313
4587
|
}
|
|
4314
4588
|
async function prepareRecursive(key, visited) {
|
|
@@ -4341,8 +4615,8 @@ async function prepareRecursive(key, visited) {
|
|
|
4341
4615
|
registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
|
|
4342
4616
|
};
|
|
4343
4617
|
const localPath = getLocalRegistryPath(key);
|
|
4344
|
-
ensureDir(
|
|
4345
|
-
|
|
4618
|
+
ensureDir(path12.dirname(localPath));
|
|
4619
|
+
fs14.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
|
|
4346
4620
|
debug("\u4FDD\u5B58\u5230: %s", localPath);
|
|
4347
4621
|
}
|
|
4348
4622
|
async function prepareComponentRegistryItems(id) {
|
|
@@ -4352,18 +4626,18 @@ async function prepareComponentRegistryItems(id) {
|
|
|
4352
4626
|
}
|
|
4353
4627
|
function cleanupTempDir() {
|
|
4354
4628
|
try {
|
|
4355
|
-
if (
|
|
4356
|
-
|
|
4629
|
+
if (fs14.existsSync(REGISTRY_TEMP_DIR)) {
|
|
4630
|
+
fs14.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
|
|
4357
4631
|
}
|
|
4358
4632
|
} catch {
|
|
4359
4633
|
}
|
|
4360
4634
|
}
|
|
4361
4635
|
function getDownloadedRegistryItem(itemId) {
|
|
4362
4636
|
const localPath = getLocalRegistryPath(itemId);
|
|
4363
|
-
if (!
|
|
4637
|
+
if (!fs14.existsSync(localPath)) {
|
|
4364
4638
|
return null;
|
|
4365
4639
|
}
|
|
4366
|
-
const content =
|
|
4640
|
+
const content = fs14.readFileSync(localPath, "utf-8");
|
|
4367
4641
|
return JSON.parse(content);
|
|
4368
4642
|
}
|
|
4369
4643
|
|
|
@@ -4531,58 +4805,58 @@ var componentCommandGroup = {
|
|
|
4531
4805
|
};
|
|
4532
4806
|
|
|
4533
4807
|
// src/commands/migration/version-manager.ts
|
|
4534
|
-
import
|
|
4535
|
-
import
|
|
4808
|
+
import fs15 from "fs";
|
|
4809
|
+
import path13 from "path";
|
|
4536
4810
|
var PACKAGE_JSON = "package.json";
|
|
4537
4811
|
var VERSION_FIELD = "migrationVersion";
|
|
4538
4812
|
function getPackageJsonPath2() {
|
|
4539
|
-
return
|
|
4813
|
+
return path13.join(process.cwd(), PACKAGE_JSON);
|
|
4540
4814
|
}
|
|
4541
4815
|
function getCurrentVersion() {
|
|
4542
4816
|
const pkgPath = getPackageJsonPath2();
|
|
4543
|
-
if (!
|
|
4817
|
+
if (!fs15.existsSync(pkgPath)) {
|
|
4544
4818
|
throw new Error("package.json not found");
|
|
4545
4819
|
}
|
|
4546
|
-
const pkg2 = JSON.parse(
|
|
4820
|
+
const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
|
|
4547
4821
|
return pkg2[VERSION_FIELD] ?? 0;
|
|
4548
4822
|
}
|
|
4549
4823
|
function setCurrentVersion(version) {
|
|
4550
4824
|
const pkgPath = getPackageJsonPath2();
|
|
4551
|
-
const pkg2 = JSON.parse(
|
|
4825
|
+
const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
|
|
4552
4826
|
pkg2[VERSION_FIELD] = version;
|
|
4553
|
-
|
|
4827
|
+
fs15.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
|
|
4554
4828
|
}
|
|
4555
4829
|
|
|
4556
4830
|
// src/commands/migration/versions/v001_capability/json-migrator/detector.ts
|
|
4557
|
-
import
|
|
4558
|
-
import
|
|
4831
|
+
import fs17 from "fs";
|
|
4832
|
+
import path15 from "path";
|
|
4559
4833
|
|
|
4560
4834
|
// src/commands/migration/versions/v001_capability/utils.ts
|
|
4561
|
-
import
|
|
4562
|
-
import
|
|
4835
|
+
import fs16 from "fs";
|
|
4836
|
+
import path14 from "path";
|
|
4563
4837
|
var CAPABILITIES_DIR2 = "server/capabilities";
|
|
4564
4838
|
function getProjectRoot3() {
|
|
4565
4839
|
return process.cwd();
|
|
4566
4840
|
}
|
|
4567
4841
|
function getCapabilitiesDir2() {
|
|
4568
|
-
return
|
|
4842
|
+
return path14.join(getProjectRoot3(), CAPABILITIES_DIR2);
|
|
4569
4843
|
}
|
|
4570
4844
|
function getPluginManifestPath2(pluginKey) {
|
|
4571
|
-
return
|
|
4845
|
+
return path14.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
|
|
4572
4846
|
}
|
|
4573
4847
|
|
|
4574
4848
|
// src/commands/migration/versions/v001_capability/json-migrator/detector.ts
|
|
4575
4849
|
function detectJsonMigration() {
|
|
4576
4850
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
4577
|
-
const oldFilePath =
|
|
4578
|
-
if (!
|
|
4851
|
+
const oldFilePath = path15.join(capabilitiesDir, "capabilities.json");
|
|
4852
|
+
if (!fs17.existsSync(oldFilePath)) {
|
|
4579
4853
|
return {
|
|
4580
4854
|
needsMigration: false,
|
|
4581
4855
|
reason: "capabilities.json not found"
|
|
4582
4856
|
};
|
|
4583
4857
|
}
|
|
4584
4858
|
try {
|
|
4585
|
-
const content =
|
|
4859
|
+
const content = fs17.readFileSync(oldFilePath, "utf-8");
|
|
4586
4860
|
const parsed = JSON.parse(content);
|
|
4587
4861
|
if (!Array.isArray(parsed)) {
|
|
4588
4862
|
return {
|
|
@@ -4633,8 +4907,8 @@ async function check(options) {
|
|
|
4633
4907
|
}
|
|
4634
4908
|
|
|
4635
4909
|
// src/commands/migration/versions/v001_capability/json-migrator/index.ts
|
|
4636
|
-
import
|
|
4637
|
-
import
|
|
4910
|
+
import fs18 from "fs";
|
|
4911
|
+
import path16 from "path";
|
|
4638
4912
|
|
|
4639
4913
|
// src/commands/migration/versions/v001_capability/mapping.ts
|
|
4640
4914
|
var DEFAULT_PLUGIN_VERSION = "1.0.0";
|
|
@@ -4864,18 +5138,18 @@ function transformCapabilities(oldCapabilities) {
|
|
|
4864
5138
|
// src/commands/migration/versions/v001_capability/json-migrator/index.ts
|
|
4865
5139
|
function loadExistingCapabilities() {
|
|
4866
5140
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
4867
|
-
if (!
|
|
5141
|
+
if (!fs18.existsSync(capabilitiesDir)) {
|
|
4868
5142
|
return [];
|
|
4869
5143
|
}
|
|
4870
|
-
const files =
|
|
5144
|
+
const files = fs18.readdirSync(capabilitiesDir);
|
|
4871
5145
|
const capabilities = [];
|
|
4872
5146
|
for (const file of files) {
|
|
4873
5147
|
if (file === "capabilities.json" || !file.endsWith(".json")) {
|
|
4874
5148
|
continue;
|
|
4875
5149
|
}
|
|
4876
5150
|
try {
|
|
4877
|
-
const filePath =
|
|
4878
|
-
const content =
|
|
5151
|
+
const filePath = path16.join(capabilitiesDir, file);
|
|
5152
|
+
const content = fs18.readFileSync(filePath, "utf-8");
|
|
4879
5153
|
const capability = JSON.parse(content);
|
|
4880
5154
|
if (capability.id && capability.pluginKey) {
|
|
4881
5155
|
capabilities.push(capability);
|
|
@@ -4933,9 +5207,9 @@ async function migrateJsonFiles(options) {
|
|
|
4933
5207
|
}
|
|
4934
5208
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
4935
5209
|
for (const cap of newCapabilities) {
|
|
4936
|
-
const filePath =
|
|
5210
|
+
const filePath = path16.join(capabilitiesDir, `${cap.id}.json`);
|
|
4937
5211
|
const content = JSON.stringify(cap, null, 2);
|
|
4938
|
-
|
|
5212
|
+
fs18.writeFileSync(filePath, content, "utf-8");
|
|
4939
5213
|
console.log(` \u2713 Created: ${cap.id}.json`);
|
|
4940
5214
|
}
|
|
4941
5215
|
return {
|
|
@@ -4947,11 +5221,11 @@ async function migrateJsonFiles(options) {
|
|
|
4947
5221
|
}
|
|
4948
5222
|
|
|
4949
5223
|
// src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
|
|
4950
|
-
import
|
|
5224
|
+
import fs19 from "fs";
|
|
4951
5225
|
function isPluginInstalled2(pluginKey) {
|
|
4952
5226
|
const actionPlugins = readActionPlugins();
|
|
4953
5227
|
const manifestPath = getPluginManifestPath2(pluginKey);
|
|
4954
|
-
return
|
|
5228
|
+
return fs19.existsSync(manifestPath) && !!actionPlugins[pluginKey];
|
|
4955
5229
|
}
|
|
4956
5230
|
function detectPluginsToInstall(capabilities) {
|
|
4957
5231
|
const pluginKeys = /* @__PURE__ */ new Set();
|
|
@@ -5027,12 +5301,12 @@ async function installPlugins(capabilities, options) {
|
|
|
5027
5301
|
}
|
|
5028
5302
|
|
|
5029
5303
|
// src/commands/migration/versions/v001_capability/code-migrator/index.ts
|
|
5030
|
-
import
|
|
5304
|
+
import path18 from "path";
|
|
5031
5305
|
import { Project as Project3 } from "ts-morph";
|
|
5032
5306
|
|
|
5033
5307
|
// src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
|
|
5034
|
-
import
|
|
5035
|
-
import
|
|
5308
|
+
import fs20 from "fs";
|
|
5309
|
+
import path17 from "path";
|
|
5036
5310
|
var EXCLUDED_DIRS = [
|
|
5037
5311
|
"node_modules",
|
|
5038
5312
|
"dist",
|
|
@@ -5047,9 +5321,9 @@ var EXCLUDED_PATTERNS = [
|
|
|
5047
5321
|
/\.d\.ts$/
|
|
5048
5322
|
];
|
|
5049
5323
|
function scanDirectory(dir, files = []) {
|
|
5050
|
-
const entries =
|
|
5324
|
+
const entries = fs20.readdirSync(dir, { withFileTypes: true });
|
|
5051
5325
|
for (const entry of entries) {
|
|
5052
|
-
const fullPath =
|
|
5326
|
+
const fullPath = path17.join(dir, entry.name);
|
|
5053
5327
|
if (entry.isDirectory()) {
|
|
5054
5328
|
if (EXCLUDED_DIRS.includes(entry.name)) {
|
|
5055
5329
|
continue;
|
|
@@ -5065,14 +5339,14 @@ function scanDirectory(dir, files = []) {
|
|
|
5065
5339
|
return files;
|
|
5066
5340
|
}
|
|
5067
5341
|
function scanServerFiles() {
|
|
5068
|
-
const serverDir =
|
|
5069
|
-
if (!
|
|
5342
|
+
const serverDir = path17.join(getProjectRoot3(), "server");
|
|
5343
|
+
if (!fs20.existsSync(serverDir)) {
|
|
5070
5344
|
return [];
|
|
5071
5345
|
}
|
|
5072
5346
|
return scanDirectory(serverDir);
|
|
5073
5347
|
}
|
|
5074
5348
|
function hasCapabilityImport(filePath) {
|
|
5075
|
-
const content =
|
|
5349
|
+
const content = fs20.readFileSync(filePath, "utf-8");
|
|
5076
5350
|
return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
|
|
5077
5351
|
}
|
|
5078
5352
|
function scanFilesToMigrate() {
|
|
@@ -5449,7 +5723,7 @@ function analyzeFile(project, filePath, actionNameMap) {
|
|
|
5449
5723
|
const callSites = analyzeCallSites(sourceFile, imports);
|
|
5450
5724
|
const classInfo = analyzeClass(sourceFile);
|
|
5451
5725
|
const { canMigrate, reason } = canAutoMigrate(classInfo);
|
|
5452
|
-
const relativePath =
|
|
5726
|
+
const relativePath = path18.relative(getProjectRoot3(), filePath);
|
|
5453
5727
|
return {
|
|
5454
5728
|
filePath: relativePath,
|
|
5455
5729
|
imports,
|
|
@@ -5460,7 +5734,7 @@ function analyzeFile(project, filePath, actionNameMap) {
|
|
|
5460
5734
|
};
|
|
5461
5735
|
}
|
|
5462
5736
|
function migrateFile(project, analysis, dryRun) {
|
|
5463
|
-
const absolutePath =
|
|
5737
|
+
const absolutePath = path18.join(getProjectRoot3(), analysis.filePath);
|
|
5464
5738
|
if (!analysis.canAutoMigrate) {
|
|
5465
5739
|
return {
|
|
5466
5740
|
filePath: analysis.filePath,
|
|
@@ -5563,17 +5837,17 @@ function getSuggestion(analysis) {
|
|
|
5563
5837
|
}
|
|
5564
5838
|
|
|
5565
5839
|
// src/commands/migration/versions/v001_capability/cleanup.ts
|
|
5566
|
-
import
|
|
5567
|
-
import
|
|
5840
|
+
import fs21 from "fs";
|
|
5841
|
+
import path19 from "path";
|
|
5568
5842
|
function cleanupOldFiles(capabilities, dryRun) {
|
|
5569
5843
|
const deletedFiles = [];
|
|
5570
5844
|
const errors = [];
|
|
5571
5845
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
5572
|
-
const oldJsonPath =
|
|
5573
|
-
if (
|
|
5846
|
+
const oldJsonPath = path19.join(capabilitiesDir, "capabilities.json");
|
|
5847
|
+
if (fs21.existsSync(oldJsonPath)) {
|
|
5574
5848
|
try {
|
|
5575
5849
|
if (!dryRun) {
|
|
5576
|
-
|
|
5850
|
+
fs21.unlinkSync(oldJsonPath);
|
|
5577
5851
|
}
|
|
5578
5852
|
deletedFiles.push("capabilities.json");
|
|
5579
5853
|
} catch (error) {
|
|
@@ -5581,11 +5855,11 @@ function cleanupOldFiles(capabilities, dryRun) {
|
|
|
5581
5855
|
}
|
|
5582
5856
|
}
|
|
5583
5857
|
for (const cap of capabilities) {
|
|
5584
|
-
const tsFilePath =
|
|
5585
|
-
if (
|
|
5858
|
+
const tsFilePath = path19.join(capabilitiesDir, `${cap.id}.ts`);
|
|
5859
|
+
if (fs21.existsSync(tsFilePath)) {
|
|
5586
5860
|
try {
|
|
5587
5861
|
if (!dryRun) {
|
|
5588
|
-
|
|
5862
|
+
fs21.unlinkSync(tsFilePath);
|
|
5589
5863
|
}
|
|
5590
5864
|
deletedFiles.push(`${cap.id}.ts`);
|
|
5591
5865
|
} catch (error) {
|
|
@@ -5601,8 +5875,8 @@ function cleanupOldFiles(capabilities, dryRun) {
|
|
|
5601
5875
|
}
|
|
5602
5876
|
|
|
5603
5877
|
// src/commands/migration/versions/v001_capability/report-generator.ts
|
|
5604
|
-
import
|
|
5605
|
-
import
|
|
5878
|
+
import fs22 from "fs";
|
|
5879
|
+
import path20 from "path";
|
|
5606
5880
|
var REPORT_FILE = "capability-migration-report.md";
|
|
5607
5881
|
function printSummary(result) {
|
|
5608
5882
|
const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
|
|
@@ -5765,15 +6039,15 @@ async function generateReport(result) {
|
|
|
5765
6039
|
}
|
|
5766
6040
|
lines.push("");
|
|
5767
6041
|
const logDir = process.env.LOG_DIR || "logs";
|
|
5768
|
-
if (!
|
|
6042
|
+
if (!fs22.existsSync(logDir)) {
|
|
5769
6043
|
return;
|
|
5770
6044
|
}
|
|
5771
|
-
const reportDir =
|
|
5772
|
-
if (!
|
|
5773
|
-
|
|
6045
|
+
const reportDir = path20.join(logDir, "migration");
|
|
6046
|
+
if (!fs22.existsSync(reportDir)) {
|
|
6047
|
+
fs22.mkdirSync(reportDir, { recursive: true });
|
|
5774
6048
|
}
|
|
5775
|
-
const reportPath =
|
|
5776
|
-
|
|
6049
|
+
const reportPath = path20.join(reportDir, REPORT_FILE);
|
|
6050
|
+
fs22.writeFileSync(reportPath, lines.join("\n"), "utf-8");
|
|
5777
6051
|
console.log(`\u{1F4C4} Report generated: ${reportPath}`);
|
|
5778
6052
|
}
|
|
5779
6053
|
|
|
@@ -6305,10 +6579,10 @@ var migrationCommand = {
|
|
|
6305
6579
|
};
|
|
6306
6580
|
|
|
6307
6581
|
// src/commands/read-logs/index.ts
|
|
6308
|
-
import
|
|
6582
|
+
import path21 from "path";
|
|
6309
6583
|
|
|
6310
6584
|
// src/commands/read-logs/std-utils.ts
|
|
6311
|
-
import
|
|
6585
|
+
import fs23 from "fs";
|
|
6312
6586
|
function formatStdPrefixTime(localTime) {
|
|
6313
6587
|
const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
|
|
6314
6588
|
if (!match) return localTime;
|
|
@@ -6338,11 +6612,11 @@ function stripPrefixFromStdLine(line) {
|
|
|
6338
6612
|
return `[${time}] ${content}`;
|
|
6339
6613
|
}
|
|
6340
6614
|
function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
|
|
6341
|
-
const stat =
|
|
6615
|
+
const stat = fs23.statSync(filePath);
|
|
6342
6616
|
if (stat.size === 0) {
|
|
6343
6617
|
return { lines: [], markerFound: false, totalLinesCount: 0 };
|
|
6344
6618
|
}
|
|
6345
|
-
const fd =
|
|
6619
|
+
const fd = fs23.openSync(filePath, "r");
|
|
6346
6620
|
const chunkSize = 64 * 1024;
|
|
6347
6621
|
let position = stat.size;
|
|
6348
6622
|
let remainder = "";
|
|
@@ -6356,7 +6630,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
|
|
|
6356
6630
|
const length = Math.min(chunkSize, position);
|
|
6357
6631
|
position -= length;
|
|
6358
6632
|
const buffer = Buffer.alloc(length);
|
|
6359
|
-
|
|
6633
|
+
fs23.readSync(fd, buffer, 0, length, position);
|
|
6360
6634
|
let chunk = buffer.toString("utf8");
|
|
6361
6635
|
if (remainder) {
|
|
6362
6636
|
chunk += remainder;
|
|
@@ -6398,7 +6672,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
|
|
|
6398
6672
|
}
|
|
6399
6673
|
}
|
|
6400
6674
|
} finally {
|
|
6401
|
-
|
|
6675
|
+
fs23.closeSync(fd);
|
|
6402
6676
|
}
|
|
6403
6677
|
return { lines: collected.reverse(), markerFound, totalLinesCount };
|
|
6404
6678
|
}
|
|
@@ -6419,21 +6693,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
|
|
|
6419
6693
|
}
|
|
6420
6694
|
|
|
6421
6695
|
// src/commands/read-logs/tail.ts
|
|
6422
|
-
import
|
|
6696
|
+
import fs24 from "fs";
|
|
6423
6697
|
function fileExists(filePath) {
|
|
6424
6698
|
try {
|
|
6425
|
-
|
|
6699
|
+
fs24.accessSync(filePath, fs24.constants.F_OK | fs24.constants.R_OK);
|
|
6426
6700
|
return true;
|
|
6427
6701
|
} catch {
|
|
6428
6702
|
return false;
|
|
6429
6703
|
}
|
|
6430
6704
|
}
|
|
6431
6705
|
function readFileTailLines(filePath, maxLines) {
|
|
6432
|
-
const stat =
|
|
6706
|
+
const stat = fs24.statSync(filePath);
|
|
6433
6707
|
if (stat.size === 0) {
|
|
6434
6708
|
return [];
|
|
6435
6709
|
}
|
|
6436
|
-
const fd =
|
|
6710
|
+
const fd = fs24.openSync(filePath, "r");
|
|
6437
6711
|
const chunkSize = 64 * 1024;
|
|
6438
6712
|
const chunks = [];
|
|
6439
6713
|
let position = stat.size;
|
|
@@ -6443,13 +6717,13 @@ function readFileTailLines(filePath, maxLines) {
|
|
|
6443
6717
|
const length = Math.min(chunkSize, position);
|
|
6444
6718
|
position -= length;
|
|
6445
6719
|
const buffer = Buffer.alloc(length);
|
|
6446
|
-
|
|
6720
|
+
fs24.readSync(fd, buffer, 0, length, position);
|
|
6447
6721
|
chunks.unshift(buffer.toString("utf8"));
|
|
6448
6722
|
const chunkLines = buffer.toString("utf8").split("\n").length - 1;
|
|
6449
6723
|
collectedLines += chunkLines;
|
|
6450
6724
|
}
|
|
6451
6725
|
} finally {
|
|
6452
|
-
|
|
6726
|
+
fs24.closeSync(fd);
|
|
6453
6727
|
}
|
|
6454
6728
|
const content = chunks.join("");
|
|
6455
6729
|
const allLines = content.split("\n");
|
|
@@ -6465,11 +6739,11 @@ function readFileTailLines(filePath, maxLines) {
|
|
|
6465
6739
|
return allLines.slice(allLines.length - maxLines);
|
|
6466
6740
|
}
|
|
6467
6741
|
function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
6468
|
-
const stat =
|
|
6742
|
+
const stat = fs24.statSync(filePath);
|
|
6469
6743
|
if (stat.size === 0) {
|
|
6470
6744
|
return { lines: [], totalLinesCount: 0 };
|
|
6471
6745
|
}
|
|
6472
|
-
const fd =
|
|
6746
|
+
const fd = fs24.openSync(filePath, "r");
|
|
6473
6747
|
const chunkSize = 64 * 1024;
|
|
6474
6748
|
let position = stat.size;
|
|
6475
6749
|
let remainder = "";
|
|
@@ -6481,7 +6755,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
|
6481
6755
|
const length = Math.min(chunkSize, position);
|
|
6482
6756
|
position -= length;
|
|
6483
6757
|
const buffer = Buffer.alloc(length);
|
|
6484
|
-
|
|
6758
|
+
fs24.readSync(fd, buffer, 0, length, position);
|
|
6485
6759
|
let chunk = buffer.toString("utf8");
|
|
6486
6760
|
if (remainder) {
|
|
6487
6761
|
chunk += remainder;
|
|
@@ -6512,7 +6786,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
|
6512
6786
|
}
|
|
6513
6787
|
}
|
|
6514
6788
|
} finally {
|
|
6515
|
-
|
|
6789
|
+
fs24.closeSync(fd);
|
|
6516
6790
|
}
|
|
6517
6791
|
return { lines: collected.reverse(), totalLinesCount };
|
|
6518
6792
|
}
|
|
@@ -6654,7 +6928,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
|
|
|
6654
6928
|
}
|
|
6655
6929
|
|
|
6656
6930
|
// src/commands/read-logs/json-lines.ts
|
|
6657
|
-
import
|
|
6931
|
+
import fs25 from "fs";
|
|
6658
6932
|
function normalizePid(value) {
|
|
6659
6933
|
if (typeof value === "number") {
|
|
6660
6934
|
return String(value);
|
|
@@ -6705,11 +6979,11 @@ function buildWantedLevelSet(levels) {
|
|
|
6705
6979
|
return set.size > 0 ? set : null;
|
|
6706
6980
|
}
|
|
6707
6981
|
function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
6708
|
-
const stat =
|
|
6982
|
+
const stat = fs25.statSync(filePath);
|
|
6709
6983
|
if (stat.size === 0) {
|
|
6710
6984
|
return { lines: [], totalLinesCount: 0 };
|
|
6711
6985
|
}
|
|
6712
|
-
const fd =
|
|
6986
|
+
const fd = fs25.openSync(filePath, "r");
|
|
6713
6987
|
const chunkSize = 64 * 1024;
|
|
6714
6988
|
let position = stat.size;
|
|
6715
6989
|
let remainder = "";
|
|
@@ -6724,7 +6998,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
|
6724
6998
|
const length = Math.min(chunkSize, position);
|
|
6725
6999
|
position -= length;
|
|
6726
7000
|
const buffer = Buffer.alloc(length);
|
|
6727
|
-
|
|
7001
|
+
fs25.readSync(fd, buffer, 0, length, position);
|
|
6728
7002
|
let chunk = buffer.toString("utf8");
|
|
6729
7003
|
if (remainder) {
|
|
6730
7004
|
chunk += remainder;
|
|
@@ -6786,7 +7060,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
|
6786
7060
|
}
|
|
6787
7061
|
}
|
|
6788
7062
|
} finally {
|
|
6789
|
-
|
|
7063
|
+
fs25.closeSync(fd);
|
|
6790
7064
|
}
|
|
6791
7065
|
return { lines: collected.reverse(), totalLinesCount };
|
|
6792
7066
|
}
|
|
@@ -6829,11 +7103,11 @@ function extractTraceId(obj) {
|
|
|
6829
7103
|
function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
6830
7104
|
const wanted = traceId.trim();
|
|
6831
7105
|
if (!wanted) return { lines: [], totalLinesCount: 0 };
|
|
6832
|
-
const stat =
|
|
7106
|
+
const stat = fs25.statSync(filePath);
|
|
6833
7107
|
if (stat.size === 0) {
|
|
6834
7108
|
return { lines: [], totalLinesCount: 0 };
|
|
6835
7109
|
}
|
|
6836
|
-
const fd =
|
|
7110
|
+
const fd = fs25.openSync(filePath, "r");
|
|
6837
7111
|
const chunkSize = 64 * 1024;
|
|
6838
7112
|
let position = stat.size;
|
|
6839
7113
|
let remainder = "";
|
|
@@ -6846,7 +7120,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
|
6846
7120
|
const length = Math.min(chunkSize, position);
|
|
6847
7121
|
position -= length;
|
|
6848
7122
|
const buffer = Buffer.alloc(length);
|
|
6849
|
-
|
|
7123
|
+
fs25.readSync(fd, buffer, 0, length, position);
|
|
6850
7124
|
let chunk = buffer.toString("utf8");
|
|
6851
7125
|
if (remainder) {
|
|
6852
7126
|
chunk += remainder;
|
|
@@ -6899,7 +7173,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
|
6899
7173
|
}
|
|
6900
7174
|
}
|
|
6901
7175
|
} finally {
|
|
6902
|
-
|
|
7176
|
+
fs25.closeSync(fd);
|
|
6903
7177
|
}
|
|
6904
7178
|
return { lines: collected.reverse(), totalLinesCount };
|
|
6905
7179
|
}
|
|
@@ -6908,11 +7182,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
6908
7182
|
if (!wantedLevelSet) {
|
|
6909
7183
|
return { lines: [], totalLinesCount: 0 };
|
|
6910
7184
|
}
|
|
6911
|
-
const stat =
|
|
7185
|
+
const stat = fs25.statSync(filePath);
|
|
6912
7186
|
if (stat.size === 0) {
|
|
6913
7187
|
return { lines: [], totalLinesCount: 0 };
|
|
6914
7188
|
}
|
|
6915
|
-
const fd =
|
|
7189
|
+
const fd = fs25.openSync(filePath, "r");
|
|
6916
7190
|
const chunkSize = 64 * 1024;
|
|
6917
7191
|
let position = stat.size;
|
|
6918
7192
|
let remainder = "";
|
|
@@ -6924,7 +7198,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
6924
7198
|
const length = Math.min(chunkSize, position);
|
|
6925
7199
|
position -= length;
|
|
6926
7200
|
const buffer = Buffer.alloc(length);
|
|
6927
|
-
|
|
7201
|
+
fs25.readSync(fd, buffer, 0, length, position);
|
|
6928
7202
|
let chunk = buffer.toString("utf8");
|
|
6929
7203
|
if (remainder) {
|
|
6930
7204
|
chunk += remainder;
|
|
@@ -6971,7 +7245,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
6971
7245
|
}
|
|
6972
7246
|
}
|
|
6973
7247
|
} finally {
|
|
6974
|
-
|
|
7248
|
+
fs25.closeSync(fd);
|
|
6975
7249
|
}
|
|
6976
7250
|
return { lines: collected.reverse(), totalLinesCount };
|
|
6977
7251
|
}
|
|
@@ -7205,30 +7479,30 @@ async function readLogsJsonResult(options) {
|
|
|
7205
7479
|
};
|
|
7206
7480
|
}
|
|
7207
7481
|
function resolveLogFilePath(logDir, type) {
|
|
7208
|
-
const base =
|
|
7482
|
+
const base = path21.isAbsolute(logDir) ? logDir : path21.join(process.cwd(), logDir);
|
|
7209
7483
|
if (type === "server") {
|
|
7210
|
-
return
|
|
7484
|
+
return path21.join(base, "server.log");
|
|
7211
7485
|
}
|
|
7212
7486
|
if (type === "trace") {
|
|
7213
|
-
return
|
|
7487
|
+
return path21.join(base, "trace.log");
|
|
7214
7488
|
}
|
|
7215
7489
|
if (type === "server-std") {
|
|
7216
|
-
return
|
|
7490
|
+
return path21.join(base, "server.std.log");
|
|
7217
7491
|
}
|
|
7218
7492
|
if (type === "client-std") {
|
|
7219
|
-
return
|
|
7493
|
+
return path21.join(base, "client.std.log");
|
|
7220
7494
|
}
|
|
7221
7495
|
if (type === "dev") {
|
|
7222
|
-
return
|
|
7496
|
+
return path21.join(base, "dev.log");
|
|
7223
7497
|
}
|
|
7224
7498
|
if (type === "dev-std") {
|
|
7225
|
-
return
|
|
7499
|
+
return path21.join(base, "dev.std.log");
|
|
7226
7500
|
}
|
|
7227
7501
|
if (type === "install-dep-std") {
|
|
7228
|
-
return
|
|
7502
|
+
return path21.join(base, "install-dep.std.log");
|
|
7229
7503
|
}
|
|
7230
7504
|
if (type === "browser") {
|
|
7231
|
-
return
|
|
7505
|
+
return path21.join(base, "browser.log");
|
|
7232
7506
|
}
|
|
7233
7507
|
throw new Error(`Unsupported log type: ${type}`);
|
|
7234
7508
|
}
|
|
@@ -7405,9 +7679,9 @@ function camelToKebab(str) {
|
|
|
7405
7679
|
}
|
|
7406
7680
|
|
|
7407
7681
|
// src/commands/build/upload-static.handler.ts
|
|
7408
|
-
import * as
|
|
7682
|
+
import * as fs26 from "fs";
|
|
7409
7683
|
import * as os2 from "os";
|
|
7410
|
-
import * as
|
|
7684
|
+
import * as path22 from "path";
|
|
7411
7685
|
import { execFileSync } from "child_process";
|
|
7412
7686
|
function readCredentialsFromEnv() {
|
|
7413
7687
|
const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
|
|
@@ -7431,8 +7705,8 @@ async function uploadStatic(options) {
|
|
|
7431
7705
|
endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
|
|
7432
7706
|
region = UPLOAD_STATIC_DEFAULTS.region
|
|
7433
7707
|
} = options;
|
|
7434
|
-
const resolvedStaticDir =
|
|
7435
|
-
if (!
|
|
7708
|
+
const resolvedStaticDir = path22.resolve(staticDir);
|
|
7709
|
+
if (!fs26.existsSync(resolvedStaticDir)) {
|
|
7436
7710
|
console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
|
|
7437
7711
|
return;
|
|
7438
7712
|
}
|
|
@@ -7465,8 +7739,8 @@ async function uploadStatic(options) {
|
|
|
7465
7739
|
({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
|
|
7466
7740
|
}
|
|
7467
7741
|
console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
|
|
7468
|
-
const confPath =
|
|
7469
|
-
|
|
7742
|
+
const confPath = path22.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
|
|
7743
|
+
fs26.writeFileSync(confPath, "");
|
|
7470
7744
|
try {
|
|
7471
7745
|
console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
|
|
7472
7746
|
configureTosutil(resolvedTosutil, confPath, {
|
|
@@ -7480,7 +7754,7 @@ async function uploadStatic(options) {
|
|
|
7480
7754
|
uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
|
|
7481
7755
|
} finally {
|
|
7482
7756
|
try {
|
|
7483
|
-
|
|
7757
|
+
fs26.unlinkSync(confPath);
|
|
7484
7758
|
} catch {
|
|
7485
7759
|
}
|
|
7486
7760
|
}
|
|
@@ -7500,8 +7774,8 @@ async function uploadStatic(options) {
|
|
|
7500
7774
|
}
|
|
7501
7775
|
}
|
|
7502
7776
|
function resolveTosutilPath(tosutilPath) {
|
|
7503
|
-
if (
|
|
7504
|
-
return
|
|
7777
|
+
if (path22.isAbsolute(tosutilPath)) {
|
|
7778
|
+
return fs26.existsSync(tosutilPath) ? tosutilPath : null;
|
|
7505
7779
|
}
|
|
7506
7780
|
try {
|
|
7507
7781
|
const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
|
|
@@ -7546,7 +7820,7 @@ async function resolveBucketId(appId) {
|
|
|
7546
7820
|
return bucketId;
|
|
7547
7821
|
}
|
|
7548
7822
|
function isDirEmpty(dirPath) {
|
|
7549
|
-
const entries =
|
|
7823
|
+
const entries = fs26.readdirSync(dirPath);
|
|
7550
7824
|
return entries.length === 0;
|
|
7551
7825
|
}
|
|
7552
7826
|
|
|
@@ -7641,12 +7915,12 @@ var commands = [
|
|
|
7641
7915
|
];
|
|
7642
7916
|
|
|
7643
7917
|
// src/index.ts
|
|
7644
|
-
var envPath =
|
|
7645
|
-
if (
|
|
7918
|
+
var envPath = path23.join(process.cwd(), ".env");
|
|
7919
|
+
if (fs27.existsSync(envPath)) {
|
|
7646
7920
|
dotenvConfig({ path: envPath });
|
|
7647
7921
|
}
|
|
7648
|
-
var __dirname =
|
|
7649
|
-
var pkg = JSON.parse(
|
|
7922
|
+
var __dirname = path23.dirname(fileURLToPath5(import.meta.url));
|
|
7923
|
+
var pkg = JSON.parse(fs27.readFileSync(path23.join(__dirname, "../package.json"), "utf-8"));
|
|
7650
7924
|
var cli = new FullstackCLI(pkg.version);
|
|
7651
7925
|
cli.useAll(commands);
|
|
7652
7926
|
cli.run();
|