@kvbox/cli 0.6.16 → 0.6.17
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 +402 -269
- package/dist/kvbox.js.map +1 -1
- package/package.json +1 -1
package/dist/kvbox.js
CHANGED
|
@@ -155,7 +155,7 @@ async function spin(message, work, opts = {}) {
|
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
// src/program.ts
|
|
158
|
-
import { Command as
|
|
158
|
+
import { Command as Command138 } from "commander";
|
|
159
159
|
|
|
160
160
|
// ../shared/src/version.ts
|
|
161
161
|
import { createRequire } from "module";
|
|
@@ -170,10 +170,10 @@ function versionOf(srcFileUrl, injected) {
|
|
|
170
170
|
}
|
|
171
171
|
|
|
172
172
|
// src/version.ts
|
|
173
|
-
var VERSION = versionOf(import.meta.url, true ? "0.6.
|
|
173
|
+
var VERSION = versionOf(import.meta.url, true ? "0.6.17" : void 0);
|
|
174
174
|
|
|
175
175
|
// src/commands/vm/index.ts
|
|
176
|
-
import { Command as
|
|
176
|
+
import { Command as Command42 } from "commander";
|
|
177
177
|
|
|
178
178
|
// src/commands/vm/connect.ts
|
|
179
179
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
@@ -493,7 +493,25 @@ var PortsRequest = z2.object({
|
|
|
493
493
|
});
|
|
494
494
|
var BoxPortSchema = z2.number().int().min(1).max(65535);
|
|
495
495
|
var BoxLinkSchema = z2.object({ from: z2.string(), port: BoxPortSchema });
|
|
496
|
-
var LinkRequest = z2.object({
|
|
496
|
+
var LinkRequest = z2.object({
|
|
497
|
+
from: z2.string().min(1),
|
|
498
|
+
fromOwner: z2.string().optional(),
|
|
499
|
+
port: BoxPortSchema,
|
|
500
|
+
/**
|
|
501
|
+
* The box `from` is on another host (#207, a control plane's call only): no rule opens here. Its host
|
|
502
|
+
* connects to this host's HTTPS listener (`BOX_LINK_PATH_RE`) with `key`, which this link alone answers to.
|
|
503
|
+
*/
|
|
504
|
+
far: z2.object({ key: z2.string().min(32) }).optional()
|
|
505
|
+
});
|
|
506
|
+
var FarLinkRequest = z2.object({
|
|
507
|
+
to: z2.string().min(1),
|
|
508
|
+
toOwner: z2.string().optional(),
|
|
509
|
+
port: BoxPortSchema,
|
|
510
|
+
url: z2.string().url(),
|
|
511
|
+
pin: z2.string().min(1),
|
|
512
|
+
key: z2.string().min(32)
|
|
513
|
+
});
|
|
514
|
+
var FarUnlinkRequest = FarLinkRequest.pick({ to: true, toOwner: true, port: true });
|
|
497
515
|
var ClaimSubdomainRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
|
|
498
516
|
var SubdomainPortRequest = z2.object({ port: BoxPortSchema });
|
|
499
517
|
var SubdomainRouteRequest = z2.object({ name: z2.string(), port: BoxPortSchema });
|
|
@@ -559,7 +577,10 @@ var BackupSchema = z2.object({
|
|
|
559
577
|
dataBytes: z2.number().int().nullable(),
|
|
560
578
|
/** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
|
|
561
579
|
uploadedBytes: z2.number().int().nullable(),
|
|
580
|
+
/** Who asked for it; for a scheduled one, whoever made the thing it is of. */
|
|
562
581
|
createdBy: z2.string().nullable(),
|
|
582
|
+
/** Taken by its nightly schedule (`backup-schedule`) rather than by a person: free, and outside the daily limit. */
|
|
583
|
+
scheduled: z2.boolean().default(false),
|
|
563
584
|
createdAt: z2.string(),
|
|
564
585
|
finishedAt: z2.string().nullable()
|
|
565
586
|
});
|
|
@@ -609,7 +630,10 @@ var VolumeBackupSchema = z2.object({
|
|
|
609
630
|
dataBytes: z2.number().int().nullable(),
|
|
610
631
|
/** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
|
|
611
632
|
uploadedBytes: z2.number().int().nullable(),
|
|
633
|
+
/** Who asked for it; for a scheduled one, whoever made the thing it is of. */
|
|
612
634
|
createdBy: z2.string().nullable(),
|
|
635
|
+
/** Taken by its nightly schedule (`backup-schedule`) rather than by a person: free, and outside the daily limit. */
|
|
636
|
+
scheduled: z2.boolean().default(false),
|
|
613
637
|
createdAt: z2.string(),
|
|
614
638
|
finishedAt: z2.string().nullable()
|
|
615
639
|
});
|
|
@@ -749,7 +773,7 @@ var MachineSchema = z2.object({
|
|
|
749
773
|
ownerKind: z2.enum(["user", "org"]).optional(),
|
|
750
774
|
/**
|
|
751
775
|
* The name of the host the box runs on. Only the control plane fills it in, on `GET /machines`: a box
|
|
752
|
-
*
|
|
776
|
+
* a volume attaches only to a box on the same host, and a link between two boxes of one host stays on it.
|
|
753
777
|
*/
|
|
754
778
|
host: z2.string().optional(),
|
|
755
779
|
/** The country code of that host (`RO`, `US`), when its admin gave one. Only the control plane fills it in. */
|
|
@@ -1050,6 +1074,8 @@ var CapacitySchema = z2.object({
|
|
|
1050
1074
|
fromBackup: z2.boolean().optional(),
|
|
1051
1075
|
/** True on a kvbox-server that keeps a box's `integrations` (#205); an older one drops the field without a word. */
|
|
1052
1076
|
integrations: z2.boolean().optional(),
|
|
1077
|
+
/** True on a kvbox-server that carries a link to a box on another host (#207); the control plane links across hosts only between two such. */
|
|
1078
|
+
farLinks: z2.boolean().optional(),
|
|
1053
1079
|
/** The integrations this kvbox-server knows (`hostKnowsIntegrations`). Absent with `integrations`: the first one's, `github` alone. */
|
|
1054
1080
|
integrationIds: z2.array(z2.string()).optional()
|
|
1055
1081
|
});
|
|
@@ -1776,6 +1802,15 @@ var TrafficReportSchema = z4.object({
|
|
|
1776
1802
|
totals: z4.object(figures),
|
|
1777
1803
|
points: z4.array(TrafficPointSchema)
|
|
1778
1804
|
});
|
|
1805
|
+
var BoxTrafficSchema = z4.object({ box: z4.string(), owner: z4.string(), ...figures });
|
|
1806
|
+
var TrafficOverviewSchema = z4.object({
|
|
1807
|
+
since: z4.string(),
|
|
1808
|
+
until: z4.string(),
|
|
1809
|
+
stepMin: z4.number().int().positive(),
|
|
1810
|
+
totals: z4.object(figures),
|
|
1811
|
+
points: z4.array(TrafficPointSchema),
|
|
1812
|
+
boxes: z4.array(BoxTrafficSchema)
|
|
1813
|
+
});
|
|
1779
1814
|
|
|
1780
1815
|
// ../sdk/src/errors.ts
|
|
1781
1816
|
var KvboxSdkError = class extends Error {
|
|
@@ -2665,6 +2700,8 @@ var StorageBackupSchema = z13.object({
|
|
|
2665
2700
|
buckets: z13.array(z13.string()),
|
|
2666
2701
|
keys: z13.number().int(),
|
|
2667
2702
|
createdBy: z13.string().nullable(),
|
|
2703
|
+
/** Taken by the storage's nightly schedule rather than by a person: free, and outside the daily limit. */
|
|
2704
|
+
scheduled: z13.boolean().default(false),
|
|
2668
2705
|
createdAt: z13.string(),
|
|
2669
2706
|
finishedAt: z13.string().nullable()
|
|
2670
2707
|
});
|
|
@@ -2966,6 +3003,14 @@ var ServerClient = class {
|
|
|
2966
3003
|
boxBackup(name, id) {
|
|
2967
3004
|
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
|
|
2968
3005
|
}
|
|
3006
|
+
/** A box's nightly backup: off, with no row, until it is turned on. */
|
|
3007
|
+
boxBackupSchedule(name) {
|
|
3008
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/backup-schedule`, BackupScheduleSchema);
|
|
3009
|
+
}
|
|
3010
|
+
/** On or off, or another hour (UTC, which turns it on). */
|
|
3011
|
+
setBoxBackupSchedule(name, change) {
|
|
3012
|
+
return this.call("PUT", `/machines/${encodeURIComponent(name)}/backup-schedule`, BackupScheduleSchema, change);
|
|
3013
|
+
}
|
|
2969
3014
|
/** Starts one; it runs in the background (`running`), `boxBackup` says how it ended. */
|
|
2970
3015
|
createBoxBackup(name) {
|
|
2971
3016
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/backups`, BackupSchema);
|
|
@@ -2987,6 +3032,13 @@ var ServerClient = class {
|
|
|
2987
3032
|
volumeBackup(name, id) {
|
|
2988
3033
|
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
|
|
2989
3034
|
}
|
|
3035
|
+
/** A volume's nightly backup: off, with no row, until it is turned on. */
|
|
3036
|
+
volumeBackupSchedule(name) {
|
|
3037
|
+
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backup-schedule`, BackupScheduleSchema);
|
|
3038
|
+
}
|
|
3039
|
+
setVolumeBackupSchedule(name, change) {
|
|
3040
|
+
return this.call("PUT", `/volumes/${encodeURIComponent(name)}/backup-schedule`, BackupScheduleSchema, change);
|
|
3041
|
+
}
|
|
2990
3042
|
/** Starts one; it runs in the background (`running`), `volumeBackup` says how it ended. */
|
|
2991
3043
|
createVolumeBackup(name) {
|
|
2992
3044
|
return this.call("POST", `/volumes/${encodeURIComponent(name)}/backups`, VolumeBackupSchema);
|
|
@@ -3204,6 +3256,13 @@ var ServerClient = class {
|
|
|
3204
3256
|
storageBackup(id) {
|
|
3205
3257
|
return this.call("GET", `/storage/backups/${encodeURIComponent(id)}`, StorageBackupSchema);
|
|
3206
3258
|
}
|
|
3259
|
+
/** The nightly backup of the slug's object storage: off until it is turned on. */
|
|
3260
|
+
storageBackupSchedule() {
|
|
3261
|
+
return this.call("GET", "/storage/backup-schedule", BackupScheduleSchema);
|
|
3262
|
+
}
|
|
3263
|
+
setStorageBackupSchedule(change) {
|
|
3264
|
+
return this.call("PUT", "/storage/backup-schedule", BackupScheduleSchema, change);
|
|
3265
|
+
}
|
|
3207
3266
|
/** Starts one; it runs in the background (`running`), `storageBackup` says how it ended. */
|
|
3208
3267
|
createStorageBackup() {
|
|
3209
3268
|
return this.call("POST", "/storage/backups", StorageBackupSchema);
|
|
@@ -3822,7 +3881,7 @@ async function noteNotConnected(client, box2, asked) {
|
|
|
3822
3881
|
}
|
|
3823
3882
|
|
|
3824
3883
|
// src/commands/vm/new.ts
|
|
3825
|
-
var newCommand = new Command("new").description("boot a new box from an image (the base one, or e.g. postgres) or a snapshot").argument("[name]", "box name (box1, box2, \u2026 when omitted)").addOption(new Option("-s, --size <size>", "box size (default: server config, s)").choices(SIZE_NAMES)).option("-b, --base <image>", "the image to boot: base (default) or one the host has, e.g. postgres").option("-e, --env <NAME=value>", "a variable of the box's own, over yours (repeatable; change later with kvbox env set --box)", collect, []).option("-f, --from <snapshot>", "start from a snapshot instead of an image").option("--from-backup <id>", "start on a backup's disk, a removed box's too (kvbox vm backup ls); image, variables and size come from it").option("--near <box>", "put it on the same host as this box, so the two
|
|
3884
|
+
var newCommand = new Command("new").description("boot a new box from an image (the base one, or e.g. postgres) or a snapshot").argument("[name]", "box name (box1, box2, \u2026 when omitted)").addOption(new Option("-s, --size <size>", "box size (default: server config, s)").choices(SIZE_NAMES)).option("-b, --base <image>", "the image to boot: base (default) or one the host has, e.g. postgres").option("-e, --env <NAME=value>", "a variable of the box's own, over yours (repeatable; change later with kvbox env set --box)", collect, []).option("-f, --from <snapshot>", "start from a snapshot instead of an image").option("--from-backup <id>", "start on a backup's disk, a removed box's too (kvbox vm backup ls); image, variables and size come from it").option("--near <box>", "put it on the same host as this box, so a link between the two stays on that host (kvbox vm link)").option("--country <country>", "put it on a host in this country, a name or a code, e.g. romania or US").addOption(new Option("--host <name>", "put it on this host and no other (admins only)").hideHelp()).option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never; default: server config, off)").option("--integration <list>", "turn integrations on for the box, e.g. github,claude (connect the account in the web app; off: none)").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
3826
3885
|
const autoHibernateSec = opts.autoHibernate === void 0 ? void 0 : parseIdleTimeout(opts.autoHibernate);
|
|
3827
3886
|
const env = parseEnvFlags(opts.env);
|
|
3828
3887
|
const integrations = opts.integration === void 0 ? void 0 : parseIntegrationList(opts.integration);
|
|
@@ -4332,7 +4391,7 @@ function parseLinkPort(text2) {
|
|
|
4332
4391
|
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new KvboxError(`--port: expected a port from 1 to 65535, got "${text2}"`);
|
|
4333
4392
|
return port;
|
|
4334
4393
|
}
|
|
4335
|
-
var linkCommand = new Command9("link").description("let one box reach a port of another (private
|
|
4394
|
+
var linkCommand = new Command9("link").description("let one box reach a port of another (private; never public)").argument("<from>", "the box that connects").argument("<box>", "the box it may reach").requiredOption("-p, --port <port>", "the port in <box>").option("--json", "print the link as JSON").action(async (from, name, opts, cmd) => {
|
|
4336
4395
|
const port = parseLinkPort(opts.port);
|
|
4337
4396
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
4338
4397
|
try {
|
|
@@ -4746,7 +4805,7 @@ var hookCommand = new Command22("hook").description("URLs that wake a box when c
|
|
|
4746
4805
|
for (const cmd of hookCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
4747
4806
|
|
|
4748
4807
|
// src/commands/vm/backup/index.ts
|
|
4749
|
-
import { Command as
|
|
4808
|
+
import { Command as Command30 } from "commander";
|
|
4750
4809
|
|
|
4751
4810
|
// src/commands/vm/backup/create.ts
|
|
4752
4811
|
import { Command as Command24 } from "commander";
|
|
@@ -4911,7 +4970,7 @@ var lsCommand4 = new Command25("ls").alias("list").description("list backups: ev
|
|
|
4911
4970
|
data: b.dataBytes === null ? "-" : gbShort(b.dataBytes),
|
|
4912
4971
|
uploaded: b.uploadedBytes === null ? "-" : gbShort(b.uploadedBytes),
|
|
4913
4972
|
disk: b.diskBytes === null ? "-" : gbShort(b.diskBytes),
|
|
4914
|
-
by: b.createdBy ?? "-",
|
|
4973
|
+
by: b.scheduled ? color.dim("schedule") : b.createdBy ?? "-",
|
|
4915
4974
|
taken: age(b.createdAt),
|
|
4916
4975
|
...anyError ? { error: b.error ?? "" } : {}
|
|
4917
4976
|
}))
|
|
@@ -4979,13 +5038,79 @@ var rmCommand3 = new Command27("rm").alias("remove").description("remove a backu
|
|
|
4979
5038
|
}
|
|
4980
5039
|
});
|
|
4981
5040
|
|
|
5041
|
+
// src/commands/vm/backup/schedule.ts
|
|
5042
|
+
import { Command as Command29 } from "commander";
|
|
5043
|
+
|
|
5044
|
+
// src/commands/vm/backup/nightly.ts
|
|
5045
|
+
import "commander";
|
|
5046
|
+
var scheduleFlags = (cmd) => cmd.option("--at <hour>", "back it up daily at this hour, 0-23 UTC (turns it on)").option("--off", "stop backing it up on its own").option("--on", "back it up on its own, at the hour it has").option("--json", "print the schedule as JSON");
|
|
5047
|
+
function changeOf(flags) {
|
|
5048
|
+
if (flags.off && (flags.on || flags.at !== void 0)) throw new KvboxError("--off takes neither --on nor --at");
|
|
5049
|
+
const hour = flags.at === void 0 ? void 0 : parseHour(flags.at);
|
|
5050
|
+
return { ...flags.off ? { enabled: false } : flags.on ? { enabled: true } : {}, ...hour !== void 0 ? { hour } : {} };
|
|
5051
|
+
}
|
|
5052
|
+
function parseHour(text2) {
|
|
5053
|
+
const m = /^(\d{1,2})(?::00)?$/.exec(text2.trim());
|
|
5054
|
+
const hour = m ? Number(m[1]) : NaN;
|
|
5055
|
+
if (!Number.isInteger(hour) || hour < 0 || hour > 23) throw new KvboxError(`--at ${text2}: an hour of the day, 0-23 (UTC), like 3 or 03:00`);
|
|
5056
|
+
return hour;
|
|
5057
|
+
}
|
|
5058
|
+
function scheduleLine(command, s, now = Date.now()) {
|
|
5059
|
+
const at = `${String(s.hour).padStart(2, "0")}:00 UTC`;
|
|
5060
|
+
if (!s.enabled) return color.dim(`not on their own (${command} --on, at ${at})`);
|
|
5061
|
+
const nextMs = s.nextAt === null ? null : Date.parse(s.nextAt) - now;
|
|
5062
|
+
const next = s.nextAt === null || nextMs === null ? "" : nextMs > -6e4 ? `, next in ${inHours(nextMs)}` : `, ${color.yellow(`due since ${s.nextAt.slice(0, 16).replace("T", " ")} UTC, waiting for the backup job`)}`;
|
|
5063
|
+
const failed = s.lastError !== null ? color.yellow(` last one failed: ${s.lastError}`) : "";
|
|
5064
|
+
return `daily at ${at}${next}${failed}`;
|
|
5065
|
+
}
|
|
5066
|
+
function inHours(ms2) {
|
|
5067
|
+
const min = Math.max(0, Math.round(ms2 / 6e4));
|
|
5068
|
+
if (min < 60) return `${min}m`;
|
|
5069
|
+
const h = Math.floor(min / 60);
|
|
5070
|
+
return h < 24 ? `${h}h ${min % 60}m` : `${Math.floor(h / 24)}d ${h % 24}h`;
|
|
5071
|
+
}
|
|
5072
|
+
function withOrg(client, command) {
|
|
5073
|
+
const org = client.target.kind === "cloud" ? client.target.org : void 0;
|
|
5074
|
+
return org ? `${command} --org ${org}` : command;
|
|
5075
|
+
}
|
|
5076
|
+
function printSchedule(what, command, schedule, flags, changed) {
|
|
5077
|
+
if (flags.json) {
|
|
5078
|
+
json(schedule);
|
|
5079
|
+
return;
|
|
5080
|
+
}
|
|
5081
|
+
const at = `${String(schedule.hour).padStart(2, "0")}:00 UTC`;
|
|
5082
|
+
const said = schedule.enabled ? scheduleLine(command, schedule) : color.dim(`not backed up on its own (${command} --on, at ${at})`);
|
|
5083
|
+
info(`${changed ? `${color.green("\u2713")} ` : ""}${what}: ${said}`);
|
|
5084
|
+
if (schedule.lastAt !== null) {
|
|
5085
|
+
const last = schedule.lastError !== null ? color.red(`failed: ${schedule.lastError}`) : schedule.lastBackup !== null ? `backup ${schedule.lastBackup}` : "starting a backup";
|
|
5086
|
+
info(color.dim(` last turn ${schedule.lastAt.slice(0, 16).replace("T", " ")} UTC: `) + last);
|
|
5087
|
+
}
|
|
5088
|
+
}
|
|
5089
|
+
|
|
5090
|
+
// src/commands/vm/backup/schedule.ts
|
|
5091
|
+
var scheduleCommand = scheduleFlags(new Command29("schedule").description("show or switch a box's nightly backup (daily, UTC; off until you turn it on)").argument("<box>", "box name")).action(
|
|
5092
|
+
async (name, flags, cmd) => {
|
|
5093
|
+
const change = changeOf(flags);
|
|
5094
|
+
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5095
|
+
try {
|
|
5096
|
+
requireCloud3(client);
|
|
5097
|
+
const box2 = displayName(await findBox(client, name), me(client));
|
|
5098
|
+
const changed = Object.keys(change).length > 0;
|
|
5099
|
+
const schedule = changed ? await client.setBoxBackupSchedule(box2, change) : await client.boxBackupSchedule(box2);
|
|
5100
|
+
printSchedule(`box ${box2}`, `kvbox vm backup schedule ${box2}`, schedule, flags, changed);
|
|
5101
|
+
} finally {
|
|
5102
|
+
await client.close();
|
|
5103
|
+
}
|
|
5104
|
+
}
|
|
5105
|
+
);
|
|
5106
|
+
|
|
4982
5107
|
// src/commands/vm/backup/index.ts
|
|
4983
|
-
var backupCommand = new
|
|
5108
|
+
var backupCommand = new Command30("backup").description("back up a box's disk to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand2).addCommand(lsCommand4).addCommand(restoreCommand).addCommand(rmCommand3).addCommand(scheduleCommand);
|
|
4984
5109
|
for (const cmd of backupCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
4985
5110
|
|
|
4986
5111
|
// src/commands/vm/rescale.ts
|
|
4987
|
-
import { Command as
|
|
4988
|
-
var rescaleCommand = new
|
|
5112
|
+
import { Command as Command31, Option as Option3 } from "commander";
|
|
5113
|
+
var rescaleCommand = new Command31("rescale").description("change a box's vCPUs, memory or disk (e.g. --vcpu 4 --mem 16GB); a running box restarts").argument("<name>", "box name").addOption(new Option3("-s, --size <size>", "a preset to start from").choices(SIZE_NAMES)).option("--vcpu <n>", "number of vCPUs").option("--mem <size>", "memory, e.g. 16GB or 4096MB").option("--disk <size>", "disk size, e.g. 32GB (grow only)").option("--force", "skip the capacity guard when a running box grows").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
4989
5114
|
const req = {
|
|
4990
5115
|
...opts.size !== void 0 ? { size: opts.size } : {},
|
|
4991
5116
|
...opts.vcpu !== void 0 ? { vcpu: parseCount(opts.vcpu) } : {},
|
|
@@ -5031,8 +5156,8 @@ function parseGib(flag, text2) {
|
|
|
5031
5156
|
}
|
|
5032
5157
|
|
|
5033
5158
|
// src/commands/vm/resume.ts
|
|
5034
|
-
import { Command as
|
|
5035
|
-
var resumeCommand = new
|
|
5159
|
+
import { Command as Command32 } from "commander";
|
|
5160
|
+
var resumeCommand = new Command32("resume").description("continue a box that is in standby (kvbox pause)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
5036
5161
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5037
5162
|
try {
|
|
5038
5163
|
const box2 = await spin(`resuming ${name}\u2026`, client.resumeMachine(name));
|
|
@@ -5044,8 +5169,8 @@ var resumeCommand = new Command30("resume").description("continue a box that is
|
|
|
5044
5169
|
});
|
|
5045
5170
|
|
|
5046
5171
|
// src/commands/vm/rm.ts
|
|
5047
|
-
import { Command as
|
|
5048
|
-
var rmCommand4 = new
|
|
5172
|
+
import { Command as Command33 } from "commander";
|
|
5173
|
+
var rmCommand4 = new Command33("rm").description("destroy a box (its disk is deleted; snapshots are kept)").argument("<name>", "box name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
5049
5174
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5050
5175
|
try {
|
|
5051
5176
|
const box2 = pickRef(await boxesFor(client, name), name, me(client));
|
|
@@ -5065,7 +5190,7 @@ var rmCommand4 = new Command31("rm").description("destroy a box (its disk is del
|
|
|
5065
5190
|
});
|
|
5066
5191
|
|
|
5067
5192
|
// src/commands/vm/set.ts
|
|
5068
|
-
import { Command as
|
|
5193
|
+
import { Command as Command34 } from "commander";
|
|
5069
5194
|
|
|
5070
5195
|
// src/swap.ts
|
|
5071
5196
|
import { spawn as spawn4 } from "child_process";
|
|
@@ -5141,7 +5266,7 @@ function runSwap(ep, mib) {
|
|
|
5141
5266
|
}
|
|
5142
5267
|
|
|
5143
5268
|
// src/commands/vm/set.ts
|
|
5144
|
-
var setCommand = new
|
|
5269
|
+
var setCommand = new Command34("set").description("change a box's settings, e.g. --auto-hibernate 30m (off: never), --idle-check /home/kvbox/idle.sh, --integration github, --swap 2G").argument("<name>", "box name").option("--auto-hibernate <duration>", "hibernate the box after this long without network traffic (30m, 4h, 1d; off: never)").option("--idle-check <script>", "a script in the box that exits 0 when it is idle, asked instead of network traffic (off: none)").option("--integration <list>", "the integrations turned on for the box, replacing its list, e.g. github,claude (off: none)").option("--swap <size>", "a swap file on the box's disk for memory spikes such as a build (2G, 512M; off: none)").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
5145
5270
|
if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.integration === void 0 && opts.swap === void 0) {
|
|
5146
5271
|
throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check, --integration or --swap");
|
|
5147
5272
|
}
|
|
@@ -5219,8 +5344,8 @@ function parseIdleCheck(text2) {
|
|
|
5219
5344
|
}
|
|
5220
5345
|
|
|
5221
5346
|
// src/commands/vm/start.ts
|
|
5222
|
-
import { Command as
|
|
5223
|
-
var startCommand = new
|
|
5347
|
+
import { Command as Command35 } from "commander";
|
|
5348
|
+
var startCommand = new Command35("start").description("boot a stopped box again (same name, IP and disk)").argument("<name>", "box name").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
5224
5349
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5225
5350
|
try {
|
|
5226
5351
|
const box2 = await spin(`booting ${name}\u2026`, client.startMachine(name, opts.force ?? false));
|
|
@@ -5232,8 +5357,8 @@ var startCommand = new Command33("start").description("boot a stopped box again
|
|
|
5232
5357
|
});
|
|
5233
5358
|
|
|
5234
5359
|
// src/commands/vm/stop.ts
|
|
5235
|
-
import { Command as
|
|
5236
|
-
var stopCommand = new
|
|
5360
|
+
import { Command as Command36 } from "commander";
|
|
5361
|
+
var stopCommand = new Command36("stop").description("shut a box down (its disk is kept; start it again with kvbox start)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
5237
5362
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5238
5363
|
try {
|
|
5239
5364
|
const box2 = await spin(`shutting ${name} down\u2026`, client.stopMachine(name));
|
|
@@ -5245,8 +5370,8 @@ var stopCommand = new Command34("stop").description("shut a box down (its disk i
|
|
|
5245
5370
|
});
|
|
5246
5371
|
|
|
5247
5372
|
// src/commands/vm/top.ts
|
|
5248
|
-
import { Command as
|
|
5249
|
-
var topCommand = new
|
|
5373
|
+
import { Command as Command37 } from "commander";
|
|
5374
|
+
var topCommand = new Command37("top").description("load, memory and disk of each running box, as the box itself sees them").option("-a, --all", "every running box on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5250
5375
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5251
5376
|
try {
|
|
5252
5377
|
const running = (await client.listMachines({ all: opts.all })).filter((b) => b.status === "running");
|
|
@@ -5306,8 +5431,8 @@ function topRows(entries, cloud) {
|
|
|
5306
5431
|
}
|
|
5307
5432
|
|
|
5308
5433
|
// src/commands/vm/traffic.ts
|
|
5309
|
-
import { Command as
|
|
5310
|
-
var trafficCommand = new
|
|
5434
|
+
import { Command as Command38 } from "commander";
|
|
5435
|
+
var trafficCommand = new Command38("traffic").description(`requests, errors, latency, bytes and wakes through a box's HTTPS names (last ${TRAFFIC_KEEP_DAYS} days at most)`).argument("<name>", "box name").option("--since <when>", "how far back: 1h, 24h, 7d, or a date like 2026-11-19 (default 24h)").option("--host <name>", "one of the box's names only, e.g. web.kvbox.app").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
5311
5436
|
const q = new URLSearchParams();
|
|
5312
5437
|
if (opts.since !== void 0) q.set("since", sinceOf(opts.since));
|
|
5313
5438
|
if (opts.host !== void 0) q.set("host", opts.host);
|
|
@@ -5369,8 +5494,8 @@ function block2(r) {
|
|
|
5369
5494
|
}
|
|
5370
5495
|
|
|
5371
5496
|
// src/commands/vm/unlink.ts
|
|
5372
|
-
import { Command as
|
|
5373
|
-
var unlinkCommand = new
|
|
5497
|
+
import { Command as Command39 } from "commander";
|
|
5498
|
+
var unlinkCommand = new Command39("unlink").description("take a link away (kvbox vm link)").argument("<from>", "the box that connects").argument("<box>", "the box it reaches").requiredOption("-p, --port <port>", "the port in <box>").option("-y, --yes", "do not ask for confirmation").option("--json", "print the removed link as JSON").action(async (from, name, opts, cmd) => {
|
|
5374
5499
|
const port = parseLinkPort(opts.port);
|
|
5375
5500
|
if (!await confirm(`Cut box ${from} off from box ${name} port ${port}? Its open connections close too.`, opts.yes ?? false)) {
|
|
5376
5501
|
info("cancelled");
|
|
@@ -5391,8 +5516,8 @@ var unlinkCommand = new Command37("unlink").description("take a link away (kvbox
|
|
|
5391
5516
|
});
|
|
5392
5517
|
|
|
5393
5518
|
// src/commands/vm/update.ts
|
|
5394
|
-
import { Command as
|
|
5395
|
-
var updateCommand = new
|
|
5519
|
+
import { Command as Command40 } from "commander";
|
|
5520
|
+
var updateCommand = new Command40("update").description("move a box onto the current base image (its files stay; a running box restarts)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
5396
5521
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5397
5522
|
try {
|
|
5398
5523
|
const before = pickRef(await boxesFor(client, name), name, me(client));
|
|
@@ -5414,8 +5539,8 @@ var updateCommand = new Command38("update").description("move a box onto the cur
|
|
|
5414
5539
|
});
|
|
5415
5540
|
|
|
5416
5541
|
// src/commands/vm/wake.ts
|
|
5417
|
-
import { Command as
|
|
5418
|
-
var wakeCommand = new
|
|
5542
|
+
import { Command as Command41 } from "commander";
|
|
5543
|
+
var wakeCommand = new Command41("wake").description("continue a hibernated box where it left off (same name, IP and disk)").argument("<name>", "box name").option("--force", "skip the capacity guard").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
5419
5544
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5420
5545
|
try {
|
|
5421
5546
|
const box2 = await spin(`waking ${name} (loading its memory from disk)\u2026`, client.wakeMachine(name, opts.force ?? false));
|
|
@@ -5427,7 +5552,7 @@ var wakeCommand = new Command39("wake").description("continue a hibernated box w
|
|
|
5427
5552
|
});
|
|
5428
5553
|
|
|
5429
5554
|
// src/commands/vm/index.ts
|
|
5430
|
-
var vmCommand = new
|
|
5555
|
+
var vmCommand = new Command42("vm").enablePositionalOptions().description("manage boxes (each one is a Firecracker microVM)").addCommand(newCommand).addCommand(forkCommand).addCommand(lsCommand).addCommand(getCommand).addCommand(connectCommand).addCommand(execCommand).addCommand(cpCommand).addCommand(stopCommand).addCommand(startCommand).addCommand(pauseCommand).addCommand(resumeCommand).addCommand(hibernateCommand).addCommand(wakeCommand).addCommand(updateCommand).addCommand(rescaleCommand).addCommand(setCommand).addCommand(usageCommand).addCommand(trafficCommand).addCommand(topCommand).addCommand(proxyCommand).addCommand(hookCommand).addCommand(backupCommand).addCommand(linkCommand).addCommand(unlinkCommand).addCommand(linksCommand).addCommand(rmCommand4);
|
|
5431
5556
|
for (const cmd of vmCommand.commands) if (cmd !== proxyCommand && cmd !== hookCommand && cmd !== backupCommand) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
5432
5557
|
var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, cpCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand, rmCommand4, claimCommand];
|
|
5433
5558
|
|
|
@@ -5436,7 +5561,7 @@ import { hostname as osHostname2 } from "os";
|
|
|
5436
5561
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
5437
5562
|
import { setTimeout as sleep4 } from "timers/promises";
|
|
5438
5563
|
import { Writable } from "stream";
|
|
5439
|
-
import { Command as
|
|
5564
|
+
import { Command as Command43 } from "commander";
|
|
5440
5565
|
|
|
5441
5566
|
// src/browser.ts
|
|
5442
5567
|
import { spawn as spawn5 } from "child_process";
|
|
@@ -5473,7 +5598,7 @@ function openBrowser(url) {
|
|
|
5473
5598
|
}
|
|
5474
5599
|
|
|
5475
5600
|
// src/commands/login.ts
|
|
5476
|
-
var loginCommand = new
|
|
5601
|
+
var loginCommand = new Command43("login").description("log in to the kvbox cloud (or your own control plane) and target it from now on").argument("[url]", `control plane URL (default: ${DEFAULT_CLOUD_URL})`).option("--password", "log in with email and password instead of approving a code in the web app").option("-e, --email <email>", "account email, for a password login (prompted otherwise)").option("--password-stdin", "read the password from the first line of stdin (for scripts)").action(async (urlArg, opts) => {
|
|
5477
5602
|
const url = normalizeUrl(urlArg ?? DEFAULT_CLOUD_URL);
|
|
5478
5603
|
const byPassword = opts.password === true || opts.passwordStdin === true || opts.email !== void 0;
|
|
5479
5604
|
const session = byPassword ? await runLogin(url, await readCredentials(opts), paths()) : await runDeviceLogin(url, paths());
|
|
@@ -5583,8 +5708,8 @@ async function firstLine(stream) {
|
|
|
5583
5708
|
}
|
|
5584
5709
|
|
|
5585
5710
|
// src/commands/logout.ts
|
|
5586
|
-
import { Command as
|
|
5587
|
-
var logoutCommand = new
|
|
5711
|
+
import { Command as Command44 } from "commander";
|
|
5712
|
+
var logoutCommand = new Command44("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
|
|
5588
5713
|
const p = paths();
|
|
5589
5714
|
const session = await readSession(p).catch(() => null);
|
|
5590
5715
|
switch (await runLogout(p)) {
|
|
@@ -5622,8 +5747,8 @@ async function runLogout(p = paths()) {
|
|
|
5622
5747
|
}
|
|
5623
5748
|
|
|
5624
5749
|
// src/commands/whoami.ts
|
|
5625
|
-
import { Command as
|
|
5626
|
-
var whoamiCommand = new
|
|
5750
|
+
import { Command as Command45 } from "commander";
|
|
5751
|
+
var whoamiCommand = new Command45("whoami").description("show which account and control plane commands target (or local mode)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5627
5752
|
if (!cmd.optsWithGlobals().local && envLogin()) {
|
|
5628
5753
|
const target = await resolveTarget({});
|
|
5629
5754
|
if (target.kind !== "cloud") return;
|
|
@@ -5648,10 +5773,10 @@ function describeSession(session) {
|
|
|
5648
5773
|
}
|
|
5649
5774
|
|
|
5650
5775
|
// src/commands/key/index.ts
|
|
5651
|
-
import { Command as
|
|
5776
|
+
import { Command as Command49 } from "commander";
|
|
5652
5777
|
|
|
5653
5778
|
// src/commands/key/create.ts
|
|
5654
|
-
import { Command as
|
|
5779
|
+
import { Command as Command46 } from "commander";
|
|
5655
5780
|
|
|
5656
5781
|
// src/commands/key/shared.ts
|
|
5657
5782
|
async function keyClient(cmd) {
|
|
@@ -5688,7 +5813,7 @@ function expiryText(expiresAt, now = Date.now()) {
|
|
|
5688
5813
|
}
|
|
5689
5814
|
|
|
5690
5815
|
// src/commands/key/create.ts
|
|
5691
|
-
var createCommand3 = new
|
|
5816
|
+
var createCommand3 = new Command46("create").description("make an API key for a program: CI, an agent, the SDK (the key is shown once)").argument("<name>", "what to call the key: lowercase letters, digits, '.', '_' or '-'").option("--expires <when>", `when it stops working: a duration (30d, 12h; m is minutes), a day (2027-01-31), or never; ${DEFAULT_API_KEY_DAYS}d by default`).option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
5692
5817
|
const expiresAt = opts.expires === void 0 ? void 0 : parseExpires(opts.expires);
|
|
5693
5818
|
const client = await keyClient(cmd);
|
|
5694
5819
|
try {
|
|
@@ -5706,8 +5831,8 @@ var createCommand3 = new Command44("create").description("make an API key for a
|
|
|
5706
5831
|
});
|
|
5707
5832
|
|
|
5708
5833
|
// src/commands/key/ls.ts
|
|
5709
|
-
import { Command as
|
|
5710
|
-
var lsCommand5 = new
|
|
5834
|
+
import { Command as Command47 } from "commander";
|
|
5835
|
+
var lsCommand5 = new Command47("ls").alias("list").description("list your API keys (never the keys themselves)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5711
5836
|
const client = await keyClient(cmd);
|
|
5712
5837
|
try {
|
|
5713
5838
|
const keys = await client.listApiKeys();
|
|
@@ -5726,8 +5851,8 @@ var lsCommand5 = new Command45("ls").alias("list").description("list your API ke
|
|
|
5726
5851
|
});
|
|
5727
5852
|
|
|
5728
5853
|
// src/commands/key/rm.ts
|
|
5729
|
-
import { Command as
|
|
5730
|
-
var rmCommand5 = new
|
|
5854
|
+
import { Command as Command48 } from "commander";
|
|
5855
|
+
var rmCommand5 = new Command48("rm").alias("remove").description("remove an API key: whatever uses it stops working").argument("<name>", "the key's name (kvbox key ls)").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
5731
5856
|
const client = await keyClient(cmd);
|
|
5732
5857
|
try {
|
|
5733
5858
|
if (!await confirm(`Remove API key ${name}? Whatever uses it stops working.`, opts.yes ?? false)) {
|
|
@@ -5743,14 +5868,14 @@ var rmCommand5 = new Command46("rm").alias("remove").description("remove an API
|
|
|
5743
5868
|
});
|
|
5744
5869
|
|
|
5745
5870
|
// src/commands/key/index.ts
|
|
5746
|
-
var keyCommand = new
|
|
5871
|
+
var keyCommand = new Command49("key").aliases(["keys"]).description("API keys: named tokens a program (CI, an agent, the SDK) uses as KVBOX_TOKEN in place of a login").addCommand(createCommand3).addCommand(lsCommand5).addCommand(rmCommand5);
|
|
5747
5872
|
|
|
5748
5873
|
// src/commands/integration/index.ts
|
|
5749
|
-
import { Command as
|
|
5874
|
+
import { Command as Command51 } from "commander";
|
|
5750
5875
|
|
|
5751
5876
|
// src/commands/integration/ls.ts
|
|
5752
|
-
import { Command as
|
|
5753
|
-
var lsCommand6 = new
|
|
5877
|
+
import { Command as Command50 } from "commander";
|
|
5878
|
+
var lsCommand6 = new Command50("ls").alias("list").description("list the accounts connected for your boxes (GitHub, Claude Code), per slug; connect one in the web app").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5754
5879
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5755
5880
|
try {
|
|
5756
5881
|
if (client.target.kind !== "cloud") throw new KvboxError("integrations belong to an account on the kvbox cloud: kvbox login first");
|
|
@@ -5779,14 +5904,14 @@ var lsCommand6 = new Command48("ls").alias("list").description("list the account
|
|
|
5779
5904
|
});
|
|
5780
5905
|
|
|
5781
5906
|
// src/commands/integration/index.ts
|
|
5782
|
-
var integrationCommand = new
|
|
5907
|
+
var integrationCommand = new Command51("integration").aliases(["integrations"]).description("integrations: accounts (GitHub, Claude Code) connected once in the web app and turned on per box with --integration").addCommand(lsCommand6);
|
|
5783
5908
|
|
|
5784
5909
|
// src/commands/snapshots/index.ts
|
|
5785
|
-
import { Command as
|
|
5910
|
+
import { Command as Command55 } from "commander";
|
|
5786
5911
|
|
|
5787
5912
|
// src/commands/snapshots/ls.ts
|
|
5788
|
-
import { Command as
|
|
5789
|
-
var lsCommand7 = new
|
|
5913
|
+
import { Command as Command52 } from "commander";
|
|
5914
|
+
var lsCommand7 = new Command52("ls").description("list snapshots (yours and your orgs'; --org <slug> for one org)").option("-a, --all", "every snapshot on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5790
5915
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5791
5916
|
try {
|
|
5792
5917
|
const cloud = client.target.kind === "cloud";
|
|
@@ -5817,8 +5942,8 @@ var lsCommand7 = new Command50("ls").description("list snapshots (yours and your
|
|
|
5817
5942
|
});
|
|
5818
5943
|
|
|
5819
5944
|
// src/commands/snapshots/new.ts
|
|
5820
|
-
import { Command as
|
|
5821
|
-
var newCommand2 = new
|
|
5945
|
+
import { Command as Command53 } from "commander";
|
|
5946
|
+
var newCommand2 = new Command53("new").description("freeze a running box (memory + disk) into a snapshot; the box keeps running").argument("<box>", "box name").argument("<name>", "snapshot name").option("--replace", "retake a snapshot that exists under this name; the old one stays until the new one is complete").option("--json", "print the snapshot as JSON").action(async (box2, name, opts, cmd) => {
|
|
5822
5947
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5823
5948
|
try {
|
|
5824
5949
|
const req = { box: box2, name, ...opts.replace ? { replace: true } : {} };
|
|
@@ -5831,8 +5956,8 @@ var newCommand2 = new Command51("new").description("freeze a running box (memory
|
|
|
5831
5956
|
});
|
|
5832
5957
|
|
|
5833
5958
|
// src/commands/snapshots/rm.ts
|
|
5834
|
-
import { Command as
|
|
5835
|
-
var rmCommand6 = new
|
|
5959
|
+
import { Command as Command54 } from "commander";
|
|
5960
|
+
var rmCommand6 = new Command54("rm").description("delete a snapshot (boxes made from it are not affected)").argument("<name>", "snapshot name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
5836
5961
|
if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
|
|
5837
5962
|
info("cancelled");
|
|
5838
5963
|
process.exitCode = 1;
|
|
@@ -5848,14 +5973,14 @@ var rmCommand6 = new Command52("rm").description("delete a snapshot (boxes made
|
|
|
5848
5973
|
});
|
|
5849
5974
|
|
|
5850
5975
|
// src/commands/snapshots/index.ts
|
|
5851
|
-
var snapshotsCommand = new
|
|
5976
|
+
var snapshotsCommand = new Command55("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand7).addCommand(rmCommand6);
|
|
5852
5977
|
for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
5853
5978
|
|
|
5854
5979
|
// src/commands/org/index.ts
|
|
5855
|
-
import { Command as
|
|
5980
|
+
import { Command as Command61 } from "commander";
|
|
5856
5981
|
|
|
5857
5982
|
// src/commands/org/ls.ts
|
|
5858
|
-
import { Command as
|
|
5983
|
+
import { Command as Command56 } from "commander";
|
|
5859
5984
|
|
|
5860
5985
|
// src/commands/org/context.ts
|
|
5861
5986
|
var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
|
|
@@ -5875,7 +6000,7 @@ function orgFor(opts, target) {
|
|
|
5875
6000
|
}
|
|
5876
6001
|
|
|
5877
6002
|
// src/commands/org/ls.ts
|
|
5878
|
-
var lsCommand8 = new
|
|
6003
|
+
var lsCommand8 = new Command56("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5879
6004
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5880
6005
|
try {
|
|
5881
6006
|
const orgs = await client.listOrgs();
|
|
@@ -5897,8 +6022,8 @@ function orgRows(orgs) {
|
|
|
5897
6022
|
}
|
|
5898
6023
|
|
|
5899
6024
|
// src/commands/org/members.ts
|
|
5900
|
-
import { Command as
|
|
5901
|
-
var lsCommand9 = new
|
|
6025
|
+
import { Command as Command57, Option as Option4 } from "commander";
|
|
6026
|
+
var lsCommand9 = new Command57("ls").description("list an org's members and their roles").option("-o, --org <slug>", "the org (or --org before the command)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5902
6027
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5903
6028
|
try {
|
|
5904
6029
|
const org = await client.getOrg(orgFor(opts, client.target));
|
|
@@ -5912,7 +6037,7 @@ var lsCommand9 = new Command55("ls").description("list an org's members and thei
|
|
|
5912
6037
|
await client.close();
|
|
5913
6038
|
}
|
|
5914
6039
|
});
|
|
5915
|
-
var addCommand2 = new
|
|
6040
|
+
var addCommand2 = new Command57("add").description("add a user to an org (admins and owners; only an owner can add an owner)").argument("<user>", "their username").addOption(new Option4("-r, --role <role>", "their role").choices(ORG_ROLES).default("member")).option("-o, --org <slug>", "the org (or --org before the command)").action(async (user, opts, cmd) => {
|
|
5916
6041
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5917
6042
|
try {
|
|
5918
6043
|
const slug = orgFor(opts, client.target);
|
|
@@ -5922,7 +6047,7 @@ var addCommand2 = new Command55("add").description("add a user to an org (admins
|
|
|
5922
6047
|
await client.close();
|
|
5923
6048
|
}
|
|
5924
6049
|
});
|
|
5925
|
-
var rmCommand7 = new
|
|
6050
|
+
var rmCommand7 = new Command57("rm").description("remove a member (or leave: remove yourself)").argument("<user>", "their username").option("-o, --org <slug>", "the org (or --org before the command)").option("-y, --yes", "do not ask for confirmation").action(async (user, opts, cmd) => {
|
|
5926
6051
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5927
6052
|
try {
|
|
5928
6053
|
const slug = orgFor(opts, client.target);
|
|
@@ -5938,11 +6063,11 @@ var rmCommand7 = new Command55("rm").description("remove a member (or leave: rem
|
|
|
5938
6063
|
await client.close();
|
|
5939
6064
|
}
|
|
5940
6065
|
});
|
|
5941
|
-
var membersCommand = new
|
|
6066
|
+
var membersCommand = new Command57("members").description("who is in an org and what they may do").addCommand(lsCommand9).addCommand(addCommand2).addCommand(rmCommand7);
|
|
5942
6067
|
|
|
5943
6068
|
// src/commands/org/new.ts
|
|
5944
|
-
import { Command as
|
|
5945
|
-
var newCommand3 = new
|
|
6069
|
+
import { Command as Command58 } from "commander";
|
|
6070
|
+
var newCommand3 = new Command58("new").description("create an org; you become its owner (the slug is permanent, the name is not)").argument("<slug>", "the org's slug: lowercase, like a username (acme)").option("-n, --name <name>", "display name (default: the slug)").option("--json", "print the org as JSON").action(async (slug, opts, cmd) => {
|
|
5946
6071
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5947
6072
|
try {
|
|
5948
6073
|
const org = await client.createOrg({ slug, name: opts.name ?? slug });
|
|
@@ -5958,8 +6083,8 @@ var newCommand3 = new Command56("new").description("create an org; you become it
|
|
|
5958
6083
|
});
|
|
5959
6084
|
|
|
5960
6085
|
// src/commands/org/rm.ts
|
|
5961
|
-
import { Command as
|
|
5962
|
-
var rmCommand8 = new
|
|
6086
|
+
import { Command as Command59 } from "commander";
|
|
6087
|
+
var rmCommand8 = new Command59("rm").description("delete an org (owners only; remove its boxes and snapshots first)").argument("<slug>", "the org").option("-y, --yes", "do not ask for confirmation").action(async (slug, opts, cmd) => {
|
|
5963
6088
|
if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
|
|
5964
6089
|
info("cancelled");
|
|
5965
6090
|
process.exitCode = 1;
|
|
@@ -5975,8 +6100,8 @@ var rmCommand8 = new Command57("rm").description("delete an org (owners only; re
|
|
|
5975
6100
|
});
|
|
5976
6101
|
|
|
5977
6102
|
// src/commands/org/role.ts
|
|
5978
|
-
import { Argument, Command as
|
|
5979
|
-
var roleCommand = new
|
|
6103
|
+
import { Argument, Command as Command60 } from "commander";
|
|
6104
|
+
var roleCommand = new Command60("role").description("change a member's role (owners only)").argument("<user>", "their username").addArgument(new Argument("<role>", "owner, admin or member").choices(ORG_ROLES)).option("-o, --org <slug>", "the org (default: the current context)").action(async (user, role, opts, cmd) => {
|
|
5980
6105
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5981
6106
|
try {
|
|
5982
6107
|
const slug = orgFor(opts, client.target);
|
|
@@ -5988,11 +6113,11 @@ var roleCommand = new Command58("role").description("change a member's role (own
|
|
|
5988
6113
|
});
|
|
5989
6114
|
|
|
5990
6115
|
// src/commands/org/index.ts
|
|
5991
|
-
var orgCommand = new
|
|
6116
|
+
var orgCommand = new Command61("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand8).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand8);
|
|
5992
6117
|
|
|
5993
6118
|
// src/commands/usage.ts
|
|
5994
|
-
import { Command as
|
|
5995
|
-
var usageCommand2 = new
|
|
6119
|
+
import { Command as Command62 } from "commander";
|
|
6120
|
+
var usageCommand2 = new Command62("usage").description("what your boxes and volumes used this month (or --since/--until): running time, vCPU-h, RAM and disk GiB-h, cost").option("--since <date>", "count from this date, e.g. 2026-10-01 (default: the 1st of this month)").option("--until <date>", "count up to this date (default: now)").option("--org <slug>", "one org's boxes only").option("-a, --all", "every box on the platform (platform admins only)").option("--by-user", "one line per user who made the boxes (e.g. who spent what in --org)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5996
6121
|
for (const [name, value] of [
|
|
5997
6122
|
["since", opts.since],
|
|
5998
6123
|
["until", opts.until]
|
|
@@ -6189,8 +6314,8 @@ function userRows(r) {
|
|
|
6189
6314
|
}
|
|
6190
6315
|
|
|
6191
6316
|
// src/commands/credit.ts
|
|
6192
|
-
import { Command as
|
|
6193
|
-
var creditCommand = new
|
|
6317
|
+
import { Command as Command63 } from "commander";
|
|
6318
|
+
var creditCommand = new Command63("credit").description("the prepaid credit left on your account and on each of your orgs").option("--org <slug>", "one org only").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
6194
6319
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6195
6320
|
try {
|
|
6196
6321
|
if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
|
|
@@ -6219,8 +6344,8 @@ function creditRow(b, me2) {
|
|
|
6219
6344
|
}
|
|
6220
6345
|
|
|
6221
6346
|
// src/commands/redeem.ts
|
|
6222
|
-
import { Command as
|
|
6223
|
-
var redeemCommand = new
|
|
6347
|
+
import { Command as Command64 } from "commander";
|
|
6348
|
+
var redeemCommand = new Command64("redeem").description("redeem a promo code for credit, on your account or (--org) an org you own").argument("<code>", "the code, like KV-7F3K-9QXM-2HBD").option("--org <slug>", "give the credit to this org, which you own; it cannot be moved later").option("--json", "print as JSON").action(async (code, opts, cmd) => {
|
|
6224
6349
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6225
6350
|
try {
|
|
6226
6351
|
if (client.target.kind === "local") throw new KvboxError("codes are redeemed on the control plane: kvbox login first");
|
|
@@ -6240,7 +6365,7 @@ var redeemCommand = new Command62("redeem").description("redeem a promo code for
|
|
|
6240
6365
|
// src/commands/deploy/index.ts
|
|
6241
6366
|
import { access as access5, readFile as readFile7 } from "fs/promises";
|
|
6242
6367
|
import { basename as basename2, resolve as resolve3 } from "path";
|
|
6243
|
-
import { Command as
|
|
6368
|
+
import { Command as Command65, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
|
|
6244
6369
|
|
|
6245
6370
|
// src/commands/deploy/config.ts
|
|
6246
6371
|
import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
@@ -7505,7 +7630,7 @@ async function readPackageJson(dir) {
|
|
|
7505
7630
|
}
|
|
7506
7631
|
|
|
7507
7632
|
// src/commands/deploy/index.ts
|
|
7508
|
-
var deployCommand = new
|
|
7633
|
+
var deployCommand = new Command65("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("--only <service>", "with several services in kvbox.json: deploy this one only (repeatable)", (v, all) => [...all ?? [], v]).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) => {
|
|
7509
7634
|
const dir = resolve3(dirArg ?? ".");
|
|
7510
7635
|
const pkg = await readPackageJson2(dir);
|
|
7511
7636
|
const facts = { indexHtml: await exists2(resolve3(dir, "index.html")), dockerfile: await exists2(resolve3(dir, "Dockerfile")) };
|
|
@@ -7662,15 +7787,15 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
|
|
|
7662
7787
|
}
|
|
7663
7788
|
|
|
7664
7789
|
// src/commands/volume/index.ts
|
|
7665
|
-
import { Command as
|
|
7790
|
+
import { Command as Command78 } from "commander";
|
|
7666
7791
|
|
|
7667
7792
|
// src/commands/volume/attach.ts
|
|
7668
|
-
import { Command as
|
|
7793
|
+
import { Command as Command66 } from "commander";
|
|
7669
7794
|
function describeMount(machine, volume2, box2) {
|
|
7670
7795
|
const path = machine.volumes?.find((v) => volume2 === v.name || volume2.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume2.slice(volume2.lastIndexOf("/") + 1));
|
|
7671
7796
|
return machine.status === "running" ? ` the box was restarted; the volume is at ${path} inside it` : ` box ${box2} is ${machine.status}; the volume is at ${path} once it runs`;
|
|
7672
7797
|
}
|
|
7673
|
-
var attachCommand = new
|
|
7798
|
+
var attachCommand = new Command66("attach").description("attach a volume to a box at /mnt/<volume> (a running box is restarted to take it)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (picked from a list when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
|
|
7674
7799
|
if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
|
|
7675
7800
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7676
7801
|
try {
|
|
@@ -7689,11 +7814,11 @@ var attachCommand = new Command64("attach").description("attach a volume to a bo
|
|
|
7689
7814
|
});
|
|
7690
7815
|
|
|
7691
7816
|
// src/commands/volume/backup/index.ts
|
|
7692
|
-
import { Command as
|
|
7817
|
+
import { Command as Command72 } from "commander";
|
|
7693
7818
|
|
|
7694
7819
|
// src/commands/volume/backup/create.ts
|
|
7695
|
-
import { Command as
|
|
7696
|
-
var createCommand4 = new
|
|
7820
|
+
import { Command as Command67 } from "commander";
|
|
7821
|
+
var createCommand4 = new Command67("create").description("back up a volume's disk to the kvbox cloud (encrypted)").argument("<volume>", "volume name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (volume2, opts, cmd) => {
|
|
7697
7822
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
7698
7823
|
try {
|
|
7699
7824
|
requireCloud3(client);
|
|
@@ -7720,8 +7845,8 @@ var createCommand4 = new Command65("create").description("back up a volume's dis
|
|
|
7720
7845
|
});
|
|
7721
7846
|
|
|
7722
7847
|
// src/commands/volume/backup/ls.ts
|
|
7723
|
-
import { Command as
|
|
7724
|
-
var lsCommand10 = new
|
|
7848
|
+
import { Command as Command68 } from "commander";
|
|
7849
|
+
var lsCommand10 = new Command68("ls").alias("list").description("list volume backups: every volume's, or one volume's").argument("[volume]", "volume name (default: every volume)").option("--json", "print as JSON").action(async (volume2, opts, cmd) => {
|
|
7725
7850
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
7726
7851
|
try {
|
|
7727
7852
|
requireCloud3(client);
|
|
@@ -7743,7 +7868,7 @@ var lsCommand10 = new Command66("ls").alias("list").description("list volume bac
|
|
|
7743
7868
|
data: b.dataBytes === null ? "-" : gbShort(b.dataBytes),
|
|
7744
7869
|
uploaded: b.uploadedBytes === null ? "-" : gbShort(b.uploadedBytes),
|
|
7745
7870
|
size: b.diskBytes === null ? "-" : gbShort(b.diskBytes),
|
|
7746
|
-
by: b.createdBy ?? "-",
|
|
7871
|
+
by: b.scheduled ? color.dim("schedule") : b.createdBy ?? "-",
|
|
7747
7872
|
taken: age(b.createdAt),
|
|
7748
7873
|
...anyError ? { error: b.error ?? "" } : {}
|
|
7749
7874
|
}))
|
|
@@ -7754,8 +7879,8 @@ var lsCommand10 = new Command66("ls").alias("list").description("list volume bac
|
|
|
7754
7879
|
});
|
|
7755
7880
|
|
|
7756
7881
|
// src/commands/volume/backup/restore.ts
|
|
7757
|
-
import { Command as
|
|
7758
|
-
var restoreCommand2 = new
|
|
7882
|
+
import { Command as Command69 } from "commander";
|
|
7883
|
+
var restoreCommand2 = new Command69("restore").description("put a backup back: the volume's data becomes the backup's (a running box holding it restarts)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").option("--json", "print the volume as JSON").action(async (volume2, id, opts, cmd) => {
|
|
7759
7884
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
7760
7885
|
try {
|
|
7761
7886
|
requireCloud3(client);
|
|
@@ -7778,8 +7903,8 @@ var restoreCommand2 = new Command67("restore").description("put a backup back: t
|
|
|
7778
7903
|
});
|
|
7779
7904
|
|
|
7780
7905
|
// src/commands/volume/backup/rm.ts
|
|
7781
|
-
import { Command as
|
|
7782
|
-
var rmCommand9 = new
|
|
7906
|
+
import { Command as Command70 } from "commander";
|
|
7907
|
+
var rmCommand9 = new Command70("rm").alias("remove").description("remove a backup for good (a volume's that is gone too)").argument("<volume>", "volume name").argument("<id>", "the backup's id (kvbox volume backup ls <volume>)").option("-y, --yes", "do not ask for confirmation").action(async (volume2, id, opts, cmd) => {
|
|
7783
7908
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
7784
7909
|
try {
|
|
7785
7910
|
requireCloud3(client);
|
|
@@ -7789,12 +7914,29 @@ var rmCommand9 = new Command68("rm").alias("remove").description("remove a backu
|
|
|
7789
7914
|
}
|
|
7790
7915
|
});
|
|
7791
7916
|
|
|
7917
|
+
// src/commands/volume/backup/schedule.ts
|
|
7918
|
+
import { Command as Command71 } from "commander";
|
|
7919
|
+
var scheduleCommand2 = scheduleFlags(
|
|
7920
|
+
new Command71("schedule").description("show or switch a volume's nightly backup (daily, UTC; off until you turn it on)").argument("<volume>", "volume name")
|
|
7921
|
+
).action(async (volume2, flags, cmd) => {
|
|
7922
|
+
const change = changeOf(flags);
|
|
7923
|
+
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
7924
|
+
try {
|
|
7925
|
+
requireCloud3(client);
|
|
7926
|
+
const changed = Object.keys(change).length > 0;
|
|
7927
|
+
const schedule = changed ? await client.setVolumeBackupSchedule(volume2, change) : await client.volumeBackupSchedule(volume2);
|
|
7928
|
+
printSchedule(`volume ${volume2}`, withOrg(client, `kvbox volume backup schedule ${volume2}`), schedule, flags, changed);
|
|
7929
|
+
} finally {
|
|
7930
|
+
await client.close();
|
|
7931
|
+
}
|
|
7932
|
+
});
|
|
7933
|
+
|
|
7792
7934
|
// src/commands/volume/backup/index.ts
|
|
7793
|
-
var backupCommand2 = new
|
|
7935
|
+
var backupCommand2 = new Command72("backup").description("back up a volume's disk to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand4).addCommand(lsCommand10).addCommand(restoreCommand2).addCommand(rmCommand9).addCommand(scheduleCommand2);
|
|
7794
7936
|
for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
|
|
7795
7937
|
|
|
7796
7938
|
// src/commands/volume/create.ts
|
|
7797
|
-
import { Command as
|
|
7939
|
+
import { Command as Command73 } from "commander";
|
|
7798
7940
|
function parseGib2(text2, label = "--size") {
|
|
7799
7941
|
const mib = parseMib(text2);
|
|
7800
7942
|
if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
|
|
@@ -7810,7 +7952,7 @@ function sizeProblem(answer) {
|
|
|
7810
7952
|
return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
|
|
7811
7953
|
}
|
|
7812
7954
|
}
|
|
7813
|
-
var createCommand5 = new
|
|
7955
|
+
var createCommand5 = new Command73("create").alias("new").description("create a volume for a box: an empty disk of its own at /mnt/<name> inside it (a running box is restarted)").argument("[name]", "volume name (1-12 chars; the box mounts it at /mnt/<name>; asked for when left out)").option("--size <gb>", "size in GB, like 50 or 50GB (whole GB; it only occupies what is written)").option("--box <box>", "the box it is for: made on that box's host and attached to it (required on kvbox.sh; optional with --local)").option("--json", "print the volume as JSON").action(async (nameArg, opts, cmd) => {
|
|
7814
7956
|
const ask = interactive();
|
|
7815
7957
|
if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
|
|
7816
7958
|
const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
|
|
@@ -7843,8 +7985,8 @@ var createCommand5 = new Command70("create").alias("new").description("create a
|
|
|
7843
7985
|
});
|
|
7844
7986
|
|
|
7845
7987
|
// src/commands/volume/detach.ts
|
|
7846
|
-
import { Command as
|
|
7847
|
-
var detachCommand = new
|
|
7988
|
+
import { Command as Command74 } from "commander";
|
|
7989
|
+
var detachCommand = new Command74("detach").description("detach a volume from a box; its data is kept (a running box is restarted)").argument("[volume]", "volume name (picked from a list when left out)").argument("[box]", "box name (the one the volume is on when left out)").option("--json", "print the box as JSON").action(async (volumeArg, boxArg, opts, cmd) => {
|
|
7848
7990
|
if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
|
|
7849
7991
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7850
7992
|
try {
|
|
@@ -7869,8 +8011,8 @@ var detachCommand = new Command71("detach").description("detach a volume from a
|
|
|
7869
8011
|
});
|
|
7870
8012
|
|
|
7871
8013
|
// src/commands/volume/grow.ts
|
|
7872
|
-
import { Command as
|
|
7873
|
-
var growCommand = new
|
|
8014
|
+
import { Command as Command75 } from "commander";
|
|
8015
|
+
var growCommand = new Command75("grow").alias("resize").description("make a volume larger (a running box holding it is restarted once)").argument("<volume>", "volume name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the volume as JSON").action(async (name, size, opts, cmd) => {
|
|
7874
8016
|
const sizeGib = parseGib2(size, "size");
|
|
7875
8017
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7876
8018
|
try {
|
|
@@ -7883,8 +8025,8 @@ var growCommand = new Command72("grow").alias("resize").description("make a volu
|
|
|
7883
8025
|
});
|
|
7884
8026
|
|
|
7885
8027
|
// src/commands/volume/ls.ts
|
|
7886
|
-
import { Command as
|
|
7887
|
-
var lsCommand11 = new
|
|
8028
|
+
import { Command as Command76 } from "commander";
|
|
8029
|
+
var lsCommand11 = new Command76("ls").alias("list").description("list volumes: size, what they occupy, which box has them").option("-a, --all", "every volume on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
7888
8030
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7889
8031
|
try {
|
|
7890
8032
|
const cloud = client.target.kind === "cloud";
|
|
@@ -7915,8 +8057,8 @@ var lsCommand11 = new Command73("ls").alias("list").description("list volumes: s
|
|
|
7915
8057
|
});
|
|
7916
8058
|
|
|
7917
8059
|
// src/commands/volume/rm.ts
|
|
7918
|
-
import { Command as
|
|
7919
|
-
var rmCommand10 = new
|
|
8060
|
+
import { Command as Command77 } from "commander";
|
|
8061
|
+
var rmCommand10 = new Command77("rm").alias("remove").description("delete a volume and everything on it (detach it first)").argument("<name>", "volume name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
7920
8062
|
if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
|
|
7921
8063
|
info("cancelled");
|
|
7922
8064
|
process.exitCode = 1;
|
|
@@ -7932,18 +8074,18 @@ var rmCommand10 = new Command74("rm").alias("remove").description("delete a volu
|
|
|
7932
8074
|
});
|
|
7933
8075
|
|
|
7934
8076
|
// src/commands/volume/index.ts
|
|
7935
|
-
var volumeCommand = new
|
|
8077
|
+
var volumeCommand = new Command78("volume").aliases(["volumes", "vol"]).description("disks of their own: create one, attach it to a box at /mnt/<name>, move it to another box later").addCommand(createCommand5).addCommand(lsCommand11).addCommand(attachCommand).addCommand(detachCommand).addCommand(growCommand).addCommand(rmCommand10);
|
|
7936
8078
|
for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
|
|
7937
8079
|
volumeCommand.addCommand(backupCommand2);
|
|
7938
8080
|
|
|
7939
8081
|
// src/commands/bucket/index.ts
|
|
7940
|
-
import { Command as
|
|
8082
|
+
import { Command as Command95 } from "commander";
|
|
7941
8083
|
|
|
7942
8084
|
// src/commands/bucket/backup/index.ts
|
|
7943
|
-
import { Command as
|
|
8085
|
+
import { Command as Command84 } from "commander";
|
|
7944
8086
|
|
|
7945
8087
|
// src/commands/bucket/backup/create.ts
|
|
7946
|
-
import { Command as
|
|
8088
|
+
import { Command as Command79 } from "commander";
|
|
7947
8089
|
|
|
7948
8090
|
// src/commands/bucket/shared.ts
|
|
7949
8091
|
async function bucketClient(cmd) {
|
|
@@ -7969,7 +8111,7 @@ function printRows(rows2) {
|
|
|
7969
8111
|
}
|
|
7970
8112
|
|
|
7971
8113
|
// src/commands/bucket/backup/create.ts
|
|
7972
|
-
var createCommand6 = new
|
|
8114
|
+
var createCommand6 = new Command79("create").description("back up your object storage (every bucket and key) to the kvbox cloud, encrypted").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (opts, cmd) => {
|
|
7973
8115
|
const client = await bucketClient(cmd);
|
|
7974
8116
|
const ls = "kvbox bucket backup ls";
|
|
7975
8117
|
try {
|
|
@@ -7997,8 +8139,8 @@ var createCommand6 = new Command76("create").description("back up your object st
|
|
|
7997
8139
|
});
|
|
7998
8140
|
|
|
7999
8141
|
// src/commands/bucket/backup/ls.ts
|
|
8000
|
-
import { Command as
|
|
8001
|
-
var lsCommand12 = new
|
|
8142
|
+
import { Command as Command80 } from "commander";
|
|
8143
|
+
var lsCommand12 = new Command80("ls").alias("list").description("list the backups of your object storage").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
8002
8144
|
const client = await bucketClient(cmd);
|
|
8003
8145
|
try {
|
|
8004
8146
|
const list = await client.storageBackups();
|
|
@@ -8019,7 +8161,7 @@ var lsCommand12 = new Command77("ls").alias("list").description("list the backup
|
|
|
8019
8161
|
keys: b.keys,
|
|
8020
8162
|
data: b.dataBytes === null ? "-" : gbShort(b.dataBytes),
|
|
8021
8163
|
uploaded: b.uploadedBytes === null ? "-" : gbShort(b.uploadedBytes),
|
|
8022
|
-
by: b.createdBy ?? "-",
|
|
8164
|
+
by: b.scheduled ? color.dim("schedule") : b.createdBy ?? "-",
|
|
8023
8165
|
taken: age(b.createdAt),
|
|
8024
8166
|
...anyError ? { error: b.error ?? "" } : {}
|
|
8025
8167
|
}))
|
|
@@ -8030,8 +8172,8 @@ var lsCommand12 = new Command77("ls").alias("list").description("list the backup
|
|
|
8030
8172
|
});
|
|
8031
8173
|
|
|
8032
8174
|
// src/commands/bucket/backup/restore.ts
|
|
8033
|
-
import { Command as
|
|
8034
|
-
var restoreCommand3 = new
|
|
8175
|
+
import { Command as Command81 } from "commander";
|
|
8176
|
+
var restoreCommand3 = new Command81("restore").description("put a backup back: every bucket and key becomes the backup's (the storage restarts)").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").option("--json", "print what changed as JSON").action(async (id, opts, cmd) => {
|
|
8035
8177
|
const client = await bucketClient(cmd);
|
|
8036
8178
|
try {
|
|
8037
8179
|
const backup = await client.storageBackup(id);
|
|
@@ -8061,8 +8203,8 @@ var restoreCommand3 = new Command78("restore").description("put a backup back: e
|
|
|
8061
8203
|
});
|
|
8062
8204
|
|
|
8063
8205
|
// src/commands/bucket/backup/rm.ts
|
|
8064
|
-
import { Command as
|
|
8065
|
-
var rmCommand11 = new
|
|
8206
|
+
import { Command as Command82 } from "commander";
|
|
8207
|
+
var rmCommand11 = new Command82("rm").alias("remove").description("remove a backup of your object storage for good").argument("<id>", "the backup's id (kvbox bucket backup ls)").option("-y, --yes", "do not ask for confirmation").action(async (id, opts, cmd) => {
|
|
8066
8208
|
const client = await bucketClient(cmd);
|
|
8067
8209
|
try {
|
|
8068
8210
|
const backup = (await client.storageBackups()).find((b) => b.id === id);
|
|
@@ -8080,12 +8222,28 @@ var rmCommand11 = new Command79("rm").alias("remove").description("remove a back
|
|
|
8080
8222
|
}
|
|
8081
8223
|
});
|
|
8082
8224
|
|
|
8225
|
+
// src/commands/bucket/backup/schedule.ts
|
|
8226
|
+
import { Command as Command83 } from "commander";
|
|
8227
|
+
var scheduleCommand3 = scheduleFlags(new Command83("schedule").description("show or switch the nightly backup of your object storage (daily, UTC; off until you turn it on)")).action(
|
|
8228
|
+
async (flags, cmd) => {
|
|
8229
|
+
const change = changeOf(flags);
|
|
8230
|
+
const client = await bucketClient(cmd);
|
|
8231
|
+
try {
|
|
8232
|
+
const changed = Object.keys(change).length > 0;
|
|
8233
|
+
const schedule = changed ? await client.setStorageBackupSchedule(change) : await client.storageBackupSchedule();
|
|
8234
|
+
printSchedule("object storage", withOrg(client, "kvbox bucket backup schedule"), schedule, flags, changed);
|
|
8235
|
+
} finally {
|
|
8236
|
+
await client.close();
|
|
8237
|
+
}
|
|
8238
|
+
}
|
|
8239
|
+
);
|
|
8240
|
+
|
|
8083
8241
|
// src/commands/bucket/backup/index.ts
|
|
8084
|
-
var backupCommand3 = new
|
|
8242
|
+
var backupCommand3 = new Command84("backup").aliases(["backups"]).description("back up your object storage to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand6).addCommand(lsCommand12).addCommand(restoreCommand3).addCommand(rmCommand11).addCommand(scheduleCommand3);
|
|
8085
8243
|
|
|
8086
8244
|
// src/commands/bucket/create.ts
|
|
8087
|
-
import { Command as
|
|
8088
|
-
var createCommand7 = new
|
|
8245
|
+
import { Command as Command85 } from "commander";
|
|
8246
|
+
var createCommand7 = new Command85("create").description("make a bucket (the first one also makes your object storage)").argument("<name>", "bucket name: 3-63 lowercase letters, digits and '-'").option("--size <GB>", "how much your object storage may hold, when this is your first bucket (default 10)").option("--region <region>", "the S3 region of your object storage (ro-west-1, de-center-1), when this is your first bucket").option("--near <box>", "put the object storage on the host of this box, when this is your first bucket").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8089
8247
|
const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
|
|
8090
8248
|
const client = await bucketClient(cmd);
|
|
8091
8249
|
try {
|
|
@@ -8105,8 +8263,8 @@ var createCommand7 = new Command81("create").description("make a bucket (the fir
|
|
|
8105
8263
|
});
|
|
8106
8264
|
|
|
8107
8265
|
// src/commands/bucket/grow.ts
|
|
8108
|
-
import { Command as
|
|
8109
|
-
var growCommand2 = new
|
|
8266
|
+
import { Command as Command86 } from "commander";
|
|
8267
|
+
var growCommand2 = new Command86("grow").description("make your object storage larger (all your buckets share it; it restarts once)").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print the object storage as JSON").action(async (size, opts, cmd) => {
|
|
8110
8268
|
const sizeGib = parseGib2(size, "size");
|
|
8111
8269
|
const client = await bucketClient(cmd);
|
|
8112
8270
|
try {
|
|
@@ -8119,8 +8277,8 @@ var growCommand2 = new Command82("grow").description("make your object storage l
|
|
|
8119
8277
|
});
|
|
8120
8278
|
|
|
8121
8279
|
// src/commands/bucket/info.ts
|
|
8122
|
-
import { Command as
|
|
8123
|
-
var infoCommand = new
|
|
8280
|
+
import { Command as Command87 } from "commander";
|
|
8281
|
+
var infoCommand = new Command87("info").description("one bucket: its address, what it holds, how full your object storage is").argument("<name>", "bucket name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8124
8282
|
const client = await bucketClient(cmd);
|
|
8125
8283
|
try {
|
|
8126
8284
|
const b = await client.getBucket(name);
|
|
@@ -8150,11 +8308,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
|
|
|
8150
8308
|
});
|
|
8151
8309
|
|
|
8152
8310
|
// src/commands/bucket/key/index.ts
|
|
8153
|
-
import { Command as
|
|
8311
|
+
import { Command as Command91 } from "commander";
|
|
8154
8312
|
|
|
8155
8313
|
// src/commands/bucket/key/create.ts
|
|
8156
|
-
import { Command as
|
|
8157
|
-
var createCommand8 = new
|
|
8314
|
+
import { Command as Command88 } from "commander";
|
|
8315
|
+
var createCommand8 = new Command88("create").description("make an access key for a bucket (the secret is shown once)").argument("<bucket>", "bucket name").option("--name <label>", "what to call the key, to tell it from the others").option("--read-only", "the key reads the bucket but cannot write to it").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
|
|
8158
8316
|
const client = await bucketClient(cmd);
|
|
8159
8317
|
try {
|
|
8160
8318
|
const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
|
|
@@ -8177,8 +8335,8 @@ var createCommand8 = new Command84("create").description("make an access key for
|
|
|
8177
8335
|
});
|
|
8178
8336
|
|
|
8179
8337
|
// src/commands/bucket/key/ls.ts
|
|
8180
|
-
import { Command as
|
|
8181
|
-
var lsCommand13 = new
|
|
8338
|
+
import { Command as Command89 } from "commander";
|
|
8339
|
+
var lsCommand13 = new Command89("ls").alias("list").description("list a bucket's access keys (never their secrets)").argument("<bucket>", "bucket name").option("--json", "print as JSON").action(async (bucket, opts, cmd) => {
|
|
8182
8340
|
const client = await bucketClient(cmd);
|
|
8183
8341
|
try {
|
|
8184
8342
|
const keys = await client.listBucketKeys(bucket);
|
|
@@ -8197,8 +8355,8 @@ var lsCommand13 = new Command85("ls").alias("list").description("list a bucket's
|
|
|
8197
8355
|
});
|
|
8198
8356
|
|
|
8199
8357
|
// src/commands/bucket/key/rm.ts
|
|
8200
|
-
import { Command as
|
|
8201
|
-
var rmCommand12 = new
|
|
8358
|
+
import { Command as Command90 } from "commander";
|
|
8359
|
+
var rmCommand12 = new Command90("rm").alias("remove").description("delete an access key: whatever uses it stops reaching the bucket").argument("<bucket>", "bucket name").argument("<access-key>", "the access key id (kvbox bucket key ls)").option("-y, --yes", "do not ask for confirmation").action(async (bucket, id, opts, cmd) => {
|
|
8202
8360
|
const client = await bucketClient(cmd);
|
|
8203
8361
|
try {
|
|
8204
8362
|
if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
|
|
@@ -8214,11 +8372,11 @@ var rmCommand12 = new Command86("rm").alias("remove").description("delete an acc
|
|
|
8214
8372
|
});
|
|
8215
8373
|
|
|
8216
8374
|
// src/commands/bucket/key/index.ts
|
|
8217
|
-
var keyCommand2 = new
|
|
8375
|
+
var keyCommand2 = new Command91("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand8).addCommand(lsCommand13).addCommand(rmCommand12);
|
|
8218
8376
|
|
|
8219
8377
|
// src/commands/bucket/ls.ts
|
|
8220
|
-
import { Command as
|
|
8221
|
-
var lsCommand14 = new
|
|
8378
|
+
import { Command as Command92 } from "commander";
|
|
8379
|
+
var lsCommand14 = new Command92("ls").alias("list").description("list buckets, and the object storage they are in").option("-a, --all", "every bucket on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
8222
8380
|
const client = await bucketClient(cmd);
|
|
8223
8381
|
try {
|
|
8224
8382
|
const buckets = await client.listBuckets({ all: opts.all });
|
|
@@ -8249,8 +8407,8 @@ var lsCommand14 = new Command88("ls").alias("list").description("list buckets, a
|
|
|
8249
8407
|
});
|
|
8250
8408
|
|
|
8251
8409
|
// src/commands/bucket/public.ts
|
|
8252
|
-
import { Command as
|
|
8253
|
-
var publicCommand = new
|
|
8410
|
+
import { Command as Command93 } from "commander";
|
|
8411
|
+
var publicCommand = new Command93("public").description("let anyone read a bucket's files at its own HTTPS address (on), or make it private again (off)").argument("<name>", "bucket name").argument("<state>", "on (public) or off (private)").option("--sub <name>", "the address to use, <name>.kvbox.app (default: <bucket>-<account>)").option("--json", "print the bucket as JSON").action(async (name, state, opts, cmd) => {
|
|
8254
8412
|
if (state !== "on" && state !== "off") throw new KvboxError(`"${state}": say on or off`);
|
|
8255
8413
|
const on = state === "on";
|
|
8256
8414
|
if (!on && opts.sub !== void 0) throw new KvboxError("--sub goes with on");
|
|
@@ -8278,8 +8436,8 @@ var publicCommand = new Command89("public").description("let anyone read a bucke
|
|
|
8278
8436
|
});
|
|
8279
8437
|
|
|
8280
8438
|
// src/commands/bucket/rm.ts
|
|
8281
|
-
import { Command as
|
|
8282
|
-
var rmCommand13 = new
|
|
8439
|
+
import { Command as Command94 } from "commander";
|
|
8440
|
+
var rmCommand13 = new Command94("rm").alias("remove").description("delete an empty bucket and its keys (the last one takes your object storage with it)").argument("<name>", "bucket name").option("--force", "your last bucket only: delete it with everything in it").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
8283
8441
|
const client = await bucketClient(cmd);
|
|
8284
8442
|
try {
|
|
8285
8443
|
const question = opts.force ? `Delete bucket ${name} with everything in it, and the object storage it is in?` : `Delete bucket ${name} and its keys?`;
|
|
@@ -8298,18 +8456,18 @@ var rmCommand13 = new Command90("rm").alias("remove").description("delete an emp
|
|
|
8298
8456
|
});
|
|
8299
8457
|
|
|
8300
8458
|
// src/commands/bucket/index.ts
|
|
8301
|
-
var bucketCommand = new
|
|
8302
|
-
var
|
|
8459
|
+
var bucketCommand = new Command95("bucket").aliases(["buckets"]).description("object storage: S3 buckets for your files, and the access keys your apps use").addCommand(createCommand7).addCommand(lsCommand14).addCommand(infoCommand).addCommand(growCommand2).addCommand(publicCommand).addCommand(rmCommand13).addCommand(keyCommand2).addCommand(backupCommand3);
|
|
8460
|
+
var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
|
|
8303
8461
|
for (const cmd of bucketCommand.commands) {
|
|
8304
|
-
if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(
|
|
8305
|
-
else
|
|
8462
|
+
if (cmd === keyCommand2 || cmd === backupCommand3) cmd.commands.forEach(withOrg2);
|
|
8463
|
+
else withOrg2(cmd);
|
|
8306
8464
|
}
|
|
8307
8465
|
|
|
8308
8466
|
// src/commands/cron/index.ts
|
|
8309
|
-
import { Command as
|
|
8467
|
+
import { Command as Command108 } from "commander";
|
|
8310
8468
|
|
|
8311
8469
|
// src/commands/cron/create.ts
|
|
8312
|
-
import { Command as
|
|
8470
|
+
import { Command as Command96 } from "commander";
|
|
8313
8471
|
|
|
8314
8472
|
// src/commands/cron/shared.ts
|
|
8315
8473
|
async function cronClient(cmd) {
|
|
@@ -8370,7 +8528,7 @@ function printRows2(rows2) {
|
|
|
8370
8528
|
var noTriggers = (service) => info(`cron service ${service} has no triggers yet; add one with: kvbox cron trigger add ${service} <box> "0 6 * * *" --port 3000 (or --run "<command>")`);
|
|
8371
8529
|
|
|
8372
8530
|
// src/commands/cron/create.ts
|
|
8373
|
-
var createCommand9 = new
|
|
8531
|
+
var createCommand9 = new Command96("create").description("make a cron service: a named set of triggers").argument("<name>", "what to call it (lowercase letters, digits and '-')").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8374
8532
|
const client = await cronClient(cmd);
|
|
8375
8533
|
try {
|
|
8376
8534
|
const service = await client.createCronService(name);
|
|
@@ -8387,8 +8545,8 @@ var createCommand9 = new Command92("create").description("make a cron service: a
|
|
|
8387
8545
|
});
|
|
8388
8546
|
|
|
8389
8547
|
// src/commands/cron/info.ts
|
|
8390
|
-
import { Command as
|
|
8391
|
-
var infoCommand2 = new
|
|
8548
|
+
import { Command as Command97 } from "commander";
|
|
8549
|
+
var infoCommand2 = new Command97("info").alias("get").description("show a cron service and its triggers").argument("<name>", "cron service name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8392
8550
|
const client = await cronClient(cmd);
|
|
8393
8551
|
try {
|
|
8394
8552
|
const service = await client.getCronService(name);
|
|
@@ -8412,8 +8570,8 @@ var infoCommand2 = new Command93("info").alias("get").description("show a cron s
|
|
|
8412
8570
|
});
|
|
8413
8571
|
|
|
8414
8572
|
// src/commands/cron/ls.ts
|
|
8415
|
-
import { Command as
|
|
8416
|
-
var lsCommand15 = new
|
|
8573
|
+
import { Command as Command98 } from "commander";
|
|
8574
|
+
var lsCommand15 = new Command98("ls").alias("list").description("list cron services").option("-a, --all", "every cron service on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
8417
8575
|
const client = await cronClient(cmd);
|
|
8418
8576
|
try {
|
|
8419
8577
|
const services = await client.listCronServices({ all: opts.all });
|
|
@@ -8433,8 +8591,8 @@ var lsCommand15 = new Command94("ls").alias("list").description("list cron servi
|
|
|
8433
8591
|
});
|
|
8434
8592
|
|
|
8435
8593
|
// src/commands/cron/rm.ts
|
|
8436
|
-
import { Command as
|
|
8437
|
-
var rmCommand14 = new
|
|
8594
|
+
import { Command as Command99 } from "commander";
|
|
8595
|
+
var rmCommand14 = new Command99("rm").alias("remove").description("delete a cron service, its triggers and their run history").argument("<name>", "cron service name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
8438
8596
|
const client = await cronClient(cmd);
|
|
8439
8597
|
try {
|
|
8440
8598
|
if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
|
|
@@ -8450,10 +8608,10 @@ var rmCommand14 = new Command95("rm").alias("remove").description("delete a cron
|
|
|
8450
8608
|
});
|
|
8451
8609
|
|
|
8452
8610
|
// src/commands/cron/trigger/index.ts
|
|
8453
|
-
import { Command as
|
|
8611
|
+
import { Command as Command107 } from "commander";
|
|
8454
8612
|
|
|
8455
8613
|
// src/commands/cron/trigger/add.ts
|
|
8456
|
-
import { Command as
|
|
8614
|
+
import { Command as Command100 } from "commander";
|
|
8457
8615
|
function portOf(value) {
|
|
8458
8616
|
const n2 = Number(value);
|
|
8459
8617
|
if (!Number.isInteger(n2) || n2 < 1 || n2 > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
|
|
@@ -8473,7 +8631,7 @@ function timeoutOf(value) {
|
|
|
8473
8631
|
if (sec > MAX_CRON_COMMAND_TIMEOUT_SEC) throw new KvboxError(`--timeout ${value}: a command may run for ${MAX_CRON_COMMAND_TIMEOUT_SEC / 60} minutes at most`);
|
|
8474
8632
|
return sec;
|
|
8475
8633
|
}
|
|
8476
|
-
var addCommand3 = new
|
|
8634
|
+
var addCommand3 = new Command100("add").description("add a trigger: on a schedule, call a port of a box or run a command in it").argument("<service>", "cron service name").argument("<box>", "the box it acts on").argument("<expr>", 'cron expression in quotes, five fields: "0 6 * * *" is every day at 06:00').option("--port <n>", "call this port, the one your app listens on in the box").option("--path <path>", "with --port: path and query to request (default: /)").option("--method <method>", `with --port: HTTP method, ${CRON_METHODS.join(" or ")} (default: POST)`).option("--run <command>", 'or run this command in the box, in quotes: "node ~/app/embed.js"').option("--timeout <duration>", `with --run: stop the command after this long (90s, 10m, 1h; default: ${DEFAULT_CRON_COMMAND_TIMEOUT_SEC / 60}m)`).option("--tz <zone>", "time zone the schedule is read in, like Europe/Bucharest", "UTC").option("--json", "print as JSON").action(async (service, box2, expr, opts, cmd) => {
|
|
8477
8635
|
let action;
|
|
8478
8636
|
if (opts.run !== void 0) {
|
|
8479
8637
|
if (opts.port !== void 0 || opts.path !== void 0 || opts.method !== void 0) throw new KvboxError("a trigger runs a command or calls a port: use --run, or --port with --path and --method, not both");
|
|
@@ -8500,8 +8658,8 @@ var addCommand3 = new Command96("add").description("add a trigger: on a schedule
|
|
|
8500
8658
|
});
|
|
8501
8659
|
|
|
8502
8660
|
// src/commands/cron/trigger/ls.ts
|
|
8503
|
-
import { Command as
|
|
8504
|
-
var lsCommand16 = new
|
|
8661
|
+
import { Command as Command101 } from "commander";
|
|
8662
|
+
var lsCommand16 = new Command101("ls").alias("list").description("list a cron service's triggers").argument("<service>", "cron service name").option("--json", "print as JSON").action(async (service, opts, cmd) => {
|
|
8505
8663
|
const client = await cronClient(cmd);
|
|
8506
8664
|
try {
|
|
8507
8665
|
const triggers = await client.listCronTriggers(service);
|
|
@@ -8517,8 +8675,8 @@ var lsCommand16 = new Command97("ls").alias("list").description("list a cron ser
|
|
|
8517
8675
|
});
|
|
8518
8676
|
|
|
8519
8677
|
// src/commands/cron/trigger/pause.ts
|
|
8520
|
-
import { Command as
|
|
8521
|
-
var pauseCommand2 = new
|
|
8678
|
+
import { Command as Command102 } from "commander";
|
|
8679
|
+
var pauseCommand2 = new Command102("pause").description("stop a trigger from firing until it is resumed").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
8522
8680
|
const client = await cronClient(cmd);
|
|
8523
8681
|
try {
|
|
8524
8682
|
const trigger = await client.setCronTriggerEnabled(service, id, false);
|
|
@@ -8533,8 +8691,8 @@ var pauseCommand2 = new Command98("pause").description("stop a trigger from firi
|
|
|
8533
8691
|
});
|
|
8534
8692
|
|
|
8535
8693
|
// src/commands/cron/trigger/resume.ts
|
|
8536
|
-
import { Command as
|
|
8537
|
-
var resumeCommand2 = new
|
|
8694
|
+
import { Command as Command103 } from "commander";
|
|
8695
|
+
var resumeCommand2 = new Command103("resume").description("let a paused trigger fire again").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
8538
8696
|
const client = await cronClient(cmd);
|
|
8539
8697
|
try {
|
|
8540
8698
|
const trigger = await client.setCronTriggerEnabled(service, id, true);
|
|
@@ -8549,8 +8707,8 @@ var resumeCommand2 = new Command99("resume").description("let a paused trigger f
|
|
|
8549
8707
|
});
|
|
8550
8708
|
|
|
8551
8709
|
// src/commands/cron/trigger/rm.ts
|
|
8552
|
-
import { Command as
|
|
8553
|
-
var rmCommand15 = new
|
|
8710
|
+
import { Command as Command104 } from "commander";
|
|
8711
|
+
var rmCommand15 = new Command104("rm").alias("remove").description("delete a trigger and its run history").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-y, --yes", "do not ask for confirmation").action(async (service, id, opts, cmd) => {
|
|
8554
8712
|
const client = await cronClient(cmd);
|
|
8555
8713
|
try {
|
|
8556
8714
|
if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
|
|
@@ -8566,8 +8724,8 @@ var rmCommand15 = new Command100("rm").alias("remove").description("delete a tri
|
|
|
8566
8724
|
});
|
|
8567
8725
|
|
|
8568
8726
|
// src/commands/cron/trigger/run.ts
|
|
8569
|
-
import { Command as
|
|
8570
|
-
var runCommand = new
|
|
8727
|
+
import { Command as Command105 } from "commander";
|
|
8728
|
+
var runCommand = new Command105("run").description("fire a trigger now, once, besides its schedule").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
8571
8729
|
const client = await cronClient(cmd);
|
|
8572
8730
|
try {
|
|
8573
8731
|
const trigger = await client.runCronTrigger(service, id);
|
|
@@ -8583,13 +8741,13 @@ var runCommand = new Command101("run").description("fire a trigger now, once, be
|
|
|
8583
8741
|
});
|
|
8584
8742
|
|
|
8585
8743
|
// src/commands/cron/trigger/runs.ts
|
|
8586
|
-
import { Command as
|
|
8744
|
+
import { Command as Command106 } from "commander";
|
|
8587
8745
|
function limitOf(value) {
|
|
8588
8746
|
const n2 = Number(value);
|
|
8589
8747
|
if (!Number.isInteger(n2) || n2 < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
|
|
8590
8748
|
return n2;
|
|
8591
8749
|
}
|
|
8592
|
-
var runsCommand = new
|
|
8750
|
+
var runsCommand = new Command106("runs").aliases(["logs"]).description("show how a trigger's last runs ended").argument("<service>", "cron service name").argument("<id>", "trigger id (kvbox cron trigger ls)").option("-n, --limit <count>", "how many runs to show", "20").option("--json", "print as JSON").action(async (service, id, opts, cmd) => {
|
|
8593
8751
|
const limit = limitOf(opts.limit);
|
|
8594
8752
|
const client = await cronClient(cmd);
|
|
8595
8753
|
try {
|
|
@@ -8619,24 +8777,24 @@ var runsCommand = new Command102("runs").aliases(["logs"]).description("show how
|
|
|
8619
8777
|
});
|
|
8620
8778
|
|
|
8621
8779
|
// src/commands/cron/trigger/index.ts
|
|
8622
|
-
var triggerCommand = new
|
|
8780
|
+
var triggerCommand = new Command107("trigger").aliases(["triggers"]).description("a cron service's triggers: a schedule and the request it sends to a box").addCommand(addCommand3).addCommand(lsCommand16).addCommand(runsCommand).addCommand(runCommand).addCommand(pauseCommand2).addCommand(resumeCommand2).addCommand(rmCommand15);
|
|
8623
8781
|
|
|
8624
8782
|
// src/commands/cron/index.ts
|
|
8625
|
-
var cronCommand = new
|
|
8626
|
-
var
|
|
8783
|
+
var cronCommand = new Command108("cron").description("cron: call a box on a schedule, waking it first if it sleeps").addCommand(createCommand9).addCommand(lsCommand15).addCommand(infoCommand2).addCommand(rmCommand14).addCommand(triggerCommand);
|
|
8784
|
+
var withOrg3 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
|
|
8627
8785
|
for (const cmd of cronCommand.commands) {
|
|
8628
|
-
if (cmd === triggerCommand) cmd.commands.forEach(
|
|
8629
|
-
else
|
|
8786
|
+
if (cmd === triggerCommand) cmd.commands.forEach(withOrg3);
|
|
8787
|
+
else withOrg3(cmd);
|
|
8630
8788
|
}
|
|
8631
8789
|
|
|
8632
8790
|
// src/commands/managed/kind.ts
|
|
8633
|
-
import { Command as
|
|
8791
|
+
import { Command as Command127 } from "commander";
|
|
8634
8792
|
|
|
8635
8793
|
// src/commands/managed/backup/index.ts
|
|
8636
|
-
import { Command as
|
|
8794
|
+
import { Command as Command115 } from "commander";
|
|
8637
8795
|
|
|
8638
8796
|
// src/commands/managed/backup/create.ts
|
|
8639
|
-
import { Command as
|
|
8797
|
+
import { Command as Command110 } from "commander";
|
|
8640
8798
|
|
|
8641
8799
|
// src/commands/managed/shared.ts
|
|
8642
8800
|
import "commander";
|
|
@@ -8697,18 +8855,7 @@ function infoRows(spec, m, user) {
|
|
|
8697
8855
|
return rows2;
|
|
8698
8856
|
}
|
|
8699
8857
|
function scheduleText2(spec, name, s, now = Date.now()) {
|
|
8700
|
-
|
|
8701
|
-
if (!s.enabled) return color.dim(`not on their own (kvbox ${spec.command} backup schedule ${name} --on, at ${at})`);
|
|
8702
|
-
const nextMs = s.nextAt === null ? null : Date.parse(s.nextAt) - now;
|
|
8703
|
-
const next = s.nextAt === null || nextMs === null ? "" : nextMs > -6e4 ? `, next in ${inHours(nextMs)}` : `, ${color.yellow(`due since ${s.nextAt.slice(0, 16).replace("T", " ")} UTC, waiting for the backup job`)}`;
|
|
8704
|
-
const failed = s.lastError !== null ? color.yellow(` last one failed: ${s.lastError}`) : "";
|
|
8705
|
-
return `daily at ${at}${next}${failed}`;
|
|
8706
|
-
}
|
|
8707
|
-
function inHours(ms2) {
|
|
8708
|
-
const min = Math.max(0, Math.round(ms2 / 6e4));
|
|
8709
|
-
if (min < 60) return `${min}m`;
|
|
8710
|
-
const h = Math.floor(min / 60);
|
|
8711
|
-
return h < 24 ? `${h}h ${min % 60}m` : `${Math.floor(h / 24)}d ${h % 24}h`;
|
|
8858
|
+
return scheduleLine(`kvbox ${spec.command} backup schedule ${name}`, s, now);
|
|
8712
8859
|
}
|
|
8713
8860
|
function printRows3(rows2) {
|
|
8714
8861
|
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
@@ -8734,7 +8881,7 @@ function parseStorage(text2, flag) {
|
|
|
8734
8881
|
}
|
|
8735
8882
|
|
|
8736
8883
|
// src/commands/managed/backup/create.ts
|
|
8737
|
-
var createCommand10 = (spec) => new
|
|
8884
|
+
var createCommand10 = (spec) => new Command110("create").description("back up a database to the kvbox cloud (encrypted)").argument("<db>", "its name").option("--wait", "stay until the backup is ready (by default it runs in the background)").option("--json", "print the backup as JSON").action(async (name, opts, cmd) => {
|
|
8738
8885
|
const client = await managedClient(cmd);
|
|
8739
8886
|
const ls = `kvbox ${spec.command} backup ls ${name}`;
|
|
8740
8887
|
try {
|
|
@@ -8761,7 +8908,7 @@ var createCommand10 = (spec) => new Command106("create").description("back up a
|
|
|
8761
8908
|
});
|
|
8762
8909
|
|
|
8763
8910
|
// src/commands/managed/backup/ls.ts
|
|
8764
|
-
import { Command as
|
|
8911
|
+
import { Command as Command111 } from "commander";
|
|
8765
8912
|
var lsCommand17 = (spec) => {
|
|
8766
8913
|
const removedOnes = async (err, name, client) => {
|
|
8767
8914
|
if (!(err instanceof CallError && err.status === 404)) throw err;
|
|
@@ -8770,7 +8917,7 @@ var lsCommand17 = (spec) => {
|
|
|
8770
8917
|
const own = name.includes("/") ? [] : gone.filter((b) => b.owner === me(client));
|
|
8771
8918
|
return own.length > 0 ? own : gone;
|
|
8772
8919
|
};
|
|
8773
|
-
return new
|
|
8920
|
+
return new Command111("ls").alias("list").description("list backups: every database's, or one database's").argument("[db]", "its name (default: every database)").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8774
8921
|
const client = await managedClient(cmd);
|
|
8775
8922
|
try {
|
|
8776
8923
|
const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name).catch((err) => removedOnes(err, name, client));
|
|
@@ -8813,8 +8960,8 @@ var lsCommand17 = (spec) => {
|
|
|
8813
8960
|
};
|
|
8814
8961
|
|
|
8815
8962
|
// src/commands/managed/backup/restore.ts
|
|
8816
|
-
import { Command as
|
|
8817
|
-
var restoreCommand4 = (spec) => new
|
|
8963
|
+
import { Command as Command112 } from "commander";
|
|
8964
|
+
var restoreCommand4 = (spec) => new Command112("restore").description("put a backup back: the database's data becomes the backup's (it restarts)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").option("--json", "print the database as JSON").action(async (name, id, opts, cmd) => {
|
|
8818
8965
|
const client = await managedClient(cmd);
|
|
8819
8966
|
try {
|
|
8820
8967
|
const backup = await client.managedBackup(spec.kind, name, id);
|
|
@@ -8836,8 +8983,8 @@ var restoreCommand4 = (spec) => new Command108("restore").description("put a bac
|
|
|
8836
8983
|
});
|
|
8837
8984
|
|
|
8838
8985
|
// src/commands/managed/backup/rm.ts
|
|
8839
|
-
import { Command as
|
|
8840
|
-
var rmCommand16 = (spec) => new
|
|
8986
|
+
import { Command as Command113 } from "commander";
|
|
8987
|
+
var rmCommand16 = (spec) => new Command113("rm").alias("remove").description("remove a backup for good (a database's that is gone too)").argument("<db>", "its name").argument("<id>", `the backup's id (kvbox ${spec.command} backup ls <db>)`).option("-y, --yes", "do not ask for confirmation").action(async (name, id, opts, cmd) => {
|
|
8841
8988
|
const client = await managedClient(cmd);
|
|
8842
8989
|
try {
|
|
8843
8990
|
await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
|
|
@@ -8847,51 +8994,37 @@ var rmCommand16 = (spec) => new Command109("rm").alias("remove").description("re
|
|
|
8847
8994
|
});
|
|
8848
8995
|
|
|
8849
8996
|
// src/commands/managed/backup/schedule.ts
|
|
8850
|
-
import { Command as
|
|
8851
|
-
var
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8855
|
-
|
|
8856
|
-
|
|
8857
|
-
|
|
8858
|
-
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
return;
|
|
8862
|
-
}
|
|
8863
|
-
info(`${changed ? `${color.green("\u2713")} ` : ""}database ${color.bold(name)}: ${scheduleText2(spec, name, schedule)}`);
|
|
8864
|
-
if (schedule.lastAt !== null) {
|
|
8865
|
-
const last = schedule.lastError !== null ? color.red(`failed: ${schedule.lastError}`) : schedule.lastBackup !== null ? `backup ${schedule.lastBackup}` : "starting a backup";
|
|
8866
|
-
info(color.dim(` last turn ${schedule.lastAt.slice(0, 16).replace("T", " ")} UTC: `) + last);
|
|
8997
|
+
import { Command as Command114 } from "commander";
|
|
8998
|
+
var scheduleCommand4 = (spec) => scheduleFlags(new Command114("schedule").description("show or change when a database is backed up on its own (daily, UTC)").argument("<db>", "its name")).action(
|
|
8999
|
+
async (name, flags, cmd) => {
|
|
9000
|
+
const change = changeOf(flags);
|
|
9001
|
+
const client = await managedClient(cmd);
|
|
9002
|
+
try {
|
|
9003
|
+
const changed = Object.keys(change).length > 0;
|
|
9004
|
+
const schedule = changed ? await client.setManagedBackupSchedule(spec.kind, name, change) : await client.managedBackupSchedule(spec.kind, name);
|
|
9005
|
+
printSchedule(`database ${name}`, `kvbox ${spec.command} backup schedule ${name}`, schedule, flags, changed);
|
|
9006
|
+
} finally {
|
|
9007
|
+
await client.close();
|
|
8867
9008
|
}
|
|
8868
|
-
} finally {
|
|
8869
|
-
await client.close();
|
|
8870
9009
|
}
|
|
8871
|
-
|
|
8872
|
-
function parseHour(text2) {
|
|
8873
|
-
const m = /^(\d{1,2})(?::00)?$/.exec(text2.trim());
|
|
8874
|
-
const hour = m ? Number(m[1]) : NaN;
|
|
8875
|
-
if (!Number.isInteger(hour) || hour < 0 || hour > 23) throw new KvboxError(`--at ${text2}: an hour of the day, 0-23 (UTC), like 3 or 03:00`);
|
|
8876
|
-
return hour;
|
|
8877
|
-
}
|
|
9010
|
+
);
|
|
8878
9011
|
|
|
8879
9012
|
// src/commands/managed/backup/index.ts
|
|
8880
9013
|
var backupCommand4 = (spec) => {
|
|
8881
|
-
const command = new
|
|
8882
|
-
for (const make of [createCommand10, lsCommand17, restoreCommand4, rmCommand16,
|
|
9014
|
+
const command = new Command115("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one, or change its nightly schedule");
|
|
9015
|
+
for (const make of [createCommand10, lsCommand17, restoreCommand4, rmCommand16, scheduleCommand4]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
8883
9016
|
return command;
|
|
8884
9017
|
};
|
|
8885
9018
|
|
|
8886
9019
|
// src/commands/managed/create.ts
|
|
8887
|
-
import { Command as
|
|
9020
|
+
import { Command as Command116 } from "commander";
|
|
8888
9021
|
import { setTimeout as sleep5 } from "timers/promises";
|
|
8889
9022
|
var READY_WAIT_MS = 9e4;
|
|
8890
9023
|
var READY_STEP_MS = 2e3;
|
|
8891
9024
|
var createCommand11 = (spec) => {
|
|
8892
|
-
const command = new
|
|
9025
|
+
const command = new Command116("create").alias("new").description(`create a ${spec.title} database: a name is all it needs`).argument("<name>", "its name (1-12 chars, lowercase letters, digits and '-'); a linked box reaches it at <name>.<account>.kvbox");
|
|
8893
9026
|
for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
|
|
8894
|
-
return command.option("--password <password>", "its password (default: generated)").option("--storage <gb>", `storage for the data in GB (default: ${spec.storageGib}; it can grow later)`).option("--near <box>", "run it on the host of this box, so
|
|
9027
|
+
return command.option("--password <password>", "its password (default: generated)").option("--storage <gb>", `storage for the data in GB (default: ${spec.storageGib}; it can grow later)`).option("--near <box>", "run it on the host of this box, so a link between them stays on that host").option("--from-backup <id>", `start it on this backup's data, a removed database's too (kvbox ${spec.command} backup ls)`).option("--json", "print it as JSON, password included").action(async (name, opts, cmd) => {
|
|
8895
9028
|
const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
|
|
8896
9029
|
const req = {
|
|
8897
9030
|
name,
|
|
@@ -8927,8 +9060,8 @@ var createCommand11 = (spec) => {
|
|
|
8927
9060
|
printRows3([...settingRows(spec, made.settings), ...secretRows(made.secret)].map(([label, value]) => [` ${label}`, value]));
|
|
8928
9061
|
info("");
|
|
8929
9062
|
info("Nobody can reach it yet. To let something in:");
|
|
8930
|
-
info(` a box
|
|
8931
|
-
info(` the internet
|
|
9063
|
+
info(` a box of yours kvbox ${spec.command} link ${shown} <box> ${color.dim(`(a new one right next to it: kvbox new <box> --near ${shown})`)}`);
|
|
9064
|
+
info(` the internet kvbox ${spec.command} public ${shown} on`);
|
|
8932
9065
|
info(color.dim(`It costs about ${money(made.price.perMonth, made.price.currency)} a month while it runs, ${money(made.price.storagePerMonth, made.price.currency)} stopped. The password again: kvbox ${spec.command} password ${shown}`));
|
|
8933
9066
|
if (!ready) info(color.dim(`It was not answering after ${READY_WAIT_MS / 1e3} s; see how it is with: kvbox ${spec.command} info ${shown}`));
|
|
8934
9067
|
} finally {
|
|
@@ -8938,8 +9071,8 @@ var createCommand11 = (spec) => {
|
|
|
8938
9071
|
};
|
|
8939
9072
|
|
|
8940
9073
|
// src/commands/managed/grow.ts
|
|
8941
|
-
import { Command as
|
|
8942
|
-
var growCommand3 = (spec) => new
|
|
9074
|
+
import { Command as Command117 } from "commander";
|
|
9075
|
+
var growCommand3 = (spec) => new Command117("grow").description("give a database more storage (it restarts once)").argument("<db>", "its name").argument("<GB>", "the new size in GB, larger than what it has").option("--json", "print as JSON").action(async (name, size, opts, cmd) => {
|
|
8943
9076
|
const storageGib = parseStorage(size, "size");
|
|
8944
9077
|
const client = await managedClient(cmd);
|
|
8945
9078
|
try {
|
|
@@ -8952,8 +9085,8 @@ var growCommand3 = (spec) => new Command113("grow").description("give a database
|
|
|
8952
9085
|
});
|
|
8953
9086
|
|
|
8954
9087
|
// src/commands/managed/info.ts
|
|
8955
|
-
import { Command as
|
|
8956
|
-
var infoCommand3 = (spec) => new
|
|
9088
|
+
import { Command as Command118 } from "commander";
|
|
9089
|
+
var infoCommand3 = (spec) => new Command118("info").alias("get").description("show one database: status, storage used, how to connect").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
8957
9090
|
const client = await managedClient(cmd);
|
|
8958
9091
|
try {
|
|
8959
9092
|
const m = await client.getManaged(spec.kind, name);
|
|
@@ -8965,8 +9098,8 @@ var infoCommand3 = (spec) => new Command114("info").alias("get").description("sh
|
|
|
8965
9098
|
});
|
|
8966
9099
|
|
|
8967
9100
|
// src/commands/managed/link.ts
|
|
8968
|
-
import { Command as
|
|
8969
|
-
var linkCommand2 = (spec) => new
|
|
9101
|
+
import { Command as Command119 } from "commander";
|
|
9102
|
+
var linkCommand2 = (spec) => new Command119("link").description("let a box reach a database privately").argument("<db>", "the database").argument("<box>", "the box that connects to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
|
|
8970
9103
|
const client = await managedClient(cmd);
|
|
8971
9104
|
try {
|
|
8972
9105
|
const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
|
|
@@ -8982,7 +9115,7 @@ var linkCommand2 = (spec) => new Command115("link").description("let a box reach
|
|
|
8982
9115
|
});
|
|
8983
9116
|
|
|
8984
9117
|
// src/commands/managed/ls.ts
|
|
8985
|
-
import { Command as
|
|
9118
|
+
import { Command as Command120 } from "commander";
|
|
8986
9119
|
function listRows(items, user, kindColumn) {
|
|
8987
9120
|
return items.map((m) => ({
|
|
8988
9121
|
owner: m.owner === user ? "private" : m.owner,
|
|
@@ -8996,7 +9129,7 @@ function listRows(items, user, kindColumn) {
|
|
|
8996
9129
|
created: age(m.createdAt)
|
|
8997
9130
|
}));
|
|
8998
9131
|
}
|
|
8999
|
-
var lsCommand18 = (spec) => new
|
|
9132
|
+
var lsCommand18 = (spec) => new Command120("ls").alias("list").description(spec ? `list your ${spec.title} databases` : "list every managed database, whatever its kind").option("-a, --all", "every one on the platform (platform admins only)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
9000
9133
|
const client = await managedClient(cmd);
|
|
9001
9134
|
try {
|
|
9002
9135
|
const items = await client.listManaged(spec?.kind, { all: opts.all });
|
|
@@ -9016,8 +9149,8 @@ var lsCommand18 = (spec) => new Command116("ls").alias("list").description(spec
|
|
|
9016
9149
|
});
|
|
9017
9150
|
|
|
9018
9151
|
// src/commands/managed/password.ts
|
|
9019
|
-
import { Command as
|
|
9020
|
-
var passwordCommand = (spec) => new
|
|
9152
|
+
import { Command as Command121 } from "commander";
|
|
9153
|
+
var passwordCommand = (spec) => new Command121("password").description("show a database's password, or set a new one with --reset").argument("<db>", "its name").option("--reset", "make a new password; the old one stops working").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
9021
9154
|
const client = await managedClient(cmd);
|
|
9022
9155
|
try {
|
|
9023
9156
|
const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
|
|
@@ -9033,8 +9166,8 @@ var passwordCommand = (spec) => new Command117("password").description("show a d
|
|
|
9033
9166
|
});
|
|
9034
9167
|
|
|
9035
9168
|
// src/commands/managed/public.ts
|
|
9036
|
-
import { Command as
|
|
9037
|
-
var publicCommand2 = (spec) => new
|
|
9169
|
+
import { Command as Command122 } from "commander";
|
|
9170
|
+
var publicCommand2 = (spec) => new Command122("public").description("open a database to the internet, or close it again").argument("<db>", "its name").argument("<state>", "on: reachable from anywhere with the password; off: only linked boxes").option("--json", "print as JSON").action(async (name, state, opts, cmd) => {
|
|
9038
9171
|
if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
|
|
9039
9172
|
const client = await managedClient(cmd);
|
|
9040
9173
|
try {
|
|
@@ -9055,8 +9188,8 @@ var publicCommand2 = (spec) => new Command118("public").description("open a data
|
|
|
9055
9188
|
});
|
|
9056
9189
|
|
|
9057
9190
|
// src/commands/managed/rm.ts
|
|
9058
|
-
import { Command as
|
|
9059
|
-
var rmCommand17 = (spec) => new
|
|
9191
|
+
import { Command as Command123 } from "commander";
|
|
9192
|
+
var rmCommand17 = (spec) => new Command123("rm").alias("remove").description("delete a database and all its data").argument("<db>", "its name").option("-y, --yes", "do not ask for confirmation").action(async (name, opts, cmd) => {
|
|
9060
9193
|
const client = await managedClient(cmd);
|
|
9061
9194
|
try {
|
|
9062
9195
|
if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
|
|
@@ -9072,8 +9205,8 @@ var rmCommand17 = (spec) => new Command119("rm").alias("remove").description("de
|
|
|
9072
9205
|
});
|
|
9073
9206
|
|
|
9074
9207
|
// src/commands/managed/start.ts
|
|
9075
|
-
import { Command as
|
|
9076
|
-
var startCommand2 = (spec) => new
|
|
9208
|
+
import { Command as Command124 } from "commander";
|
|
9209
|
+
var startCommand2 = (spec) => new Command124("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
9077
9210
|
const client = await managedClient(cmd);
|
|
9078
9211
|
try {
|
|
9079
9212
|
const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
|
|
@@ -9085,8 +9218,8 @@ var startCommand2 = (spec) => new Command120("start").description("run a stopped
|
|
|
9085
9218
|
});
|
|
9086
9219
|
|
|
9087
9220
|
// src/commands/managed/stop.ts
|
|
9088
|
-
import { Command as
|
|
9089
|
-
var stopCommand2 = (spec) => new
|
|
9221
|
+
import { Command as Command125 } from "commander";
|
|
9222
|
+
var stopCommand2 = (spec) => new Command125("stop").description("shut a database down, keeping its data (only its storage is charged)").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
9090
9223
|
const client = await managedClient(cmd);
|
|
9091
9224
|
try {
|
|
9092
9225
|
const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
|
|
@@ -9098,8 +9231,8 @@ var stopCommand2 = (spec) => new Command121("stop").description("shut a database
|
|
|
9098
9231
|
});
|
|
9099
9232
|
|
|
9100
9233
|
// src/commands/managed/unlink.ts
|
|
9101
|
-
import { Command as
|
|
9102
|
-
var unlinkCommand2 = (spec) => new
|
|
9234
|
+
import { Command as Command126 } from "commander";
|
|
9235
|
+
var unlinkCommand2 = (spec) => new Command126("unlink").description("stop a box from reaching a database").argument("<db>", "the database").argument("<box>", "the box that was linked to it").option("--json", "print as JSON").action(async (name, box2, opts, cmd) => {
|
|
9103
9236
|
const client = await managedClient(cmd);
|
|
9104
9237
|
try {
|
|
9105
9238
|
const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
|
|
@@ -9112,7 +9245,7 @@ var unlinkCommand2 = (spec) => new Command122("unlink").description("stop a box
|
|
|
9112
9245
|
|
|
9113
9246
|
// src/commands/managed/kind.ts
|
|
9114
9247
|
function kindCommand(spec, description) {
|
|
9115
|
-
const command = new
|
|
9248
|
+
const command = new Command127(spec.command).aliases(spec.aliases).description(description);
|
|
9116
9249
|
for (const make of [createCommand11, lsCommand18, infoCommand3, passwordCommand, publicCommand2, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand17]) {
|
|
9117
9250
|
command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
9118
9251
|
}
|
|
@@ -9127,14 +9260,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
|
|
|
9127
9260
|
var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
|
|
9128
9261
|
|
|
9129
9262
|
// src/commands/managed/index.ts
|
|
9130
|
-
import { Command as
|
|
9131
|
-
var managedCommand = new
|
|
9263
|
+
import { Command as Command128 } from "commander";
|
|
9264
|
+
var managedCommand = new Command128("managed").description(`databases kvbox runs for you, every kind together (${KINDS.map((k) => `${k.title}: kvbox ${k.command}`).join(", ")})`).addCommand(lsCommand18().option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
9132
9265
|
|
|
9133
9266
|
// src/commands/env/index.ts
|
|
9134
|
-
import { Command as
|
|
9267
|
+
import { Command as Command132 } from "commander";
|
|
9135
9268
|
|
|
9136
9269
|
// src/commands/env/ls.ts
|
|
9137
|
-
import { Command as
|
|
9270
|
+
import { Command as Command129 } from "commander";
|
|
9138
9271
|
|
|
9139
9272
|
// src/commands/env/shared.ts
|
|
9140
9273
|
function requireCloud4(client) {
|
|
@@ -9161,7 +9294,7 @@ function firstBootHint(box2, name) {
|
|
|
9161
9294
|
}
|
|
9162
9295
|
|
|
9163
9296
|
// src/commands/env/ls.ts
|
|
9164
|
-
var lsCommand19 = new
|
|
9297
|
+
var lsCommand19 = new Command129("ls").alias("list").description("list the variables (a secret shows as (sealed))").option("--box <box>", "what this box gets: its own variables and the ones it inherits").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
9165
9298
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
9166
9299
|
try {
|
|
9167
9300
|
if (opts.box !== void 0) {
|
|
@@ -9200,8 +9333,8 @@ var lsCommand19 = new Command125("ls").alias("list").description("list the varia
|
|
|
9200
9333
|
});
|
|
9201
9334
|
|
|
9202
9335
|
// src/commands/env/rm.ts
|
|
9203
|
-
import { Command as
|
|
9204
|
-
var rmCommand18 = new
|
|
9336
|
+
import { Command as Command130 } from "commander";
|
|
9337
|
+
var rmCommand18 = new Command130("rm").alias("remove").description("remove variables; boxes lose them when they next start").argument("<names...>", "variable names").option("-y, --yes", "do not ask for confirmation").option("--box <box>", "remove this box's own variables (yours, or the org's, of the same name come back)").option("--json", "print as JSON").action(async (names2, opts, cmd) => {
|
|
9205
9338
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
9206
9339
|
try {
|
|
9207
9340
|
const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
|
|
@@ -9238,8 +9371,8 @@ var rmCommand18 = new Command126("rm").alias("remove").description("remove varia
|
|
|
9238
9371
|
});
|
|
9239
9372
|
|
|
9240
9373
|
// src/commands/env/set.ts
|
|
9241
|
-
import { Command as
|
|
9242
|
-
var setCommand2 = new
|
|
9374
|
+
import { Command as Command131 } from "commander";
|
|
9375
|
+
var setCommand2 = new Command131("set").description("add or change a variable; boxes get it when they next start").argument("[name]", "variable name, e.g. DATABASE_URL (asked for when left out)").argument("[value]", "its value (asked for when left out; hidden with --secret)").option("--secret", "write-only: the value is never shown again, by any command").option("--box <box>", "this box's own variable, over yours (or the org's) of the same name").option("--json", "print as JSON").action(async (nameArg, valueArg, opts, cmd) => {
|
|
9243
9376
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
9244
9377
|
try {
|
|
9245
9378
|
const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
|
|
@@ -9276,14 +9409,14 @@ var setCommand2 = new Command127("set").description("add or change a variable; b
|
|
|
9276
9409
|
});
|
|
9277
9410
|
|
|
9278
9411
|
// src/commands/env/index.ts
|
|
9279
|
-
var envCommand = new
|
|
9412
|
+
var envCommand = new Command132("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand19, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand18);
|
|
9280
9413
|
for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
|
|
9281
9414
|
|
|
9282
9415
|
// src/commands/domain/index.ts
|
|
9283
|
-
import { Command as
|
|
9416
|
+
import { Command as Command136 } from "commander";
|
|
9284
9417
|
|
|
9285
9418
|
// src/commands/domain/add.ts
|
|
9286
|
-
import { Command as
|
|
9419
|
+
import { Command as Command133 } from "commander";
|
|
9287
9420
|
|
|
9288
9421
|
// src/commands/domain/shared.ts
|
|
9289
9422
|
function requireCloud5(client) {
|
|
@@ -9303,7 +9436,7 @@ function hostIn(name, zone) {
|
|
|
9303
9436
|
}
|
|
9304
9437
|
|
|
9305
9438
|
// src/commands/domain/add.ts
|
|
9306
|
-
var addCommand4 = new
|
|
9439
|
+
var addCommand4 = new Command133("add").description("serve a box at a domain of your own, https://<domain>, with its certificate made for you").argument("<domain>", "a domain you control, like example.com or app.example.com").argument("<box>", "box name").option("--port <port>", "the box port the domain serves (default: the port of its kvbox.app address)").option("--json", "print the domain as JSON").action(async (domainArg, name, opts, cmd) => {
|
|
9307
9440
|
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
9308
9441
|
const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
|
|
9309
9442
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
@@ -9339,8 +9472,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
|
|
|
9339
9472
|
});
|
|
9340
9473
|
|
|
9341
9474
|
// src/commands/domain/ls.ts
|
|
9342
|
-
import { Command as
|
|
9343
|
-
var lsCommand20 = new
|
|
9475
|
+
import { Command as Command134 } from "commander";
|
|
9476
|
+
var lsCommand20 = new Command134("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
9344
9477
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
9345
9478
|
try {
|
|
9346
9479
|
requireCloud5(client);
|
|
@@ -9369,8 +9502,8 @@ var lsCommand20 = new Command130("ls").alias("list").description("list your cust
|
|
|
9369
9502
|
});
|
|
9370
9503
|
|
|
9371
9504
|
// src/commands/domain/rm.ts
|
|
9372
|
-
import { Command as
|
|
9373
|
-
var rmCommand19 = new
|
|
9505
|
+
import { Command as Command135 } from "commander";
|
|
9506
|
+
var rmCommand19 = new Command135("rm").alias("remove").description("stop serving a box at a custom domain").argument("<domain>", "the domain").option("-y, --yes", "do not ask for confirmation").action(async (domainArg, opts, cmd) => {
|
|
9374
9507
|
const domain = domainArg.trim().toLowerCase();
|
|
9375
9508
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
9376
9509
|
try {
|
|
@@ -9391,7 +9524,7 @@ var rmCommand19 = new Command131("rm").alias("remove").description("stop serving
|
|
|
9391
9524
|
});
|
|
9392
9525
|
|
|
9393
9526
|
// src/commands/domain/index.ts
|
|
9394
|
-
var domainCommand = new
|
|
9527
|
+
var domainCommand = new Command136("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand20).addCommand(rmCommand19);
|
|
9395
9528
|
for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
9396
9529
|
|
|
9397
9530
|
// src/commands/update.ts
|
|
@@ -9399,7 +9532,7 @@ import { spawn as spawn8 } from "child_process";
|
|
|
9399
9532
|
import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
9400
9533
|
import { tmpdir } from "os";
|
|
9401
9534
|
import { join as join9 } from "path";
|
|
9402
|
-
import { Command as
|
|
9535
|
+
import { Command as Command137 } from "commander";
|
|
9403
9536
|
|
|
9404
9537
|
// src/update.ts
|
|
9405
9538
|
import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
@@ -9518,7 +9651,7 @@ function run2(cmd, args) {
|
|
|
9518
9651
|
child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
|
|
9519
9652
|
});
|
|
9520
9653
|
}
|
|
9521
|
-
var selfUpdateCommand = new
|
|
9654
|
+
var selfUpdateCommand = new Command137("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
|
|
9522
9655
|
suppressUpdateNotice();
|
|
9523
9656
|
const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
|
|
9524
9657
|
let code;
|
|
@@ -9647,7 +9780,7 @@ function installRootHelp(program) {
|
|
|
9647
9780
|
|
|
9648
9781
|
// src/program.ts
|
|
9649
9782
|
function buildProgram() {
|
|
9650
|
-
const program = new
|
|
9783
|
+
const program = new Command138("kvbox").description("self-hosted Firecracker microVMs with Docker-like ergonomics").version(VERSION, "-v, --version").option("--local", "use this machine's kvbox-server over its socket, ignoring kvbox login and KVBOX_TOKEN").option("--org <slug>", "the org: where kvbox new creates, and which box a name means when it is not one of yours; before the command here, or after it").showHelpAfterError().enablePositionalOptions();
|
|
9651
9784
|
program.addCommand(vmCommand);
|
|
9652
9785
|
program.addCommand(snapshotsCommand);
|
|
9653
9786
|
program.addCommand(volumeCommand);
|