@atlashub/smartstack-cli 4.67.0 → 4.69.0

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 CHANGED
@@ -112183,12 +112183,14 @@ var logger = {
112183
112183
  error: source_default.red
112184
112184
  };
112185
112185
  const color = colors12[type];
112186
- const maxLen = Math.max(...content.map((l) => l.length));
112186
+ const stripAnsi3 = (s) => s.replace(/\x1B\[[0-9;]*m/g, "");
112187
+ const maxLen = Math.max(...content.map((l) => stripAnsi3(l).length));
112187
112188
  const border = color("\u2500".repeat(maxLen + 4));
112188
112189
  console.log();
112189
112190
  console.log(border);
112190
112191
  content.forEach((line) => {
112191
- console.log(color("\u2502"), line.padEnd(maxLen), color("\u2502"));
112192
+ const pad = maxLen - stripAnsi3(line).length;
112193
+ console.log(color("\u2502"), line + " ".repeat(pad), color("\u2502"));
112192
112194
  });
112193
112195
  console.log(border);
112194
112196
  console.log();
@@ -127661,11 +127663,19 @@ var doctorCommand = new Command("doctor").description("Run diagnostics and check
127661
127663
  });
127662
127664
  } else if (containerEngine && !containerEngine.running) {
127663
127665
  const isPodman = containerEngine.name === "Podman";
127666
+ const wslMissing = isPodman && process.platform === "win32" && (() => {
127667
+ try {
127668
+ return (0, import_child_process8.execSync)("wsl --status", { encoding: "utf-8", timeout: 5e3, stdio: "pipe" }) && false;
127669
+ } catch {
127670
+ return true;
127671
+ }
127672
+ })();
127664
127673
  diagnostics.push({
127665
127674
  name: "Container Engine",
127666
127675
  status: "warning",
127667
- message: `${containerEngine.name} installed but ${isPodman ? "machine" : "daemon"} not running`,
127668
- fix: isPodman ? "Run: podman machine init && podman machine start" : "Start Docker Desktop, or run: podman machine init && podman machine start"
127676
+ message: wslMissing ? "Podman installed but WSL2 is missing" : `${containerEngine.name} installed but ${isPodman ? "machine" : "daemon"} not running`,
127677
+ fix: wslMissing ? "Run as Admin: wsl --install, restart PC, then: podman machine init && podman machine start" : isPodman ? "Run: podman machine init && podman machine start" : "Start Docker Desktop, or run: podman machine init && podman machine start",
127678
+ installCmd: wslMissing ? process.platform === "win32" ? "wsl --install" : void 0 : void 0
127669
127679
  });
127670
127680
  } else {
127671
127681
  diagnostics.push({
@@ -130196,11 +130206,29 @@ function detectEngine() {
130196
130206
  return podman;
130197
130207
  }
130198
130208
  if (podman.installed && !podman.running) {
130199
- logger.error("Podman is installed but the machine is not running.");
130200
- console.log();
130201
- console.log(` Initialize and start the Podman machine:`);
130202
- console.log(` ${source_default.cyan("podman machine init")} (first time only)`);
130203
- console.log(` ${source_default.cyan("podman machine start")}`);
130209
+ const wslMissing = process.platform === "win32" && (() => {
130210
+ try {
130211
+ const r = (0, import_child_process12.spawnSync)("wsl", ["--status"], { encoding: "utf-8", shell: true, timeout: 5e3, stdio: "pipe" });
130212
+ return r.status !== 0;
130213
+ } catch {
130214
+ return true;
130215
+ }
130216
+ })();
130217
+ if (wslMissing) {
130218
+ logger.error("WSL2 is required by Podman but is not installed.");
130219
+ console.log();
130220
+ console.log(` Install WSL2 first (run as Administrator):`);
130221
+ console.log(` ${source_default.cyan("wsl --install")}`);
130222
+ console.log(` Restart your PC, then:`);
130223
+ console.log(` ${source_default.cyan("podman machine init")}`);
130224
+ console.log(` ${source_default.cyan("podman machine start")}`);
130225
+ } else {
130226
+ logger.error("Podman is installed but the machine is not running.");
130227
+ console.log();
130228
+ console.log(` Initialize and start the Podman machine:`);
130229
+ console.log(` ${source_default.cyan("podman machine init")} (first time only)`);
130230
+ console.log(` ${source_default.cyan("podman machine start")}`);
130231
+ }
130204
130232
  if (docker.installed) {
130205
130233
  console.log();
130206
130234
  console.log(` Or start Docker Desktop instead.`);
@@ -130247,15 +130275,64 @@ function requireComposeFile() {
130247
130275
  }
130248
130276
  return composePath;
130249
130277
  }
130278
+ function getPodmanEnv(engine) {
130279
+ if (engine.name !== "podman") return {};
130280
+ const dockerConfigPath = (0, import_path18.join)(process.env.USERPROFILE || process.env.HOME || "", ".docker", "config.json");
130281
+ try {
130282
+ if (import_fs_extra16.default.existsSync(dockerConfigPath)) {
130283
+ const config = JSON.parse(import_fs_extra16.default.readFileSync(dockerConfigPath, "utf-8"));
130284
+ if (config.credsStore === "desktop" || config.credsStore === "wincred") {
130285
+ const cleanAuthPath = (0, import_path18.join)(process.env.TEMP || "/tmp", "podman-auth.json");
130286
+ if (!import_fs_extra16.default.existsSync(cleanAuthPath)) {
130287
+ import_fs_extra16.default.writeFileSync(cleanAuthPath, "{}", "utf-8");
130288
+ }
130289
+ return { REGISTRY_AUTH_FILE: cleanAuthPath };
130290
+ }
130291
+ }
130292
+ } catch {
130293
+ }
130294
+ return {};
130295
+ }
130250
130296
  function runCompose(engine, composePath, args) {
130297
+ const extraEnv = getPodmanEnv(engine);
130298
+ if (Object.keys(extraEnv).length > 0) {
130299
+ logger.info("Bypassing Docker Desktop credential store for Podman");
130300
+ }
130251
130301
  const result = (0, import_child_process12.spawnSync)(engine.cmd, ["compose", "-f", composePath, ...args], {
130252
130302
  encoding: "utf-8",
130253
130303
  shell: true,
130254
- stdio: "inherit",
130255
- cwd: process.cwd()
130304
+ stdio: "pipe",
130305
+ cwd: process.cwd(),
130306
+ env: { ...process.env, ...extraEnv }
130256
130307
  });
130308
+ if (result.stdout) process.stdout.write(result.stdout);
130309
+ if (result.stderr) process.stderr.write(result.stderr);
130310
+ if (result.status !== 0) {
130311
+ const output = (result.stdout || "") + (result.stderr || "");
130312
+ diagnoseError(engine, output);
130313
+ }
130257
130314
  return result.status ?? 1;
130258
130315
  }
130316
+ function diagnoseError(engine, output) {
130317
+ if (/no space left|disk full/i.test(output)) {
130318
+ console.log();
130319
+ logger.warning("Disk space error detected.");
130320
+ console.log(` Free up space with: ${source_default.cyan(`${engine.name} system prune -a`)}`);
130321
+ console.log();
130322
+ }
130323
+ if (/could not resolve|network.*unreachable|timeout.*connect/i.test(output)) {
130324
+ console.log();
130325
+ logger.warning("Network error detected. Check your internet connection.");
130326
+ console.log();
130327
+ }
130328
+ if (/unable to connect to Podman socket|podman machine init/i.test(output)) {
130329
+ console.log();
130330
+ logger.warning("Podman machine is not running.");
130331
+ console.log(` ${source_default.cyan("podman machine init")} (first time only)`);
130332
+ console.log(` ${source_default.cyan("podman machine start")}`);
130333
+ console.log();
130334
+ }
130335
+ }
130259
130336
  var dockerCommand = new Command("docker").description("Build and run SmartStack Docker images (Docker or Podman)").addCommand(
130260
130337
  new Command("up").description("Build images and start containers").option("-d, --detach", "Run containers in the background").option("--no-build", "Skip image build, use existing images").action(async (options) => {
130261
130338
  const engine = requireEngine();