ai-project-manage-cli 6.0.77 → 6.0.79

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 +55 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -3853,6 +3853,19 @@ function resolveMavenLocalRepoWithSource() {
3853
3853
  sourceDetail: "~/.m2/repository"
3854
3854
  };
3855
3855
  }
3856
+ function resolveWisdomDeployMode(raw) {
3857
+ if (raw === void 0 || raw === null || raw === "") {
3858
+ return "default";
3859
+ }
3860
+ const mode = String(raw).trim().toLowerCase();
3861
+ if (mode === "default" || mode === "full") {
3862
+ return mode;
3863
+ }
3864
+ console.error(
3865
+ `apm.config.json \u4E2D wisdomDeploy.mode \u53EA\u80FD\u4E3A default \u6216 full\uFF0C\u5F53\u524D\u503C: ${raw}`
3866
+ );
3867
+ process.exit(1);
3868
+ }
3856
3869
  function resolveWisdomBackendDeployFromApmConfig(cfg) {
3857
3870
  const projectName = reqTopLevelName(cfg);
3858
3871
  const w = cfg.wisdomDeploy ?? {};
@@ -3886,7 +3899,8 @@ function resolveWisdomBackendDeployFromApmConfig(cfg) {
3886
3899
  mavenLocalRepoSourceDetail: mavenLocalRepo.sourceDetail,
3887
3900
  healthCheckPort: healthPort,
3888
3901
  healthCheckContext: reqHc(h.context, "context").trim(),
3889
- healthCheckTimeout: healthTimeout
3902
+ healthCheckTimeout: healthTimeout,
3903
+ mode: resolveWisdomDeployMode(w.mode)
3890
3904
  };
3891
3905
  }
