@kvbox/cli 0.5.40 → 0.5.41

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.41" : void 0);
168
168
 
169
169
  // src/commands/vm/index.ts
170
170
  import { Command as Command37 } from "commander";
@@ -1579,8 +1579,8 @@ async function checkDirect(ep) {
1579
1579
  }
1580
1580
  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
1581
  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");
1582
+ const { readFile: readFile9 } = await import("fs/promises");
1583
+ const text2 = (await readFile9(logPath).catch(() => Buffer.alloc(0))).subarray(from).toString("utf8");
1584
1584
  const lines = text2.trimEnd().split("\n").slice(-20).reverse();
1585
1585
  return lines.find((l) => l.startsWith("error: "))?.slice("error: ".length);
1586
1586
  }
@@ -4039,28 +4039,18 @@ function creditRow(b, me2) {
4039
4039
  }
4040
4040
 
4041
4041
  // src/commands/deploy/index.ts
4042
- import { access as access4, readFile as readFile7 } from "fs/promises";
4042
+ import { access as access4, readFile as readFile8 } from "fs/promises";
4043
4043
  import { basename, resolve as resolve2 } from "path";
4044
4044
  import { Command as Command61, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
4045
4045
 
4046
4046
  // src/commands/deploy/config.ts
4047
- import { readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
4048
- import { join as join5 } from "path";
4047
+ import { readFile as readFile7, writeFile as writeFile4 } from "fs/promises";
4048
+ import { join as join6 } from "path";
4049
4049
  import { z as z5 } from "zod";
4050
4050
 
4051
- // src/commands/deploy/templates/pm.ts
4052
- import { access } from "fs/promises";
4051
+ // src/commands/deploy/templates/docker.ts
4052
+ import { readFile as readFile6 } from "fs/promises";
4053
4053
  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
4054
 
4065
4055
  // src/commands/deploy/templates/server.ts
4066
4056
  var APP_DIR = "/srv/app/current";
@@ -4068,6 +4058,7 @@ var SERVICE = "kvbox-app";
4068
4058
  var START_WAIT_SEC = 30;
4069
4059
  var APP_NOT_LISTENING = 4;
4070
4060
  var LOG_MARKER = "--- kvbox-app log ---";
4061
+ 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
4062
  function commands(pm) {
4072
4063
  switch (pm) {
4073
4064
  case "pnpm":
@@ -4122,6 +4113,8 @@ function serverRemote(opts) {
4122
4113
  `mv /srv/app/.incoming ${APP_DIR}`,
4123
4114
  "sudo -n systemctl daemon-reload",
4124
4115
  `sudo -n systemctl enable --quiet ${SERVICE}`,
4116
+ // A box that switched from the Docker template: its container holds the same box port.
4117
+ DROP_CONTAINER,
4125
4118
  `sudo -n systemctl restart ${SERVICE}`,
4126
4119
  "rm -rf /srv/app/.old",
4127
4120
  // bash's /dev/tcp: no curl or nc in the image needed.
@@ -4134,6 +4127,81 @@ function serverRemote(opts) {
4134
4127
  ].join("\n");
4135
4128
  }
4136
4129
 
4130
+ // src/commands/deploy/templates/docker.ts
4131
+ var CONTAINER = "kvbox-app";
4132
+ var BUILD_LOG_LINES = 60;
4133
+ function exposedPort(dockerfile) {
4134
+ const m = /^\s*EXPOSE\s+(\d+)/im.exec(dockerfile);
4135
+ return m ? Number(m[1]) : void 0;
4136
+ }
4137
+ var dockerTemplate = {
4138
+ id: "docker",
4139
+ label: "Docker",
4140
+ hint: "built from the Dockerfile in the box, run as a container on $PORT (3000)",
4141
+ size: "s",
4142
+ port: 3e3,
4143
+ customPort: true,
4144
+ listens: "The container must listen on the port its Dockerfile EXPOSEs (or on PORT, 3000, without one)",
4145
+ logs: `docker logs ${CONTAINER}`,
4146
+ detect(_pkg, dir) {
4147
+ return dir.dockerfile;
4148
+ },
4149
+ /** No local build: the box does it. The Dockerfile is read for its EXPOSE port only. */
4150
+ async build(ctx) {
4151
+ const dockerfile = await readFile6(join2(ctx.dir, "Dockerfile"), "utf8").catch(() => void 0);
4152
+ if (dockerfile === void 0) throw new KvboxError(`${ctx.dir}: no Dockerfile; the Docker template builds the image from it`);
4153
+ const containerPort = exposedPort(dockerfile);
4154
+ return { outDir: ctx.dir, exclude: ["node_modules", ".git"], pm: "npm", what: "the source", ...containerPort !== void 0 ? { containerPort } : {} };
4155
+ },
4156
+ remote(built, port) {
4157
+ return dockerRemote(port, built.containerPort ?? port);
4158
+ }
4159
+ };
4160
+ function dockerRemote(port, containerPort) {
4161
+ return [
4162
+ "set -eo pipefail",
4163
+ "test -d /srv/app -a -w /srv/app || exit 3",
4164
+ "command -v docker >/dev/null || exit 3",
4165
+ "rm -rf /srv/app/.incoming /srv/app/.old",
4166
+ "mkdir -p /srv/app/.incoming",
4167
+ "tar -xf - -C /srv/app/.incoming",
4168
+ "cd /srv/app/.incoming",
4169
+ // Plain progress, not -q: a failed RUN step then shows its own output (npm's error, say), which
4170
+ // quiet mode drops; the last lines are enough and are what the CLI prints on a failure.
4171
+ `docker build --progress=plain -t ${CONTAINER} . 2>&1 | tail -n ${BUILD_LOG_LINES}`,
4172
+ "cd /",
4173
+ `if [ -e ${APP_DIR} ]; then mv ${APP_DIR} /srv/app/.old; fi`,
4174
+ `mv /srv/app/.incoming ${APP_DIR}`,
4175
+ "rm -rf /srv/app/.old",
4176
+ "sudo -n systemctl enable --quiet docker",
4177
+ // A box that switched from the Next.js or Node template: its service holds the same box port.
4178
+ `sudo -n systemctl disable --now --quiet ${SERVICE} 2>/dev/null || true`,
4179
+ `docker rm -f ${CONTAINER} >/dev/null 2>&1 || true`,
4180
+ `docker run -d --name ${CONTAINER} --restart unless-stopped -p ${port}:${containerPort} -e PORT=${containerPort} ${CONTAINER} >/dev/null`,
4181
+ "docker image prune -f >/dev/null",
4182
+ "i=0",
4183
+ `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`,
4184
+ " i=$((i+1))",
4185
+ ` 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`,
4186
+ " sleep 1",
4187
+ "done"
4188
+ ].join("\n");
4189
+ }
4190
+
4191
+ // src/commands/deploy/templates/pm.ts
4192
+ import { access } from "fs/promises";
4193
+ import { join as join3 } from "path";
4194
+ async function packageManager(dir) {
4195
+ const has = (f) => access(join3(dir, f)).then(() => true, () => false);
4196
+ if (await has("pnpm-lock.yaml")) return "pnpm";
4197
+ if (await has("yarn.lock")) return "yarn";
4198
+ if (await has("bun.lockb") || await has("bun.lock")) return "bun";
4199
+ return "npm";
4200
+ }
4201
+ function runScript(pm, script) {
4202
+ return pm === "yarn" ? [script] : ["run", script];
4203
+ }
4204
+
4137
4205
  // src/commands/deploy/templates/nextjs.ts
4138
4206
  var nextjsTemplate = {
4139
4207
  id: "nextjs",
@@ -4189,7 +4257,7 @@ var nodeTemplate = {
4189
4257
  // src/commands/deploy/templates/react.ts
4190
4258
  import { spawn as spawn5 } from "child_process";
4191
4259
  import { access as access2 } from "fs/promises";
4192
- import { join as join3 } from "path";
4260
+ import { join as join4 } from "path";
4193
4261
  var OUT_DIRS = ["dist", "build"];
4194
4262
  async function runBuild(dir, pm) {
4195
4263
  const args = runScript(pm, "build");
@@ -4220,8 +4288,8 @@ var reactTemplate = {
4220
4288
  await runBuild(ctx.dir, pm);
4221
4289
  const candidates = ctx.dist !== void 0 ? [ctx.dist] : OUT_DIRS;
4222
4290
  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}/` };
4291
+ const outDir = join4(ctx.dir, dist);
4292
+ if (await access2(join4(outDir, "index.html")).then(() => true, () => false)) return { outDir, dist, exclude: [], pm, what: `${dist}/` };
4225
4293
  }
4226
4294
  throw new KvboxError(
4227
4295
  `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 +4308,8 @@ function nginxRemote() {
4240
4308
  "if [ -e /srv/app/dist ]; then mv /srv/app/dist /srv/app/.old; fi",
4241
4309
  "mv /srv/app/.incoming /srv/app/dist",
4242
4310
  "rm -rf /srv/app/.old",
4311
+ // A box that switched from the Docker template: its container would keep running (and its RAM) for nothing.
4312
+ DROP_CONTAINER,
4243
4313
  "sudo -n systemctl enable --now --quiet nginx",
4244
4314
  "sudo -n systemctl reload nginx"
4245
4315
  ].join("\n");
@@ -4247,7 +4317,7 @@ function nginxRemote() {
4247
4317
 
4248
4318
  // src/commands/deploy/templates/static.ts
4249
4319
  import { access as access3 } from "fs/promises";
4250
- import { join as join4 } from "path";
4320
+ import { join as join5 } from "path";
4251
4321
  var EXCLUDE = ["node_modules", ".git", "kvbox.json"];
4252
4322
  var staticTemplate = {
4253
4323
  id: "static",
@@ -4261,8 +4331,8 @@ var staticTemplate = {
4261
4331
  },
4262
4332
  async build(ctx) {
4263
4333
  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)) {
4334
+ const outDir = dist !== void 0 ? join5(ctx.dir, dist) : ctx.dir;
4335
+ if (!await access3(join5(outDir, "index.html")).then(() => true, () => false)) {
4266
4336
  throw new KvboxError(
4267
4337
  `${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
4338
  );
@@ -4274,15 +4344,16 @@ var staticTemplate = {
4274
4344
  };
4275
4345
 
4276
4346
  // src/commands/deploy/templates/index.ts
4277
- var TEMPLATES = [reactTemplate, nextjsTemplate, nodeTemplate, staticTemplate];
4347
+ var TEMPLATES = [dockerTemplate, reactTemplate, nextjsTemplate, nodeTemplate, staticTemplate];
4278
4348
  var TEMPLATE_IDS = TEMPLATES.map((t) => t.id);
4279
4349
  function templateById(id) {
4280
4350
  const t = TEMPLATES.find((x) => x.id === id);
4281
4351
  if (!t) throw new Error(`no template ${id}`);
4282
4352
  return t;
4283
4353
  }
4284
- function detectTemplate(pkg, dir = { indexHtml: false }) {
4285
- return TEMPLATES.find((t) => t.detect(pkg, dir));
4354
+ var NO_FACTS = { indexHtml: false, dockerfile: false };
4355
+ function detectTemplates(pkg, dir = NO_FACTS) {
4356
+ return TEMPLATES.filter((t) => t.detect(pkg, dir));
4286
4357
  }
4287
4358
 
4288
4359
  // src/commands/deploy/config.ts
@@ -4306,10 +4377,10 @@ var DeployConfigSchema = z5.object({
4306
4377
  port: z5.number().int().min(1).max(65535).optional()
4307
4378
  });
4308
4379
  async function readConfig(dir) {
4309
- const path = join5(dir, CONFIG_FILE);
4380
+ const path = join6(dir, CONFIG_FILE);
4310
4381
  let raw;
4311
4382
  try {
4312
- raw = await readFile6(path, "utf8");
4383
+ raw = await readFile7(path, "utf8");
4313
4384
  } catch (err) {
4314
4385
  if (err.code === "ENOENT") return void 0;
4315
4386
  throw err;
@@ -4328,7 +4399,7 @@ async function readConfig(dir) {
4328
4399
  return parsed.data;
4329
4400
  }
4330
4401
  async function writeConfig(dir, config) {
4331
- await writeFile4(join5(dir, CONFIG_FILE), JSON.stringify(config, null, 2) + "\n");
4402
+ await writeFile4(join6(dir, CONFIG_FILE), JSON.stringify(config, null, 2) + "\n");
4332
4403
  }
4333
4404
  function nameFromDir(dirName) {
4334
4405
  const slug = dirName.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 12).replace(/-+$/, "");
@@ -4341,7 +4412,7 @@ function subdomainFor(name) {
4341
4412
  // src/commands/deploy/ship.ts
4342
4413
  import { spawn as spawn6 } from "child_process";
4343
4414
  import { readdir, stat as stat2 } from "fs/promises";
4344
- import { join as join6 } from "path";
4415
+ import { join as join7 } from "path";
4345
4416
  var IMAGE_TOO_OLD = 3;
4346
4417
  var SSH_FAILED3 = 255;
4347
4418
  async function measure(dir, exclude = []) {
@@ -4349,7 +4420,7 @@ async function measure(dir, exclude = []) {
4349
4420
  const walk = async (d) => {
4350
4421
  for (const entry of await readdir(d, { withFileTypes: true })) {
4351
4422
  if (exclude.includes(entry.name)) continue;
4352
- const path = join6(d, entry.name);
4423
+ const path = join7(d, entry.name);
4353
4424
  if (entry.isDirectory()) await walk(path);
4354
4425
  else if (entry.isFile()) {
4355
4426
  total.files += 1;
@@ -4392,10 +4463,10 @@ async function ship(ep, dir, remote, exclude = []) {
4392
4463
  var shipping = { ship, measure, waitForSsh };
4393
4464
 
4394
4465
  // 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) => {
4466
+ 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
4467
  const dir = resolve2(dirArg ?? ".");
4397
4468
  const pkg = await readPackageJson(dir);
4398
- const facts = { indexHtml: await access4(resolve2(dir, "index.html")).then(() => true, () => false) };
4469
+ const facts = { indexHtml: await exists(resolve2(dir, "index.html")), dockerfile: await exists(resolve2(dir, "Dockerfile")) };
4399
4470
  const saved = await readConfig(dir);
4400
4471
  const globals = cmd.optsWithGlobals();
4401
4472
  const orgFlag = orgOption(globals);
@@ -4438,8 +4509,9 @@ ${result.output.trim()}` : ""}`, SSH_FAILED3);
4438
4509
  }
4439
4510
  if (result.status === APP_NOT_LISTENING) {
4440
4511
  const log = result.output.split(LOG_MARKER)[1]?.trim();
4512
+ const where = built.containerPort !== void 0 && built.containerPort !== port ? `the container's port ${built.containerPort} (box port ${port})` : `port ${port}`;
4441
4513
  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 ? `
4514
+ `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
4515
  last lines:
4444
4516
  ${log}` : ""}`
4445
4517
  );
@@ -4473,16 +4545,17 @@ function parsePort(v) {
4473
4545
  if (portProblem(v)) throw new InvalidArgumentError2("expected a port, 1-65535");
4474
4546
  return Number(v);
4475
4547
  }
4548
+ var exists = (path) => access4(path).then(() => true, () => false);
4476
4549
  async function readPackageJson(dir) {
4477
4550
  try {
4478
- return JSON.parse(await readFile7(resolve2(dir, "package.json"), "utf8"));
4551
+ return JSON.parse(await readFile8(resolve2(dir, "package.json"), "utf8"));
4479
4552
  } catch (err) {
4480
4553
  if (err.code === "ENOENT") return void 0;
4481
4554
  throw new KvboxError(`${resolve2(dir, "package.json")}: ${err.message}`);
4482
4555
  }
4483
4556
  }
4484
4557
  async function settle(dir, pkg, facts, saved, opts, orgFlag, cloud) {
4485
- const detected = detectTemplate(pkg, facts);
4558
+ const [detected, ...also] = detectTemplates(pkg, facts);
4486
4559
  if (opts.name !== void 0 && !BOX_NAME_RE.test(opts.name)) throw new KvboxError(`--name ${opts.name}: ${NAME_RULE}`);
4487
4560
  if (opts.sub !== void 0) assertSubdomain(opts.sub);
4488
4561
  const renamed = saved !== void 0 && (opts.name !== void 0 && opts.name !== saved.name || orgFlag !== void 0 && orgFlag !== saved.org);
@@ -4513,10 +4586,13 @@ async function settle(dir, pkg, facts, saved, opts, orgFlag, cloud) {
4513
4586
  `);
4514
4587
  let templateId = defaults.template;
4515
4588
  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);
4589
+ const initial = TEMPLATES.indexOf(detected ?? templateById("react"));
4590
+ 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);
4591
+ }
4592
+ if (open.template && !ask && detected !== void 0 && also.length > 0 && templateId === detected.id) {
4593
+ 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
4594
  }
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("|")}`);
4595
+ 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
4596
  const template = templateById(templateId);
4521
4597
  let name = defaults.name;
4522
4598
  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 +5096,7 @@ for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in thi
5020
5096
  import { spawn as spawn7 } from "child_process";
5021
5097
  import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
5022
5098
  import { tmpdir } from "os";
5023
- import { join as join7 } from "path";
5099
+ import { join as join8 } from "path";
5024
5100
  import { Command as Command76 } from "commander";
5025
5101
 
5026
5102
  // src/update.ts
@@ -5148,8 +5224,8 @@ var selfUpdateCommand = new Command76("update").description("update kvbox to the
5148
5224
  code = await run(inst.cmd, inst.args);
5149
5225
  } else {
5150
5226
  const script = await download(inst.url);
5151
- const dir = mkdtempSync(join7(tmpdir(), "kvbox-update-"));
5152
- const file = join7(dir, "install.sh");
5227
+ const dir = mkdtempSync(join8(tmpdir(), "kvbox-update-"));
5228
+ const file = join8(dir, "install.sh");
5153
5229
  try {
5154
5230
  writeFileSync2(file, script, { mode: 448 });
5155
5231
  code = await run(inst.cmd, inst.args.map((a) => a === "{script}" ? file : a));