@arkhera30/cli 0.1.1 → 0.1.2
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 +46 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import chalk10 from "chalk";
|
|
|
8
8
|
import { Command } from "commander";
|
|
9
9
|
import chalk from "chalk";
|
|
10
10
|
import ora from "ora";
|
|
11
|
-
import { input, confirm, number } from "@inquirer/prompts";
|
|
11
|
+
import { input, confirm, number, select } from "@inquirer/prompts";
|
|
12
12
|
|
|
13
13
|
// src/lib/config.ts
|
|
14
14
|
import { readFileSync, writeFileSync, mkdirSync, existsSync } from "fs";
|
|
@@ -261,6 +261,9 @@ function createRuntime(name) {
|
|
|
261
261
|
}
|
|
262
262
|
};
|
|
263
263
|
}
|
|
264
|
+
async function checkRuntime(name) {
|
|
265
|
+
return tryCommand(name, ["compose", "version"]);
|
|
266
|
+
}
|
|
264
267
|
async function detectRuntime(preferred) {
|
|
265
268
|
if (preferred) {
|
|
266
269
|
const hasPreferred = await tryCommand(preferred, ["compose", "version"]);
|
|
@@ -384,7 +387,7 @@ function installComposeFile() {
|
|
|
384
387
|
}
|
|
385
388
|
|
|
386
389
|
// src/commands/setup.ts
|
|
387
|
-
var setupCommand = new Command("setup").description("Interactive first-run setup for Horus").option("-y, --yes", "Non-interactive mode (use defaults + env vars)").option("--data-dir <path>", "Data directory path").option("--repos-path <path>", "Host repos path for Forge scanning").action(async (opts) => {
|
|
390
|
+
var setupCommand = new Command("setup").description("Interactive first-run setup for Horus").option("-y, --yes", "Non-interactive mode (use defaults + env vars)").option("--runtime <runtime>", "Container runtime to use: docker or podman (non-interactive only)").option("--data-dir <path>", "Data directory path").option("--repos-path <path>", "Host repos path for Forge scanning").action(async (opts) => {
|
|
388
391
|
console.log("");
|
|
389
392
|
console.log(chalk.bold("Horus Setup"));
|
|
390
393
|
console.log(chalk.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
@@ -403,17 +406,46 @@ var setupCommand = new Command("setup").description("Interactive first-run setup
|
|
|
403
406
|
}
|
|
404
407
|
}
|
|
405
408
|
}
|
|
406
|
-
const
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
409
|
+
const checkSpinner = ora("Checking for container runtimes...").start();
|
|
410
|
+
const [hasDocker, hasPodman] = await Promise.all([
|
|
411
|
+
checkRuntime("docker"),
|
|
412
|
+
checkRuntime("podman")
|
|
413
|
+
]);
|
|
414
|
+
checkSpinner.stop();
|
|
415
|
+
const available = [
|
|
416
|
+
...hasDocker ? ["docker"] : [],
|
|
417
|
+
...hasPodman ? ["podman"] : []
|
|
418
|
+
];
|
|
419
|
+
if (available.length === 0) {
|
|
420
|
+
console.log(chalk.red("No container runtime found."));
|
|
413
421
|
console.log("");
|
|
414
|
-
console.log(
|
|
422
|
+
console.log("Horus requires Docker or Podman with the Compose plugin.");
|
|
423
|
+
console.log("");
|
|
424
|
+
console.log("Install one of:");
|
|
425
|
+
console.log(" Docker Desktop: https://www.docker.com/products/docker-desktop/");
|
|
426
|
+
console.log(" Podman Desktop: https://podman-desktop.io/");
|
|
415
427
|
process.exit(1);
|
|
416
428
|
}
|
|
429
|
+
let selectedRuntime;
|
|
430
|
+
if (opts.yes) {
|
|
431
|
+
const requested = opts.runtime;
|
|
432
|
+
if (requested && !available.includes(requested)) {
|
|
433
|
+
console.log(chalk.red(`Requested runtime "${requested}" is not installed.`));
|
|
434
|
+
console.log(chalk.dim(`Available: ${available.join(", ")}`));
|
|
435
|
+
process.exit(1);
|
|
436
|
+
}
|
|
437
|
+
selectedRuntime = requested ?? available[0];
|
|
438
|
+
console.log(`Using ${chalk.cyan(selectedRuntime)}`);
|
|
439
|
+
} else {
|
|
440
|
+
selectedRuntime = await select({
|
|
441
|
+
message: "Which container runtime would you like to use?",
|
|
442
|
+
choices: available.map((r) => ({
|
|
443
|
+
value: r,
|
|
444
|
+
name: r === "docker" ? "Docker" : "Podman"
|
|
445
|
+
}))
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
const runtime = await detectRuntime(selectedRuntime);
|
|
417
449
|
let config;
|
|
418
450
|
if (opts.yes) {
|
|
419
451
|
config = {
|
|
@@ -1013,7 +1045,7 @@ var connectCommand = new Command6("connect").description("Configure Claude/Curso
|
|
|
1013
1045
|
import { Command as Command7 } from "commander";
|
|
1014
1046
|
import chalk7 from "chalk";
|
|
1015
1047
|
import ora6 from "ora";
|
|
1016
|
-
import { select, confirm as confirm3 } from "@inquirer/prompts";
|
|
1048
|
+
import { select as select2, confirm as confirm3 } from "@inquirer/prompts";
|
|
1017
1049
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync4, mkdirSync as mkdirSync3, readdirSync, existsSync as existsSync4 } from "fs";
|
|
1018
1050
|
import { join as join4 } from "path";
|
|
1019
1051
|
import { createHash } from "crypto";
|
|
@@ -1110,7 +1142,7 @@ var updateCommand = new Command7("update").description("Update Horus to the late
|
|
|
1110
1142
|
name: `${snapshot.timestamp} (images: ${Object.keys(snapshot.images).length})`,
|
|
1111
1143
|
value: i
|
|
1112
1144
|
}));
|
|
1113
|
-
const idx = await
|
|
1145
|
+
const idx = await select2({
|
|
1114
1146
|
message: "Select snapshot to restore:",
|
|
1115
1147
|
choices
|
|
1116
1148
|
});
|
|
@@ -1289,7 +1321,7 @@ function colorMessage(status, msg) {
|
|
|
1289
1321
|
return chalk8.red(msg);
|
|
1290
1322
|
}
|
|
1291
1323
|
}
|
|
1292
|
-
async function
|
|
1324
|
+
async function checkRuntime2() {
|
|
1293
1325
|
try {
|
|
1294
1326
|
execSync("docker info", { stdio: "ignore" });
|
|
1295
1327
|
return { status: "pass", label: "Runtime", message: "Docker is running" };
|
|
@@ -1477,7 +1509,7 @@ var doctorCommand = new Command8("doctor").description("Diagnose common Horus is
|
|
|
1477
1509
|
console.log(chalk8.bold("Horus Doctor"));
|
|
1478
1510
|
console.log(chalk8.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
1479
1511
|
const allResults = [];
|
|
1480
|
-
allResults.push(await
|
|
1512
|
+
allResults.push(await checkRuntime2());
|
|
1481
1513
|
allResults.push(await checkCompose());
|
|
1482
1514
|
allResults.push(checkConfig());
|
|
1483
1515
|
allResults.push(checkComposeFile());
|