@kelceyp/caw 1.0.6 → 1.0.7
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/caw.js +59 -18
- package/package.json +1 -1
- package/scripts/postinstall.js +1 -1
package/dist/caw.js
CHANGED
|
@@ -10644,7 +10644,7 @@ function isProcessAlive(pid) {
|
|
|
10644
10644
|
}
|
|
10645
10645
|
}
|
|
10646
10646
|
function getPm2Name(envDir) {
|
|
10647
|
-
return `caw-${path3.basename(envDir)}`;
|
|
10647
|
+
return `caw-${path3.basename(envDir).replace(/^\./, "")}`;
|
|
10648
10648
|
}
|
|
10649
10649
|
function isPm2Installed() {
|
|
10650
10650
|
try {
|
|
@@ -10718,6 +10718,8 @@ function createPm2Manager(envDir, checkPm2 = isPm2Installed) {
|
|
|
10718
10718
|
return false;
|
|
10719
10719
|
try {
|
|
10720
10720
|
pm2Exec(`stop ${name}`);
|
|
10721
|
+
} catch {}
|
|
10722
|
+
try {
|
|
10721
10723
|
pm2Exec(`delete ${name}`);
|
|
10722
10724
|
return true;
|
|
10723
10725
|
} catch {
|
|
@@ -10731,6 +10733,9 @@ function createPm2Manager(envDir, checkPm2 = isPm2Installed) {
|
|
|
10731
10733
|
` + `Install PM2 with: npm install -g pm2
|
|
10732
10734
|
` + 'Or switch to PID mode by setting "process_manager": "pid" in config.json');
|
|
10733
10735
|
}
|
|
10736
|
+
try {
|
|
10737
|
+
pm2Exec(`delete ${name}`);
|
|
10738
|
+
} catch {}
|
|
10734
10739
|
const logPath = logFilePath(envDir);
|
|
10735
10740
|
const envArgs = Object.entries(envVars).map(([k, v]) => `${k}=${v}`).join(" ");
|
|
10736
10741
|
const nodeArgsStr = nodeArgs.length > 0 ? ` --node-args="${nodeArgs.map((a) => `\\"${a}\\"`).join(" ")}"` : "";
|
|
@@ -10971,7 +10976,7 @@ async function pollHealth(port, maxRetries = 10, intervalMs = 1000) {
|
|
|
10971
10976
|
}
|
|
10972
10977
|
function attemptInstallServer() {
|
|
10973
10978
|
try {
|
|
10974
|
-
execSync4("npm install -g @kelceyp/caw-server@^1", { stdio: "inherit" });
|
|
10979
|
+
execSync4("npm install -g @kelceyp/caw-server@^1 --loglevel=error", { stdio: "inherit" });
|
|
10975
10980
|
return true;
|
|
10976
10981
|
} catch {
|
|
10977
10982
|
return false;
|
|
@@ -11412,6 +11417,18 @@ async function checkHealth3(port) {
|
|
|
11412
11417
|
return { reachable: false, healthy: false, data: null };
|
|
11413
11418
|
}
|
|
11414
11419
|
}
|
|
11420
|
+
async function fetchRunningVersion(port) {
|
|
11421
|
+
try {
|
|
11422
|
+
const response = await fetch(`http://localhost:${port}/api/info`);
|
|
11423
|
+
if (response.ok) {
|
|
11424
|
+
const data = await response.json();
|
|
11425
|
+
return data.version || null;
|
|
11426
|
+
}
|
|
11427
|
+
return null;
|
|
11428
|
+
} catch {
|
|
11429
|
+
return null;
|
|
11430
|
+
}
|
|
11431
|
+
}
|
|
11415
11432
|
async function pollHealth2(port, maxRetries = 10, intervalMs = 1000) {
|
|
11416
11433
|
for (let i = 0;i < maxRetries; i++) {
|
|
11417
11434
|
await new Promise((r) => setTimeout(r, intervalMs));
|
|
@@ -11467,12 +11484,30 @@ var create6 = () => {
|
|
|
11467
11484
|
} catch (e) {
|
|
11468
11485
|
console.warn(`Warning: Could not write cache file: ${e.message}`);
|
|
11469
11486
|
}
|
|
11487
|
+
let skipInstall = false;
|
|
11470
11488
|
if (import_semver2.default.gte(installedVersion, latestServerVersion)) {
|
|
11471
|
-
|
|
11472
|
-
|
|
11489
|
+
let needsRestart = false;
|
|
11490
|
+
if (fs11.existsSync(envDir) && configExists4(envDir)) {
|
|
11491
|
+
const config = readConfigWithDefaults(envDir);
|
|
11492
|
+
const pm = createProcessManager(config, envDir);
|
|
11493
|
+
if (pm.isRunning().running) {
|
|
11494
|
+
const runningVersion = await fetchRunningVersion(config.port);
|
|
11495
|
+
if (runningVersion && import_semver2.default.lt(runningVersion, installedVersion)) {
|
|
11496
|
+
needsRestart = true;
|
|
11497
|
+
console.log(`Installed: ${installedVersion} Running: ${runningVersion} — restarting server.`);
|
|
11498
|
+
}
|
|
11499
|
+
}
|
|
11500
|
+
}
|
|
11501
|
+
if (!needsRestart) {
|
|
11502
|
+
console.log(`Server is already up to date (version ${installedVersion}).`);
|
|
11503
|
+
process.exit(0);
|
|
11504
|
+
}
|
|
11505
|
+
skipInstall = true;
|
|
11506
|
+
}
|
|
11507
|
+
if (!skipInstall) {
|
|
11508
|
+
console.log(`Server update available: ${installedVersion} → ${latestServerVersion}`);
|
|
11473
11509
|
}
|
|
11474
|
-
|
|
11475
|
-
if (!import_semver2.default.satisfies(latestServerVersion, COMPATIBLE_SERVER_RANGE)) {
|
|
11510
|
+
if (!skipInstall && !import_semver2.default.satisfies(latestServerVersion, COMPATIBLE_SERVER_RANGE)) {
|
|
11476
11511
|
const installedLauncherVersion = resolveInstalledLauncherVersion();
|
|
11477
11512
|
if (installedLauncherVersion && installedLauncherVersion === latestLauncherVersion) {
|
|
11478
11513
|
console.error(`Error: Launcher is already at the latest version (${installedLauncherVersion}) but does not support server version ${latestServerVersion}. A new launcher version is needed before upgrading.`);
|
|
@@ -11480,7 +11515,7 @@ var create6 = () => {
|
|
|
11480
11515
|
}
|
|
11481
11516
|
console.log(`Upgrading launcher to ${latestLauncherVersion}...`);
|
|
11482
11517
|
try {
|
|
11483
|
-
execSync5(`npm install -g @kelceyp/caw@${latestLauncherVersion}`, { stdio: "inherit" });
|
|
11518
|
+
execSync5(`npm install -g @kelceyp/caw@${latestLauncherVersion} --loglevel=error`, { stdio: "inherit" });
|
|
11484
11519
|
} catch {
|
|
11485
11520
|
console.error("Error: Could not upgrade launcher. Run manually: npm install -g @kelceyp/caw@latest");
|
|
11486
11521
|
process.exit(1);
|
|
@@ -11529,16 +11564,18 @@ var create6 = () => {
|
|
|
11529
11564
|
pm.cleanup();
|
|
11530
11565
|
}
|
|
11531
11566
|
}
|
|
11532
|
-
|
|
11533
|
-
|
|
11534
|
-
|
|
11535
|
-
|
|
11536
|
-
|
|
11537
|
-
|
|
11538
|
-
|
|
11539
|
-
|
|
11567
|
+
if (!skipInstall) {
|
|
11568
|
+
console.log(`Installing @kelceyp/caw-server@${latestServerVersion}...`);
|
|
11569
|
+
try {
|
|
11570
|
+
execSync5(`npm install -g @kelceyp/caw-server@${latestServerVersion} --loglevel=error`, { stdio: "inherit" });
|
|
11571
|
+
} catch {
|
|
11572
|
+
if (serverWasStopped) {
|
|
11573
|
+
console.error("Error: npm install failed. Server is stopped. Fix the issue and run 'caw upgrade' again, or start the server with 'caw start'.");
|
|
11574
|
+
} else {
|
|
11575
|
+
console.error("Error: npm install failed. Fix the issue and run 'caw upgrade' again.");
|
|
11576
|
+
}
|
|
11577
|
+
process.exit(1);
|
|
11540
11578
|
}
|
|
11541
|
-
process.exit(1);
|
|
11542
11579
|
}
|
|
11543
11580
|
if (serverWasStopped || fs11.existsSync(envDir) && configExists4(envDir)) {
|
|
11544
11581
|
const config = readConfigWithDefaults(envDir);
|
|
@@ -11560,7 +11597,11 @@ var create6 = () => {
|
|
|
11560
11597
|
process.exit(1);
|
|
11561
11598
|
}
|
|
11562
11599
|
}
|
|
11563
|
-
|
|
11600
|
+
if (skipInstall) {
|
|
11601
|
+
console.log(`Server restarted with version ${installedVersion}.`);
|
|
11602
|
+
} else {
|
|
11603
|
+
console.log(`Server upgraded from ${installedVersion} to ${latestServerVersion}.`);
|
|
11604
|
+
}
|
|
11564
11605
|
}).onError({ exitCode: 1 }).build();
|
|
11565
11606
|
};
|
|
11566
11607
|
var upgrade_default = Object.freeze({ create: create6 });
|
|
@@ -11577,6 +11618,6 @@ if (!globalCheck.ok) {
|
|
|
11577
11618
|
console.error(globalCheck.message);
|
|
11578
11619
|
process.exit(1);
|
|
11579
11620
|
}
|
|
11580
|
-
var LAUNCHER_VERSION = "1.0.
|
|
11621
|
+
var LAUNCHER_VERSION = "1.0.7";
|
|
11581
11622
|
var app = create().name("caw").version(LAUNCHER_VERSION).command(start_default.create()).command(stop_default.create()).command(status_default.create()).command(logs_default.create()).command(upgrade_default.create());
|
|
11582
11623
|
await app.run(process.argv.slice(2));
|
package/package.json
CHANGED
package/scripts/postinstall.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { execSync } from 'node:child_process';
|
|
2
2
|
|
|
3
3
|
try {
|
|
4
|
-
execSync('npm install -g @kelceyp/caw-server@^1', { stdio: 'inherit' });
|
|
4
|
+
execSync('npm install -g @kelceyp/caw-server@^1 --loglevel=error', { stdio: 'inherit' });
|
|
5
5
|
} catch {
|
|
6
6
|
console.warn('Could not install @kelceyp/caw-server automatically.');
|
|
7
7
|
console.warn('Run "caw start" to retry installation.');
|