ai-project-manage-cli 6.0.70 → 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.
Files changed (2) hide show
  1. package/dist/index.js +75 -35
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2376,9 +2376,23 @@ function reqWb(v, field) {
2376
2376
  }
2377
2377
  return v;
2378
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
+ }
2379
2393
  function expandWindowsEnvVars(pathStr, env = process.env) {
2380
2394
  return pathStr.replace(/%([^%]+)%/g, (_, name) => {
2381
- const value = env[name];
2395
+ const value = readEnvVar(env, name);
2382
2396
  return value ?? `%${name}%`;
2383
2397
  });
2384
2398
  }
@@ -2403,14 +2417,17 @@ function readMavenLocalRepoFromMavenOpts(mavenOpts, env = process.env) {
2403
2417
  }
2404
2418
  function readMavenLocalRepoFromEnv(env = process.env) {
2405
2419
  for (const key of MAVEN_REPO_ENV_KEYS) {
2406
- const raw = env[key]?.trim();
2420
+ const raw = readEnvVar(env, key)?.trim();
2407
2421
  if (raw) {
2408
- return expandUserPath(raw, env);
2422
+ return { path: expandUserPath(raw, env), key };
2409
2423
  }
2410
2424
  }
2411
- const mavenOpts = env.MAVEN_OPTS?.trim();
2425
+ const mavenOpts = readEnvVar(env, "MAVEN_OPTS")?.trim();
2412
2426
  if (mavenOpts) {
2413
- return readMavenLocalRepoFromMavenOpts(mavenOpts, env);
2427
+ const path12 = readMavenLocalRepoFromMavenOpts(mavenOpts, env);
2428
+ if (path12) {
2429
+ return { path: path12, key: "MAVEN_OPTS" };
2430
+ }
2414
2431
  }
2415
2432
  return null;
2416
2433
  }
@@ -2433,12 +2450,28 @@ function readMavenLocalRepoFromSettings() {
2433
2450
  return null;
2434
2451
  }
2435
2452
  }
2436
- function resolveMavenLocalRepo(configured) {
2437
- const trimmed = configured?.trim();
2438
- if (trimmed) {
2439
- return expandUserPath(trimmed);
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
+ };
2440
2469
  }
2441
- return readMavenLocalRepoFromEnv() ?? readMavenLocalRepoFromSettings() ?? join13(homedir2(), ".m2", "repository");
2470
+ return {
2471
+ path: join13(homedir2(), ".m2", "repository"),
2472
+ source: "default",
2473
+ sourceDetail: "~/.m2/repository"
2474
+ };
2442
2475
  }
