ai-project-manage-cli 6.0.70 → 6.0.72

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
@@ -520,7 +520,7 @@ async function tryReadGitOriginUrl(cwd) {
520
520
  }
521
521
 
522
522
  // src/deployment-config-sync.ts
523
- var TEMPLATE_HINT = "\u4FDD\u7559\u6A21\u677F .apm/apm.config.json \u4E0E .apm/deploy/README.md";
523
+ var TEMPLATE_HINT = "\u4FDD\u7559\u6A21\u677F .apm/apm.config.json";
524
524
  var SYNC_HINT = "\u767B\u8BB0\u5DE5\u4F5C\u7A7A\u95F4\u8DEF\u5F84\u3001\u7ED1\u5B9A\u4ED3\u5E93\u540E\uFF0C\u53EF\u6267\u884C: apm sync-deploy-config";
525
525
  async function resolveRepositoryIdForSync(api, workdirPath) {
526
526
  const baseline = await api.cli.workspaceBaseline({ workdirPath });
@@ -583,15 +583,8 @@ ${diagnostic ?? ""}
583
583
  const apmConfigPath = toFsPath(join3(targetApmDir, "apm.config.json"));
584
584
  writeFileSync3(apmConfigPath, `${JSON.stringify(parsed, null, 2)}
585
585
  `, "utf8");
586
- const deployDir = join3(targetApmDir, "deploy");
587
- await ensureDirExists(deployDir);
588
- writeFileSync3(
589
- toFsPath(join3(deployDir, "README.md")),
590
- config.deploymentDoc ?? "",
591
- "utf8"
592
- );
593
586
  console.log(`[apm] \u5DF2\u540C\u6B65\u5E73\u53F0\u90E8\u7F72\u914D\u7F6E: ${config.name}`);
594
- console.log("[apm] \u5DF2\u5199\u5165 .apm/apm.config.json \u4E0E .apm/deploy/README.md");
587
+ console.log("[apm] \u5DF2\u5199\u5165 .apm/apm.config.json");
595
588
  return { synced: true, repositoryId, configName: config.name };
596
589
  }
597
590
 
@@ -915,7 +908,7 @@ async function runInit(name) {
915
908
  console.log(`[apm] \u5DE5\u4F5C\u76EE\u5F55\u8DEF\u5F84\uFF1A${workdir}`);
916
909
  if (syncResult && !syncResult.synced) {
917
910
  console.log(
918
- "[apm] \u5F53\u524D .apm/apm.config.json \u4E0E .apm/deploy/README.md \u4E3A\u6A21\u677F\u9ED8\u8BA4\u503C\uFF1B\u5B8C\u6210\u5E73\u53F0\u767B\u8BB0\u540E\u6267\u884C apm sync-deploy-config"
911
+ "[apm] \u5F53\u524D .apm/apm.config.json \u4E3A\u6A21\u677F\u9ED8\u8BA4\u503C\uFF1B\u5B8C\u6210\u5E73\u53F0\u767B\u8BB0\u540E\u6267\u884C apm sync-deploy-config"
919
912
  );
920
913
  }
921
914
  console.log("[apm] \u8BF7\u5728\u5E73\u53F0\u300C\u63A5\u5165\u7BA1\u7406 \u2192 \u5DE5\u4F5C\u7A7A\u95F4\u300D\u767B\u8BB0\u4E0A\u8FF0\u76EE\u5F55\u8DEF\u5F84");
@@ -2376,9 +2369,23 @@ function reqWb(v, field) {
2376
2369
  }
2377
2370
  return v;
2378
2371
  }
2372
+ function readEnvVar(env, name) {
2373
+ if (env[name] !== void 0) {
2374
+ return env[name];
2375
+ }
2376
+ if (process.platform === "win32") {
2377
+ const target = name.toUpperCase();
2378
+ for (const [key, value] of Object.entries(env)) {
2379
+ if (key.toUpperCase() === target) {
2380
+ return value;
2381
+ }
2382
+ }
2383
+ }
2384
+ return void 0;
2385
+ }
2379
2386
  function expandWindowsEnvVars(pathStr, env = process.env) {
2380
2387
  return pathStr.replace(/%([^%]+)%/g, (_, name) => {
2381
- const value = env[name];
2388
+ const value = readEnvVar(env, name);
2382
2389
  return value ?? `%${name}%`;
2383
2390
  });
2384
2391
  }
@@ -2403,14 +2410,17 @@ function readMavenLocalRepoFromMavenOpts(mavenOpts, env = process.env) {
2403
2410
  }
