ai-project-manage-cli 6.0.69 → 6.0.71
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 +135 -30
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2227,7 +2227,7 @@ function validateAgentWsMessage(value, kind) {
|
|
|
2227
2227
|
// src/commands/connect/deploy-run.ts
|
|
2228
2228
|
import { spawn } from "node:child_process";
|
|
2229
2229
|
import { existsSync as existsSync14, readFileSync as readFileSync12 } from "node:fs";
|
|
2230
|
-
import { join as
|
|
2230
|
+
import { join as join14 } from "node:path";
|
|
2231
2231
|
|
|
2232
2232
|
// src/commands/deploy/internal/wisdom-auto-deploy.ts
|
|
2233
2233
|
import { existsSync as existsSync13, readFileSync as readFileSync11 } from "node:fs";
|
|
@@ -2236,7 +2236,8 @@ import { spawnSync as spawnSync3 } from "node:child_process";
|
|
|
2236
2236
|
|
|
2237
2237
|
// src/commands/deploy/internal/apm-config.ts
|
|
2238
2238
|
import { existsSync as existsSync11, readFileSync as readFileSync9 } from "node:fs";
|
|
2239
|
-
import {
|
|
2239
|
+
import { homedir as homedir2 } from "node:os";
|
|
2240
|
+
import { join as join13, resolve as resolve3 } from "node:path";
|
|
2240
2241
|
function loadApmConfig(options) {
|
|
2241
2242
|
const p = resolve3(
|
|
2242
2243
|
process.cwd(),
|
|
@@ -2375,6 +2376,103 @@ function reqWb(v, field) {
|
|
|
2375
2376
|
}
|
|
2376
2377
|
return v;
|
|
2377
2378
|
}
|
|
2379
|
+
function readEnvVar(env, name) {
|
|
2380
|
+
if (env[name] !== void 0) {
|
|
2381
|
+
return env[name];
|
|
2382
|
+
}
|
|
2383
|
+
if (process.platform === "win32") {
|
|
2384
|
+
const target = name.toUpperCase();
|
|
2385
|
+
for (const [key, value] of Object.entries(env)) {
|
|
2386
|
+
if (key.toUpperCase() === target) {
|
|
2387
|
+
return value;
|
|
2388
|
+
}
|
|
2389
|
+
}
|
|
2390
|
+
}
|
|
2391
|
+
return void 0;
|
|
2392
|
+
}
|
|
2393
|
+
function expandWindowsEnvVars(pathStr, env = process.env) {
|
|
2394
|
+
return pathStr.replace(/%([^%]+)%/g, (_, name) => {
|
|
2395
|
+
const value = readEnvVar(env, name);
|
|
2396
|
+
return value ?? `%${name}%`;
|
|
2397
|
+
});
|
|
2398
|
+
}
|
|
2399
|
+
function expandUserPath(pathStr, env = process.env) {
|
|
2400
|
+
const home = env.HOME ?? env.USERPROFILE ?? homedir2();
|
|
2401
|
+
const withEnv = expandWindowsEnvVars(pathStr, env);
|
|
2402
|
+
const expanded = withEnv.replace(/^~(?=\/|\\|$)/, home);
|
|
2403
|
+
if (/^[a-zA-Z]:[/\\]/.test(expanded)) {
|
|
2404
|
+
return expanded;
|
|
2405
|
+
}
|
|
2406
|
+
return resolve3(expanded);
|
|
2407
|
+
}
|
|
2408
|
+
var MAVEN_REPO_ENV_KEYS = [
|
|
2409
|
+
"MAVEN_LOCAL_REPO",
|
|
2410
|
+
"M2_REPO",
|
|
2411
|
+
"MAVEN_REPOSITORY"
|
|
2412
|
+
];
|
|
2413
|
+
function readMavenLocalRepoFromMavenOpts(mavenOpts, env = process.env) {
|
|
2414
|
+
const match = mavenOpts.match(/-Dmaven\.repo\.local=(?:"([^"]+)"|(\S+))/);
|
|
2415
|
+
const raw = match?.[1]?.trim() || match?.[2]?.trim();
|
|
2416
|
+
return raw ? expandUserPath(raw, env) : null;
|
|
2417
|
+
}
|
|
2418
|
+
function readMavenLocalRepoFromEnv(env = process.env) {
|
|
2419
|
+
for (const key of MAVEN_REPO_ENV_KEYS) {
|
|
2420
|
+
const raw = readEnvVar(env, key)?.trim();
|
|
2421
|
+
if (raw) {
|
|
2422
|
+
return { path: expandUserPath(raw, env), key };
|
|
2423
|
+
}
|
|
2424
|
+
}
|
|
2425
|
+
const mavenOpts = readEnvVar(env, "MAVEN_OPTS")?.trim();
|
|
2426
|
+
if (mavenOpts) {
|
|
2427
|
+
const path12 = readMavenLocalRepoFromMavenOpts(mavenOpts, env);
|
|
2428
|
+
if (path12) {
|
|
2429
|
+
return { path: path12, key: "MAVEN_OPTS" };
|
|
2430
|
+
}
|
|
2431
|
+
}
|
|
2432
|
+
return null;
|
|
2433
|
+
}
|
|
2434
|
+
function readMavenLocalRepoFromSettings() {
|
|
2435
|
+
const settingsPath = join13(homedir2(), ".m2", "settings.xml");
|
|
2436
|
+
if (!existsSync11(settingsPath)) {
|
|
2437
|
+
return null;
|
|
2438
|
+
}
|
|
2439
|
+
try {
|
|
2440
|
+
const xml = readFileSync9(settingsPath, "utf8");
|
|
2441
|
+
const match = xml.match(
|
|
2442
|
+
/<localRepository>\s*([^<]+?)\s*<\/localRepository>/
|
|
2443
|
+
);
|
|
2444
|
+
const raw = match?.[1]?.trim();
|
|
2445
|
+
if (!raw) {
|
|
2446
|
+
return null;
|
|
2447
|
+
}
|
|
2448
|
+
return expandUserPath(raw);
|
|
2449
|
+
} catch {
|
|
2450
|
+
return null;
|
|
2451
|
+
}
|
|
2452
|
+
}
|
|
2453
|
+
function resolveMavenLocalRepoWithSource() {
|
|
2454
|
+
const fromEnv = readMavenLocalRepoFromEnv();
|
|
2455
|
+
if (fromEnv) {
|
|
2456
|
+
return {
|
|
2457
|
+
path: fromEnv.path,
|
|
2458
|
+
source: "env",
|
|
2459
|
+
sourceDetail: fromEnv.key
|
|
2460
|
+
};
|
|
2461
|
+
}
|
|
2462
|
+
const fromSettings = readMavenLocalRepoFromSettings();
|
|
2463
|
+
if (fromSettings) {
|
|
2464
|
+
return {
|
|
2465
|
+
path: fromSettings,
|
|
2466
|
+
source: "settings",
|
|
2467
|
+
sourceDetail: "~/.m2/settings.xml"
|
|
2468
|
+
};
|
|
2469
|
+
}
|
|
2470
|
+
return {
|
|
2471
|
+
path: join13(homedir2(), ".m2", "repository"),
|
|
2472
|
+
source: "default",
|
|
2473
|
+
sourceDetail: "~/.m2/repository"
|
|
2474
|
+
};
|
|
2475
|
+
}
|
|
2378
2476
|
function resolveWisdomBackendDeployFromApmConfig(cfg) {
|
|
2379
2477
|
const projectName = reqTopLevelName(cfg);
|
|
2380
2478
|
const w = cfg.wisdomDeploy ?? {};
|
|
@@ -2391,6 +2489,7 @@ function resolveWisdomBackendDeployFromApmConfig(cfg) {
|
|
|
2391
2489
|
console.error("apm.config.json \u4E2D healthCheck.timeout \u987B\u4E3A\u6B63\u6574\u6570");
|
|
2392
2490
|
process.exit(1);
|
|
2393
2491
|
}
|
|
2492
|
+
const mavenLocalRepo = resolveMavenLocalRepoWithSource();
|
|
2394
2493
|
return {
|
|
2395
2494
|
projectName,
|
|
2396
2495
|
host: reqWd(w.host, "host").trim(),
|
|
@@ -2402,7 +2501,9 @@ function resolveWisdomBackendDeployFromApmConfig(cfg) {
|
|
|
2402
2501
|
remoteLibDir: `${remoteAppDir}/lib`,
|
|
2403
2502
|
startupJar: posixBasename(jarPath),
|
|
2404
2503
|
packageName: `${projectName}.jar.zip`,
|
|
2405
|
-
mavenLocalRepo:
|
|
2504
|
+
mavenLocalRepo: mavenLocalRepo.path,
|
|
2505
|
+
mavenLocalRepoSource: mavenLocalRepo.source,
|
|
2506
|
+
mavenLocalRepoSourceDetail: mavenLocalRepo.sourceDetail,
|
|
2406
2507
|
healthCheckPort: healthPort,
|
|
2407
2508
|
healthCheckContext: reqHc(h.context, "context").trim(),
|
|
2408
2509
|
healthCheckTimeout: healthTimeout
|
|
@@ -2731,7 +2832,7 @@ function getMvnExecutable() {
|
|
|
2731
2832
|
}
|
|
2732
2833
|
fail("\u672A\u627E\u5230 mvn \u547D\u4EE4\uFF0C\u8BF7\u786E\u8BA4 Maven \u5DF2\u5B89\u88C5\u5E76\u52A0\u5165 PATH");
|
|
2733
2834
|
}
|
|
2734
|
-
function runMavenBuild(projectRoot, mavenLocalRepo) {
|
|
2835
|
+
function runMavenBuild(projectRoot, mavenLocalRepo, repoSource) {
|
|
2735
2836
|
const mavenRepo = expandPath(mavenLocalRepo);
|
|
2736
2837
|
const mvn = getMvnExecutable();
|
|
2737
2838
|
const command = [
|
|
@@ -2742,8 +2843,14 @@ function runMavenBuild(projectRoot, mavenLocalRepo) {
|
|
|
2742
2843
|
formatMavenLocalRepoArg(mavenRepo),
|
|
2743
2844
|
"-DskipTests"
|
|
2744
2845
|
].join(" ");
|
|
2745
|
-
log(
|
|
2746
|
-
|
|
2846
|
+
log("\u5F00\u59CB Maven \u6784\u5EFA...");
|
|
2847
|
+
if (repoSource) {
|
|
2848
|
+
log(
|
|
2849
|
+
`Maven \u672C\u5730\u4ED3\u5E93: ${mavenRepo} (\u6765\u6E90: ${repoSource.source}/${repoSource.sourceDetail})`
|
|
2850
|
+
);
|
|
2851
|
+
} else {
|
|
2852
|
+
log(`Maven \u672C\u5730\u4ED3\u5E93: ${mavenRepo}`);
|
|
2853
|
+
}
|
|
2747
2854
|
log(`\u6784\u5EFA\u76EE\u5F55: ${projectRoot}`);
|
|
2748
2855
|
const result = spawnSync2(command, {
|
|
2749
2856
|
cwd: projectRoot,
|
|
@@ -2752,9 +2859,7 @@ function runMavenBuild(projectRoot, mavenLocalRepo) {
|
|
|
2752
2859
|
env: process.env
|
|
2753
2860
|
});
|
|
2754
2861
|
if (result.status !== 0) {
|
|
2755
|
-
fail(
|
|
2756
|
-
`Maven \u6784\u5EFA\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${result.status ?? 1}\u3002\u8BF7\u5728\u9879\u76EE\u6839\u76EE\u5F55\u624B\u52A8\u6267\u884C\u4EE5\u67E5\u770B\u8BE6\u7EC6\u9519\u8BEF: ${command}`
|
|
2757
|
-
);
|
|
2862
|
+
fail(`Maven \u6784\u5EFA\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${result.status ?? 1}`);
|
|
2758
2863
|
}
|
|
2759
2864
|
}
|
|
2760
2865
|
function locateLibDir(projectRoot) {
|
|
@@ -2832,7 +2937,7 @@ async function uploadUpdatePackage(sftp, zipPath, config) {
|
|
|
2832
2937
|
async function runRemoteCommand(client, command, options) {
|
|
2833
2938
|
const check = options?.check ?? true;
|
|
2834
2939
|
const stream = options?.stream ?? false;
|
|
2835
|
-
|
|
2940
|
+
const label = options?.label ?? "\u8FDC\u7A0B\u547D\u4EE4";
|
|
2836
2941
|
return new Promise((resolve5, reject) => {
|
|
2837
2942
|
client.exec(command, (err, execStream) => {
|
|
2838
2943
|
if (err) {
|
|
@@ -2852,18 +2957,16 @@ async function runRemoteCommand(client, command, options) {
|
|
|
2852
2957
|
errText += data.toString();
|
|
2853
2958
|
});
|
|
2854
2959
|
execStream.on("close", (code) => {
|
|
2855
|
-
if (!
|
|
2856
|
-
if (out) {
|
|
2857
|
-
console.log(out.trimEnd());
|
|
2858
|
-
}
|
|
2859
|
-
if (errText) {
|
|
2860
|
-
console.error(errText.trimEnd());
|
|
2861
|
-
}
|
|
2862
|
-
} else if (out && !out.endsWith("\n")) {
|
|
2960
|
+
if (stream && out && !out.endsWith("\n")) {
|
|
2863
2961
|
process.stdout.write("\n");
|
|
2864
2962
|
}
|
|
2865
2963
|
if (check && code !== 0) {
|
|
2866
|
-
|
|
2964
|
+
const combined = `${out}
|
|
2965
|
+
${errText}`.trim();
|
|
2966
|
+
fail(
|
|
2967
|
+
`${label}\u5931\u8D25 (exit ${code})` + (combined ? `
|
|
2968
|
+
\u8F93\u51FA: ${combined}` : "")
|
|
2969
|
+
);
|
|
2867
2970
|
}
|
|
2868
2971
|
resolve5({ exitCode: code, out: out.trim(), err: errText.trim() });
|
|
2869
2972
|
});
|
|
@@ -2898,7 +3001,9 @@ async function extractUpdatePackageOnRemote(client, config, remoteZipPath) {
|
|
|
2898
3001
|
remoteZipPath,
|
|
2899
3002
|
config.remoteLibDir
|
|
2900
3003
|
);
|
|
2901
|
-
const { out } = await runRemoteCommand(client, script
|
|
3004
|
+
const { out } = await runRemoteCommand(client, script, {
|
|
3005
|
+
label: "\u8FDC\u7A0B\u89E3\u538B"
|
|
3006
|
+
});
|
|
2902
3007
|
const match = out.match(/UPDATED_COUNT=(\d+)/);
|
|
2903
3008
|
if (!match) {
|
|
2904
3009
|
fail(`\u8FDC\u7A0B\u89E3\u538B\u5931\u8D25\uFF0C\u672A\u83B7\u53D6\u66F4\u65B0\u6570\u91CF
|
|
@@ -3024,7 +3129,8 @@ exit 1
|
|
|
3024
3129
|
}
|
|
3025
3130
|
async function runRemoteServiceScript(client, script, action) {
|
|
3026
3131
|
const { exitCode, out, err } = await runRemoteCommand(client, script, {
|
|
3027
|
-
check: false
|
|
3132
|
+
check: false,
|
|
3133
|
+
label: action === "status" ? "\u8FDC\u7A0B status" : action === "restart" ? "\u8FDC\u7A0B restart" : "\u5065\u5EB7\u68C0\u67E5"
|
|
3028
3134
|
});
|
|
3029
3135
|
const combined = `${out}
|
|
3030
3136
|
${err}`.trim();
|
|
@@ -3065,9 +3171,7 @@ async function getRunningJar(client, config) {
|
|
|
3065
3171
|
return null;
|
|
3066
3172
|
}
|
|
3067
3173
|
async function healthCheckService(client, config) {
|
|
3068
|
-
log(
|
|
3069
|
-
`\u5065\u5EB7\u68C0\u67E5: http://127.0.0.1:${config.healthCheckPort}${normalizeHealthContext(config.healthCheckContext)} (\u8D85\u65F6 ${config.healthCheckTimeout}s)`
|
|
3070
|
-
);
|
|
3174
|
+
log("\u5065\u5EB7\u68C0\u67E5...");
|
|
3071
3175
|
const script = buildRemoteHealthScript(
|
|
3072
3176
|
config.healthCheckPort,
|
|
3073
3177
|
config.healthCheckContext,
|
|
@@ -3085,7 +3189,10 @@ async function runWisdomBackendDeploy(options) {
|
|
|
3085
3189
|
log(`=== \u81EA\u52A8\u90E8\u7F72: ${config.projectName} ===`);
|
|
3086
3190
|
log(`\u914D\u7F6E\u6587\u4EF6: ${path2.join(workspaceApmDir(), "apm.config.json")}`);
|
|
3087
3191
|
log(`\u9879\u76EE\u6839\u76EE\u5F55: ${projectRoot}`);
|
|
3088
|
-
runMavenBuild(projectRoot, config.mavenLocalRepo
|
|
3192
|
+
runMavenBuild(projectRoot, config.mavenLocalRepo, {
|
|
3193
|
+
source: config.mavenLocalRepoSource,
|
|
3194
|
+
sourceDetail: config.mavenLocalRepoSourceDetail
|
|
3195
|
+
});
|
|
3089
3196
|
const libDir = locateLibDir(projectRoot);
|
|
3090
3197
|
let manifest = loadManifest3();
|
|
3091
3198
|
const conn = await connectSsh(config);
|
|
@@ -3179,7 +3286,6 @@ function resolveFrontendDeployCommand(env, cwd) {
|
|
|
3179
3286
|
return null;
|
|
3180
3287
|
}
|
|
3181
3288
|
function runShellCommand(command, cwd) {
|
|
3182
|
-
console.error(`==> ${command}`);
|
|
3183
3289
|
const result = spawnSync3(command, {
|
|
3184
3290
|
cwd,
|
|
3185
3291
|
stdio: "inherit",
|
|
@@ -3223,7 +3329,7 @@ async function runWisdomAutoDeploy(options) {
|
|
|
3223
3329
|
// src/commands/connect/deploy-run.ts
|
|
3224
3330
|
var DEPLOY_LOG_SYNC_INTERVAL_MS = 3e4;
|
|
3225
3331
|
function readApmConfig(workdir) {
|
|
3226
|
-
const configPath =
|
|
3332
|
+
const configPath = join14(workspaceApmDir(workdir), "apm.config.json");
|
|
3227
3333
|
if (!existsSync14(configPath)) {
|
|
3228
3334
|
return void 0;
|
|
3229
3335
|
}
|
|
@@ -4133,10 +4239,10 @@ async function runCursorAgent(cfg, ctx, options) {
|
|
|
4133
4239
|
|
|
4134
4240
|
// src/commands/connect/cli-version-sync.ts
|
|
4135
4241
|
import { existsSync as existsSync16, readFileSync as readFileSync14, writeFileSync as writeFileSync12 } from "fs";
|
|
4136
|
-
import { join as
|
|
4242
|
+
import { join as join15 } from "path";
|
|
4137
4243
|
var CLI_VERSION_FILE = ".cli-version.json";
|
|
4138
4244
|
function manifestPath(apmDir) {
|
|
4139
|
-
return
|
|
4245
|
+
return join15(apmDir, CLI_VERSION_FILE);
|
|
4140
4246
|
}
|
|
4141
4247
|
function loadManifest4(apmDir) {
|
|
4142
4248
|
const path12 = toFsPath(manifestPath(apmDir));
|
|
@@ -4587,7 +4693,6 @@ async function runCreatePr(options) {
|
|
|
4587
4693
|
// src/commands/deploy/deploy.ts
|
|
4588
4694
|
import { spawnSync as spawnSync5 } from "node:child_process";
|
|
4589
4695
|
function runShellCommand3(command, cwd) {
|
|
4590
|
-
console.error(`==> ${command}`);
|
|
4591
4696
|
const result = spawnSync5(command, {
|
|
4592
4697
|
cwd,
|
|
4593
4698
|
stdio: "inherit",
|