@kvbox/cli 0.5.40 → 0.5.42

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/kvbox.js CHANGED
@@ -164,7 +164,7 @@ function versionOf(srcFileUrl, injected) {
164
164
  }
165
165
 
166
166
  // src/version.ts
167
- var VERSION = versionOf(import.meta.url, true ? "0.5.40" : void 0);
167
+ var VERSION = versionOf(import.meta.url, true ? "0.5.42" : void 0);
168
168
 
169
169
  // src/commands/vm/index.ts
170
170
  import { Command as Command37 } from "commander";
@@ -558,7 +558,9 @@ var MachineSchema = z2.object({
558
558
  diskBytes: z2.number().int(),
559
559
  // the box's own writable disk, as the guest sees it
560
560
  diskUsedBytes: z2.number().int(),
561
- // what that sparse file really occupies on the host
561
+ // what the box uses of it: the filesystem's own count, like the guest's `df` (#115)
562
+ /** What the disk's sparse file occupies on the host. Grows while the box runs, `kvbox stop` trims it back. Hosts before 0.5.42 do not send it. */
563
+ diskHostBytes: z2.number().int().optional(),
562
564
  base: z2.string(),
563
565
  // version of the image the box's overlay stacks on
564
566
  /** The image (#87) when it is not the base one: `postgres`. `base` is then that image's version. */
@@ -1579,8 +1581,8 @@ async function checkDirect(ep) {
1579
1581
  }
1580
1582
  var NOT_A_HOST_HINT = "kvbox-server is not installed, so this machine is not a kvbox host. Set it up with install-server.sh, or log in to the cloud with: kvbox login";
1581
1583
  async function lastErrorLine(logPath, from = 0) {
1582
- const { readFile: readFile8 } = await import("fs/promises");
1583
- const text2 = (await readFile8(logPath).catch(() => Buffer.alloc(0))).subarray(from).toString("utf8");
1584
+ const { readFile: readFile9 } = await import("fs/promises");
1585
+ const text2 = (await readFile9(logPath).catch(() => Buffer.alloc(0))).subarray(from).toString("utf8");
1584
1586
  const lines = text2.trimEnd().split("\n").slice(-20).reverse();
1585
1587
  return lines.find((l) => l.startsWith("error: "))?.slice("error: ".length);
1586
1588
  }
@@ -4039,28 +4041,18 @@ function creditRow(b, me2) {
4039
4041
  }
4040
4042
 
4041
4043
  // src/commands/deploy/index.ts
4042
- import { access as access4, readFile as readFile7 } from "fs/promises";
4044
+ import { access as access4, readFile as readFile8 } from "fs/promises";
4043
4045
  import { basename, resolve as resolve2 } from "path";
4044
4046
  import { Command as Command61, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
4045
4047
 
4046
4048
  // src/commands/deploy/config.ts
4047
- import { readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
4048
- import { join as join5 } from "path";
4049
+ import { readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
4050
+ import { join as join6 } from "path";
4049
4051
  import { z as z5 } from "zod";
4050
4052
 
4051
- // src/commands/deploy/templates/pm.ts
4052
- import { access } from "fs/promises";
4053
+ // src/commands/deploy/templates/docker.ts
4054
+ import { readFile as readFile6 } from "fs/promises";
4053
4055
  import { join as join2 } from "path";
4054
- async function packageManager(dir) {
4055
- const has = (f) => access(join2(dir, f)).then(() => true, () => false);
4056
- if (await has("pnpm-lock.yaml")) return "pnpm";
4057
- if (await has("yarn.lock")) return "yarn";
4058
- if (await has("bun.lockb") || await has("bun.lock")) return "bun";
4059
- return "npm";
4060
- }
4061
- function runScript(pm, script) {
4062
- return pm === "yarn" ? [script] : ["run", script];
4063
- }
4064
4056
 
4065
4057
  // src/commands/deploy/templates/server.ts
4066
4058
  var APP_DIR = "/srv/app/current";
@@ -4068,6 +4060,7 @@ var SERVICE = "kvbox-app";
4068
4060
  var START_WAIT_SEC = 30;
4069
4061
  var APP_NOT_LISTENING = 4;
4070
4062
  var LOG_MARKER = "--- kvbox-app log ---";
4063
+ var DROP_CONTAINER = `if systemctl is-active --quiet docker && docker inspect ${SERVICE} >/dev/null 2>&1; then docker rm -f ${SERVICE} >/dev/null 2>&1 || true; docker rmi ${SERVICE} >/dev/null 2>&1 || true; sudo -n systemctl disable --quiet docker 2>/dev/null || true; fi`;
4071
4064
  function commands(pm) {
4072
4065
  switch (pm) {
4073
4066
  case "pnpm":
@@ -4122,6 +4115,8 @@ function serverRemote(opts) {
4122
4115
  `mv /srv/app/.incoming ${APP_DIR}`,
4123
4116
  "sudo -n systemctl daemon-reload",
4124
4117
  `sudo -n systemctl enable --quiet ${SERVICE}`,
4118
+ // A box that switched from the Docker template: its container holds the same box port.
4119
+ DROP_CONTAINER,
4125
4120
  `sudo -n systemctl restart ${SERVICE}`,
4126
4121
  "rm -rf /srv/app/.old",
4127
4122
  // bash's /dev/tcp: no curl or nc in the image needed.
@@ -4134,6 +4129,81 @@ function serverRemote(opts) {
4134
4129
  ].join("\n");
4135
4130
  }
4136
4131
 
4132
+ // src/commands/deploy/templates/docker.ts
4133
+ var CONTAINER = "kvbox-app";
4134
+ var BUILD_LOG_LINES = 60;
4135
+ function exposedPort(dockerfile) {
4136
+ const m = /^\s*EXPOSE\s+(\d+)/im.exec(dockerfile);
4137
+ return m ? Number(m[1]) : void 0;
4138
+ }
4139
+ var dockerTemplate = {
4140
+ id: "docker",
4141
+ label: "Docker",
4142
+ hint: "built from the Dockerfile in the box, run as a container on $PORT (3000)",
4143
+ size: "s",
4144
+ port: 3e3,
4145
+ customPort: true,
4146
+ listens: "The container must listen on the port its Dockerfile EXPOSEs (or on PORT, 3000, without one)",
4147
+ logs: `docker logs ${CONTAINER}`,
4148
+ detect(_pkg, dir) {
4149
+ return dir.dockerfile;
4150
+ },
4151
+ /** No local build: the box does it. The Dockerfile is read for its EXPOSE port only. */
4152
+ async build(ctx) {
4153
+ const dockerfile = await readFile6(join2(ctx.dir, "Dockerfile"), "utf8").catch(() => void 0);
4154
+ if (dockerfile === void 0) throw new KvboxError(`${ctx.dir}: no Dockerfile; the Docker template builds the image from it`);
4155
+ const containerPort = exposedPort(dockerfile);
4156
+ return { outDir: ctx.dir, exclude: ["node_modules", ".git"], pm: "npm", what: "the source", ...containerPort !== void 0 ? { containerPort } : {} };
4157
+ },
4158
+ remote(built, port) {
4159
+ return dockerRemote(port, built.containerPort ?? port);
4160
+ }
4161
+ };
4162
+ function dockerRemote(port, containerPort) {
4163
+ return [
4164
+ "set -eo pipefail",
4165
+ "test -d /srv/app -a -w /srv/app || exit 3",
4166
+ "command -v docker >/dev/null || exit 3",
4167
+ "rm -rf /srv/app/.incoming /srv/app/.old",
4168
+ "mkdir -p /srv/app/.incoming",
4169
+ "tar -xf - -C /srv/app/.incoming",
4170
+ "cd /srv/app/.incoming",
4171
+ // Plain progress, not -q: a failed RUN step then shows its own output (npm's error, say), which
4172
+ // quiet mode drops; the last lines are enough and are what the CLI prints on a failure.
4173
+ `docker build --progress=plain -t ${CONTAINER} . 2>&1 | tail -n ${BUILD_LOG_LINES}`,
4174
+ "cd /",
4175
+ `if [ -e ${APP_DIR} ]; then mv ${APP_DIR} /srv/app/.old; fi`,
4176
+ `mv /srv/app/.incoming ${APP_DIR}`,
4177
+ "rm -rf /srv/app/.old",
4178
+ "sudo -n systemctl enable --quiet docker",
4179
+ // A box that switched from the Next.js or Node template: its service holds the same box port.
4180
+ `sudo -n systemctl disable --now --quiet ${SERVICE} 2>/dev/null || true`,
4181
+ `docker rm -f ${CONTAINER} >/dev/null 2>&1 || true`,
4182
+ `docker run -d --name ${CONTAINER} --restart unless-stopped -p ${port}:${containerPort} -e PORT=${containerPort} ${CONTAINER} >/dev/null`,
4183
+ "docker image prune -f >/dev/null",
4184
+ "i=0",
4185
+ `until ip=$(docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' ${CONTAINER} 2>/dev/null) && [ -n "$ip" ] && timeout 1 bash -c "</dev/tcp/$ip/${containerPort}" 2>/dev/null; do`,
4186
+ " i=$((i+1))",
4187
+ ` if [ "$i" -ge ${START_WAIT_SEC} ] || [ "$(docker inspect -f '{{.State.Running}}' ${CONTAINER} 2>/dev/null)" != true ]; then echo '${LOG_MARKER}'; docker logs --tail 20 ${CONTAINER} 2>&1 || true; exit ${APP_NOT_LISTENING}; fi`,
4188
+ " sleep 1",
4189
+ "done"
4190
+ ].join("\n");
4191
+ }
4192
+
4193
+ // src/commands/deploy/templates/pm.ts
4194
+ import { access } from "fs/promises";
4195
+ import { join as join3 } from "path";
4196
+ async function packageManager(dir) {
4197
+ const has = (f) => access(join3(dir, f)).then(() => true, () => false);
4198
+ if (await has("pnpm-lock.yaml")) return "pnpm";
4199
+ if (await has("yarn.lock")) return "yarn";
4200
+ if (await has("bun.lockb") || await has("bun.lock")) return "bun";
4201
+ return "npm";
4202
+ }
4203
+ function runScript(pm, script) {
4204
+ return pm === "yarn" ? [script] : ["run", script];
4205
+ }
4206
+
4137
4207
  // src/commands/deploy/templates/nextjs.ts
4138
4208
  var nextjsTemplate = {
4139
4209
  id: "nextjs",
@@ -4189,7 +4259,7 @@ var nodeTemplate = {
4189
4259
  // src/commands/deploy/templates/react.ts
4190
4260
  import { spawn as spawn5 } from "child_process";
4191
4261
  import { access as access2 } from "fs/promises";
4192
- import { join as join3 } from "path";
4262
+ import { join as join4 } from "path";
4193
4263
  var OUT_DIRS = ["dist", "build"];
4194
4264
  async function runBuild(dir, pm) {
4195
4265
  const args = runScript(pm, "build");
@@ -4220,8 +4290,8 @@ var reactTemplate = {
4220
4290
  await runBuild(ctx.dir, pm);
4221
4291
  const candidates = ctx.dist !== void 0 ? [ctx.dist] : OUT_DIRS;
4222
4292
  for (const dist of candidates) {
4223
- const outDir = join3(ctx.dir, dist);
4224
- if (await access2(join3(outDir, "index.html")).then(() => true, () => false)) return { outDir, dist, exclude: [], pm, what: `${dist}/` };
4293
+ const outDir = join4(ctx.dir, dist);
4294
+ if (await access2(join4(outDir, "index.html")).then(() => true, () => false)) return { outDir, dist, exclude: [], pm, what: `${dist}/` };
4225
4295
  }
4226
4296
  throw new KvboxError(
4227
4297
  `the build left no ${candidates.join(" or ")}/index.html. The React template ships a directory of static files; set "dist" in kvbox.json to the build output directory, or pick the right template with --template`
@@ -4240,6 +4310,8 @@ function nginxRemote() {
4240
4310
  "if [ -e /srv/app/dist ]; then mv /srv/app/dist /srv/app/.old; fi",
4241
4311
  "mv /srv/app/.incoming /srv/app/dist",
4242
4312
  "rm -rf /srv/app/.old",
4313
+ // A box that switched from the Docker template: its container would keep running (and its RAM) for nothing.
4314
+ DROP_CONTAINER,
4243
4315
  "sudo -n systemctl enable --now --quiet nginx",
4244
4316
  "sudo -n systemctl reload nginx"
4245
4317
  ].join("\n");
@@ -4247,7 +4319,7 @@ function nginxRemote() {
4247
4319
 
4248
4320
  // src/commands/deploy/templates/static.ts
4249
4321
  import { access as access3 } from "fs/promises";
4250
- import { join as join4 } from "path";
4322
+ import { join as join5 } from "path";
4251
4323
  var EXCLUDE = ["node_modules", ".git", "kvbox.json"];
4252
4324
  var staticTemplate = {
4253
4325
  id: "static",
@@ -4261,8 +4333,8 @@ var staticTemplate = {
4261
4333
  },
4262
4334
  async build(ctx) {
4263
4335
  const dist = ctx.dist;
4264
- const outDir = dist !== void 0 ? join4(ctx.dir, dist) : ctx.dir;
4265
- if (!await access3(join4(outDir, "index.html")).then(() => true, () => false)) {
4336
+ const outDir = dist !== void 0 ? join5(ctx.dir, dist) : ctx.dir;
4337
+ if (!await access3(join5(outDir, "index.html")).then(() => true, () => false)) {
4266
4338
  throw new KvboxError(
4267
4339
  `${outDir} has no index.html. The static template ships a directory of files as it is; set "dist" in kvbox.json to the folder that holds the site, or pick another template with --template`
4268
4340
  );
@@ -4274,15 +4346,16 @@ var staticTemplate = {
4274
4346
  };
4275
4347
 
4276
4348
  // src/commands/deploy/templates/index.ts
4277
- var TEMPLATES = [reactTemplate, nextjsTemplate, nodeTemplate, staticTemplate];
4349
+ var TEMPLATES = [dockerTemplate, reactTemplate, nextjsTemplate, nodeTemplate, staticTemplate];
4278
4350
  var TEMPLATE_IDS = TEMPLATES.map((t) => t.id);
4279
4351
  function templateById(id) {
4280
4352
  const t = TEMPLATES.find((x) => x.id === id);
4281
4353
  if (!t) throw new Error(`no template ${id}`);
4282
4354
  return t;
4283
4355
  }
4284
- function detectTemplate(pkg, dir = { indexHtml: false }) {
4285
- return TEMPLATES.find((t) => t.detect(pkg, dir));
4356
+ var NO_FACTS = { indexHtml: false, dockerfile: false };
4357
+ function detectTemplates(pkg, dir = NO_FACTS) {
4358
+ return TEMPLATES.filter((t) => t.detect(pkg, dir));
4286
4359
  }
4287
4360
 
4288
4361
  // src/commands/deploy/config.ts
@@ -4306,10 +4379,10 @@ var DeployConfigSchema = z5.object({
4306
4379
  port: z5.number().int().min(1).max(65535).optional()
4307
4380
  });
4308
4381
  async function readConfig(dir) {
4309
- const path = join5(dir, CONFIG_FILE);
4382
+ const path = join6(dir, CONFIG_FILE);
4310
4383
  let raw;
4311
4384
  try {
4312
- raw = await readFile6(path, "utf8");
4385
+ raw = await readFile7(path, "utf8");
4313
4386
  } catch (err) {
4314
4387
  if (err.code === "ENOENT") return void 0;
4315
4388
  throw err;
@@ -4328,7 +4401,7 @@ async function readConfig(dir) {
4328
4401
  return parsed.data;
4329
4402
  }
4330
4403
  async function writeConfig(dir, config) {
4331
- await writeFile4(join5(dir, CONFIG_FILE), JSON.stringify(config, null, 2) + "\n");
4404
+ await writeFile4(join6(dir, CONFIG_FILE), JSON.stringify(config, null, 2) + "\n");
4332
4405
  }
4333
4406
  function nameFromDir(dirName) {
4334
4407
  const slug = dirName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 12).replace(/-+$/, "");
@@ -4341,7 +4414,7 @@ function subdomainFor(name) {
4341
4414
  // src/commands/deploy/ship.ts
4342
4415
  import { spawn as spawn6 } from "child_process";
4343
4416
  import { readdir, stat as stat2 } from "fs/promises";
4344
- import { join as join6 } from "path";
4417
+ import { join as join7 } from "path";
4345
4418
  var IMAGE_TOO_OLD = 3;
4346
4419
  var SSH_FAILED3 = 255;
4347
4420
  async function measure(dir, exclude = []) {
@@ -4349,7 +4422,7 @@ async function measure(dir, exclude = []) {
4349
4422
  const walk = async (d) => {
4350
4423
  for (const entry of await readdir(d, { withFileTypes: true })) {
4351
4424
  if (exclude.includes(entry.name)) continue;
4352
- const path = join6(d, entry.name);
4425
+ const path = join7(d, entry.name);
4353
4426
  if (entry.isDirectory()) await walk(path);
4354
4427
  else if (entry.isFile()) {
4355
4428
  total.files += 1;
@@ -4392,10 +4465,10 @@ async function ship(ep, dir, remote, exclude = []) {
4392
4465
  var shipping = { ship, measure, waitForSsh };
4393
4466
 
4394
4467
  // src/commands/deploy/index.ts
4395
- var deployCommand = new Command61("deploy").description("put the app in this directory (React, Next.js, a Node server or a static site) on a box with its own HTTPS address; redeploy by running it again").argument("[dir]", "the app's directory (default: the current one)").addOption(new Option5("-t, --template <template>", "what kind of app it is (detected from package.json and the directory when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the port a Next.js app or Node server listens on (default 3000; saved to kvbox.json)", parsePort).option("-y, --yes", "ask nothing: take the defaults for whatever the flags and kvbox.json leave open").option("--json", "print the result as JSON").option("--org <slug>", "deploy into this org's boxes (saved to kvbox.json)").action(async (dirArg, opts, cmd) => {
4468
+ var deployCommand = new Command61("deploy").description("put the app in this directory (React, Next.js, a Node server, a Dockerfile or a static site) on a box with its own HTTPS address; redeploy by running it again").argument("[dir]", "the app's directory (default: the current one)").addOption(new Option5("-t, --template <template>", "what kind of app it is (detected from package.json and the directory when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the box port of a Next.js app, Node server or container (default 3000; saved to kvbox.json)", parsePort).option("-y, --yes", "ask nothing: take the defaults for whatever the flags and kvbox.json leave open").option("--json", "print the result as JSON").option("--org <slug>", "deploy into this org's boxes (saved to kvbox.json)").action(async (dirArg, opts, cmd) => {
4396
4469
  const dir = resolve2(dirArg ?? ".");
4397
4470
  const pkg = await readPackageJson(dir);
4398
- const facts = { indexHtml: await access4(resolve2(dir, "index.html")).then(() => true, () => false) };
4471
+ const facts = { indexHtml: await exists(resolve2(dir, "index.html")), dockerfile: await exists(resolve2(dir, "Dockerfile")) };
4399
4472
  const saved = await readConfig(dir);
4400
4473
  const globals = cmd.optsWithGlobals();
4401
4474
  const orgFlag = orgOption(globals);
@@ -4438,8 +4511,9 @@ ${result.output.trim()}` : ""}`, SSH_FAILED3);
4438
4511
  }
4439
4512
  if (result.status === APP_NOT_LISTENING) {
4440
4513
  const log = result.output.split(LOG_MARKER)[1]?.trim();
4514
+ const where = built.containerPort !== void 0 && built.containerPort !== port ? `the container's port ${built.containerPort} (box port ${port})` : `port ${port}`;
4441
4515
  throw new KvboxError(
4442
- `the app did not answer on port ${port} within ${START_WAIT_SEC} s: it crashed, or listens on another port. It must listen on process.env.PORT (${port})${template.customPort ? ", or say its port with --port" : ""}. Its log: kvbox exec ${ref} -- journalctl -u kvbox-app${log ? `
4516
+ `the app did not answer on ${where} within ${START_WAIT_SEC} s: it crashed, or listens on another port. ${template.listens ?? `It must listen on process.env.PORT (${port})`}${template.customPort ? ", or say its port with --port" : ""}. Its log: kvbox exec ${ref} -- ${template.logs ?? "journalctl -u kvbox-app"}${log ? `
4443
4517
  last lines:
4444
4518
  ${log}` : ""}`
4445
4519
  );
@@ -4473,16 +4547,17 @@ function parsePort(v) {
4473
4547
  if (portProblem(v)) throw new InvalidArgumentError2("expected a port, 1-65535");
4474
4548
  return Number(v);
4475
4549
  }
4550
+ var exists = (path) => access4(path).then(() => true, () => false);
4476
4551
  async function readPackageJson(dir) {
4477
4552
  try {
4478
- return JSON.parse(await readFile7(resolve2(dir, "package.json"), "utf8"));
4553
+ return JSON.parse(await readFile8(resolve2(dir, "package.json"), "utf8"));
4479
4554
  } catch (err) {
4480
4555
  if (err.code === "ENOENT") return void 0;
4481
4556
  throw new KvboxError(`${resolve2(dir, "package.json")}: ${err.message}`);
4482
4557
  }
4483
4558
  }
4484
4559
  async function settle(dir, pkg, facts, saved, opts, orgFlag, cloud) {
4485
- const detected = detectTemplate(pkg, facts);
4560
+ const [detected, ...also] = detectTemplates(pkg, facts);
4486
4561
  if (opts.name !== void 0 && !BOX_NAME_RE.test(opts.name)) throw new KvboxError(`--name ${opts.name}: ${NAME_RULE}`);
4487
4562
  if (opts.sub !== void 0) assertSubdomain(opts.sub);
4488
4563
  const renamed = saved !== void 0 && (opts.name !== void 0 && opts.name !== saved.name || orgFlag !== void 0 && orgFlag !== saved.org);
@@ -4513,10 +4588,13 @@ async function settle(dir, pkg, facts, saved, opts, orgFlag, cloud) {
4513
4588
  `);
4514
4589
  let templateId = defaults.template;
4515
4590
  if (open.template && ask) {
4516
- const initial = detected ? TEMPLATES.indexOf(detected) : 0;
4517
- templateId = await select("Template", TEMPLATES.map((t) => ({ value: t.id, label: t.label, hint: t === detected ? `${t.hint} \xB7 detected` : t.hint })), initial);
4591
+ const initial = TEMPLATES.indexOf(detected ?? templateById("react"));
4592
+ templateId = await select("Template", TEMPLATES.map((t) => ({ value: t.id, label: t.label, hint: t === detected ? `${t.hint} \xB7 detected${also.length ? `, also ${also.map((a) => a.label).join(", ")}` : ""}` : t.hint })), initial);
4593
+ }
4594
+ if (open.template && !ask && detected !== void 0 && also.length > 0 && templateId === detected.id) {
4595
+ info(` ${detected.label} detected: deploying with it. The app is also ${also.map((a) => `${a.label} (--template ${a.id})`).join(", ")}; say so to use that instead.`);
4518
4596
  }
4519
- if (templateId === void 0) throw new KvboxError(`could not tell what kind of app ${dir} is (no package.json of a Vite, Create React App or Next.js project, or of a server on Express, Fastify, Koa, Hono or NestJS, and no index.html): say it with --template ${TEMPLATE_IDS.join("|")}`);
4597
+ if (templateId === void 0) throw new KvboxError(`could not tell what kind of app ${dir} is (no Dockerfile, no package.json of a Vite, Create React App or Next.js project, or of a server on Express, Fastify, Koa, Hono or NestJS, and no index.html): say it with --template ${TEMPLATE_IDS.join("|")}`);
4520
4598
  const template = templateById(templateId);
4521
4599
  let name = defaults.name;
4522
4600
  if (open.name && ask) name = await text("Box name", { default: defaults.name, validate: (a) => BOX_NAME_RE.test(a) ? void 0 : NAME_RULE });
@@ -5020,7 +5098,7 @@ for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in thi
5020
5098
  import { spawn as spawn7 } from "child_process";
5021
5099
  import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
5022
5100
  import { tmpdir } from "os";
5023
- import { join as join7 } from "path";
5101
+ import { join as join8 } from "path";
5024
5102
  import { Command as Command76 } from "commander";
5025
5103
 
5026
5104
  // src/update.ts
@@ -5148,8 +5226,8 @@ var selfUpdateCommand = new Command76("update").description("update kvbox to the
5148
5226
  code = await run(inst.cmd, inst.args);
5149
5227
  } else {
5150
5228
  const script = await download(inst.url);
5151
- const dir = mkdtempSync(join7(tmpdir(), "kvbox-update-"));
5152
- const file = join7(dir, "install.sh");
5229
+ const dir = mkdtempSync(join8(tmpdir(), "kvbox-update-"));
5230
+ const file = join8(dir, "install.sh");
5153
5231
  try {
5154
5232
  writeFileSync2(file, script, { mode: 448 });
5155
5233
  code = await run(inst.cmd, inst.args.map((a) => a === "{script}" ? file : a));