@lark-apaas/fullstack-cli 1.1.40-alpha.0 → 1.1.40-alpha.2
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 +216 -309
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import fs27 from "fs";
|
|
3
|
+
import path23 from "path";
|
|
4
4
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
5
5
|
import { config as dotenvConfig } from "dotenv";
|
|
6
6
|
|
|
@@ -3106,112 +3106,27 @@ async function run3(options = {}) {
|
|
|
3106
3106
|
// src/commands/upgrade/deps/run.handler.ts
|
|
3107
3107
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
3108
3108
|
|
|
3109
|
-
// src/utils/grayscale/
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
3113
|
-
var CACHE_PATH = path8.join(os.homedir(), ".fullstack", "grayscale-cache.json");
|
|
3114
|
-
var NORMAL_TTL_MS = 30 * 60 * 1e3;
|
|
3115
|
-
var FALLBACK_TTL_MS = 24 * 60 * 60 * 1e3;
|
|
3116
|
-
function readLocalCache(fallback = false) {
|
|
3117
|
-
try {
|
|
3118
|
-
if (!fs10.existsSync(CACHE_PATH)) {
|
|
3119
|
-
return null;
|
|
3120
|
-
}
|
|
3121
|
-
const content = fs10.readFileSync(CACHE_PATH, "utf-8");
|
|
3122
|
-
const entry = JSON.parse(content);
|
|
3123
|
-
if (!entry.config || !entry.timestamp) {
|
|
3124
|
-
return null;
|
|
3125
|
-
}
|
|
3126
|
-
const ttl = fallback ? FALLBACK_TTL_MS : NORMAL_TTL_MS;
|
|
3127
|
-
const age = Date.now() - entry.timestamp;
|
|
3128
|
-
if (age > ttl) {
|
|
3129
|
-
return null;
|
|
3130
|
-
}
|
|
3131
|
-
return entry.config;
|
|
3132
|
-
} catch {
|
|
3109
|
+
// src/utils/grayscale/config.ts
|
|
3110
|
+
function getGrayscaleConfig(configJson) {
|
|
3111
|
+
const raw = configJson || process.env.GRAYSCALE_CONFIG;
|
|
3112
|
+
if (!raw) {
|
|
3133
3113
|
return null;
|
|
3134
3114
|
}
|
|
3135
|
-
}
|
|
3136
|
-
function writeLocalCache(config) {
|
|
3137
3115
|
try {
|
|
3138
|
-
const
|
|
3139
|
-
if (!
|
|
3140
|
-
|
|
3116
|
+
const config = JSON.parse(raw);
|
|
3117
|
+
if (!config.enabled) {
|
|
3118
|
+
return null;
|
|
3141
3119
|
}
|
|
3142
|
-
|
|
3143
|
-
config,
|
|
3144
|
-
timestamp: Date.now()
|
|
3145
|
-
};
|
|
3146
|
-
fs10.writeFileSync(CACHE_PATH, JSON.stringify(entry, null, 2), "utf-8");
|
|
3120
|
+
return config;
|
|
3147
3121
|
} catch {
|
|
3148
|
-
|
|
3149
|
-
}
|
|
3150
|
-
|
|
3151
|
-
// src/utils/grayscale/config.ts
|
|
3152
|
-
var memoryCache = null;
|
|
3153
|
-
var MEMORY_TTL_MS = 60 * 1e3;
|
|
3154
|
-
var API_TIMEOUT_MS = 3e3;
|
|
3155
|
-
async function fetchFromApi() {
|
|
3156
|
-
try {
|
|
3157
|
-
const client = getHttpClient();
|
|
3158
|
-
const controller = new AbortController();
|
|
3159
|
-
const timer = setTimeout(() => controller.abort(), API_TIMEOUT_MS);
|
|
3160
|
-
try {
|
|
3161
|
-
const response = await client.post(
|
|
3162
|
-
"/api/v1/studio/innerapi/get_grayscale_config",
|
|
3163
|
-
{},
|
|
3164
|
-
{ signal: controller.signal }
|
|
3165
|
-
);
|
|
3166
|
-
if (!response.ok) {
|
|
3167
|
-
console.warn(`[grayscale] API request failed: ${response.status} ${response.statusText}`);
|
|
3168
|
-
return null;
|
|
3169
|
-
}
|
|
3170
|
-
const result = await response.json();
|
|
3171
|
-
if (result.status_code !== "0") {
|
|
3172
|
-
console.warn(`[grayscale] API error: ${result.message}`);
|
|
3173
|
-
return null;
|
|
3174
|
-
}
|
|
3175
|
-
return result.data?.config ?? null;
|
|
3176
|
-
} finally {
|
|
3177
|
-
clearTimeout(timer);
|
|
3178
|
-
}
|
|
3179
|
-
} catch (error) {
|
|
3180
|
-
const message = error instanceof Error ? error.message : String(error);
|
|
3181
|
-
console.warn(`[grayscale] Failed to fetch config from API: ${message}`);
|
|
3122
|
+
console.warn("[grayscale] Failed to parse grayscale config");
|
|
3182
3123
|
return null;
|
|
3183
3124
|
}
|
|
3184
3125
|
}
|
|
3185
|
-
async function getGrayscaleConfig() {
|
|
3186
|
-
if (memoryCache) {
|
|
3187
|
-
const age = Date.now() - memoryCache.timestamp;
|
|
3188
|
-
if (age <= MEMORY_TTL_MS) {
|
|
3189
|
-
return memoryCache.config;
|
|
3190
|
-
}
|
|
3191
|
-
memoryCache = null;
|
|
3192
|
-
}
|
|
3193
|
-
const localNormal = readLocalCache(false);
|
|
3194
|
-
if (localNormal) {
|
|
3195
|
-
memoryCache = { config: localNormal, timestamp: Date.now() };
|
|
3196
|
-
return localNormal;
|
|
3197
|
-
}
|
|
3198
|
-
const apiConfig = await fetchFromApi();
|
|
3199
|
-
if (apiConfig) {
|
|
3200
|
-
memoryCache = { config: apiConfig, timestamp: Date.now() };
|
|
3201
|
-
writeLocalCache(apiConfig);
|
|
3202
|
-
return apiConfig;
|
|
3203
|
-
}
|
|
3204
|
-
const localFallback = readLocalCache(true);
|
|
3205
|
-
if (localFallback) {
|
|
3206
|
-
memoryCache = { config: localFallback, timestamp: Date.now() };
|
|
3207
|
-
return localFallback;
|
|
3208
|
-
}
|
|
3209
|
-
return null;
|
|
3210
|
-
}
|
|
3211
3126
|
|
|
3212
3127
|
// src/utils/grayscale/identity.ts
|
|
3213
|
-
import
|
|
3214
|
-
import
|
|
3128
|
+
import fs10 from "fs";
|
|
3129
|
+
import path8 from "path";
|
|
3215
3130
|
function readFromEnvVars() {
|
|
3216
3131
|
const appId = process.env.app_id || process.env.APP_ID;
|
|
3217
3132
|
const tenantId = process.env.tenant_id || process.env.TENANT_ID;
|
|
@@ -3219,11 +3134,11 @@ function readFromEnvVars() {
|
|
|
3219
3134
|
}
|
|
3220
3135
|
function parseEnvFile(filePath) {
|
|
3221
3136
|
const result = {};
|
|
3222
|
-
if (!
|
|
3137
|
+
if (!fs10.existsSync(filePath)) {
|
|
3223
3138
|
return result;
|
|
3224
3139
|
}
|
|
3225
3140
|
try {
|
|
3226
|
-
const content =
|
|
3141
|
+
const content = fs10.readFileSync(filePath, "utf-8");
|
|
3227
3142
|
const lines = content.split("\n");
|
|
3228
3143
|
for (const line of lines) {
|
|
3229
3144
|
const trimmed = line.trim();
|
|
@@ -3240,7 +3155,7 @@ function parseEnvFile(filePath) {
|
|
|
3240
3155
|
return result;
|
|
3241
3156
|
}
|
|
3242
3157
|
function readFromForceEnvFile(cwd) {
|
|
3243
|
-
const envPath2 =
|
|
3158
|
+
const envPath2 = path8.join(cwd, ".force", "environment", "env");
|
|
3244
3159
|
const vars = parseEnvFile(envPath2);
|
|
3245
3160
|
return {
|
|
3246
3161
|
appId: vars.app_id || vars.APP_ID,
|
|
@@ -3263,7 +3178,7 @@ function readFromClientBasePath() {
|
|
|
3263
3178
|
return {};
|
|
3264
3179
|
}
|
|
3265
3180
|
function readFromDotEnv(cwd) {
|
|
3266
|
-
const envPath2 =
|
|
3181
|
+
const envPath2 = path8.join(cwd, ".env");
|
|
3267
3182
|
const vars = parseEnvFile(envPath2);
|
|
3268
3183
|
return {
|
|
3269
3184
|
appId: vars.app_id || vars.APP_ID,
|
|
@@ -3271,12 +3186,12 @@ function readFromDotEnv(cwd) {
|
|
|
3271
3186
|
};
|
|
3272
3187
|
}
|
|
3273
3188
|
function readFromPackageJson(cwd) {
|
|
3274
|
-
const pkgPath =
|
|
3275
|
-
if (!
|
|
3189
|
+
const pkgPath = path8.join(cwd, "package.json");
|
|
3190
|
+
if (!fs10.existsSync(pkgPath)) {
|
|
3276
3191
|
return {};
|
|
3277
3192
|
}
|
|
3278
3193
|
try {
|
|
3279
|
-
const content =
|
|
3194
|
+
const content = fs10.readFileSync(pkgPath, "utf-8");
|
|
3280
3195
|
const pkg2 = JSON.parse(content);
|
|
3281
3196
|
const appId = pkg2?.fullstack?.appId;
|
|
3282
3197
|
return appId ? { appId } : {};
|
|
@@ -3309,14 +3224,12 @@ function readProjectIdentity(cwd) {
|
|
|
3309
3224
|
}
|
|
3310
3225
|
|
|
3311
3226
|
// src/utils/grayscale/rules.ts
|
|
3312
|
-
|
|
3313
|
-
function isInPercentage(key, percentage) {
|
|
3227
|
+
function isInPercentage(tenantId, percentage) {
|
|
3314
3228
|
if (percentage <= 0) return false;
|
|
3315
3229
|
if (percentage >= 100) return true;
|
|
3316
|
-
const
|
|
3317
|
-
|
|
3318
|
-
|
|
3319
|
-
return value < threshold;
|
|
3230
|
+
const id = parseInt(tenantId, 10);
|
|
3231
|
+
if (isNaN(id)) return false;
|
|
3232
|
+
return id % 100 < percentage;
|
|
3320
3233
|
}
|
|
3321
3234
|
function matchConditions(rule, identity) {
|
|
3322
3235
|
const { conditions } = rule;
|
|
@@ -3331,9 +3244,7 @@ function matchConditions(rule, identity) {
|
|
|
3331
3244
|
}
|
|
3332
3245
|
}
|
|
3333
3246
|
if (conditions.percentage != null && conditions.percentage > 0) {
|
|
3334
|
-
|
|
3335
|
-
const hashValue = hashKey === "tenant_id" ? identity.tenantId : identity.appId;
|
|
3336
|
-
if (hashValue && isInPercentage(hashValue, conditions.percentage)) {
|
|
3247
|
+
if (identity.tenantId && isInPercentage(identity.tenantId, conditions.percentage)) {
|
|
3337
3248
|
return true;
|
|
3338
3249
|
}
|
|
3339
3250
|
}
|
|
@@ -3379,16 +3290,12 @@ function resolveTargetVersions(config, identity) {
|
|
|
3379
3290
|
}
|
|
3380
3291
|
|
|
3381
3292
|
// src/utils/grayscale/index.ts
|
|
3382
|
-
|
|
3383
|
-
const config =
|
|
3293
|
+
function resolveGrayscaleVersions(cwd, configJson) {
|
|
3294
|
+
const config = getGrayscaleConfig(configJson);
|
|
3384
3295
|
if (!config) {
|
|
3385
3296
|
console.log("[grayscale] Config not available, skipping grayscale");
|
|
3386
3297
|
return null;
|
|
3387
3298
|
}
|
|
3388
|
-
if (!config.enabled) {
|
|
3389
|
-
console.log("[grayscale] Grayscale is disabled");
|
|
3390
|
-
return null;
|
|
3391
|
-
}
|
|
3392
3299
|
const identity = readProjectIdentity(cwd);
|
|
3393
3300
|
if (!identity.appId && !identity.tenantId) {
|
|
3394
3301
|
console.log("[grayscale] No app_id or tenant_id found, skipping grayscale");
|
|
@@ -3507,7 +3414,7 @@ async function run4(options = {}) {
|
|
|
3507
3414
|
if (!options.skipGrayscale && !options.version) {
|
|
3508
3415
|
console.log("[fullstack-cli] Step 2/3: Checking grayscale config...");
|
|
3509
3416
|
try {
|
|
3510
|
-
const grayscaleVersions =
|
|
3417
|
+
const grayscaleVersions = resolveGrayscaleVersions(cwd, options.grayscaleConfig);
|
|
3511
3418
|
if (grayscaleVersions) {
|
|
3512
3419
|
console.log("[fullstack-cli] Step 3/3: Applying grayscale versions...");
|
|
3513
3420
|
installGrayscaleVersions(packages, grayscaleVersions, cwd, !!options.dryRun);
|
|
@@ -3548,7 +3455,7 @@ var depsCommand = {
|
|
|
3548
3455
|
name: "deps",
|
|
3549
3456
|
description: "Upgrade @lark-apaas dependencies",
|
|
3550
3457
|
register(parentCommand) {
|
|
3551
|
-
parentCommand.command(this.name).description(this.description).option("--version <version>", "Upgrade to specific version").option("--packages <packages>", "Only upgrade specific packages (comma-separated)").option("--skip-grayscale", "Skip grayscale version check").option("--dry-run", "Show upgrade plan without executing").action(async (options) => {
|
|
3458
|
+
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").action(async (options) => {
|
|
3552
3459
|
await run4(options);
|
|
3553
3460
|
});
|
|
3554
3461
|
}
|
|
@@ -3567,8 +3474,8 @@ var upgradeCommand = {
|
|
|
3567
3474
|
};
|
|
3568
3475
|
|
|
3569
3476
|
// src/commands/action-plugin/utils.ts
|
|
3570
|
-
import
|
|
3571
|
-
import
|
|
3477
|
+
import fs11 from "fs";
|
|
3478
|
+
import path9 from "path";
|
|
3572
3479
|
import { spawnSync as spawnSync4, execSync as execSync2 } from "child_process";
|
|
3573
3480
|
function parsePluginName(input) {
|
|
3574
3481
|
const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
|
|
@@ -3586,18 +3493,18 @@ function getProjectRoot() {
|
|
|
3586
3493
|
return process.cwd();
|
|
3587
3494
|
}
|
|
3588
3495
|
function getPackageJsonPath() {
|
|
3589
|
-
return
|
|
3496
|
+
return path9.join(getProjectRoot(), "package.json");
|
|
3590
3497
|
}
|
|
3591
3498
|
function getPluginPath(pluginName) {
|
|
3592
|
-
return
|
|
3499
|
+
return path9.join(getProjectRoot(), "node_modules", pluginName);
|
|
3593
3500
|
}
|
|
3594
3501
|
function readPackageJson2() {
|
|
3595
3502
|
const pkgPath = getPackageJsonPath();
|
|
3596
|
-
if (!
|
|
3503
|
+
if (!fs11.existsSync(pkgPath)) {
|
|
3597
3504
|
throw new Error("package.json not found in current directory");
|
|
3598
3505
|
}
|
|
3599
3506
|
try {
|
|
3600
|
-
const content =
|
|
3507
|
+
const content = fs11.readFileSync(pkgPath, "utf-8");
|
|
3601
3508
|
return JSON.parse(content);
|
|
3602
3509
|
} catch {
|
|
3603
3510
|
throw new Error("Failed to parse package.json");
|
|
@@ -3605,7 +3512,7 @@ function readPackageJson2() {
|
|
|
3605
3512
|
}
|
|
3606
3513
|
function writePackageJson2(pkg2) {
|
|
3607
3514
|
const pkgPath = getPackageJsonPath();
|
|
3608
|
-
|
|
3515
|
+
fs11.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
|
|
3609
3516
|
}
|
|
3610
3517
|
function readActionPlugins() {
|
|
3611
3518
|
const pkg2 = readPackageJson2();
|
|
@@ -3638,12 +3545,12 @@ function npmInstall(tgzPath) {
|
|
|
3638
3545
|
}
|
|
3639
3546
|
}
|
|
3640
3547
|
function getPackageVersion(pluginName) {
|
|
3641
|
-
const pkgJsonPath =
|
|
3642
|
-
if (!
|
|
3548
|
+
const pkgJsonPath = path9.join(getPluginPath(pluginName), "package.json");
|
|
3549
|
+
if (!fs11.existsSync(pkgJsonPath)) {
|
|
3643
3550
|
return null;
|
|
3644
3551
|
}
|
|
3645
3552
|
try {
|
|
3646
|
-
const content =
|
|
3553
|
+
const content = fs11.readFileSync(pkgJsonPath, "utf-8");
|
|
3647
3554
|
const pkg2 = JSON.parse(content);
|
|
3648
3555
|
return pkg2.version || null;
|
|
3649
3556
|
} catch {
|
|
@@ -3651,49 +3558,49 @@ function getPackageVersion(pluginName) {
|
|
|
3651
3558
|
}
|
|
3652
3559
|
}
|
|
3653
3560
|
function readPluginPackageJson(pluginPath) {
|
|
3654
|
-
const pkgJsonPath =
|
|
3655
|
-
if (!
|
|
3561
|
+
const pkgJsonPath = path9.join(pluginPath, "package.json");
|
|
3562
|
+
if (!fs11.existsSync(pkgJsonPath)) {
|
|
3656
3563
|
return null;
|
|
3657
3564
|
}
|
|
3658
3565
|
try {
|
|
3659
|
-
const content =
|
|
3566
|
+
const content = fs11.readFileSync(pkgJsonPath, "utf-8");
|
|
3660
3567
|
return JSON.parse(content);
|
|
3661
3568
|
} catch {
|
|
3662
3569
|
return null;
|
|
3663
3570
|
}
|
|
3664
3571
|
}
|
|
3665
3572
|
function extractTgzToNodeModules(tgzPath, pluginName) {
|
|
3666
|
-
const nodeModulesPath =
|
|
3667
|
-
const targetDir =
|
|
3668
|
-
const scopeDir =
|
|
3669
|
-
if (!
|
|
3670
|
-
|
|
3573
|
+
const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
|
|
3574
|
+
const targetDir = path9.join(nodeModulesPath, pluginName);
|
|
3575
|
+
const scopeDir = path9.dirname(targetDir);
|
|
3576
|
+
if (!fs11.existsSync(scopeDir)) {
|
|
3577
|
+
fs11.mkdirSync(scopeDir, { recursive: true });
|
|
3671
3578
|
}
|
|
3672
|
-
if (
|
|
3673
|
-
|
|
3579
|
+
if (fs11.existsSync(targetDir)) {
|
|
3580
|
+
fs11.rmSync(targetDir, { recursive: true });
|
|
3674
3581
|
}
|
|
3675
|
-
const tempDir =
|
|
3676
|
-
if (
|
|
3677
|
-
|
|
3582
|
+
const tempDir = path9.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
|
|
3583
|
+
if (fs11.existsSync(tempDir)) {
|
|
3584
|
+
fs11.rmSync(tempDir, { recursive: true });
|
|
3678
3585
|
}
|
|
3679
|
-
|
|
3586
|
+
fs11.mkdirSync(tempDir, { recursive: true });
|
|
3680
3587
|
try {
|
|
3681
3588
|
execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
|
|
3682
|
-
const extractedDir =
|
|
3683
|
-
if (
|
|
3684
|
-
|
|
3589
|
+
const extractedDir = path9.join(tempDir, "package");
|
|
3590
|
+
if (fs11.existsSync(extractedDir)) {
|
|
3591
|
+
fs11.renameSync(extractedDir, targetDir);
|
|
3685
3592
|
} else {
|
|
3686
|
-
const files =
|
|
3593
|
+
const files = fs11.readdirSync(tempDir);
|
|
3687
3594
|
if (files.length === 1) {
|
|
3688
|
-
|
|
3595
|
+
fs11.renameSync(path9.join(tempDir, files[0]), targetDir);
|
|
3689
3596
|
} else {
|
|
3690
3597
|
throw new Error("Unexpected tgz structure");
|
|
3691
3598
|
}
|
|
3692
3599
|
}
|
|
3693
3600
|
return targetDir;
|
|
3694
3601
|
} finally {
|
|
3695
|
-
if (
|
|
3696
|
-
|
|
3602
|
+
if (fs11.existsSync(tempDir)) {
|
|
3603
|
+
fs11.rmSync(tempDir, { recursive: true });
|
|
3697
3604
|
}
|
|
3698
3605
|
}
|
|
3699
3606
|
}
|
|
@@ -3702,10 +3609,10 @@ function checkMissingPeerDeps(peerDeps) {
|
|
|
3702
3609
|
return [];
|
|
3703
3610
|
}
|
|
3704
3611
|
const missing = [];
|
|
3705
|
-
const nodeModulesPath =
|
|
3612
|
+
const nodeModulesPath = path9.join(getProjectRoot(), "node_modules");
|
|
3706
3613
|
for (const [depName, _version] of Object.entries(peerDeps)) {
|
|
3707
|
-
const depPath =
|
|
3708
|
-
if (!
|
|
3614
|
+
const depPath = path9.join(nodeModulesPath, depName);
|
|
3615
|
+
if (!fs11.existsSync(depPath)) {
|
|
3709
3616
|
missing.push(depName);
|
|
3710
3617
|
}
|
|
3711
3618
|
}
|
|
@@ -3729,16 +3636,16 @@ function installMissingDeps(deps) {
|
|
|
3729
3636
|
}
|
|
3730
3637
|
function removePluginDirectory(pluginName) {
|
|
3731
3638
|
const pluginPath = getPluginPath(pluginName);
|
|
3732
|
-
if (
|
|
3733
|
-
|
|
3639
|
+
if (fs11.existsSync(pluginPath)) {
|
|
3640
|
+
fs11.rmSync(pluginPath, { recursive: true });
|
|
3734
3641
|
console.log(`[action-plugin] Removed ${pluginName}`);
|
|
3735
3642
|
}
|
|
3736
3643
|
}
|
|
3737
3644
|
|
|
3738
3645
|
// src/commands/action-plugin/api-client.ts
|
|
3739
3646
|
import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
|
|
3740
|
-
import
|
|
3741
|
-
import
|
|
3647
|
+
import fs12 from "fs";
|
|
3648
|
+
import path10 from "path";
|
|
3742
3649
|
var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
|
|
3743
3650
|
async function getPluginVersions(keys, latestOnly = true) {
|
|
3744
3651
|
const client = getHttpClient();
|
|
@@ -3802,19 +3709,19 @@ async function downloadFromPublic(downloadURL) {
|
|
|
3802
3709
|
return Buffer.from(arrayBuffer);
|
|
3803
3710
|
}
|
|
3804
3711
|
function getPluginCacheDir() {
|
|
3805
|
-
return
|
|
3712
|
+
return path10.join(process.cwd(), PLUGIN_CACHE_DIR);
|
|
3806
3713
|
}
|
|
3807
3714
|
function ensureCacheDir() {
|
|
3808
3715
|
const cacheDir = getPluginCacheDir();
|
|
3809
|
-
if (!
|
|
3810
|
-
|
|
3716
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3717
|
+
fs12.mkdirSync(cacheDir, { recursive: true });
|
|
3811
3718
|
}
|
|
3812
3719
|
}
|
|
3813
3720
|
function getTempFilePath(pluginKey, version) {
|
|
3814
3721
|
ensureCacheDir();
|
|
3815
3722
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
3816
3723
|
const filename = `${safeKey}@${version}.tgz`;
|
|
3817
|
-
return
|
|
3724
|
+
return path10.join(getPluginCacheDir(), filename);
|
|
3818
3725
|
}
|
|
3819
3726
|
var MAX_RETRIES = 2;
|
|
3820
3727
|
async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
|
|
@@ -3851,7 +3758,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
|
|
|
3851
3758
|
);
|
|
3852
3759
|
}
|
|
3853
3760
|
const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
|
|
3854
|
-
|
|
3761
|
+
fs12.writeFileSync(tgzPath, tgzBuffer);
|
|
3855
3762
|
console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
|
|
3856
3763
|
return {
|
|
3857
3764
|
tgzPath,
|
|
@@ -3865,18 +3772,18 @@ function getCachePath(pluginKey, version) {
|
|
|
3865
3772
|
ensureCacheDir();
|
|
3866
3773
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
3867
3774
|
const filename = `${safeKey}@${version}.tgz`;
|
|
3868
|
-
return
|
|
3775
|
+
return path10.join(getPluginCacheDir(), filename);
|
|
3869
3776
|
}
|
|
3870
3777
|
function hasCachedPlugin(pluginKey, version) {
|
|
3871
3778
|
const cachePath = getCachePath(pluginKey, version);
|
|
3872
|
-
return
|
|
3779
|
+
return fs12.existsSync(cachePath);
|
|
3873
3780
|
}
|
|
3874
3781
|
function listCachedPlugins() {
|
|
3875
3782
|
const cacheDir = getPluginCacheDir();
|
|
3876
|
-
if (!
|
|
3783
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3877
3784
|
return [];
|
|
3878
3785
|
}
|
|
3879
|
-
const files =
|
|
3786
|
+
const files = fs12.readdirSync(cacheDir);
|
|
3880
3787
|
const result = [];
|
|
3881
3788
|
for (const file of files) {
|
|
3882
3789
|
if (!file.endsWith(".tgz")) continue;
|
|
@@ -3884,8 +3791,8 @@ function listCachedPlugins() {
|
|
|
3884
3791
|
if (!match) continue;
|
|
3885
3792
|
const [, rawName, version] = match;
|
|
3886
3793
|
const name = rawName.replace(/^_/, "@").replace(/_/, "/");
|
|
3887
|
-
const filePath =
|
|
3888
|
-
const stat =
|
|
3794
|
+
const filePath = path10.join(cacheDir, file);
|
|
3795
|
+
const stat = fs12.statSync(filePath);
|
|
3889
3796
|
result.push({
|
|
3890
3797
|
name,
|
|
3891
3798
|
version,
|
|
@@ -3898,14 +3805,14 @@ function listCachedPlugins() {
|
|
|
3898
3805
|
}
|
|
3899
3806
|
function cleanAllCache() {
|
|
3900
3807
|
const cacheDir = getPluginCacheDir();
|
|
3901
|
-
if (!
|
|
3808
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3902
3809
|
return 0;
|
|
3903
3810
|
}
|
|
3904
|
-
const files =
|
|
3811
|
+
const files = fs12.readdirSync(cacheDir);
|
|
3905
3812
|
let count = 0;
|
|
3906
3813
|
for (const file of files) {
|
|
3907
3814
|
if (file.endsWith(".tgz")) {
|
|
3908
|
-
|
|
3815
|
+
fs12.unlinkSync(path10.join(cacheDir, file));
|
|
3909
3816
|
count++;
|
|
3910
3817
|
}
|
|
3911
3818
|
}
|
|
@@ -3913,21 +3820,21 @@ function cleanAllCache() {
|
|
|
3913
3820
|
}
|
|
3914
3821
|
function cleanPluginCache(pluginKey, version) {
|
|
3915
3822
|
const cacheDir = getPluginCacheDir();
|
|
3916
|
-
if (!
|
|
3823
|
+
if (!fs12.existsSync(cacheDir)) {
|
|
3917
3824
|
return 0;
|
|
3918
3825
|
}
|
|
3919
3826
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
3920
|
-
const files =
|
|
3827
|
+
const files = fs12.readdirSync(cacheDir);
|
|
3921
3828
|
let count = 0;
|
|
3922
3829
|
for (const file of files) {
|
|
3923
3830
|
if (version) {
|
|
3924
3831
|
if (file === `${safeKey}@${version}.tgz`) {
|
|
3925
|
-
|
|
3832
|
+
fs12.unlinkSync(path10.join(cacheDir, file));
|
|
3926
3833
|
count++;
|
|
3927
3834
|
}
|
|
3928
3835
|
} else {
|
|
3929
3836
|
if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
|
|
3930
|
-
|
|
3837
|
+
fs12.unlinkSync(path10.join(cacheDir, file));
|
|
3931
3838
|
count++;
|
|
3932
3839
|
}
|
|
3933
3840
|
}
|
|
@@ -4354,40 +4261,40 @@ var actionPluginCommandGroup = {
|
|
|
4354
4261
|
};
|
|
4355
4262
|
|
|
4356
4263
|
// src/commands/capability/utils.ts
|
|
4357
|
-
import
|
|
4264
|
+
import fs13 from "fs";
|
|
4358
4265
|
import { createRequire as createRequire2 } from "module";
|
|
4359
|
-
import
|
|
4266
|
+
import path11 from "path";
|
|
4360
4267
|
var CAPABILITIES_DIR = "server/capabilities";
|
|
4361
4268
|
function getProjectRoot2() {
|
|
4362
4269
|
return process.cwd();
|
|
4363
4270
|
}
|
|
4364
4271
|
function getCapabilitiesDir() {
|
|
4365
|
-
return
|
|
4272
|
+
return path11.join(getProjectRoot2(), CAPABILITIES_DIR);
|
|
4366
4273
|
}
|
|
4367
4274
|
function getCapabilityPath(id) {
|
|
4368
|
-
return
|
|
4275
|
+
return path11.join(getCapabilitiesDir(), `${id}.json`);
|
|
4369
4276
|
}
|
|
4370
4277
|
function getPluginManifestPath(pluginKey) {
|
|
4371
|
-
return
|
|
4278
|
+
return path11.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
|
|
4372
4279
|
}
|
|
4373
4280
|
function capabilitiesDirExists() {
|
|
4374
|
-
return
|
|
4281
|
+
return fs13.existsSync(getCapabilitiesDir());
|
|
4375
4282
|
}
|
|
4376
4283
|
function listCapabilityIds() {
|
|
4377
4284
|
const dir = getCapabilitiesDir();
|
|
4378
|
-
if (!
|
|
4285
|
+
if (!fs13.existsSync(dir)) {
|
|
4379
4286
|
return [];
|
|
4380
4287
|
}
|
|
4381
|
-
const files =
|
|
4288
|
+
const files = fs13.readdirSync(dir);
|
|
4382
4289
|
return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
|
|
4383
4290
|
}
|
|
4384
4291
|
function readCapability(id) {
|
|
4385
4292
|
const filePath = getCapabilityPath(id);
|
|
4386
|
-
if (!
|
|
4293
|
+
if (!fs13.existsSync(filePath)) {
|
|
4387
4294
|
throw new Error(`Capability not found: ${id}`);
|
|
4388
4295
|
}
|
|
4389
4296
|
try {
|
|
4390
|
-
const content =
|
|
4297
|
+
const content = fs13.readFileSync(filePath, "utf-8");
|
|
4391
4298
|
return JSON.parse(content);
|
|
4392
4299
|
} catch (error) {
|
|
4393
4300
|
if (error instanceof SyntaxError) {
|
|
@@ -4414,11 +4321,11 @@ function readAllCapabilities() {
|
|
|
4414
4321
|
}
|
|
4415
4322
|
function readPluginManifest(pluginKey) {
|
|
4416
4323
|
const manifestPath = getPluginManifestPath(pluginKey);
|
|
4417
|
-
if (!
|
|
4324
|
+
if (!fs13.existsSync(manifestPath)) {
|
|
4418
4325
|
throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
|
|
4419
4326
|
}
|
|
4420
4327
|
try {
|
|
4421
|
-
const content =
|
|
4328
|
+
const content = fs13.readFileSync(manifestPath, "utf-8");
|
|
4422
4329
|
return JSON.parse(content);
|
|
4423
4330
|
} catch (error) {
|
|
4424
4331
|
if (error instanceof SyntaxError) {
|
|
@@ -4435,7 +4342,7 @@ function hasValidParamsSchema(paramsSchema) {
|
|
|
4435
4342
|
}
|
|
4436
4343
|
async function loadPlugin(pluginKey) {
|
|
4437
4344
|
try {
|
|
4438
|
-
const userRequire = createRequire2(
|
|
4345
|
+
const userRequire = createRequire2(path11.join(getProjectRoot2(), "package.json"));
|
|
4439
4346
|
const resolvedPath = userRequire.resolve(pluginKey);
|
|
4440
4347
|
const pluginModule = await import(resolvedPath);
|
|
4441
4348
|
const pluginPackage = pluginModule.default ?? pluginModule;
|
|
@@ -4598,9 +4505,9 @@ var capabilityCommandGroup = {
|
|
|
4598
4505
|
import { execFile } from "child_process";
|
|
4599
4506
|
|
|
4600
4507
|
// src/commands/component/registry-preparer.ts
|
|
4601
|
-
import
|
|
4602
|
-
import
|
|
4603
|
-
import
|
|
4508
|
+
import fs14 from "fs";
|
|
4509
|
+
import path12 from "path";
|
|
4510
|
+
import os from "os";
|
|
4604
4511
|
|
|
4605
4512
|
// src/commands/component/service.ts
|
|
4606
4513
|
import { mapValues } from "es-toolkit";
|
|
@@ -4655,7 +4562,7 @@ async function sendInstallEvent(key) {
|
|
|
4655
4562
|
}
|
|
4656
4563
|
|
|
4657
4564
|
// src/commands/component/registry-preparer.ts
|
|
4658
|
-
var REGISTRY_TEMP_DIR =
|
|
4565
|
+
var REGISTRY_TEMP_DIR = path12.join(os.tmpdir(), "miaoda-registry");
|
|
4659
4566
|
function parseComponentKey(key) {
|
|
4660
4567
|
const match = key.match(/^@([^/]+)\/(.+)$/);
|
|
4661
4568
|
if (!match) {
|
|
@@ -4667,11 +4574,11 @@ function parseComponentKey(key) {
|
|
|
4667
4574
|
}
|
|
4668
4575
|
function getLocalRegistryPath(key) {
|
|
4669
4576
|
const { scope, name } = parseComponentKey(key);
|
|
4670
|
-
return
|
|
4577
|
+
return path12.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
|
|
4671
4578
|
}
|
|
4672
4579
|
function ensureDir(dirPath) {
|
|
4673
|
-
if (!
|
|
4674
|
-
|
|
4580
|
+
if (!fs14.existsSync(dirPath)) {
|
|
4581
|
+
fs14.mkdirSync(dirPath, { recursive: true });
|
|
4675
4582
|
}
|
|
4676
4583
|
}
|
|
4677
4584
|
async function prepareRecursive(key, visited) {
|
|
@@ -4704,8 +4611,8 @@ async function prepareRecursive(key, visited) {
|
|
|
4704
4611
|
registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
|
|
4705
4612
|
};
|
|
4706
4613
|
const localPath = getLocalRegistryPath(key);
|
|
4707
|
-
ensureDir(
|
|
4708
|
-
|
|
4614
|
+
ensureDir(path12.dirname(localPath));
|
|
4615
|
+
fs14.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
|
|
4709
4616
|
debug("\u4FDD\u5B58\u5230: %s", localPath);
|
|
4710
4617
|
}
|
|
4711
4618
|
async function prepareComponentRegistryItems(id) {
|
|
@@ -4715,18 +4622,18 @@ async function prepareComponentRegistryItems(id) {
|
|
|
4715
4622
|
}
|
|
4716
4623
|
function cleanupTempDir() {
|
|
4717
4624
|
try {
|
|
4718
|
-
if (
|
|
4719
|
-
|
|
4625
|
+
if (fs14.existsSync(REGISTRY_TEMP_DIR)) {
|
|
4626
|
+
fs14.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
|
|
4720
4627
|
}
|
|
4721
4628
|
} catch {
|
|
4722
4629
|
}
|
|
4723
4630
|
}
|
|
4724
4631
|
function getDownloadedRegistryItem(itemId) {
|
|
4725
4632
|
const localPath = getLocalRegistryPath(itemId);
|
|
4726
|
-
if (!
|
|
4633
|
+
if (!fs14.existsSync(localPath)) {
|
|
4727
4634
|
return null;
|
|
4728
4635
|
}
|
|
4729
|
-
const content =
|
|
4636
|
+
const content = fs14.readFileSync(localPath, "utf-8");
|
|
4730
4637
|
return JSON.parse(content);
|
|
4731
4638
|
}
|
|
4732
4639
|
|
|
@@ -4894,58 +4801,58 @@ var componentCommandGroup = {
|
|
|
4894
4801
|
};
|
|
4895
4802
|
|
|
4896
4803
|
// src/commands/migration/version-manager.ts
|
|
4897
|
-
import
|
|
4898
|
-
import
|
|
4804
|
+
import fs15 from "fs";
|
|
4805
|
+
import path13 from "path";
|
|
4899
4806
|
var PACKAGE_JSON = "package.json";
|
|
4900
4807
|
var VERSION_FIELD = "migrationVersion";
|
|
4901
4808
|
function getPackageJsonPath2() {
|
|
4902
|
-
return
|
|
4809
|
+
return path13.join(process.cwd(), PACKAGE_JSON);
|
|
4903
4810
|
}
|
|
4904
4811
|
function getCurrentVersion() {
|
|
4905
4812
|
const pkgPath = getPackageJsonPath2();
|
|
4906
|
-
if (!
|
|
4813
|
+
if (!fs15.existsSync(pkgPath)) {
|
|
4907
4814
|
throw new Error("package.json not found");
|
|
4908
4815
|
}
|
|
4909
|
-
const pkg2 = JSON.parse(
|
|
4816
|
+
const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
|
|
4910
4817
|
return pkg2[VERSION_FIELD] ?? 0;
|
|
4911
4818
|
}
|
|
4912
4819
|
function setCurrentVersion(version) {
|
|
4913
4820
|
const pkgPath = getPackageJsonPath2();
|
|
4914
|
-
const pkg2 = JSON.parse(
|
|
4821
|
+
const pkg2 = JSON.parse(fs15.readFileSync(pkgPath, "utf-8"));
|
|
4915
4822
|
pkg2[VERSION_FIELD] = version;
|
|
4916
|
-
|
|
4823
|
+
fs15.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
|
|
4917
4824
|
}
|
|
4918
4825
|
|
|
4919
4826
|
// src/commands/migration/versions/v001_capability/json-migrator/detector.ts
|
|
4920
|
-
import fs18 from "fs";
|
|
4921
|
-
import path16 from "path";
|
|
4922
|
-
|
|
4923
|
-
// src/commands/migration/versions/v001_capability/utils.ts
|
|
4924
4827
|
import fs17 from "fs";
|
|
4925
4828
|
import path15 from "path";
|
|
4829
|
+
|
|
4830
|
+
// src/commands/migration/versions/v001_capability/utils.ts
|
|
4831
|
+
import fs16 from "fs";
|
|
4832
|
+
import path14 from "path";
|
|
4926
4833
|
var CAPABILITIES_DIR2 = "server/capabilities";
|
|
4927
4834
|
function getProjectRoot3() {
|
|
4928
4835
|
return process.cwd();
|
|
4929
4836
|
}
|
|
4930
4837
|
function getCapabilitiesDir2() {
|
|
4931
|
-
return
|
|
4838
|
+
return path14.join(getProjectRoot3(), CAPABILITIES_DIR2);
|
|
4932
4839
|
}
|
|
4933
4840
|
function getPluginManifestPath2(pluginKey) {
|
|
4934
|
-
return
|
|
4841
|
+
return path14.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
|
|
4935
4842
|
}
|
|
4936
4843
|
|
|
4937
4844
|
// src/commands/migration/versions/v001_capability/json-migrator/detector.ts
|
|
4938
4845
|
function detectJsonMigration() {
|
|
4939
4846
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
4940
|
-
const oldFilePath =
|
|
4941
|
-
if (!
|
|
4847
|
+
const oldFilePath = path15.join(capabilitiesDir, "capabilities.json");
|
|
4848
|
+
if (!fs17.existsSync(oldFilePath)) {
|
|
4942
4849
|
return {
|
|
4943
4850
|
needsMigration: false,
|
|
4944
4851
|
reason: "capabilities.json not found"
|
|
4945
4852
|
};
|
|
4946
4853
|
}
|
|
4947
4854
|
try {
|
|
4948
|
-
const content =
|
|
4855
|
+
const content = fs17.readFileSync(oldFilePath, "utf-8");
|
|
4949
4856
|
const parsed = JSON.parse(content);
|
|
4950
4857
|
if (!Array.isArray(parsed)) {
|
|
4951
4858
|
return {
|
|
@@ -4996,8 +4903,8 @@ async function check(options) {
|
|
|
4996
4903
|
}
|
|
4997
4904
|
|
|
4998
4905
|
// src/commands/migration/versions/v001_capability/json-migrator/index.ts
|
|
4999
|
-
import
|
|
5000
|
-
import
|
|
4906
|
+
import fs18 from "fs";
|
|
4907
|
+
import path16 from "path";
|
|
5001
4908
|
|
|
5002
4909
|
// src/commands/migration/versions/v001_capability/mapping.ts
|
|
5003
4910
|
var DEFAULT_PLUGIN_VERSION = "1.0.0";
|
|
@@ -5227,18 +5134,18 @@ function transformCapabilities(oldCapabilities) {
|
|
|
5227
5134
|
// src/commands/migration/versions/v001_capability/json-migrator/index.ts
|
|
5228
5135
|
function loadExistingCapabilities() {
|
|
5229
5136
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
5230
|
-
if (!
|
|
5137
|
+
if (!fs18.existsSync(capabilitiesDir)) {
|
|
5231
5138
|
return [];
|
|
5232
5139
|
}
|
|
5233
|
-
const files =
|
|
5140
|
+
const files = fs18.readdirSync(capabilitiesDir);
|
|
5234
5141
|
const capabilities = [];
|
|
5235
5142
|
for (const file of files) {
|
|
5236
5143
|
if (file === "capabilities.json" || !file.endsWith(".json")) {
|
|
5237
5144
|
continue;
|
|
5238
5145
|
}
|
|
5239
5146
|
try {
|
|
5240
|
-
const filePath =
|
|
5241
|
-
const content =
|
|
5147
|
+
const filePath = path16.join(capabilitiesDir, file);
|
|
5148
|
+
const content = fs18.readFileSync(filePath, "utf-8");
|
|
5242
5149
|
const capability = JSON.parse(content);
|
|
5243
5150
|
if (capability.id && capability.pluginKey) {
|
|
5244
5151
|
capabilities.push(capability);
|
|
@@ -5296,9 +5203,9 @@ async function migrateJsonFiles(options) {
|
|
|
5296
5203
|
}
|
|
5297
5204
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
5298
5205
|
for (const cap of newCapabilities) {
|
|
5299
|
-
const filePath =
|
|
5206
|
+
const filePath = path16.join(capabilitiesDir, `${cap.id}.json`);
|
|
5300
5207
|
const content = JSON.stringify(cap, null, 2);
|
|
5301
|
-
|
|
5208
|
+
fs18.writeFileSync(filePath, content, "utf-8");
|
|
5302
5209
|
console.log(` \u2713 Created: ${cap.id}.json`);
|
|
5303
5210
|
}
|
|
5304
5211
|
return {
|
|
@@ -5310,11 +5217,11 @@ async function migrateJsonFiles(options) {
|
|
|
5310
5217
|
}
|
|
5311
5218
|
|
|
5312
5219
|
// src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
|
|
5313
|
-
import
|
|
5220
|
+
import fs19 from "fs";
|
|
5314
5221
|
function isPluginInstalled2(pluginKey) {
|
|
5315
5222
|
const actionPlugins = readActionPlugins();
|
|
5316
5223
|
const manifestPath = getPluginManifestPath2(pluginKey);
|
|
5317
|
-
return
|
|
5224
|
+
return fs19.existsSync(manifestPath) && !!actionPlugins[pluginKey];
|
|
5318
5225
|
}
|
|
5319
5226
|
function detectPluginsToInstall(capabilities) {
|
|
5320
5227
|
const pluginKeys = /* @__PURE__ */ new Set();
|
|
@@ -5390,12 +5297,12 @@ async function installPlugins(capabilities, options) {
|
|
|
5390
5297
|
}
|
|
5391
5298
|
|
|
5392
5299
|
// src/commands/migration/versions/v001_capability/code-migrator/index.ts
|
|
5393
|
-
import
|
|
5300
|
+
import path18 from "path";
|
|
5394
5301
|
import { Project as Project3 } from "ts-morph";
|
|
5395
5302
|
|
|
5396
5303
|
// src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
|
|
5397
|
-
import
|
|
5398
|
-
import
|
|
5304
|
+
import fs20 from "fs";
|
|
5305
|
+
import path17 from "path";
|
|
5399
5306
|
var EXCLUDED_DIRS = [
|
|
5400
5307
|
"node_modules",
|
|
5401
5308
|
"dist",
|
|
@@ -5410,9 +5317,9 @@ var EXCLUDED_PATTERNS = [
|
|
|
5410
5317
|
/\.d\.ts$/
|
|
5411
5318
|
];
|
|
5412
5319
|
function scanDirectory(dir, files = []) {
|
|
5413
|
-
const entries =
|
|
5320
|
+
const entries = fs20.readdirSync(dir, { withFileTypes: true });
|
|
5414
5321
|
for (const entry of entries) {
|
|
5415
|
-
const fullPath =
|
|
5322
|
+
const fullPath = path17.join(dir, entry.name);
|
|
5416
5323
|
if (entry.isDirectory()) {
|
|
5417
5324
|
if (EXCLUDED_DIRS.includes(entry.name)) {
|
|
5418
5325
|
continue;
|
|
@@ -5428,14 +5335,14 @@ function scanDirectory(dir, files = []) {
|
|
|
5428
5335
|
return files;
|
|
5429
5336
|
}
|
|
5430
5337
|
function scanServerFiles() {
|
|
5431
|
-
const serverDir =
|
|
5432
|
-
if (!
|
|
5338
|
+
const serverDir = path17.join(getProjectRoot3(), "server");
|
|
5339
|
+
if (!fs20.existsSync(serverDir)) {
|
|
5433
5340
|
return [];
|
|
5434
5341
|
}
|
|
5435
5342
|
return scanDirectory(serverDir);
|
|
5436
5343
|
}
|
|
5437
5344
|
function hasCapabilityImport(filePath) {
|
|
5438
|
-
const content =
|
|
5345
|
+
const content = fs20.readFileSync(filePath, "utf-8");
|
|
5439
5346
|
return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
|
|
5440
5347
|
}
|
|
5441
5348
|
function scanFilesToMigrate() {
|
|
@@ -5812,7 +5719,7 @@ function analyzeFile(project, filePath, actionNameMap) {
|
|
|
5812
5719
|
const callSites = analyzeCallSites(sourceFile, imports);
|
|
5813
5720
|
const classInfo = analyzeClass(sourceFile);
|
|
5814
5721
|
const { canMigrate, reason } = canAutoMigrate(classInfo);
|
|
5815
|
-
const relativePath =
|
|
5722
|
+
const relativePath = path18.relative(getProjectRoot3(), filePath);
|
|
5816
5723
|
return {
|
|
5817
5724
|
filePath: relativePath,
|
|
5818
5725
|
imports,
|
|
@@ -5823,7 +5730,7 @@ function analyzeFile(project, filePath, actionNameMap) {
|
|
|
5823
5730
|
};
|
|
5824
5731
|
}
|
|
5825
5732
|
function migrateFile(project, analysis, dryRun) {
|
|
5826
|
-
const absolutePath =
|
|
5733
|
+
const absolutePath = path18.join(getProjectRoot3(), analysis.filePath);
|
|
5827
5734
|
if (!analysis.canAutoMigrate) {
|
|
5828
5735
|
return {
|
|
5829
5736
|
filePath: analysis.filePath,
|
|
@@ -5926,17 +5833,17 @@ function getSuggestion(analysis) {
|
|
|
5926
5833
|
}
|
|
5927
5834
|
|
|
5928
5835
|
// src/commands/migration/versions/v001_capability/cleanup.ts
|
|
5929
|
-
import
|
|
5930
|
-
import
|
|
5836
|
+
import fs21 from "fs";
|
|
5837
|
+
import path19 from "path";
|
|
5931
5838
|
function cleanupOldFiles(capabilities, dryRun) {
|
|
5932
5839
|
const deletedFiles = [];
|
|
5933
5840
|
const errors = [];
|
|
5934
5841
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
5935
|
-
const oldJsonPath =
|
|
5936
|
-
if (
|
|
5842
|
+
const oldJsonPath = path19.join(capabilitiesDir, "capabilities.json");
|
|
5843
|
+
if (fs21.existsSync(oldJsonPath)) {
|
|
5937
5844
|
try {
|
|
5938
5845
|
if (!dryRun) {
|
|
5939
|
-
|
|
5846
|
+
fs21.unlinkSync(oldJsonPath);
|
|
5940
5847
|
}
|
|
5941
5848
|
deletedFiles.push("capabilities.json");
|
|
5942
5849
|
} catch (error) {
|
|
@@ -5944,11 +5851,11 @@ function cleanupOldFiles(capabilities, dryRun) {
|
|
|
5944
5851
|
}
|
|
5945
5852
|
}
|
|
5946
5853
|
for (const cap of capabilities) {
|
|
5947
|
-
const tsFilePath =
|
|
5948
|
-
if (
|
|
5854
|
+
const tsFilePath = path19.join(capabilitiesDir, `${cap.id}.ts`);
|
|
5855
|
+
if (fs21.existsSync(tsFilePath)) {
|
|
5949
5856
|
try {
|
|
5950
5857
|
if (!dryRun) {
|
|
5951
|
-
|
|
5858
|
+
fs21.unlinkSync(tsFilePath);
|
|
5952
5859
|
}
|
|
5953
5860
|
deletedFiles.push(`${cap.id}.ts`);
|
|
5954
5861
|
} catch (error) {
|
|
@@ -5964,8 +5871,8 @@ function cleanupOldFiles(capabilities, dryRun) {
|
|
|
5964
5871
|
}
|
|
5965
5872
|
|
|
5966
5873
|
// src/commands/migration/versions/v001_capability/report-generator.ts
|
|
5967
|
-
import
|
|
5968
|
-
import
|
|
5874
|
+
import fs22 from "fs";
|
|
5875
|
+
import path20 from "path";
|
|
5969
5876
|
var REPORT_FILE = "capability-migration-report.md";
|
|
5970
5877
|
function printSummary(result) {
|
|
5971
5878
|
const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
|
|
@@ -6128,15 +6035,15 @@ async function generateReport(result) {
|
|
|
6128
6035
|
}
|
|
6129
6036
|
lines.push("");
|
|
6130
6037
|
const logDir = process.env.LOG_DIR || "logs";
|
|
6131
|
-
if (!
|
|
6038
|
+
if (!fs22.existsSync(logDir)) {
|
|
6132
6039
|
return;
|
|
6133
6040
|
}
|
|
6134
|
-
const reportDir =
|
|
6135
|
-
if (!
|
|
6136
|
-
|
|
6041
|
+
const reportDir = path20.join(logDir, "migration");
|
|
6042
|
+
if (!fs22.existsSync(reportDir)) {
|
|
6043
|
+
fs22.mkdirSync(reportDir, { recursive: true });
|
|
6137
6044
|
}
|
|
6138
|
-
const reportPath =
|
|
6139
|
-
|
|
6045
|
+
const reportPath = path20.join(reportDir, REPORT_FILE);
|
|
6046
|
+
fs22.writeFileSync(reportPath, lines.join("\n"), "utf-8");
|
|
6140
6047
|
console.log(`\u{1F4C4} Report generated: ${reportPath}`);
|
|
6141
6048
|
}
|
|
6142
6049
|
|
|
@@ -6668,10 +6575,10 @@ var migrationCommand = {
|
|
|
6668
6575
|
};
|
|
6669
6576
|
|
|
6670
6577
|
// src/commands/read-logs/index.ts
|
|
6671
|
-
import
|
|
6578
|
+
import path21 from "path";
|
|
6672
6579
|
|
|
6673
6580
|
// src/commands/read-logs/std-utils.ts
|
|
6674
|
-
import
|
|
6581
|
+
import fs23 from "fs";
|
|
6675
6582
|
function formatStdPrefixTime(localTime) {
|
|
6676
6583
|
const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
|
|
6677
6584
|
if (!match) return localTime;
|
|
@@ -6701,11 +6608,11 @@ function stripPrefixFromStdLine(line) {
|
|
|
6701
6608
|
return `[${time}] ${content}`;
|
|
6702
6609
|
}
|
|
6703
6610
|
function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
|
|
6704
|
-
const stat =
|
|
6611
|
+
const stat = fs23.statSync(filePath);
|
|
6705
6612
|
if (stat.size === 0) {
|
|
6706
6613
|
return { lines: [], markerFound: false, totalLinesCount: 0 };
|
|
6707
6614
|
}
|
|
6708
|
-
const fd =
|
|
6615
|
+
const fd = fs23.openSync(filePath, "r");
|
|
6709
6616
|
const chunkSize = 64 * 1024;
|
|
6710
6617
|
let position = stat.size;
|
|
6711
6618
|
let remainder = "";
|
|
@@ -6719,7 +6626,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
|
|
|
6719
6626
|
const length = Math.min(chunkSize, position);
|
|
6720
6627
|
position -= length;
|
|
6721
6628
|
const buffer = Buffer.alloc(length);
|
|
6722
|
-
|
|
6629
|
+
fs23.readSync(fd, buffer, 0, length, position);
|
|
6723
6630
|
let chunk = buffer.toString("utf8");
|
|
6724
6631
|
if (remainder) {
|
|
6725
6632
|
chunk += remainder;
|
|
@@ -6761,7 +6668,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
|
|
|
6761
6668
|
}
|
|
6762
6669
|
}
|
|
6763
6670
|
} finally {
|
|
6764
|
-
|
|
6671
|
+
fs23.closeSync(fd);
|
|
6765
6672
|
}
|
|
6766
6673
|
return { lines: collected.reverse(), markerFound, totalLinesCount };
|
|
6767
6674
|
}
|
|
@@ -6782,21 +6689,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
|
|
|
6782
6689
|
}
|
|
6783
6690
|
|
|
6784
6691
|
// src/commands/read-logs/tail.ts
|
|
6785
|
-
import
|
|
6692
|
+
import fs24 from "fs";
|
|
6786
6693
|
function fileExists(filePath) {
|
|
6787
6694
|
try {
|
|
6788
|
-
|
|
6695
|
+
fs24.accessSync(filePath, fs24.constants.F_OK | fs24.constants.R_OK);
|
|
6789
6696
|
return true;
|
|
6790
6697
|
} catch {
|
|
6791
6698
|
return false;
|
|
6792
6699
|
}
|
|
6793
6700
|
}
|
|
6794
6701
|
function readFileTailLines(filePath, maxLines) {
|
|
6795
|
-
const stat =
|
|
6702
|
+
const stat = fs24.statSync(filePath);
|
|
6796
6703
|
if (stat.size === 0) {
|
|
6797
6704
|
return [];
|
|
6798
6705
|
}
|
|
6799
|
-
const fd =
|
|
6706
|
+
const fd = fs24.openSync(filePath, "r");
|
|
6800
6707
|
const chunkSize = 64 * 1024;
|
|
6801
6708
|
const chunks = [];
|
|
6802
6709
|
let position = stat.size;
|
|
@@ -6806,13 +6713,13 @@ function readFileTailLines(filePath, maxLines) {
|
|
|
6806
6713
|
const length = Math.min(chunkSize, position);
|
|
6807
6714
|
position -= length;
|
|
6808
6715
|
const buffer = Buffer.alloc(length);
|
|
6809
|
-
|
|
6716
|
+
fs24.readSync(fd, buffer, 0, length, position);
|
|
6810
6717
|
chunks.unshift(buffer.toString("utf8"));
|
|
6811
6718
|
const chunkLines = buffer.toString("utf8").split("\n").length - 1;
|
|
6812
6719
|
collectedLines += chunkLines;
|
|
6813
6720
|
}
|
|
6814
6721
|
} finally {
|
|
6815
|
-
|
|
6722
|
+
fs24.closeSync(fd);
|
|
6816
6723
|
}
|
|
6817
6724
|
const content = chunks.join("");
|
|
6818
6725
|
const allLines = content.split("\n");
|
|
@@ -6828,11 +6735,11 @@ function readFileTailLines(filePath, maxLines) {
|
|
|
6828
6735
|
return allLines.slice(allLines.length - maxLines);
|
|
6829
6736
|
}
|
|
6830
6737
|
function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
6831
|
-
const stat =
|
|
6738
|
+
const stat = fs24.statSync(filePath);
|
|
6832
6739
|
if (stat.size === 0) {
|
|
6833
6740
|
return { lines: [], totalLinesCount: 0 };
|
|
6834
6741
|
}
|
|
6835
|
-
const fd =
|
|
6742
|
+
const fd = fs24.openSync(filePath, "r");
|
|
6836
6743
|
const chunkSize = 64 * 1024;
|
|
6837
6744
|
let position = stat.size;
|
|
6838
6745
|
let remainder = "";
|
|
@@ -6844,7 +6751,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
|
6844
6751
|
const length = Math.min(chunkSize, position);
|
|
6845
6752
|
position -= length;
|
|
6846
6753
|
const buffer = Buffer.alloc(length);
|
|
6847
|
-
|
|
6754
|
+
fs24.readSync(fd, buffer, 0, length, position);
|
|
6848
6755
|
let chunk = buffer.toString("utf8");
|
|
6849
6756
|
if (remainder) {
|
|
6850
6757
|
chunk += remainder;
|
|
@@ -6875,7 +6782,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
|
6875
6782
|
}
|
|
6876
6783
|
}
|
|
6877
6784
|
} finally {
|
|
6878
|
-
|
|
6785
|
+
fs24.closeSync(fd);
|
|
6879
6786
|
}
|
|
6880
6787
|
return { lines: collected.reverse(), totalLinesCount };
|
|
6881
6788
|
}
|
|
@@ -7017,7 +6924,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
|
|
|
7017
6924
|
}
|
|
7018
6925
|
|
|
7019
6926
|
// src/commands/read-logs/json-lines.ts
|
|
7020
|
-
import
|
|
6927
|
+
import fs25 from "fs";
|
|
7021
6928
|
function normalizePid(value) {
|
|
7022
6929
|
if (typeof value === "number") {
|
|
7023
6930
|
return String(value);
|
|
@@ -7068,11 +6975,11 @@ function buildWantedLevelSet(levels) {
|
|
|
7068
6975
|
return set.size > 0 ? set : null;
|
|
7069
6976
|
}
|
|
7070
6977
|
function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
7071
|
-
const stat =
|
|
6978
|
+
const stat = fs25.statSync(filePath);
|
|
7072
6979
|
if (stat.size === 0) {
|
|
7073
6980
|
return { lines: [], totalLinesCount: 0 };
|
|
7074
6981
|
}
|
|
7075
|
-
const fd =
|
|
6982
|
+
const fd = fs25.openSync(filePath, "r");
|
|
7076
6983
|
const chunkSize = 64 * 1024;
|
|
7077
6984
|
let position = stat.size;
|
|
7078
6985
|
let remainder = "";
|
|
@@ -7087,7 +6994,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
|
7087
6994
|
const length = Math.min(chunkSize, position);
|
|
7088
6995
|
position -= length;
|
|
7089
6996
|
const buffer = Buffer.alloc(length);
|
|
7090
|
-
|
|
6997
|
+
fs25.readSync(fd, buffer, 0, length, position);
|
|
7091
6998
|
let chunk = buffer.toString("utf8");
|
|
7092
6999
|
if (remainder) {
|
|
7093
7000
|
chunk += remainder;
|
|
@@ -7149,7 +7056,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
|
7149
7056
|
}
|
|
7150
7057
|
}
|
|
7151
7058
|
} finally {
|
|
7152
|
-
|
|
7059
|
+
fs25.closeSync(fd);
|
|
7153
7060
|
}
|
|
7154
7061
|
return { lines: collected.reverse(), totalLinesCount };
|
|
7155
7062
|
}
|
|
@@ -7192,11 +7099,11 @@ function extractTraceId(obj) {
|
|
|
7192
7099
|
function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
7193
7100
|
const wanted = traceId.trim();
|
|
7194
7101
|
if (!wanted) return { lines: [], totalLinesCount: 0 };
|
|
7195
|
-
const stat =
|
|
7102
|
+
const stat = fs25.statSync(filePath);
|
|
7196
7103
|
if (stat.size === 0) {
|
|
7197
7104
|
return { lines: [], totalLinesCount: 0 };
|
|
7198
7105
|
}
|
|
7199
|
-
const fd =
|
|
7106
|
+
const fd = fs25.openSync(filePath, "r");
|
|
7200
7107
|
const chunkSize = 64 * 1024;
|
|
7201
7108
|
let position = stat.size;
|
|
7202
7109
|
let remainder = "";
|
|
@@ -7209,7 +7116,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
|
7209
7116
|
const length = Math.min(chunkSize, position);
|
|
7210
7117
|
position -= length;
|
|
7211
7118
|
const buffer = Buffer.alloc(length);
|
|
7212
|
-
|
|
7119
|
+
fs25.readSync(fd, buffer, 0, length, position);
|
|
7213
7120
|
let chunk = buffer.toString("utf8");
|
|
7214
7121
|
if (remainder) {
|
|
7215
7122
|
chunk += remainder;
|
|
@@ -7262,7 +7169,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
|
7262
7169
|
}
|
|
7263
7170
|
}
|
|
7264
7171
|
} finally {
|
|
7265
|
-
|
|
7172
|
+
fs25.closeSync(fd);
|
|
7266
7173
|
}
|
|
7267
7174
|
return { lines: collected.reverse(), totalLinesCount };
|
|
7268
7175
|
}
|
|
@@ -7271,11 +7178,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
7271
7178
|
if (!wantedLevelSet) {
|
|
7272
7179
|
return { lines: [], totalLinesCount: 0 };
|
|
7273
7180
|
}
|
|
7274
|
-
const stat =
|
|
7181
|
+
const stat = fs25.statSync(filePath);
|
|
7275
7182
|
if (stat.size === 0) {
|
|
7276
7183
|
return { lines: [], totalLinesCount: 0 };
|
|
7277
7184
|
}
|
|
7278
|
-
const fd =
|
|
7185
|
+
const fd = fs25.openSync(filePath, "r");
|
|
7279
7186
|
const chunkSize = 64 * 1024;
|
|
7280
7187
|
let position = stat.size;
|
|
7281
7188
|
let remainder = "";
|
|
@@ -7287,7 +7194,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
7287
7194
|
const length = Math.min(chunkSize, position);
|
|
7288
7195
|
position -= length;
|
|
7289
7196
|
const buffer = Buffer.alloc(length);
|
|
7290
|
-
|
|
7197
|
+
fs25.readSync(fd, buffer, 0, length, position);
|
|
7291
7198
|
let chunk = buffer.toString("utf8");
|
|
7292
7199
|
if (remainder) {
|
|
7293
7200
|
chunk += remainder;
|
|
@@ -7334,7 +7241,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
7334
7241
|
}
|
|
7335
7242
|
}
|
|
7336
7243
|
} finally {
|
|
7337
|
-
|
|
7244
|
+
fs25.closeSync(fd);
|
|
7338
7245
|
}
|
|
7339
7246
|
return { lines: collected.reverse(), totalLinesCount };
|
|
7340
7247
|
}
|
|
@@ -7568,30 +7475,30 @@ async function readLogsJsonResult(options) {
|
|
|
7568
7475
|
};
|
|
7569
7476
|
}
|
|
7570
7477
|
function resolveLogFilePath(logDir, type) {
|
|
7571
|
-
const base =
|
|
7478
|
+
const base = path21.isAbsolute(logDir) ? logDir : path21.join(process.cwd(), logDir);
|
|
7572
7479
|
if (type === "server") {
|
|
7573
|
-
return
|
|
7480
|
+
return path21.join(base, "server.log");
|
|
7574
7481
|
}
|
|
7575
7482
|
if (type === "trace") {
|
|
7576
|
-
return
|
|
7483
|
+
return path21.join(base, "trace.log");
|
|
7577
7484
|
}
|
|
7578
7485
|
if (type === "server-std") {
|
|
7579
|
-
return
|
|
7486
|
+
return path21.join(base, "server.std.log");
|
|
7580
7487
|
}
|
|
7581
7488
|
if (type === "client-std") {
|
|
7582
|
-
return
|
|
7489
|
+
return path21.join(base, "client.std.log");
|
|
7583
7490
|
}
|
|
7584
7491
|
if (type === "dev") {
|
|
7585
|
-
return
|
|
7492
|
+
return path21.join(base, "dev.log");
|
|
7586
7493
|
}
|
|
7587
7494
|
if (type === "dev-std") {
|
|
7588
|
-
return
|
|
7495
|
+
return path21.join(base, "dev.std.log");
|
|
7589
7496
|
}
|
|
7590
7497
|
if (type === "install-dep-std") {
|
|
7591
|
-
return
|
|
7498
|
+
return path21.join(base, "install-dep.std.log");
|
|
7592
7499
|
}
|
|
7593
7500
|
if (type === "browser") {
|
|
7594
|
-
return
|
|
7501
|
+
return path21.join(base, "browser.log");
|
|
7595
7502
|
}
|
|
7596
7503
|
throw new Error(`Unsupported log type: ${type}`);
|
|
7597
7504
|
}
|
|
@@ -7768,9 +7675,9 @@ function camelToKebab(str) {
|
|
|
7768
7675
|
}
|
|
7769
7676
|
|
|
7770
7677
|
// src/commands/build/upload-static.handler.ts
|
|
7771
|
-
import * as
|
|
7772
|
-
import * as
|
|
7773
|
-
import * as
|
|
7678
|
+
import * as fs26 from "fs";
|
|
7679
|
+
import * as os2 from "os";
|
|
7680
|
+
import * as path22 from "path";
|
|
7774
7681
|
import { execFileSync } from "child_process";
|
|
7775
7682
|
function readCredentialsFromEnv() {
|
|
7776
7683
|
const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
|
|
@@ -7794,8 +7701,8 @@ async function uploadStatic(options) {
|
|
|
7794
7701
|
endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
|
|
7795
7702
|
region = UPLOAD_STATIC_DEFAULTS.region
|
|
7796
7703
|
} = options;
|
|
7797
|
-
const resolvedStaticDir =
|
|
7798
|
-
if (!
|
|
7704
|
+
const resolvedStaticDir = path22.resolve(staticDir);
|
|
7705
|
+
if (!fs26.existsSync(resolvedStaticDir)) {
|
|
7799
7706
|
console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
|
|
7800
7707
|
return;
|
|
7801
7708
|
}
|
|
@@ -7828,8 +7735,8 @@ async function uploadStatic(options) {
|
|
|
7828
7735
|
({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
|
|
7829
7736
|
}
|
|
7830
7737
|
console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
|
|
7831
|
-
const confPath =
|
|
7832
|
-
|
|
7738
|
+
const confPath = path22.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
|
|
7739
|
+
fs26.writeFileSync(confPath, "");
|
|
7833
7740
|
try {
|
|
7834
7741
|
console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
|
|
7835
7742
|
configureTosutil(resolvedTosutil, confPath, {
|
|
@@ -7843,7 +7750,7 @@ async function uploadStatic(options) {
|
|
|
7843
7750
|
uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
|
|
7844
7751
|
} finally {
|
|
7845
7752
|
try {
|
|
7846
|
-
|
|
7753
|
+
fs26.unlinkSync(confPath);
|
|
7847
7754
|
} catch {
|
|
7848
7755
|
}
|
|
7849
7756
|
}
|
|
@@ -7863,8 +7770,8 @@ async function uploadStatic(options) {
|
|
|
7863
7770
|
}
|
|
7864
7771
|
}
|
|
7865
7772
|
function resolveTosutilPath(tosutilPath) {
|
|
7866
|
-
if (
|
|
7867
|
-
return
|
|
7773
|
+
if (path22.isAbsolute(tosutilPath)) {
|
|
7774
|
+
return fs26.existsSync(tosutilPath) ? tosutilPath : null;
|
|
7868
7775
|
}
|
|
7869
7776
|
try {
|
|
7870
7777
|
const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
|
|
@@ -7909,7 +7816,7 @@ async function resolveBucketId(appId) {
|
|
|
7909
7816
|
return bucketId;
|
|
7910
7817
|
}
|
|
7911
7818
|
function isDirEmpty(dirPath) {
|
|
7912
|
-
const entries =
|
|
7819
|
+
const entries = fs26.readdirSync(dirPath);
|
|
7913
7820
|
return entries.length === 0;
|
|
7914
7821
|
}
|
|
7915
7822
|
|
|
@@ -8004,12 +7911,12 @@ var commands = [
|
|
|
8004
7911
|
];
|
|
8005
7912
|
|
|
8006
7913
|
// src/index.ts
|
|
8007
|
-
var envPath =
|
|
8008
|
-
if (
|
|
7914
|
+
var envPath = path23.join(process.cwd(), ".env");
|
|
7915
|
+
if (fs27.existsSync(envPath)) {
|
|
8009
7916
|
dotenvConfig({ path: envPath });
|
|
8010
7917
|
}
|
|
8011
|
-
var __dirname =
|
|
8012
|
-
var pkg = JSON.parse(
|
|
7918
|
+
var __dirname = path23.dirname(fileURLToPath5(import.meta.url));
|
|
7919
|
+
var pkg = JSON.parse(fs27.readFileSync(path23.join(__dirname, "../package.json"), "utf-8"));
|
|
8013
7920
|
var cli = new FullstackCLI(pkg.version);
|
|
8014
7921
|
cli.useAll(commands);
|
|
8015
7922
|
cli.run();
|