ai-project-manage-cli 6.0.95 → 6.0.96
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 +48 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3878,7 +3878,20 @@ function runNpm2(args, options = {}) {
|
|
|
3878
3878
|
shell: useNpmShell2
|
|
3879
3879
|
});
|
|
3880
3880
|
}
|
|
3881
|
+
function verifyPm2Bin(pm2Bin) {
|
|
3882
|
+
if (!pm2Bin.trim() || !existsSync14(pm2Bin)) {
|
|
3883
|
+
return false;
|
|
3884
|
+
}
|
|
3885
|
+
const result = spawnSync2(pm2Bin, ["--version"], {
|
|
3886
|
+
encoding: "utf8",
|
|
3887
|
+
shell: useNpmShell2,
|
|
3888
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
3889
|
+
timeout: 15e3
|
|
3890
|
+
});
|
|
3891
|
+
return !result.error && result.status === 0;
|
|
3892
|
+
}
|
|
3881
3893
|
function findGlobalPm2() {
|
|
3894
|
+
const candidates = [];
|
|
3882
3895
|
const whichResult = spawnSync2(useNpmShell2 ? "where" : "which", ["pm2"], {
|
|
3883
3896
|
encoding: "utf8",
|
|
3884
3897
|
shell: useNpmShell2,
|
|
@@ -3888,8 +3901,8 @@ function findGlobalPm2() {
|
|
|
3888
3901
|
const lines = whichResult.stdout?.toString().trim().split(/\r?\n/) ?? [];
|
|
3889
3902
|
for (const line of lines) {
|
|
3890
3903
|
const candidate = line.trim();
|
|
3891
|
-
if (candidate
|
|
3892
|
-
|
|
3904
|
+
if (candidate) {
|
|
3905
|
+
candidates.push(candidate);
|
|
3893
3906
|
}
|
|
3894
3907
|
}
|
|
3895
3908
|
}
|
|
@@ -3900,10 +3913,15 @@ function findGlobalPm2() {
|
|
|
3900
3913
|
if (binResult.status === 0) {
|
|
3901
3914
|
const globalBin = binResult.stdout?.toString().trim();
|
|
3902
3915
|
if (globalBin) {
|
|
3903
|
-
|
|
3904
|
-
|
|
3905
|
-
|
|
3906
|
-
|
|
3916
|
+
candidates.push(join15(globalBin, useNpmShell2 ? "pm2.cmd" : "pm2"));
|
|
3917
|
+
}
|
|
3918
|
+
}
|
|
3919
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3920
|
+
for (const candidate of candidates) {
|
|
3921
|
+
if (seen.has(candidate)) continue;
|
|
3922
|
+
seen.add(candidate);
|
|
3923
|
+
if (verifyPm2Bin(candidate)) {
|
|
3924
|
+
return candidate;
|
|
3907
3925
|
}
|
|
3908
3926
|
}
|
|
3909
3927
|
return null;
|
|
@@ -3919,9 +3937,31 @@ function installGlobalPm2() {
|
|
|
3919
3937
|
process.exit(result.status ?? 1);
|
|
3920
3938
|
}
|
|
3921
3939
|
}
|
|
3940
|
+
function readPm2Version(pm2Bin) {
|
|
3941
|
+
const result = spawnSync2(pm2Bin, ["--version"], {
|
|
3942
|
+
encoding: "utf8",
|
|
3943
|
+
shell: useNpmShell2,
|
|
3944
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
3945
|
+
timeout: 15e3
|
|
3946
|
+
});
|
|
3947
|
+
if (result.error || result.status !== 0) {
|
|
3948
|
+
return null;
|
|
3949
|
+
}
|
|
3950
|
+
return result.stdout?.toString().trim() || null;
|
|
3951
|
+
}
|
|
3952
|
+
function logPm2Ready(pm2Bin, installed2) {
|
|
3953
|
+
const version = readPm2Version(pm2Bin);
|
|
3954
|
+
const versionSuffix = version ? ` ${version}` : "";
|
|
3955
|
+
if (installed2) {
|
|
3956
|
+
console.log(`[apm] \u5168\u5C40 pm2 \u5DF2\u5B89\u88C5${versionSuffix}: ${pm2Bin}`);
|
|
3957
|
+
} else {
|
|
3958
|
+
console.log(`[apm] \u5DF2\u68C0\u6D4B\u5230\u5168\u5C40 pm2${versionSuffix}: ${pm2Bin}`);
|
|
3959
|
+
}
|
|
3960
|
+
}
|
|
3922
3961
|
function ensureGlobalPm2() {
|
|
3923
3962
|
const existing = findGlobalPm2();
|
|
3924
3963
|
if (existing) {
|
|
3964
|
+
logPm2Ready(existing, false);
|
|
3925
3965
|
return existing;
|
|
3926
3966
|
}
|
|
3927
3967
|
installGlobalPm2();
|
|
@@ -3932,6 +3972,7 @@ function ensureGlobalPm2() {
|
|
|
3932
3972
|
);
|
|
3933
3973
|
process.exit(1);
|
|
3934
3974
|
}
|
|
3975
|
+
logPm2Ready(installed2, true);
|
|
3935
3976
|
return installed2;
|
|
3936
3977
|
}
|
|
3937
3978
|
function resolveApmEntryPath(entryArg = process.argv[1]) {
|
|
@@ -4086,8 +4127,8 @@ async function prepareEcosystem(server) {
|
|
|
4086
4127
|
}
|
|
4087
4128
|
async function runDaemonStart(options) {
|
|
4088
4129
|
assertConnectNotRunning();
|
|
4089
|
-
ensureGlobalPm2();
|
|
4090
4130
|
await runUpdate();
|
|
4131
|
+
ensureGlobalPm2();
|
|
4091
4132
|
const cfg = await prepareEcosystem(options.server);
|
|
4092
4133
|
runPm2(["start", PM2_ECOSYSTEM_PATH, "--update-env"], { inherit: true });
|
|
4093
4134
|
console.log(
|