@kvbox/cli 0.6.0 → 0.6.1
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 +259 -89
- package/dist/kvbox.js.map +1 -1
- package/package.json +1 -1
package/dist/kvbox.js
CHANGED
|
@@ -149,7 +149,7 @@ async function spin(message, work, opts = {}) {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
// src/program.ts
|
|
152
|
-
import { Command as
|
|
152
|
+
import { Command as Command99 } from "commander";
|
|
153
153
|
|
|
154
154
|
// ../shared/src/version.ts
|
|
155
155
|
import { createRequire } from "module";
|
|
@@ -164,7 +164,7 @@ function versionOf(srcFileUrl, injected) {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// src/version.ts
|
|
167
|
-
var VERSION = versionOf(import.meta.url, true ? "0.6.
|
|
167
|
+
var VERSION = versionOf(import.meta.url, true ? "0.6.1" : void 0);
|
|
168
168
|
|
|
169
169
|
// src/commands/vm/index.ts
|
|
170
170
|
import { Command as Command37 } from "commander";
|
|
@@ -292,7 +292,9 @@ function paths(home = kvboxHome()) {
|
|
|
292
292
|
dir,
|
|
293
293
|
meta: join(dir, "meta.json"),
|
|
294
294
|
/** The volume itself: a sparse ext4 the guest sees as a whole disk. */
|
|
295
|
-
disk: join(dir, "disk.ext4")
|
|
295
|
+
disk: join(dir, "disk.ext4"),
|
|
296
|
+
/** A restore's disk while it downloads (a backup's chunks), renamed over `disk` once complete. */
|
|
297
|
+
restoring: join(dir, "disk.ext4.restore")
|
|
296
298
|
};
|
|
297
299
|
},
|
|
298
300
|
/** Each owner's environment variables as the control plane last sent them (#88): env/<owner>.json, mode 600. */
|
|
@@ -523,6 +525,7 @@ var WakeHookCallSchema = z2.object({
|
|
|
523
525
|
reason: z2.string().optional()
|
|
524
526
|
});
|
|
525
527
|
var BACKUP_STATUSES = ["running", "ready", "failed"];
|
|
528
|
+
var BACKUP_KINDS = ["box", "volume"];
|
|
526
529
|
var BackupSchema = z2.object({
|
|
527
530
|
id: z2.string(),
|
|
528
531
|
owner: z2.string(),
|
|
@@ -570,6 +573,31 @@ var HostRestoreRequest = z2.object({
|
|
|
570
573
|
/** The certificate fingerprint of the store the URLs point at (see HostUploadRequest). */
|
|
571
574
|
pin: z2.string().optional()
|
|
572
575
|
});
|
|
576
|
+
var VolumeBackupSchema = z2.object({
|
|
577
|
+
id: z2.string(),
|
|
578
|
+
owner: z2.string(),
|
|
579
|
+
volume: z2.string(),
|
|
580
|
+
status: z2.enum(BACKUP_STATUSES),
|
|
581
|
+
/** Why it failed; null otherwise. */
|
|
582
|
+
error: z2.string().nullable(),
|
|
583
|
+
/** The volume's size when taken. */
|
|
584
|
+
diskBytes: z2.number().int().nullable(),
|
|
585
|
+
/** What it holds: the slots that are not all zeros. */
|
|
586
|
+
dataBytes: z2.number().int().nullable(),
|
|
587
|
+
/** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
|
|
588
|
+
uploadedBytes: z2.number().int().nullable(),
|
|
589
|
+
createdBy: z2.string().nullable(),
|
|
590
|
+
createdAt: z2.string(),
|
|
591
|
+
finishedAt: z2.string().nullable()
|
|
592
|
+
});
|
|
593
|
+
var HostVolumeBackupManifestSchema = z2.object({ id: z2.string(), sizeBytes: z2.number().int(), chunks: z2.array(z2.string().nullable()) });
|
|
594
|
+
var HostVolumeRestoreRequest = z2.object({
|
|
595
|
+
id: z2.string(),
|
|
596
|
+
key: z2.string(),
|
|
597
|
+
sizeBytes: z2.number().int().positive(),
|
|
598
|
+
chunks: z2.array(z2.object({ index: z2.number().int().nonnegative(), hash: z2.string(), url: z2.string() })),
|
|
599
|
+
pin: z2.string().optional()
|
|
600
|
+
});
|
|
573
601
|
var BackupStoreSetupRequest = z2.object({ path: z2.string().min(1), force: z2.boolean().optional(), newStore: z2.boolean().optional() });
|
|
574
602
|
var BackupStoreStatusSchema = z2.object({
|
|
575
603
|
path: z2.string(),
|
|
@@ -602,7 +630,38 @@ var CloudBackupStoreSchema = z2.object({
|
|
|
602
630
|
freeBytes: z2.number().int().nullable(),
|
|
603
631
|
/** Ready backups kept here, and what their chunks take (encrypted, compressed). */
|
|
604
632
|
backups: z2.number().int(),
|
|
605
|
-
storedBytes: z2.number().int()
|
|
633
|
+
storedBytes: z2.number().int(),
|
|
634
|
+
/** How many boxes have a ready backup here (a box and an earlier one of the same name count once), and how many volumes (#168). */
|
|
635
|
+
boxes: z2.number().int(),
|
|
636
|
+
volumes: z2.number().int(),
|
|
637
|
+
/** When the newest ready backup kept here finished; null when it keeps none. */
|
|
638
|
+
lastBackupAt: z2.string().nullable()
|
|
639
|
+
});
|
|
640
|
+
var StoredItemSchema = z2.object({
|
|
641
|
+
kind: z2.enum(BACKUP_KINDS),
|
|
642
|
+
owner: z2.string(),
|
|
643
|
+
name: z2.string(),
|
|
644
|
+
/** The host the box (or volume) is on now; null when it is gone (its backups stay). */
|
|
645
|
+
host: z2.string().nullable(),
|
|
646
|
+
/** It is on the store's own host: losing that host loses it and its backups together. */
|
|
647
|
+
sameHost: z2.boolean(),
|
|
648
|
+
/** Ready backups kept here, and what they added to the store together (encrypted, compressed). */
|
|
649
|
+
backups: z2.number().int(),
|
|
650
|
+
uploadedBytes: z2.number().int(),
|
|
651
|
+
/** The newest backup sent here, whatever became of it. */
|
|
652
|
+
latest: z2.object({ id: z2.string(), status: z2.enum(BACKUP_STATUSES), error: z2.string().nullable(), createdAt: z2.string() })
|
|
653
|
+
});
|
|
654
|
+
var FailedBackupSchema = z2.object({
|
|
655
|
+
id: z2.string(),
|
|
656
|
+
owner: z2.string(),
|
|
657
|
+
/** What it was a backup of: a box or a volume (#168), and its name. */
|
|
658
|
+
kind: z2.enum(BACKUP_KINDS),
|
|
659
|
+
name: z2.string(),
|
|
660
|
+
error: z2.string().nullable(),
|
|
661
|
+
/** The host that took it, and the host of the store it was going to; null when gone, or when it failed before a store was picked. */
|
|
662
|
+
host: z2.string().nullable(),
|
|
663
|
+
store: z2.string().nullable(),
|
|
664
|
+
createdAt: z2.string()
|
|
606
665
|
});
|
|
607
666
|
var MachineSchema = z2.object({
|
|
608
667
|
/** Host-unique short id (the tap is `kv-<id>`). Missing only on a box made before ids that has not restarted since. */
|
|
@@ -1694,6 +1753,24 @@ var ServerClient = class {
|
|
|
1694
1753
|
createBoxBackup(name) {
|
|
1695
1754
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/backups`, BackupSchema);
|
|
1696
1755
|
}
|
|
1756
|
+
/** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
|
|
1757
|
+
listVolumeBackups() {
|
|
1758
|
+
return this.call("GET", "/backups?kind=volume", z6.array(VolumeBackupSchema));
|
|
1759
|
+
}
|
|
1760
|
+
volumeBackups(name) {
|
|
1761
|
+
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups`, z6.array(VolumeBackupSchema));
|
|
1762
|
+
}
|
|
1763
|
+
volumeBackup(name, id) {
|
|
1764
|
+
return this.call("GET", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, VolumeBackupSchema);
|
|
1765
|
+
}
|
|
1766
|
+
/** Starts one; it runs in the background (`running`), `volumeBackup` says how it ended. */
|
|
1767
|
+
createVolumeBackup(name) {
|
|
1768
|
+
return this.call("POST", `/volumes/${encodeURIComponent(name)}/backups`, VolumeBackupSchema);
|
|
1769
|
+
}
|
|
1770
|
+
/** The volume's disk becomes the backup's; a running box that holds it restarts. Waits for the whole download. */
|
|
1771
|
+
restoreVolumeBackup(name, id) {
|
|
1772
|
+
return this.call("POST", `/volumes/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}/restore`, VolumeSchema, {}, void 0, 2 * 36e5);
|
|
1773
|
+
}
|
|
1697
1774
|
/** The box's disk becomes the backup's; a running box restarts. Waits for the whole download. */
|
|
1698
1775
|
restoreBoxBackup(name, id) {
|
|
1699
1776
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}/restore`, MachineSchema, {}, void 0, 2 * 36e5);
|
|
@@ -3211,25 +3288,26 @@ function requireCloud3(client) {
|
|
|
3211
3288
|
var POLL_MS = 2e3;
|
|
3212
3289
|
var POLL_TRIES = 30;
|
|
3213
3290
|
var WAIT_MS = 7 * 36e5;
|
|
3214
|
-
async function
|
|
3291
|
+
async function untilSettled(ask, what, id, where, opts = {}) {
|
|
3215
3292
|
const { pollMs = POLL_MS, tries = POLL_TRIES, waitMs = WAIT_MS } = opts;
|
|
3293
|
+
const lostTrack = (why) => new KvboxError(`stopped waiting for backup ${id} of ${what} (${why}); it may still be running: ${where}`);
|
|
3216
3294
|
const until = Date.now() + waitMs;
|
|
3217
3295
|
let failed = 0;
|
|
3218
3296
|
for (; ; ) {
|
|
3219
3297
|
try {
|
|
3220
|
-
const b = await
|
|
3298
|
+
const b = await ask();
|
|
3221
3299
|
if (b.status !== "running") return b;
|
|
3222
3300
|
failed = 0;
|
|
3223
3301
|
} catch (err) {
|
|
3224
3302
|
failed += 1;
|
|
3225
|
-
if (failed >= tries) throw lostTrack(
|
|
3303
|
+
if (failed >= tries) throw lostTrack(`could not ask how it is doing: ${err.message}`);
|
|
3226
3304
|
}
|
|
3227
|
-
if (Date.now() >= until) throw lostTrack(
|
|
3305
|
+
if (Date.now() >= until) throw lostTrack("it is taking longer than a backup is given");
|
|
3228
3306
|
await sleep2(pollMs);
|
|
3229
3307
|
}
|
|
3230
3308
|
}
|
|
3231
|
-
function
|
|
3232
|
-
return
|
|
3309
|
+
function untilDone(client, box, id, opts = {}) {
|
|
3310
|
+
return untilSettled(() => client.boxBackup(box, id), `box ${box}`, id, `kvbox vm backup ls ${box}`, opts);
|
|
3233
3311
|
}
|
|
3234
3312
|
function sizeLine(b) {
|
|
3235
3313
|
const data = b.dataBytes === null ? "?" : gb(b.dataBytes);
|
|
@@ -5744,7 +5822,7 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
|
|
|
5744
5822
|
}
|
|
5745
5823
|
|
|
5746
5824
|
// src/commands/volume/index.ts
|
|
5747
|
-
import { Command as
|
|
5825
|
+
import { Command as Command65 } from "commander";
|
|
5748
5826
|
|
|
5749
5827
|
// src/commands/volume/attach.ts
|
|
5750
5828
|
import { Command as Command55 } from "commander";
|
|
@@ -5770,8 +5848,99 @@ var attachCommand = new Command55("attach").description("attach a volume to a bo
|
|
|
5770
5848
|
}
|
|
5771
5849
|
});
|
|
5772
5850
|
|
|
5773
|
-
// src/commands/volume/
|
|
5851
|
+
// src/commands/volume/backup/index.ts
|
|
5852
|
+
import { Command as Command59 } from "commander";
|
|
5853
|
+
|
|
5854
|
+
// src/commands/volume/backup/create.ts
|
|
5774
5855
|
import { Command as Command56 } from "commander";
|
|
5856
|
+
var createCommand3 = new Command56("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 (volume, opts, cmd) => {
|
|
5857
|
+
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5858
|
+
try {
|
|
5859
|
+
requireCloud3(client);
|
|
5860
|
+
const started = await client.createVolumeBackup(volume);
|
|
5861
|
+
if (!opts.wait) {
|
|
5862
|
+
if (opts.json) json(started);
|
|
5863
|
+
else {
|
|
5864
|
+
info(`${color.green("\u2713")} backup ${started.id} of volume ${color.bold(volume)} started; it runs in the background`);
|
|
5865
|
+
info(color.dim(` status: kvbox volume backup ls ${volume}`));
|
|
5866
|
+
}
|
|
5867
|
+
return;
|
|
5868
|
+
}
|
|
5869
|
+
const done = await spin(`backing up volume ${volume}\u2026`, untilSettled(() => client.volumeBackup(volume, started.id), `volume ${volume}`, started.id, `kvbox volume backup ls ${volume}`));
|
|
5870
|
+
if (opts.json) json(done);
|
|
5871
|
+
if (done.status === "failed") throw new KvboxError(`backup ${done.id} of volume ${volume} failed: ${done.error ?? "no reason given"}`);
|
|
5872
|
+
if (opts.json) return;
|
|
5873
|
+
info(`${color.green("\u2713")} backup ${done.id} of volume ${color.bold(volume)}: ${sizeLine(done)}`);
|
|
5874
|
+
info(color.dim(` restore with: kvbox volume backup restore ${volume} ${done.id}`));
|
|
5875
|
+
} finally {
|
|
5876
|
+
await client.close();
|
|
5877
|
+
}
|
|
5878
|
+
});
|
|
5879
|
+
|
|
5880
|
+
// src/commands/volume/backup/ls.ts
|
|
5881
|
+
import { Command as Command57 } from "commander";
|
|
5882
|
+
var lsCommand8 = new Command57("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 (volume, opts, cmd) => {
|
|
5883
|
+
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5884
|
+
try {
|
|
5885
|
+
requireCloud3(client);
|
|
5886
|
+
const list = volume === void 0 ? await client.listVolumeBackups() : await client.volumeBackups(volume);
|
|
5887
|
+
if (opts.json) {
|
|
5888
|
+
json(list);
|
|
5889
|
+
return;
|
|
5890
|
+
}
|
|
5891
|
+
if (list.length === 0) {
|
|
5892
|
+
info(volume === void 0 ? "no volume backups yet; make one with: kvbox volume backup create <volume>" : `volume ${volume} has no backups; make one with: kvbox volume backup create ${volume}`);
|
|
5893
|
+
return;
|
|
5894
|
+
}
|
|
5895
|
+
const anyError = list.some((b) => b.error !== null);
|
|
5896
|
+
table(
|
|
5897
|
+
list.map((b) => ({
|
|
5898
|
+
id: b.id,
|
|
5899
|
+
...volume === void 0 ? { volume: b.owner === me(client) ? b.volume : `${b.owner}/${b.volume}` } : {},
|
|
5900
|
+
status: b.status === "ready" ? color.green(b.status) : b.status === "failed" ? color.red(b.status) : color.yellow(b.status),
|
|
5901
|
+
data: b.dataBytes === null ? "-" : gbShort(b.dataBytes),
|
|
5902
|
+
uploaded: b.uploadedBytes === null ? "-" : gbShort(b.uploadedBytes),
|
|
5903
|
+
size: b.diskBytes === null ? "-" : gbShort(b.diskBytes),
|
|
5904
|
+
by: b.createdBy ?? "-",
|
|
5905
|
+
taken: age(b.createdAt),
|
|
5906
|
+
...anyError ? { error: b.error ?? "" } : {}
|
|
5907
|
+
}))
|
|
5908
|
+
);
|
|
5909
|
+
} finally {
|
|
5910
|
+
await client.close();
|
|
5911
|
+
}
|
|
5912
|
+
});
|
|
5913
|
+
|
|
5914
|
+
// src/commands/volume/backup/restore.ts
|
|
5915
|
+
import { Command as Command58 } from "commander";
|
|
5916
|
+
var restoreCommand2 = new Command58("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 (volume, id, opts, cmd) => {
|
|
5917
|
+
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5918
|
+
try {
|
|
5919
|
+
requireCloud3(client);
|
|
5920
|
+
const backup = await client.volumeBackup(volume, id);
|
|
5921
|
+
const question = `Restore volume ${volume} from backup ${backup.id} (${age(backup.createdAt)} ago, ${sizeLine(backup)})? Everything written to it since is lost, and a running box that holds it restarts.`;
|
|
5922
|
+
if (!await confirm(question, opts.yes ?? false)) {
|
|
5923
|
+
info("cancelled");
|
|
5924
|
+
process.exitCode = 1;
|
|
5925
|
+
return;
|
|
5926
|
+
}
|
|
5927
|
+
const restored = await spin(`restoring volume ${volume} from ${backup.id}\u2026`, client.restoreVolumeBackup(volume, id));
|
|
5928
|
+
if (opts.json) {
|
|
5929
|
+
json(restored);
|
|
5930
|
+
return;
|
|
5931
|
+
}
|
|
5932
|
+
info(`${color.green("\u2713")} volume ${color.bold(volume)} restored from backup ${backup.id}${restored.attachedTo ? color.dim(` (box ${restored.attachedTo} was restarted if it was running)`) : ""}`);
|
|
5933
|
+
} finally {
|
|
5934
|
+
await client.close();
|
|
5935
|
+
}
|
|
5936
|
+
});
|
|
5937
|
+
|
|
5938
|
+
// src/commands/volume/backup/index.ts
|
|
5939
|
+
var backupCommand2 = new Command59("backup").description("back up a volume's disk to the kvbox cloud, list backups, restore one").addCommand(createCommand3).addCommand(lsCommand8).addCommand(restoreCommand2);
|
|
5940
|
+
for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
|
|
5941
|
+
|
|
5942
|
+
// src/commands/volume/create.ts
|
|
5943
|
+
import { Command as Command60 } from "commander";
|
|
5775
5944
|
function parseGib2(text2, label = "--size") {
|
|
5776
5945
|
const mib = parseMib(text2);
|
|
5777
5946
|
if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
|
|
@@ -5787,7 +5956,7 @@ function sizeProblem(answer) {
|
|
|
5787
5956
|
return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
|
|
5788
5957
|
}
|
|
5789
5958
|
}
|
|
5790
|
-
var
|
|
5959
|
+
var createCommand4 = new Command60("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) => {
|
|
5791
5960
|
const ask = interactive();
|
|
5792
5961
|
if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
|
|
5793
5962
|
const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
|
|
@@ -5820,8 +5989,8 @@ var createCommand3 = new Command56("create").alias("new").description("create a
|
|
|
5820
5989
|
});
|
|
5821
5990
|
|
|
5822
5991
|
// src/commands/volume/detach.ts
|
|
5823
|
-
import { Command as
|
|
5824
|
-
var detachCommand = new
|
|
5992
|
+
import { Command as Command61 } from "commander";
|
|
5993
|
+
var detachCommand = new Command61("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) => {
|
|
5825
5994
|
if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
|
|
5826
5995
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5827
5996
|
try {
|
|
@@ -5846,8 +6015,8 @@ var detachCommand = new Command57("detach").description("detach a volume from a
|
|
|
5846
6015
|
});
|
|
5847
6016
|
|
|
5848
6017
|
// src/commands/volume/grow.ts
|
|
5849
|
-
import { Command as
|
|
5850
|
-
var growCommand = new
|
|
6018
|
+
import { Command as Command62 } from "commander";
|
|
6019
|
+
var growCommand = new Command62("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) => {
|
|
5851
6020
|
const sizeGib = parseGib2(size, "size");
|
|
5852
6021
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5853
6022
|
try {
|
|
@@ -5860,8 +6029,8 @@ var growCommand = new Command58("grow").alias("resize").description("make a volu
|
|
|
5860
6029
|
});
|
|
5861
6030
|
|
|
5862
6031
|
// src/commands/volume/ls.ts
|
|
5863
|
-
import { Command as
|
|
5864
|
-
var
|
|
6032
|
+
import { Command as Command63 } from "commander";
|
|
6033
|
+
var lsCommand9 = new Command63("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) => {
|
|
5865
6034
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5866
6035
|
try {
|
|
5867
6036
|
const cloud = client.target.kind === "cloud";
|
|
@@ -5892,8 +6061,8 @@ var lsCommand8 = new Command59("ls").alias("list").description("list volumes: si
|
|
|
5892
6061
|
});
|
|
5893
6062
|
|
|
5894
6063
|
// src/commands/volume/rm.ts
|
|
5895
|
-
import { Command as
|
|
5896
|
-
var rmCommand7 = new
|
|
6064
|
+
import { Command as Command64 } from "commander";
|
|
6065
|
+
var rmCommand7 = new Command64("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) => {
|
|
5897
6066
|
if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
|
|
5898
6067
|
info("cancelled");
|
|
5899
6068
|
process.exitCode = 1;
|
|
@@ -5909,14 +6078,15 @@ var rmCommand7 = new Command60("rm").alias("remove").description("delete a volum
|
|
|
5909
6078
|
});
|
|
5910
6079
|
|
|
5911
6080
|
// src/commands/volume/index.ts
|
|
5912
|
-
var volumeCommand = new
|
|
6081
|
+
var volumeCommand = new Command65("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(createCommand4).addCommand(lsCommand9).addCommand(attachCommand).addCommand(detachCommand).addCommand(growCommand).addCommand(rmCommand7);
|
|
5913
6082
|
for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
|
|
6083
|
+
volumeCommand.addCommand(backupCommand2);
|
|
5914
6084
|
|
|
5915
6085
|
// src/commands/bucket/index.ts
|
|
5916
|
-
import { Command as
|
|
6086
|
+
import { Command as Command75 } from "commander";
|
|
5917
6087
|
|
|
5918
6088
|
// src/commands/bucket/create.ts
|
|
5919
|
-
import { Command as
|
|
6089
|
+
import { Command as Command66 } from "commander";
|
|
5920
6090
|
|
|
5921
6091
|
// src/commands/bucket/shared.ts
|
|
5922
6092
|
async function bucketClient(cmd) {
|
|
@@ -5942,7 +6112,7 @@ function printRows(rows2) {
|
|
|
5942
6112
|
}
|
|
5943
6113
|
|
|
5944
6114
|
// src/commands/bucket/create.ts
|
|
5945
|
-
var
|
|
6115
|
+
var createCommand5 = new Command66("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) => {
|
|
5946
6116
|
const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
|
|
5947
6117
|
const client = await bucketClient(cmd);
|
|
5948
6118
|
try {
|
|
@@ -5962,8 +6132,8 @@ var createCommand4 = new Command62("create").description("make a bucket (the fir
|
|
|
5962
6132
|
});
|
|
5963
6133
|
|
|
5964
6134
|
// src/commands/bucket/grow.ts
|
|
5965
|
-
import { Command as
|
|
5966
|
-
var growCommand2 = new
|
|
6135
|
+
import { Command as Command67 } from "commander";
|
|
6136
|
+
var growCommand2 = new Command67("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) => {
|
|
5967
6137
|
const sizeGib = parseGib2(size, "size");
|
|
5968
6138
|
const client = await bucketClient(cmd);
|
|
5969
6139
|
try {
|
|
@@ -5976,8 +6146,8 @@ var growCommand2 = new Command63("grow").description("make your object storage l
|
|
|
5976
6146
|
});
|
|
5977
6147
|
|
|
5978
6148
|
// src/commands/bucket/info.ts
|
|
5979
|
-
import { Command as
|
|
5980
|
-
var infoCommand = new
|
|
6149
|
+
import { Command as Command68 } from "commander";
|
|
6150
|
+
var infoCommand = new Command68("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) => {
|
|
5981
6151
|
const client = await bucketClient(cmd);
|
|
5982
6152
|
try {
|
|
5983
6153
|
const b = await client.getBucket(name);
|
|
@@ -6006,11 +6176,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
|
|
|
6006
6176
|
});
|
|
6007
6177
|
|
|
6008
6178
|
// src/commands/bucket/key/index.ts
|
|
6009
|
-
import { Command as
|
|
6179
|
+
import { Command as Command72 } from "commander";
|
|
6010
6180
|
|
|
6011
6181
|
// src/commands/bucket/key/create.ts
|
|
6012
|
-
import { Command as
|
|
6013
|
-
var
|
|
6182
|
+
import { Command as Command69 } from "commander";
|
|
6183
|
+
var createCommand6 = new Command69("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) => {
|
|
6014
6184
|
const client = await bucketClient(cmd);
|
|
6015
6185
|
try {
|
|
6016
6186
|
const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
|
|
@@ -6033,8 +6203,8 @@ var createCommand5 = new Command65("create").description("make an access key for
|
|
|
6033
6203
|
});
|
|
6034
6204
|
|
|
6035
6205
|
// src/commands/bucket/key/ls.ts
|
|
6036
|
-
import { Command as
|
|
6037
|
-
var
|
|
6206
|
+
import { Command as Command70 } from "commander";
|
|
6207
|
+
var lsCommand10 = new Command70("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) => {
|
|
6038
6208
|
const client = await bucketClient(cmd);
|
|
6039
6209
|
try {
|
|
6040
6210
|
const keys = await client.listBucketKeys(bucket);
|
|
@@ -6053,8 +6223,8 @@ var lsCommand9 = new Command66("ls").alias("list").description("list a bucket's
|
|
|
6053
6223
|
});
|
|
6054
6224
|
|
|
6055
6225
|
// src/commands/bucket/key/rm.ts
|
|
6056
|
-
import { Command as
|
|
6057
|
-
var rmCommand8 = new
|
|
6226
|
+
import { Command as Command71 } from "commander";
|
|
6227
|
+
var rmCommand8 = new Command71("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) => {
|
|
6058
6228
|
const client = await bucketClient(cmd);
|
|
6059
6229
|
try {
|
|
6060
6230
|
if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
|
|
@@ -6070,11 +6240,11 @@ var rmCommand8 = new Command67("rm").alias("remove").description("delete an acce
|
|
|
6070
6240
|
});
|
|
6071
6241
|
|
|
6072
6242
|
// src/commands/bucket/key/index.ts
|
|
6073
|
-
var keyCommand = new
|
|
6243
|
+
var keyCommand = new Command72("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand6).addCommand(lsCommand10).addCommand(rmCommand8);
|
|
6074
6244
|
|
|
6075
6245
|
// src/commands/bucket/ls.ts
|
|
6076
|
-
import { Command as
|
|
6077
|
-
var
|
|
6246
|
+
import { Command as Command73 } from "commander";
|
|
6247
|
+
var lsCommand11 = new Command73("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) => {
|
|
6078
6248
|
const client = await bucketClient(cmd);
|
|
6079
6249
|
try {
|
|
6080
6250
|
const buckets = await client.listBuckets({ all: opts.all });
|
|
@@ -6104,8 +6274,8 @@ var lsCommand10 = new Command69("ls").alias("list").description("list buckets, a
|
|
|
6104
6274
|
});
|
|
6105
6275
|
|
|
6106
6276
|
// src/commands/bucket/rm.ts
|
|
6107
|
-
import { Command as
|
|
6108
|
-
var rmCommand9 = new
|
|
6277
|
+
import { Command as Command74 } from "commander";
|
|
6278
|
+
var rmCommand9 = new Command74("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) => {
|
|
6109
6279
|
const client = await bucketClient(cmd);
|
|
6110
6280
|
try {
|
|
6111
6281
|
const question = opts.force ? `Delete bucket ${name} with everything in it, and the object storage it is in?` : `Delete bucket ${name} and its keys?`;
|
|
@@ -6124,7 +6294,7 @@ var rmCommand9 = new Command70("rm").alias("remove").description("delete an empt
|
|
|
6124
6294
|
});
|
|
6125
6295
|
|
|
6126
6296
|
// src/commands/bucket/index.ts
|
|
6127
|
-
var bucketCommand = new
|
|
6297
|
+
var bucketCommand = new Command75("bucket").aliases(["buckets"]).description("object storage: S3 buckets for your files, and the access keys your apps use").addCommand(createCommand5).addCommand(lsCommand11).addCommand(infoCommand).addCommand(growCommand2).addCommand(rmCommand9).addCommand(keyCommand);
|
|
6128
6298
|
var withOrg = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
|
|
6129
6299
|
for (const cmd of bucketCommand.commands) {
|
|
6130
6300
|
if (cmd === keyCommand) cmd.commands.forEach(withOrg);
|
|
@@ -6132,10 +6302,10 @@ for (const cmd of bucketCommand.commands) {
|
|
|
6132
6302
|
}
|
|
6133
6303
|
|
|
6134
6304
|
// src/commands/managed/kind.ts
|
|
6135
|
-
import { Command as
|
|
6305
|
+
import { Command as Command88 } from "commander";
|
|
6136
6306
|
|
|
6137
6307
|
// src/commands/managed/create.ts
|
|
6138
|
-
import { Command as
|
|
6308
|
+
import { Command as Command77 } from "commander";
|
|
6139
6309
|
import { setTimeout as sleep3 } from "timers/promises";
|
|
6140
6310
|
|
|
6141
6311
|
// src/commands/managed/shared.ts
|
|
@@ -6221,8 +6391,8 @@ function parseStorage(text2, flag) {
|
|
|
6221
6391
|
// src/commands/managed/create.ts
|
|
6222
6392
|
var READY_WAIT_MS = 9e4;
|
|
6223
6393
|
var READY_STEP_MS = 2e3;
|
|
6224
|
-
var
|
|
6225
|
-
const command = new
|
|
6394
|
+
var createCommand7 = (spec) => {
|
|
6395
|
+
const command = new Command77("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");
|
|
6226
6396
|
for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
|
|
6227
6397
|
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 the box can be linked to it").option("--json", "print it as JSON, password included").action(async (name, opts, cmd) => {
|
|
6228
6398
|
const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
|
|
@@ -6263,8 +6433,8 @@ var createCommand6 = (spec) => {
|
|
|
6263
6433
|
};
|
|
6264
6434
|
|
|
6265
6435
|
// src/commands/managed/grow.ts
|
|
6266
|
-
import { Command as
|
|
6267
|
-
var growCommand3 = (spec) => new
|
|
6436
|
+
import { Command as Command78 } from "commander";
|
|
6437
|
+
var growCommand3 = (spec) => new Command78("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) => {
|
|
6268
6438
|
const storageGib = parseStorage(size, "size");
|
|
6269
6439
|
const client = await managedClient(cmd);
|
|
6270
6440
|
try {
|
|
@@ -6277,8 +6447,8 @@ var growCommand3 = (spec) => new Command74("grow").description("give a database
|
|
|
6277
6447
|
});
|
|
6278
6448
|
|
|
6279
6449
|
// src/commands/managed/info.ts
|
|
6280
|
-
import { Command as
|
|
6281
|
-
var infoCommand2 = (spec) => new
|
|
6450
|
+
import { Command as Command79 } from "commander";
|
|
6451
|
+
var infoCommand2 = (spec) => new Command79("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) => {
|
|
6282
6452
|
const client = await managedClient(cmd);
|
|
6283
6453
|
try {
|
|
6284
6454
|
const m = await client.getManaged(spec.kind, name);
|
|
@@ -6290,8 +6460,8 @@ var infoCommand2 = (spec) => new Command75("info").alias("get").description("sho
|
|
|
6290
6460
|
});
|
|
6291
6461
|
|
|
6292
6462
|
// src/commands/managed/link.ts
|
|
6293
|
-
import { Command as
|
|
6294
|
-
var linkCommand2 = (spec) => new
|
|
6463
|
+
import { Command as Command80 } from "commander";
|
|
6464
|
+
var linkCommand2 = (spec) => new Command80("link").description("let a box reach a database privately (same host)").argument("<db>", "the database").argument("<box>", "the box that connects to it").option("--json", "print as JSON").action(async (name, box, opts, cmd) => {
|
|
6295
6465
|
const client = await managedClient(cmd);
|
|
6296
6466
|
try {
|
|
6297
6467
|
const m = await spin(`linking ${box} to ${name}\u2026`, client.linkManaged(spec.kind, name, box));
|
|
@@ -6307,7 +6477,7 @@ var linkCommand2 = (spec) => new Command76("link").description("let a box reach
|
|
|
6307
6477
|
});
|
|
6308
6478
|
|
|
6309
6479
|
// src/commands/managed/ls.ts
|
|
6310
|
-
import { Command as
|
|
6480
|
+
import { Command as Command81 } from "commander";
|
|
6311
6481
|
function listRows(items, user, kindColumn) {
|
|
6312
6482
|
return items.map((m) => ({
|
|
6313
6483
|
owner: m.owner === user ? "private" : m.owner,
|
|
@@ -6321,7 +6491,7 @@ function listRows(items, user, kindColumn) {
|
|
|
6321
6491
|
created: age(m.createdAt)
|
|
6322
6492
|
}));
|
|
6323
6493
|
}
|
|
6324
|
-
var
|
|
6494
|
+
var lsCommand12 = (spec) => new Command81("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) => {
|
|
6325
6495
|
const client = await managedClient(cmd);
|
|
6326
6496
|
try {
|
|
6327
6497
|
const items = await client.listManaged(spec?.kind, { all: opts.all });
|
|
@@ -6341,8 +6511,8 @@ var lsCommand11 = (spec) => new Command77("ls").alias("list").description(spec ?
|
|
|
6341
6511
|
});
|
|
6342
6512
|
|
|
6343
6513
|
// src/commands/managed/password.ts
|
|
6344
|
-
import { Command as
|
|
6345
|
-
var passwordCommand = (spec) => new
|
|
6514
|
+
import { Command as Command82 } from "commander";
|
|
6515
|
+
var passwordCommand = (spec) => new Command82("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) => {
|
|
6346
6516
|
const client = await managedClient(cmd);
|
|
6347
6517
|
try {
|
|
6348
6518
|
const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
|
|
@@ -6358,8 +6528,8 @@ var passwordCommand = (spec) => new Command78("password").description("show a da
|
|
|
6358
6528
|
});
|
|
6359
6529
|
|
|
6360
6530
|
// src/commands/managed/public.ts
|
|
6361
|
-
import { Command as
|
|
6362
|
-
var publicCommand = (spec) => new
|
|
6531
|
+
import { Command as Command83 } from "commander";
|
|
6532
|
+
var publicCommand = (spec) => new Command83("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) => {
|
|
6363
6533
|
if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
|
|
6364
6534
|
const client = await managedClient(cmd);
|
|
6365
6535
|
try {
|
|
@@ -6380,8 +6550,8 @@ var publicCommand = (spec) => new Command79("public").description("open a databa
|
|
|
6380
6550
|
});
|
|
6381
6551
|
|
|
6382
6552
|
// src/commands/managed/rm.ts
|
|
6383
|
-
import { Command as
|
|
6384
|
-
var rmCommand10 = (spec) => new
|
|
6553
|
+
import { Command as Command84 } from "commander";
|
|
6554
|
+
var rmCommand10 = (spec) => new Command84("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) => {
|
|
6385
6555
|
const client = await managedClient(cmd);
|
|
6386
6556
|
try {
|
|
6387
6557
|
if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
|
|
@@ -6397,8 +6567,8 @@ var rmCommand10 = (spec) => new Command80("rm").alias("remove").description("del
|
|
|
6397
6567
|
});
|
|
6398
6568
|
|
|
6399
6569
|
// src/commands/managed/start.ts
|
|
6400
|
-
import { Command as
|
|
6401
|
-
var startCommand2 = (spec) => new
|
|
6570
|
+
import { Command as Command85 } from "commander";
|
|
6571
|
+
var startCommand2 = (spec) => new Command85("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
6402
6572
|
const client = await managedClient(cmd);
|
|
6403
6573
|
try {
|
|
6404
6574
|
const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
|
|
@@ -6410,8 +6580,8 @@ var startCommand2 = (spec) => new Command81("start").description("run a stopped
|
|
|
6410
6580
|
});
|
|
6411
6581
|
|
|
6412
6582
|
// src/commands/managed/stop.ts
|
|
6413
|
-
import { Command as
|
|
6414
|
-
var stopCommand2 = (spec) => new
|
|
6583
|
+
import { Command as Command86 } from "commander";
|
|
6584
|
+
var stopCommand2 = (spec) => new Command86("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) => {
|
|
6415
6585
|
const client = await managedClient(cmd);
|
|
6416
6586
|
try {
|
|
6417
6587
|
const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
|
|
@@ -6423,8 +6593,8 @@ var stopCommand2 = (spec) => new Command82("stop").description("shut a database
|
|
|
6423
6593
|
});
|
|
6424
6594
|
|
|
6425
6595
|
// src/commands/managed/unlink.ts
|
|
6426
|
-
import { Command as
|
|
6427
|
-
var unlinkCommand2 = (spec) => new
|
|
6596
|
+
import { Command as Command87 } from "commander";
|
|
6597
|
+
var unlinkCommand2 = (spec) => new Command87("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, box, opts, cmd) => {
|
|
6428
6598
|
const client = await managedClient(cmd);
|
|
6429
6599
|
try {
|
|
6430
6600
|
const m = await spin(`unlinking ${box} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box));
|
|
@@ -6437,8 +6607,8 @@ var unlinkCommand2 = (spec) => new Command83("unlink").description("stop a box f
|
|
|
6437
6607
|
|
|
6438
6608
|
// src/commands/managed/kind.ts
|
|
6439
6609
|
function kindCommand(spec, description) {
|
|
6440
|
-
const command = new
|
|
6441
|
-
for (const make of [
|
|
6610
|
+
const command = new Command88(spec.command).aliases(spec.aliases).description(description);
|
|
6611
|
+
for (const make of [createCommand7, lsCommand12, infoCommand2, passwordCommand, publicCommand, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand10]) {
|
|
6442
6612
|
command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
6443
6613
|
}
|
|
6444
6614
|
return command;
|
|
@@ -6451,14 +6621,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
|
|
|
6451
6621
|
var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
|
|
6452
6622
|
|
|
6453
6623
|
// src/commands/managed/index.ts
|
|
6454
|
-
import { Command as
|
|
6455
|
-
var managedCommand = new
|
|
6624
|
+
import { Command as Command89 } from "commander";
|
|
6625
|
+
var managedCommand = new Command89("managed").description(`databases kvbox runs for you, every kind together (${KINDS.map((k) => `${k.title}: kvbox ${k.command}`).join(", ")})`).addCommand(lsCommand12().option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
6456
6626
|
|
|
6457
6627
|
// src/commands/env/index.ts
|
|
6458
|
-
import { Command as
|
|
6628
|
+
import { Command as Command93 } from "commander";
|
|
6459
6629
|
|
|
6460
6630
|
// src/commands/env/ls.ts
|
|
6461
|
-
import { Command as
|
|
6631
|
+
import { Command as Command90 } from "commander";
|
|
6462
6632
|
|
|
6463
6633
|
// src/commands/env/shared.ts
|
|
6464
6634
|
function requireCloud4(client) {
|
|
@@ -6485,7 +6655,7 @@ function firstBootHint(box, name) {
|
|
|
6485
6655
|
}
|
|
6486
6656
|
|
|
6487
6657
|
// src/commands/env/ls.ts
|
|
6488
|
-
var
|
|
6658
|
+
var lsCommand13 = new Command90("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) => {
|
|
6489
6659
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6490
6660
|
try {
|
|
6491
6661
|
if (opts.box !== void 0) {
|
|
@@ -6524,8 +6694,8 @@ var lsCommand12 = new Command86("ls").alias("list").description("list the variab
|
|
|
6524
6694
|
});
|
|
6525
6695
|
|
|
6526
6696
|
// src/commands/env/rm.ts
|
|
6527
|
-
import { Command as
|
|
6528
|
-
var rmCommand11 = new
|
|
6697
|
+
import { Command as Command91 } from "commander";
|
|
6698
|
+
var rmCommand11 = new Command91("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) => {
|
|
6529
6699
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6530
6700
|
try {
|
|
6531
6701
|
const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
|
|
@@ -6562,8 +6732,8 @@ var rmCommand11 = new Command87("rm").alias("remove").description("remove variab
|
|
|
6562
6732
|
});
|
|
6563
6733
|
|
|
6564
6734
|
// src/commands/env/set.ts
|
|
6565
|
-
import { Command as
|
|
6566
|
-
var setCommand2 = new
|
|
6735
|
+
import { Command as Command92 } from "commander";
|
|
6736
|
+
var setCommand2 = new Command92("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) => {
|
|
6567
6737
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6568
6738
|
try {
|
|
6569
6739
|
const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
|
|
@@ -6600,14 +6770,14 @@ var setCommand2 = new Command88("set").description("add or change a variable; bo
|
|
|
6600
6770
|
});
|
|
6601
6771
|
|
|
6602
6772
|
// src/commands/env/index.ts
|
|
6603
|
-
var envCommand = new
|
|
6773
|
+
var envCommand = new Command93("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand13, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand11);
|
|
6604
6774
|
for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
|
|
6605
6775
|
|
|
6606
6776
|
// src/commands/domain/index.ts
|
|
6607
|
-
import { Command as
|
|
6777
|
+
import { Command as Command97 } from "commander";
|
|
6608
6778
|
|
|
6609
6779
|
// src/commands/domain/add.ts
|
|
6610
|
-
import { Command as
|
|
6780
|
+
import { Command as Command94 } from "commander";
|
|
6611
6781
|
|
|
6612
6782
|
// src/commands/domain/shared.ts
|
|
6613
6783
|
function requireCloud5(client) {
|
|
@@ -6627,7 +6797,7 @@ function hostIn(name, zone) {
|
|
|
6627
6797
|
}
|
|
6628
6798
|
|
|
6629
6799
|
// src/commands/domain/add.ts
|
|
6630
|
-
var addCommand3 = new
|
|
6800
|
+
var addCommand3 = new Command94("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) => {
|
|
6631
6801
|
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
6632
6802
|
const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
|
|
6633
6803
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
@@ -6663,8 +6833,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
|
|
|
6663
6833
|
});
|
|
6664
6834
|
|
|
6665
6835
|
// src/commands/domain/ls.ts
|
|
6666
|
-
import { Command as
|
|
6667
|
-
var
|
|
6836
|
+
import { Command as Command95 } from "commander";
|
|
6837
|
+
var lsCommand14 = new Command95("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
6668
6838
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
6669
6839
|
try {
|
|
6670
6840
|
requireCloud5(client);
|
|
@@ -6693,8 +6863,8 @@ var lsCommand13 = new Command91("ls").alias("list").description("list your custo
|
|
|
6693
6863
|
});
|
|
6694
6864
|
|
|
6695
6865
|
// src/commands/domain/rm.ts
|
|
6696
|
-
import { Command as
|
|
6697
|
-
var rmCommand12 = new
|
|
6866
|
+
import { Command as Command96 } from "commander";
|
|
6867
|
+
var rmCommand12 = new Command96("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) => {
|
|
6698
6868
|
const domain = domainArg.trim().toLowerCase();
|
|
6699
6869
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
6700
6870
|
try {
|
|
@@ -6715,7 +6885,7 @@ var rmCommand12 = new Command92("rm").alias("remove").description("stop serving
|
|
|
6715
6885
|
});
|
|
6716
6886
|
|
|
6717
6887
|
// src/commands/domain/index.ts
|
|
6718
|
-
var domainCommand = new
|
|
6888
|
+
var domainCommand = new Command97("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand3).addCommand(lsCommand14).addCommand(rmCommand12);
|
|
6719
6889
|
for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
6720
6890
|
|
|
6721
6891
|
// src/commands/update.ts
|
|
@@ -6723,7 +6893,7 @@ import { spawn as spawn6 } from "child_process";
|
|
|
6723
6893
|
import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
6724
6894
|
import { tmpdir } from "os";
|
|
6725
6895
|
import { join as join9 } from "path";
|
|
6726
|
-
import { Command as
|
|
6896
|
+
import { Command as Command98 } from "commander";
|
|
6727
6897
|
|
|
6728
6898
|
// src/update.ts
|
|
6729
6899
|
import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
@@ -6842,7 +7012,7 @@ function run2(cmd, args) {
|
|
|
6842
7012
|
child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
|
|
6843
7013
|
});
|
|
6844
7014
|
}
|
|
6845
|
-
var selfUpdateCommand = new
|
|
7015
|
+
var selfUpdateCommand = new Command98("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
|
|
6846
7016
|
suppressUpdateNotice();
|
|
6847
7017
|
const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
|
|
6848
7018
|
let code;
|
|
@@ -6967,7 +7137,7 @@ function installRootHelp(program) {
|
|
|
6967
7137
|
|
|
6968
7138
|
// src/program.ts
|
|
6969
7139
|
function buildProgram() {
|
|
6970
|
-
const program = new
|
|
7140
|
+
const program = new Command99("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").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();
|
|
6971
7141
|
program.addCommand(vmCommand);
|
|
6972
7142
|
program.addCommand(snapshotsCommand);
|
|
6973
7143
|
program.addCommand(volumeCommand);
|