2443
2476
  function resolveWisdomBackendDeployFromApmConfig(cfg) {
2444
2477
  const projectName = reqTopLevelName(cfg);
@@ -2456,6 +2489,7 @@ function resolveWisdomBackendDeployFromApmConfig(cfg) {
2456
2489
  console.error("apm.config.json \u4E2D healthCheck.timeout \u987B\u4E3A\u6B63\u6574\u6570");
2457
2490
  process.exit(1);
2458
2491
  }
2492
+ const mavenLocalRepo = resolveMavenLocalRepoWithSource();
2459
2493
  return {
2460
2494
  projectName,
2461
2495
  host: reqWd(w.host, "host").trim(),
@@ -2467,7 +2501,9 @@ function resolveWisdomBackendDeployFromApmConfig(cfg) {
2467
2501
  remoteLibDir: `${remoteAppDir}/lib`,
2468
2502
  startupJar: posixBasename(jarPath),
2469
2503
  packageName: `${projectName}.jar.zip`,
2470
- mavenLocalRepo: resolveMavenLocalRepo(w.mavenLocalRepo),
2504
+ mavenLocalRepo: mavenLocalRepo.path,
2505
+ mavenLocalRepoSource: mavenLocalRepo.source,
2506
+ mavenLocalRepoSourceDetail: mavenLocalRepo.sourceDetail,
2471
2507
  healthCheckPort: healthPort,
2472
2508
  healthCheckContext: reqHc(h.context, "context").trim(),
2473
2509
  healthCheckTimeout: healthTimeout
@@ -2796,7 +2832,7 @@ function getMvnExecutable() {
2796
2832
  }
2797
2833
  fail("\u672A\u627E\u5230 mvn \u547D\u4EE4\uFF0C\u8BF7\u786E\u8BA4 Maven \u5DF2\u5B89\u88C5\u5E76\u52A0\u5165 PATH");
2798
2834
  }
2799
- function runMavenBuild(projectRoot, mavenLocalRepo) {
2835
+ function runMavenBuild(projectRoot, mavenLocalRepo, repoSource) {
2800
2836
  const mavenRepo = expandPath(mavenLocalRepo);
2801
2837
  const mvn = getMvnExecutable();
2802
2838
  const command = [
@@ -2807,8 +2843,14 @@ function runMavenBuild(projectRoot, mavenLocalRepo) {
2807
2843
  formatMavenLocalRepoArg(mavenRepo),
2808
2844
  "-DskipTests"
2809
2845
  ].join(" ");
2810
- log(`\u5F00\u59CB Maven \u6784\u5EFA: ${command}`);
2811
- log(`Maven \u672C\u5730\u4ED3\u5E93: ${mavenRepo}`);
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
+ }
2812
2854
  log(`\u6784\u5EFA\u76EE\u5F55: ${projectRoot}`);
2813
2855
  const result = spawnSync2(command, {
2814
2856
  cwd: projectRoot,
@@ -2817,9 +2859,7 @@ function runMavenBuild(projectRoot, mavenLocalRepo) {
2817
2859
  env: process.env
2818
2860
  });
2819
2861
  if (result.status !== 0) {
2820
- fail(
2821
- `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}`
2822
- );
2862
+ fail(`Maven \u6784\u5EFA\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${result.status ?? 1}`);
2823
2863
  }
2824
2864
  }
2825
2865
  function locateLibDir(projectRoot) {
@@ -2897,7 +2937,7 @@ async function uploadUpdatePackage(sftp, zipPath, config) {
2897
2937
  async function runRemoteCommand(client, command, options) {
2898
2938
  const check = options?.check ?? true;
2899
2939
  const stream = options?.stream ?? false;
2900
- log(`\u8FDC\u7A0B\u6267\u884C: ${command}`);
2940
+ const label = options?.label ?? "\u8FDC\u7A0B\u547D\u4EE4";
2901
2941
  return new Promise((resolve5, reject) => {
2902
2942
  client.exec(command, (err, execStream) => {
2903
2943
  if (err) {
@@ -2917,18 +2957,16 @@ async function runRemoteCommand(client, command, options) {
2917
2957
  errText += data.toString();
2918
2958
  });
2919
2959
  execStream.on("close", (code) => {
2920
- if (!stream) {
2921
- if (out) {
2922
- console.log(out.trimEnd());
2923
- }
2924
- if (errText) {
2925
- console.error(errText.trimEnd());
2926
- }
2927
- } else if (out && !out.endsWith("\n")) {
2960
+ if (stream && out && !out.endsWith("\n")) {
2928
2961
  process.stdout.write("\n");
2929
2962
  }
2930
2963
  if (check && code !== 0) {
2931
- fail(`\u8FDC\u7A0B\u547D\u4EE4\u5931\u8D25 (exit ${code}): ${command}`);
2964
+ const combined = `${out}
2965
+ ${errText}`.trim();
2966
+ fail(
2967
+ `${label}\u5931\u8D25 (exit ${code})` + (combined ? `
2968
+ \u8F93\u51FA: ${combined}` : "")
2969
+ );
2932
2970
  }
2933
2971
  resolve5({ exitCode: code, out: out.trim(), err: errText.trim() });
2934
2972
  });
@@ -2963,7 +3001,9 @@ async function extractUpdatePackageOnRemote(client, config, remoteZipPath) {
2963
3001
  remoteZipPath,
2964
3002
  config.remoteLibDir
2965
3003
  );
2966
- const { out } = await runRemoteCommand(client, script);
3004
+ const { out } = await runRemoteCommand(client, script, {
3005
+ label: "\u8FDC\u7A0B\u89E3\u538B"
3006
+ });
2967
3007
  const match = out.match(/UPDATED_COUNT=(\d+)/);
2968
3008
  if (!match) {
2969
3009
  fail(`\u8FDC\u7A0B\u89E3\u538B\u5931\u8D25\uFF0C\u672A\u83B7\u53D6\u66F4\u65B0\u6570\u91CF
@@ -3089,7 +3129,8 @@ exit 1
3089
3129
  }
3090
3130
  async function runRemoteServiceScript(client, script, action) {
3091
3131
  const { exitCode, out, err } = await runRemoteCommand(client, script, {
3092
- check: false
3132
+ check: false,
3133
+ label: action === "status" ? "\u8FDC\u7A0B status" : action === "restart" ? "\u8FDC\u7A0B restart" : "\u5065\u5EB7\u68C0\u67E5"
3093
3134
  });
3094
3135
  const combined = `${out}
3095
3136
  ${err}`.trim();
@@ -3130,9 +3171,7 @@ async function getRunningJar(client, config) {
3130
3171
  return null;
3131
3172
  }
3132
3173
  async function healthCheckService(client, config) {
3133
- log(
3134
- `\u5065\u5EB7\u68C0\u67E5: http://127.0.0.1:${config.healthCheckPort}${normalizeHealthContext(config.healthCheckContext)} (\u8D85\u65F6 ${config.healthCheckTimeout}s)`
3135
- );
3174
+ log("\u5065\u5EB7\u68C0\u67E5...");
3136
3175
  const script = buildRemoteHealthScript(
3137
3176
  config.healthCheckPort,
3138
3177
  config.healthCheckContext,
@@ -3150,7 +3189,10 @@ async function runWisdomBackendDeploy(options) {
3150
3189
  log(`=== \u81EA\u52A8\u90E8\u7F72: ${config.projectName} ===`);
3151
3190
  log(`\u914D\u7F6E\u6587\u4EF6: ${path2.join(workspaceApmDir(), "apm.config.json")}`);
3152
3191
  log(`\u9879\u76EE\u6839\u76EE\u5F55: ${projectRoot}`);
3153
- runMavenBuild(projectRoot, config.mavenLocalRepo);
3192
+ runMavenBuild(projectRoot, config.mavenLocalRepo, {
3193
+ source: config.mavenLocalRepoSource,
3194
+ sourceDetail: config.mavenLocalRepoSourceDetail
3195
+ });
3154
3196
  const libDir = locateLibDir(projectRoot);
3155
3197
  let manifest = loadManifest3();
3156
3198
  const conn = await connectSsh(config);
@@ -3244,7 +3286,6 @@ function resolveFrontendDeployCommand(env, cwd) {
3244
3286
  return null;
3245
3287
  }
3246
3288
  function runShellCommand(command, cwd) {
3247
- console.error(`==> ${command}`);
3248
3289
  const result = spawnSync3(command, {
3249
3290
  cwd,
3250
3291
  stdio: "inherit",
@@ -4652,7 +4693,6 @@ async function runCreatePr(options) {
4652
4693
  // src/commands/deploy/deploy.ts
4653
4694
  import { spawnSync as spawnSync5 } from "node:child_process";
4654
4695
  function runShellCommand3(command, cwd) {
4655
- console.error(`==> ${command}`);
4656
4696
  const result = spawnSync5(command, {
4657
4697
  cwd,
4658
4698
  stdio: "inherit",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "6.0.70",
3
+ "version": "6.0.71",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,