2404
2411
  function readMavenLocalRepoFromEnv(env = process.env) {
2405
2412
  for (const key of MAVEN_REPO_ENV_KEYS) {
2406
- const raw = env[key]?.trim();
2413
+ const raw = readEnvVar(env, key)?.trim();
2407
2414
  if (raw) {
2408
- return expandUserPath(raw, env);
2415
+ return { path: expandUserPath(raw, env), key };
2409
2416
  }
2410
2417
  }
2411
- const mavenOpts = env.MAVEN_OPTS?.trim();
2418
+ const mavenOpts = readEnvVar(env, "MAVEN_OPTS")?.trim();
2412
2419
  if (mavenOpts) {
2413
- return readMavenLocalRepoFromMavenOpts(mavenOpts, env);
2420
+ const path12 = readMavenLocalRepoFromMavenOpts(mavenOpts, env);
2421
+ if (path12) {
2422
+ return { path: path12, key: "MAVEN_OPTS" };
2423
+ }
2414
2424
  }
2415
2425
  return null;
2416
2426
  }
@@ -2433,12 +2443,28 @@ function readMavenLocalRepoFromSettings() {
2433
2443
  return null;
2434
2444
  }
2435
2445
  }
2436
- function resolveMavenLocalRepo(configured) {
2437
- const trimmed = configured?.trim();
2438
- if (trimmed) {
2439
- return expandUserPath(trimmed);
2446
+ function resolveMavenLocalRepoWithSource() {
2447
+ const fromEnv = readMavenLocalRepoFromEnv();
2448
+ if (fromEnv) {
2449
+ return {
2450
+ path: fromEnv.path,
2451
+ source: "env",
2452
+ sourceDetail: fromEnv.key
2453
+ };
2454
+ }
2455
+ const fromSettings = readMavenLocalRepoFromSettings();
2456
+ if (fromSettings) {
2457
+ return {
2458
+ path: fromSettings,
2459
+ source: "settings",
2460
+ sourceDetail: "~/.m2/settings.xml"
2461
+ };
2440
2462
  }
2441
- return readMavenLocalRepoFromEnv() ?? readMavenLocalRepoFromSettings() ?? join13(homedir2(), ".m2", "repository");
2463
+ return {
2464
+ path: join13(homedir2(), ".m2", "repository"),
2465
+ source: "default",
2466
+ sourceDetail: "~/.m2/repository"
2467
+ };
2442
2468
  }
2443
2469
  function resolveWisdomBackendDeployFromApmConfig(cfg) {
2444
2470
  const projectName = reqTopLevelName(cfg);
@@ -2456,6 +2482,7 @@ function resolveWisdomBackendDeployFromApmConfig(cfg) {
2456
2482
  console.error("apm.config.json \u4E2D healthCheck.timeout \u987B\u4E3A\u6B63\u6574\u6570");
2457
2483
  process.exit(1);
2458
2484
  }
2485
+ const mavenLocalRepo = resolveMavenLocalRepoWithSource();
2459
2486
  return {
2460
2487
  projectName,
2461
2488
  host: reqWd(w.host, "host").trim(),
@@ -2467,7 +2494,9 @@ function resolveWisdomBackendDeployFromApmConfig(cfg) {
2467
2494
  remoteLibDir: `${remoteAppDir}/lib`,
2468
2495
  startupJar: posixBasename(jarPath),
2469
2496
  packageName: `${projectName}.jar.zip`,
2470
- mavenLocalRepo: resolveMavenLocalRepo(w.mavenLocalRepo),
2497
+ mavenLocalRepo: mavenLocalRepo.path,
2498
+ mavenLocalRepoSource: mavenLocalRepo.source,
2499
+ mavenLocalRepoSourceDetail: mavenLocalRepo.sourceDetail,
2471
2500
  healthCheckPort: healthPort,
2472
2501
  healthCheckContext: reqHc(h.context, "context").trim(),
2473
2502
  healthCheckTimeout: healthTimeout
@@ -2796,7 +2825,7 @@ function getMvnExecutable() {
2796
2825
  }
2797
2826
  fail("\u672A\u627E\u5230 mvn \u547D\u4EE4\uFF0C\u8BF7\u786E\u8BA4 Maven \u5DF2\u5B89\u88C5\u5E76\u52A0\u5165 PATH");
2798
2827
  }
2799
- function runMavenBuild(projectRoot, mavenLocalRepo) {
2828
+ function runMavenBuild(projectRoot, mavenLocalRepo, repoSource) {
2800
2829
  const mavenRepo = expandPath(mavenLocalRepo);
2801
2830
  const mvn = getMvnExecutable();
2802
2831
  const command = [
@@ -2807,8 +2836,14 @@ function runMavenBuild(projectRoot, mavenLocalRepo) {
2807
2836
  formatMavenLocalRepoArg(mavenRepo),
2808
2837
  "-DskipTests"
2809
2838
  ].join(" ");
2810
- log(`\u5F00\u59CB Maven \u6784\u5EFA: ${command}`);
2811
- log(`Maven \u672C\u5730\u4ED3\u5E93: ${mavenRepo}`);
2839
+ log("\u5F00\u59CB Maven \u6784\u5EFA...");
2840
+ if (repoSource) {
2841
+ log(
2842
+ `Maven \u672C\u5730\u4ED3\u5E93: ${mavenRepo} (\u6765\u6E90: ${repoSource.source}/${repoSource.sourceDetail})`
2843
+ );
2844
+ } else {
2845
+ log(`Maven \u672C\u5730\u4ED3\u5E93: ${mavenRepo}`);
2846
+ }
2812
2847
  log(`\u6784\u5EFA\u76EE\u5F55: ${projectRoot}`);
2813
2848
  const result = spawnSync2(command, {
2814
2849
  cwd: projectRoot,
@@ -2817,9 +2852,7 @@ function runMavenBuild(projectRoot, mavenLocalRepo) {
2817
2852
  env: process.env
2818
2853
  });
2819
2854
  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
- );
2855
+ fail(`Maven \u6784\u5EFA\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${result.status ?? 1}`);
2823
2856
  }
2824
2857
  }
2825
2858
  function locateLibDir(projectRoot) {
@@ -2897,7 +2930,7 @@ async function uploadUpdatePackage(sftp, zipPath, config) {
2897
2930
  async function runRemoteCommand(client, command, options) {
2898
2931
  const check = options?.check ?? true;
2899
2932
  const stream = options?.stream ?? false;
2900
- log(`\u8FDC\u7A0B\u6267\u884C: ${command}`);
2933
+ const label = options?.label ?? "\u8FDC\u7A0B\u547D\u4EE4";
2901
2934
  return new Promise((resolve5, reject) => {
2902
2935
  client.exec(command, (err, execStream) => {
2903
2936
  if (err) {
@@ -2917,18 +2950,16 @@ async function runRemoteCommand(client, command, options) {
2917
2950
  errText += data.toString();
2918
2951
  });
2919
2952
  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")) {
2953
+ if (stream && out && !out.endsWith("\n")) {
2928
2954
  process.stdout.write("\n");
2929
2955
  }
2930
2956
  if (check && code !== 0) {
2931
- fail(`\u8FDC\u7A0B\u547D\u4EE4\u5931\u8D25 (exit ${code}): ${command}`);
2957
+ const combined = `${out}
2958
+ ${errText}`.trim();
2959
+ fail(
2960
+ `${label}\u5931\u8D25 (exit ${code})` + (combined ? `
2961
+ \u8F93\u51FA: ${combined}` : "")
2962
+ );
2932
2963
  }
2933
2964
  resolve5({ exitCode: code, out: out.trim(), err: errText.trim() });
2934
2965
  });
@@ -2963,7 +2994,9 @@ async function extractUpdatePackageOnRemote(client, config, remoteZipPath) {
2963
2994
  remoteZipPath,
2964
2995
  config.remoteLibDir
2965
2996
  );
2966
- const { out } = await runRemoteCommand(client, script);
2997
+ const { out } = await runRemoteCommand(client, script, {
2998
+ label: "\u8FDC\u7A0B\u89E3\u538B"
2999
+ });
2967
3000
  const match = out.match(/UPDATED_COUNT=(\d+)/);
2968
3001
  if (!match) {
2969
3002
  fail(`\u8FDC\u7A0B\u89E3\u538B\u5931\u8D25\uFF0C\u672A\u83B7\u53D6\u66F4\u65B0\u6570\u91CF
@@ -3089,7 +3122,8 @@ exit 1
3089
3122
  }
3090
3123
  async function runRemoteServiceScript(client, script, action) {
3091
3124
  const { exitCode, out, err } = await runRemoteCommand(client, script, {
3092
- check: false
3125
+ check: false,
3126
+ label: action === "status" ? "\u8FDC\u7A0B status" : action === "restart" ? "\u8FDC\u7A0B restart" : "\u5065\u5EB7\u68C0\u67E5"
3093
3127
  });
3094
3128
  const combined = `${out}
3095
3129
  ${err}`.trim();
@@ -3130,9 +3164,7 @@ async function getRunningJar(client, config) {
3130
3164
  return null;
3131
3165
  }
3132
3166
  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
- );
3167
+ log("\u5065\u5EB7\u68C0\u67E5...");
3136
3168
  const script = buildRemoteHealthScript(
3137
3169
  config.healthCheckPort,
3138
3170
  config.healthCheckContext,
@@ -3150,7 +3182,10 @@ async function runWisdomBackendDeploy(options) {
3150
3182
  log(`=== \u81EA\u52A8\u90E8\u7F72: ${config.projectName} ===`);
3151
3183
  log(`\u914D\u7F6E\u6587\u4EF6: ${path2.join(workspaceApmDir(), "apm.config.json")}`);
3152
3184
  log(`\u9879\u76EE\u6839\u76EE\u5F55: ${projectRoot}`);
3153
- runMavenBuild(projectRoot, config.mavenLocalRepo);
3185
+ runMavenBuild(projectRoot, config.mavenLocalRepo, {
3186
+ source: config.mavenLocalRepoSource,
3187
+ sourceDetail: config.mavenLocalRepoSourceDetail
3188
+ });
3154
3189
  const libDir = locateLibDir(projectRoot);
3155
3190
  let manifest = loadManifest3();
3156
3191
  const conn = await connectSsh(config);
@@ -3244,7 +3279,6 @@ function resolveFrontendDeployCommand(env, cwd) {
3244
3279
  return null;
3245
3280
  }
3246
3281
  function runShellCommand(command, cwd) {
3247
- console.error(`==> ${command}`);
3248
3282
  const result = spawnSync3(command, {
3249
3283
  cwd,
3250
3284
  stdio: "inherit",
@@ -4652,7 +4686,6 @@ async function runCreatePr(options) {
4652
4686
  // src/commands/deploy/deploy.ts
4653
4687
  import { spawnSync as spawnSync5 } from "node:child_process";
4654
4688
  function runShellCommand3(command, cwd) {
4655
- console.error(`==> ${command}`);
4656
4689
  const result = spawnSync5(command, {
4657
4690
  cwd,
4658
4691
  stdio: "inherit",
@@ -5623,7 +5656,7 @@ function buildProgram() {
5623
5656
  await runLogin(opts);
5624
5657
  });
5625
5658
  program.command("init").description(
5626
- "\u5728\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u521D\u59CB\u5316 .apm \u6A21\u677F\uFF08\u82E5 .apm \u5DF2\u5B58\u5728\u4E14\u975E\u7A7A\u5219\u62A5\u9519\uFF09\uFF1B\u5DF2\u767B\u5F55\u4E14\u5E73\u53F0\u6709\u5339\u914D\u90E8\u7F72\u914D\u7F6E\u65F6\u4F1A\u540C\u6B65 apm.config.json \u4E0E deploy/README.md"
5659
+ "\u5728\u5F53\u524D\u5DE5\u4F5C\u76EE\u5F55\u521D\u59CB\u5316 .apm \u6A21\u677F\uFF08\u82E5 .apm \u5DF2\u5B58\u5728\u4E14\u975E\u7A7A\u5219\u62A5\u9519\uFF09\uFF1B\u5DF2\u767B\u5F55\u4E14\u5E73\u53F0\u6709\u5339\u914D\u90E8\u7F72\u914D\u7F6E\u65F6\u4F1A\u540C\u6B65 apm.config.json"
5627
5660
  ).option("--name <name>", "\u5DE5\u4F5C\u76EE\u5F55\u540D\u79F0").action(async (opts) => {
5628
5661
  await runInit(opts.name);
5629
5662
  });
@@ -5643,7 +5676,7 @@ function buildProgram() {
5643
5676
  await runUpdateSkills();
5644
5677
  });
5645
5678
  program.command("sync-deploy-config").description(
5646
- "\u4ECE\u5E73\u53F0\u62C9\u53D6\u90E8\u7F72\u914D\u7F6E\uFF0C\u8986\u76D6 .apm/apm.config.json \u4E0E .apm/deploy/README.md\uFF08\u9700\u5DF2 login \u4E14\u5DE5\u4F5C\u7A7A\u95F4\u5DF2\u767B\u8BB0\u5E76\u7ED1\u5B9A\u4ED3\u5E93\uFF09"
5679
+ "\u4ECE\u5E73\u53F0\u62C9\u53D6\u90E8\u7F72\u914D\u7F6E\uFF0C\u8986\u76D6 .apm/apm.config.json\uFF08\u9700\u5DF2 login \u4E14\u5DE5\u4F5C\u7A7A\u95F4\u5DF2\u767B\u8BB0\u5E76\u7ED1\u5B9A\u4ED3\u5E93\uFF09"
5647
5680
  ).action(async () => {
5648
5681
  await runSyncDeployConfig();
5649
5682
  });
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.72",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,
@@ -1,14 +0,0 @@
1
- ## 部署
2
-
3
- 部署测试环境:`apm deploy test`
4
- 部署线上环境:`apm deploy online`
5
-
6
-
7
- ## 前端产物下载地址
8
-
9
- http://<服务器地址>/dist.zip
10
- http://<服务器地址>/{name}.jar.zip
11
-
12
- ## 测试地址
13
-
14
- http://<服务器地址>