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