@kvbox/cli 0.6.8 → 0.6.9
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 +456 -197
- package/dist/kvbox.js.map +1 -1
- package/package.json +1 -1
package/dist/kvbox.js
CHANGED
|
@@ -9,6 +9,12 @@ var KvboxError = class extends Error {
|
|
|
9
9
|
}
|
|
10
10
|
exitCode;
|
|
11
11
|
};
|
|
12
|
+
var NotFoundError = class extends KvboxError {
|
|
13
|
+
constructor(what) {
|
|
14
|
+
super(`${what}: not found`, 1);
|
|
15
|
+
this.name = "NotFoundError";
|
|
16
|
+
}
|
|
17
|
+
};
|
|
12
18
|
var AmbiguousRefError = class extends KvboxError {
|
|
13
19
|
/** `orgFlag` false: `--org` names something else on this command (a fork's target), so only `slug/name` is offered. */
|
|
14
20
|
constructor(kind, name, slugs, orgFlag = true) {
|
|
@@ -149,7 +155,7 @@ async function spin(message, work, opts = {}) {
|
|
|
149
155
|
}
|
|
150
156
|
|
|
151
157
|
// src/program.ts
|
|
152
|
-
import { Command as
|
|
158
|
+
import { Command as Command123 } from "commander";
|
|
153
159
|
|
|
154
160
|
// ../shared/src/version.ts
|
|
155
161
|
import { createRequire } from "module";
|
|
@@ -164,10 +170,10 @@ function versionOf(srcFileUrl, injected) {
|
|
|
164
170
|
}
|
|
165
171
|
|
|
166
172
|
// src/version.ts
|
|
167
|
-
var VERSION = versionOf(import.meta.url, true ? "0.6.
|
|
173
|
+
var VERSION = versionOf(import.meta.url, true ? "0.6.9" : void 0);
|
|
168
174
|
|
|
169
175
|
// src/commands/vm/index.ts
|
|
170
|
-
import { Command as
|
|
176
|
+
import { Command as Command38 } from "commander";
|
|
171
177
|
|
|
172
178
|
// src/commands/vm/connect.ts
|
|
173
179
|
import { spawnSync as spawnSync3 } from "child_process";
|
|
@@ -531,16 +537,20 @@ var CloudBackupStoreSchema = z.object({
|
|
|
531
537
|
/** Ready backups kept here, and what their chunks take (encrypted, compressed). */
|
|
532
538
|
backups: z.number().int(),
|
|
533
539
|
storedBytes: z.number().int(),
|
|
534
|
-
/** How many boxes have a ready backup here (a box and an earlier one of the same name count once),
|
|
540
|
+
/** How many boxes have a ready backup here (a box and an earlier one of the same name count once), how many volumes (#168) and managed databases (#186). */
|
|
535
541
|
boxes: z.number().int(),
|
|
536
542
|
volumes: z.number().int(),
|
|
543
|
+
databases: z.number().int(),
|
|
537
544
|
/** When the newest ready backup kept here finished; null when it keeps none. */
|
|
538
545
|
lastBackupAt: z.string().nullable()
|
|
539
546
|
});
|
|
540
547
|
var StoredItemSchema = z.object({
|
|
541
548
|
kind: z.enum(BACKUP_KINDS),
|
|
542
549
|
owner: z.string(),
|
|
550
|
+
/** The box's or volume's name; a managed database's (#186) for its hidden volume. */
|
|
543
551
|
name: z.string(),
|
|
552
|
+
/** The managed database's kind (`postgres`) when the volume is one's (#186); null otherwise. */
|
|
553
|
+
managed: z.string().nullable(),
|
|
544
554
|
/** The host the box (or volume) is on now; null when it is gone (its backups stay). */
|
|
545
555
|
host: z.string().nullable(),
|
|
546
556
|
/** It is on the store's own host: losing that host loses it and its backups together. */
|
|
@@ -554,9 +564,11 @@ var StoredItemSchema = z.object({
|
|
|
554
564
|
var FailedBackupSchema = z.object({
|
|
555
565
|
id: z.string(),
|
|
556
566
|
owner: z.string(),
|
|
557
|
-
/** What it was a backup of: a box or a volume (#168), and its name. */
|
|
567
|
+
/** What it was a backup of: a box or a volume (#168), and its name; a managed database's (#186) for its hidden volume. */
|
|
558
568
|
kind: z.enum(BACKUP_KINDS),
|
|
559
569
|
name: z.string(),
|
|
570
|
+
/** The managed database's kind (`postgres`) when the volume is one's; null otherwise. */
|
|
571
|
+
managed: z.string().nullable(),
|
|
560
572
|
error: z.string().nullable(),
|
|
561
573
|
/** 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. */
|
|
562
574
|
host: z.string().nullable(),
|
|
@@ -1091,7 +1103,7 @@ var VolumeEventsResponseSchema = z.object({
|
|
|
1091
1103
|
events: z.array(VolumeEventRowSchema),
|
|
1092
1104
|
next: z.number().int()
|
|
1093
1105
|
});
|
|
1094
|
-
var API_ERROR_CODES = ["account-inactive", "org-inactive", "out-of-credit", "box-outdated"];
|
|
1106
|
+
var API_ERROR_CODES = ["account-inactive", "org-inactive", "out-of-credit", "box-outdated", "storage-outdated", "object-exists", "storage-waking"];
|
|
1095
1107
|
var ApiErrorCodeSchema = z.enum(API_ERROR_CODES);
|
|
1096
1108
|
var ApiErrorSchema = z.object({
|
|
1097
1109
|
error: z.string(),
|
|
@@ -1583,7 +1595,7 @@ var PaymentRequiredError = class extends KvboxApiError {
|
|
|
1583
1595
|
this.name = "PaymentRequiredError";
|
|
1584
1596
|
}
|
|
1585
1597
|
};
|
|
1586
|
-
var
|
|
1598
|
+
var NotFoundError2 = class extends KvboxApiError {
|
|
1587
1599
|
constructor(status2, message, opts = {}) {
|
|
1588
1600
|
super(status2, message, opts);
|
|
1589
1601
|
this.name = "NotFoundError";
|
|
@@ -1608,7 +1620,7 @@ function apiError(status2, message, opts = {}) {
|
|
|
1608
1620
|
case 402:
|
|
1609
1621
|
return new PaymentRequiredError(status2, message, opts);
|
|
1610
1622
|
case 404:
|
|
1611
|
-
return new
|
|
1623
|
+
return new NotFoundError2(status2, message, opts);
|
|
1612
1624
|
case 409:
|
|
1613
1625
|
return opts.code === "box-outdated" ? new BoxOutdatedError(status2, message, opts) : new ConflictError(status2, message, opts);
|
|
1614
1626
|
default:
|
|
@@ -1679,7 +1691,7 @@ var Machines = class {
|
|
|
1679
1691
|
const named = listing.filter((m) => m.name === bare && (slash === -1 || slugOf2(m.owner) === org));
|
|
1680
1692
|
if (named.length <= 1) {
|
|
1681
1693
|
if (named[0] !== void 0) return named[0];
|
|
1682
|
-
throw new
|
|
1694
|
+
throw new NotFoundError2(404, `box ${name}: not found`);
|
|
1683
1695
|
}
|
|
1684
1696
|
const own = named.filter((m) => m.ownerKind === "user");
|
|
1685
1697
|
if (own.length === 1) return own[0];
|
|
@@ -2176,6 +2188,25 @@ var ResetPasswordRequest = z8.object({ password: z8.string().optional() });
|
|
|
2176
2188
|
var SetPublicRequest = z8.object({ on: z8.boolean() });
|
|
2177
2189
|
var ManagedLinkRequest = z8.object({ box: z8.string() });
|
|
2178
2190
|
var GrowManagedRequest = z8.object({ storageGib: z8.number().int() });
|
|
2191
|
+
var ManagedBackupSchema = z8.object({
|
|
2192
|
+
id: z8.string(),
|
|
2193
|
+
owner: z8.string(),
|
|
2194
|
+
kind: z8.string(),
|
|
2195
|
+
name: z8.string(),
|
|
2196
|
+
version: z8.string(),
|
|
2197
|
+
status: z8.enum(BACKUP_STATUSES),
|
|
2198
|
+
/** Why it failed; null otherwise. */
|
|
2199
|
+
error: z8.string().nullable(),
|
|
2200
|
+
/** The service's storage when taken. */
|
|
2201
|
+
diskBytes: z8.number().int().nullable(),
|
|
2202
|
+
/** What it holds: the slots that are not all zeros. */
|
|
2203
|
+
dataBytes: z8.number().int().nullable(),
|
|
2204
|
+
/** What this backup added to storage (encrypted, compressed): the chunks no earlier backup had. */
|
|
2205
|
+
uploadedBytes: z8.number().int().nullable(),
|
|
2206
|
+
createdBy: z8.string().nullable(),
|
|
2207
|
+
createdAt: z8.string(),
|
|
2208
|
+
finishedAt: z8.string().nullable()
|
|
2209
|
+
});
|
|
2179
2210
|
|
|
2180
2211
|
// ../shared/src/cron.ts
|
|
2181
2212
|
import { z as z9 } from "zod";
|
|
@@ -2297,6 +2328,8 @@ var ObjectStorageSchema = z10.object({
|
|
|
2297
2328
|
/** With `?live=1`, when the storage answered: what is on its disk, and the disk's real size. */
|
|
2298
2329
|
usedBytes: z10.number().optional(),
|
|
2299
2330
|
totalBytes: z10.number().optional(),
|
|
2331
|
+
/** With `?live=1`, when the storage answered: what each bucket holds. */
|
|
2332
|
+
bucketUsage: z10.array(z10.object({ name: z10.string(), objects: z10.number(), bytes: z10.number() })).optional(),
|
|
2300
2333
|
host: z10.string(),
|
|
2301
2334
|
country: z10.string().optional(),
|
|
2302
2335
|
buckets: z10.number().int(),
|
|
@@ -2335,6 +2368,64 @@ var BucketKeySchema = z10.object({
|
|
|
2335
2368
|
var CreateBucketKeyRequest = z10.object({ name: z10.string().optional(), readOnly: z10.boolean().optional() });
|
|
2336
2369
|
var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z10.string(), endpoint: z10.string().nullable(), region: z10.string() });
|
|
2337
2370
|
var GrowStorageRequest = z10.object({ sizeGib: z10.number().int() });
|
|
2371
|
+
var OBJECT_LIST_MAX = 1e3;
|
|
2372
|
+
var SHARE_LINK_MAX_SEC = 7 * 24 * 3600;
|
|
2373
|
+
var UPLOAD_URL_SEC = 12 * 3600;
|
|
2374
|
+
var MULTIPART_THRESHOLD_BYTES = 64 * 1024 * 1024;
|
|
2375
|
+
var MULTIPART_PART_BYTES = 16 * 1024 * 1024;
|
|
2376
|
+
var UPLOAD_MAX_BYTES = 50 * 1024 * 1024 * 1024;
|
|
2377
|
+
var MOVE_MAX_BYTES = 5 * 1024 * 1024 * 1024;
|
|
2378
|
+
var DELETE_PREFIXES_MAX = 100;
|
|
2379
|
+
var StoredObjectSchema = z10.object({
|
|
2380
|
+
key: z10.string(),
|
|
2381
|
+
size: z10.number(),
|
|
2382
|
+
etag: z10.string(),
|
|
2383
|
+
/** ISO 8601. */
|
|
2384
|
+
modified: z10.string()
|
|
2385
|
+
});
|
|
2386
|
+
var ObjectListingSchema = z10.object({
|
|
2387
|
+
prefix: z10.string(),
|
|
2388
|
+
folders: z10.array(z10.string()),
|
|
2389
|
+
objects: z10.array(StoredObjectSchema),
|
|
2390
|
+
next: z10.string().optional(),
|
|
2391
|
+
canWrite: z10.boolean()
|
|
2392
|
+
});
|
|
2393
|
+
var ObjectInfoSchema = StoredObjectSchema.extend({ contentType: z10.string() });
|
|
2394
|
+
var ObjectCountSchema = z10.object({ objects: z10.number(), bytes: z10.number(), more: z10.boolean() });
|
|
2395
|
+
var ObjectLinkRequest = z10.object({
|
|
2396
|
+
key: z10.string(),
|
|
2397
|
+
expiresSec: z10.number().int().positive(),
|
|
2398
|
+
/** Answer as a download (`Content-Disposition: attachment`) instead of showing it. */
|
|
2399
|
+
download: z10.boolean().optional(),
|
|
2400
|
+
/**
|
|
2401
|
+
* Let the browser keep what the link answers until the link expires (`Cache-Control: private`, `Expires`),
|
|
2402
|
+
* so the same link shown twice is fetched once. Asked again within the hour, for the same file as it
|
|
2403
|
+
* is, it is the same URL, and it lasts up to an hour longer than `expiresSec`. For the app's own previews.
|
|
2404
|
+
* Only a fetch of the whole file is kept so: the storage answers a part of one (`Range`) without the two headers.
|
|
2405
|
+
*/
|
|
2406
|
+
cached: z10.boolean().optional()
|
|
2407
|
+
});
|
|
2408
|
+
var ObjectLinkSchema = z10.object({ url: z10.string(), expiresAt: z10.string() });
|
|
2409
|
+
var MEDIA_TYPE_RE = /^[\w.+-]+\/[\w.+-]+(?:\s*;[\x20-\x7e]*)?$/;
|
|
2410
|
+
var StartUploadRequest = z10.object({ key: z10.string(), size: z10.number().int().nonnegative(), contentType: z10.string().max(200).regex(MEDIA_TYPE_RE, "not a media type like image/png").optional(), overwrite: z10.boolean().optional() });
|
|
2411
|
+
var UploadPlanSchema = z10.discriminatedUnion("kind", [
|
|
2412
|
+
z10.object({ kind: z10.literal("single"), url: z10.string() }),
|
|
2413
|
+
z10.object({ kind: z10.literal("multipart"), uploadId: z10.string(), partSize: z10.number(), urls: z10.array(z10.string()) })
|
|
2414
|
+
]);
|
|
2415
|
+
var CompleteUploadRequest = z10.object({
|
|
2416
|
+
key: z10.string(),
|
|
2417
|
+
uploadId: z10.string(),
|
|
2418
|
+
parts: z10.array(z10.object({ part: z10.number().int().positive(), etag: z10.string() })).min(1)
|
|
2419
|
+
});
|
|
2420
|
+
var AbortUploadRequest = z10.object({ key: z10.string(), uploadId: z10.string() });
|
|
2421
|
+
var DeleteObjectsRequest = z10.object({ keys: z10.array(z10.string()).max(OBJECT_LIST_MAX).optional(), prefixes: z10.array(z10.string()).max(DELETE_PREFIXES_MAX).optional() });
|
|
2422
|
+
var DeletedObjectsSchema = z10.object({
|
|
2423
|
+
deleted: z10.number(),
|
|
2424
|
+
more: z10.boolean(),
|
|
2425
|
+
errors: z10.array(z10.object({ key: z10.string(), message: z10.string() }))
|
|
2426
|
+
});
|
|
2427
|
+
var MoveObjectRequest = z10.object({ from: z10.string(), to: z10.string(), overwrite: z10.boolean().optional() });
|
|
2428
|
+
var CreateFolderRequest = z10.object({ prefix: z10.string() });
|
|
2338
2429
|
|
|
2339
2430
|
// src/kvm.ts
|
|
2340
2431
|
import { accessSync, constants, readFileSync, statSync } from "fs";
|
|
@@ -2570,6 +2661,13 @@ var ServerClient = class {
|
|
|
2570
2661
|
createBoxBackup(name) {
|
|
2571
2662
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/backups`, BackupSchema);
|
|
2572
2663
|
}
|
|
2664
|
+
/**
|
|
2665
|
+
* Remove a backup of any kind by its id (#111): gone from every listing at once, its storage freed a day
|
|
2666
|
+
* later. Works for a backup whose box, volume or database is gone too.
|
|
2667
|
+
*/
|
|
2668
|
+
removeBackup(id) {
|
|
2669
|
+
return this.call("DELETE", `/backups/${encodeURIComponent(id)}`, z11.undefined());
|
|
2670
|
+
}
|
|
2573
2671
|
/** A volume's backups (#168): the same as a box's, of the volume's disk. Newest first. */
|
|
2574
2672
|
listVolumeBackups() {
|
|
2575
2673
|
return this.call("GET", "/backups?kind=volume", z11.array(VolumeBackupSchema));
|
|
@@ -2817,6 +2915,27 @@ var ServerClient = class {
|
|
|
2817
2915
|
growManaged(kind, name, storageGib) {
|
|
2818
2916
|
return this.call("POST", this.managedPath(kind, name, "/grow"), ManagedSchema, { storageGib });
|
|
2819
2917
|
}
|
|
2918
|
+
/** A managed service's backups (#186): its storage's, by the volume backup engine. Every one of a kind, those of removed services too. */
|
|
2919
|
+
listManagedBackups(kind) {
|
|
2920
|
+
return this.call("GET", `/backups?managed=${encodeURIComponent(kind)}`, z11.array(ManagedBackupSchema));
|
|
2921
|
+
}
|
|
2922
|
+
managedBackups(kind, name) {
|
|
2923
|
+
return this.call("GET", this.managedPath(kind, name, "/backups"), z11.array(ManagedBackupSchema));
|
|
2924
|
+
}
|
|
2925
|
+
managedBackup(kind, name, id) {
|
|
2926
|
+
return this.call("GET", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}`), ManagedBackupSchema);
|
|
2927
|
+
}
|
|
2928
|
+
/** Starts one; it runs in the background (`running`), `managedBackup` says how it ended. */
|
|
2929
|
+
createManagedBackup(kind, name) {
|
|
2930
|
+
return this.call("POST", this.managedPath(kind, name, "/backups"), ManagedBackupSchema);
|
|
2931
|
+
}
|
|
2932
|
+
/**
|
|
2933
|
+
* The service's data becomes the backup's; it restarts. Waits for the whole download (the control
|
|
2934
|
+
* plane gives its host 2 h) and for the password to be set again (up to 3 min more), so 2 h 10 min.
|
|
2935
|
+
*/
|
|
2936
|
+
restoreManagedBackup(kind, name, id) {
|
|
2937
|
+
return this.call("POST", this.managedPath(kind, name, `/backups/${encodeURIComponent(id)}/restore`), ManagedSchema, {}, void 0, 2 * 36e5 + 10 * 6e4);
|
|
2938
|
+
}
|
|
2820
2939
|
stopManaged(kind, name) {
|
|
2821
2940
|
return this.call("POST", this.managedPath(kind, name, "/stop"), ManagedSchema);
|
|
2822
2941
|
}
|
|
@@ -4144,7 +4263,7 @@ var hookCommand = new Command21("hook").description("URLs that wake a box when c
|
|
|
4144
4263
|
for (const cmd of hookCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
4145
4264
|
|
|
4146
4265
|
// src/commands/vm/backup/index.ts
|
|
4147
|
-
import { Command as
|
|
4266
|
+
import { Command as Command26 } from "commander";
|
|
4148
4267
|
|
|
4149
4268
|
// src/commands/vm/backup/create.ts
|
|
4150
4269
|
import { Command as Command22 } from "commander";
|
|
@@ -4183,6 +4302,18 @@ function sizeLine(b) {
|
|
|
4183
4302
|
const added = b.uploadedBytes === null ? "" : `, ${gb(b.uploadedBytes)} uploaded`;
|
|
4184
4303
|
return `${data} of data${added}`;
|
|
4185
4304
|
}
|
|
4305
|
+
async function removeListed(client, listed, nameOf, name, id, what, yes) {
|
|
4306
|
+
const backup = listed.find((b) => b.id === id && (nameOf(b) === name || `${b.owner}/${nameOf(b)}` === name));
|
|
4307
|
+
if (!backup) throw new NotFoundError(`backup ${id} of ${what}`);
|
|
4308
|
+
const question = `Remove backup ${backup.id} of ${what} (${age(backup.createdAt)} ago, ${backup.status === "ready" ? sizeLine(backup) : backup.status})? It cannot be restored after this.`;
|
|
4309
|
+
if (!await confirm(question, yes)) {
|
|
4310
|
+
info("cancelled");
|
|
4311
|
+
process.exitCode = 1;
|
|
4312
|
+
return;
|
|
4313
|
+
}
|
|
4314
|
+
await client.removeBackup(backup.id);
|
|
4315
|
+
info(`${color.green("\u2713")} backup ${backup.id} of ${what} removed`);
|
|
4316
|
+
}
|
|
4186
4317
|
|
|
4187
4318
|
// src/commands/vm/backup/create.ts
|
|
4188
4319
|
var createCommand2 = new Command22("create").description("back up a box's disk to the kvbox cloud (encrypted; memory and volumes not included)").argument("<box>", "box 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) => {
|
|
@@ -4272,13 +4403,25 @@ var restoreCommand = new Command24("restore").description("put a backup back: th
|
|
|
4272
4403
|
}
|
|
4273
4404
|
});
|
|
4274
4405
|
|
|
4406
|
+
// src/commands/vm/backup/rm.ts
|
|
4407
|
+
import { Command as Command25 } from "commander";
|
|
4408
|
+
var rmCommand3 = new Command25("rm").alias("remove").description("remove a backup for good (a box's that is gone too)").argument("<box>", "box name").argument("<id>", "the backup's id (kvbox vm backup ls <box>)").option("-y, --yes", "do not ask for confirmation").action(async (box2, id, opts, cmd) => {
|
|
4409
|
+
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
4410
|
+
try {
|
|
4411
|
+
requireCloud3(client);
|
|
4412
|
+
await removeListed(client, await client.listBackups(), (b) => b.box, box2, id, `box ${box2}`, opts.yes ?? false);
|
|
4413
|
+
} finally {
|
|
4414
|
+
await client.close();
|
|
4415
|
+
}
|
|
4416
|
+
});
|
|
4417
|
+
|
|
4275
4418
|
// src/commands/vm/backup/index.ts
|
|
4276
|
-
var backupCommand = new
|
|
4419
|
+
var backupCommand = new Command26("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);
|
|
4277
4420
|
for (const cmd of backupCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
4278
4421
|
|
|
4279
4422
|
// src/commands/vm/rescale.ts
|
|
4280
|
-
import { Command as
|
|
4281
|
-
var rescaleCommand = new
|
|
4423
|
+
import { Command as Command27, Option as Option3 } from "commander";
|
|
4424
|
+
var rescaleCommand = new Command27("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) => {
|
|
4282
4425
|
const req = {
|
|
4283
4426
|
...opts.size !== void 0 ? { size: opts.size } : {},
|
|
4284
4427
|
...opts.vcpu !== void 0 ? { vcpu: parseCount(opts.vcpu) } : {},
|
|
@@ -4324,8 +4467,8 @@ function parseGib(flag, text2) {
|
|
|
4324
4467
|
}
|
|
4325
4468
|
|
|
4326
4469
|
// src/commands/vm/resume.ts
|
|
4327
|
-
import { Command as
|
|
4328
|
-
var resumeCommand = new
|
|
4470
|
+
import { Command as Command28 } from "commander";
|
|
4471
|
+
var resumeCommand = new Command28("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) => {
|
|
4329
4472
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
4330
4473
|
try {
|
|
4331
4474
|
const box2 = await spin(`resuming ${name}\u2026`, client.resumeMachine(name));
|
|
@@ -4337,8 +4480,8 @@ var resumeCommand = new Command27("resume").description("continue a box that is
|
|
|
4337
4480
|
});
|
|
4338
4481
|
|
|
4339
4482
|
// src/commands/vm/rm.ts
|
|
4340
|
-
import { Command as
|
|
4341
|
-
var
|
|
4483
|
+
import { Command as Command29 } from "commander";
|
|
4484
|
+
var rmCommand4 = new Command29("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) => {
|
|
4342
4485
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
4343
4486
|
try {
|
|
4344
4487
|
const box2 = pickRef(await boxesFor(client, name), name, me(client));
|
|
@@ -4358,7 +4501,7 @@ var rmCommand3 = new Command28("rm").description("destroy a box (its disk is del
|
|
|
4358
4501
|
});
|
|
4359
4502
|
|
|
4360
4503
|
// src/commands/vm/set.ts
|
|
4361
|
-
import { Command as
|
|
4504
|
+
import { Command as Command30 } from "commander";
|
|
4362
4505
|
|
|
4363
4506
|
// src/swap.ts
|
|
4364
4507
|
import { spawn as spawn3 } from "child_process";
|
|
@@ -4434,7 +4577,7 @@ function runSwap(ep, mib) {
|
|
|
4434
4577
|
}
|
|
4435
4578
|
|
|
4436
4579
|
// src/commands/vm/set.ts
|
|
4437
|
-
var setCommand = new
|
|
4580
|
+
var setCommand = new Command30("set").description("change a box's settings, e.g. --auto-hibernate 30m (off: never), --idle-check /home/kvbox/idle.sh, --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("--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) => {
|
|
4438
4581
|
if (opts.autoHibernate === void 0 && opts.idleCheck === void 0 && opts.swap === void 0) {
|
|
4439
4582
|
throw new KvboxError("nothing to change: give --auto-hibernate, --idle-check or --swap");
|
|
4440
4583
|
}
|
|
@@ -4503,8 +4646,8 @@ function parseIdleCheck(text2) {
|
|
|
4503
4646
|
}
|
|
4504
4647
|
|
|
4505
4648
|
// src/commands/vm/start.ts
|
|
4506
|
-
import { Command as
|
|
4507
|
-
var startCommand = new
|
|
4649
|
+
import { Command as Command31 } from "commander";
|
|
4650
|
+
var startCommand = new Command31("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) => {
|
|
4508
4651
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
4509
4652
|
try {
|
|
4510
4653
|
const box2 = await spin(`booting ${name}\u2026`, client.startMachine(name, opts.force ?? false));
|
|
@@ -4516,8 +4659,8 @@ var startCommand = new Command30("start").description("boot a stopped box again
|
|
|
4516
4659
|
});
|
|
4517
4660
|
|
|
4518
4661
|
// src/commands/vm/stop.ts
|
|
4519
|
-
import { Command as
|
|
4520
|
-
var stopCommand = new
|
|
4662
|
+
import { Command as Command32 } from "commander";
|
|
4663
|
+
var stopCommand = new Command32("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) => {
|
|
4521
4664
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
4522
4665
|
try {
|
|
4523
4666
|
const box2 = await spin(`shutting ${name} down\u2026`, client.stopMachine(name));
|
|
@@ -4529,8 +4672,8 @@ var stopCommand = new Command31("stop").description("shut a box down (its disk i
|
|
|
4529
4672
|
});
|
|
4530
4673
|
|
|
4531
4674
|
// src/commands/vm/top.ts
|
|
4532
|
-
import { Command as
|
|
4533
|
-
var topCommand = new
|
|
4675
|
+
import { Command as Command33 } from "commander";
|
|
4676
|
+
var topCommand = new Command33("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) => {
|
|
4534
4677
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
4535
4678
|
try {
|
|
4536
4679
|
const running = (await client.listMachines({ all: opts.all })).filter((b) => b.status === "running");
|
|
@@ -4590,8 +4733,8 @@ function topRows(entries, cloud) {
|
|
|
4590
4733
|
}
|
|
4591
4734
|
|
|
4592
4735
|
// src/commands/vm/unlink.ts
|
|
4593
|
-
import { Command as
|
|
4594
|
-
var unlinkCommand = new
|
|
4736
|
+
import { Command as Command34 } from "commander";
|
|
4737
|
+
var unlinkCommand = new Command34("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) => {
|
|
4595
4738
|
const port = parseLinkPort(opts.port);
|
|
4596
4739
|
if (!await confirm(`Cut box ${from} off from box ${name} port ${port}? Its open connections close too.`, opts.yes ?? false)) {
|
|
4597
4740
|
info("cancelled");
|
|
@@ -4612,8 +4755,8 @@ var unlinkCommand = new Command33("unlink").description("take a link away (kvbox
|
|
|
4612
4755
|
});
|
|
4613
4756
|
|
|
4614
4757
|
// src/commands/vm/update.ts
|
|
4615
|
-
import { Command as
|
|
4616
|
-
var updateCommand = new
|
|
4758
|
+
import { Command as Command35 } from "commander";
|
|
4759
|
+
var updateCommand = new Command35("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) => {
|
|
4617
4760
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
4618
4761
|
try {
|
|
4619
4762
|
const before = pickRef(await boxesFor(client, name), name, me(client));
|
|
@@ -4635,8 +4778,8 @@ var updateCommand = new Command34("update").description("move a box onto the cur
|
|
|
4635
4778
|
});
|
|
4636
4779
|
|
|
4637
4780
|
// src/commands/vm/usage.ts
|
|
4638
|
-
import { Command as
|
|
4639
|
-
var usageCommand = new
|
|
4781
|
+
import { Command as Command36 } from "commander";
|
|
4782
|
+
var usageCommand = new Command36("usage").description("how long a box ran, slept and sat stopped, as vCPU-hours, RAM and disk GiB-hours (and cost, when the host prices them)").argument("<name>", "box name").option("--since <date>", "count from this date instead of the box's creation, e.g. 2026-10-01").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
4640
4783
|
let since;
|
|
4641
4784
|
if (opts.since !== void 0) {
|
|
4642
4785
|
const t = Date.parse(opts.since);
|
|
@@ -4683,8 +4826,8 @@ function block(u) {
|
|
|
4683
4826
|
}
|
|
4684
4827
|
|
|
4685
4828
|
// src/commands/vm/wake.ts
|
|
4686
|
-
import { Command as
|
|
4687
|
-
var wakeCommand = new
|
|
4829
|
+
import { Command as Command37 } from "commander";
|
|
4830
|
+
var wakeCommand = new Command37("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) => {
|
|
4688
4831
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
4689
4832
|
try {
|
|
4690
4833
|
const box2 = await spin(`waking ${name} (loading its memory from disk)\u2026`, client.wakeMachine(name, opts.force ?? false));
|
|
@@ -4696,16 +4839,16 @@ var wakeCommand = new Command36("wake").description("continue a hibernated box w
|
|
|
4696
4839
|
});
|
|
4697
4840
|
|
|
4698
4841
|
// src/commands/vm/index.ts
|
|
4699
|
-
var vmCommand = new
|
|
4842
|
+
var vmCommand = new Command38("vm").enablePositionalOptions().description("manage boxes (each one is a Firecracker microVM)").addCommand(newCommand).addCommand(forkCommand).addCommand(lsCommand).addCommand(getCommand).addCommand(connectCommand).addCommand(execCommand).addCommand(stopCommand).addCommand(startCommand).addCommand(pauseCommand).addCommand(resumeCommand).addCommand(hibernateCommand).addCommand(wakeCommand).addCommand(updateCommand).addCommand(rescaleCommand).addCommand(setCommand).addCommand(usageCommand).addCommand(topCommand).addCommand(proxyCommand).addCommand(hookCommand).addCommand(backupCommand).addCommand(linkCommand).addCommand(unlinkCommand).addCommand(linksCommand).addCommand(rmCommand4);
|
|
4700
4843
|
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)");
|
|
4701
|
-
var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand,
|
|
4844
|
+
var vmAliases = [newCommand, lsCommand, getCommand, connectCommand, execCommand, stopCommand, startCommand, pauseCommand, resumeCommand, hibernateCommand, wakeCommand, rmCommand4, claimCommand];
|
|
4702
4845
|
|
|
4703
4846
|
// src/commands/login.ts
|
|
4704
4847
|
import { hostname as osHostname2 } from "os";
|
|
4705
4848
|
import { createInterface as createInterface2 } from "readline/promises";
|
|
4706
4849
|
import { setTimeout as sleep4 } from "timers/promises";
|
|
4707
4850
|
import { Writable } from "stream";
|
|
4708
|
-
import { Command as
|
|
4851
|
+
import { Command as Command39 } from "commander";
|
|
4709
4852
|
|
|
4710
4853
|
// src/browser.ts
|
|
4711
4854
|
import { spawn as spawn4 } from "child_process";
|
|
@@ -4742,7 +4885,7 @@ function openBrowser(url) {
|
|
|
4742
4885
|
}
|
|
4743
4886
|
|
|
4744
4887
|
// src/commands/login.ts
|
|
4745
|
-
var loginCommand = new
|
|
4888
|
+
var loginCommand = new Command39("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) => {
|
|
4746
4889
|
const url = normalizeUrl(urlArg ?? DEFAULT_CLOUD_URL);
|
|
4747
4890
|
const byPassword = opts.password === true || opts.passwordStdin === true || opts.email !== void 0;
|
|
4748
4891
|
const session = byPassword ? await runLogin(url, await readCredentials(opts), paths()) : await runDeviceLogin(url, paths());
|
|
@@ -4852,8 +4995,8 @@ async function firstLine(stream) {
|
|
|
4852
4995
|
}
|
|
4853
4996
|
|
|
4854
4997
|
// src/commands/logout.ts
|
|
4855
|
-
import { Command as
|
|
4856
|
-
var logoutCommand = new
|
|
4998
|
+
import { Command as Command40 } from "commander";
|
|
4999
|
+
var logoutCommand = new Command40("logout").description("log out of the control plane; commands target this machine's kvbox-server again").action(async () => {
|
|
4857
5000
|
const p = paths();
|
|
4858
5001
|
const session = await readSession(p).catch(() => null);
|
|
4859
5002
|
switch (await runLogout(p)) {
|
|
@@ -4891,8 +5034,8 @@ async function runLogout(p = paths()) {
|
|
|
4891
5034
|
}
|
|
4892
5035
|
|
|
4893
5036
|
// src/commands/whoami.ts
|
|
4894
|
-
import { Command as
|
|
4895
|
-
var whoamiCommand = new
|
|
5037
|
+
import { Command as Command41 } from "commander";
|
|
5038
|
+
var whoamiCommand = new Command41("whoami").description("show which account and control plane commands target (or local mode)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
4896
5039
|
if (!cmd.optsWithGlobals().local && envLogin()) {
|
|
4897
5040
|
const target = await resolveTarget({});
|
|
4898
5041
|
if (target.kind !== "cloud") return;
|
|
@@ -4917,10 +5060,10 @@ function describeSession(session) {
|
|
|
4917
5060
|
}
|
|
4918
5061
|
|
|
4919
5062
|
// src/commands/key/index.ts
|
|
4920
|
-
import { Command as
|
|
5063
|
+
import { Command as Command45 } from "commander";
|
|
4921
5064
|
|
|
4922
5065
|
// src/commands/key/create.ts
|
|
4923
|
-
import { Command as
|
|
5066
|
+
import { Command as Command42 } from "commander";
|
|
4924
5067
|
|
|
4925
5068
|
// src/commands/key/shared.ts
|
|
4926
5069
|
async function keyClient(cmd) {
|
|
@@ -4957,7 +5100,7 @@ function expiryText(expiresAt, now = Date.now()) {
|
|
|
4957
5100
|
}
|
|
4958
5101
|
|
|
4959
5102
|
// src/commands/key/create.ts
|
|
4960
|
-
var createCommand3 = new
|
|
5103
|
+
var createCommand3 = new Command42("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) => {
|
|
4961
5104
|
const expiresAt = opts.expires === void 0 ? void 0 : parseExpires(opts.expires);
|
|
4962
5105
|
const client = await keyClient(cmd);
|
|
4963
5106
|
try {
|
|
@@ -4975,8 +5118,8 @@ var createCommand3 = new Command41("create").description("make an API key for a
|
|
|
4975
5118
|
});
|
|
4976
5119
|
|
|
4977
5120
|
// src/commands/key/ls.ts
|
|
4978
|
-
import { Command as
|
|
4979
|
-
var lsCommand5 = new
|
|
5121
|
+
import { Command as Command43 } from "commander";
|
|
5122
|
+
var lsCommand5 = new Command43("ls").alias("list").description("list your API keys (never the keys themselves)").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
4980
5123
|
const client = await keyClient(cmd);
|
|
4981
5124
|
try {
|
|
4982
5125
|
const keys = await client.listApiKeys();
|
|
@@ -4995,8 +5138,8 @@ var lsCommand5 = new Command42("ls").alias("list").description("list your API ke
|
|
|
4995
5138
|
});
|
|
4996
5139
|
|
|
4997
5140
|
// src/commands/key/rm.ts
|
|
4998
|
-
import { Command as
|
|
4999
|
-
var
|
|
5141
|
+
import { Command as Command44 } from "commander";
|
|
5142
|
+
var rmCommand5 = new Command44("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) => {
|
|
5000
5143
|
const client = await keyClient(cmd);
|
|
5001
5144
|
try {
|
|
5002
5145
|
if (!await confirm(`Remove API key ${name}? Whatever uses it stops working.`, opts.yes ?? false)) {
|
|
@@ -5012,14 +5155,14 @@ var rmCommand4 = new Command43("rm").alias("remove").description("remove an API
|
|
|
5012
5155
|
});
|
|
5013
5156
|
|
|
5014
5157
|
// src/commands/key/index.ts
|
|
5015
|
-
var keyCommand = new
|
|
5158
|
+
var keyCommand = new Command45("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);
|
|
5016
5159
|
|
|
5017
5160
|
// src/commands/snapshots/index.ts
|
|
5018
|
-
import { Command as
|
|
5161
|
+
import { Command as Command49 } from "commander";
|
|
5019
5162
|
|
|
5020
5163
|
// src/commands/snapshots/ls.ts
|
|
5021
|
-
import { Command as
|
|
5022
|
-
var lsCommand6 = new
|
|
5164
|
+
import { Command as Command46 } from "commander";
|
|
5165
|
+
var lsCommand6 = new Command46("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) => {
|
|
5023
5166
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5024
5167
|
try {
|
|
5025
5168
|
const cloud = client.target.kind === "cloud";
|
|
@@ -5050,8 +5193,8 @@ var lsCommand6 = new Command45("ls").description("list snapshots (yours and your
|
|
|
5050
5193
|
});
|
|
5051
5194
|
|
|
5052
5195
|
// src/commands/snapshots/new.ts
|
|
5053
|
-
import { Command as
|
|
5054
|
-
var newCommand2 = new
|
|
5196
|
+
import { Command as Command47 } from "commander";
|
|
5197
|
+
var newCommand2 = new Command47("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) => {
|
|
5055
5198
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
5056
5199
|
try {
|
|
5057
5200
|
const req = { box: box2, name, ...opts.replace ? { replace: true } : {} };
|
|
@@ -5064,8 +5207,8 @@ var newCommand2 = new Command46("new").description("freeze a running box (memory
|
|
|
5064
5207
|
});
|
|
5065
5208
|
|
|
5066
5209
|
// src/commands/snapshots/rm.ts
|
|
5067
|
-
import { Command as
|
|
5068
|
-
var
|
|
5210
|
+
import { Command as Command48 } from "commander";
|
|
5211
|
+
var rmCommand6 = new Command48("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) => {
|
|
5069
5212
|
if (!await confirm(`Delete snapshot ${name}?`, opts.yes ?? false)) {
|
|
5070
5213
|
info("cancelled");
|
|
5071
5214
|
process.exitCode = 1;
|
|
@@ -5081,14 +5224,14 @@ var rmCommand5 = new Command47("rm").description("delete a snapshot (boxes made
|
|
|
5081
5224
|
});
|
|
5082
5225
|
|
|
5083
5226
|
// src/commands/snapshots/index.ts
|
|
5084
|
-
var snapshotsCommand = new
|
|
5227
|
+
var snapshotsCommand = new Command49("snapshots").aliases(["snapshot", "snap"]).description("freeze running boxes into snapshots and manage them").addCommand(newCommand2).addCommand(lsCommand6).addCommand(rmCommand6);
|
|
5085
5228
|
for (const cmd of snapshotsCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
5086
5229
|
|
|
5087
5230
|
// src/commands/org/index.ts
|
|
5088
|
-
import { Command as
|
|
5231
|
+
import { Command as Command55 } from "commander";
|
|
5089
5232
|
|
|
5090
5233
|
// src/commands/org/ls.ts
|
|
5091
|
-
import { Command as
|
|
5234
|
+
import { Command as Command50 } from "commander";
|
|
5092
5235
|
|
|
5093
5236
|
// src/commands/org/context.ts
|
|
5094
5237
|
var NOT_LOGGED_IN2 = "orgs live on the control plane: kvbox login first";
|
|
@@ -5108,7 +5251,7 @@ function orgFor(opts, target) {
|
|
|
5108
5251
|
}
|
|
5109
5252
|
|
|
5110
5253
|
// src/commands/org/ls.ts
|
|
5111
|
-
var lsCommand7 = new
|
|
5254
|
+
var lsCommand7 = new Command50("ls").description("list the orgs you belong to and your role in each").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
5112
5255
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5113
5256
|
try {
|
|
5114
5257
|
const orgs = await client.listOrgs();
|
|
@@ -5130,8 +5273,8 @@ function orgRows(orgs) {
|
|
|
5130
5273
|
}
|
|
5131
5274
|
|
|
5132
5275
|
// src/commands/org/members.ts
|
|
5133
|
-
import { Command as
|
|
5134
|
-
var lsCommand8 = new
|
|
5276
|
+
import { Command as Command51, Option as Option4 } from "commander";
|
|
5277
|
+
var lsCommand8 = new Command51("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) => {
|
|
5135
5278
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5136
5279
|
try {
|
|
5137
5280
|
const org = await client.getOrg(orgFor(opts, client.target));
|
|
@@ -5145,7 +5288,7 @@ var lsCommand8 = new Command50("ls").description("list an org's members and thei
|
|
|
5145
5288
|
await client.close();
|
|
5146
5289
|
}
|
|
5147
5290
|
});
|
|
5148
|
-
var addCommand2 = new
|
|
5291
|
+
var addCommand2 = new Command51("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) => {
|
|
5149
5292
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5150
5293
|
try {
|
|
5151
5294
|
const slug = orgFor(opts, client.target);
|
|
@@ -5155,7 +5298,7 @@ var addCommand2 = new Command50("add").description("add a user to an org (admins
|
|
|
5155
5298
|
await client.close();
|
|
5156
5299
|
}
|
|
5157
5300
|
});
|
|
5158
|
-
var
|
|
5301
|
+
var rmCommand7 = new Command51("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) => {
|
|
5159
5302
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5160
5303
|
try {
|
|
5161
5304
|
const slug = orgFor(opts, client.target);
|
|
@@ -5171,11 +5314,11 @@ var rmCommand6 = new Command50("rm").description("remove a member (or leave: rem
|
|
|
5171
5314
|
await client.close();
|
|
5172
5315
|
}
|
|
5173
5316
|
});
|
|
5174
|
-
var membersCommand = new
|
|
5317
|
+
var membersCommand = new Command51("members").description("who is in an org and what they may do").addCommand(lsCommand8).addCommand(addCommand2).addCommand(rmCommand7);
|
|
5175
5318
|
|
|
5176
5319
|
// src/commands/org/new.ts
|
|
5177
|
-
import { Command as
|
|
5178
|
-
var newCommand3 = new
|
|
5320
|
+
import { Command as Command52 } from "commander";
|
|
5321
|
+
var newCommand3 = new Command52("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) => {
|
|
5179
5322
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5180
5323
|
try {
|
|
5181
5324
|
const org = await client.createOrg({ slug, name: opts.name ?? slug });
|
|
@@ -5191,8 +5334,8 @@ var newCommand3 = new Command51("new").description("create an org; you become it
|
|
|
5191
5334
|
});
|
|
5192
5335
|
|
|
5193
5336
|
// src/commands/org/rm.ts
|
|
5194
|
-
import { Command as
|
|
5195
|
-
var
|
|
5337
|
+
import { Command as Command53 } from "commander";
|
|
5338
|
+
var rmCommand8 = new Command53("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) => {
|
|
5196
5339
|
if (!await confirm(`Delete org ${slug}? Its members lose access; its slug stays taken.`, opts.yes ?? false)) {
|
|
5197
5340
|
info("cancelled");
|
|
5198
5341
|
process.exitCode = 1;
|
|
@@ -5208,8 +5351,8 @@ var rmCommand7 = new Command52("rm").description("delete an org (owners only; re
|
|
|
5208
5351
|
});
|
|
5209
5352
|
|
|
5210
5353
|
// src/commands/org/role.ts
|
|
5211
|
-
import { Argument, Command as
|
|
5212
|
-
var roleCommand = new
|
|
5354
|
+
import { Argument, Command as Command54 } from "commander";
|
|
5355
|
+
var roleCommand = new Command54("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) => {
|
|
5213
5356
|
const client = await cloudClientFor(cmd.optsWithGlobals());
|
|
5214
5357
|
try {
|
|
5215
5358
|
const slug = orgFor(opts, client.target);
|
|
@@ -5221,11 +5364,11 @@ var roleCommand = new Command53("role").description("change a member's role (own
|
|
|
5221
5364
|
});
|
|
5222
5365
|
|
|
5223
5366
|
// src/commands/org/index.ts
|
|
5224
|
-
var orgCommand = new
|
|
5367
|
+
var orgCommand = new Command55("org").description("orgs: shared slugs that own boxes, with owners, admins and members").addCommand(lsCommand7).addCommand(newCommand3).addCommand(membersCommand).addCommand(roleCommand).addCommand(rmCommand8);
|
|
5225
5368
|
|
|
5226
5369
|
// src/commands/usage.ts
|
|
5227
|
-
import { Command as
|
|
5228
|
-
var usageCommand2 = new
|
|
5370
|
+
import { Command as Command56 } from "commander";
|
|
5371
|
+
var usageCommand2 = new Command56("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) => {
|
|
5229
5372
|
for (const [name, value] of [
|
|
5230
5373
|
["since", opts.since],
|
|
5231
5374
|
["until", opts.until]
|
|
@@ -5407,8 +5550,8 @@ function userRows(r) {
|
|
|
5407
5550
|
}
|
|
5408
5551
|
|
|
5409
5552
|
// src/commands/credit.ts
|
|
5410
|
-
import { Command as
|
|
5411
|
-
var creditCommand = new
|
|
5553
|
+
import { Command as Command57 } from "commander";
|
|
5554
|
+
var creditCommand = new Command57("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) => {
|
|
5412
5555
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5413
5556
|
try {
|
|
5414
5557
|
if (client.target.kind === "local") throw new KvboxError("credit lives on the control plane: kvbox login first");
|
|
@@ -5437,8 +5580,8 @@ function creditRow(b, me2) {
|
|
|
5437
5580
|
}
|
|
5438
5581
|
|
|
5439
5582
|
// src/commands/redeem.ts
|
|
5440
|
-
import { Command as
|
|
5441
|
-
var redeemCommand = new
|
|
5583
|
+
import { Command as Command58 } from "commander";
|
|
5584
|
+
var redeemCommand = new Command58("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) => {
|
|
5442
5585
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
5443
5586
|
try {
|
|
5444
5587
|
if (client.target.kind === "local") throw new KvboxError("codes are redeemed on the control plane: kvbox login first");
|
|
@@ -5458,7 +5601,7 @@ var redeemCommand = new Command57("redeem").description("redeem a promo code for
|
|
|
5458
5601
|
// src/commands/deploy/index.ts
|
|
5459
5602
|
import { access as access5, readFile as readFile7 } from "fs/promises";
|
|
5460
5603
|
import { basename as basename2, resolve as resolve3 } from "path";
|
|
5461
|
-
import { Command as
|
|
5604
|
+
import { Command as Command59, InvalidArgumentError as InvalidArgumentError2, Option as Option5 } from "commander";
|
|
5462
5605
|
|
|
5463
5606
|
// src/commands/deploy/config.ts
|
|
5464
5607
|
import { readFile as readFile5, writeFile as writeFile3 } from "fs/promises";
|
|
@@ -6723,7 +6866,7 @@ async function readPackageJson(dir) {
|
|
|
6723
6866
|
}
|
|
6724
6867
|
|
|
6725
6868
|
// src/commands/deploy/index.ts
|
|
6726
|
-
var deployCommand = new
|
|
6869
|
+
var deployCommand = new Command59("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) => {
|
|
6727
6870
|
const dir = resolve3(dirArg ?? ".");
|
|
6728
6871
|
const pkg = await readPackageJson2(dir);
|
|
6729
6872
|
const facts = { indexHtml: await exists2(resolve3(dir, "index.html")), dockerfile: await exists2(resolve3(dir, "Dockerfile")) };
|
|
@@ -6880,15 +7023,15 @@ async function settle2(dir, pkg, facts, saved, opts, orgFlag, cloud) {
|
|
|
6880
7023
|
}
|
|
6881
7024
|
|
|
6882
7025
|
// src/commands/volume/index.ts
|
|
6883
|
-
import { Command as
|
|
7026
|
+
import { Command as Command71 } from "commander";
|
|
6884
7027
|
|
|
6885
7028
|
// src/commands/volume/attach.ts
|
|
6886
|
-
import { Command as
|
|
7029
|
+
import { Command as Command60 } from "commander";
|
|
6887
7030
|
function describeMount(machine, volume2, box2) {
|
|
6888
7031
|
const path = machine.volumes?.find((v) => volume2 === v.name || volume2.endsWith(`/${v.name}`))?.mountPath ?? volumeMountPath(volume2.slice(volume2.lastIndexOf("/") + 1));
|
|
6889
7032
|
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`;
|
|
6890
7033
|
}
|
|
6891
|
-
var attachCommand = new
|
|
7034
|
+
var attachCommand = new Command60("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) => {
|
|
6892
7035
|
if (volumeArg === void 0 || boxArg === void 0) askOrUsage("give the volume and the box: kvbox volume attach <volume> <box>");
|
|
6893
7036
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
6894
7037
|
try {
|
|
@@ -6907,11 +7050,11 @@ var attachCommand = new Command59("attach").description("attach a volume to a bo
|
|
|
6907
7050
|
});
|
|
6908
7051
|
|
|
6909
7052
|
// src/commands/volume/backup/index.ts
|
|
6910
|
-
import { Command as
|
|
7053
|
+
import { Command as Command65 } from "commander";
|
|
6911
7054
|
|
|
6912
7055
|
// src/commands/volume/backup/create.ts
|
|
6913
|
-
import { Command as
|
|
6914
|
-
var createCommand4 = new
|
|
7056
|
+
import { Command as Command61 } from "commander";
|
|
7057
|
+
var createCommand4 = new Command61("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) => {
|
|
6915
7058
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6916
7059
|
try {
|
|
6917
7060
|
requireCloud3(client);
|
|
@@ -6936,8 +7079,8 @@ var createCommand4 = new Command60("create").description("back up a volume's dis
|
|
|
6936
7079
|
});
|
|
6937
7080
|
|
|
6938
7081
|
// src/commands/volume/backup/ls.ts
|
|
6939
|
-
import { Command as
|
|
6940
|
-
var lsCommand9 = new
|
|
7082
|
+
import { Command as Command62 } from "commander";
|
|
7083
|
+
var lsCommand9 = new Command62("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) => {
|
|
6941
7084
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6942
7085
|
try {
|
|
6943
7086
|
requireCloud3(client);
|
|
@@ -6970,8 +7113,8 @@ var lsCommand9 = new Command61("ls").alias("list").description("list volume back
|
|
|
6970
7113
|
});
|
|
6971
7114
|
|
|
6972
7115
|
// src/commands/volume/backup/restore.ts
|
|
6973
|
-
import { Command as
|
|
6974
|
-
var restoreCommand2 = new
|
|
7116
|
+
import { Command as Command63 } from "commander";
|
|
7117
|
+
var restoreCommand2 = new Command63("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) => {
|
|
6975
7118
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6976
7119
|
try {
|
|
6977
7120
|
requireCloud3(client);
|
|
@@ -6993,12 +7136,24 @@ var restoreCommand2 = new Command62("restore").description("put a backup back: t
|
|
|
6993
7136
|
}
|
|
6994
7137
|
});
|
|
6995
7138
|
|
|
7139
|
+
// src/commands/volume/backup/rm.ts
|
|
7140
|
+
import { Command as Command64 } from "commander";
|
|
7141
|
+
var rmCommand9 = new Command64("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) => {
|
|
7142
|
+
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
7143
|
+
try {
|
|
7144
|
+
requireCloud3(client);
|
|
7145
|
+
await removeListed(client, await client.listVolumeBackups(), (b) => b.volume, volume2, id, `volume ${volume2}`, opts.yes ?? false);
|
|
7146
|
+
} finally {
|
|
7147
|
+
await client.close();
|
|
7148
|
+
}
|
|
7149
|
+
});
|
|
7150
|
+
|
|
6996
7151
|
// src/commands/volume/backup/index.ts
|
|
6997
|
-
var backupCommand2 = new
|
|
7152
|
+
var backupCommand2 = new Command65("backup").description("back up a volume's disk to the kvbox cloud, list backups, restore or remove one").addCommand(createCommand4).addCommand(lsCommand9).addCommand(restoreCommand2).addCommand(rmCommand9);
|
|
6998
7153
|
for (const cmd of backupCommand2.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
|
|
6999
7154
|
|
|
7000
7155
|
// src/commands/volume/create.ts
|
|
7001
|
-
import { Command as
|
|
7156
|
+
import { Command as Command66 } from "commander";
|
|
7002
7157
|
function parseGib2(text2, label = "--size") {
|
|
7003
7158
|
const mib = parseMib(text2);
|
|
7004
7159
|
if (mib === void 0 || mib % 1024 !== 0) throw new KvboxError(`${label} ${text2}: write whole GB, like 50 or 50GB`);
|
|
@@ -7014,7 +7169,7 @@ function sizeProblem(answer) {
|
|
|
7014
7169
|
return err instanceof KvboxError ? err.message.replace(/^--size \S+: /, "") : String(err);
|
|
7015
7170
|
}
|
|
7016
7171
|
}
|
|
7017
|
-
var createCommand5 = new
|
|
7172
|
+
var createCommand5 = new Command66("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) => {
|
|
7018
7173
|
const ask = interactive();
|
|
7019
7174
|
if (nameArg === void 0 || opts.size === void 0) askOrUsage("give the name and the size: kvbox volume create <name> --size <gb> --box <box>");
|
|
7020
7175
|
const name = nameArg ?? await text("Volume name", { validate: (a) => VOLUME_NAME_RE.test(a) ? void 0 : VOLUME_NAME_RULE });
|
|
@@ -7047,8 +7202,8 @@ var createCommand5 = new Command64("create").alias("new").description("create a
|
|
|
7047
7202
|
});
|
|
7048
7203
|
|
|
7049
7204
|
// src/commands/volume/detach.ts
|
|
7050
|
-
import { Command as
|
|
7051
|
-
var detachCommand = new
|
|
7205
|
+
import { Command as Command67 } from "commander";
|
|
7206
|
+
var detachCommand = new Command67("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) => {
|
|
7052
7207
|
if (volumeArg === void 0) askOrUsage("give the volume: kvbox volume detach <volume> [box]");
|
|
7053
7208
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7054
7209
|
try {
|
|
@@ -7073,8 +7228,8 @@ var detachCommand = new Command65("detach").description("detach a volume from a
|
|
|
7073
7228
|
});
|
|
7074
7229
|
|
|
7075
7230
|
// src/commands/volume/grow.ts
|
|
7076
|
-
import { Command as
|
|
7077
|
-
var growCommand = new
|
|
7231
|
+
import { Command as Command68 } from "commander";
|
|
7232
|
+
var growCommand = new Command68("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) => {
|
|
7078
7233
|
const sizeGib = parseGib2(size, "size");
|
|
7079
7234
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7080
7235
|
try {
|
|
@@ -7087,8 +7242,8 @@ var growCommand = new Command66("grow").alias("resize").description("make a volu
|
|
|
7087
7242
|
});
|
|
7088
7243
|
|
|
7089
7244
|
// src/commands/volume/ls.ts
|
|
7090
|
-
import { Command as
|
|
7091
|
-
var lsCommand10 = new
|
|
7245
|
+
import { Command as Command69 } from "commander";
|
|
7246
|
+
var lsCommand10 = new Command69("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) => {
|
|
7092
7247
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
7093
7248
|
try {
|
|
7094
7249
|
const cloud = client.target.kind === "cloud";
|
|
@@ -7119,8 +7274,8 @@ var lsCommand10 = new Command67("ls").alias("list").description("list volumes: s
|
|
|
7119
7274
|
});
|
|
7120
7275
|
|
|
7121
7276
|
// src/commands/volume/rm.ts
|
|
7122
|
-
import { Command as
|
|
7123
|
-
var
|
|
7277
|
+
import { Command as Command70 } from "commander";
|
|
7278
|
+
var rmCommand10 = new Command70("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) => {
|
|
7124
7279
|
if (!await confirm(`Delete volume ${name} and everything on it?`, opts.yes ?? false)) {
|
|
7125
7280
|
info("cancelled");
|
|
7126
7281
|
process.exitCode = 1;
|
|
@@ -7136,15 +7291,15 @@ var rmCommand8 = new Command68("rm").alias("remove").description("delete a volum
|
|
|
7136
7291
|
});
|
|
7137
7292
|
|
|
7138
7293
|
// src/commands/volume/index.ts
|
|
7139
|
-
var volumeCommand = new
|
|
7294
|
+
var volumeCommand = new Command71("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(lsCommand10).addCommand(attachCommand).addCommand(detachCommand).addCommand(growCommand).addCommand(rmCommand10);
|
|
7140
7295
|
for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
|
|
7141
7296
|
volumeCommand.addCommand(backupCommand2);
|
|
7142
7297
|
|
|
7143
7298
|
// src/commands/bucket/index.ts
|
|
7144
|
-
import { Command as
|
|
7299
|
+
import { Command as Command81 } from "commander";
|
|
7145
7300
|
|
|
7146
7301
|
// src/commands/bucket/create.ts
|
|
7147
|
-
import { Command as
|
|
7302
|
+
import { Command as Command72 } from "commander";
|
|
7148
7303
|
|
|
7149
7304
|
// src/commands/bucket/shared.ts
|
|
7150
7305
|
async function bucketClient(cmd) {
|
|
@@ -7170,7 +7325,7 @@ function printRows(rows2) {
|
|
|
7170
7325
|
}
|
|
7171
7326
|
|
|
7172
7327
|
// src/commands/bucket/create.ts
|
|
7173
|
-
var createCommand6 = new
|
|
7328
|
+
var createCommand6 = new Command72("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) => {
|
|
7174
7329
|
const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
|
|
7175
7330
|
const client = await bucketClient(cmd);
|
|
7176
7331
|
try {
|
|
@@ -7190,8 +7345,8 @@ var createCommand6 = new Command70("create").description("make a bucket (the fir
|
|
|
7190
7345
|
});
|
|
7191
7346
|
|
|
7192
7347
|
// src/commands/bucket/grow.ts
|
|
7193
|
-
import { Command as
|
|
7194
|
-
var growCommand2 = new
|
|
7348
|
+
import { Command as Command73 } from "commander";
|
|
7349
|
+
var growCommand2 = new Command73("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) => {
|
|
7195
7350
|
const sizeGib = parseGib2(size, "size");
|
|
7196
7351
|
const client = await bucketClient(cmd);
|
|
7197
7352
|
try {
|
|
@@ -7204,8 +7359,8 @@ var growCommand2 = new Command71("grow").description("make your object storage l
|
|
|
7204
7359
|
});
|
|
7205
7360
|
|
|
7206
7361
|
// src/commands/bucket/info.ts
|
|
7207
|
-
import { Command as
|
|
7208
|
-
var infoCommand = new
|
|
7362
|
+
import { Command as Command74 } from "commander";
|
|
7363
|
+
var infoCommand = new Command74("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) => {
|
|
7209
7364
|
const client = await bucketClient(cmd);
|
|
7210
7365
|
try {
|
|
7211
7366
|
const b = await client.getBucket(name);
|
|
@@ -7234,11 +7389,11 @@ with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
|
|
|
7234
7389
|
});
|
|
7235
7390
|
|
|
7236
7391
|
// src/commands/bucket/key/index.ts
|
|
7237
|
-
import { Command as
|
|
7392
|
+
import { Command as Command78 } from "commander";
|
|
7238
7393
|
|
|
7239
7394
|
// src/commands/bucket/key/create.ts
|
|
7240
|
-
import { Command as
|
|
7241
|
-
var createCommand7 = new
|
|
7395
|
+
import { Command as Command75 } from "commander";
|
|
7396
|
+
var createCommand7 = new Command75("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) => {
|
|
7242
7397
|
const client = await bucketClient(cmd);
|
|
7243
7398
|
try {
|
|
7244
7399
|
const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
|
|
@@ -7261,8 +7416,8 @@ var createCommand7 = new Command73("create").description("make an access key for
|
|
|
7261
7416
|
});
|
|
7262
7417
|
|
|
7263
7418
|
// src/commands/bucket/key/ls.ts
|
|
7264
|
-
import { Command as
|
|
7265
|
-
var lsCommand11 = new
|
|
7419
|
+
import { Command as Command76 } from "commander";
|
|
7420
|
+
var lsCommand11 = new Command76("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) => {
|
|
7266
7421
|
const client = await bucketClient(cmd);
|
|
7267
7422
|
try {
|
|
7268
7423
|
const keys = await client.listBucketKeys(bucket);
|
|
@@ -7281,8 +7436,8 @@ var lsCommand11 = new Command74("ls").alias("list").description("list a bucket's
|
|
|
7281
7436
|
});
|
|
7282
7437
|
|
|
7283
7438
|
// src/commands/bucket/key/rm.ts
|
|
7284
|
-
import { Command as
|
|
7285
|
-
var
|
|
7439
|
+
import { Command as Command77 } from "commander";
|
|
7440
|
+
var rmCommand11 = new Command77("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) => {
|
|
7286
7441
|
const client = await bucketClient(cmd);
|
|
7287
7442
|
try {
|
|
7288
7443
|
if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
|
|
@@ -7298,11 +7453,11 @@ var rmCommand9 = new Command75("rm").alias("remove").description("delete an acce
|
|
|
7298
7453
|
});
|
|
7299
7454
|
|
|
7300
7455
|
// src/commands/bucket/key/index.ts
|
|
7301
|
-
var keyCommand2 = new
|
|
7456
|
+
var keyCommand2 = new Command78("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand7).addCommand(lsCommand11).addCommand(rmCommand11);
|
|
7302
7457
|
|
|
7303
7458
|
// src/commands/bucket/ls.ts
|
|
7304
|
-
import { Command as
|
|
7305
|
-
var lsCommand12 = new
|
|
7459
|
+
import { Command as Command79 } from "commander";
|
|
7460
|
+
var lsCommand12 = new Command79("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) => {
|
|
7306
7461
|
const client = await bucketClient(cmd);
|
|
7307
7462
|
try {
|
|
7308
7463
|
const buckets = await client.listBuckets({ all: opts.all });
|
|
@@ -7332,8 +7487,8 @@ var lsCommand12 = new Command77("ls").alias("list").description("list buckets, a
|
|
|
7332
7487
|
});
|
|
7333
7488
|
|
|
7334
7489
|
// src/commands/bucket/rm.ts
|
|
7335
|
-
import { Command as
|
|
7336
|
-
var
|
|
7490
|
+
import { Command as Command80 } from "commander";
|
|
7491
|
+
var rmCommand12 = new Command80("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) => {
|
|
7337
7492
|
const client = await bucketClient(cmd);
|
|
7338
7493
|
try {
|
|
7339
7494
|
const question = opts.force ? `Delete bucket ${name} with everything in it, and the object storage it is in?` : `Delete bucket ${name} and its keys?`;
|
|
@@ -7352,7 +7507,7 @@ var rmCommand10 = new Command78("rm").alias("remove").description("delete an emp
|
|
|
7352
7507
|
});
|
|
7353
7508
|
|
|
7354
7509
|
// src/commands/bucket/index.ts
|
|
7355
|
-
var bucketCommand = new
|
|
7510
|
+
var bucketCommand = new Command81("bucket").aliases(["buckets"]).description("object storage: S3 buckets for your files, and the access keys your apps use").addCommand(createCommand6).addCommand(lsCommand12).addCommand(infoCommand).addCommand(growCommand2).addCommand(rmCommand12).addCommand(keyCommand2);
|
|
7356
7511
|
var withOrg = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
|
|
7357
7512
|
for (const cmd of bucketCommand.commands) {
|
|
7358
7513
|
if (cmd === keyCommand2) cmd.commands.forEach(withOrg);
|
|
@@ -7360,10 +7515,10 @@ for (const cmd of bucketCommand.commands) {
|
|
|
7360
7515
|
}
|
|
7361
7516
|
|
|
7362
7517
|
// src/commands/cron/index.ts
|
|
7363
|
-
import { Command as
|
|
7518
|
+
import { Command as Command94 } from "commander";
|
|
7364
7519
|
|
|
7365
7520
|
// src/commands/cron/create.ts
|
|
7366
|
-
import { Command as
|
|
7521
|
+
import { Command as Command82 } from "commander";
|
|
7367
7522
|
|
|
7368
7523
|
// src/commands/cron/shared.ts
|
|
7369
7524
|
async function cronClient(cmd) {
|
|
@@ -7424,7 +7579,7 @@ function printRows2(rows2) {
|
|
|
7424
7579
|
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>")`);
|
|
7425
7580
|
|
|
7426
7581
|
// src/commands/cron/create.ts
|
|
7427
|
-
var createCommand8 = new
|
|
7582
|
+
var createCommand8 = new Command82("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) => {
|
|
7428
7583
|
const client = await cronClient(cmd);
|
|
7429
7584
|
try {
|
|
7430
7585
|
const service = await client.createCronService(name);
|
|
@@ -7441,8 +7596,8 @@ var createCommand8 = new Command80("create").description("make a cron service: a
|
|
|
7441
7596
|
});
|
|
7442
7597
|
|
|
7443
7598
|
// src/commands/cron/info.ts
|
|
7444
|
-
import { Command as
|
|
7445
|
-
var infoCommand2 = new
|
|
7599
|
+
import { Command as Command83 } from "commander";
|
|
7600
|
+
var infoCommand2 = new Command83("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) => {
|
|
7446
7601
|
const client = await cronClient(cmd);
|
|
7447
7602
|
try {
|
|
7448
7603
|
const service = await client.getCronService(name);
|
|
@@ -7466,8 +7621,8 @@ var infoCommand2 = new Command81("info").alias("get").description("show a cron s
|
|
|
7466
7621
|
});
|
|
7467
7622
|
|
|
7468
7623
|
// src/commands/cron/ls.ts
|
|
7469
|
-
import { Command as
|
|
7470
|
-
var lsCommand13 = new
|
|
7624
|
+
import { Command as Command84 } from "commander";
|
|
7625
|
+
var lsCommand13 = new Command84("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) => {
|
|
7471
7626
|
const client = await cronClient(cmd);
|
|
7472
7627
|
try {
|
|
7473
7628
|
const services = await client.listCronServices({ all: opts.all });
|
|
@@ -7487,8 +7642,8 @@ var lsCommand13 = new Command82("ls").alias("list").description("list cron servi
|
|
|
7487
7642
|
});
|
|
7488
7643
|
|
|
7489
7644
|
// src/commands/cron/rm.ts
|
|
7490
|
-
import { Command as
|
|
7491
|
-
var
|
|
7645
|
+
import { Command as Command85 } from "commander";
|
|
7646
|
+
var rmCommand13 = new Command85("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) => {
|
|
7492
7647
|
const client = await cronClient(cmd);
|
|
7493
7648
|
try {
|
|
7494
7649
|
if (!await confirm(`Delete cron service ${name}? Its triggers stop firing and their run history is deleted.`, opts.yes ?? false)) {
|
|
@@ -7504,10 +7659,10 @@ var rmCommand11 = new Command83("rm").alias("remove").description("delete a cron
|
|
|
7504
7659
|
});
|
|
7505
7660
|
|
|
7506
7661
|
// src/commands/cron/trigger/index.ts
|
|
7507
|
-
import { Command as
|
|
7662
|
+
import { Command as Command93 } from "commander";
|
|
7508
7663
|
|
|
7509
7664
|
// src/commands/cron/trigger/add.ts
|
|
7510
|
-
import { Command as
|
|
7665
|
+
import { Command as Command86 } from "commander";
|
|
7511
7666
|
function portOf(value) {
|
|
7512
7667
|
const n = Number(value);
|
|
7513
7668
|
if (!Number.isInteger(n) || n < 1 || n > 65535) throw new KvboxError(`--port ${value}: a port is a number from 1 to 65535`);
|
|
@@ -7527,7 +7682,7 @@ function timeoutOf(value) {
|
|
|
7527
7682
|
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`);
|
|
7528
7683
|
return sec;
|
|
7529
7684
|
}
|
|
7530
|
-
var addCommand3 = new
|
|
7685
|
+
var addCommand3 = new Command86("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) => {
|
|
7531
7686
|
let action;
|
|
7532
7687
|
if (opts.run !== void 0) {
|
|
7533
7688
|
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");
|
|
@@ -7554,8 +7709,8 @@ var addCommand3 = new Command84("add").description("add a trigger: on a schedule
|
|
|
7554
7709
|
});
|
|
7555
7710
|
|
|
7556
7711
|
// src/commands/cron/trigger/ls.ts
|
|
7557
|
-
import { Command as
|
|
7558
|
-
var lsCommand14 = new
|
|
7712
|
+
import { Command as Command87 } from "commander";
|
|
7713
|
+
var lsCommand14 = new Command87("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) => {
|
|
7559
7714
|
const client = await cronClient(cmd);
|
|
7560
7715
|
try {
|
|
7561
7716
|
const triggers = await client.listCronTriggers(service);
|
|
@@ -7571,8 +7726,8 @@ var lsCommand14 = new Command85("ls").alias("list").description("list a cron ser
|
|
|
7571
7726
|
});
|
|
7572
7727
|
|
|
7573
7728
|
// src/commands/cron/trigger/pause.ts
|
|
7574
|
-
import { Command as
|
|
7575
|
-
var pauseCommand2 = new
|
|
7729
|
+
import { Command as Command88 } from "commander";
|
|
7730
|
+
var pauseCommand2 = new Command88("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) => {
|
|
7576
7731
|
const client = await cronClient(cmd);
|
|
7577
7732
|
try {
|
|
7578
7733
|
const trigger = await client.setCronTriggerEnabled(service, id, false);
|
|
@@ -7587,8 +7742,8 @@ var pauseCommand2 = new Command86("pause").description("stop a trigger from firi
|
|
|
7587
7742
|
});
|
|
7588
7743
|
|
|
7589
7744
|
// src/commands/cron/trigger/resume.ts
|
|
7590
|
-
import { Command as
|
|
7591
|
-
var resumeCommand2 = new
|
|
7745
|
+
import { Command as Command89 } from "commander";
|
|
7746
|
+
var resumeCommand2 = new Command89("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) => {
|
|
7592
7747
|
const client = await cronClient(cmd);
|
|
7593
7748
|
try {
|
|
7594
7749
|
const trigger = await client.setCronTriggerEnabled(service, id, true);
|
|
@@ -7603,8 +7758,8 @@ var resumeCommand2 = new Command87("resume").description("let a paused trigger f
|
|
|
7603
7758
|
});
|
|
7604
7759
|
|
|
7605
7760
|
// src/commands/cron/trigger/rm.ts
|
|
7606
|
-
import { Command as
|
|
7607
|
-
var
|
|
7761
|
+
import { Command as Command90 } from "commander";
|
|
7762
|
+
var rmCommand14 = new Command90("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) => {
|
|
7608
7763
|
const client = await cronClient(cmd);
|
|
7609
7764
|
try {
|
|
7610
7765
|
if (!await confirm(`Delete trigger ${id} of cron service ${service}? Its run history is deleted too.`, opts.yes ?? false)) {
|
|
@@ -7620,8 +7775,8 @@ var rmCommand12 = new Command88("rm").alias("remove").description("delete a trig
|
|
|
7620
7775
|
});
|
|
7621
7776
|
|
|
7622
7777
|
// src/commands/cron/trigger/run.ts
|
|
7623
|
-
import { Command as
|
|
7624
|
-
var runCommand = new
|
|
7778
|
+
import { Command as Command91 } from "commander";
|
|
7779
|
+
var runCommand = new Command91("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) => {
|
|
7625
7780
|
const client = await cronClient(cmd);
|
|
7626
7781
|
try {
|
|
7627
7782
|
const trigger = await client.runCronTrigger(service, id);
|
|
@@ -7637,13 +7792,13 @@ var runCommand = new Command89("run").description("fire a trigger now, once, bes
|
|
|
7637
7792
|
});
|
|
7638
7793
|
|
|
7639
7794
|
// src/commands/cron/trigger/runs.ts
|
|
7640
|
-
import { Command as
|
|
7795
|
+
import { Command as Command92 } from "commander";
|
|
7641
7796
|
function limitOf(value) {
|
|
7642
7797
|
const n = Number(value);
|
|
7643
7798
|
if (!Number.isInteger(n) || n < 1) throw new KvboxError(`-n ${value}: a number of runs, 1 or more`);
|
|
7644
7799
|
return n;
|
|
7645
7800
|
}
|
|
7646
|
-
var runsCommand = new
|
|
7801
|
+
var runsCommand = new Command92("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) => {
|
|
7647
7802
|
const limit = limitOf(opts.limit);
|
|
7648
7803
|
const client = await cronClient(cmd);
|
|
7649
7804
|
try {
|
|
@@ -7673,10 +7828,10 @@ var runsCommand = new Command90("runs").aliases(["logs"]).description("show how
|
|
|
7673
7828
|
});
|
|
7674
7829
|
|
|
7675
7830
|
// src/commands/cron/trigger/index.ts
|
|
7676
|
-
var triggerCommand = new
|
|
7831
|
+
var triggerCommand = new Command93("trigger").aliases(["triggers"]).description("a cron service's triggers: a schedule and the request it sends to a box").addCommand(addCommand3).addCommand(lsCommand14).addCommand(runsCommand).addCommand(runCommand).addCommand(pauseCommand2).addCommand(resumeCommand2).addCommand(rmCommand14);
|
|
7677
7832
|
|
|
7678
7833
|
// src/commands/cron/index.ts
|
|
7679
|
-
var cronCommand = new
|
|
7834
|
+
var cronCommand = new Command94("cron").description("cron: call a box on a schedule, waking it first if it sleeps").addCommand(createCommand8).addCommand(lsCommand13).addCommand(infoCommand2).addCommand(rmCommand13).addCommand(triggerCommand);
|
|
7680
7835
|
var withOrg2 = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal cron services)");
|
|
7681
7836
|
for (const cmd of cronCommand.commands) {
|
|
7682
7837
|
if (cmd === triggerCommand) cmd.commands.forEach(withOrg2);
|
|
@@ -7684,11 +7839,13 @@ for (const cmd of cronCommand.commands) {
|
|
|
7684
7839
|
}
|
|
7685
7840
|
|
|
7686
7841
|
// src/commands/managed/kind.ts
|
|
7687
|
-
import { Command as
|
|
7842
|
+
import { Command as Command112 } from "commander";
|
|
7688
7843
|
|
|
7689
|
-
// src/commands/managed/
|
|
7690
|
-
import { Command as
|
|
7691
|
-
|
|
7844
|
+
// src/commands/managed/backup/index.ts
|
|
7845
|
+
import { Command as Command100 } from "commander";
|
|
7846
|
+
|
|
7847
|
+
// src/commands/managed/backup/create.ts
|
|
7848
|
+
import { Command as Command96 } from "commander";
|
|
7692
7849
|
|
|
7693
7850
|
// src/commands/managed/shared.ts
|
|
7694
7851
|
import "commander";
|
|
@@ -7770,11 +7927,112 @@ function parseStorage(text2, flag) {
|
|
|
7770
7927
|
return Number(m[1]);
|
|
7771
7928
|
}
|
|
7772
7929
|
|
|
7930
|
+
// src/commands/managed/backup/create.ts
|
|
7931
|
+
var createCommand9 = (spec) => new Command96("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) => {
|
|
7932
|
+
const client = await managedClient(cmd);
|
|
7933
|
+
const ls = `kvbox ${spec.command} backup ls ${name}`;
|
|
7934
|
+
try {
|
|
7935
|
+
const started = await client.createManagedBackup(spec.kind, name);
|
|
7936
|
+
if (!opts.wait) {
|
|
7937
|
+
if (opts.json) json(started);
|
|
7938
|
+
else {
|
|
7939
|
+
info(`${color.green("\u2713")} backup ${started.id} of database ${color.bold(name)} started; it runs in the background`);
|
|
7940
|
+
info(color.dim(` status: ${ls}`));
|
|
7941
|
+
}
|
|
7942
|
+
return;
|
|
7943
|
+
}
|
|
7944
|
+
const done = await spin(`backing up database ${name}\u2026`, untilSettled(() => client.managedBackup(spec.kind, name, started.id), `database ${name}`, started.id, ls));
|
|
7945
|
+
if (opts.json) json(done);
|
|
7946
|
+
if (done.status === "failed") throw new KvboxError(`backup ${done.id} of database ${name} failed: ${done.error ?? "no reason given"}`);
|
|
7947
|
+
if (opts.json) return;
|
|
7948
|
+
info(`${color.green("\u2713")} backup ${done.id} of database ${color.bold(name)}: ${sizeLine(done)}`);
|
|
7949
|
+
info(color.dim(` restore with: kvbox ${spec.command} backup restore ${name} ${done.id}`));
|
|
7950
|
+
} finally {
|
|
7951
|
+
await client.close();
|
|
7952
|
+
}
|
|
7953
|
+
});
|
|
7954
|
+
|
|
7955
|
+
// src/commands/managed/backup/ls.ts
|
|
7956
|
+
import { Command as Command97 } from "commander";
|
|
7957
|
+
var lsCommand15 = (spec) => new Command97("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) => {
|
|
7958
|
+
const client = await managedClient(cmd);
|
|
7959
|
+
try {
|
|
7960
|
+
const list = name === void 0 ? await client.listManagedBackups(spec.kind) : await client.managedBackups(spec.kind, name);
|
|
7961
|
+
if (opts.json) {
|
|
7962
|
+
json(list);
|
|
7963
|
+
return;
|
|
7964
|
+
}
|
|
7965
|
+
if (list.length === 0) {
|
|
7966
|
+
info(name === void 0 ? `no backups yet; make one with: kvbox ${spec.command} backup create <db>` : `database ${name} has no backups; make one with: kvbox ${spec.command} backup create ${name}`);
|
|
7967
|
+
return;
|
|
7968
|
+
}
|
|
7969
|
+
const anyError = list.some((b) => b.error !== null);
|
|
7970
|
+
table(
|
|
7971
|
+
list.map((b) => ({
|
|
7972
|
+
id: b.id,
|
|
7973
|
+
...name === void 0 ? { database: b.owner === me(client) ? b.name : `${b.owner}/${b.name}` } : {},
|
|
7974
|
+
status: b.status === "ready" ? color.green(b.status) : b.status === "failed" ? color.red(b.status) : color.yellow(b.status),
|
|
7975
|
+
version: b.version,
|
|
7976
|
+
data: b.dataBytes === null ? "-" : gbShort(b.dataBytes),
|
|
7977
|
+
uploaded: b.uploadedBytes === null ? "-" : gbShort(b.uploadedBytes),
|
|
7978
|
+
by: b.createdBy ?? "-",
|
|
7979
|
+
taken: age(b.createdAt),
|
|
7980
|
+
...anyError ? { error: b.error ?? "" } : {}
|
|
7981
|
+
}))
|
|
7982
|
+
);
|
|
7983
|
+
} finally {
|
|
7984
|
+
await client.close();
|
|
7985
|
+
}
|
|
7986
|
+
});
|
|
7987
|
+
|
|
7988
|
+
// src/commands/managed/backup/restore.ts
|
|
7989
|
+
import { Command as Command98 } from "commander";
|
|
7990
|
+
var restoreCommand3 = (spec) => new Command98("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) => {
|
|
7991
|
+
const client = await managedClient(cmd);
|
|
7992
|
+
try {
|
|
7993
|
+
const backup = await client.managedBackup(spec.kind, name, id);
|
|
7994
|
+
const question = `Restore database ${name} from backup ${backup.id} (${age(backup.createdAt)} ago, ${sizeLine(backup)})? Everything written to it since is lost, and it restarts.`;
|
|
7995
|
+
if (!await confirm(question, opts.yes ?? false)) {
|
|
7996
|
+
info("cancelled");
|
|
7997
|
+
process.exitCode = 1;
|
|
7998
|
+
return;
|
|
7999
|
+
}
|
|
8000
|
+
const restored = await spin(`restoring database ${name} from ${backup.id}\u2026`, client.restoreManagedBackup(spec.kind, name, id));
|
|
8001
|
+
if (opts.json) {
|
|
8002
|
+
json(restored);
|
|
8003
|
+
return;
|
|
8004
|
+
}
|
|
8005
|
+
info(`${color.green("\u2713")} database ${color.bold(name)} restored from backup ${backup.id}; its password is the one it had before the restore`);
|
|
8006
|
+
} finally {
|
|
8007
|
+
await client.close();
|
|
8008
|
+
}
|
|
8009
|
+
});
|
|
8010
|
+
|
|
8011
|
+
// src/commands/managed/backup/rm.ts
|
|
8012
|
+
import { Command as Command99 } from "commander";
|
|
8013
|
+
var rmCommand15 = (spec) => new Command99("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) => {
|
|
8014
|
+
const client = await managedClient(cmd);
|
|
8015
|
+
try {
|
|
8016
|
+
await removeListed(client, await client.listManagedBackups(spec.kind), (b) => b.name, name, id, `database ${name}`, opts.yes ?? false);
|
|
8017
|
+
} finally {
|
|
8018
|
+
await client.close();
|
|
8019
|
+
}
|
|
8020
|
+
});
|
|
8021
|
+
|
|
8022
|
+
// src/commands/managed/backup/index.ts
|
|
8023
|
+
var backupCommand3 = (spec) => {
|
|
8024
|
+
const command = new Command100("backup").description("back up a database to the kvbox cloud, list backups, restore or remove one");
|
|
8025
|
+
for (const make of [createCommand9, lsCommand15, restoreCommand3, rmCommand15]) command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
8026
|
+
return command;
|
|
8027
|
+
};
|
|
8028
|
+
|
|
7773
8029
|
// src/commands/managed/create.ts
|
|
8030
|
+
import { Command as Command101 } from "commander";
|
|
8031
|
+
import { setTimeout as sleep5 } from "timers/promises";
|
|
7774
8032
|
var READY_WAIT_MS = 9e4;
|
|
7775
8033
|
var READY_STEP_MS = 2e3;
|
|
7776
|
-
var
|
|
7777
|
-
const command = new
|
|
8034
|
+
var createCommand10 = (spec) => {
|
|
8035
|
+
const command = new Command101("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");
|
|
7778
8036
|
for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
|
|
7779
8037
|
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) => {
|
|
7780
8038
|
const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
|
|
@@ -7815,8 +8073,8 @@ var createCommand9 = (spec) => {
|
|
|
7815
8073
|
};
|
|
7816
8074
|
|
|
7817
8075
|
// src/commands/managed/grow.ts
|
|
7818
|
-
import { Command as
|
|
7819
|
-
var growCommand3 = (spec) => new
|
|
8076
|
+
import { Command as Command102 } from "commander";
|
|
8077
|
+
var growCommand3 = (spec) => new Command102("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) => {
|
|
7820
8078
|
const storageGib = parseStorage(size, "size");
|
|
7821
8079
|
const client = await managedClient(cmd);
|
|
7822
8080
|
try {
|
|
@@ -7829,8 +8087,8 @@ var growCommand3 = (spec) => new Command95("grow").description("give a database
|
|
|
7829
8087
|
});
|
|
7830
8088
|
|
|
7831
8089
|
// src/commands/managed/info.ts
|
|
7832
|
-
import { Command as
|
|
7833
|
-
var infoCommand3 = (spec) => new
|
|
8090
|
+
import { Command as Command103 } from "commander";
|
|
8091
|
+
var infoCommand3 = (spec) => new Command103("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) => {
|
|
7834
8092
|
const client = await managedClient(cmd);
|
|
7835
8093
|
try {
|
|
7836
8094
|
const m = await client.getManaged(spec.kind, name);
|
|
@@ -7842,8 +8100,8 @@ var infoCommand3 = (spec) => new Command96("info").alias("get").description("sho
|
|
|
7842
8100
|
});
|
|
7843
8101
|
|
|
7844
8102
|
// src/commands/managed/link.ts
|
|
7845
|
-
import { Command as
|
|
7846
|
-
var linkCommand2 = (spec) => new
|
|
8103
|
+
import { Command as Command104 } from "commander";
|
|
8104
|
+
var linkCommand2 = (spec) => new Command104("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, box2, opts, cmd) => {
|
|
7847
8105
|
const client = await managedClient(cmd);
|
|
7848
8106
|
try {
|
|
7849
8107
|
const m = await spin(`linking ${box2} to ${name}\u2026`, client.linkManaged(spec.kind, name, box2));
|
|
@@ -7859,7 +8117,7 @@ var linkCommand2 = (spec) => new Command97("link").description("let a box reach
|
|
|
7859
8117
|
});
|
|
7860
8118
|
|
|
7861
8119
|
// src/commands/managed/ls.ts
|
|
7862
|
-
import { Command as
|
|
8120
|
+
import { Command as Command105 } from "commander";
|
|
7863
8121
|
function listRows(items, user, kindColumn) {
|
|
7864
8122
|
return items.map((m) => ({
|
|
7865
8123
|
owner: m.owner === user ? "private" : m.owner,
|
|
@@ -7873,7 +8131,7 @@ function listRows(items, user, kindColumn) {
|
|
|
7873
8131
|
created: age(m.createdAt)
|
|
7874
8132
|
}));
|
|
7875
8133
|
}
|
|
7876
|
-
var
|
|
8134
|
+
var lsCommand16 = (spec) => new Command105("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) => {
|
|
7877
8135
|
const client = await managedClient(cmd);
|
|
7878
8136
|
try {
|
|
7879
8137
|
const items = await client.listManaged(spec?.kind, { all: opts.all });
|
|
@@ -7893,8 +8151,8 @@ var lsCommand15 = (spec) => new Command98("ls").alias("list").description(spec ?
|
|
|
7893
8151
|
});
|
|
7894
8152
|
|
|
7895
8153
|
// src/commands/managed/password.ts
|
|
7896
|
-
import { Command as
|
|
7897
|
-
var passwordCommand = (spec) => new
|
|
8154
|
+
import { Command as Command106 } from "commander";
|
|
8155
|
+
var passwordCommand = (spec) => new Command106("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) => {
|
|
7898
8156
|
const client = await managedClient(cmd);
|
|
7899
8157
|
try {
|
|
7900
8158
|
const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
|
|
@@ -7910,8 +8168,8 @@ var passwordCommand = (spec) => new Command99("password").description("show a da
|
|
|
7910
8168
|
});
|
|
7911
8169
|
|
|
7912
8170
|
// src/commands/managed/public.ts
|
|
7913
|
-
import { Command as
|
|
7914
|
-
var publicCommand = (spec) => new
|
|
8171
|
+
import { Command as Command107 } from "commander";
|
|
8172
|
+
var publicCommand = (spec) => new Command107("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) => {
|
|
7915
8173
|
if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
|
|
7916
8174
|
const client = await managedClient(cmd);
|
|
7917
8175
|
try {
|
|
@@ -7932,8 +8190,8 @@ var publicCommand = (spec) => new Command100("public").description("open a datab
|
|
|
7932
8190
|
});
|
|
7933
8191
|
|
|
7934
8192
|
// src/commands/managed/rm.ts
|
|
7935
|
-
import { Command as
|
|
7936
|
-
var
|
|
8193
|
+
import { Command as Command108 } from "commander";
|
|
8194
|
+
var rmCommand16 = (spec) => new Command108("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) => {
|
|
7937
8195
|
const client = await managedClient(cmd);
|
|
7938
8196
|
try {
|
|
7939
8197
|
if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
|
|
@@ -7949,8 +8207,8 @@ var rmCommand13 = (spec) => new Command101("rm").alias("remove").description("de
|
|
|
7949
8207
|
});
|
|
7950
8208
|
|
|
7951
8209
|
// src/commands/managed/start.ts
|
|
7952
|
-
import { Command as
|
|
7953
|
-
var startCommand2 = (spec) => new
|
|
8210
|
+
import { Command as Command109 } from "commander";
|
|
8211
|
+
var startCommand2 = (spec) => new Command109("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
7954
8212
|
const client = await managedClient(cmd);
|
|
7955
8213
|
try {
|
|
7956
8214
|
const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
|
|
@@ -7962,8 +8220,8 @@ var startCommand2 = (spec) => new Command102("start").description("run a stopped
|
|
|
7962
8220
|
});
|
|
7963
8221
|
|
|
7964
8222
|
// src/commands/managed/stop.ts
|
|
7965
|
-
import { Command as
|
|
7966
|
-
var stopCommand2 = (spec) => new
|
|
8223
|
+
import { Command as Command110 } from "commander";
|
|
8224
|
+
var stopCommand2 = (spec) => new Command110("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) => {
|
|
7967
8225
|
const client = await managedClient(cmd);
|
|
7968
8226
|
try {
|
|
7969
8227
|
const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
|
|
@@ -7975,8 +8233,8 @@ var stopCommand2 = (spec) => new Command103("stop").description("shut a database
|
|
|
7975
8233
|
});
|
|
7976
8234
|
|
|
7977
8235
|
// src/commands/managed/unlink.ts
|
|
7978
|
-
import { Command as
|
|
7979
|
-
var unlinkCommand2 = (spec) => new
|
|
8236
|
+
import { Command as Command111 } from "commander";
|
|
8237
|
+
var unlinkCommand2 = (spec) => new Command111("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) => {
|
|
7980
8238
|
const client = await managedClient(cmd);
|
|
7981
8239
|
try {
|
|
7982
8240
|
const m = await spin(`unlinking ${box2} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box2));
|
|
@@ -7989,10 +8247,11 @@ var unlinkCommand2 = (spec) => new Command104("unlink").description("stop a box
|
|
|
7989
8247
|
|
|
7990
8248
|
// src/commands/managed/kind.ts
|
|
7991
8249
|
function kindCommand(spec, description) {
|
|
7992
|
-
const command = new
|
|
7993
|
-
for (const make of [
|
|
8250
|
+
const command = new Command112(spec.command).aliases(spec.aliases).description(description);
|
|
8251
|
+
for (const make of [createCommand10, lsCommand16, infoCommand3, passwordCommand, publicCommand, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand16]) {
|
|
7994
8252
|
command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
7995
8253
|
}
|
|
8254
|
+
command.addCommand(backupCommand3(spec));
|
|
7996
8255
|
return command;
|
|
7997
8256
|
}
|
|
7998
8257
|
|
|
@@ -8003,14 +8262,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
|
|
|
8003
8262
|
var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
|
|
8004
8263
|
|
|
8005
8264
|
// src/commands/managed/index.ts
|
|
8006
|
-
import { Command as
|
|
8007
|
-
var managedCommand = new
|
|
8265
|
+
import { Command as Command113 } from "commander";
|
|
8266
|
+
var managedCommand = new Command113("managed").description(`databases kvbox runs for you, every kind together (${KINDS.map((k) => `${k.title}: kvbox ${k.command}`).join(", ")})`).addCommand(lsCommand16().option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
8008
8267
|
|
|
8009
8268
|
// src/commands/env/index.ts
|
|
8010
|
-
import { Command as
|
|
8269
|
+
import { Command as Command117 } from "commander";
|
|
8011
8270
|
|
|
8012
8271
|
// src/commands/env/ls.ts
|
|
8013
|
-
import { Command as
|
|
8272
|
+
import { Command as Command114 } from "commander";
|
|
8014
8273
|
|
|
8015
8274
|
// src/commands/env/shared.ts
|
|
8016
8275
|
function requireCloud4(client) {
|
|
@@ -8037,7 +8296,7 @@ function firstBootHint(box2, name) {
|
|
|
8037
8296
|
}
|
|
8038
8297
|
|
|
8039
8298
|
// src/commands/env/ls.ts
|
|
8040
|
-
var
|
|
8299
|
+
var lsCommand17 = new Command114("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) => {
|
|
8041
8300
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
8042
8301
|
try {
|
|
8043
8302
|
if (opts.box !== void 0) {
|
|
@@ -8076,8 +8335,8 @@ var lsCommand16 = new Command107("ls").alias("list").description("list the varia
|
|
|
8076
8335
|
});
|
|
8077
8336
|
|
|
8078
8337
|
// src/commands/env/rm.ts
|
|
8079
|
-
import { Command as
|
|
8080
|
-
var
|
|
8338
|
+
import { Command as Command115 } from "commander";
|
|
8339
|
+
var rmCommand17 = new Command115("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) => {
|
|
8081
8340
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
8082
8341
|
try {
|
|
8083
8342
|
const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
|
|
@@ -8114,8 +8373,8 @@ var rmCommand14 = new Command108("rm").alias("remove").description("remove varia
|
|
|
8114
8373
|
});
|
|
8115
8374
|
|
|
8116
8375
|
// src/commands/env/set.ts
|
|
8117
|
-
import { Command as
|
|
8118
|
-
var setCommand2 = new
|
|
8376
|
+
import { Command as Command116 } from "commander";
|
|
8377
|
+
var setCommand2 = new Command116("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) => {
|
|
8119
8378
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
8120
8379
|
try {
|
|
8121
8380
|
const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
|
|
@@ -8152,14 +8411,14 @@ var setCommand2 = new Command109("set").description("add or change a variable; b
|
|
|
8152
8411
|
});
|
|
8153
8412
|
|
|
8154
8413
|
// src/commands/env/index.ts
|
|
8155
|
-
var envCommand = new
|
|
8414
|
+
var envCommand = new Command117("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand17, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand17);
|
|
8156
8415
|
for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
|
|
8157
8416
|
|
|
8158
8417
|
// src/commands/domain/index.ts
|
|
8159
|
-
import { Command as
|
|
8418
|
+
import { Command as Command121 } from "commander";
|
|
8160
8419
|
|
|
8161
8420
|
// src/commands/domain/add.ts
|
|
8162
|
-
import { Command as
|
|
8421
|
+
import { Command as Command118 } from "commander";
|
|
8163
8422
|
|
|
8164
8423
|
// src/commands/domain/shared.ts
|
|
8165
8424
|
function requireCloud5(client) {
|
|
@@ -8179,7 +8438,7 @@ function hostIn(name, zone) {
|
|
|
8179
8438
|
}
|
|
8180
8439
|
|
|
8181
8440
|
// src/commands/domain/add.ts
|
|
8182
|
-
var addCommand4 = new
|
|
8441
|
+
var addCommand4 = new Command118("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) => {
|
|
8183
8442
|
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
8184
8443
|
const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
|
|
8185
8444
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
@@ -8215,8 +8474,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
|
|
|
8215
8474
|
});
|
|
8216
8475
|
|
|
8217
8476
|
// src/commands/domain/ls.ts
|
|
8218
|
-
import { Command as
|
|
8219
|
-
var
|
|
8477
|
+
import { Command as Command119 } from "commander";
|
|
8478
|
+
var lsCommand18 = new Command119("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
8220
8479
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
8221
8480
|
try {
|
|
8222
8481
|
requireCloud5(client);
|
|
@@ -8245,8 +8504,8 @@ var lsCommand17 = new Command112("ls").alias("list").description("list your cust
|
|
|
8245
8504
|
});
|
|
8246
8505
|
|
|
8247
8506
|
// src/commands/domain/rm.ts
|
|
8248
|
-
import { Command as
|
|
8249
|
-
var
|
|
8507
|
+
import { Command as Command120 } from "commander";
|
|
8508
|
+
var rmCommand18 = new Command120("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) => {
|
|
8250
8509
|
const domain = domainArg.trim().toLowerCase();
|
|
8251
8510
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
8252
8511
|
try {
|
|
@@ -8267,7 +8526,7 @@ var rmCommand15 = new Command113("rm").alias("remove").description("stop serving
|
|
|
8267
8526
|
});
|
|
8268
8527
|
|
|
8269
8528
|
// src/commands/domain/index.ts
|
|
8270
|
-
var domainCommand = new
|
|
8529
|
+
var domainCommand = new Command121("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand4).addCommand(lsCommand18).addCommand(rmCommand18);
|
|
8271
8530
|
for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
8272
8531
|
|
|
8273
8532
|
// src/commands/update.ts
|
|
@@ -8275,7 +8534,7 @@ import { spawn as spawn7 } from "child_process";
|
|
|
8275
8534
|
import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
8276
8535
|
import { tmpdir } from "os";
|
|
8277
8536
|
import { join as join9 } from "path";
|
|
8278
|
-
import { Command as
|
|
8537
|
+
import { Command as Command122 } from "commander";
|
|
8279
8538
|
|
|
8280
8539
|
// src/update.ts
|
|
8281
8540
|
import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
@@ -8394,7 +8653,7 @@ function run2(cmd, args) {
|
|
|
8394
8653
|
child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
|
|
8395
8654
|
});
|
|
8396
8655
|
}
|
|
8397
|
-
var selfUpdateCommand = new
|
|
8656
|
+
var selfUpdateCommand = new Command122("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
|
|
8398
8657
|
suppressUpdateNotice();
|
|
8399
8658
|
const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
|
|
8400
8659
|
let code;
|
|
@@ -8521,7 +8780,7 @@ function installRootHelp(program) {
|
|
|
8521
8780
|
|
|
8522
8781
|
// src/program.ts
|
|
8523
8782
|
function buildProgram() {
|
|
8524
|
-
const program = new
|
|
8783
|
+
const program = new Command123("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();
|
|
8525
8784
|
program.addCommand(vmCommand);
|
|
8526
8785
|
program.addCommand(snapshotsCommand);
|
|
8527
8786
|
program.addCommand(volumeCommand);
|