@lark-apaas/fullstack-cli 1.1.16-beta.14 → 1.1.16-beta.15
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 +441 -190
- package/package.json +2 -2
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
|
|
|
@@ -3107,6 +3107,167 @@ async function run3(options = {}) {
|
|
|
3107
3107
|
|
|
3108
3108
|
// src/commands/upgrade/deps/run.handler.ts
|
|
3109
3109
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
3110
|
+
import fs10 from "fs";
|
|
3111
|
+
import path8 from "path";
|
|
3112
|
+
|
|
3113
|
+
// src/utils/grayscale/config.ts
|
|
3114
|
+
function getGrayscaleConfig(configJson) {
|
|
3115
|
+
if (!configJson) {
|
|
3116
|
+
return null;
|
|
3117
|
+
}
|
|
3118
|
+
try {
|
|
3119
|
+
const parsed = JSON.parse(configJson);
|
|
3120
|
+
const config = parsed.config;
|
|
3121
|
+
if (!config || !config.enabled) {
|
|
3122
|
+
return null;
|
|
3123
|
+
}
|
|
3124
|
+
return {
|
|
3125
|
+
config,
|
|
3126
|
+
tenantId: parsed.tenant_id != null ? String(parsed.tenant_id) : void 0,
|
|
3127
|
+
appId: parsed.app_id || void 0,
|
|
3128
|
+
xTtEnv: parsed.x_tt_env || void 0
|
|
3129
|
+
};
|
|
3130
|
+
} catch {
|
|
3131
|
+
console.warn("[grayscale] Failed to parse grayscale config");
|
|
3132
|
+
return null;
|
|
3133
|
+
}
|
|
3134
|
+
}
|
|
3135
|
+
|
|
3136
|
+
// src/utils/grayscale/identity.ts
|
|
3137
|
+
function readProjectIdentity() {
|
|
3138
|
+
return {
|
|
3139
|
+
appId: process.env.app_id || process.env.APP_ID,
|
|
3140
|
+
tenantId: process.env.tenant_id || process.env.TENANT_ID,
|
|
3141
|
+
xTtEnv: process.env.FORCE_FRAMEWORK_CLI_CANARY_ENV || process.env.x_tt_env
|
|
3142
|
+
};
|
|
3143
|
+
}
|
|
3144
|
+
|
|
3145
|
+
// src/utils/grayscale/types.ts
|
|
3146
|
+
var RuleType = {
|
|
3147
|
+
TenantID: "tenant_id",
|
|
3148
|
+
AppID: "app_id",
|
|
3149
|
+
Canary: "canary",
|
|
3150
|
+
Percentage: "percentage"
|
|
3151
|
+
};
|
|
3152
|
+
|
|
3153
|
+
// src/utils/grayscale/rules.ts
|
|
3154
|
+
var RULE_PRIORITY = {
|
|
3155
|
+
[RuleType.Canary]: 0,
|
|
3156
|
+
[RuleType.AppID]: 1,
|
|
3157
|
+
[RuleType.TenantID]: 2,
|
|
3158
|
+
[RuleType.Percentage]: 3
|
|
3159
|
+
};
|
|
3160
|
+
function sortRulesByPriority(rules) {
|
|
3161
|
+
return [...rules].sort((a, b) => (RULE_PRIORITY[a.type] ?? 99) - (RULE_PRIORITY[b.type] ?? 99));
|
|
3162
|
+
}
|
|
3163
|
+
function isInPercentage(tenantId, percentage) {
|
|
3164
|
+
if (percentage <= 0) return false;
|
|
3165
|
+
if (percentage >= 100) return true;
|
|
3166
|
+
const id = parseInt(tenantId, 10);
|
|
3167
|
+
if (isNaN(id)) return false;
|
|
3168
|
+
return id % 100 < percentage;
|
|
3169
|
+
}
|
|
3170
|
+
function matchRule(rule, identity) {
|
|
3171
|
+
switch (rule.type) {
|
|
3172
|
+
case RuleType.TenantID:
|
|
3173
|
+
return !!identity.tenantId && !!rule.values && rule.values.includes(identity.tenantId);
|
|
3174
|
+
case RuleType.AppID:
|
|
3175
|
+
return !!identity.appId && !!rule.values && rule.values.includes(identity.appId);
|
|
3176
|
+
case RuleType.Canary:
|
|
3177
|
+
return identity.xTtEnv === rule.value;
|
|
3178
|
+
case RuleType.Percentage:
|
|
3179
|
+
if (rule.value >= 100) return true;
|
|
3180
|
+
if (rule.value <= 0) return false;
|
|
3181
|
+
if (!identity.tenantId) return false;
|
|
3182
|
+
return isInPercentage(identity.tenantId, rule.value);
|
|
3183
|
+
default:
|
|
3184
|
+
return false;
|
|
3185
|
+
}
|
|
3186
|
+
}
|
|
3187
|
+
function isBlocked(channel, identity) {
|
|
3188
|
+
if (!channel.block_rules || channel.block_rules.length === 0) return false;
|
|
3189
|
+
return sortRulesByPriority(channel.block_rules).some((rule) => matchRule(rule, identity));
|
|
3190
|
+
}
|
|
3191
|
+
function matchChannel(channel, identity) {
|
|
3192
|
+
if (isBlocked(channel, identity)) return false;
|
|
3193
|
+
if (!channel.rules || channel.rules.length === 0) return false;
|
|
3194
|
+
return sortRulesByPriority(channel.rules).some((rule) => matchRule(rule, identity));
|
|
3195
|
+
}
|
|
3196
|
+
function resolveTargetVersions(config, identity) {
|
|
3197
|
+
const stableVersions = config.stable?.versions || {};
|
|
3198
|
+
const matchedChannel = (config.channels || []).find((ch) => matchChannel(ch, identity));
|
|
3199
|
+
const merged = /* @__PURE__ */ new Map();
|
|
3200
|
+
for (const [pkg2, version] of Object.entries(stableVersions)) {
|
|
3201
|
+
merged.set(pkg2, version);
|
|
3202
|
+
}
|
|
3203
|
+
if (matchedChannel) {
|
|
3204
|
+
console.log(`[grayscale] Matched channel: ${matchedChannel.name}`);
|
|
3205
|
+
for (const [pkg2, version] of Object.entries(matchedChannel.versions || {})) {
|
|
3206
|
+
merged.set(pkg2, version);
|
|
3207
|
+
}
|
|
3208
|
+
} else {
|
|
3209
|
+
console.log("[grayscale] No channel matched, use stable");
|
|
3210
|
+
}
|
|
3211
|
+
return merged.size > 0 ? merged : null;
|
|
3212
|
+
}
|
|
3213
|
+
|
|
3214
|
+
// src/utils/grayscale/index.ts
|
|
3215
|
+
function resolveGrayscaleVersions(_cwd, configJson) {
|
|
3216
|
+
const result = getGrayscaleConfig(configJson);
|
|
3217
|
+
if (!result) {
|
|
3218
|
+
console.log("[grayscale] Config not available, skipping grayscale");
|
|
3219
|
+
return null;
|
|
3220
|
+
}
|
|
3221
|
+
const { config, tenantId: payloadTenantId, appId: payloadAppId, xTtEnv: payloadXTtEnv } = result;
|
|
3222
|
+
const envIdentity = readProjectIdentity();
|
|
3223
|
+
const identity = {
|
|
3224
|
+
appId: payloadAppId || envIdentity.appId,
|
|
3225
|
+
tenantId: payloadTenantId || envIdentity.tenantId,
|
|
3226
|
+
xTtEnv: payloadXTtEnv || envIdentity.xTtEnv
|
|
3227
|
+
};
|
|
3228
|
+
console.log(
|
|
3229
|
+
`[grayscale] Project identity: appId=${identity.appId || "N/A"}, tenantId=${identity.tenantId || "N/A"}, xTtEnv=${identity.xTtEnv || "N/A"}`
|
|
3230
|
+
);
|
|
3231
|
+
const versions = resolveTargetVersions(config, identity);
|
|
3232
|
+
if (!versions || versions.size === 0) {
|
|
3233
|
+
console.log("[grayscale] No target versions resolved");
|
|
3234
|
+
return null;
|
|
3235
|
+
}
|
|
3236
|
+
console.log(`[grayscale] Resolved ${versions.size} package version(s):`);
|
|
3237
|
+
for (const [pkg2, ver] of versions) {
|
|
3238
|
+
console.log(`[grayscale] ${pkg2} -> ${ver}`);
|
|
3239
|
+
}
|
|
3240
|
+
return versions;
|
|
3241
|
+
}
|
|
3242
|
+
|
|
3243
|
+
// src/commands/upgrade/deps/run.handler.ts
|
|
3244
|
+
function parseSemver(version) {
|
|
3245
|
+
const match = version.match(/^(\d+)\.(\d+)\.(\d+)/);
|
|
3246
|
+
if (!match) return null;
|
|
3247
|
+
return [parseInt(match[1], 10), parseInt(match[2], 10), parseInt(match[3], 10)];
|
|
3248
|
+
}
|
|
3249
|
+
function compareSemver(a, b) {
|
|
3250
|
+
const va = parseSemver(a);
|
|
3251
|
+
const vb = parseSemver(b);
|
|
3252
|
+
if (!va || !vb) return 0;
|
|
3253
|
+
for (let i = 0; i < 3; i++) {
|
|
3254
|
+
if (va[i] < vb[i]) return -1;
|
|
3255
|
+
if (va[i] > vb[i]) return 1;
|
|
3256
|
+
}
|
|
3257
|
+
return 0;
|
|
3258
|
+
}
|
|
3259
|
+
function satisfiesCaret(installed, range) {
|
|
3260
|
+
const baseVersion = range.slice(1);
|
|
3261
|
+
const base = parseSemver(baseVersion);
|
|
3262
|
+
const inst = parseSemver(installed);
|
|
3263
|
+
if (!base || !inst) return false;
|
|
3264
|
+
if (compareSemver(installed, baseVersion) < 0) return false;
|
|
3265
|
+
if (inst[0] > base[0]) return false;
|
|
3266
|
+
return true;
|
|
3267
|
+
}
|
|
3268
|
+
function isRangeVersion(version) {
|
|
3269
|
+
return version.startsWith("^");
|
|
3270
|
+
}
|
|
3110
3271
|
function findLarkAapaasPackages(cwd, filterPackages) {
|
|
3111
3272
|
const pkg2 = readPackageJson(cwd);
|
|
3112
3273
|
const allPackages = /* @__PURE__ */ new Set();
|
|
@@ -3159,11 +3320,70 @@ function upgradePackages(packages, version, cwd) {
|
|
|
3159
3320
|
});
|
|
3160
3321
|
}
|
|
3161
3322
|
}
|
|
3323
|
+
function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode) {
|
|
3324
|
+
const upgradePlan = [];
|
|
3325
|
+
for (const pkg2 of packages) {
|
|
3326
|
+
const version = grayscaleVersions.get(pkg2);
|
|
3327
|
+
if (version) {
|
|
3328
|
+
let current = "";
|
|
3329
|
+
try {
|
|
3330
|
+
const installedPkgPath = path8.join(cwd, "node_modules", pkg2, "package.json");
|
|
3331
|
+
const installedPkg = JSON.parse(fs10.readFileSync(installedPkgPath, "utf-8"));
|
|
3332
|
+
current = installedPkg.version || "";
|
|
3333
|
+
} catch (err) {
|
|
3334
|
+
const code = err?.code;
|
|
3335
|
+
if (code !== "ENOENT") {
|
|
3336
|
+
console.warn(`[fullstack-cli] Failed to read installed version of ${pkg2}: ${err instanceof Error ? err.message : String(err)}`);
|
|
3337
|
+
}
|
|
3338
|
+
}
|
|
3339
|
+
if (mode === "destroy") {
|
|
3340
|
+
if (!isRangeVersion(version) && current === version) {
|
|
3341
|
+
console.log(`[fullstack-cli] ${pkg2}@${version} (already installed, skip)`);
|
|
3342
|
+
continue;
|
|
3343
|
+
}
|
|
3344
|
+
} else {
|
|
3345
|
+
if (isRangeVersion(version)) {
|
|
3346
|
+
if (current && satisfiesCaret(current, version)) {
|
|
3347
|
+
console.log(`[fullstack-cli] ${pkg2}@${current} satisfies ${version} (skip)`);
|
|
3348
|
+
continue;
|
|
3349
|
+
}
|
|
3350
|
+
} else {
|
|
3351
|
+
if (current === version) {
|
|
3352
|
+
console.log(`[fullstack-cli] ${pkg2}@${version} (already installed, skip)`);
|
|
3353
|
+
continue;
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
}
|
|
3357
|
+
upgradePlan.push({ pkg: pkg2, version, current });
|
|
3358
|
+
}
|
|
3359
|
+
}
|
|
3360
|
+
if (upgradePlan.length === 0) {
|
|
3361
|
+
console.log("[fullstack-cli] No grayscale versions matched current packages");
|
|
3362
|
+
return;
|
|
3363
|
+
}
|
|
3364
|
+
console.log(`[fullstack-cli] Grayscale upgrade plan (${upgradePlan.length} package(s)):`);
|
|
3365
|
+
upgradePlan.forEach(({ pkg: pkg2, version, current }) => {
|
|
3366
|
+
console.log(` - ${pkg2} ${current} -> ${version}`);
|
|
3367
|
+
});
|
|
3368
|
+
if (dryRun) {
|
|
3369
|
+
console.log("[fullstack-cli] Dry run mode, skipping actual installation");
|
|
3370
|
+
return;
|
|
3371
|
+
}
|
|
3372
|
+
const targets = upgradePlan.map(({ pkg: pkg2, version }) => `${pkg2}@${version}`);
|
|
3373
|
+
console.log(`[fullstack-cli] Installing ${targets.join(" ")}...`);
|
|
3374
|
+
const result = spawnSync3("npm", ["install", ...targets], {
|
|
3375
|
+
cwd,
|
|
3376
|
+
stdio: "inherit"
|
|
3377
|
+
});
|
|
3378
|
+
if (result.error || result.status !== 0) {
|
|
3379
|
+
console.warn(`[fullstack-cli] npm install failed: ${result.error?.message ?? `exit ${result.status}`}`);
|
|
3380
|
+
}
|
|
3381
|
+
}
|
|
3162
3382
|
async function run4(options = {}) {
|
|
3163
3383
|
const cwd = process.env.INIT_CWD || process.cwd();
|
|
3164
3384
|
console.log("[fullstack-cli] Starting dependencies upgrade...");
|
|
3165
3385
|
try {
|
|
3166
|
-
console.log("[fullstack-cli] Step 1/
|
|
3386
|
+
console.log("[fullstack-cli] Step 1/3: Scanning @lark-apaas dependencies...");
|
|
3167
3387
|
const packages = findLarkAapaasPackages(cwd, options.packages);
|
|
3168
3388
|
if (packages.length === 0) {
|
|
3169
3389
|
console.log("[fullstack-cli] No @lark-apaas packages found");
|
|
@@ -3171,7 +3391,38 @@ async function run4(options = {}) {
|
|
|
3171
3391
|
}
|
|
3172
3392
|
console.log(`[fullstack-cli] Found ${packages.length} @lark-apaas package(s):`);
|
|
3173
3393
|
packages.forEach((p) => console.log(` - ${p}`));
|
|
3174
|
-
|
|
3394
|
+
if (options.skipGrayscale) {
|
|
3395
|
+
console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (--skip-grayscale)");
|
|
3396
|
+
} else if (options.version) {
|
|
3397
|
+
console.log("[fullstack-cli] Step 2/3: Skipping grayscale check (explicit --version provided)");
|
|
3398
|
+
} else if (!options.grayscaleConfig) {
|
|
3399
|
+
console.log("[fullstack-cli] Step 2/3: No grayscale config, falling back to default upgrade");
|
|
3400
|
+
} else {
|
|
3401
|
+
console.log("[fullstack-cli] Step 2/3: Checking grayscale config...");
|
|
3402
|
+
try {
|
|
3403
|
+
const grayscaleVersions = resolveGrayscaleVersions(cwd, options.grayscaleConfig);
|
|
3404
|
+
if (grayscaleVersions) {
|
|
3405
|
+
console.log("[fullstack-cli] Step 3/3: Applying grayscale versions...");
|
|
3406
|
+
installGrayscaleVersions(packages, grayscaleVersions, cwd, !!options.dryRun, options.mode || "rebuild");
|
|
3407
|
+
if (!options.dryRun) {
|
|
3408
|
+
console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s) via grayscale`);
|
|
3409
|
+
console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
|
|
3410
|
+
}
|
|
3411
|
+
} else {
|
|
3412
|
+
console.log("[fullstack-cli] Grayscale config provided but not available, skip upgrade");
|
|
3413
|
+
}
|
|
3414
|
+
} catch (error) {
|
|
3415
|
+
const msg = error instanceof Error ? error.message : String(error);
|
|
3416
|
+
console.warn(`[fullstack-cli] Grayscale check failed: ${msg}, skip upgrade`);
|
|
3417
|
+
}
|
|
3418
|
+
return;
|
|
3419
|
+
}
|
|
3420
|
+
if (options.dryRun) {
|
|
3421
|
+
console.log("[fullstack-cli] Dry run mode: would upgrade via npm update (no grayscale)");
|
|
3422
|
+
packages.forEach((p) => console.log(` - ${p} -> ${options.version || "latest compatible"}`));
|
|
3423
|
+
return;
|
|
3424
|
+
}
|
|
3425
|
+
console.log("[fullstack-cli] Step 3/3: Upgrading packages...");
|
|
3175
3426
|
upgradePackages(packages, options.version, cwd);
|
|
3176
3427
|
console.log(`[fullstack-cli] \u2713 Successfully upgraded ${packages.length} package(s)`);
|
|
3177
3428
|
console.log("[fullstack-cli] Dependencies upgrade completed successfully \u2705");
|
|
@@ -3187,7 +3438,7 @@ var depsCommand = {
|
|
|
3187
3438
|
name: "deps",
|
|
3188
3439
|
description: "Upgrade @lark-apaas dependencies",
|
|
3189
3440
|
register(parentCommand) {
|
|
3190
|
-
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) => {
|
|
3441
|
+
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("--grayscale-config <json>", "Grayscale config JSON (injected by sandbox_console)").option("--dry-run", "Show upgrade plan without executing").option("--mode <mode>", "Execution mode: rebuild (default) or destroy", "rebuild").action(async (options) => {
|
|
3191
3442
|
await run4(options);
|
|
3192
3443
|
});
|
|
3193
3444
|
}
|
|
@@ -3206,8 +3457,8 @@ var upgradeCommand = {
|
|
|
3206
3457
|
};
|
|
3207
3458
|
|
|
3208
3459
|
// src/commands/action-plugin/utils.ts
|
|
3209
|
-
import
|
|
3210
|
-
import
|
|
3460
|
+
import fs11 from "fs";
|
|
3461
|
+
import path9 from "path";
|
|
3211
3462
|
import { spawnSync as spawnSync4, execSync as execSync2 } from "child_process";
|
|
3212
3463
|
function parsePluginName(input) {
|
|
3213
3464
|
const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
|
|
@@ -3225,18 +3476,18 @@ function getProjectRoot() {
|
|
|
3225
3476
|
return process.cwd();
|
|
3226
3477
|
}
|
|
3227
3478
|
function getPackageJsonPath() {
|
|
3228
|
-
return
|
|
3479
|
+
return path9.join(getProjectRoot(), "package.json");
|
|
3229
3480
|
}
|
|
3230
3481
|
function getPluginPath(pluginName) {
|
|
3231
|
-
return
|
|
3482
|
+
return path9.join(getProjectRoot(), "node_modules", pluginName);
|
|
3232
3483
|
}
|
|
3233
3484
|
function readPackageJson2() {
|
|
3234
3485
|
const pkgPath = getPackageJsonPath();
|
|
3235
|
-
if (!
|
|
3486
|
+
if (!fs11.existsSync(pkgPath)) {
|
|
3236
3487
|
throw new Error("package.json not found in current directory");
|
|
3237
3488
|
}
|
|
3238
3489
|
try {
|
|
3239
|
-
const content =
|
|
3490
|
+
const content = fs11.readFileSync(pkgPath, "utf-8");
|
|
3240
3491
|
return JSON.parse(content);
|
|
3241
3492
|
} catch {
|
|
3242
3493
|
throw new Error("Failed to parse package.json");
|
|
@@ -3244,7 +3495,7 @@ function readPackageJson2() {
|
|
|
3244
3495
|
}
|
|
3245
3496
|
function writePackageJson2(pkg2) {
|
|
3246
3497
|
const pkgPath = getPackageJsonPath();
|
|
3247
|
-
|
|
3498
|
+
fs11.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
|
|
3248
3499
|
}
|
|
3249
3500
|
function readActionPlugins() {
|
|
3250
3501
|
const pkg2 = readPackageJson2();
|
|
@@ -3277,12 +3528,12 @@ function npmInstall(tgzPath) {
|
|
|
3277
3528
|
}
|
|
3278
3529
|
}
|
|
3279
3530
|
function getPackageVersion(pluginName) {
|
|
3280
|
-
const pkgJsonPath =
|
|
3281
|
-
if (!
|
|
3531
|
+
const pkgJsonPath = path9.join(getPluginPath(pluginName), "package.json");
|
|
3532
|
+
if (!fs11.existsSync(pkgJsonPath)) {
|
|
3282
3533
|
return null;
|
|
3283
3534
|
}
|
|
3284
3535
|
try {
|
|
3285
|
-
const content =
|
|
3536
|
+
const content = fs11.readFileSync(pkgJsonPath, "utf-8");
|
|
3286
3537
|
const pkg2 = JSON.parse(content);
|
|
3287
3538
|
return pkg2.version || null;
|
|
3288
3539
|
} catch {
|
|
@@ -3290,49 +3541,49 @@ function getPackageVersion(pluginName) {
|
|
|
3290
3541
|
}
|
|
3291
3542
|
}
|
|
3292
3543
|
function readPluginPackageJson(pluginPath) {
|
|
3293
|
-
const pkgJsonPath =
|
|
3294
|
-
if (!
|
|
3544
|
+
const pkgJsonPath = path9.join(pluginPath, "package.json");
|
|
3545
|
+
if (!fs11.existsSync(pkgJsonPath)) {
|
|
3295
3546
|
return null;
|
|
3296
3547
|
}
|
|
3297
3548
|
try {
|
|
3298
|
-
const content =
|
|
3549
|
+
const content = fs11.readFileSync(pkgJsonPath, "utf-8");
|
|
3299
3550
|
return JSON.parse(content);
|
|
3300
3551
|
} catch {
|
|
3301
3552
|
return null;
|
|
3302
3553
|
}
|
|
3303
3554
|
}
|
|
3304
3555
|
function extractTgzToNodeModules(tgzPath, pluginName) {
|
|
3305
|
-
const nodeModulesPath =
|
|
3306
|
-
const targetDir =
|
|
3307
|
-
const scopeDir =
|
|
3308
|
-
if (!
|
|
3309
|
-
|
|
3556
|
+
const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
|
|
3557
|
+
const targetDir = path9.join(nodeModulesPath, pluginName);
|
|
3558
|
+
const scopeDir = path9.dirname(targetDir);
|
|
3559
|
+
if (!fs11.existsSync(scopeDir)) {
|
|
3560
|
+
fs11.mkdirSync(scopeDir, { recursive: true });
|
|
3310
3561
|
}
|
|
3311
|
-
if (
|
|
3312
|
-
|
|
3562
|
+
if (fs11.existsSync(targetDir)) {
|
|
3563
|
+
fs11.rmSync(targetDir, { recursive: true });
|
|
3313
3564
|
}
|
|
3314
|
-
const tempDir =
|
|
3315
|
-
if (
|
|
3316
|
-
|
|
3565
|
+
const tempDir = path9.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
|
|
3566
|
+
if (fs11.existsSync(tempDir)) {
|
|
3567
|
+
fs11.rmSync(tempDir, { recursive: true });
|
|
3317
3568
|
}
|
|
3318
|
-
|
|
3569
|
+
fs11.mkdirSync(tempDir, { recursive: true });
|
|
3319
3570
|
try {
|
|
3320
3571
|
execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
|
|
3321
|
-
const extractedDir =
|
|
3322
|
-
if (
|
|
3323
|
-
|
|
3572
|
+
const extractedDir = path9.join(tempDir, "package");
|
|
3573
|
+
if (fs11.existsSync(extractedDir)) {
|
|
3574
|
+
fs11.renameSync(extractedDir, targetDir);
|
|
3324
3575
|
} else {
|
|
3325
|
-
const files =
|
|
3576
|
+
const files = fs11.readdirSync(tempDir);
|
|
3326
3577
|
if (files.length === 1) {
|
|
3327
|
-
|
|
3578
|
+
fs11.renameSync(path9.join(tempDir, files[0]), targetDir);
|
|
3328
3579
|
} else {
|
|
3329
3580
|
throw new Error("Unexpected tgz structure");
|
|
3330
3581
|
}
|
|
3331
3582
|
}
|
|
3332
3583
|
return targetDir;
|
|
3333
3584
|
} finally {
|
|
3334
|
-
if (
|
|
3335
|
-
|
|
3585
|
+
if (fs11.existsSync(tempDir)) {
|
|
3586
|
+
fs11.rmSync(tempDir, { recursive: true });
|
|
3336
3587
|
}
|
|
3337
3588
|
}
|
|
3338
3589
|
}
|
|
@@ -3341,10 +3592,10 @@ function checkMissingPeerDeps(peerDeps) {
|
|
|
3341
3592
|
return [];
|
|
3342
3593
|
}
|
|
3343
3594
|
const missing = [];
|
|
3344
|
-
const nodeModulesPath =
|
|
3595
|
+
const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
|
|
3345
3596
|
for (const [depName, _version] of Object.entries(peerDeps)) {
|
|
3346
|
-
const depPath =
|
|
3347
|
-
if (!
|
|
3597
|
+
const depPath = path9.join(nodeModulesPath, depName);
|
|
3598
|
+
if (!fs11.existsSync(depPath)) {
|
|
3348
3599
|
missing.push(depName);
|
|
3349
3600
|
}
|
|
3350
3601
|
}
|
|
@@ -3368,16 +3619,16 @@ function installMissingDeps(deps) {
|
|
|
3368
3619
|
}
|
|
3369
3620
|
function removePluginDirectory(pluginName) {
|
|
3370
3621
|
const pluginPath = getPluginPath(pluginName);
|
|
3371
|
-
if (
|
|
3372
|
-
|
|
3622
|
+
if (fs11.existsSync(pluginPath)) {
|
|
3623
|
+
fs11.rmSync(pluginPath, { recursive: true });
|
|
3373
3624
|
console.log(`[action-plugin] Removed ${pluginName}`);
|
|
3374
3625
|
}
|
|
3375
3626
|
}
|
|
3376
3627
|
|
|
3377
3628
|
// src/commands/action-plugin/api-client.ts
|
|
3378
3629
|
import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
|
|
3379
|
-
import
|
|
3380
|
-
import
|
|
3630
|
+
import fs12 from "fs";
|
|
3631
|
+
import path10 from "path";
|
|
3381
3632
|
var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
|
|
3382
3633
|
async function getPluginVersions(keys, latestOnly = true) {
|
|
3383
3634
|
const client = getHttpClient();
|
|
@@ -3441,19 +3692,19 @@ async function downloadFromPublic(downloadURL) {
|
|
|
3441
3692
|
return Buffer.from(arrayBuffer);
|
|
3442
3693
|
}
|
|
3443
3694
|
function getPluginCacheDir() {
|
|
3444
|
-
return
|
|
3695
|
+
return path10.join(process.cwd(), PLUGIN_CACHE_DIR);
|
|
3445
3696
|
}
|
|
3446
3697
|
function ensureCacheDir() {
|
|
3447
3698
|
const cacheDir = getPluginCacheDir();
|
|
3448
|
-
if (!
|
|
3449
|
-
|
|
3699
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3700
|
+
fs12.mkdirSync(cacheDir, { recursive: true });
|
|
3450
3701
|
}
|
|
3451
3702
|
}
|
|
3452
3703
|
function getTempFilePath(pluginKey, version) {
|
|
3453
3704
|
ensureCacheDir();
|
|
3454
3705
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
3455
3706
|
const filename = `${safeKey}@${version}.tgz`;
|
|
3456
|
-
return
|
|
3707
|
+
return path10.join(getPluginCacheDir(), filename);
|
|
3457
3708
|
}
|
|
3458
3709
|
var MAX_RETRIES = 2;
|
|
3459
3710
|
async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
|
|
@@ -3490,7 +3741,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
|
|
|
3490
3741
|
);
|
|
3491
3742
|
}
|
|
3492
3743
|
const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
|
|
3493
|
-
|
|
3744
|
+
fs12.writeFileSync(tgzPath, tgzBuffer);
|
|
3494
3745
|
console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
|
|
3495
3746
|
return {
|
|
3496
3747
|
tgzPath,
|
|
@@ -3504,18 +3755,18 @@ function getCachePath(pluginKey, version) {
|
|
|
3504
3755
|
ensureCacheDir();
|
|
3505
3756
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
3506
3757
|
const filename = `${safeKey}@${version}.tgz`;
|
|
3507
|
-
return
|
|
3758
|
+
return path10.join(getPluginCacheDir(), filename);
|
|
3508
3759
|
}
|
|
3509
3760
|
function hasCachedPlugin(pluginKey, version) {
|
|
3510
3761
|
const cachePath = getCachePath(pluginKey, version);
|
|
3511
|
-
return
|
|
3762
|
+
return fs12.existsSync(cachePath);
|
|
3512
3763
|
}
|
|
3513
3764
|
function listCachedPlugins() {
|
|
3514
3765
|
const cacheDir = getPluginCacheDir();
|
|
3515
|
-
if (!
|
|
3766
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3516
3767
|
return [];
|
|
3517
3768
|
}
|
|
3518
|
-
const files =
|
|
3769
|
+
const files = fs12.readdirSync(cacheDir);
|
|
3519
3770
|
const result = [];
|
|
3520
3771
|
for (const file of files) {
|
|
3521
3772
|
if (!file.endsWith(".tgz")) continue;
|
|
@@ -3523,8 +3774,8 @@ function listCachedPlugins() {
|
|
|
3523
3774
|
if (!match) continue;
|
|
3524
3775
|
const [, rawName, version] = match;
|
|
3525
3776
|
const name = rawName.replace(/^_/, "@").replace(/_/, "/");
|
|
3526
|
-
const filePath =
|
|
3527
|
-
const stat =
|
|
3777
|
+
const filePath = path10.join(cacheDir, file);
|
|
3778
|
+
const stat = fs12.statSync(filePath);
|
|
3528
3779
|
result.push({
|
|
3529
3780
|
name,
|
|
3530
3781
|
version,
|
|
@@ -3537,14 +3788,14 @@ function listCachedPlugins() {
|
|
|
3537
3788
|
}
|
|
3538
3789
|
function cleanAllCache() {
|
|
3539
3790
|
const cacheDir = getPluginCacheDir();
|
|
3540
|
-
if (!
|
|
3791
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3541
3792
|
return 0;
|
|
3542
3793
|
}
|
|
3543
|
-
const files =
|
|
3794
|
+
const files = fs12.readdirSync(cacheDir);
|
|
3544
3795
|
let count = 0;
|
|
3545
3796
|
for (const file of files) {
|
|
3546
3797
|
if (file.endsWith(".tgz")) {
|
|
3547
|
-
|
|
3798
|
+
fs12.unlinkSync(path10.join(cacheDir, file));
|
|
3548
3799
|
count++;
|
|
3549
3800
|
}
|
|
3550
3801
|
}
|
|
@@ -3552,21 +3803,21 @@ function cleanAllCache() {
|
|
|
3552
3803
|
}
|
|
3553
3804
|
function cleanPluginCache(pluginKey, version) {
|
|
3554
3805
|
const cacheDir = getPluginCacheDir();
|
|
3555
|
-
if (!
|
|
3806
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3556
3807
|
return 0;
|
|
3557
3808
|
}
|
|
3558
3809
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
3559
|
-
const files =
|
|
3810
|
+
const files = fs12.readdirSync(cacheDir);
|
|
3560
3811
|
let count = 0;
|
|
3561
3812
|
for (const file of files) {
|
|
3562
3813
|
if (version) {
|
|
3563
3814
|
if (file === `${safeKey}@${version}.tgz`) {
|
|
3564
|
-
|
|
3815
|
+
fs12.unlinkSync(path10.join(cacheDir, file));
|
|
3565
3816
|
count++;
|
|
3566
3817
|
}
|
|
3567
3818
|
} else {
|
|
3568
3819
|
if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
|
|
3569
|
-
|
|
3820
|
+
fs12.unlinkSync(path10.join(cacheDir, file));
|
|
3570
3821
|
count++;
|
|
3571
3822
|
}
|
|
3572
3823
|
}
|
|
@@ -3993,40 +4244,40 @@ var actionPluginCommandGroup = {
|
|
|
3993
4244
|
};
|
|
3994
4245
|
|
|
3995
4246
|
// src/commands/capability/utils.ts
|
|
3996
|
-
import
|
|
4247
|
+
import fs13 from "fs";
|
|
3997
4248
|
import { createRequire as createRequire2 } from "module";
|
|
3998
|
-
import
|
|
4249
|
+
import path11 from "path";
|
|
3999
4250
|
var CAPABILITIES_DIR = "server/capabilities";
|
|
4000
4251
|
function getProjectRoot2() {
|
|
4001
4252
|
return process.cwd();
|
|
4002
4253
|
}
|
|
4003
4254
|
function getCapabilitiesDir() {
|
|
4004
|
-
return
|
|
4255
|
+
return path11.join(getProjectRoot2(), CAPABILITIES_DIR);
|
|
4005
4256
|
}
|
|
4006
4257
|
function getCapabilityPath(id) {
|
|
4007
|
-
return
|
|
4258
|
+
return path11.join(getCapabilitiesDir(), `${id}.json`);
|
|
4008
4259
|
}
|
|
4009
4260
|
function getPluginManifestPath(pluginKey) {
|
|
4010
|
-
return
|
|
4261
|
+
return path11.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
|
|
4011
4262
|
}
|
|
4012
4263
|
function capabilitiesDirExists() {
|
|
4013
|
-
return
|
|
4264
|
+
return fs13.existsSync(getCapabilitiesDir());
|
|
4014
4265
|
}
|
|
4015
4266
|
function listCapabilityIds() {
|
|
4016
4267
|
const dir = getCapabilitiesDir();
|
|
4017
|
-
if (!
|
|
4268
|
+
if (!fs13.existsSync(dir)) {
|
|
4018
4269
|
return [];
|
|
4019
4270
|
}
|
|
4020
|
-
const files =
|
|
4271
|
+
const files = fs13.readdirSync(dir);
|
|
4021
4272
|
return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
|
|
4022
4273
|
}
|
|
4023
4274
|
function readCapability(id) {
|
|
4024
4275
|
const filePath = getCapabilityPath(id);
|
|
4025
|
-
if (!
|
|
4276
|
+
if (!fs13.existsSync(filePath)) {
|
|
4026
4277
|
throw new Error(`Capability not found: ${id}`);
|
|
4027
4278
|
}
|
|
4028
4279
|
try {
|
|
4029
|
-
const content =
|
|
4280
|
+
const content = fs13.readFileSync(filePath, "utf-8");
|
|
4030
4281
|
return JSON.parse(content);
|
|
4031
4282
|
} catch (error) {
|
|
4032
4283
|
if (error instanceof SyntaxError) {
|
|
@@ -4053,11 +4304,11 @@ function readAllCapabilities() {
|
|
|
4053
4304
|
}
|
|
4054
4305
|
function readPluginManifest(pluginKey) {
|
|
4055
4306
|
const manifestPath = getPluginManifestPath(pluginKey);
|
|
4056
|
-
if (!
|
|
4307
|
+
if (!fs13.existsSync(manifestPath)) {
|
|
4057
4308
|
throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
|
|
4058
4309
|
}
|
|
4059
4310
|
try {
|
|
4060
|
-
const content =
|
|
4311
|
+
const content = fs13.readFileSync(manifestPath, "utf-8");
|
|
4061
4312
|
return JSON.parse(content);
|
|
4062
4313
|
} catch (error) {
|
|
4063
4314
|
if (error instanceof SyntaxError) {
|
|
@@ -4074,7 +4325,7 @@ function hasValidParamsSchema(paramsSchema) {
|
|
|
4074
4325
|
}
|
|
4075
4326
|
async function loadPlugin(pluginKey) {
|
|
4076
4327
|
try {
|
|
4077
|
-
const userRequire = createRequire2(
|
|
4328
|
+
const userRequire = createRequire2(path11.join(getProjectRoot2(), "package.json"));
|
|
4078
4329
|
const resolvedPath = userRequire.resolve(pluginKey);
|
|
4079
4330
|
const pluginModule = await import(resolvedPath);
|
|
4080
4331
|
const pluginPackage = pluginModule.default ?? pluginModule;
|
|
@@ -4237,8 +4488,8 @@ var capabilityCommandGroup = {
|
|
|
4237
4488
|
import { execFile } from "child_process";
|
|
4238
4489
|
|
|
4239
4490
|
// src/commands/component/registry-preparer.ts
|
|
4240
|
-
import
|
|
4241
|
-
import
|
|
4491
|
+
import fs14 from "fs";
|
|
4492
|
+
import path12 from "path";
|
|
4242
4493
|
import os from "os";
|
|
4243
4494
|
|
|
4244
4495
|
// src/commands/component/service.ts
|
|
@@ -4294,7 +4545,7 @@ async function sendInstallEvent(key) {
|
|
|
4294
4545
|
}
|
|
4295
4546
|
|
|
4296
4547
|
// src/commands/component/registry-preparer.ts
|
|
4297
|
-
var REGISTRY_TEMP_DIR =
|
|
4548
|
+
var REGISTRY_TEMP_DIR = path12.join(os.tmpdir(), "miaoda-registry");
|
|
4298
4549
|
function parseComponentKey(key) {
|
|
4299
4550
|
const match = key.match(/^@([^/]+)\/(.+)$/);
|
|
4300
4551
|
if (!match) {
|
|
@@ -4306,11 +4557,11 @@ function parseComponentKey(key) {
|
|
|
4306
4557
|
}
|
|
4307
4558
|
function getLocalRegistryPath(key) {
|
|
4308
4559
|
const { scope, name } = parseComponentKey(key);
|
|
4309
|
-
return
|
|
4560
|
+
return path12.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
|
|
4310
4561
|
}
|
|
4311
4562
|
function ensureDir(dirPath) {
|
|
4312
|
-
if (!
|
|
4313
|
-
|
|
4563
|
+
if (!fs14.existsSync(dirPath)) {
|
|
4564
|
+
fs14.mkdirSync(dirPath, { recursive: true });
|
|
4314
4565
|
}
|
|
4315
4566
|
}
|
|
4316
4567
|
async function prepareRecursive(key, visited) {
|
|
@@ -4343,8 +4594,8 @@ async function prepareRecursive(key, visited) {
|
|
|
4343
4594
|
registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
|
|
4344
4595
|
};
|
|
4345
4596
|
const localPath = getLocalRegistryPath(key);
|
|
4346
|
-
ensureDir(
|
|
4347
|
-
|
|
4597
|
+
ensureDir(path12.dirname(localPath));
|
|
4598
|
+
fs14.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
|
|
4348
4599
|
debug("\u4FDD\u5B58\u5230: %s", localPath);
|
|
4349
4600
|
}
|
|
4350
4601
|
async function prepareComponentRegistryItems(id) {
|
|
@@ -4354,18 +4605,18 @@ async function prepareComponentRegistryItems(id) {
|
|
|
4354
4605
|
}
|
|
4355
4606
|
function cleanupTempDir() {
|
|
4356
4607
|
try {
|
|
4357
|
-
if (
|
|
4358
|
-
|
|
4608
|
+
if (fs14.existsSync(REGISTRY_TEMP_DIR)) {
|
|
4609
|
+
fs14.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
|
|
4359
4610
|
}
|
|
4360
4611
|
} catch {
|
|
4361
4612
|
}
|
|
4362
4613
|
}
|
|
4363
4614
|
function getDownloadedRegistryItem(itemId) {
|
|
4364
4615
|
const localPath = getLocalRegistryPath(itemId);
|
|
4365
|
-
if (!
|
|
4616
|
+
if (!fs14.existsSync(localPath)) {
|
|
4366
4617
|
return null;
|
|
4367
4618
|
}
|
|
4368
|
-
const content =
|
|
4619
|
+
const content = fs14.readFileSync(localPath, "utf-8");
|
|
4369
4620
|
return JSON.parse(content);
|
|
4370
4621
|
}
|
|
4371
4622
|
|
|
@@ -4533,58 +4784,58 @@ var componentCommandGroup = {
|
|
|
4533
4784
|
};
|
|
4534
4785
|
|
|
4535
4786
|
// src/commands/migration/version-manager.ts
|
|
4536
|
-
import
|
|
4537
|
-
import
|
|
4787
|
+
import fs15 from "fs";
|
|
4788
|
+
import path13 from "path";
|
|
4538
4789
|
var PACKAGE_JSON = "package.json";
|
|
4539
4790
|
var VERSION_FIELD = "migrationVersion";
|
|
4540
4791
|
function getPackageJsonPath2() {
|
|
4541
|
-
return
|
|
4792
|
+
return path13.join(process.cwd(), PACKAGE_JSON);
|
|
4542
4793
|
}
|
|
4543
4794
|
function getCurrentVersion() {
|
|
4544
4795
|
const pkgPath = getPackageJsonPath2();
|
|
4545
|
-
if (!
|
|
4796
|
+
if (!fs15.existsSync(pkgPath)) {
|
|
4546
4797
|
throw new Error("package.json not found");
|
|
4547
4798
|
}
|
|
4548
|
-
const pkg2 = JSON.parse(
|
|
4799
|
+
const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
|
|
4549
4800
|
return pkg2[VERSION_FIELD] ?? 0;
|
|
4550
4801
|
}
|
|
4551
4802
|
function setCurrentVersion(version) {
|
|
4552
4803
|
const pkgPath = getPackageJsonPath2();
|
|
4553
|
-
const pkg2 = JSON.parse(
|
|
4804
|
+
const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
|
|
4554
4805
|
pkg2[VERSION_FIELD] = version;
|
|
4555
|
-
|
|
4806
|
+
fs15.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
|
|
4556
4807
|
}
|
|
4557
4808
|
|
|
4558
4809
|
// src/commands/migration/versions/v001_capability/json-migrator/detector.ts
|
|
4559
|
-
import
|
|
4560
|
-
import
|
|
4810
|
+
import fs17 from "fs";
|
|
4811
|
+
import path15 from "path";
|
|
4561
4812
|
|
|
4562
4813
|
// src/commands/migration/versions/v001_capability/utils.ts
|
|
4563
|
-
import
|
|
4564
|
-
import
|
|
4814
|
+
import fs16 from "fs";
|
|
4815
|
+
import path14 from "path";
|
|
4565
4816
|
var CAPABILITIES_DIR2 = "server/capabilities";
|
|
4566
4817
|
function getProjectRoot3() {
|
|
4567
4818
|
return process.cwd();
|
|
4568
4819
|
}
|
|
4569
4820
|
function getCapabilitiesDir2() {
|
|
4570
|
-
return
|
|
4821
|
+
return path14.join(getProjectRoot3(), CAPABILITIES_DIR2);
|
|
4571
4822
|
}
|
|
4572
4823
|
function getPluginManifestPath2(pluginKey) {
|
|
4573
|
-
return
|
|
4824
|
+
return path14.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
|
|
4574
4825
|
}
|
|
4575
4826
|
|
|
4576
4827
|
// src/commands/migration/versions/v001_capability/json-migrator/detector.ts
|
|
4577
4828
|
function detectJsonMigration() {
|
|
4578
4829
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
4579
|
-
const oldFilePath =
|
|
4580
|
-
if (!
|
|
4830
|
+
const oldFilePath = path15.join(capabilitiesDir, "capabilities.json");
|
|
4831
|
+
if (!fs17.existsSync(oldFilePath)) {
|
|
4581
4832
|
return {
|
|
4582
4833
|
needsMigration: false,
|
|
4583
4834
|
reason: "capabilities.json not found"
|
|
4584
4835
|
};
|
|
4585
4836
|
}
|
|
4586
4837
|
try {
|
|
4587
|
-
const content =
|
|
4838
|
+
const content = fs17.readFileSync(oldFilePath, "utf-8");
|
|
4588
4839
|
const parsed = JSON.parse(content);
|
|
4589
4840
|
if (!Array.isArray(parsed)) {
|
|
4590
4841
|
return {
|
|
@@ -4635,8 +4886,8 @@ async function check(options) {
|
|
|
4635
4886
|
}
|
|
4636
4887
|
|
|
4637
4888
|
// src/commands/migration/versions/v001_capability/json-migrator/index.ts
|
|
4638
|
-
import
|
|
4639
|
-
import
|
|
4889
|
+
import fs18 from "fs";
|
|
4890
|
+
import path16 from "path";
|
|
4640
4891
|
|
|
4641
4892
|
// src/commands/migration/versions/v001_capability/mapping.ts
|
|
4642
4893
|
var DEFAULT_PLUGIN_VERSION = "1.0.0";
|
|
@@ -4866,18 +5117,18 @@ function transformCapabilities(oldCapabilities) {
|
|
|
4866
5117
|
// src/commands/migration/versions/v001_capability/json-migrator/index.ts
|
|
4867
5118
|
function loadExistingCapabilities() {
|
|
4868
5119
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
4869
|
-
if (!
|
|
5120
|
+
if (!fs18.existsSync(capabilitiesDir)) {
|
|
4870
5121
|
return [];
|
|
4871
5122
|
}
|
|
4872
|
-
const files =
|
|
5123
|
+
const files = fs18.readdirSync(capabilitiesDir);
|
|
4873
5124
|
const capabilities = [];
|
|
4874
5125
|
for (const file of files) {
|
|
4875
5126
|
if (file === "capabilities.json" || !file.endsWith(".json")) {
|
|
4876
5127
|
continue;
|
|
4877
5128
|
}
|
|
4878
5129
|
try {
|
|
4879
|
-
const filePath =
|
|
4880
|
-
const content =
|
|
5130
|
+
const filePath = path16.join(capabilitiesDir, file);
|
|
5131
|
+
const content = fs18.readFileSync(filePath, "utf-8");
|
|
4881
5132
|
const capability = JSON.parse(content);
|
|
4882
5133
|
if (capability.id && capability.pluginKey) {
|
|
4883
5134
|
capabilities.push(capability);
|
|
@@ -4935,9 +5186,9 @@ async function migrateJsonFiles(options) {
|
|
|
4935
5186
|
}
|
|
4936
5187
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
4937
5188
|
for (const cap of newCapabilities) {
|
|
4938
|
-
const filePath =
|
|
5189
|
+
const filePath = path16.join(capabilitiesDir, `${cap.id}.json`);
|
|
4939
5190
|
const content = JSON.stringify(cap, null, 2);
|
|
4940
|
-
|
|
5191
|
+
fs18.writeFileSync(filePath, content, "utf-8");
|
|
4941
5192
|
console.log(` \u2713 Created: ${cap.id}.json`);
|
|
4942
5193
|
}
|
|
4943
5194
|
return {
|
|
@@ -4949,11 +5200,11 @@ async function migrateJsonFiles(options) {
|
|
|
4949
5200
|
}
|
|
4950
5201
|
|
|
4951
5202
|
// src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
|
|
4952
|
-
import
|
|
5203
|
+
import fs19 from "fs";
|
|
4953
5204
|
function isPluginInstalled2(pluginKey) {
|
|
4954
5205
|
const actionPlugins = readActionPlugins();
|
|
4955
5206
|
const manifestPath = getPluginManifestPath2(pluginKey);
|
|
4956
|
-
return
|
|
5207
|
+
return fs19.existsSync(manifestPath) && !!actionPlugins[pluginKey];
|
|
4957
5208
|
}
|
|
4958
5209
|
function detectPluginsToInstall(capabilities) {
|
|
4959
5210
|
const pluginKeys = /* @__PURE__ */ new Set();
|
|
@@ -5029,12 +5280,12 @@ async function installPlugins(capabilities, options) {
|
|
|
5029
5280
|
}
|
|
5030
5281
|
|
|
5031
5282
|
// src/commands/migration/versions/v001_capability/code-migrator/index.ts
|
|
5032
|
-
import
|
|
5283
|
+
import path18 from "path";
|
|
5033
5284
|
import { Project as Project3 } from "ts-morph";
|
|
5034
5285
|
|
|
5035
5286
|
// src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
|
|
5036
|
-
import
|
|
5037
|
-
import
|
|
5287
|
+
import fs20 from "fs";
|
|
5288
|
+
import path17 from "path";
|
|
5038
5289
|
var EXCLUDED_DIRS = [
|
|
5039
5290
|
"node_modules",
|
|
5040
5291
|
"dist",
|
|
@@ -5049,9 +5300,9 @@ var EXCLUDED_PATTERNS = [
|
|
|
5049
5300
|
/\.d\.ts$/
|
|
5050
5301
|
];
|
|
5051
5302
|
function scanDirectory(dir, files = []) {
|
|
5052
|
-
const entries =
|
|
5303
|
+
const entries = fs20.readdirSync(dir, { withFileTypes: true });
|
|
5053
5304
|
for (const entry of entries) {
|
|
5054
|
-
const fullPath =
|
|
5305
|
+
const fullPath = path17.join(dir, entry.name);
|
|
5055
5306
|
if (entry.isDirectory()) {
|
|
5056
5307
|
if (EXCLUDED_DIRS.includes(entry.name)) {
|
|
5057
5308
|
continue;
|
|
@@ -5067,14 +5318,14 @@ function scanDirectory(dir, files = []) {
|
|
|
5067
5318
|
return files;
|
|
5068
5319
|
}
|
|
5069
5320
|
function scanServerFiles() {
|
|
5070
|
-
const serverDir =
|
|
5071
|
-
if (!
|
|
5321
|
+
const serverDir = path17.join(getProjectRoot3(), "server");
|
|
5322
|
+
if (!fs20.existsSync(serverDir)) {
|
|
5072
5323
|
return [];
|
|
5073
5324
|
}
|
|
5074
5325
|
return scanDirectory(serverDir);
|
|
5075
5326
|
}
|
|
5076
5327
|
function hasCapabilityImport(filePath) {
|
|
5077
|
-
const content =
|
|
5328
|
+
const content = fs20.readFileSync(filePath, "utf-8");
|
|
5078
5329
|
return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
|
|
5079
5330
|
}
|
|
5080
5331
|
function scanFilesToMigrate() {
|
|
@@ -5451,7 +5702,7 @@ function analyzeFile(project, filePath, actionNameMap) {
|
|
|
5451
5702
|
const callSites = analyzeCallSites(sourceFile, imports);
|
|
5452
5703
|
const classInfo = analyzeClass(sourceFile);
|
|
5453
5704
|
const { canMigrate, reason } = canAutoMigrate(classInfo);
|
|
5454
|
-
const relativePath =
|
|
5705
|
+
const relativePath = path18.relative(getProjectRoot3(), filePath);
|
|
5455
5706
|
return {
|
|
5456
5707
|
filePath: relativePath,
|
|
5457
5708
|
imports,
|
|
@@ -5462,7 +5713,7 @@ function analyzeFile(project, filePath, actionNameMap) {
|
|
|
5462
5713
|
};
|
|
5463
5714
|
}
|
|
5464
5715
|
function migrateFile(project, analysis, dryRun) {
|
|
5465
|
-
const absolutePath =
|
|
5716
|
+
const absolutePath = path18.join(getProjectRoot3(), analysis.filePath);
|
|
5466
5717
|
if (!analysis.canAutoMigrate) {
|
|
5467
5718
|
return {
|
|
5468
5719
|
filePath: analysis.filePath,
|
|
@@ -5565,17 +5816,17 @@ function getSuggestion(analysis) {
|
|
|
5565
5816
|
}
|
|
5566
5817
|
|
|
5567
5818
|
// src/commands/migration/versions/v001_capability/cleanup.ts
|
|
5568
|
-
import
|
|
5569
|
-
import
|
|
5819
|
+
import fs21 from "fs";
|
|
5820
|
+
import path19 from "path";
|
|
5570
5821
|
function cleanupOldFiles(capabilities, dryRun) {
|
|
5571
5822
|
const deletedFiles = [];
|
|
5572
5823
|
const errors = [];
|
|
5573
5824
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
5574
|
-
const oldJsonPath =
|
|
5575
|
-
if (
|
|
5825
|
+
const oldJsonPath = path19.join(capabilitiesDir, "capabilities.json");
|
|
5826
|
+
if (fs21.existsSync(oldJsonPath)) {
|
|
5576
5827
|
try {
|
|
5577
5828
|
if (!dryRun) {
|
|
5578
|
-
|
|
5829
|
+
fs21.unlinkSync(oldJsonPath);
|
|
5579
5830
|
}
|
|
5580
5831
|
deletedFiles.push("capabilities.json");
|
|
5581
5832
|
} catch (error) {
|
|
@@ -5583,11 +5834,11 @@ function cleanupOldFiles(capabilities, dryRun) {
|
|
|
5583
5834
|
}
|
|
5584
5835
|
}
|
|
5585
5836
|
for (const cap of capabilities) {
|
|
5586
|
-
const tsFilePath =
|
|
5587
|
-
if (
|
|
5837
|
+
const tsFilePath = path19.join(capabilitiesDir, `${cap.id}.ts`);
|
|
5838
|
+
if (fs21.existsSync(tsFilePath)) {
|
|
5588
5839
|
try {
|
|
5589
5840
|
if (!dryRun) {
|
|
5590
|
-
|
|
5841
|
+
fs21.unlinkSync(tsFilePath);
|
|
5591
5842
|
}
|
|
5592
5843
|
deletedFiles.push(`${cap.id}.ts`);
|
|
5593
5844
|
} catch (error) {
|
|
@@ -5603,8 +5854,8 @@ function cleanupOldFiles(capabilities, dryRun) {
|
|
|
5603
5854
|
}
|
|
5604
5855
|
|
|
5605
5856
|
// src/commands/migration/versions/v001_capability/report-generator.ts
|
|
5606
|
-
import
|
|
5607
|
-
import
|
|
5857
|
+
import fs22 from "fs";
|
|
5858
|
+
import path20 from "path";
|
|
5608
5859
|
var REPORT_FILE = "capability-migration-report.md";
|
|
5609
5860
|
function printSummary(result) {
|
|
5610
5861
|
const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
|
|
@@ -5767,15 +6018,15 @@ async function generateReport(result) {
|
|
|
5767
6018
|
}
|
|
5768
6019
|
lines.push("");
|
|
5769
6020
|
const logDir = process.env.LOG_DIR || "logs";
|
|
5770
|
-
if (!
|
|
6021
|
+
if (!fs22.existsSync(logDir)) {
|
|
5771
6022
|
return;
|
|
5772
6023
|
}
|
|
5773
|
-
const reportDir =
|
|
5774
|
-
if (!
|
|
5775
|
-
|
|
6024
|
+
const reportDir = path20.join(logDir, "migration");
|
|
6025
|
+
if (!fs22.existsSync(reportDir)) {
|
|
6026
|
+
fs22.mkdirSync(reportDir, { recursive: true });
|
|
5776
6027
|
}
|
|
5777
|
-
const reportPath =
|
|
5778
|
-
|
|
6028
|
+
const reportPath = path20.join(reportDir, REPORT_FILE);
|
|
6029
|
+
fs22.writeFileSync(reportPath, lines.join("\n"), "utf-8");
|
|
5779
6030
|
console.log(`\u{1F4C4} Report generated: ${reportPath}`);
|
|
5780
6031
|
}
|
|
5781
6032
|
|
|
@@ -6307,10 +6558,10 @@ var migrationCommand = {
|
|
|
6307
6558
|
};
|
|
6308
6559
|
|
|
6309
6560
|
// src/commands/read-logs/index.ts
|
|
6310
|
-
import
|
|
6561
|
+
import path21 from "path";
|
|
6311
6562
|
|
|
6312
6563
|
// src/commands/read-logs/std-utils.ts
|
|
6313
|
-
import
|
|
6564
|
+
import fs23 from "fs";
|
|
6314
6565
|
function formatStdPrefixTime(localTime) {
|
|
6315
6566
|
const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
|
|
6316
6567
|
if (!match) return localTime;
|
|
@@ -6340,11 +6591,11 @@ function stripPrefixFromStdLine(line) {
|
|
|
6340
6591
|
return `[${time}] ${content}`;
|
|
6341
6592
|
}
|
|
6342
6593
|
function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
|
|
6343
|
-
const stat =
|
|
6594
|
+
const stat = fs23.statSync(filePath);
|
|
6344
6595
|
if (stat.size === 0) {
|
|
6345
6596
|
return { lines: [], markerFound: false, totalLinesCount: 0 };
|
|
6346
6597
|
}
|
|
6347
|
-
const fd =
|
|
6598
|
+
const fd = fs23.openSync(filePath, "r");
|
|
6348
6599
|
const chunkSize = 64 * 1024;
|
|
6349
6600
|
let position = stat.size;
|
|
6350
6601
|
let remainder = "";
|
|
@@ -6358,7 +6609,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
|
|
|
6358
6609
|
const length = Math.min(chunkSize, position);
|
|
6359
6610
|
position -= length;
|
|
6360
6611
|
const buffer = Buffer.alloc(length);
|
|
6361
|
-
|
|
6612
|
+
fs23.readSync(fd, buffer, 0, length, position);
|
|
6362
6613
|
let chunk = buffer.toString("utf8");
|
|
6363
6614
|
if (remainder) {
|
|
6364
6615
|
chunk += remainder;
|
|
@@ -6400,7 +6651,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
|
|
|
6400
6651
|
}
|
|
6401
6652
|
}
|
|
6402
6653
|
} finally {
|
|
6403
|
-
|
|
6654
|
+
fs23.closeSync(fd);
|
|
6404
6655
|
}
|
|
6405
6656
|
return { lines: collected.reverse(), markerFound, totalLinesCount };
|
|
6406
6657
|
}
|
|
@@ -6421,21 +6672,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
|
|
|
6421
6672
|
}
|
|
6422
6673
|
|
|
6423
6674
|
// src/commands/read-logs/tail.ts
|
|
6424
|
-
import
|
|
6675
|
+
import fs24 from "fs";
|
|
6425
6676
|
function fileExists(filePath) {
|
|
6426
6677
|
try {
|
|
6427
|
-
|
|
6678
|
+
fs24.accessSync(filePath, fs24.constants.F_OK | fs24.constants.R_OK);
|
|
6428
6679
|
return true;
|
|
6429
6680
|
} catch {
|
|
6430
6681
|
return false;
|
|
6431
6682
|
}
|
|
6432
6683
|
}
|
|
6433
6684
|
function readFileTailLines(filePath, maxLines) {
|
|
6434
|
-
const stat =
|
|
6685
|
+
const stat = fs24.statSync(filePath);
|
|
6435
6686
|
if (stat.size === 0) {
|
|
6436
6687
|
return [];
|
|
6437
6688
|
}
|
|
6438
|
-
const fd =
|
|
6689
|
+
const fd = fs24.openSync(filePath, "r");
|
|
6439
6690
|
const chunkSize = 64 * 1024;
|
|
6440
6691
|
const chunks = [];
|
|
6441
6692
|
let position = stat.size;
|
|
@@ -6445,13 +6696,13 @@ function readFileTailLines(filePath, maxLines) {
|
|
|
6445
6696
|
const length = Math.min(chunkSize, position);
|
|
6446
6697
|
position -= length;
|
|
6447
6698
|
const buffer = Buffer.alloc(length);
|
|
6448
|
-
|
|
6699
|
+
fs24.readSync(fd, buffer, 0, length, position);
|
|
6449
6700
|
chunks.unshift(buffer.toString("utf8"));
|
|
6450
6701
|
const chunkLines = buffer.toString("utf8").split("\n").length - 1;
|
|
6451
6702
|
collectedLines += chunkLines;
|
|
6452
6703
|
}
|
|
6453
6704
|
} finally {
|
|
6454
|
-
|
|
6705
|
+
fs24.closeSync(fd);
|
|
6455
6706
|
}
|
|
6456
6707
|
const content = chunks.join("");
|
|
6457
6708
|
const allLines = content.split("\n");
|
|
@@ -6467,11 +6718,11 @@ function readFileTailLines(filePath, maxLines) {
|
|
|
6467
6718
|
return allLines.slice(allLines.length - maxLines);
|
|
6468
6719
|
}
|
|
6469
6720
|
function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
6470
|
-
const stat =
|
|
6721
|
+
const stat = fs24.statSync(filePath);
|
|
6471
6722
|
if (stat.size === 0) {
|
|
6472
6723
|
return { lines: [], totalLinesCount: 0 };
|
|
6473
6724
|
}
|
|
6474
|
-
const fd =
|
|
6725
|
+
const fd = fs24.openSync(filePath, "r");
|
|
6475
6726
|
const chunkSize = 64 * 1024;
|
|
6476
6727
|
let position = stat.size;
|
|
6477
6728
|
let remainder = "";
|
|
@@ -6483,7 +6734,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
|
6483
6734
|
const length = Math.min(chunkSize, position);
|
|
6484
6735
|
position -= length;
|
|
6485
6736
|
const buffer = Buffer.alloc(length);
|
|
6486
|
-
|
|
6737
|
+
fs24.readSync(fd, buffer, 0, length, position);
|
|
6487
6738
|
let chunk = buffer.toString("utf8");
|
|
6488
6739
|
if (remainder) {
|
|
6489
6740
|
chunk += remainder;
|
|
@@ -6514,7 +6765,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
|
6514
6765
|
}
|
|
6515
6766
|
}
|
|
6516
6767
|
} finally {
|
|
6517
|
-
|
|
6768
|
+
fs24.closeSync(fd);
|
|
6518
6769
|
}
|
|
6519
6770
|
return { lines: collected.reverse(), totalLinesCount };
|
|
6520
6771
|
}
|
|
@@ -6656,7 +6907,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
|
|
|
6656
6907
|
}
|
|
6657
6908
|
|
|
6658
6909
|
// src/commands/read-logs/json-lines.ts
|
|
6659
|
-
import
|
|
6910
|
+
import fs25 from "fs";
|
|
6660
6911
|
function normalizePid(value) {
|
|
6661
6912
|
if (typeof value === "number") {
|
|
6662
6913
|
return String(value);
|
|
@@ -6707,11 +6958,11 @@ function buildWantedLevelSet(levels) {
|
|
|
6707
6958
|
return set.size > 0 ? set : null;
|
|
6708
6959
|
}
|
|
6709
6960
|
function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
6710
|
-
const stat =
|
|
6961
|
+
const stat = fs25.statSync(filePath);
|
|
6711
6962
|
if (stat.size === 0) {
|
|
6712
6963
|
return { lines: [], totalLinesCount: 0 };
|
|
6713
6964
|
}
|
|
6714
|
-
const fd =
|
|
6965
|
+
const fd = fs25.openSync(filePath, "r");
|
|
6715
6966
|
const chunkSize = 64 * 1024;
|
|
6716
6967
|
let position = stat.size;
|
|
6717
6968
|
let remainder = "";
|
|
@@ -6726,7 +6977,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
|
6726
6977
|
const length = Math.min(chunkSize, position);
|
|
6727
6978
|
position -= length;
|
|
6728
6979
|
const buffer = Buffer.alloc(length);
|
|
6729
|
-
|
|
6980
|
+
fs25.readSync(fd, buffer, 0, length, position);
|
|
6730
6981
|
let chunk = buffer.toString("utf8");
|
|
6731
6982
|
if (remainder) {
|
|
6732
6983
|
chunk += remainder;
|
|
@@ -6788,7 +7039,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
|
6788
7039
|
}
|
|
6789
7040
|
}
|
|
6790
7041
|
} finally {
|
|
6791
|
-
|
|
7042
|
+
fs25.closeSync(fd);
|
|
6792
7043
|
}
|
|
6793
7044
|
return { lines: collected.reverse(), totalLinesCount };
|
|
6794
7045
|
}
|
|
@@ -6831,11 +7082,11 @@ function extractTraceId(obj) {
|
|
|
6831
7082
|
function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
6832
7083
|
const wanted = traceId.trim();
|
|
6833
7084
|
if (!wanted) return { lines: [], totalLinesCount: 0 };
|
|
6834
|
-
const stat =
|
|
7085
|
+
const stat = fs25.statSync(filePath);
|
|
6835
7086
|
if (stat.size === 0) {
|
|
6836
7087
|
return { lines: [], totalLinesCount: 0 };
|
|
6837
7088
|
}
|
|
6838
|
-
const fd =
|
|
7089
|
+
const fd = fs25.openSync(filePath, "r");
|
|
6839
7090
|
const chunkSize = 64 * 1024;
|
|
6840
7091
|
let position = stat.size;
|
|
6841
7092
|
let remainder = "";
|
|
@@ -6848,7 +7099,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
|
6848
7099
|
const length = Math.min(chunkSize, position);
|
|
6849
7100
|
position -= length;
|
|
6850
7101
|
const buffer = Buffer.alloc(length);
|
|
6851
|
-
|
|
7102
|
+
fs25.readSync(fd, buffer, 0, length, position);
|
|
6852
7103
|
let chunk = buffer.toString("utf8");
|
|
6853
7104
|
if (remainder) {
|
|
6854
7105
|
chunk += remainder;
|
|
@@ -6901,7 +7152,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
|
6901
7152
|
}
|
|
6902
7153
|
}
|
|
6903
7154
|
} finally {
|
|
6904
|
-
|
|
7155
|
+
fs25.closeSync(fd);
|
|
6905
7156
|
}
|
|
6906
7157
|
return { lines: collected.reverse(), totalLinesCount };
|
|
6907
7158
|
}
|
|
@@ -6910,11 +7161,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
6910
7161
|
if (!wantedLevelSet) {
|
|
6911
7162
|
return { lines: [], totalLinesCount: 0 };
|
|
6912
7163
|
}
|
|
6913
|
-
const stat =
|
|
7164
|
+
const stat = fs25.statSync(filePath);
|
|
6914
7165
|
if (stat.size === 0) {
|
|
6915
7166
|
return { lines: [], totalLinesCount: 0 };
|
|
6916
7167
|
}
|
|
6917
|
-
const fd =
|
|
7168
|
+
const fd = fs25.openSync(filePath, "r");
|
|
6918
7169
|
const chunkSize = 64 * 1024;
|
|
6919
7170
|
let position = stat.size;
|
|
6920
7171
|
let remainder = "";
|
|
@@ -6926,7 +7177,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
6926
7177
|
const length = Math.min(chunkSize, position);
|
|
6927
7178
|
position -= length;
|
|
6928
7179
|
const buffer = Buffer.alloc(length);
|
|
6929
|
-
|
|
7180
|
+
fs25.readSync(fd, buffer, 0, length, position);
|
|
6930
7181
|
let chunk = buffer.toString("utf8");
|
|
6931
7182
|
if (remainder) {
|
|
6932
7183
|
chunk += remainder;
|
|
@@ -6973,7 +7224,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
6973
7224
|
}
|
|
6974
7225
|
}
|
|
6975
7226
|
} finally {
|
|
6976
|
-
|
|
7227
|
+
fs25.closeSync(fd);
|
|
6977
7228
|
}
|
|
6978
7229
|
return { lines: collected.reverse(), totalLinesCount };
|
|
6979
7230
|
}
|
|
@@ -7207,30 +7458,30 @@ async function readLogsJsonResult(options) {
|
|
|
7207
7458
|
};
|
|
7208
7459
|
}
|
|
7209
7460
|
function resolveLogFilePath(logDir, type) {
|
|
7210
|
-
const base =
|
|
7461
|
+
const base = path21.isAbsolute(logDir) ? logDir : path21.join(process.cwd(), logDir);
|
|
7211
7462
|
if (type === "server") {
|
|
7212
|
-
return
|
|
7463
|
+
return path21.join(base, "server.log");
|
|
7213
7464
|
}
|
|
7214
7465
|
if (type === "trace") {
|
|
7215
|
-
return
|
|
7466
|
+
return path21.join(base, "trace.log");
|
|
7216
7467
|
}
|
|
7217
7468
|
if (type === "server-std") {
|
|
7218
|
-
return
|
|
7469
|
+
return path21.join(base, "server.std.log");
|
|
7219
7470
|
}
|
|
7220
7471
|
if (type === "client-std") {
|
|
7221
|
-
return
|
|
7472
|
+
return path21.join(base, "client.std.log");
|
|
7222
7473
|
}
|
|
7223
7474
|
if (type === "dev") {
|
|
7224
|
-
return
|
|
7475
|
+
return path21.join(base, "dev.log");
|
|
7225
7476
|
}
|
|
7226
7477
|
if (type === "dev-std") {
|
|
7227
|
-
return
|
|
7478
|
+
return path21.join(base, "dev.std.log");
|
|
7228
7479
|
}
|
|
7229
7480
|
if (type === "install-dep-std") {
|
|
7230
|
-
return
|
|
7481
|
+
return path21.join(base, "install-dep.std.log");
|
|
7231
7482
|
}
|
|
7232
7483
|
if (type === "browser") {
|
|
7233
|
-
return
|
|
7484
|
+
return path21.join(base, "browser.log");
|
|
7234
7485
|
}
|
|
7235
7486
|
throw new Error(`Unsupported log type: ${type}`);
|
|
7236
7487
|
}
|
|
@@ -7407,9 +7658,9 @@ function camelToKebab(str) {
|
|
|
7407
7658
|
}
|
|
7408
7659
|
|
|
7409
7660
|
// src/commands/build/upload-static.handler.ts
|
|
7410
|
-
import * as
|
|
7661
|
+
import * as fs26 from "fs";
|
|
7411
7662
|
import * as os2 from "os";
|
|
7412
|
-
import * as
|
|
7663
|
+
import * as path22 from "path";
|
|
7413
7664
|
import { execFileSync } from "child_process";
|
|
7414
7665
|
function readCredentialsFromEnv() {
|
|
7415
7666
|
const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
|
|
@@ -7433,8 +7684,8 @@ async function uploadStatic(options) {
|
|
|
7433
7684
|
endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
|
|
7434
7685
|
region = UPLOAD_STATIC_DEFAULTS.region
|
|
7435
7686
|
} = options;
|
|
7436
|
-
const resolvedStaticDir =
|
|
7437
|
-
if (!
|
|
7687
|
+
const resolvedStaticDir = path22.resolve(staticDir);
|
|
7688
|
+
if (!fs26.existsSync(resolvedStaticDir)) {
|
|
7438
7689
|
console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
|
|
7439
7690
|
return;
|
|
7440
7691
|
}
|
|
@@ -7467,8 +7718,8 @@ async function uploadStatic(options) {
|
|
|
7467
7718
|
({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
|
|
7468
7719
|
}
|
|
7469
7720
|
console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
|
|
7470
|
-
const confPath =
|
|
7471
|
-
|
|
7721
|
+
const confPath = path22.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
|
|
7722
|
+
fs26.writeFileSync(confPath, "");
|
|
7472
7723
|
try {
|
|
7473
7724
|
console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
|
|
7474
7725
|
configureTosutil(resolvedTosutil, confPath, {
|
|
@@ -7482,7 +7733,7 @@ async function uploadStatic(options) {
|
|
|
7482
7733
|
uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
|
|
7483
7734
|
} finally {
|
|
7484
7735
|
try {
|
|
7485
|
-
|
|
7736
|
+
fs26.unlinkSync(confPath);
|
|
7486
7737
|
} catch {
|
|
7487
7738
|
}
|
|
7488
7739
|
}
|
|
@@ -7502,8 +7753,8 @@ async function uploadStatic(options) {
|
|
|
7502
7753
|
}
|
|
7503
7754
|
}
|
|
7504
7755
|
function resolveTosutilPath(tosutilPath) {
|
|
7505
|
-
if (
|
|
7506
|
-
return
|
|
7756
|
+
if (path22.isAbsolute(tosutilPath)) {
|
|
7757
|
+
return fs26.existsSync(tosutilPath) ? tosutilPath : null;
|
|
7507
7758
|
}
|
|
7508
7759
|
try {
|
|
7509
7760
|
const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
|
|
@@ -7548,7 +7799,7 @@ async function resolveBucketId(appId) {
|
|
|
7548
7799
|
return bucketId;
|
|
7549
7800
|
}
|
|
7550
7801
|
function isDirEmpty(dirPath) {
|
|
7551
|
-
const entries =
|
|
7802
|
+
const entries = fs26.readdirSync(dirPath);
|
|
7552
7803
|
return entries.length === 0;
|
|
7553
7804
|
}
|
|
7554
7805
|
|
|
@@ -7643,12 +7894,12 @@ var commands = [
|
|
|
7643
7894
|
];
|
|
7644
7895
|
|
|
7645
7896
|
// src/index.ts
|
|
7646
|
-
var envPath =
|
|
7647
|
-
if (
|
|
7897
|
+
var envPath = path23.join(process.cwd(), ".env");
|
|
7898
|
+
if (fs27.existsSync(envPath)) {
|
|
7648
7899
|
dotenvConfig({ path: envPath });
|
|
7649
7900
|
}
|
|
7650
|
-
var __dirname =
|
|
7651
|
-
var pkg = JSON.parse(
|
|
7901
|
+
var __dirname = path23.dirname(fileURLToPath5(import.meta.url));
|
|
7902
|
+
var pkg = JSON.parse(fs27.readFileSync(path23.join(__dirname, "../package.json"), "utf-8"));
|
|
7652
7903
|
var cli = new FullstackCLI(pkg.version);
|
|
7653
7904
|
cli.useAll(commands);
|
|
7654
7905
|
cli.run();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lark-apaas/fullstack-cli",
|
|
3
|
-
"version": "1.1.16-beta.
|
|
3
|
+
"version": "1.1.16-beta.15",
|
|
4
4
|
"description": "CLI tool for fullstack template management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"access": "public"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@lark-apaas/http-client": "
|
|
34
|
+
"@lark-apaas/http-client": "0.1.5-beta.0",
|
|
35
35
|
"@lydell/node-pty": "1.1.0",
|
|
36
36
|
"@vercel/nft": "^0.30.3",
|
|
37
37
|
"commander": "^13.0.0",
|