@lead-routing/cli 0.6.7 → 0.6.9
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 +82 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1342,24 +1342,37 @@ Install URL: ${chalk2.cyan(MANAGED_PACKAGE_INSTALL_URL)}`,
|
|
|
1342
1342
|
log7.step("Step 3/9 Checking local prerequisites");
|
|
1343
1343
|
await checkPrerequisites();
|
|
1344
1344
|
log7.step("Step 4/9 SSH connection");
|
|
1345
|
-
|
|
1345
|
+
let sshCfg = await collectSshConfig({
|
|
1346
1346
|
sshPort: options.sshPort,
|
|
1347
1347
|
sshUser: options.sshUser,
|
|
1348
1348
|
sshKey: options.sshKey,
|
|
1349
1349
|
remoteDir: options.remoteDir
|
|
1350
1350
|
});
|
|
1351
1351
|
if (!dryRun) {
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1352
|
+
let sshConnected = false;
|
|
1353
|
+
while (!sshConnected) {
|
|
1354
|
+
try {
|
|
1355
|
+
await ssh.connect(sshCfg);
|
|
1356
|
+
log7.success(`Connected to ${sshCfg.host}`);
|
|
1357
|
+
sshConnected = true;
|
|
1358
|
+
} catch (err) {
|
|
1359
|
+
log7.error(`SSH connection failed: ${String(err)}`);
|
|
1360
|
+
const retry = await confirm({ message: "Re-enter SSH details and try again?" });
|
|
1361
|
+
if (isCancel3(retry) || !retry) {
|
|
1362
|
+
cancel3("Setup cancelled.");
|
|
1363
|
+
process.exit(0);
|
|
1364
|
+
}
|
|
1365
|
+
sshCfg = await collectSshConfig({
|
|
1366
|
+
sshPort: options.sshPort,
|
|
1367
|
+
sshUser: options.sshUser,
|
|
1368
|
+
sshKey: options.sshKey,
|
|
1369
|
+
remoteDir: options.remoteDir
|
|
1370
|
+
});
|
|
1371
|
+
}
|
|
1359
1372
|
}
|
|
1360
1373
|
}
|
|
1361
1374
|
log7.step("Step 5/9 Configuration");
|
|
1362
|
-
|
|
1375
|
+
let cfg = await collectConfig({
|
|
1363
1376
|
externalDb: options.externalDb,
|
|
1364
1377
|
externalRedis: options.externalRedis
|
|
1365
1378
|
});
|
|
@@ -1391,7 +1404,66 @@ Files created: docker-compose.yml, Caddyfile, .env.web, .env.engine, lead-routin
|
|
|
1391
1404
|
log7.step("Step 8/9 Starting services");
|
|
1392
1405
|
await startServices(ssh, remoteDir);
|
|
1393
1406
|
log7.step("Step 9/9 Verifying health");
|
|
1394
|
-
|
|
1407
|
+
let healthy = false;
|
|
1408
|
+
while (!healthy) {
|
|
1409
|
+
try {
|
|
1410
|
+
await verifyHealth(cfg.appUrl, cfg.engineUrl, ssh, remoteDir);
|
|
1411
|
+
healthy = true;
|
|
1412
|
+
} catch (err) {
|
|
1413
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1414
|
+
log7.error(`Health check failed: ${message}`);
|
|
1415
|
+
const retry = await confirm({ message: "Re-enter URLs and retry?" });
|
|
1416
|
+
if (isCancel3(retry) || !retry) {
|
|
1417
|
+
log7.info(`Run ${chalk2.cyan("lead-routing init --resume")} to retry health checks later.`);
|
|
1418
|
+
process.exit(1);
|
|
1419
|
+
}
|
|
1420
|
+
const newAppUrl = await text3({
|
|
1421
|
+
message: "App URL",
|
|
1422
|
+
initialValue: cfg.appUrl,
|
|
1423
|
+
validate: (v) => {
|
|
1424
|
+
if (!v) return "Required";
|
|
1425
|
+
try {
|
|
1426
|
+
const u = new URL(v);
|
|
1427
|
+
if (u.protocol !== "https:") return "Must be HTTPS";
|
|
1428
|
+
} catch {
|
|
1429
|
+
return "Invalid URL";
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
});
|
|
1433
|
+
if (isCancel3(newAppUrl)) {
|
|
1434
|
+
cancel3("Setup cancelled.");
|
|
1435
|
+
process.exit(0);
|
|
1436
|
+
}
|
|
1437
|
+
const newEngineUrl = await text3({
|
|
1438
|
+
message: "Engine URL",
|
|
1439
|
+
initialValue: cfg.engineUrl,
|
|
1440
|
+
validate: (v) => {
|
|
1441
|
+
if (!v) return "Required";
|
|
1442
|
+
try {
|
|
1443
|
+
const u = new URL(v);
|
|
1444
|
+
if (u.protocol !== "https:") return "Must be HTTPS";
|
|
1445
|
+
} catch {
|
|
1446
|
+
return "Invalid URL";
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
});
|
|
1450
|
+
if (isCancel3(newEngineUrl)) {
|
|
1451
|
+
cancel3("Setup cancelled.");
|
|
1452
|
+
process.exit(0);
|
|
1453
|
+
}
|
|
1454
|
+
cfg.appUrl = newAppUrl.trim().replace(/\/+$/, "");
|
|
1455
|
+
cfg.engineUrl = newEngineUrl.trim().replace(/\/+$/, "");
|
|
1456
|
+
log7.step("Regenerating config files with new URLs...");
|
|
1457
|
+
const { dir: newDir } = generateFiles(cfg, sshCfg, {
|
|
1458
|
+
licenseKey: licenseResult.key,
|
|
1459
|
+
licenseTier: licenseResult.tier
|
|
1460
|
+
});
|
|
1461
|
+
await uploadFiles(ssh, newDir, remoteDir);
|
|
1462
|
+
log7.step("Restarting services with new config...");
|
|
1463
|
+
await startServices(ssh, remoteDir);
|
|
1464
|
+
log7.step("Retrying health check...");
|
|
1465
|
+
}
|
|
1466
|
+
}
|
|
1395
1467
|
try {
|
|
1396
1468
|
const envWebPath = join5(dir, ".env.web");
|
|
1397
1469
|
const envContent = readFileSync4(envWebPath, "utf-8");
|