@lark-apaas/fullstack-cli 1.1.72-alpha.20261114063639 → 1.1.72-alpha.20261117064304
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
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { fileURLToPath as
|
|
2
|
+
import fs34 from "fs";
|
|
3
|
+
import path27 from "path";
|
|
4
|
+
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
5
5
|
import { config as dotenvConfig } from "dotenv";
|
|
6
6
|
|
|
7
7
|
// src/cli.ts
|
|
@@ -3458,7 +3458,7 @@ function getCliVersion() {
|
|
|
3458
3458
|
}
|
|
3459
3459
|
|
|
3460
3460
|
// src/commands/upgrade/get-upgrade-files.ts
|
|
3461
|
-
function getUpgradeFilesToStage(disableGenOpenapi = true, userProjectRoot = process.env.INIT_CWD || process.cwd()
|
|
3461
|
+
function getUpgradeFilesToStage(disableGenOpenapi = true, userProjectRoot = process.env.INIT_CWD || process.cwd()) {
|
|
3462
3462
|
const stack = resolveStack(userProjectRoot);
|
|
3463
3463
|
const isNestjs = isNestjsProject(userProjectRoot, stack);
|
|
3464
3464
|
const syncConfig = genSyncConfig(stack, { disableGenOpenapi });
|
|
@@ -3475,63 +3475,11 @@ function getUpgradeFilesToStage(disableGenOpenapi = true, userProjectRoot = proc
|
|
|
3475
3475
|
filesToStage.add(rule.to);
|
|
3476
3476
|
}
|
|
3477
3477
|
});
|
|
3478
|
-
if (isNestjs && includeOxlintConfig) filesToStage.add("oxlint.config.ts");
|
|
3479
3478
|
filesToStage.add("package.json");
|
|
3480
3479
|
filesToStage.add("package-lock.json");
|
|
3481
3480
|
return Array.from(filesToStage);
|
|
3482
3481
|
}
|
|
3483
3482
|
|
|
3484
|
-
// src/commands/upgrade/oxlint-config.ts
|
|
3485
|
-
import fs13 from "fs";
|
|
3486
|
-
import path10 from "path";
|
|
3487
|
-
import { createRequire as createRequire2 } from "module";
|
|
3488
|
-
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
3489
|
-
async function prepareOxlintConfig(projectRoot) {
|
|
3490
|
-
if (!isNestjsProject(projectRoot, resolveStack(projectRoot)))
|
|
3491
|
-
return "not-nestjs";
|
|
3492
|
-
const existing = [
|
|
3493
|
-
"oxlint.config.ts",
|
|
3494
|
-
"oxlint.config.mts",
|
|
3495
|
-
"oxlint.config.cts",
|
|
3496
|
-
"oxlint.config.js",
|
|
3497
|
-
"oxlint.config.mjs",
|
|
3498
|
-
"oxlint.config.cjs",
|
|
3499
|
-
".oxlintrc.json"
|
|
3500
|
-
];
|
|
3501
|
-
if (existing.some((name) => fs13.existsSync(path10.join(projectRoot, name))))
|
|
3502
|
-
return "existing";
|
|
3503
|
-
const request = createRequire2(path10.join(projectRoot, "package.json"));
|
|
3504
|
-
const pluginRoot = path10.resolve(
|
|
3505
|
-
path10.dirname(fileURLToPath5(import.meta.url)),
|
|
3506
|
-
".."
|
|
3507
|
-
);
|
|
3508
|
-
const bundled = path10.join(pluginRoot, "templates/oxlint");
|
|
3509
|
-
const assets = fs13.existsSync(bundled) ? bundled : path10.resolve(
|
|
3510
|
-
path10.dirname(fileURLToPath5(import.meta.url)),
|
|
3511
|
-
"../../..",
|
|
3512
|
-
"templates/oxlint"
|
|
3513
|
-
);
|
|
3514
|
-
const eslintFile = path10.join(projectRoot, "eslint.config.js");
|
|
3515
|
-
const normalize = (text) => text.replace(/^\uFEFF/, "").replace(/\r\n/g, "\n");
|
|
3516
|
-
const current = normalize(fs13.readFileSync(eslintFile, "utf8"));
|
|
3517
|
-
const original = normalize(
|
|
3518
|
-
fs13.readFileSync(path10.join(assets, "eslint.config.js.reference"), "utf8")
|
|
3519
|
-
);
|
|
3520
|
-
if (current === original) {
|
|
3521
|
-
fs13.copyFileSync(
|
|
3522
|
-
path10.join(assets, "oxlint.config.ts"),
|
|
3523
|
-
path10.join(projectRoot, "oxlint.config.ts"),
|
|
3524
|
-
fs13.constants.COPYFILE_EXCL
|
|
3525
|
-
);
|
|
3526
|
-
return "template";
|
|
3527
|
-
}
|
|
3528
|
-
const { generateOxlintConfig } = request(
|
|
3529
|
-
"@lark-apaas/fullstack-presets/lib/oxlint/upgrade.js"
|
|
3530
|
-
);
|
|
3531
|
-
await generateOxlintConfig({ projectRoot });
|
|
3532
|
-
return "generated";
|
|
3533
|
-
}
|
|
3534
|
-
|
|
3535
3483
|
// src/commands/upgrade/run.handler.ts
|
|
3536
3484
|
async function run3(options = {}) {
|
|
3537
3485
|
const userProjectRoot = process.env.INIT_CWD || process.cwd();
|
|
@@ -3539,7 +3487,6 @@ async function run3(options = {}) {
|
|
|
3539
3487
|
try {
|
|
3540
3488
|
console.log("[fullstack-cli] Step 1/3: Syncing template files...");
|
|
3541
3489
|
await run2({ disableGenOpenapi: options.disableGenOpenapi ?? true });
|
|
3542
|
-
const oxlintStatus = await prepareOxlintConfig(userProjectRoot);
|
|
3543
3490
|
console.log("[fullstack-cli] Step 2/3: Cleaning up package.json...");
|
|
3544
3491
|
const cleaned = cleanupPackageJson(userProjectRoot);
|
|
3545
3492
|
if (!cleaned) {
|
|
@@ -3551,8 +3498,7 @@ async function run3(options = {}) {
|
|
|
3551
3498
|
const version = getCliVersion();
|
|
3552
3499
|
const filesToStage = getUpgradeFilesToStage(
|
|
3553
3500
|
options.disableGenOpenapi ?? true,
|
|
3554
|
-
userProjectRoot
|
|
3555
|
-
oxlintStatus === "template" || oxlintStatus === "generated"
|
|
3501
|
+
userProjectRoot
|
|
3556
3502
|
);
|
|
3557
3503
|
autoCommitUpgradeChanges(version, userProjectRoot, filesToStage);
|
|
3558
3504
|
} else {
|
|
@@ -3570,8 +3516,8 @@ async function run3(options = {}) {
|
|
|
3570
3516
|
|
|
3571
3517
|
// src/commands/upgrade/deps/run.handler.ts
|
|
3572
3518
|
import { spawnSync as spawnSync4 } from "child_process";
|
|
3573
|
-
import
|
|
3574
|
-
import
|
|
3519
|
+
import fs13 from "fs";
|
|
3520
|
+
import path10 from "path";
|
|
3575
3521
|
|
|
3576
3522
|
// src/utils/grayscale/config.ts
|
|
3577
3523
|
function getGrayscaleConfig(configJson) {
|
|
@@ -3819,8 +3765,8 @@ function installGrayscaleVersions(packages, grayscaleVersions, cwd, dryRun, mode
|
|
|
3819
3765
|
if (version) {
|
|
3820
3766
|
let current = "";
|
|
3821
3767
|
try {
|
|
3822
|
-
const installedPkgPath =
|
|
3823
|
-
const installedPkg = JSON.parse(
|
|
3768
|
+
const installedPkgPath = path10.join(cwd, "node_modules", pkg2, "package.json");
|
|
3769
|
+
const installedPkg = JSON.parse(fs13.readFileSync(installedPkgPath, "utf-8"));
|
|
3824
3770
|
current = installedPkg.version || "";
|
|
3825
3771
|
} catch (err) {
|
|
3826
3772
|
const code = err?.code;
|
|
@@ -3938,8 +3884,8 @@ var depsCommand = {
|
|
|
3938
3884
|
|
|
3939
3885
|
// src/commands/upgrade/global-deps/run.handler.ts
|
|
3940
3886
|
import { spawnSync as spawnSync5 } from "child_process";
|
|
3941
|
-
import
|
|
3942
|
-
import
|
|
3887
|
+
import fs14 from "fs";
|
|
3888
|
+
import path11 from "path";
|
|
3943
3889
|
var MANAGED_GLOBAL_CLIS = [
|
|
3944
3890
|
"@lark-apaas/fullstack-cli",
|
|
3945
3891
|
"@lark-apaas/miaoda-cli"
|
|
@@ -3950,15 +3896,15 @@ function readGlobalInstalledVersion(pkg2) {
|
|
|
3950
3896
|
if (process.env.NPM_CONFIG_PREFIX) candidates.push(process.env.NPM_CONFIG_PREFIX);
|
|
3951
3897
|
candidates.push("/usr");
|
|
3952
3898
|
candidates.push("/usr/local");
|
|
3953
|
-
if (process.env.HOME) candidates.push(
|
|
3899
|
+
if (process.env.HOME) candidates.push(path11.join(process.env.HOME, ".npm-global"));
|
|
3954
3900
|
const seen = /* @__PURE__ */ new Set();
|
|
3955
3901
|
for (const prefix of candidates) {
|
|
3956
3902
|
if (seen.has(prefix)) continue;
|
|
3957
3903
|
seen.add(prefix);
|
|
3958
3904
|
try {
|
|
3959
|
-
const pkgPath =
|
|
3960
|
-
if (
|
|
3961
|
-
const meta = JSON.parse(
|
|
3905
|
+
const pkgPath = path11.join(prefix, "lib", "node_modules", pkg2, "package.json");
|
|
3906
|
+
if (fs14.existsSync(pkgPath)) {
|
|
3907
|
+
const meta = JSON.parse(fs14.readFileSync(pkgPath, "utf-8"));
|
|
3962
3908
|
if (meta && typeof meta.version === "string") return meta.version;
|
|
3963
3909
|
}
|
|
3964
3910
|
} catch (err) {
|
|
@@ -4055,8 +4001,8 @@ var upgradeCommand = {
|
|
|
4055
4001
|
};
|
|
4056
4002
|
|
|
4057
4003
|
// src/commands/action-plugin/utils.ts
|
|
4058
|
-
import
|
|
4059
|
-
import
|
|
4004
|
+
import fs15 from "fs";
|
|
4005
|
+
import path12 from "path";
|
|
4060
4006
|
import { spawnSync as spawnSync6, execSync as execSync2 } from "child_process";
|
|
4061
4007
|
function parsePluginName(input) {
|
|
4062
4008
|
const match = input.match(/^(@[^/]+\/[^@]+)(?:@(.+))?$/);
|
|
@@ -4074,18 +4020,18 @@ function getProjectRoot() {
|
|
|
4074
4020
|
return process.cwd();
|
|
4075
4021
|
}
|
|
4076
4022
|
function getPackageJsonPath() {
|
|
4077
|
-
return
|
|
4023
|
+
return path12.join(getProjectRoot(), "package.json");
|
|
4078
4024
|
}
|
|
4079
4025
|
function getPluginPath(pluginName) {
|
|
4080
|
-
return
|
|
4026
|
+
return path12.join(getProjectRoot(), "node_modules", pluginName);
|
|
4081
4027
|
}
|
|
4082
4028
|
function readPackageJson2() {
|
|
4083
4029
|
const pkgPath = getPackageJsonPath();
|
|
4084
|
-
if (!
|
|
4030
|
+
if (!fs15.existsSync(pkgPath)) {
|
|
4085
4031
|
throw new Error("package.json not found in current directory");
|
|
4086
4032
|
}
|
|
4087
4033
|
try {
|
|
4088
|
-
const content =
|
|
4034
|
+
const content = fs15.readFileSync(pkgPath, "utf-8");
|
|
4089
4035
|
return JSON.parse(content);
|
|
4090
4036
|
} catch {
|
|
4091
4037
|
throw new Error("Failed to parse package.json");
|
|
@@ -4093,7 +4039,7 @@ function readPackageJson2() {
|
|
|
4093
4039
|
}
|
|
4094
4040
|
function writePackageJson2(pkg2) {
|
|
4095
4041
|
const pkgPath = getPackageJsonPath();
|
|
4096
|
-
|
|
4042
|
+
fs15.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
|
|
4097
4043
|
}
|
|
4098
4044
|
function readActionPlugins() {
|
|
4099
4045
|
const pkg2 = readPackageJson2();
|
|
@@ -4126,12 +4072,12 @@ function npmInstall(tgzPath) {
|
|
|
4126
4072
|
}
|
|
4127
4073
|
}
|
|
4128
4074
|
function getPackageVersion(pluginName) {
|
|
4129
|
-
const pkgJsonPath =
|
|
4130
|
-
if (!
|
|
4075
|
+
const pkgJsonPath = path12.join(getPluginPath(pluginName), "package.json");
|
|
4076
|
+
if (!fs15.existsSync(pkgJsonPath)) {
|
|
4131
4077
|
return null;
|
|
4132
4078
|
}
|
|
4133
4079
|
try {
|
|
4134
|
-
const content =
|
|
4080
|
+
const content = fs15.readFileSync(pkgJsonPath, "utf-8");
|
|
4135
4081
|
const pkg2 = JSON.parse(content);
|
|
4136
4082
|
return pkg2.version || null;
|
|
4137
4083
|
} catch {
|
|
@@ -4139,49 +4085,49 @@ function getPackageVersion(pluginName) {
|
|
|
4139
4085
|
}
|
|
4140
4086
|
}
|
|
4141
4087
|
function readPluginPackageJson(pluginPath) {
|
|
4142
|
-
const pkgJsonPath =
|
|
4143
|
-
if (!
|
|
4088
|
+
const pkgJsonPath = path12.join(pluginPath, "package.json");
|
|
4089
|
+
if (!fs15.existsSync(pkgJsonPath)) {
|
|
4144
4090
|
return null;
|
|
4145
4091
|
}
|
|
4146
4092
|
try {
|
|
4147
|
-
const content =
|
|
4093
|
+
const content = fs15.readFileSync(pkgJsonPath, "utf-8");
|
|
4148
4094
|
return JSON.parse(content);
|
|
4149
4095
|
} catch {
|
|
4150
4096
|
return null;
|
|
4151
4097
|
}
|
|
4152
4098
|
}
|
|
4153
4099
|
function extractTgzToNodeModules(tgzPath, pluginName) {
|
|
4154
|
-
const nodeModulesPath =
|
|
4155
|
-
const targetDir =
|
|
4156
|
-
const scopeDir =
|
|
4157
|
-
if (!
|
|
4158
|
-
|
|
4100
|
+
const nodeModulesPath = path12.join(getProjectRoot(), "node_modules");
|
|
4101
|
+
const targetDir = path12.join(nodeModulesPath, pluginName);
|
|
4102
|
+
const scopeDir = path12.dirname(targetDir);
|
|
4103
|
+
if (!fs15.existsSync(scopeDir)) {
|
|
4104
|
+
fs15.mkdirSync(scopeDir, { recursive: true });
|
|
4159
4105
|
}
|
|
4160
|
-
if (
|
|
4161
|
-
|
|
4106
|
+
if (fs15.existsSync(targetDir)) {
|
|
4107
|
+
fs15.rmSync(targetDir, { recursive: true });
|
|
4162
4108
|
}
|
|
4163
|
-
const tempDir =
|
|
4164
|
-
if (
|
|
4165
|
-
|
|
4109
|
+
const tempDir = path12.join(nodeModulesPath, ".cache", "fullstack-cli", "extract-temp");
|
|
4110
|
+
if (fs15.existsSync(tempDir)) {
|
|
4111
|
+
fs15.rmSync(tempDir, { recursive: true });
|
|
4166
4112
|
}
|
|
4167
|
-
|
|
4113
|
+
fs15.mkdirSync(tempDir, { recursive: true });
|
|
4168
4114
|
try {
|
|
4169
4115
|
execSync2(`tar -xzf "${tgzPath}" -C "${tempDir}"`, { stdio: "pipe" });
|
|
4170
|
-
const extractedDir =
|
|
4171
|
-
if (
|
|
4172
|
-
|
|
4116
|
+
const extractedDir = path12.join(tempDir, "package");
|
|
4117
|
+
if (fs15.existsSync(extractedDir)) {
|
|
4118
|
+
fs15.renameSync(extractedDir, targetDir);
|
|
4173
4119
|
} else {
|
|
4174
|
-
const files =
|
|
4120
|
+
const files = fs15.readdirSync(tempDir);
|
|
4175
4121
|
if (files.length === 1) {
|
|
4176
|
-
|
|
4122
|
+
fs15.renameSync(path12.join(tempDir, files[0]), targetDir);
|
|
4177
4123
|
} else {
|
|
4178
4124
|
throw new Error("Unexpected tgz structure");
|
|
4179
4125
|
}
|
|
4180
4126
|
}
|
|
4181
4127
|
return targetDir;
|
|
4182
4128
|
} finally {
|
|
4183
|
-
if (
|
|
4184
|
-
|
|
4129
|
+
if (fs15.existsSync(tempDir)) {
|
|
4130
|
+
fs15.rmSync(tempDir, { recursive: true });
|
|
4185
4131
|
}
|
|
4186
4132
|
}
|
|
4187
4133
|
}
|
|
@@ -4190,10 +4136,10 @@ function checkMissingPeerDeps(peerDeps) {
|
|
|
4190
4136
|
return [];
|
|
4191
4137
|
}
|
|
4192
4138
|
const missing = [];
|
|
4193
|
-
const nodeModulesPath =
|
|
4139
|
+
const nodeModulesPath = path12.join(getProjectRoot(), "node_modules");
|
|
4194
4140
|
for (const [depName, _version] of Object.entries(peerDeps)) {
|
|
4195
|
-
const depPath =
|
|
4196
|
-
if (!
|
|
4141
|
+
const depPath = path12.join(nodeModulesPath, depName);
|
|
4142
|
+
if (!fs15.existsSync(depPath)) {
|
|
4197
4143
|
missing.push(depName);
|
|
4198
4144
|
}
|
|
4199
4145
|
}
|
|
@@ -4217,16 +4163,16 @@ function installMissingDeps(deps) {
|
|
|
4217
4163
|
}
|
|
4218
4164
|
function removePluginDirectory(pluginName) {
|
|
4219
4165
|
const pluginPath = getPluginPath(pluginName);
|
|
4220
|
-
if (
|
|
4221
|
-
|
|
4166
|
+
if (fs15.existsSync(pluginPath)) {
|
|
4167
|
+
fs15.rmSync(pluginPath, { recursive: true });
|
|
4222
4168
|
console.log(`[action-plugin] Removed ${pluginName}`);
|
|
4223
4169
|
}
|
|
4224
4170
|
}
|
|
4225
4171
|
|
|
4226
4172
|
// src/commands/action-plugin/api-client.ts
|
|
4227
4173
|
import { HttpClient as HttpClient2 } from "@lark-apaas/http-client";
|
|
4228
|
-
import
|
|
4229
|
-
import
|
|
4174
|
+
import fs16 from "fs";
|
|
4175
|
+
import path13 from "path";
|
|
4230
4176
|
var PLUGIN_CACHE_DIR = "node_modules/.cache/fullstack-cli/plugins";
|
|
4231
4177
|
async function getPluginVersions(keys, latestOnly = true) {
|
|
4232
4178
|
const client = getHttpClient();
|
|
@@ -4291,19 +4237,19 @@ async function downloadFromPublic(downloadURL) {
|
|
|
4291
4237
|
return Buffer.from(arrayBuffer);
|
|
4292
4238
|
}
|
|
4293
4239
|
function getPluginCacheDir() {
|
|
4294
|
-
return
|
|
4240
|
+
return path13.join(process.cwd(), PLUGIN_CACHE_DIR);
|
|
4295
4241
|
}
|
|
4296
4242
|
function ensureCacheDir() {
|
|
4297
4243
|
const cacheDir = getPluginCacheDir();
|
|
4298
|
-
if (!
|
|
4299
|
-
|
|
4244
|
+
if (!fs16.existsSync(cacheDir)) {
|
|
4245
|
+
fs16.mkdirSync(cacheDir, { recursive: true });
|
|
4300
4246
|
}
|
|
4301
4247
|
}
|
|
4302
4248
|
function getTempFilePath(pluginKey, version) {
|
|
4303
4249
|
ensureCacheDir();
|
|
4304
4250
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
4305
4251
|
const filename = `${safeKey}@${version}.tgz`;
|
|
4306
|
-
return
|
|
4252
|
+
return path13.join(getPluginCacheDir(), filename);
|
|
4307
4253
|
}
|
|
4308
4254
|
var MAX_RETRIES = 2;
|
|
4309
4255
|
async function withRetry(operation, description, maxRetries = MAX_RETRIES) {
|
|
@@ -4340,7 +4286,7 @@ async function downloadPlugin(pluginKey, requestedVersion) {
|
|
|
4340
4286
|
);
|
|
4341
4287
|
}
|
|
4342
4288
|
const tgzPath = getTempFilePath(pluginKey, pluginInfo.version);
|
|
4343
|
-
|
|
4289
|
+
fs16.writeFileSync(tgzPath, tgzBuffer);
|
|
4344
4290
|
console.log(`[action-plugin] Downloaded to ${tgzPath} (${(tgzBuffer.length / 1024).toFixed(2)} KB)`);
|
|
4345
4291
|
return {
|
|
4346
4292
|
tgzPath,
|
|
@@ -4354,18 +4300,18 @@ function getCachePath(pluginKey, version) {
|
|
|
4354
4300
|
ensureCacheDir();
|
|
4355
4301
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
4356
4302
|
const filename = `${safeKey}@${version}.tgz`;
|
|
4357
|
-
return
|
|
4303
|
+
return path13.join(getPluginCacheDir(), filename);
|
|
4358
4304
|
}
|
|
4359
4305
|
function hasCachedPlugin(pluginKey, version) {
|
|
4360
4306
|
const cachePath = getCachePath(pluginKey, version);
|
|
4361
|
-
return
|
|
4307
|
+
return fs16.existsSync(cachePath);
|
|
4362
4308
|
}
|
|
4363
4309
|
function listCachedPlugins() {
|
|
4364
4310
|
const cacheDir = getPluginCacheDir();
|
|
4365
|
-
if (!
|
|
4311
|
+
if (!fs16.existsSync(cacheDir)) {
|
|
4366
4312
|
return [];
|
|
4367
4313
|
}
|
|
4368
|
-
const files =
|
|
4314
|
+
const files = fs16.readdirSync(cacheDir);
|
|
4369
4315
|
const result = [];
|
|
4370
4316
|
for (const file of files) {
|
|
4371
4317
|
if (!file.endsWith(".tgz")) continue;
|
|
@@ -4373,8 +4319,8 @@ function listCachedPlugins() {
|
|
|
4373
4319
|
if (!match) continue;
|
|
4374
4320
|
const [, rawName, version] = match;
|
|
4375
4321
|
const name = rawName.replace(/^_/, "@").replace(/_/, "/");
|
|
4376
|
-
const filePath =
|
|
4377
|
-
const stat =
|
|
4322
|
+
const filePath = path13.join(cacheDir, file);
|
|
4323
|
+
const stat = fs16.statSync(filePath);
|
|
4378
4324
|
result.push({
|
|
4379
4325
|
name,
|
|
4380
4326
|
version,
|
|
@@ -4387,14 +4333,14 @@ function listCachedPlugins() {
|
|
|
4387
4333
|
}
|
|
4388
4334
|
function cleanAllCache() {
|
|
4389
4335
|
const cacheDir = getPluginCacheDir();
|
|
4390
|
-
if (!
|
|
4336
|
+
if (!fs16.existsSync(cacheDir)) {
|
|
4391
4337
|
return 0;
|
|
4392
4338
|
}
|
|
4393
|
-
const files =
|
|
4339
|
+
const files = fs16.readdirSync(cacheDir);
|
|
4394
4340
|
let count = 0;
|
|
4395
4341
|
for (const file of files) {
|
|
4396
4342
|
if (file.endsWith(".tgz")) {
|
|
4397
|
-
|
|
4343
|
+
fs16.unlinkSync(path13.join(cacheDir, file));
|
|
4398
4344
|
count++;
|
|
4399
4345
|
}
|
|
4400
4346
|
}
|
|
@@ -4402,21 +4348,21 @@ function cleanAllCache() {
|
|
|
4402
4348
|
}
|
|
4403
4349
|
function cleanPluginCache(pluginKey, version) {
|
|
4404
4350
|
const cacheDir = getPluginCacheDir();
|
|
4405
|
-
if (!
|
|
4351
|
+
if (!fs16.existsSync(cacheDir)) {
|
|
4406
4352
|
return 0;
|
|
4407
4353
|
}
|
|
4408
4354
|
const safeKey = pluginKey.replace(/[/@]/g, "_");
|
|
4409
|
-
const files =
|
|
4355
|
+
const files = fs16.readdirSync(cacheDir);
|
|
4410
4356
|
let count = 0;
|
|
4411
4357
|
for (const file of files) {
|
|
4412
4358
|
if (version) {
|
|
4413
4359
|
if (file === `${safeKey}@${version}.tgz`) {
|
|
4414
|
-
|
|
4360
|
+
fs16.unlinkSync(path13.join(cacheDir, file));
|
|
4415
4361
|
count++;
|
|
4416
4362
|
}
|
|
4417
4363
|
} else {
|
|
4418
4364
|
if (file.startsWith(`${safeKey}@`) && file.endsWith(".tgz")) {
|
|
4419
|
-
|
|
4365
|
+
fs16.unlinkSync(path13.join(cacheDir, file));
|
|
4420
4366
|
count++;
|
|
4421
4367
|
}
|
|
4422
4368
|
}
|
|
@@ -4687,9 +4633,9 @@ async function remove(nameWithVersion) {
|
|
|
4687
4633
|
}
|
|
4688
4634
|
|
|
4689
4635
|
// src/commands/capability/utils.ts
|
|
4690
|
-
import
|
|
4691
|
-
import { createRequire as
|
|
4692
|
-
import
|
|
4636
|
+
import fs17 from "fs";
|
|
4637
|
+
import { createRequire as createRequire2 } from "module";
|
|
4638
|
+
import path14 from "path";
|
|
4693
4639
|
var CAPABILITIES_DIR = "server/capabilities";
|
|
4694
4640
|
var SHARED_CAPABILITIES_DIR = "shared/capabilities";
|
|
4695
4641
|
var CAPABILITIES_DIR_ENV = "CAPABILITIES_DIR";
|
|
@@ -4699,38 +4645,38 @@ function getProjectRoot2() {
|
|
|
4699
4645
|
function getCapabilitiesDir() {
|
|
4700
4646
|
const fromEnv = process.env[CAPABILITIES_DIR_ENV]?.trim();
|
|
4701
4647
|
if (fromEnv) {
|
|
4702
|
-
return
|
|
4648
|
+
return path14.resolve(getProjectRoot2(), fromEnv.replace(/\/+$/, ""));
|
|
4703
4649
|
}
|
|
4704
|
-
const sharedDir =
|
|
4705
|
-
if (
|
|
4650
|
+
const sharedDir = path14.join(getProjectRoot2(), SHARED_CAPABILITIES_DIR);
|
|
4651
|
+
if (fs17.existsSync(sharedDir)) {
|
|
4706
4652
|
return sharedDir;
|
|
4707
4653
|
}
|
|
4708
|
-
return
|
|
4654
|
+
return path14.join(getProjectRoot2(), CAPABILITIES_DIR);
|
|
4709
4655
|
}
|
|
4710
4656
|
function getCapabilityPath(id) {
|
|
4711
|
-
return
|
|
4657
|
+
return path14.join(getCapabilitiesDir(), `${id}.json`);
|
|
4712
4658
|
}
|
|
4713
4659
|
function getPluginManifestPath(pluginKey) {
|
|
4714
|
-
return
|
|
4660
|
+
return path14.join(getProjectRoot2(), "node_modules", pluginKey, "manifest.json");
|
|
4715
4661
|
}
|
|
4716
4662
|
function capabilitiesDirExists() {
|
|
4717
|
-
return
|
|
4663
|
+
return fs17.existsSync(getCapabilitiesDir());
|
|
4718
4664
|
}
|
|
4719
4665
|
function listCapabilityIds() {
|
|
4720
4666
|
const dir = getCapabilitiesDir();
|
|
4721
|
-
if (!
|
|
4667
|
+
if (!fs17.existsSync(dir)) {
|
|
4722
4668
|
return [];
|
|
4723
4669
|
}
|
|
4724
|
-
const files =
|
|
4670
|
+
const files = fs17.readdirSync(dir);
|
|
4725
4671
|
return files.filter((f) => f.endsWith(".json") && f !== "capabilities.json").map((f) => f.replace(/\.json$/, ""));
|
|
4726
4672
|
}
|
|
4727
4673
|
function readCapability(id) {
|
|
4728
4674
|
const filePath = getCapabilityPath(id);
|
|
4729
|
-
if (!
|
|
4675
|
+
if (!fs17.existsSync(filePath)) {
|
|
4730
4676
|
throw new Error(`Capability not found: ${id}`);
|
|
4731
4677
|
}
|
|
4732
4678
|
try {
|
|
4733
|
-
const content =
|
|
4679
|
+
const content = fs17.readFileSync(filePath, "utf-8");
|
|
4734
4680
|
return JSON.parse(content);
|
|
4735
4681
|
} catch (error) {
|
|
4736
4682
|
if (error instanceof SyntaxError) {
|
|
@@ -4757,11 +4703,11 @@ function readAllCapabilities() {
|
|
|
4757
4703
|
}
|
|
4758
4704
|
function readPluginManifest(pluginKey) {
|
|
4759
4705
|
const manifestPath = getPluginManifestPath(pluginKey);
|
|
4760
|
-
if (!
|
|
4706
|
+
if (!fs17.existsSync(manifestPath)) {
|
|
4761
4707
|
throw new Error(`Plugin not installed: ${pluginKey} (manifest.json not found)`);
|
|
4762
4708
|
}
|
|
4763
4709
|
try {
|
|
4764
|
-
const content =
|
|
4710
|
+
const content = fs17.readFileSync(manifestPath, "utf-8");
|
|
4765
4711
|
return JSON.parse(content);
|
|
4766
4712
|
} catch (error) {
|
|
4767
4713
|
if (error instanceof SyntaxError) {
|
|
@@ -4778,7 +4724,7 @@ function hasValidParamsSchema(paramsSchema) {
|
|
|
4778
4724
|
}
|
|
4779
4725
|
async function loadPlugin(pluginKey) {
|
|
4780
4726
|
try {
|
|
4781
|
-
const userRequire =
|
|
4727
|
+
const userRequire = createRequire2(path14.join(getProjectRoot2(), "package.json"));
|
|
4782
4728
|
const resolvedPath = userRequire.resolve(pluginKey);
|
|
4783
4729
|
const pluginModule = await import(resolvedPath);
|
|
4784
4730
|
const pluginPackage = pluginModule.default ?? pluginModule;
|
|
@@ -4876,10 +4822,10 @@ function logError(message) {
|
|
|
4876
4822
|
}
|
|
4877
4823
|
|
|
4878
4824
|
// src/commands/action-plugin/form-context.ts
|
|
4879
|
-
import
|
|
4825
|
+
import fs19 from "fs";
|
|
4880
4826
|
|
|
4881
4827
|
// src/commands/action-plugin/form-errors.ts
|
|
4882
|
-
import
|
|
4828
|
+
import fs18 from "fs";
|
|
4883
4829
|
var FormCliErrorCode = {
|
|
4884
4830
|
PLUGIN_NOT_INSTALLED: "PLUGIN_NOT_INSTALLED",
|
|
4885
4831
|
PLUGIN_SDK_TOO_OLD: "PLUGIN_SDK_TOO_OLD",
|
|
@@ -4991,7 +4937,7 @@ function parseTimeout(raw) {
|
|
|
4991
4937
|
return value;
|
|
4992
4938
|
}
|
|
4993
4939
|
function readJsonFile(filePath, label) {
|
|
4994
|
-
if (!
|
|
4940
|
+
if (!fs18.existsSync(filePath)) {
|
|
4995
4941
|
throw new FormCliError(
|
|
4996
4942
|
FormCliErrorCode.INVALID_INPUT,
|
|
4997
4943
|
`${label} not found: ${filePath}`
|
|
@@ -4999,7 +4945,7 @@ function readJsonFile(filePath, label) {
|
|
|
4999
4945
|
}
|
|
5000
4946
|
let content;
|
|
5001
4947
|
try {
|
|
5002
|
-
content =
|
|
4948
|
+
content = fs18.readFileSync(filePath, "utf-8");
|
|
5003
4949
|
} catch (error) {
|
|
5004
4950
|
throw new FormCliError(
|
|
5005
4951
|
FormCliErrorCode.INVALID_INPUT,
|
|
@@ -5038,7 +4984,7 @@ function readJsonArg(raw, flag) {
|
|
|
5038
4984
|
if (raw === "-") {
|
|
5039
4985
|
let content;
|
|
5040
4986
|
try {
|
|
5041
|
-
content =
|
|
4987
|
+
content = fs18.readFileSync(0, "utf-8");
|
|
5042
4988
|
} catch (error) {
|
|
5043
4989
|
throw new FormCliError(
|
|
5044
4990
|
FormCliErrorCode.INVALID_INPUT,
|
|
@@ -5074,7 +5020,7 @@ function outputParseErrorsAsJson(command) {
|
|
|
5074
5020
|
message: str.replace(/^error:\s*/, "").trim(),
|
|
5075
5021
|
hint: `Run "fullstack-cli ${usage} --help" for usage.`
|
|
5076
5022
|
};
|
|
5077
|
-
|
|
5023
|
+
fs18.writeSync(1, `${JSON.stringify(output, null, 2)}
|
|
5078
5024
|
`);
|
|
5079
5025
|
}
|
|
5080
5026
|
});
|
|
@@ -5141,7 +5087,7 @@ function createStderrLogger(prefix) {
|
|
|
5141
5087
|
};
|
|
5142
5088
|
}
|
|
5143
5089
|
function readMatchingCapability(instanceId, pluginKey) {
|
|
5144
|
-
if (!
|
|
5090
|
+
if (!fs19.existsSync(getCapabilityPath(instanceId))) {
|
|
5145
5091
|
throw new FormCliError(
|
|
5146
5092
|
FormCliErrorCode.INSTANCE_NOT_FOUND,
|
|
5147
5093
|
`Capability instance ${instanceId} not found`,
|
|
@@ -5809,26 +5755,26 @@ var TemplateIssueCode = {
|
|
|
5809
5755
|
/** paramsSchema 声明的变量表单值里没有引用(提醒,不阻塞) */
|
|
5810
5756
|
UNUSED_INPUT_PARAM: "UNUSED_INPUT_PARAM"
|
|
5811
5757
|
};
|
|
5812
|
-
function toJsonPointer(
|
|
5813
|
-
if (
|
|
5758
|
+
function toJsonPointer(path28) {
|
|
5759
|
+
if (path28.length === 0) {
|
|
5814
5760
|
return "";
|
|
5815
5761
|
}
|
|
5816
|
-
return "/" +
|
|
5762
|
+
return "/" + path28.map((segment) => String(segment).replace(/~/g, "~0").replace(/\//g, "~1")).join("/");
|
|
5817
5763
|
}
|
|
5818
|
-
function forEachString(value,
|
|
5764
|
+
function forEachString(value, path28, visit) {
|
|
5819
5765
|
if (typeof value === "string") {
|
|
5820
|
-
visit(value,
|
|
5766
|
+
visit(value, path28);
|
|
5821
5767
|
return;
|
|
5822
5768
|
}
|
|
5823
5769
|
if (Array.isArray(value)) {
|
|
5824
5770
|
value.forEach(
|
|
5825
|
-
(item, index) => forEachString(item, [...
|
|
5771
|
+
(item, index) => forEachString(item, [...path28, index], visit)
|
|
5826
5772
|
);
|
|
5827
5773
|
return;
|
|
5828
5774
|
}
|
|
5829
5775
|
if (value && typeof value === "object") {
|
|
5830
5776
|
for (const [key, item] of Object.entries(value)) {
|
|
5831
|
-
forEachString(item, [...
|
|
5777
|
+
forEachString(item, [...path28, key], visit);
|
|
5832
5778
|
}
|
|
5833
5779
|
}
|
|
5834
5780
|
}
|
|
@@ -5844,8 +5790,8 @@ function checkTemplateRefs(formValue, paramsSchema) {
|
|
|
5844
5790
|
const reminders = [];
|
|
5845
5791
|
const declared = new Set(declaredParams(paramsSchema));
|
|
5846
5792
|
const referenced = /* @__PURE__ */ new Set();
|
|
5847
|
-
forEachString(formValue, [], (str,
|
|
5848
|
-
const pointer = toJsonPointer(
|
|
5793
|
+
forEachString(formValue, [], (str, path28) => {
|
|
5794
|
+
const pointer = toJsonPointer(path28);
|
|
5849
5795
|
for (const match of str.matchAll(INPUT_REF_REGEX)) {
|
|
5850
5796
|
const name = match[1];
|
|
5851
5797
|
referenced.add(name);
|
|
@@ -5890,20 +5836,20 @@ function normalizeIssue(issue) {
|
|
|
5890
5836
|
if (!isRecord(issue)) {
|
|
5891
5837
|
return void 0;
|
|
5892
5838
|
}
|
|
5893
|
-
const { code, message, path:
|
|
5839
|
+
const { code, message, path: path28 } = issue;
|
|
5894
5840
|
if (typeof message !== "string" || message === "") {
|
|
5895
5841
|
return void 0;
|
|
5896
5842
|
}
|
|
5897
5843
|
if (code !== void 0 && (typeof code !== "string" || code === "")) {
|
|
5898
5844
|
return void 0;
|
|
5899
5845
|
}
|
|
5900
|
-
if (
|
|
5846
|
+
if (path28 !== void 0 && typeof path28 !== "string") {
|
|
5901
5847
|
return void 0;
|
|
5902
5848
|
}
|
|
5903
5849
|
return {
|
|
5904
5850
|
message,
|
|
5905
5851
|
...code === void 0 ? {} : { code },
|
|
5906
|
-
...
|
|
5852
|
+
...path28 === void 0 ? {} : { path: path28 }
|
|
5907
5853
|
};
|
|
5908
5854
|
}
|
|
5909
5855
|
function normalizeResult(raw) {
|
|
@@ -6072,8 +6018,8 @@ async function validate(options) {
|
|
|
6072
6018
|
}
|
|
6073
6019
|
|
|
6074
6020
|
// src/commands/capability/write.handler.ts
|
|
6075
|
-
import
|
|
6076
|
-
import
|
|
6021
|
+
import fs20 from "fs";
|
|
6022
|
+
import path15 from "path";
|
|
6077
6023
|
var CAPABILITY_ID_PATTERN = /^[A-Za-z0-9][A-Za-z0-9_-]{0,127}$/;
|
|
6078
6024
|
var CREATED_BY_PLACEHOLDER = "__fullstack_cli_created_by__";
|
|
6079
6025
|
function assertValidId(id) {
|
|
@@ -6086,23 +6032,23 @@ function assertValidId(id) {
|
|
|
6086
6032
|
}
|
|
6087
6033
|
function capabilityFilePath(id) {
|
|
6088
6034
|
const dir = getCapabilitiesDir();
|
|
6089
|
-
const relative =
|
|
6090
|
-
if (relative === ".." || relative.startsWith(`..${
|
|
6035
|
+
const relative = path15.relative(getProjectRoot2(), dir);
|
|
6036
|
+
if (relative === ".." || relative.startsWith(`..${path15.sep}`) || path15.isAbsolute(relative)) {
|
|
6091
6037
|
throw new FormCliError(
|
|
6092
6038
|
FormCliErrorCode.INVALID_INPUT,
|
|
6093
6039
|
`Capabilities directory ${dir} is outside the project root ${getProjectRoot2()}; check ${CAPABILITIES_DIR_ENV}`
|
|
6094
6040
|
);
|
|
6095
6041
|
}
|
|
6096
|
-
return
|
|
6042
|
+
return path15.join(dir, `${id}.json`);
|
|
6097
6043
|
}
|
|
6098
6044
|
function toProjectRelative(absolutePath) {
|
|
6099
|
-
return
|
|
6045
|
+
return path15.relative(getProjectRoot2(), absolutePath).split(path15.sep).join("/");
|
|
6100
6046
|
}
|
|
6101
6047
|
function readPluginIcon(pluginKey) {
|
|
6102
6048
|
try {
|
|
6103
6049
|
const pkg2 = JSON.parse(
|
|
6104
|
-
|
|
6105
|
-
|
|
6050
|
+
fs20.readFileSync(
|
|
6051
|
+
path15.join(getPluginPath(pluginKey), "package.json"),
|
|
6106
6052
|
"utf-8"
|
|
6107
6053
|
)
|
|
6108
6054
|
);
|
|
@@ -6119,17 +6065,17 @@ function serializeCapability(record, createdByToken) {
|
|
|
6119
6065
|
return createdByToken === void 0 ? json : json.replace(`"${CREATED_BY_PLACEHOLDER}"`, createdByToken);
|
|
6120
6066
|
}
|
|
6121
6067
|
function writeAtomically(filePath, content, options) {
|
|
6122
|
-
const dir =
|
|
6123
|
-
|
|
6124
|
-
const tmp =
|
|
6068
|
+
const dir = path15.dirname(filePath);
|
|
6069
|
+
fs20.mkdirSync(dir, { recursive: true });
|
|
6070
|
+
const tmp = path15.join(
|
|
6125
6071
|
dir,
|
|
6126
|
-
`.${
|
|
6072
|
+
`.${path15.basename(filePath)}.${process.pid}.${Date.now()}.tmp`
|
|
6127
6073
|
);
|
|
6128
|
-
|
|
6074
|
+
fs20.writeFileSync(tmp, content);
|
|
6129
6075
|
try {
|
|
6130
6076
|
if (options.exclusive) {
|
|
6131
6077
|
try {
|
|
6132
|
-
|
|
6078
|
+
fs20.linkSync(tmp, filePath);
|
|
6133
6079
|
} catch (error) {
|
|
6134
6080
|
if (error.code === "EEXIST") {
|
|
6135
6081
|
throw new FormCliError(
|
|
@@ -6143,10 +6089,10 @@ function writeAtomically(filePath, content, options) {
|
|
|
6143
6089
|
throw error;
|
|
6144
6090
|
}
|
|
6145
6091
|
} else {
|
|
6146
|
-
|
|
6092
|
+
fs20.renameSync(tmp, filePath);
|
|
6147
6093
|
}
|
|
6148
6094
|
} finally {
|
|
6149
|
-
|
|
6095
|
+
fs20.rmSync(tmp, { force: true });
|
|
6150
6096
|
}
|
|
6151
6097
|
}
|
|
6152
6098
|
function readParamsSchema(raw) {
|
|
@@ -6173,7 +6119,7 @@ async function runCreate(options) {
|
|
|
6173
6119
|
);
|
|
6174
6120
|
}
|
|
6175
6121
|
const filePath = capabilityFilePath(options.id);
|
|
6176
|
-
if (
|
|
6122
|
+
if (fs20.existsSync(filePath)) {
|
|
6177
6123
|
throw new FormCliError(
|
|
6178
6124
|
FormCliErrorCode.INSTANCE_EXISTS,
|
|
6179
6125
|
`Capability ${options.id} already exists at ${toProjectRelative(filePath)}`,
|
|
@@ -6220,7 +6166,7 @@ async function runCreate(options) {
|
|
|
6220
6166
|
async function runUpdate(options) {
|
|
6221
6167
|
assertValidId(options.id);
|
|
6222
6168
|
const filePath = capabilityFilePath(options.id);
|
|
6223
|
-
if (!
|
|
6169
|
+
if (!fs20.existsSync(filePath)) {
|
|
6224
6170
|
throw new FormCliError(
|
|
6225
6171
|
FormCliErrorCode.INSTANCE_NOT_FOUND,
|
|
6226
6172
|
`Capability ${options.id} not found at ${toProjectRelative(filePath)}`,
|
|
@@ -6229,7 +6175,7 @@ async function runUpdate(options) {
|
|
|
6229
6175
|
}
|
|
6230
6176
|
);
|
|
6231
6177
|
}
|
|
6232
|
-
const rawText =
|
|
6178
|
+
const rawText = fs20.readFileSync(filePath, "utf-8");
|
|
6233
6179
|
let existing;
|
|
6234
6180
|
try {
|
|
6235
6181
|
const parsed = JSON.parse(rawText);
|
|
@@ -6287,7 +6233,7 @@ async function runUpdate(options) {
|
|
|
6287
6233
|
}
|
|
6288
6234
|
function readPluginKeyOf(filePath) {
|
|
6289
6235
|
try {
|
|
6290
|
-
const parsed = JSON.parse(
|
|
6236
|
+
const parsed = JSON.parse(fs20.readFileSync(filePath, "utf-8"));
|
|
6291
6237
|
return typeof parsed?.pluginKey === "string" && parsed.pluginKey ? parsed.pluginKey : void 0;
|
|
6292
6238
|
} catch {
|
|
6293
6239
|
return void 0;
|
|
@@ -6304,12 +6250,12 @@ function runDelete(options) {
|
|
|
6304
6250
|
hint: 'Check the id with "fullstack-cli capability list --summary".'
|
|
6305
6251
|
}
|
|
6306
6252
|
);
|
|
6307
|
-
if (!
|
|
6253
|
+
if (!fs20.existsSync(filePath)) {
|
|
6308
6254
|
throw notFound();
|
|
6309
6255
|
}
|
|
6310
6256
|
const pluginKey = readPluginKeyOf(filePath);
|
|
6311
6257
|
try {
|
|
6312
|
-
|
|
6258
|
+
fs20.unlinkSync(filePath);
|
|
6313
6259
|
} catch (error) {
|
|
6314
6260
|
if (error.code === "ENOENT") {
|
|
6315
6261
|
throw notFound();
|
|
@@ -6497,8 +6443,8 @@ var capabilityCommandGroup = {
|
|
|
6497
6443
|
import { execFile } from "child_process";
|
|
6498
6444
|
|
|
6499
6445
|
// src/commands/component/registry-preparer.ts
|
|
6500
|
-
import
|
|
6501
|
-
import
|
|
6446
|
+
import fs21 from "fs";
|
|
6447
|
+
import path16 from "path";
|
|
6502
6448
|
import os from "os";
|
|
6503
6449
|
|
|
6504
6450
|
// src/commands/component/service.ts
|
|
@@ -6558,7 +6504,7 @@ async function sendInstallEvent(key) {
|
|
|
6558
6504
|
}
|
|
6559
6505
|
|
|
6560
6506
|
// src/commands/component/registry-preparer.ts
|
|
6561
|
-
var REGISTRY_TEMP_DIR =
|
|
6507
|
+
var REGISTRY_TEMP_DIR = path16.join(os.tmpdir(), "miaoda-registry");
|
|
6562
6508
|
function parseComponentKey(key) {
|
|
6563
6509
|
const match = key.match(/^@([^/]+)\/(.+)$/);
|
|
6564
6510
|
if (!match) {
|
|
@@ -6570,11 +6516,11 @@ function parseComponentKey(key) {
|
|
|
6570
6516
|
}
|
|
6571
6517
|
function getLocalRegistryPath(key) {
|
|
6572
6518
|
const { scope, name } = parseComponentKey(key);
|
|
6573
|
-
return
|
|
6519
|
+
return path16.join(REGISTRY_TEMP_DIR, scope, `${name}.json`);
|
|
6574
6520
|
}
|
|
6575
6521
|
function ensureDir(dirPath) {
|
|
6576
|
-
if (!
|
|
6577
|
-
|
|
6522
|
+
if (!fs21.existsSync(dirPath)) {
|
|
6523
|
+
fs21.mkdirSync(dirPath, { recursive: true });
|
|
6578
6524
|
}
|
|
6579
6525
|
}
|
|
6580
6526
|
async function prepareRecursive(key, visited) {
|
|
@@ -6607,8 +6553,8 @@ async function prepareRecursive(key, visited) {
|
|
|
6607
6553
|
registryDependencies: deps.map((dep) => getLocalRegistryPath(dep))
|
|
6608
6554
|
};
|
|
6609
6555
|
const localPath = getLocalRegistryPath(key);
|
|
6610
|
-
ensureDir(
|
|
6611
|
-
|
|
6556
|
+
ensureDir(path16.dirname(localPath));
|
|
6557
|
+
fs21.writeFileSync(localPath, JSON.stringify(rewrittenItem, null, 2), "utf-8");
|
|
6612
6558
|
debug("\u4FDD\u5B58\u5230: %s", localPath);
|
|
6613
6559
|
}
|
|
6614
6560
|
async function prepareComponentRegistryItems(id) {
|
|
@@ -6618,18 +6564,18 @@ async function prepareComponentRegistryItems(id) {
|
|
|
6618
6564
|
}
|
|
6619
6565
|
function cleanupTempDir() {
|
|
6620
6566
|
try {
|
|
6621
|
-
if (
|
|
6622
|
-
|
|
6567
|
+
if (fs21.existsSync(REGISTRY_TEMP_DIR)) {
|
|
6568
|
+
fs21.rmSync(REGISTRY_TEMP_DIR, { recursive: true, force: true });
|
|
6623
6569
|
}
|
|
6624
6570
|
} catch {
|
|
6625
6571
|
}
|
|
6626
6572
|
}
|
|
6627
6573
|
function getDownloadedRegistryItem(itemId) {
|
|
6628
6574
|
const localPath = getLocalRegistryPath(itemId);
|
|
6629
|
-
if (!
|
|
6575
|
+
if (!fs21.existsSync(localPath)) {
|
|
6630
6576
|
return null;
|
|
6631
6577
|
}
|
|
6632
|
-
const content =
|
|
6578
|
+
const content = fs21.readFileSync(localPath, "utf-8");
|
|
6633
6579
|
return JSON.parse(content);
|
|
6634
6580
|
}
|
|
6635
6581
|
|
|
@@ -6797,58 +6743,58 @@ var componentCommandGroup = {
|
|
|
6797
6743
|
};
|
|
6798
6744
|
|
|
6799
6745
|
// src/commands/migration/version-manager.ts
|
|
6800
|
-
import
|
|
6801
|
-
import
|
|
6746
|
+
import fs22 from "fs";
|
|
6747
|
+
import path17 from "path";
|
|
6802
6748
|
var PACKAGE_JSON = "package.json";
|
|
6803
6749
|
var VERSION_FIELD = "migrationVersion";
|
|
6804
6750
|
function getPackageJsonPath2() {
|
|
6805
|
-
return
|
|
6751
|
+
return path17.join(process.cwd(), PACKAGE_JSON);
|
|
6806
6752
|
}
|
|
6807
6753
|
function getCurrentVersion() {
|
|
6808
6754
|
const pkgPath = getPackageJsonPath2();
|
|
6809
|
-
if (!
|
|
6755
|
+
if (!fs22.existsSync(pkgPath)) {
|
|
6810
6756
|
throw new Error("package.json not found");
|
|
6811
6757
|
}
|
|
6812
|
-
const pkg2 = JSON.parse(
|
|
6758
|
+
const pkg2 = JSON.parse(fs22.readFileSync(pkgPath, "utf-8"));
|
|
6813
6759
|
return pkg2[VERSION_FIELD] ?? 0;
|
|
6814
6760
|
}
|
|
6815
6761
|
function setCurrentVersion(version) {
|
|
6816
6762
|
const pkgPath = getPackageJsonPath2();
|
|
6817
|
-
const pkg2 = JSON.parse(
|
|
6763
|
+
const pkg2 = JSON.parse(fs22.readFileSync(pkgPath, "utf-8"));
|
|
6818
6764
|
pkg2[VERSION_FIELD] = version;
|
|
6819
|
-
|
|
6765
|
+
fs22.writeFileSync(pkgPath, JSON.stringify(pkg2, null, 2) + "\n", "utf-8");
|
|
6820
6766
|
}
|
|
6821
6767
|
|
|
6822
6768
|
// src/commands/migration/versions/v001_capability/json-migrator/detector.ts
|
|
6823
|
-
import fs25 from "fs";
|
|
6824
|
-
import path20 from "path";
|
|
6825
|
-
|
|
6826
|
-
// src/commands/migration/versions/v001_capability/utils.ts
|
|
6827
6769
|
import fs24 from "fs";
|
|
6828
6770
|
import path19 from "path";
|
|
6771
|
+
|
|
6772
|
+
// src/commands/migration/versions/v001_capability/utils.ts
|
|
6773
|
+
import fs23 from "fs";
|
|
6774
|
+
import path18 from "path";
|
|
6829
6775
|
var CAPABILITIES_DIR2 = "server/capabilities";
|
|
6830
6776
|
function getProjectRoot3() {
|
|
6831
6777
|
return process.cwd();
|
|
6832
6778
|
}
|
|
6833
6779
|
function getCapabilitiesDir2() {
|
|
6834
|
-
return
|
|
6780
|
+
return path18.join(getProjectRoot3(), CAPABILITIES_DIR2);
|
|
6835
6781
|
}
|
|
6836
6782
|
function getPluginManifestPath2(pluginKey) {
|
|
6837
|
-
return
|
|
6783
|
+
return path18.join(getProjectRoot3(), "node_modules", pluginKey, "manifest.json");
|
|
6838
6784
|
}
|
|
6839
6785
|
|
|
6840
6786
|
// src/commands/migration/versions/v001_capability/json-migrator/detector.ts
|
|
6841
6787
|
function detectJsonMigration() {
|
|
6842
6788
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
6843
|
-
const oldFilePath =
|
|
6844
|
-
if (!
|
|
6789
|
+
const oldFilePath = path19.join(capabilitiesDir, "capabilities.json");
|
|
6790
|
+
if (!fs24.existsSync(oldFilePath)) {
|
|
6845
6791
|
return {
|
|
6846
6792
|
needsMigration: false,
|
|
6847
6793
|
reason: "capabilities.json not found"
|
|
6848
6794
|
};
|
|
6849
6795
|
}
|
|
6850
6796
|
try {
|
|
6851
|
-
const content =
|
|
6797
|
+
const content = fs24.readFileSync(oldFilePath, "utf-8");
|
|
6852
6798
|
const parsed = JSON.parse(content);
|
|
6853
6799
|
if (!Array.isArray(parsed)) {
|
|
6854
6800
|
return {
|
|
@@ -6899,8 +6845,8 @@ async function check(options) {
|
|
|
6899
6845
|
}
|
|
6900
6846
|
|
|
6901
6847
|
// src/commands/migration/versions/v001_capability/json-migrator/index.ts
|
|
6902
|
-
import
|
|
6903
|
-
import
|
|
6848
|
+
import fs25 from "fs";
|
|
6849
|
+
import path20 from "path";
|
|
6904
6850
|
|
|
6905
6851
|
// src/commands/migration/versions/v001_capability/mapping.ts
|
|
6906
6852
|
var DEFAULT_PLUGIN_VERSION = "1.0.0";
|
|
@@ -7130,18 +7076,18 @@ function transformCapabilities(oldCapabilities) {
|
|
|
7130
7076
|
// src/commands/migration/versions/v001_capability/json-migrator/index.ts
|
|
7131
7077
|
function loadExistingCapabilities() {
|
|
7132
7078
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
7133
|
-
if (!
|
|
7079
|
+
if (!fs25.existsSync(capabilitiesDir)) {
|
|
7134
7080
|
return [];
|
|
7135
7081
|
}
|
|
7136
|
-
const files =
|
|
7082
|
+
const files = fs25.readdirSync(capabilitiesDir);
|
|
7137
7083
|
const capabilities = [];
|
|
7138
7084
|
for (const file of files) {
|
|
7139
7085
|
if (file === "capabilities.json" || !file.endsWith(".json")) {
|
|
7140
7086
|
continue;
|
|
7141
7087
|
}
|
|
7142
7088
|
try {
|
|
7143
|
-
const filePath =
|
|
7144
|
-
const content =
|
|
7089
|
+
const filePath = path20.join(capabilitiesDir, file);
|
|
7090
|
+
const content = fs25.readFileSync(filePath, "utf-8");
|
|
7145
7091
|
const capability = JSON.parse(content);
|
|
7146
7092
|
if (capability.id && capability.pluginKey) {
|
|
7147
7093
|
capabilities.push(capability);
|
|
@@ -7199,9 +7145,9 @@ async function migrateJsonFiles(options) {
|
|
|
7199
7145
|
}
|
|
7200
7146
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
7201
7147
|
for (const cap of newCapabilities) {
|
|
7202
|
-
const filePath =
|
|
7148
|
+
const filePath = path20.join(capabilitiesDir, `${cap.id}.json`);
|
|
7203
7149
|
const content = JSON.stringify(cap, null, 2);
|
|
7204
|
-
|
|
7150
|
+
fs25.writeFileSync(filePath, content, "utf-8");
|
|
7205
7151
|
console.log(` \u2713 Created: ${cap.id}.json`);
|
|
7206
7152
|
}
|
|
7207
7153
|
return {
|
|
@@ -7213,11 +7159,11 @@ async function migrateJsonFiles(options) {
|
|
|
7213
7159
|
}
|
|
7214
7160
|
|
|
7215
7161
|
// src/commands/migration/versions/v001_capability/plugin-installer/detector.ts
|
|
7216
|
-
import
|
|
7162
|
+
import fs26 from "fs";
|
|
7217
7163
|
function isPluginInstalled2(pluginKey) {
|
|
7218
7164
|
const actionPlugins = readActionPlugins();
|
|
7219
7165
|
const manifestPath = getPluginManifestPath2(pluginKey);
|
|
7220
|
-
return
|
|
7166
|
+
return fs26.existsSync(manifestPath) && !!actionPlugins[pluginKey];
|
|
7221
7167
|
}
|
|
7222
7168
|
function detectPluginsToInstall(capabilities) {
|
|
7223
7169
|
const pluginKeys = /* @__PURE__ */ new Set();
|
|
@@ -7293,12 +7239,12 @@ async function installPlugins(capabilities, options) {
|
|
|
7293
7239
|
}
|
|
7294
7240
|
|
|
7295
7241
|
// src/commands/migration/versions/v001_capability/code-migrator/index.ts
|
|
7296
|
-
import
|
|
7242
|
+
import path22 from "path";
|
|
7297
7243
|
import { Project as Project3 } from "ts-morph";
|
|
7298
7244
|
|
|
7299
7245
|
// src/commands/migration/versions/v001_capability/code-migrator/scanner.ts
|
|
7300
|
-
import
|
|
7301
|
-
import
|
|
7246
|
+
import fs27 from "fs";
|
|
7247
|
+
import path21 from "path";
|
|
7302
7248
|
var EXCLUDED_DIRS = [
|
|
7303
7249
|
"node_modules",
|
|
7304
7250
|
"dist",
|
|
@@ -7313,9 +7259,9 @@ var EXCLUDED_PATTERNS = [
|
|
|
7313
7259
|
/\.d\.ts$/
|
|
7314
7260
|
];
|
|
7315
7261
|
function scanDirectory(dir, files = []) {
|
|
7316
|
-
const entries =
|
|
7262
|
+
const entries = fs27.readdirSync(dir, { withFileTypes: true });
|
|
7317
7263
|
for (const entry of entries) {
|
|
7318
|
-
const fullPath =
|
|
7264
|
+
const fullPath = path21.join(dir, entry.name);
|
|
7319
7265
|
if (entry.isDirectory()) {
|
|
7320
7266
|
if (EXCLUDED_DIRS.includes(entry.name)) {
|
|
7321
7267
|
continue;
|
|
@@ -7331,14 +7277,14 @@ function scanDirectory(dir, files = []) {
|
|
|
7331
7277
|
return files;
|
|
7332
7278
|
}
|
|
7333
7279
|
function scanServerFiles() {
|
|
7334
|
-
const serverDir =
|
|
7335
|
-
if (!
|
|
7280
|
+
const serverDir = path21.join(getProjectRoot3(), "server");
|
|
7281
|
+
if (!fs27.existsSync(serverDir)) {
|
|
7336
7282
|
return [];
|
|
7337
7283
|
}
|
|
7338
7284
|
return scanDirectory(serverDir);
|
|
7339
7285
|
}
|
|
7340
7286
|
function hasCapabilityImport(filePath) {
|
|
7341
|
-
const content =
|
|
7287
|
+
const content = fs27.readFileSync(filePath, "utf-8");
|
|
7342
7288
|
return /import\s+.*from\s+['"][^'"]*capabilities[^'"]*['"]/.test(content);
|
|
7343
7289
|
}
|
|
7344
7290
|
function scanFilesToMigrate() {
|
|
@@ -7715,7 +7661,7 @@ function analyzeFile(project, filePath, actionNameMap) {
|
|
|
7715
7661
|
const callSites = analyzeCallSites(sourceFile, imports);
|
|
7716
7662
|
const classInfo = analyzeClass(sourceFile);
|
|
7717
7663
|
const { canMigrate, reason } = canAutoMigrate(classInfo);
|
|
7718
|
-
const relativePath =
|
|
7664
|
+
const relativePath = path22.relative(getProjectRoot3(), filePath);
|
|
7719
7665
|
return {
|
|
7720
7666
|
filePath: relativePath,
|
|
7721
7667
|
imports,
|
|
@@ -7726,7 +7672,7 @@ function analyzeFile(project, filePath, actionNameMap) {
|
|
|
7726
7672
|
};
|
|
7727
7673
|
}
|
|
7728
7674
|
function migrateFile(project, analysis, dryRun) {
|
|
7729
|
-
const absolutePath =
|
|
7675
|
+
const absolutePath = path22.join(getProjectRoot3(), analysis.filePath);
|
|
7730
7676
|
if (!analysis.canAutoMigrate) {
|
|
7731
7677
|
return {
|
|
7732
7678
|
filePath: analysis.filePath,
|
|
@@ -7829,17 +7775,17 @@ function getSuggestion(analysis) {
|
|
|
7829
7775
|
}
|
|
7830
7776
|
|
|
7831
7777
|
// src/commands/migration/versions/v001_capability/cleanup.ts
|
|
7832
|
-
import
|
|
7833
|
-
import
|
|
7778
|
+
import fs28 from "fs";
|
|
7779
|
+
import path23 from "path";
|
|
7834
7780
|
function cleanupOldFiles(capabilities, dryRun) {
|
|
7835
7781
|
const deletedFiles = [];
|
|
7836
7782
|
const errors = [];
|
|
7837
7783
|
const capabilitiesDir = getCapabilitiesDir2();
|
|
7838
|
-
const oldJsonPath =
|
|
7839
|
-
if (
|
|
7784
|
+
const oldJsonPath = path23.join(capabilitiesDir, "capabilities.json");
|
|
7785
|
+
if (fs28.existsSync(oldJsonPath)) {
|
|
7840
7786
|
try {
|
|
7841
7787
|
if (!dryRun) {
|
|
7842
|
-
|
|
7788
|
+
fs28.unlinkSync(oldJsonPath);
|
|
7843
7789
|
}
|
|
7844
7790
|
deletedFiles.push("capabilities.json");
|
|
7845
7791
|
} catch (error) {
|
|
@@ -7847,11 +7793,11 @@ function cleanupOldFiles(capabilities, dryRun) {
|
|
|
7847
7793
|
}
|
|
7848
7794
|
}
|
|
7849
7795
|
for (const cap of capabilities) {
|
|
7850
|
-
const tsFilePath =
|
|
7851
|
-
if (
|
|
7796
|
+
const tsFilePath = path23.join(capabilitiesDir, `${cap.id}.ts`);
|
|
7797
|
+
if (fs28.existsSync(tsFilePath)) {
|
|
7852
7798
|
try {
|
|
7853
7799
|
if (!dryRun) {
|
|
7854
|
-
|
|
7800
|
+
fs28.unlinkSync(tsFilePath);
|
|
7855
7801
|
}
|
|
7856
7802
|
deletedFiles.push(`${cap.id}.ts`);
|
|
7857
7803
|
} catch (error) {
|
|
@@ -7867,8 +7813,8 @@ function cleanupOldFiles(capabilities, dryRun) {
|
|
|
7867
7813
|
}
|
|
7868
7814
|
|
|
7869
7815
|
// src/commands/migration/versions/v001_capability/report-generator.ts
|
|
7870
|
-
import
|
|
7871
|
-
import
|
|
7816
|
+
import fs29 from "fs";
|
|
7817
|
+
import path24 from "path";
|
|
7872
7818
|
var REPORT_FILE = "capability-migration-report.md";
|
|
7873
7819
|
function printSummary(result) {
|
|
7874
7820
|
const { jsonMigration, pluginInstallation, codeMigration, cleanup } = result;
|
|
@@ -8031,15 +7977,15 @@ async function generateReport(result) {
|
|
|
8031
7977
|
}
|
|
8032
7978
|
lines.push("");
|
|
8033
7979
|
const logDir = process.env.LOG_DIR || "logs";
|
|
8034
|
-
if (!
|
|
7980
|
+
if (!fs29.existsSync(logDir)) {
|
|
8035
7981
|
return;
|
|
8036
7982
|
}
|
|
8037
|
-
const reportDir =
|
|
8038
|
-
if (!
|
|
8039
|
-
|
|
7983
|
+
const reportDir = path24.join(logDir, "migration");
|
|
7984
|
+
if (!fs29.existsSync(reportDir)) {
|
|
7985
|
+
fs29.mkdirSync(reportDir, { recursive: true });
|
|
8040
7986
|
}
|
|
8041
|
-
const reportPath =
|
|
8042
|
-
|
|
7987
|
+
const reportPath = path24.join(reportDir, REPORT_FILE);
|
|
7988
|
+
fs29.writeFileSync(reportPath, lines.join("\n"), "utf-8");
|
|
8043
7989
|
console.log(`\u{1F4C4} Report generated: ${reportPath}`);
|
|
8044
7990
|
}
|
|
8045
7991
|
|
|
@@ -8571,10 +8517,10 @@ var migrationCommand = {
|
|
|
8571
8517
|
};
|
|
8572
8518
|
|
|
8573
8519
|
// src/commands/read-logs/index.ts
|
|
8574
|
-
import
|
|
8520
|
+
import path25 from "path";
|
|
8575
8521
|
|
|
8576
8522
|
// src/commands/read-logs/std-utils.ts
|
|
8577
|
-
import
|
|
8523
|
+
import fs30 from "fs";
|
|
8578
8524
|
function formatStdPrefixTime(localTime) {
|
|
8579
8525
|
const match = localTime.match(/^(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})$/);
|
|
8580
8526
|
if (!match) return localTime;
|
|
@@ -8604,11 +8550,11 @@ function stripPrefixFromStdLine(line) {
|
|
|
8604
8550
|
return `[${time}] ${content}`;
|
|
8605
8551
|
}
|
|
8606
8552
|
function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarker) {
|
|
8607
|
-
const stat =
|
|
8553
|
+
const stat = fs30.statSync(filePath);
|
|
8608
8554
|
if (stat.size === 0) {
|
|
8609
8555
|
return { lines: [], markerFound: false, totalLinesCount: 0 };
|
|
8610
8556
|
}
|
|
8611
|
-
const fd =
|
|
8557
|
+
const fd = fs30.openSync(filePath, "r");
|
|
8612
8558
|
const chunkSize = 64 * 1024;
|
|
8613
8559
|
let position = stat.size;
|
|
8614
8560
|
let remainder = "";
|
|
@@ -8622,7 +8568,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
|
|
|
8622
8568
|
const length = Math.min(chunkSize, position);
|
|
8623
8569
|
position -= length;
|
|
8624
8570
|
const buffer = Buffer.alloc(length);
|
|
8625
|
-
|
|
8571
|
+
fs30.readSync(fd, buffer, 0, length, position);
|
|
8626
8572
|
let chunk = buffer.toString("utf8");
|
|
8627
8573
|
if (remainder) {
|
|
8628
8574
|
chunk += remainder;
|
|
@@ -8664,7 +8610,7 @@ function readStdLinesTailFromLastMarkerPaged(filePath, maxLines, offset, isMarke
|
|
|
8664
8610
|
}
|
|
8665
8611
|
}
|
|
8666
8612
|
} finally {
|
|
8667
|
-
|
|
8613
|
+
fs30.closeSync(fd);
|
|
8668
8614
|
}
|
|
8669
8615
|
return { lines: collected.reverse(), markerFound, totalLinesCount };
|
|
8670
8616
|
}
|
|
@@ -8685,21 +8631,21 @@ function readServerStdSegment(filePath, maxLines, offset) {
|
|
|
8685
8631
|
}
|
|
8686
8632
|
|
|
8687
8633
|
// src/commands/read-logs/tail.ts
|
|
8688
|
-
import
|
|
8634
|
+
import fs31 from "fs";
|
|
8689
8635
|
function fileExists(filePath) {
|
|
8690
8636
|
try {
|
|
8691
|
-
|
|
8637
|
+
fs31.accessSync(filePath, fs31.constants.F_OK | fs31.constants.R_OK);
|
|
8692
8638
|
return true;
|
|
8693
8639
|
} catch {
|
|
8694
8640
|
return false;
|
|
8695
8641
|
}
|
|
8696
8642
|
}
|
|
8697
8643
|
function readFileTailLines(filePath, maxLines) {
|
|
8698
|
-
const stat =
|
|
8644
|
+
const stat = fs31.statSync(filePath);
|
|
8699
8645
|
if (stat.size === 0) {
|
|
8700
8646
|
return [];
|
|
8701
8647
|
}
|
|
8702
|
-
const fd =
|
|
8648
|
+
const fd = fs31.openSync(filePath, "r");
|
|
8703
8649
|
const chunkSize = 64 * 1024;
|
|
8704
8650
|
const chunks = [];
|
|
8705
8651
|
let position = stat.size;
|
|
@@ -8709,13 +8655,13 @@ function readFileTailLines(filePath, maxLines) {
|
|
|
8709
8655
|
const length = Math.min(chunkSize, position);
|
|
8710
8656
|
position -= length;
|
|
8711
8657
|
const buffer = Buffer.alloc(length);
|
|
8712
|
-
|
|
8658
|
+
fs31.readSync(fd, buffer, 0, length, position);
|
|
8713
8659
|
chunks.unshift(buffer.toString("utf8"));
|
|
8714
8660
|
const chunkLines = buffer.toString("utf8").split("\n").length - 1;
|
|
8715
8661
|
collectedLines += chunkLines;
|
|
8716
8662
|
}
|
|
8717
8663
|
} finally {
|
|
8718
|
-
|
|
8664
|
+
fs31.closeSync(fd);
|
|
8719
8665
|
}
|
|
8720
8666
|
const content = chunks.join("");
|
|
8721
8667
|
const allLines = content.split("\n");
|
|
@@ -8731,11 +8677,11 @@ function readFileTailLines(filePath, maxLines) {
|
|
|
8731
8677
|
return allLines.slice(allLines.length - maxLines);
|
|
8732
8678
|
}
|
|
8733
8679
|
function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
8734
|
-
const stat =
|
|
8680
|
+
const stat = fs31.statSync(filePath);
|
|
8735
8681
|
if (stat.size === 0) {
|
|
8736
8682
|
return { lines: [], totalLinesCount: 0 };
|
|
8737
8683
|
}
|
|
8738
|
-
const fd =
|
|
8684
|
+
const fd = fs31.openSync(filePath, "r");
|
|
8739
8685
|
const chunkSize = 64 * 1024;
|
|
8740
8686
|
let position = stat.size;
|
|
8741
8687
|
let remainder = "";
|
|
@@ -8747,7 +8693,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
|
8747
8693
|
const length = Math.min(chunkSize, position);
|
|
8748
8694
|
position -= length;
|
|
8749
8695
|
const buffer = Buffer.alloc(length);
|
|
8750
|
-
|
|
8696
|
+
fs31.readSync(fd, buffer, 0, length, position);
|
|
8751
8697
|
let chunk = buffer.toString("utf8");
|
|
8752
8698
|
if (remainder) {
|
|
8753
8699
|
chunk += remainder;
|
|
@@ -8778,7 +8724,7 @@ function readFileTailNonEmptyLinesWithOffset(filePath, maxLines, offset) {
|
|
|
8778
8724
|
}
|
|
8779
8725
|
}
|
|
8780
8726
|
} finally {
|
|
8781
|
-
|
|
8727
|
+
fs31.closeSync(fd);
|
|
8782
8728
|
}
|
|
8783
8729
|
return { lines: collected.reverse(), totalLinesCount };
|
|
8784
8730
|
}
|
|
@@ -8920,7 +8866,7 @@ function readDevStdSegment(filePath, maxLines, offset) {
|
|
|
8920
8866
|
}
|
|
8921
8867
|
|
|
8922
8868
|
// src/commands/read-logs/json-lines.ts
|
|
8923
|
-
import
|
|
8869
|
+
import fs32 from "fs";
|
|
8924
8870
|
|
|
8925
8871
|
// src/commands/read-logs/structured-log.ts
|
|
8926
8872
|
function normalizeLevelName(value) {
|
|
@@ -8996,11 +8942,11 @@ function buildWantedLevelSet(levels) {
|
|
|
8996
8942
|
return set.size > 0 ? set : null;
|
|
8997
8943
|
}
|
|
8998
8944
|
function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
8999
|
-
const stat =
|
|
8945
|
+
const stat = fs32.statSync(filePath);
|
|
9000
8946
|
if (stat.size === 0) {
|
|
9001
8947
|
return { lines: [], totalLinesCount: 0 };
|
|
9002
8948
|
}
|
|
9003
|
-
const fd =
|
|
8949
|
+
const fd = fs32.openSync(filePath, "r");
|
|
9004
8950
|
const chunkSize = 64 * 1024;
|
|
9005
8951
|
let position = stat.size;
|
|
9006
8952
|
let remainder = "";
|
|
@@ -9015,7 +8961,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
|
9015
8961
|
const length = Math.min(chunkSize, position);
|
|
9016
8962
|
position -= length;
|
|
9017
8963
|
const buffer = Buffer.alloc(length);
|
|
9018
|
-
|
|
8964
|
+
fs32.readSync(fd, buffer, 0, length, position);
|
|
9019
8965
|
let chunk = buffer.toString("utf8");
|
|
9020
8966
|
if (remainder) {
|
|
9021
8967
|
chunk += remainder;
|
|
@@ -9077,7 +9023,7 @@ function readJsonLinesLastPid(filePath, maxLines, offset, levels) {
|
|
|
9077
9023
|
}
|
|
9078
9024
|
}
|
|
9079
9025
|
} finally {
|
|
9080
|
-
|
|
9026
|
+
fs32.closeSync(fd);
|
|
9081
9027
|
}
|
|
9082
9028
|
return { lines: collected.reverse(), totalLinesCount };
|
|
9083
9029
|
}
|
|
@@ -9120,11 +9066,11 @@ function extractTraceId(obj) {
|
|
|
9120
9066
|
function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
9121
9067
|
const wanted = traceId.trim();
|
|
9122
9068
|
if (!wanted) return { lines: [], totalLinesCount: 0 };
|
|
9123
|
-
const stat =
|
|
9069
|
+
const stat = fs32.statSync(filePath);
|
|
9124
9070
|
if (stat.size === 0) {
|
|
9125
9071
|
return { lines: [], totalLinesCount: 0 };
|
|
9126
9072
|
}
|
|
9127
|
-
const fd =
|
|
9073
|
+
const fd = fs32.openSync(filePath, "r");
|
|
9128
9074
|
const chunkSize = 64 * 1024;
|
|
9129
9075
|
let position = stat.size;
|
|
9130
9076
|
let remainder = "";
|
|
@@ -9137,7 +9083,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
|
9137
9083
|
const length = Math.min(chunkSize, position);
|
|
9138
9084
|
position -= length;
|
|
9139
9085
|
const buffer = Buffer.alloc(length);
|
|
9140
|
-
|
|
9086
|
+
fs32.readSync(fd, buffer, 0, length, position);
|
|
9141
9087
|
let chunk = buffer.toString("utf8");
|
|
9142
9088
|
if (remainder) {
|
|
9143
9089
|
chunk += remainder;
|
|
@@ -9190,7 +9136,7 @@ function readJsonLinesByTraceId(filePath, traceId, maxLines, offset, levels) {
|
|
|
9190
9136
|
}
|
|
9191
9137
|
}
|
|
9192
9138
|
} finally {
|
|
9193
|
-
|
|
9139
|
+
fs32.closeSync(fd);
|
|
9194
9140
|
}
|
|
9195
9141
|
return { lines: collected.reverse(), totalLinesCount };
|
|
9196
9142
|
}
|
|
@@ -9199,11 +9145,11 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
9199
9145
|
if (!wantedLevelSet) {
|
|
9200
9146
|
return { lines: [], totalLinesCount: 0 };
|
|
9201
9147
|
}
|
|
9202
|
-
const stat =
|
|
9148
|
+
const stat = fs32.statSync(filePath);
|
|
9203
9149
|
if (stat.size === 0) {
|
|
9204
9150
|
return { lines: [], totalLinesCount: 0 };
|
|
9205
9151
|
}
|
|
9206
|
-
const fd =
|
|
9152
|
+
const fd = fs32.openSync(filePath, "r");
|
|
9207
9153
|
const chunkSize = 64 * 1024;
|
|
9208
9154
|
let position = stat.size;
|
|
9209
9155
|
let remainder = "";
|
|
@@ -9215,7 +9161,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
9215
9161
|
const length = Math.min(chunkSize, position);
|
|
9216
9162
|
position -= length;
|
|
9217
9163
|
const buffer = Buffer.alloc(length);
|
|
9218
|
-
|
|
9164
|
+
fs32.readSync(fd, buffer, 0, length, position);
|
|
9219
9165
|
let chunk = buffer.toString("utf8");
|
|
9220
9166
|
if (remainder) {
|
|
9221
9167
|
chunk += remainder;
|
|
@@ -9262,7 +9208,7 @@ function readJsonLinesTailByLevel(filePath, maxLines, offset, levels) {
|
|
|
9262
9208
|
}
|
|
9263
9209
|
}
|
|
9264
9210
|
} finally {
|
|
9265
|
-
|
|
9211
|
+
fs32.closeSync(fd);
|
|
9266
9212
|
}
|
|
9267
9213
|
return { lines: collected.reverse(), totalLinesCount };
|
|
9268
9214
|
}
|
|
@@ -9755,30 +9701,30 @@ async function readLogsJsonResult(options) {
|
|
|
9755
9701
|
};
|
|
9756
9702
|
}
|
|
9757
9703
|
function resolveLogFilePath(logDir, type) {
|
|
9758
|
-
const base =
|
|
9704
|
+
const base = path25.isAbsolute(logDir) ? logDir : path25.join(process.cwd(), logDir);
|
|
9759
9705
|
if (type === "server") {
|
|
9760
|
-
return
|
|
9706
|
+
return path25.join(base, "server.log");
|
|
9761
9707
|
}
|
|
9762
9708
|
if (type === "trace") {
|
|
9763
|
-
return
|
|
9709
|
+
return path25.join(base, "trace.log");
|
|
9764
9710
|
}
|
|
9765
9711
|
if (type === "server-std") {
|
|
9766
|
-
return
|
|
9712
|
+
return path25.join(base, "server.std.log");
|
|
9767
9713
|
}
|
|
9768
9714
|
if (type === "client-std") {
|
|
9769
|
-
return
|
|
9715
|
+
return path25.join(base, "client.std.log");
|
|
9770
9716
|
}
|
|
9771
9717
|
if (type === "dev") {
|
|
9772
|
-
return
|
|
9718
|
+
return path25.join(base, "dev.log");
|
|
9773
9719
|
}
|
|
9774
9720
|
if (type === "dev-std") {
|
|
9775
|
-
return
|
|
9721
|
+
return path25.join(base, "dev.std.log");
|
|
9776
9722
|
}
|
|
9777
9723
|
if (type === "install-dep-std") {
|
|
9778
|
-
return
|
|
9724
|
+
return path25.join(base, "install-dep.std.log");
|
|
9779
9725
|
}
|
|
9780
9726
|
if (type === "browser") {
|
|
9781
|
-
return
|
|
9727
|
+
return path25.join(base, "browser.log");
|
|
9782
9728
|
}
|
|
9783
9729
|
throw new Error(`Unsupported log type: ${type}`);
|
|
9784
9730
|
}
|
|
@@ -9948,9 +9894,9 @@ function camelToKebab2(str) {
|
|
|
9948
9894
|
}
|
|
9949
9895
|
|
|
9950
9896
|
// src/commands/build/upload-static.handler.ts
|
|
9951
|
-
import * as
|
|
9897
|
+
import * as fs33 from "fs";
|
|
9952
9898
|
import * as os2 from "os";
|
|
9953
|
-
import * as
|
|
9899
|
+
import * as path26 from "path";
|
|
9954
9900
|
import { execFileSync } from "child_process";
|
|
9955
9901
|
function readCredentialsFromEnv() {
|
|
9956
9902
|
const uploadPrefix = process.env.STATIC_UPLOAD_PREFIX;
|
|
@@ -9974,8 +9920,8 @@ async function uploadStatic(options) {
|
|
|
9974
9920
|
endpoint = UPLOAD_STATIC_DEFAULTS.endpoint,
|
|
9975
9921
|
region = UPLOAD_STATIC_DEFAULTS.region
|
|
9976
9922
|
} = options;
|
|
9977
|
-
const resolvedStaticDir =
|
|
9978
|
-
if (!
|
|
9923
|
+
const resolvedStaticDir = path26.resolve(staticDir);
|
|
9924
|
+
if (!fs33.existsSync(resolvedStaticDir)) {
|
|
9979
9925
|
console.error(`${LOG_PREFIX} \u76EE\u5F55\u4E0D\u5B58\u5728: ${resolvedStaticDir}\uFF0C\u8DF3\u8FC7\u4E0A\u4F20`);
|
|
9980
9926
|
return;
|
|
9981
9927
|
}
|
|
@@ -10008,8 +9954,8 @@ async function uploadStatic(options) {
|
|
|
10008
9954
|
({ AccessKeyID: accessKeyID, SecretAccessKey: secretAccessKey, SessionToken: sessionToken } = uploadCredential);
|
|
10009
9955
|
}
|
|
10010
9956
|
console.error(`${LOG_PREFIX} \u4E0A\u4F20\u76EE\u6807: ${uploadPrefix}`);
|
|
10011
|
-
const confPath =
|
|
10012
|
-
|
|
9957
|
+
const confPath = path26.join(os2.tmpdir(), `.tosutilconfig-static-${process.pid}`);
|
|
9958
|
+
fs33.writeFileSync(confPath, "");
|
|
10013
9959
|
try {
|
|
10014
9960
|
console.error(`${LOG_PREFIX} \u914D\u7F6E tosutil...`);
|
|
10015
9961
|
configureTosutil(resolvedTosutil, confPath, {
|
|
@@ -10023,7 +9969,7 @@ async function uploadStatic(options) {
|
|
|
10023
9969
|
uploadToTos(resolvedTosutil, confPath, resolvedStaticDir, uploadPrefix);
|
|
10024
9970
|
} finally {
|
|
10025
9971
|
try {
|
|
10026
|
-
|
|
9972
|
+
fs33.unlinkSync(confPath);
|
|
10027
9973
|
} catch {
|
|
10028
9974
|
}
|
|
10029
9975
|
}
|
|
@@ -10043,8 +9989,8 @@ async function uploadStatic(options) {
|
|
|
10043
9989
|
}
|
|
10044
9990
|
}
|
|
10045
9991
|
function resolveTosutilPath(tosutilPath) {
|
|
10046
|
-
if (
|
|
10047
|
-
return
|
|
9992
|
+
if (path26.isAbsolute(tosutilPath)) {
|
|
9993
|
+
return fs33.existsSync(tosutilPath) ? tosutilPath : null;
|
|
10048
9994
|
}
|
|
10049
9995
|
try {
|
|
10050
9996
|
const resolved = execFileSync("which", [tosutilPath], { encoding: "utf-8" }).trim();
|
|
@@ -10089,7 +10035,7 @@ async function resolveBucketId(appId) {
|
|
|
10089
10035
|
return bucketId;
|
|
10090
10036
|
}
|
|
10091
10037
|
function isDirEmpty(dirPath) {
|
|
10092
|
-
const entries =
|
|
10038
|
+
const entries = fs33.readdirSync(dirPath);
|
|
10093
10039
|
return entries.length === 0;
|
|
10094
10040
|
}
|
|
10095
10041
|
|
|
@@ -10185,13 +10131,13 @@ var commands = [
|
|
|
10185
10131
|
|
|
10186
10132
|
// src/index.ts
|
|
10187
10133
|
for (const filename of [".env.local", ".env"]) {
|
|
10188
|
-
const envPath =
|
|
10189
|
-
if (
|
|
10134
|
+
const envPath = path27.join(process.cwd(), filename);
|
|
10135
|
+
if (fs34.existsSync(envPath)) {
|
|
10190
10136
|
dotenvConfig({ path: envPath });
|
|
10191
10137
|
}
|
|
10192
10138
|
}
|
|
10193
|
-
var __dirname =
|
|
10194
|
-
var pkg = JSON.parse(
|
|
10139
|
+
var __dirname = path27.dirname(fileURLToPath5(import.meta.url));
|
|
10140
|
+
var pkg = JSON.parse(fs34.readFileSync(path27.join(__dirname, "../package.json"), "utf-8"));
|
|
10195
10141
|
var cli = new FullstackCLI(pkg.version);
|
|
10196
10142
|
cli.useAll(commands);
|
|
10197
10143
|
cli.run();
|