3892
3906
  function posixDirname(p) {
@@ -4263,6 +4277,19 @@ function locateLibDir(projectRoot) {
4263
4277
  log(`\u5B9A\u4F4D lib \u4EA7\u7269: ${libJars.length} \u4E2A`);
4264
4278
  return libDir;
4265
4279
  }
4280
+ function locateMainJar(projectRoot) {
4281
+ const targetDir = getTargetDir(projectRoot);
4282
+ if (!existsSync14(targetDir)) {
4283
+ fail(`\u6784\u5EFA\u4EA7\u7269\u76EE\u5F55\u4E0D\u5B58\u5728: ${targetDir}`);
4284
+ }
4285
+ const jarFiles = readdirSync5(targetDir).filter((name) => name.endsWith(".jar") && !name.endsWith(".jar.original")).map((name) => path2.join(targetDir, name)).sort((a, b) => statSync5(b).mtimeMs - statSync5(a).mtimeMs);
4286
+ if (jarFiles.length === 0) {
4287
+ fail(`target \u76EE\u5F55\u4E0B\u6CA1\u6709\u4E3B JAR: ${targetDir}`);
4288
+ }
4289
+ const mainJar = jarFiles[0];
4290
+ log(`\u5B9A\u4F4D\u4E3B JAR \u4EA7\u7269: ${path2.basename(mainJar)}`);
4291
+ return mainJar;
4292
+ }
4266
4293
  async function connectSsh(config) {
4267
4294
  const client = new Client();
4268
4295
  log(`\u8FDE\u63A5\u670D\u52A1\u5668 ${config.username}@${config.host}:${config.port}`);
@@ -4319,6 +4346,18 @@ async function uploadUpdatePackage(sftp, zipPath, config) {
4319
4346
  }
4320
4347
  return remotePath;
4321
4348
  }
4349
+ async function uploadFullJar(sftp, localJarPath, config) {
4350
+ const remoteDir = config.remoteAppDir.replace(/\/$/, "");
4351
+ const remotePath = `${remoteDir}/${config.startupJar}`;
4352
+ log(`\u4E0A\u4F20\u5168\u91CF JAR (${path2.basename(localJarPath)}) -> ${remotePath}`);
4353
+ try {
4354
+ await sftp.mkdir(remoteDir, true);
4355
+ await sftp.fastPut(localJarPath, remotePath);
4356
+ log("\u5168\u91CF JAR \u4E0A\u4F20\u6210\u529F");
4357
+ } catch (err) {
4358
+ fail(`\u5168\u91CF JAR \u4E0A\u4F20\u5931\u8D25: ${err instanceof Error ? err.message : err}`);
4359
+ }
4360
+ }
4322
4361
  async function runRemoteCommand(client, command, options) {
4323
4362
  const check = options?.check ?? true;
4324
4363
  const stream = options?.stream ?? false;
@@ -4574,14 +4613,26 @@ async function runWisdomBackendDeploy(options) {
4574
4613
  log(`=== \u81EA\u52A8\u90E8\u7F72: ${config.projectName} ===`);
4575
4614
  log(`\u914D\u7F6E\u6587\u4EF6: ${path2.join(workspaceApmDir(), "apm.config.json")}`);
4576
4615
  log(`\u9879\u76EE\u6839\u76EE\u5F55: ${projectRoot}`);
4616
+ log(
4617
+ `\u90E8\u7F72\u6A21\u5F0F: ${config.mode}${config.mode === "full" ? "\uFF08\u5168\u91CF JAR\uFF0C\u8DF3\u8FC7 lib \u68C0\u67E5\uFF09" : "\uFF08\u589E\u91CF lib \u66F4\u65B0\uFF09"}`
4618
+ );
4577
4619
  runMavenBuild(projectRoot, config.mavenLocalRepo, {
4578
4620
  source: config.mavenLocalRepoSource,
4579
4621
  sourceDetail: config.mavenLocalRepoSourceDetail
4580
4622
  });
4581
- const libDir = locateLibDir(projectRoot);
4582
- let manifest = loadManifest4();
4583
4623
  const conn = await connectSsh(config);
4584
4624
  try {
4625
+ if (config.mode === "full") {
4626
+ const mainJar = locateMainJar(projectRoot);
4627
+ await uploadFullJar(conn.sftp, mainJar, config);
4628
+ log("\u91CD\u542F\u670D\u52A1...");
4629
+ await restartRemoteService(conn.client, config);
4630
+ await healthCheckService(conn.client, config);
4631
+ log("\u90E8\u7F72\u5B8C\u6210");
4632
+ return;
4633
+ }
4634
+ const libDir = locateLibDir(projectRoot);
4635
+ let manifest = loadManifest4();
4585
4636
  const remoteLibStats = await getRemoteFileStats(
4586
4637
  conn.sftp,
4587
4638
  config.remoteLibDir
@@ -5648,7 +5699,7 @@ function registerDeploySftpCommands(program) {
5648
5699
  // src/commands/deploy/wisdom-backend.ts
5649
5700
  function registerDeployWisdomBackendCommands(program) {
5650
5701
  program.command("deploy-wisdom-backend").description(
5651
- "Maven \u6784\u5EFA\u540E\u901A\u8FC7 SFTP \u589E\u91CF\u66F4\u65B0\u8FDC\u7A0B lib \u76EE\u5F55\u5E76\u91CD\u542F Spring Boot \u670D\u52A1\uFF08\u914D\u7F6E\u89C1 apm.config.json \u7684 wisdomDeploy \u4E0E healthCheck\uFF09"
5702
+ "Maven \u6784\u5EFA\u540E\u90E8\u7F72 Spring Boot \u670D\u52A1\uFF08\u914D\u7F6E\u89C1 apm.config.json \u7684 wisdomDeploy \u4E0E healthCheck\uFF1Bmode=default \u589E\u91CF\u66F4\u65B0 lib\uFF0Cmode=full \u53D1\u5E03\u5168\u91CF JAR\uFF09"
5652
5703
  ).option(
5653
5704
  "--config <path>",
5654
5705
  "apm.config.json \u8DEF\u5F84\uFF08\u9ED8\u8BA4 .apm/apm.config.json\uFF09"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "6.0.77",
3
+ "version": "6.0.79",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,