ai-project-manage-cli 6.0.109 → 6.0.111
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 +231 -91
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2637,13 +2637,32 @@ function validateDeployPush(o) {
|
|
|
2637
2637
|
}
|
|
2638
2638
|
};
|
|
2639
2639
|
}
|
|
2640
|
+
function validateSessionCacheCleanupPush(o) {
|
|
2641
|
+
if (o.type !== "session-cache-cleanup") {
|
|
2642
|
+
return { ok: false, reason: "\u671F\u671B session-cache-cleanup" };
|
|
2643
|
+
}
|
|
2644
|
+
if (!nonEmptyString(o.sessionId)) {
|
|
2645
|
+
return { ok: false, reason: "session-cache-cleanup \u7F3A\u5C11 sessionId" };
|
|
2646
|
+
}
|
|
2647
|
+
if (!nonEmptyString(o.workdir)) {
|
|
2648
|
+
return { ok: false, reason: "session-cache-cleanup \u7F3A\u5C11 workdir" };
|
|
2649
|
+
}
|
|
2650
|
+
return {
|
|
2651
|
+
ok: true,
|
|
2652
|
+
data: {
|
|
2653
|
+
type: "session-cache-cleanup",
|
|
2654
|
+
sessionId: o.sessionId.trim(),
|
|
2655
|
+
workdir: o.workdir.trim()
|
|
2656
|
+
}
|
|
2657
|
+
};
|
|
2658
|
+
}
|
|
2640
2659
|
function validateAgentWsMessage(value, kind) {
|
|
2641
2660
|
if (typeof value !== "object" || value === null) {
|
|
2642
2661
|
return { ok: false, reason: "\u6D88\u606F\u4F53\u4E0D\u662F JSON \u5BF9\u8C61" };
|
|
2643
2662
|
}
|
|
2644
2663
|
const o = value;
|
|
2645
2664
|
const type = o.type;
|
|
2646
|
-
if (type !== "heartbeat" && type !== "message" && type !== "cancel" && type !== "deploy") {
|
|
2665
|
+
if (type !== "heartbeat" && type !== "message" && type !== "cancel" && type !== "deploy" && type !== "session-cache-cleanup") {
|
|
2647
2666
|
return { ok: false, reason: `\u672A\u77E5 type: ${String(type)}` };
|
|
2648
2667
|
}
|
|
2649
2668
|
if (kind === "heartbeat" || type === "heartbeat") {
|
|
@@ -2655,6 +2674,9 @@ function validateAgentWsMessage(value, kind) {
|
|
|
2655
2674
|
if (type === "deploy") {
|
|
2656
2675
|
return validateDeployPush(o);
|
|
2657
2676
|
}
|
|
2677
|
+
if (type === "session-cache-cleanup") {
|
|
2678
|
+
return validateSessionCacheCleanupPush(o);
|
|
2679
|
+
}
|
|
2658
2680
|
return validateMessagePush(o);
|
|
2659
2681
|
}
|
|
2660
2682
|
|
|
@@ -2893,6 +2915,19 @@ function posixBasename(p) {
|
|
|
2893
2915
|
const idx = normalized.lastIndexOf("/");
|
|
2894
2916
|
return idx >= 0 ? normalized.slice(idx + 1) : normalized;
|
|
2895
2917
|
}
|
|
2918
|
+
function resolveWisdomBackendPackOnlyFromApmConfig(cfg) {
|
|
2919
|
+
const projectName = reqTopLevelName(cfg);
|
|
2920
|
+
const w = cfg.wisdomDeploy ?? {};
|
|
2921
|
+
const mavenLocalRepo = resolveMavenLocalRepoWithSource();
|
|
2922
|
+
return {
|
|
2923
|
+
projectName,
|
|
2924
|
+
packageName: `${projectName}.jar.zip`,
|
|
2925
|
+
mavenLocalRepo: mavenLocalRepo.path,
|
|
2926
|
+
mavenLocalRepoSource: mavenLocalRepo.source,
|
|
2927
|
+
mavenLocalRepoSourceDetail: mavenLocalRepo.sourceDetail,
|
|
2928
|
+
mode: resolveWisdomDeployMode(w.mode)
|
|
2929
|
+
};
|
|
2930
|
+
}
|
|
2896
2931
|
function resolveWisdomBackendDeployFromApmConfig(cfg) {
|
|
2897
2932
|
const projectName = reqTopLevelName(cfg);
|
|
2898
2933
|
const w = cfg.wisdomDeploy ?? {};
|
|
@@ -2987,8 +3022,8 @@ var DeployExecutionError = class extends Error {
|
|
|
2987
3022
|
|
|
2988
3023
|
// src/commands/deploy/deploy-debug-log.ts
|
|
2989
3024
|
import { spawnSync as spawnSync4 } from "node:child_process";
|
|
2990
|
-
import { existsSync as
|
|
2991
|
-
import { dirname as dirname5, join as
|
|
3025
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
3026
|
+
import { dirname as dirname5, join as join17 } from "node:path";
|
|
2992
3027
|
|
|
2993
3028
|
// src/commands/deploy/internal/deploy-artifact-minio.ts
|
|
2994
3029
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -3242,7 +3277,8 @@ async function uploadDeployArtifactZip(options) {
|
|
|
3242
3277
|
|
|
3243
3278
|
// src/commands/deploy/internal/deploy-shell-env.ts
|
|
3244
3279
|
import { spawnSync as spawnSync3 } from "node:child_process";
|
|
3245
|
-
import {
|
|
3280
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
3281
|
+
import { dirname as dirname4, join as join16 } from "node:path";
|
|
3246
3282
|
|
|
3247
3283
|
// src/commands/daemon.ts
|
|
3248
3284
|
import { spawnSync as spawnSync2 } from "child_process";
|
|
@@ -4018,17 +4054,38 @@ async function runDaemonLogs(options) {
|
|
|
4018
4054
|
// src/commands/deploy/internal/deploy-shell-env.ts
|
|
4019
4055
|
var PATH_SEP = process.platform === "win32" ? ";" : ":";
|
|
4020
4056
|
var useNpmShell3 = process.platform === "win32";
|
|
4021
|
-
function
|
|
4022
|
-
|
|
4023
|
-
|
|
4024
|
-
|
|
4025
|
-
|
|
4026
|
-
|
|
4027
|
-
|
|
4057
|
+
function readEnvPath(env) {
|
|
4058
|
+
if (process.platform === "win32") {
|
|
4059
|
+
return env.Path ?? env.PATH ?? "";
|
|
4060
|
+
}
|
|
4061
|
+
return env.PATH ?? "";
|
|
4062
|
+
}
|
|
4063
|
+
function writeEnvPath(env, value) {
|
|
4064
|
+
if (process.platform === "win32") {
|
|
4065
|
+
env.Path = value;
|
|
4066
|
+
delete env.PATH;
|
|
4067
|
+
return;
|
|
4068
|
+
}
|
|
4069
|
+
env.PATH = value;
|
|
4070
|
+
}
|
|
4071
|
+
function resolveNodeInstallDir() {
|
|
4072
|
+
return dirname4(process.execPath);
|
|
4073
|
+
}
|
|
4074
|
+
function resolveNpmCmdPath() {
|
|
4075
|
+
if (process.platform !== "win32") {
|
|
4028
4076
|
return null;
|
|
4029
4077
|
}
|
|
4030
|
-
const
|
|
4031
|
-
return
|
|
4078
|
+
const candidate = join16(resolveNodeInstallDir(), "npm.cmd");
|
|
4079
|
+
return existsSync15(candidate) ? candidate : null;
|
|
4080
|
+
}
|
|
4081
|
+
function formatNpmRunShellCommand(scriptName) {
|
|
4082
|
+
const trimmed = scriptName.trim();
|
|
4083
|
+
if (process.platform !== "win32") {
|
|
4084
|
+
return `npm run ${trimmed}`;
|
|
4085
|
+
}
|
|
4086
|
+
const npmCmd = resolveNpmCmdPath();
|
|
4087
|
+
const npm = npmCmd ? `"${npmCmd}"` : "npm.cmd";
|
|
4088
|
+
return `${npm} run ${trimmed}`;
|
|
4032
4089
|
}
|
|
4033
4090
|
function prependPath(pathValue, segment) {
|
|
4034
4091
|
if (!segment) {
|
|
@@ -4043,10 +4100,22 @@ function prependPath(pathValue, segment) {
|
|
|
4043
4100
|
}
|
|
4044
4101
|
return `${segment}${PATH_SEP}${pathValue}`;
|
|
4045
4102
|
}
|
|
4103
|
+
function spawnNpm(args, env) {
|
|
4104
|
+
const npmCmdPath = resolveNpmCmdPath();
|
|
4105
|
+
return spawnSync3(npmCmdPath ?? (useNpmShell3 ? "npm.cmd" : "npm"), args, {
|
|
4106
|
+
encoding: "utf8",
|
|
4107
|
+
shell: useNpmShell3 && !npmCmdPath,
|
|
4108
|
+
env,
|
|
4109
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
4110
|
+
});
|
|
4111
|
+
}
|
|
4112
|
+
function resolveNpmGlobalBin2() {
|
|
4113
|
+
return resolveNpmGlobalBinWithoutEnv(process.env);
|
|
4114
|
+
}
|
|
4046
4115
|
function buildDeployShellEnv(extra) {
|
|
4047
4116
|
const env = { ...process.env, ...extra };
|
|
4048
|
-
const pathSegments = [
|
|
4049
|
-
const globalBin =
|
|
4117
|
+
const pathSegments = [resolveNodeInstallDir()];
|
|
4118
|
+
const globalBin = resolveNpmGlobalBinWithoutEnv(env);
|
|
4050
4119
|
if (globalBin) {
|
|
4051
4120
|
pathSegments.push(globalBin);
|
|
4052
4121
|
}
|
|
@@ -4054,11 +4123,29 @@ function buildDeployShellEnv(extra) {
|
|
|
4054
4123
|
resolveApmEntryPath();
|
|
4055
4124
|
} catch {
|
|
4056
4125
|
}
|
|
4126
|
+
let pathValue = readEnvPath(env);
|
|
4057
4127
|
for (const segment of pathSegments) {
|
|
4058
|
-
|
|
4128
|
+
pathValue = prependPath(pathValue, segment);
|
|
4059
4129
|
}
|
|
4130
|
+
writeEnvPath(env, pathValue);
|
|
4131
|
+
return env;
|
|
4132
|
+
}
|
|
4133
|
+
function buildDeployShellEnvWithoutGlobalBin(extra) {
|
|
4134
|
+
const env = { ...process.env, ...extra };
|
|
4135
|
+
let pathValue = readEnvPath(env);
|
|
4136
|
+
pathValue = prependPath(pathValue, resolveNodeInstallDir());
|
|
4137
|
+
writeEnvPath(env, pathValue);
|
|
4060
4138
|
return env;
|
|
4061
4139
|
}
|
|
4140
|
+
function resolveNpmGlobalBinWithoutEnv(baseEnv) {
|
|
4141
|
+
const env = buildDeployShellEnvWithoutGlobalBin(baseEnv);
|
|
4142
|
+
const result = spawnNpm(["bin", "-g"], env);
|
|
4143
|
+
if (result.status !== 0) {
|
|
4144
|
+
return null;
|
|
4145
|
+
}
|
|
4146
|
+
const bin = result.stdout?.toString().trim();
|
|
4147
|
+
return bin || null;
|
|
4148
|
+
}
|
|
4062
4149
|
|
|
4063
4150
|
// src/commands/deploy/deploy-debug-log.ts
|
|
4064
4151
|
var LOG_PREFIX = "[apm:deploy-debug]";
|
|
@@ -4161,7 +4248,7 @@ function logExecuteDeployContext(input) {
|
|
|
4161
4248
|
const deploymentRunId = process.env[APM_DEPLOYMENT_RUN_ID_ENV]?.trim() || null;
|
|
4162
4249
|
const shellEnv = buildDeployShellEnv();
|
|
4163
4250
|
const npmGlobalBin = resolveNpmGlobalBin2();
|
|
4164
|
-
const packageJsonPath =
|
|
4251
|
+
const packageJsonPath = join17(input.cwd, "package.json");
|
|
4165
4252
|
logLine("========== executeDeploy \u4E0A\u4E0B\u6587 ==========");
|
|
4166
4253
|
logLine(`trigger=${trigger} deployEnv=${input.env}`);
|
|
4167
4254
|
logLine(`cwd(input)=${input.cwdInput}`);
|
|
@@ -4171,12 +4258,12 @@ function logExecuteDeployContext(input) {
|
|
|
4171
4258
|
`cwdMatchProcess=${input.cwd === input.processCwd ? "yes" : "no"} (connect \u901A\u5E38\u4E3A no)`
|
|
4172
4259
|
);
|
|
4173
4260
|
logLine(
|
|
4174
|
-
`apm.config=${input.apmConfigPath} exists=${
|
|
4261
|
+
`apm.config=${input.apmConfigPath} exists=${existsSync16(
|
|
4175
4262
|
input.apmConfigPath
|
|
4176
4263
|
)}`
|
|
4177
4264
|
);
|
|
4178
4265
|
logLine(
|
|
4179
|
-
`package.json=${packageJsonPath} exists=${
|
|
4266
|
+
`package.json=${packageJsonPath} exists=${existsSync16(packageJsonPath)}`
|
|
4180
4267
|
);
|
|
4181
4268
|
logLine(
|
|
4182
4269
|
`flags captureOutput=${input.captureOutput} packOnly=${Boolean(
|
|
@@ -4197,10 +4284,10 @@ function logExecuteDeployContext(input) {
|
|
|
4197
4284
|
)) {
|
|
4198
4285
|
logLine(` ${key}=${value}`);
|
|
4199
4286
|
}
|
|
4200
|
-
logLine(`process.env.PATH=${summarizePath(process.env
|
|
4287
|
+
logLine(`process.env.PATH=${summarizePath(readEnvPath(process.env))}`);
|
|
4201
4288
|
logLine("--- buildDeployShellEnv()\uFF08\u5B50\u8FDB\u7A0B\u5B9E\u9645 env\uFF09---");
|
|
4202
|
-
logLine(describePathDelta(process.env
|
|
4203
|
-
logLine(`shellEnv.PATH=${summarizePath(shellEnv
|
|
4289
|
+
logLine(describePathDelta(readEnvPath(process.env), readEnvPath(shellEnv)));
|
|
4290
|
+
logLine(`shellEnv.PATH=${summarizePath(readEnvPath(shellEnv))}`);
|
|
4204
4291
|
for (const [key, value] of Object.entries(
|
|
4205
4292
|
pickEnvKeys(shellEnv, [APM_DEPLOYMENT_RUN_ID_ENV, "NODE_ENV"])
|
|
4206
4293
|
)) {
|
|
@@ -4219,7 +4306,7 @@ function logRunDeployShellContext(input) {
|
|
|
4219
4306
|
`stdio=${input.captureOutput ? "stdin=inherit stdout=pipe stderr=pipe" : "inherit"}`
|
|
4220
4307
|
);
|
|
4221
4308
|
logLine(`shell=true maxBuffer=${50 * 1024 * 1024}`);
|
|
4222
|
-
logLine(`shellEnv.PATH(head)=${summarizePath(shellEnv
|
|
4309
|
+
logLine(`shellEnv.PATH(head)=${summarizePath(readEnvPath(shellEnv), 8)}`);
|
|
4223
4310
|
logLine("--------------------------------------------");
|
|
4224
4311
|
}
|
|
4225
4312
|
function logRunDeployShellResult(input) {
|
|
@@ -4232,14 +4319,14 @@ function logWisdomFrontendDeployContext(input) {
|
|
|
4232
4319
|
logLine(
|
|
4233
4320
|
`buildKey=build:${input.env} buildCmd=${input.buildCmd ?? "(missing)"}`
|
|
4234
4321
|
);
|
|
4235
|
-
logLine(`distDir=${input.distDir} exists=${
|
|
4322
|
+
logLine(`distDir=${input.distDir} exists=${existsSync16(input.distDir)}`);
|
|
4236
4323
|
logLine(
|
|
4237
4324
|
`packOnly=${input.packOnly} archiveDeployArtifact=${input.archiveDeployArtifact}`
|
|
4238
4325
|
);
|
|
4239
4326
|
}
|
|
4240
4327
|
|
|
4241
4328
|
// src/commands/deploy/internal/wisdom-deploy.ts
|
|
4242
|
-
import { existsSync as
|
|
4329
|
+
import { existsSync as existsSync20, readFileSync as readFileSync15, statSync as statSync9 } from "node:fs";
|
|
4243
4330
|
import path10 from "node:path";
|
|
4244
4331
|
|
|
4245
4332
|
// src/commands/deploy/deploy-shell-run.ts
|
|
@@ -4348,7 +4435,7 @@ import JSZip2 from "jszip";
|
|
|
4348
4435
|
|
|
4349
4436
|
// src/commands/deploy/internal/wisdom-backend/manifest.ts
|
|
4350
4437
|
import {
|
|
4351
|
-
existsSync as
|
|
4438
|
+
existsSync as existsSync17,
|
|
4352
4439
|
mkdirSync as mkdirSync7,
|
|
4353
4440
|
readFileSync as readFileSync13,
|
|
4354
4441
|
statSync as statSync6,
|
|
@@ -4370,7 +4457,7 @@ function fileSignature(filePath) {
|
|
|
4370
4457
|
}
|
|
4371
4458
|
function loadManifest3() {
|
|
4372
4459
|
const manifestPath2 = manifestFilePath();
|
|
4373
|
-
if (!
|
|
4460
|
+
if (!existsSync17(manifestPath2)) {
|
|
4374
4461
|
return {};
|
|
4375
4462
|
}
|
|
4376
4463
|
return JSON.parse(readFileSync13(manifestPath2, "utf8"));
|
|
@@ -4641,6 +4728,12 @@ async function runWisdomSftpDeploy(params) {
|
|
|
4641
4728
|
});
|
|
4642
4729
|
let zipSizeBytes = 0;
|
|
4643
4730
|
let artifactUploaded = false;
|
|
4731
|
+
if (!packOnly && !params.settings) {
|
|
4732
|
+
throw new DeployExecutionError(
|
|
4733
|
+
"SFTP \u90E8\u7F72\u7F3A\u5C11 wisdomDeploy \u8FDE\u63A5\u914D\u7F6E\uFF08host\u3001remotePath \u7B49\uFF09",
|
|
4734
|
+
1
|
|
4735
|
+
);
|
|
4736
|
+
}
|
|
4644
4737
|
if (packOnly && artifactUpload.upload) {
|
|
4645
4738
|
const packed = await packDirectoryWithMinioArchive({
|
|
4646
4739
|
localDir: params.localDir,
|
|
@@ -4684,8 +4777,8 @@ async function runWisdomSftpDeploy(params) {
|
|
|
4684
4777
|
return {
|
|
4685
4778
|
ok: true,
|
|
4686
4779
|
localDir: params.localDir,
|
|
4687
|
-
host: params.settings
|
|
4688
|
-
remotePath: params.settings
|
|
4780
|
+
host: params.settings?.host ?? "",
|
|
4781
|
+
remotePath: params.settings?.remotePath ?? "",
|
|
4689
4782
|
zipSizeBytes,
|
|
4690
4783
|
extracted: packOnly ? false : params.extract,
|
|
4691
4784
|
packOnly,
|
|
@@ -4806,7 +4899,7 @@ function listAllLibFilesForArchive(libDir) {
|
|
|
4806
4899
|
}
|
|
4807
4900
|
|
|
4808
4901
|
// src/commands/deploy/internal/wisdom-backend/maven-build.ts
|
|
4809
|
-
import { existsSync as
|
|
4902
|
+
import { existsSync as existsSync19, readdirSync as readdirSync6, statSync as statSync8 } from "node:fs";
|
|
4810
4903
|
import path7 from "node:path";
|
|
4811
4904
|
import { spawnSync as spawnSync6 } from "node:child_process";
|
|
4812
4905
|
function getMvnExecutable() {
|
|
@@ -4855,11 +4948,11 @@ function runMavenBuild(projectRoot, mavenLocalRepo, repoSource) {
|
|
|
4855
4948
|
}
|
|
4856
4949
|
function locateLibDir(projectRoot) {
|
|
4857
4950
|
const targetDir = getTargetDir(projectRoot);
|
|
4858
|
-
if (!
|
|
4951
|
+
if (!existsSync19(targetDir)) {
|
|
4859
4952
|
fail(`\u6784\u5EFA\u4EA7\u7269\u76EE\u5F55\u4E0D\u5B58\u5728: ${targetDir}`);
|
|
4860
4953
|
}
|
|
4861
4954
|
const libDir = path7.join(targetDir, "lib");
|
|
4862
|
-
if (!
|
|
4955
|
+
if (!existsSync19(libDir) || !statSync8(libDir).isDirectory()) {
|
|
4863
4956
|
fail(`lib \u76EE\u5F55\u4E0D\u5B58\u5728: ${libDir}`);
|
|
4864
4957
|
}
|
|
4865
4958
|
const libJars = readdirSync6(libDir).filter((name) => name.endsWith(".jar"));
|
|
@@ -4871,7 +4964,7 @@ function locateLibDir(projectRoot) {
|
|
|
4871
4964
|
}
|
|
4872
4965
|
function locateMainJar(projectRoot) {
|
|
4873
4966
|
const targetDir = getTargetDir(projectRoot);
|
|
4874
|
-
if (!
|
|
4967
|
+
if (!existsSync19(targetDir)) {
|
|
4875
4968
|
fail(`\u6784\u5EFA\u4EA7\u7269\u76EE\u5F55\u4E0D\u5B58\u5728: ${targetDir}`);
|
|
4876
4969
|
}
|
|
4877
4970
|
const jarFiles = readdirSync6(targetDir).filter((name) => name.endsWith(".jar") && !name.endsWith(".jar.original")).map((name) => path7.join(targetDir, name)).sort((a, b) => statSync8(b).mtimeMs - statSync8(a).mtimeMs);
|
|
@@ -5209,6 +5302,12 @@ async function restartRemoteService(client, config) {
|
|
|
5209
5302
|
}
|
|
5210
5303
|
|
|
5211
5304
|
// src/commands/deploy/internal/wisdom-backend/index.ts
|
|
5305
|
+
function asFullBackendDeployConfig(config) {
|
|
5306
|
+
if (!("host" in config)) {
|
|
5307
|
+
fail("\u5B8C\u6574\u90E8\u7F72\u7F3A\u5C11 wisdomDeploy \u8FDC\u7A0B\u8FDE\u63A5\u914D\u7F6E");
|
|
5308
|
+
}
|
|
5309
|
+
return config;
|
|
5310
|
+
}
|
|
5212
5311
|
async function runWisdomBackendDeploy(options) {
|
|
5213
5312
|
const projectRoot = path9.resolve(options.projectRoot ?? process.cwd());
|
|
5214
5313
|
const config = options.config;
|
|
@@ -5260,11 +5359,12 @@ async function runWisdomBackendDeploy(options) {
|
|
|
5260
5359
|
log("\u4EC5\u6253\u5305\u5B8C\u6210\uFF08\u672A\u4E0A\u4F20\u8FDC\u7A0B\u670D\u52A1\u5668\uFF09");
|
|
5261
5360
|
return;
|
|
5262
5361
|
}
|
|
5263
|
-
const
|
|
5362
|
+
const deployConfig = asFullBackendDeployConfig(config);
|
|
5363
|
+
const conn = await connectSsh(deployConfig);
|
|
5264
5364
|
try {
|
|
5265
5365
|
if (config.mode === "full") {
|
|
5266
5366
|
const mainJar = locateMainJar(projectRoot);
|
|
5267
|
-
await uploadFullJar(conn.sftp, mainJar,
|
|
5367
|
+
await uploadFullJar(conn.sftp, mainJar, deployConfig);
|
|
5268
5368
|
const archiveZipPath = await createUpdatePackage(
|
|
5269
5369
|
[
|
|
5270
5370
|
{
|
|
@@ -5281,8 +5381,8 @@ async function runWisdomBackendDeploy(options) {
|
|
|
5281
5381
|
kind: "backend"
|
|
5282
5382
|
});
|
|
5283
5383
|
log("\u91CD\u542F\u670D\u52A1...");
|
|
5284
|
-
await restartRemoteService(conn.client,
|
|
5285
|
-
await healthCheckService(conn.client,
|
|
5384
|
+
await restartRemoteService(conn.client, deployConfig);
|
|
5385
|
+
await healthCheckService(conn.client, deployConfig);
|
|
5286
5386
|
log("\u90E8\u7F72\u5B8C\u6210");
|
|
5287
5387
|
return;
|
|
5288
5388
|
}
|
|
@@ -5290,7 +5390,7 @@ async function runWisdomBackendDeploy(options) {
|
|
|
5290
5390
|
let manifest = loadManifest3();
|
|
5291
5391
|
const remoteLibStats = await getRemoteFileStats(
|
|
5292
5392
|
conn.sftp,
|
|
5293
|
-
|
|
5393
|
+
deployConfig.remoteLibDir
|
|
5294
5394
|
);
|
|
5295
5395
|
log("\u6536\u96C6 JAR \u66F4\u65B0...");
|
|
5296
5396
|
const libUploadEntries = listLibFilesToUpload(
|
|
@@ -5308,7 +5408,7 @@ async function runWisdomBackendDeploy(options) {
|
|
|
5308
5408
|
const remoteZipPath = await uploadUpdatePackage(
|
|
5309
5409
|
conn.sftp,
|
|
5310
5410
|
zipPath,
|
|
5311
|
-
|
|
5411
|
+
deployConfig
|
|
5312
5412
|
);
|
|
5313
5413
|
await uploadDeployArtifactZip({
|
|
5314
5414
|
zipPath,
|
|
@@ -5318,13 +5418,13 @@ async function runWisdomBackendDeploy(options) {
|
|
|
5318
5418
|
log("\u8FDC\u7A0B\u89E3\u538B lib \u76EE\u5F55\uFF08\u4EC5\u8986\u76D6\u5DF2\u6709 JAR\uFF09...");
|
|
5319
5419
|
updated = await extractUpdatePackageOnRemote(
|
|
5320
5420
|
conn.client,
|
|
5321
|
-
|
|
5421
|
+
deployConfig,
|
|
5322
5422
|
remoteZipPath
|
|
5323
5423
|
);
|
|
5324
5424
|
} else {
|
|
5325
5425
|
log("\u65E0 JAR \u9700\u8981\u66F4\u65B0\uFF0C\u8DF3\u8FC7\u66F4\u65B0\u5305\u4E0A\u4F20");
|
|
5326
5426
|
}
|
|
5327
|
-
const runningJar = await getRunningJar(conn.client,
|
|
5427
|
+
const runningJar = await getRunningJar(conn.client, deployConfig);
|
|
5328
5428
|
let needRestart = updated > 0;
|
|
5329
5429
|
if (!needRestart && !runningJar) {
|
|
5330
5430
|
log("\u670D\u52A1\u672A\u8FD0\u884C\uFF0C\u9700\u8981\u542F\u52A8");
|
|
@@ -5334,9 +5434,9 @@ async function runWisdomBackendDeploy(options) {
|
|
|
5334
5434
|
}
|
|
5335
5435
|
if (needRestart) {
|
|
5336
5436
|
log("\u91CD\u542F\u670D\u52A1...");
|
|
5337
|
-
await restartRemoteService(conn.client,
|
|
5437
|
+
await restartRemoteService(conn.client, deployConfig);
|
|
5338
5438
|
}
|
|
5339
|
-
await healthCheckService(conn.client,
|
|
5439
|
+
await healthCheckService(conn.client, deployConfig);
|
|
5340
5440
|
if (libUploadEntries.length > 0) {
|
|
5341
5441
|
manifest = updateManifestEntries(manifest, libUploadEntries, projectRoot);
|
|
5342
5442
|
saveManifest3(manifest);
|
|
@@ -5353,11 +5453,11 @@ function isWisdomDeployConfigured(cfg) {
|
|
|
5353
5453
|
return Boolean(w?.host?.trim() && w?.remotePath?.trim());
|
|
5354
5454
|
}
|
|
5355
5455
|
function detectWisdomProjectType(cwd) {
|
|
5356
|
-
return
|
|
5456
|
+
return existsSync20(path10.join(cwd, "package.json")) ? "frontend" : "backend";
|
|
5357
5457
|
}
|
|
5358
5458
|
function readPackageScripts(cwd) {
|
|
5359
5459
|
const pkgPath = path10.join(cwd, "package.json");
|
|
5360
|
-
if (!
|
|
5460
|
+
if (!existsSync20(pkgPath)) {
|
|
5361
5461
|
return {};
|
|
5362
5462
|
}
|
|
5363
5463
|
try {
|
|
@@ -5372,10 +5472,10 @@ function resolveFrontendBuildCommand(env, cwd) {
|
|
|
5372
5472
|
const scripts = readPackageScripts(cwd);
|
|
5373
5473
|
const buildKey = `build:${env}`;
|
|
5374
5474
|
if (scripts[buildKey]?.trim()) {
|
|
5375
|
-
return `
|
|
5475
|
+
return formatNpmRunShellCommand(`build:${env}`);
|
|
5376
5476
|
}
|
|
5377
5477
|
if (isProductionDeployEnv(env) && scripts.build?.trim()) {
|
|
5378
|
-
return "
|
|
5478
|
+
return formatNpmRunShellCommand("build");
|
|
5379
5479
|
}
|
|
5380
5480
|
return null;
|
|
5381
5481
|
}
|
|
@@ -5384,7 +5484,7 @@ function resolveFrontendDistDir(cwd) {
|
|
|
5384
5484
|
for (const rel of candidates) {
|
|
5385
5485
|
const full = path10.join(cwd, rel);
|
|
5386
5486
|
try {
|
|
5387
|
-
if (
|
|
5487
|
+
if (existsSync20(full) && statSync9(full).isDirectory()) {
|
|
5388
5488
|
return full;
|
|
5389
5489
|
}
|
|
5390
5490
|
} catch {
|
|
@@ -5418,7 +5518,7 @@ async function executeWisdomFrontendDeploy(options) {
|
|
|
5418
5518
|
const projectName = resolveProjectNameForDeploy(cfg, cwd, {
|
|
5419
5519
|
requireName: packOnly || archiveDeployArtifact
|
|
5420
5520
|
});
|
|
5421
|
-
const settings = resolveWisdomDeployFromApmConfig(cfg);
|
|
5521
|
+
const settings = packOnly ? void 0 : resolveWisdomDeployFromApmConfig(cfg);
|
|
5422
5522
|
await runWisdomSftpDeploy({
|
|
5423
5523
|
localDir: distDir,
|
|
5424
5524
|
settings,
|
|
@@ -5430,7 +5530,7 @@ async function executeWisdomFrontendDeploy(options) {
|
|
|
5430
5530
|
}
|
|
5431
5531
|
async function executeWisdomBackendDeployFlow(options) {
|
|
5432
5532
|
const { cwd, cfg, packOnly } = options;
|
|
5433
|
-
const settings = resolveWisdomBackendDeployFromApmConfig(cfg);
|
|
5533
|
+
const settings = packOnly ? resolveWisdomBackendPackOnlyFromApmConfig(cfg) : resolveWisdomBackendDeployFromApmConfig(cfg);
|
|
5434
5534
|
if (packOnly) {
|
|
5435
5535
|
console.error(`[apm] Java\uFF1AMaven \u6784\u5EFA\uFF08\u4EC5\u6253\u5305\uFF0C\u5FFD\u7565\u73AF\u5883 ${options.env}\uFF09`);
|
|
5436
5536
|
} else {
|
|
@@ -5652,7 +5752,8 @@ async function executeDeploy(options) {
|
|
|
5652
5752
|
}
|
|
5653
5753
|
const preDeployLog = outputParts.join("\n");
|
|
5654
5754
|
const cfg = loadApmConfig({ configPath: apmConfigPath });
|
|
5655
|
-
|
|
5755
|
+
const packOnly = Boolean(options.packOnly);
|
|
5756
|
+
if (!packOnly && !isWisdomDeployConfigured(cfg)) {
|
|
5656
5757
|
const lines = formatMissingWisdomDeployLines();
|
|
5657
5758
|
throw new DeployExecutionError(lines.join("\n"), 1, lines.join("\n"));
|
|
5658
5759
|
}
|
|
@@ -5662,7 +5763,7 @@ async function executeDeploy(options) {
|
|
|
5662
5763
|
cwd,
|
|
5663
5764
|
configPath: apmConfigPath,
|
|
5664
5765
|
captureOutput,
|
|
5665
|
-
packOnly
|
|
5766
|
+
packOnly,
|
|
5666
5767
|
archiveDeployArtifact: options.archiveDeployArtifact
|
|
5667
5768
|
});
|
|
5668
5769
|
return preDeployLog;
|
|
@@ -5945,6 +6046,58 @@ async function handleInboundDeploy(cfg, msg, signal) {
|
|
|
5945
6046
|
}
|
|
5946
6047
|
}
|
|
5947
6048
|
|
|
6049
|
+
// src/commands/clean-session-cache.ts
|
|
6050
|
+
import { existsSync as existsSync21, rmSync as rmSync4 } from "node:fs";
|
|
6051
|
+
|
|
6052
|
+
// src/commands/connect/pre-step-cache.ts
|
|
6053
|
+
var PULL_TTL_MS = 3e4;
|
|
6054
|
+
function sessionWorkdirKey(sessionId, workdir) {
|
|
6055
|
+
return `${sessionId}\0${workdir}`;
|
|
6056
|
+
}
|
|
6057
|
+
var lastBranchKey = null;
|
|
6058
|
+
var lastPullAtByKey = /* @__PURE__ */ new Map();
|
|
6059
|
+
function shouldRunBranch(sessionId, workdir) {
|
|
6060
|
+
return lastBranchKey !== sessionWorkdirKey(sessionId, workdir);
|
|
6061
|
+
}
|
|
6062
|
+
function markBranchDone(sessionId, workdir) {
|
|
6063
|
+
lastBranchKey = sessionWorkdirKey(sessionId, workdir);
|
|
6064
|
+
}
|
|
6065
|
+
function shouldRunPull(sessionId, workdir) {
|
|
6066
|
+
const key = sessionWorkdirKey(sessionId, workdir);
|
|
6067
|
+
const last = lastPullAtByKey.get(key);
|
|
6068
|
+
if (last == null) {
|
|
6069
|
+
return true;
|
|
6070
|
+
}
|
|
6071
|
+
return Date.now() - last >= PULL_TTL_MS;
|
|
6072
|
+
}
|
|
6073
|
+
function markPullDone(sessionId, workdir) {
|
|
6074
|
+
lastPullAtByKey.set(sessionWorkdirKey(sessionId, workdir), Date.now());
|
|
6075
|
+
}
|
|
6076
|
+
function clearPreStepCacheForSession(sessionId, workdir) {
|
|
6077
|
+
const key = sessionWorkdirKey(sessionId, workdir);
|
|
6078
|
+
lastPullAtByKey.delete(key);
|
|
6079
|
+
if (lastBranchKey === key) {
|
|
6080
|
+
lastBranchKey = null;
|
|
6081
|
+
}
|
|
6082
|
+
}
|
|
6083
|
+
|
|
6084
|
+
// src/commands/clean-session-cache.ts
|
|
6085
|
+
function cleanSessionWorkspaceCache(sessionId, workdir) {
|
|
6086
|
+
const trimmedSessionId = sessionId.trim();
|
|
6087
|
+
const trimmedWorkdir = workdir.trim();
|
|
6088
|
+
if (!trimmedSessionId || !trimmedWorkdir) {
|
|
6089
|
+
return;
|
|
6090
|
+
}
|
|
6091
|
+
const dir = sessionDir(trimmedSessionId, workspaceApmDir(trimmedWorkdir));
|
|
6092
|
+
if (existsSync21(dir)) {
|
|
6093
|
+
rmSync4(dir, { recursive: true, force: true });
|
|
6094
|
+
console.log(`[apm] \u5DF2\u6E05\u7406\u4F1A\u8BDD\u7F13\u5B58 ${dir}`);
|
|
6095
|
+
} else {
|
|
6096
|
+
console.log(`[apm] \u4F1A\u8BDD\u7F13\u5B58\u4E0D\u5B58\u5728\uFF0C\u8DF3\u8FC7 ${dir}`);
|
|
6097
|
+
}
|
|
6098
|
+
clearPreStepCacheForSession(trimmedSessionId, trimmedWorkdir);
|
|
6099
|
+
}
|
|
6100
|
+
|
|
5948
6101
|
// src/commands/connect/abort-signal-debug.ts
|
|
5949
6102
|
import {
|
|
5950
6103
|
getEventListeners,
|
|
@@ -6212,13 +6365,13 @@ ${JSON.stringify(event, null, 2)}
|
|
|
6212
6365
|
}
|
|
6213
6366
|
|
|
6214
6367
|
// src/commands/connect/agent-session-registry.ts
|
|
6215
|
-
import { existsSync as
|
|
6368
|
+
import { existsSync as existsSync22, mkdirSync as mkdirSync9, readFileSync as readFileSync16, writeFileSync as writeFileSync14 } from "node:fs";
|
|
6216
6369
|
import { dirname as dirname6, resolve as resolve5 } from "node:path";
|
|
6217
6370
|
function registryPath(workdir, sessionId) {
|
|
6218
6371
|
return resolve5(workdir, ".apm", "sessions", sessionId, "cursor-agents.json");
|
|
6219
6372
|
}
|
|
6220
6373
|
function readRegistry(path19) {
|
|
6221
|
-
if (!
|
|
6374
|
+
if (!existsSync22(path19)) {
|
|
6222
6375
|
return {};
|
|
6223
6376
|
}
|
|
6224
6377
|
try {
|
|
@@ -6690,15 +6843,15 @@ async function ensureMessageHasReply(cfg, sessionId, messageId, fallback) {
|
|
|
6690
6843
|
}
|
|
6691
6844
|
|
|
6692
6845
|
// src/commands/connect/cli-version-sync.ts
|
|
6693
|
-
import { existsSync as
|
|
6694
|
-
import { join as
|
|
6846
|
+
import { existsSync as existsSync23, readFileSync as readFileSync17, writeFileSync as writeFileSync15 } from "fs";
|
|
6847
|
+
import { join as join18 } from "path";
|
|
6695
6848
|
var CLI_VERSION_FILE = ".cli-version.json";
|
|
6696
6849
|
function manifestPath(apmDir) {
|
|
6697
|
-
return
|
|
6850
|
+
return join18(apmDir, CLI_VERSION_FILE);
|
|
6698
6851
|
}
|
|
6699
6852
|
function loadManifest4(apmDir) {
|
|
6700
6853
|
const path19 = toFsPath(manifestPath(apmDir));
|
|
6701
|
-
if (!
|
|
6854
|
+
if (!existsSync23(path19)) {
|
|
6702
6855
|
return null;
|
|
6703
6856
|
}
|
|
6704
6857
|
try {
|
|
@@ -6739,31 +6892,6 @@ function markSkillsSyncedForCliVersion(workdir, cliVersion) {
|
|
|
6739
6892
|
syncedInSession.set(workdir, cliVersion);
|
|
6740
6893
|
}
|
|
6741
6894
|
|
|
6742
|
-
// src/commands/connect/pre-step-cache.ts
|
|
6743
|
-
var PULL_TTL_MS = 3e4;
|
|
6744
|
-
function sessionWorkdirKey(sessionId, workdir) {
|
|
6745
|
-
return `${sessionId}\0${workdir}`;
|
|
6746
|
-
}
|
|
6747
|
-
var lastBranchKey = null;
|
|
6748
|
-
var lastPullAtByKey = /* @__PURE__ */ new Map();
|
|
6749
|
-
function shouldRunBranch(sessionId, workdir) {
|
|
6750
|
-
return lastBranchKey !== sessionWorkdirKey(sessionId, workdir);
|
|
6751
|
-
}
|
|
6752
|
-
function markBranchDone(sessionId, workdir) {
|
|
6753
|
-
lastBranchKey = sessionWorkdirKey(sessionId, workdir);
|
|
6754
|
-
}
|
|
6755
|
-
function shouldRunPull(sessionId, workdir) {
|
|
6756
|
-
const key = sessionWorkdirKey(sessionId, workdir);
|
|
6757
|
-
const last = lastPullAtByKey.get(key);
|
|
6758
|
-
if (last == null) {
|
|
6759
|
-
return true;
|
|
6760
|
-
}
|
|
6761
|
-
return Date.now() - last >= PULL_TTL_MS;
|
|
6762
|
-
}
|
|
6763
|
-
function markPullDone(sessionId, workdir) {
|
|
6764
|
-
lastPullAtByKey.set(sessionWorkdirKey(sessionId, workdir), Date.now());
|
|
6765
|
-
}
|
|
6766
|
-
|
|
6767
6895
|
// src/commands/connect/run-slot-pool.ts
|
|
6768
6896
|
var DEFAULT_MAX_CONCURRENT = 5;
|
|
6769
6897
|
function createRunSlotPool(maxConcurrent = DEFAULT_MAX_CONCURRENT, options = {}) {
|
|
@@ -7063,6 +7191,18 @@ function attachWsHandlers(ws, ctx, onOpen) {
|
|
|
7063
7191
|
});
|
|
7064
7192
|
return;
|
|
7065
7193
|
}
|
|
7194
|
+
if (validated.data.type === "session-cache-cleanup") {
|
|
7195
|
+
const msg2 = validated.data;
|
|
7196
|
+
const task2 = (async () => {
|
|
7197
|
+
const workdir = requireRemoteWorkdir(msg2.workdir);
|
|
7198
|
+
cleanSessionWorkspaceCache(msg2.sessionId, workdir);
|
|
7199
|
+
})();
|
|
7200
|
+
activeTasks.add(task2);
|
|
7201
|
+
void task2.finally(() => {
|
|
7202
|
+
activeTasks.delete(task2);
|
|
7203
|
+
});
|
|
7204
|
+
return;
|
|
7205
|
+
}
|
|
7066
7206
|
if (validated.data.type !== "message") {
|
|
7067
7207
|
return;
|
|
7068
7208
|
}
|
|
@@ -7503,7 +7643,7 @@ function registerDeployMainCommand(program) {
|
|
|
7503
7643
|
"\u6C9F\u901A\u7FA4 ID\uFF1B\u4F20\u5165\u65F6\u5728\u5E73\u53F0\u521B\u5EFA\u90E8\u7F72\u8BB0\u5F55\u5E76\u540C\u6B65\u65E5\u5FD7"
|
|
7504
7644
|
).option(
|
|
7505
7645
|
"--pack-only",
|
|
7506
|
-
"\u4EC5\u6784\u5EFA/\u6253\u5305\uFF0C\u4E0D\u4E0A\u4F20\u8FDC\u7A0B SFTP/SSH\
|
|
7646
|
+
"\u4EC5\u6784\u5EFA/\u6253\u5305\u5E76\u4E0A\u4F20 MinIO \u5F52\u6863\uFF0C\u4E0D\u4E0A\u4F20\u8FDC\u7A0B SFTP/SSH\uFF08\u65E0\u9700 wisdomDeploy\uFF09"
|
|
7507
7647
|
).action(
|
|
7508
7648
|
async (env, opts) => {
|
|
7509
7649
|
const cwd = process.cwd();
|
|
@@ -7549,7 +7689,7 @@ import path15 from "node:path";
|
|
|
7549
7689
|
import Docker from "dockerode";
|
|
7550
7690
|
|
|
7551
7691
|
// src/commands/deploy/internal/backend-deploy/dockerode-client/connection-options.ts
|
|
7552
|
-
import { existsSync as
|
|
7692
|
+
import { existsSync as existsSync24, readFileSync as readFileSync18 } from "node:fs";
|
|
7553
7693
|
import path12 from "node:path";
|
|
7554
7694
|
function asOptionalTlsBuffer(value) {
|
|
7555
7695
|
if (typeof value !== "string") {
|
|
@@ -7561,7 +7701,7 @@ function asOptionalTlsBuffer(value) {
|
|
|
7561
7701
|
if (normalized === "") {
|
|
7562
7702
|
return void 0;
|
|
7563
7703
|
}
|
|
7564
|
-
if (
|
|
7704
|
+
if (existsSync24(normalized)) {
|
|
7565
7705
|
return readFileSync18(normalized);
|
|
7566
7706
|
}
|
|
7567
7707
|
const looksLikePath = /[\\/]/.test(normalized) || normalized.endsWith(".pem");
|
|
@@ -7772,7 +7912,7 @@ var DockerodeClient = class {
|
|
|
7772
7912
|
var createDockerodeClient = (config) => new DockerodeClient(config);
|
|
7773
7913
|
|
|
7774
7914
|
// src/commands/deploy/internal/backend-deploy/dockerode-client/env.ts
|
|
7775
|
-
import { existsSync as
|
|
7915
|
+
import { existsSync as existsSync25, readFileSync as readFileSync19, statSync as statSync10 } from "node:fs";
|
|
7776
7916
|
import path13 from "node:path";
|
|
7777
7917
|
function stripSurroundingQuotes(value) {
|
|
7778
7918
|
const t = value.trim();
|
|
@@ -7789,7 +7929,7 @@ function loadEnvFromFile(envFilePath) {
|
|
|
7789
7929
|
return {};
|
|
7790
7930
|
}
|
|
7791
7931
|
const targetPath = path13.resolve(envFilePath);
|
|
7792
|
-
if (!
|
|
7932
|
+
if (!existsSync25(targetPath) || !statSync10(targetPath).isFile()) {
|
|
7793
7933
|
return {};
|
|
7794
7934
|
}
|
|
7795
7935
|
const raw = readFileSync19(targetPath, "utf-8");
|
|
@@ -7963,12 +8103,12 @@ function dockerPushImage(params, cwd) {
|
|
|
7963
8103
|
}
|
|
7964
8104
|
|
|
7965
8105
|
// src/commands/deploy/internal/backend-deploy/resolve-dockerfile.ts
|
|
7966
|
-
import { existsSync as
|
|
8106
|
+
import { existsSync as existsSync26 } from "node:fs";
|
|
7967
8107
|
import path14 from "node:path";
|
|
7968
8108
|
function resolveDockerBuildPaths(cwd) {
|
|
7969
8109
|
const dockerfilePath = path14.join(cwd, "Dockerfile");
|
|
7970
8110
|
Logger.info(`\u67E5\u627EDockerfile\u6587\u4EF6\uFF0C\u8DEF\u5F84: ${dockerfilePath}`);
|
|
7971
|
-
if (!
|
|
8111
|
+
if (!existsSync26(dockerfilePath)) {
|
|
7972
8112
|
throw new Error(`Dockerfile \u4E0D\u5B58\u5728\uFF1A${dockerfilePath}`);
|
|
7973
8113
|
}
|
|
7974
8114
|
Logger.info("\u2713 Dockerfile \u5B58\u5728");
|
|
@@ -8289,7 +8429,6 @@ function registerDeploySftpCommands(program) {
|
|
|
8289
8429
|
async (opts) => {
|
|
8290
8430
|
try {
|
|
8291
8431
|
const cfg = loadApmConfig({ configPath: opts.config });
|
|
8292
|
-
const settings = resolveWisdomDeployFromApmConfig(cfg);
|
|
8293
8432
|
const projectName = resolveProjectNameForDeploy(cfg, process.cwd(), {
|
|
8294
8433
|
requireName: true
|
|
8295
8434
|
});
|
|
@@ -8304,6 +8443,7 @@ function registerDeploySftpCommands(program) {
|
|
|
8304
8443
|
1
|
|
8305
8444
|
);
|
|
8306
8445
|
}
|
|
8446
|
+
const settings = packOnly ? void 0 : resolveWisdomDeployFromApmConfig(cfg);
|
|
8307
8447
|
const result = await runWisdomSftpDeploy({
|
|
8308
8448
|
localDir: root,
|
|
8309
8449
|
settings,
|