ai-project-manage-cli 6.0.67 → 6.0.68

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 +59 -46
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -2603,7 +2603,20 @@ function fail(message) {
2603
2603
  process.exit(1);
2604
2604
  }
2605
2605
  function expandPath(pathStr) {
2606
- return path2.resolve(pathStr.replace(/^~(?=\/|$)/, process.env.HOME ?? ""));
2606
+ const home = process.env.HOME ?? process.env.USERPROFILE ?? "";
2607
+ return path2.resolve(pathStr.replace(/^~(?=\/|\\|$)/, home));
2608
+ }
2609
+ function quoteForShell(value) {
2610
+ if (process.platform === "win32") {
2611
+ return `"${value.replace(/"/g, '""')}"`;
2612
+ }
2613
+ return shellSingleQuote(value);
2614
+ }
2615
+ function formatMavenLocalRepoArg(repoPath) {
2616
+ if (process.platform === "win32") {
2617
+ return `-Dmaven.repo.local=${quoteForShell(repoPath)}`;
2618
+ }
2619
+ return `-Dmaven.repo.local=${repoPath}`;
2607
2620
  }
2608
2621
  function deployCacheDir() {
2609
2622
  return path2.join(workspaceApmDir(), "deploy", ".deploy_cache");
@@ -2708,33 +2721,40 @@ function getMvnExecutable() {
2708
2721
  const isWin = process.platform === "win32";
2709
2722
  const candidates = isWin ? ["mvn.cmd", "mvn.bat", "mvn"] : ["mvn"];
2710
2723
  for (const name of candidates) {
2711
- const result = spawnSync2(isWin ? "where" : "which", [name], {
2712
- encoding: "utf8"
2724
+ const result = spawnSync2(isWin ? `where ${name}` : `which ${name}`, {
2725
+ encoding: "utf8",
2726
+ shell: true
2713
2727
  });
2714
2728
  if (result.status === 0 && result.stdout.trim()) {
2715
- return result.stdout.trim().split(/\r?\n/)[0];
2729
+ return result.stdout.trim().split(/\r?\n/)[0].trim();
2716
2730
  }
2717
2731
  }
2718
2732
  fail("\u672A\u627E\u5230 mvn \u547D\u4EE4\uFF0C\u8BF7\u786E\u8BA4 Maven \u5DF2\u5B89\u88C5\u5E76\u52A0\u5165 PATH");
2719
2733
  }
2720
2734
  function runMavenBuild(projectRoot, mavenLocalRepo) {
2721
2735
  const mavenRepo = expandPath(mavenLocalRepo);
2722
- const cmd = [
2723
- getMvnExecutable(),
2736
+ const mvn = getMvnExecutable();
2737
+ const command = [
2738
+ quoteForShell(mvn),
2724
2739
  "clean",
2725
2740
  "package",
2726
2741
  `-P${MAVEN_PROFILE}`,
2727
- `-Dmaven.repo.local=${mavenRepo}`,
2742
+ formatMavenLocalRepoArg(mavenRepo),
2728
2743
  "-DskipTests"
2729
- ];
2730
- log(`\u5F00\u59CB Maven \u6784\u5EFA: ${cmd.join(" ")}`);
2744
+ ].join(" ");
2745
+ log(`\u5F00\u59CB Maven \u6784\u5EFA: ${command}`);
2731
2746
  log(`Maven \u672C\u5730\u4ED3\u5E93: ${mavenRepo}`);
2732
- const result = spawnSync2(cmd[0], cmd.slice(1), {
2747
+ log(`\u6784\u5EFA\u76EE\u5F55: ${projectRoot}`);
2748
+ const result = spawnSync2(command, {
2733
2749
  cwd: projectRoot,
2734
- stdio: "inherit"
2750
+ stdio: "inherit",
2751
+ shell: true,
2752
+ env: process.env
2735
2753
  });
2736
2754
  if (result.status !== 0) {
2737
- fail(`Maven \u6784\u5EFA\u5931\u8D25\uFF0C\u9000\u51FA\u7801: ${result.status ?? 1}`);
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
+ );
2738
2758
  }
2739
2759
  }
2740
2760
  function locateLibDir(projectRoot) {
@@ -2978,9 +2998,7 @@ async function runWisdomBackendDeploy(options) {
2978
2998
  log(`=== \u81EA\u52A8\u90E8\u7F72: ${config.projectName} ===`);
2979
2999
  log(`\u914D\u7F6E\u6587\u4EF6: ${path2.join(workspaceApmDir(), "apm.config.json")}`);
2980
3000
  log(`\u9879\u76EE\u6839\u76EE\u5F55: ${projectRoot}`);
2981
- if (!options.skipMaven) {
2982
- runMavenBuild(projectRoot, config.mavenLocalRepo);
2983
- }
3001
+ runMavenBuild(projectRoot, config.mavenLocalRepo);
2984
3002
  const libDir = locateLibDir(projectRoot);
2985
3003
  let manifest = loadManifest3();
2986
3004
  const conn = await connectSsh(config);
@@ -3115,8 +3133,7 @@ async function runWisdomAutoDeploy(options) {
3115
3133
  );
3116
3134
  await runWisdomBackendDeploy({
3117
3135
  config: settings,
3118
- projectRoot: cwd,
3119
- skipMaven: Boolean(options.skipMaven)
3136
+ projectRoot: cwd
3120
3137
  });
3121
3138
  return { projectType };
3122
3139
  }
@@ -4505,33 +4522,30 @@ function registerDeployMainCommand(program) {
4505
4522
  ).argument("<env>", "\u90E8\u7F72\u73AF\u5883\u540D\uFF08\u5982 test\u3001online\uFF09").option(
4506
4523
  "--config <path>",
4507
4524
  "apm.config.json \u8DEF\u5F84\uFF08\u9ED8\u8BA4 .apm/apm.config.json\uFF09"
4508
- ).option("--skip-maven", "\u8DF3\u8FC7 Maven \u6784\u5EFA\uFF08\u4EC5\u533B\u52A1\u540E\u7AEF\uFF09").action(
4509
- async (env, opts) => {
4510
- const cwd = process.cwd();
4511
- const cfg = loadApmConfig({ configPath: opts.config });
4512
- if (isWisdomLegacyDeploy(cfg)) {
4513
- await runWisdomAutoDeploy({
4514
- env,
4515
- cwd,
4516
- configPath: opts.config,
4517
- skipMaven: opts.skipMaven
4518
- });
4519
- return;
4520
- }
4521
- const deployCommands = cfg.deploy ?? {};
4522
- const command = deployCommands[env]?.trim();
4523
- if (!command) {
4524
- const keys = Object.keys(deployCommands);
4525
- console.error(
4526
- keys.length > 0 ? `apm.config.json \u4E2D\u672A\u914D\u7F6E deploy.${env}\uFF0C\u53EF\u7528\u73AF\u5883: ${keys.join(
4527
- ", "
4528
- )}` : `apm.config.json \u4E2D\u672A\u914D\u7F6E deploy \u6BB5`
4529
- );
4530
- process.exit(1);
4531
- }
4532
- runShellCommand3(command, cwd);
4525
+ ).action(async (env, opts) => {
4526
+ const cwd = process.cwd();
4527
+ const cfg = loadApmConfig({ configPath: opts.config });
4528
+ if (isWisdomLegacyDeploy(cfg)) {
4529
+ await runWisdomAutoDeploy({
4530
+ env,
4531
+ cwd,
4532
+ configPath: opts.config
4533
+ });
4534
+ return;
4533
4535
  }
4534
- );
4536
+ const deployCommands = cfg.deploy ?? {};
4537
+ const command = deployCommands[env]?.trim();
4538
+ if (!command) {
4539
+ const keys = Object.keys(deployCommands);
4540
+ console.error(
4541
+ keys.length > 0 ? `apm.config.json \u4E2D\u672A\u914D\u7F6E deploy.${env}\uFF0C\u53EF\u7528\u73AF\u5883: ${keys.join(
4542
+ ", "
4543
+ )}` : `apm.config.json \u4E2D\u672A\u914D\u7F6E deploy \u6BB5`
4544
+ );
4545
+ process.exit(1);
4546
+ }
4547
+ runShellCommand3(command, cwd);
4548
+ });
4535
4549
  }
4536
4550
 
4537
4551
  // src/commands/deploy/backend.ts
@@ -5431,12 +5445,11 @@ function registerDeployWisdomBackendCommands(program) {
5431
5445
  ).option(
5432
5446
  "--config <path>",
5433
5447
  "apm.config.json \u8DEF\u5F84\uFF08\u9ED8\u8BA4 .apm/apm.config.json\uFF09"
5434
- ).option("--skip-maven", "\u8DF3\u8FC7 Maven \u6784\u5EFA\uFF0C\u4EC5\u4E0A\u4F20\u5E76\u91CD\u542F").action(async (opts) => {
5448
+ ).action(async (opts) => {
5435
5449
  const cfg = loadApmConfig({ configPath: opts.config });
5436
5450
  const settings = resolveWisdomBackendDeployFromApmConfig(cfg);
5437
5451
  await runWisdomBackendDeploy({
5438
- config: settings,
5439
- skipMaven: Boolean(opts.skipMaven)
5452
+ config: settings
5440
5453
  });
5441
5454
  });
5442
5455
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ai-project-manage-cli",
3
- "version": "6.0.67",
3
+ "version": "6.0.68",
4
4
  "description": "命令行工具:后续用于调用平台后端 API 完成运维与自动化操作",
5
5
  "type": "module",
6
6
  "private": false,