@kvbox/cli 0.5.49 → 0.5.50
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 +447 -109
- package/dist/kvbox.js.map +1 -1
- package/package.json +1 -1
package/dist/kvbox.js
CHANGED
|
@@ -149,7 +149,7 @@ async function spin(message, work, opts = {}) {
|
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
// src/program.ts
|
|
152
|
-
import { Command as
|
|
152
|
+
import { Command as Command95 } from "commander";
|
|
153
153
|
|
|
154
154
|
// ../shared/src/version.ts
|
|
155
155
|
import { createRequire } from "module";
|
|
@@ -164,7 +164,7 @@ function versionOf(srcFileUrl, injected) {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// src/version.ts
|
|
167
|
-
var VERSION = versionOf(import.meta.url, true ? "0.5.
|
|
167
|
+
var VERSION = versionOf(import.meta.url, true ? "0.5.50" : void 0);
|
|
168
168
|
|
|
169
169
|
// src/commands/vm/index.ts
|
|
170
170
|
import { Command as Command37 } from "commander";
|
|
@@ -426,7 +426,7 @@ import { openSync } from "fs";
|
|
|
426
426
|
import { mkdir as mkdir2, readFile as readFile3, stat } from "fs/promises";
|
|
427
427
|
import { setTimeout as sleep } from "timers/promises";
|
|
428
428
|
import { Agent, request } from "undici";
|
|
429
|
-
import { z as
|
|
429
|
+
import { z as z6 } from "zod";
|
|
430
430
|
|
|
431
431
|
// ../shared/src/api.ts
|
|
432
432
|
import { z as z2 } from "zod";
|
|
@@ -938,13 +938,21 @@ var UsageDaySchema = z2.object({
|
|
|
938
938
|
cost: z2.number(),
|
|
939
939
|
currency: z2.string(),
|
|
940
940
|
boxes: z2.array(UsageDayItemSchema),
|
|
941
|
-
volumes: z2.array(UsageDayItemSchema)
|
|
941
|
+
volumes: z2.array(UsageDayItemSchema),
|
|
942
|
+
/** Object storage that existed that day (#182); absent on a day without any. */
|
|
943
|
+
storage: z2.array(UsageDayItemSchema).optional()
|
|
942
944
|
});
|
|
943
945
|
var UsageReportSchema = z2.object({
|
|
944
946
|
window: z2.object({ from: z2.string(), to: z2.string() }),
|
|
945
947
|
boxes: z2.array(BoxUsageSchema),
|
|
946
948
|
/** Absent from a side older than #91. */
|
|
947
949
|
volumes: z2.array(VolumeUsageSchema).optional(),
|
|
950
|
+
/**
|
|
951
|
+
* Object storage (#182, control plane only): one row per storage a slug has or had, shaped like a
|
|
952
|
+
* volume's. `volumeHours` are the hours it existed, `volumeGibHours` those of the GiB beyond the
|
|
953
|
+
* included ones, `sizeGib` its whole size. Absent when there is none.
|
|
954
|
+
*/
|
|
955
|
+
storage: z2.array(VolumeUsageSchema).optional(),
|
|
948
956
|
/** With `?by=day` only, oldest day first. */
|
|
949
957
|
days: z2.array(UsageDaySchema).optional(),
|
|
950
958
|
totals: z2.object({
|
|
@@ -954,7 +962,7 @@ var UsageReportSchema = z2.object({
|
|
|
954
962
|
diskGibHours: z2.number(),
|
|
955
963
|
volumeHours: z2.number().optional(),
|
|
956
964
|
volumeGibHours: z2.number().optional(),
|
|
957
|
-
/** Boxes and
|
|
965
|
+
/** Boxes, volumes and object storage together. */
|
|
958
966
|
cost: z2.object({ amount: z2.number(), currency: z2.string() }).optional()
|
|
959
967
|
})
|
|
960
968
|
});
|
|
@@ -1230,7 +1238,15 @@ var PricingSchema = z3.object({
|
|
|
1230
1238
|
diskGibHour: z3.number().nonnegative(),
|
|
1231
1239
|
volumeHour: z3.number().nonnegative().default(0),
|
|
1232
1240
|
volumeGibHour: z3.number().nonnegative().default(0),
|
|
1233
|
-
diskIncludedGib: z3.number().int().nonnegative().default(0)
|
|
1241
|
+
diskIncludedGib: z3.number().int().nonnegative().default(0),
|
|
1242
|
+
/**
|
|
1243
|
+
* Object storage (#182): an hour of a slug's storage existing, whatever it holds, which covers its
|
|
1244
|
+
* hidden box and the first `storageIncludedGib` of its size; each GiB above that is `storageGibHour`.
|
|
1245
|
+
* A price list from before object storage charges nothing for it.
|
|
1246
|
+
*/
|
|
1247
|
+
storageHour: z3.number().nonnegative().default(0),
|
|
1248
|
+
storageGibHour: z3.number().nonnegative().default(0),
|
|
1249
|
+
storageIncludedGib: z3.number().int().nonnegative().default(0)
|
|
1234
1250
|
});
|
|
1235
1251
|
var PriceListSchema = PricingSchema.extend({ welcomeCredit: z3.number().nonnegative() });
|
|
1236
1252
|
var HOUR_MS = 36e5;
|
|
@@ -1346,6 +1362,59 @@ var SetPublicRequest = z4.object({ on: z4.boolean() });
|
|
|
1346
1362
|
var ManagedLinkRequest = z4.object({ box: z4.string() });
|
|
1347
1363
|
var GrowManagedRequest = z4.object({ storageGib: z4.number().int() });
|
|
1348
1364
|
|
|
1365
|
+
// ../shared/src/storage.ts
|
|
1366
|
+
import { z as z5 } from "zod";
|
|
1367
|
+
var ObjectStorageSchema = z5.object({
|
|
1368
|
+
owner: z5.string(),
|
|
1369
|
+
ownerKind: z5.enum(["user", "org"]),
|
|
1370
|
+
/** `https://s3-<slug>.<domain>`: what an S3 client is given, with path-style addressing. Null while the address is not claimed. */
|
|
1371
|
+
endpoint: z5.string().nullable(),
|
|
1372
|
+
region: z5.string(),
|
|
1373
|
+
/** The most it may hold. */
|
|
1374
|
+
sizeGib: z5.number().int(),
|
|
1375
|
+
/** `running` when it answers; `unknown` while its host is not heard from. */
|
|
1376
|
+
status: BoxStatusSchema,
|
|
1377
|
+
/** With `?live=1`, when the storage answered: what is on its disk, and the disk's real size. */
|
|
1378
|
+
usedBytes: z5.number().optional(),
|
|
1379
|
+
totalBytes: z5.number().optional(),
|
|
1380
|
+
host: z5.string(),
|
|
1381
|
+
country: z5.string().optional(),
|
|
1382
|
+
buckets: z5.number().int(),
|
|
1383
|
+
price: z5.object({ perMonth: z5.number(), currency: z5.string() }),
|
|
1384
|
+
createdAt: z5.string()
|
|
1385
|
+
});
|
|
1386
|
+
var BucketSchema = z5.object({
|
|
1387
|
+
name: z5.string(),
|
|
1388
|
+
owner: z5.string(),
|
|
1389
|
+
ownerKind: z5.enum(["user", "org"]),
|
|
1390
|
+
endpoint: z5.string().nullable(),
|
|
1391
|
+
region: z5.string(),
|
|
1392
|
+
keys: z5.number().int(),
|
|
1393
|
+
objects: z5.number().optional(),
|
|
1394
|
+
bytes: z5.number().optional(),
|
|
1395
|
+
createdBy: z5.string().nullable(),
|
|
1396
|
+
createdAt: z5.string()
|
|
1397
|
+
});
|
|
1398
|
+
var CreateBucketRequest = z5.object({
|
|
1399
|
+
name: z5.string(),
|
|
1400
|
+
sizeGib: z5.number().int().optional(),
|
|
1401
|
+
near: z5.string().optional()
|
|
1402
|
+
});
|
|
1403
|
+
var CreatedBucketSchema = BucketSchema.extend({ storage: ObjectStorageSchema, storageCreated: z5.boolean() });
|
|
1404
|
+
var BucketInfoSchema = BucketSchema.extend({ storage: ObjectStorageSchema });
|
|
1405
|
+
var BucketKeySchema = z5.object({
|
|
1406
|
+
id: z5.string(),
|
|
1407
|
+
name: z5.string(),
|
|
1408
|
+
bucket: z5.string(),
|
|
1409
|
+
owner: z5.string(),
|
|
1410
|
+
readOnly: z5.boolean(),
|
|
1411
|
+
createdBy: z5.string().nullable(),
|
|
1412
|
+
createdAt: z5.string()
|
|
1413
|
+
});
|
|
1414
|
+
var CreateBucketKeyRequest = z5.object({ name: z5.string().optional(), readOnly: z5.boolean().optional() });
|
|
1415
|
+
var CreatedBucketKeySchema = BucketKeySchema.extend({ secret: z5.string(), endpoint: z5.string().nullable(), region: z5.string() });
|
|
1416
|
+
var GrowStorageRequest = z5.object({ sizeGib: z5.number().int() });
|
|
1417
|
+
|
|
1349
1418
|
// src/kvm.ts
|
|
1350
1419
|
import { accessSync, constants, readFileSync, statSync } from "fs";
|
|
1351
1420
|
import { userInfo } from "os";
|
|
@@ -1500,7 +1569,7 @@ var ServerClient = class {
|
|
|
1500
1569
|
* `all`: every box on the platform (platform admins only, #78).
|
|
1501
1570
|
*/
|
|
1502
1571
|
listMachines(opts = {}) {
|
|
1503
|
-
return this.call("GET", `/machines${allQuery(opts)}`,
|
|
1572
|
+
return this.call("GET", `/machines${allQuery(opts)}`, z6.array(MachineSchema), void 0, opts.org);
|
|
1504
1573
|
}
|
|
1505
1574
|
createMachine(req) {
|
|
1506
1575
|
return this.call("POST", "/machines", MachineSchema, req);
|
|
@@ -1554,10 +1623,10 @@ var ServerClient = class {
|
|
|
1554
1623
|
}
|
|
1555
1624
|
/** Backups, the control plane's only: a box's disk in object storage. Newest first. */
|
|
1556
1625
|
listBackups() {
|
|
1557
|
-
return this.call("GET", "/backups",
|
|
1626
|
+
return this.call("GET", "/backups", z6.array(BackupSchema));
|
|
1558
1627
|
}
|
|
1559
1628
|
boxBackups(name) {
|
|
1560
|
-
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`,
|
|
1629
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups`, z6.array(BackupSchema));
|
|
1561
1630
|
}
|
|
1562
1631
|
boxBackup(name, id) {
|
|
1563
1632
|
return this.call("GET", `/machines/${encodeURIComponent(name)}/backups/${encodeURIComponent(id)}`, BackupSchema);
|
|
@@ -1572,7 +1641,7 @@ var ServerClient = class {
|
|
|
1572
1641
|
}
|
|
1573
1642
|
/** Wake hooks (#101), the control plane's only: a URL and a secret that wake the box. */
|
|
1574
1643
|
boxHooks(name) {
|
|
1575
|
-
return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`,
|
|
1644
|
+
return this.call("GET", `/machines/${encodeURIComponent(name)}/hooks`, z6.array(WakeHookSchema));
|
|
1576
1645
|
}
|
|
1577
1646
|
createBoxHook(name) {
|
|
1578
1647
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/hooks`, CreatedWakeHookSchema);
|
|
@@ -1600,7 +1669,7 @@ var ServerClient = class {
|
|
|
1600
1669
|
}
|
|
1601
1670
|
/** Every readable box's subdomains, one entry each. */
|
|
1602
1671
|
listSubdomains() {
|
|
1603
|
-
return this.call("GET", "/subdomains",
|
|
1672
|
+
return this.call("GET", "/subdomains", z6.array(SubdomainSchema));
|
|
1604
1673
|
}
|
|
1605
1674
|
/** Custom domains (#89), the control plane's only: serve the box at the user's own name. */
|
|
1606
1675
|
addDomain(name, req) {
|
|
@@ -1611,7 +1680,7 @@ var ServerClient = class {
|
|
|
1611
1680
|
}
|
|
1612
1681
|
/** Every readable box's custom domains. */
|
|
1613
1682
|
listDomains() {
|
|
1614
|
-
return this.call("GET", "/domains",
|
|
1683
|
+
return this.call("GET", "/domains", z6.array(DomainSchema));
|
|
1615
1684
|
}
|
|
1616
1685
|
/** A running box's own load, memory and disk, asked of its guest (#67). */
|
|
1617
1686
|
machineStats(name) {
|
|
@@ -1640,22 +1709,22 @@ var ServerClient = class {
|
|
|
1640
1709
|
return this.call("POST", "/billing/redeem", RedeemResponseSchema, { code });
|
|
1641
1710
|
}
|
|
1642
1711
|
deleteMachine(name) {
|
|
1643
|
-
return this.call("DELETE", `/machines/${encodeURIComponent(name)}`,
|
|
1712
|
+
return this.call("DELETE", `/machines/${encodeURIComponent(name)}`, z6.undefined());
|
|
1644
1713
|
}
|
|
1645
1714
|
/** Like `listMachines`, for snapshots. */
|
|
1646
1715
|
listSnapshots(opts = {}) {
|
|
1647
|
-
return this.call("GET", `/snapshots${allQuery(opts)}`,
|
|
1716
|
+
return this.call("GET", `/snapshots${allQuery(opts)}`, z6.array(SnapshotSchema), void 0, opts.org);
|
|
1648
1717
|
}
|
|
1649
1718
|
createSnapshot(req) {
|
|
1650
1719
|
return this.call("POST", "/snapshots", SnapshotSchema, req);
|
|
1651
1720
|
}
|
|
1652
1721
|
deleteSnapshot(name) {
|
|
1653
|
-
return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`,
|
|
1722
|
+
return this.call("DELETE", `/snapshots/${encodeURIComponent(name)}`, z6.undefined());
|
|
1654
1723
|
}
|
|
1655
1724
|
// ---- environment variables (#88), a control plane only: the caller's slug, or `--org`'s ----
|
|
1656
1725
|
/** `org`: that org's list instead of `--org`'s (or the caller's own). */
|
|
1657
1726
|
listEnv(org) {
|
|
1658
|
-
return this.call("GET", "/vars",
|
|
1727
|
+
return this.call("GET", "/vars", z6.array(EnvVarSchema), void 0, org);
|
|
1659
1728
|
}
|
|
1660
1729
|
setEnv(name, req) {
|
|
1661
1730
|
return this.call("PUT", `/vars/${encodeURIComponent(name)}`, EnvChangeSchema, req);
|
|
@@ -1675,13 +1744,13 @@ var ServerClient = class {
|
|
|
1675
1744
|
}
|
|
1676
1745
|
// ---- volumes (#52) ----
|
|
1677
1746
|
listVolumes(opts = {}) {
|
|
1678
|
-
return this.call("GET", `/volumes${allQuery(opts)}`,
|
|
1747
|
+
return this.call("GET", `/volumes${allQuery(opts)}`, z6.array(VolumeSchema), void 0, opts.org);
|
|
1679
1748
|
}
|
|
1680
1749
|
createVolume(req) {
|
|
1681
1750
|
return this.call("POST", "/volumes", VolumeSchema, req);
|
|
1682
1751
|
}
|
|
1683
1752
|
deleteVolume(name) {
|
|
1684
|
-
return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`,
|
|
1753
|
+
return this.call("DELETE", `/volumes/${encodeURIComponent(name)}`, z6.undefined());
|
|
1685
1754
|
}
|
|
1686
1755
|
/** Both answer with the box as it is afterwards (restarted when it was running). */
|
|
1687
1756
|
attachVolume(name, req) {
|
|
@@ -1694,16 +1763,45 @@ var ServerClient = class {
|
|
|
1694
1763
|
resizeVolume(name, sizeGib) {
|
|
1695
1764
|
return this.call("POST", `/volumes/${encodeURIComponent(name)}/resize`, VolumeSchema, { sizeGib });
|
|
1696
1765
|
}
|
|
1766
|
+
// ---- object storage (#182): the control plane's alone ----
|
|
1767
|
+
listBuckets(opts = {}) {
|
|
1768
|
+
return this.call("GET", `/buckets${allQuery(opts)}`, z6.array(BucketSchema), void 0, opts.org);
|
|
1769
|
+
}
|
|
1770
|
+
/** The first bucket of a slug also makes its storage: a box boots twice, so this may take a couple of minutes. */
|
|
1771
|
+
createBucket(req) {
|
|
1772
|
+
return this.call("POST", "/buckets", CreatedBucketSchema, req);
|
|
1773
|
+
}
|
|
1774
|
+
getBucket(name) {
|
|
1775
|
+
return this.call("GET", `/buckets/${encodeURIComponent(name)}`, BucketInfoSchema);
|
|
1776
|
+
}
|
|
1777
|
+
deleteBucket(name, force = false) {
|
|
1778
|
+
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}${force ? "?force=1" : ""}`, z6.undefined());
|
|
1779
|
+
}
|
|
1780
|
+
listBucketKeys(name) {
|
|
1781
|
+
return this.call("GET", `/buckets/${encodeURIComponent(name)}/keys`, z6.array(BucketKeySchema));
|
|
1782
|
+
}
|
|
1783
|
+
createBucketKey(name, req) {
|
|
1784
|
+
return this.call("POST", `/buckets/${encodeURIComponent(name)}/keys`, CreatedBucketKeySchema, req);
|
|
1785
|
+
}
|
|
1786
|
+
deleteBucketKey(name, id) {
|
|
1787
|
+
return this.call("DELETE", `/buckets/${encodeURIComponent(name)}/keys/${encodeURIComponent(id)}`, z6.undefined());
|
|
1788
|
+
}
|
|
1789
|
+
listStorage(opts = {}) {
|
|
1790
|
+
return this.call("GET", `/storage${allQuery(opts)}`, z6.array(ObjectStorageSchema), void 0, opts.org);
|
|
1791
|
+
}
|
|
1792
|
+
growStorage(sizeGib) {
|
|
1793
|
+
return this.call("POST", "/storage/grow", ObjectStorageSchema, { sizeGib });
|
|
1794
|
+
}
|
|
1697
1795
|
// ---- managed services (#173): the control plane's alone ----
|
|
1698
1796
|
managedPath(kind, name, rest = "") {
|
|
1699
1797
|
return `/managed/${encodeURIComponent(kind)}${name === void 0 ? "" : `/${encodeURIComponent(name)}`}${rest}`;
|
|
1700
1798
|
}
|
|
1701
1799
|
managedCatalog() {
|
|
1702
|
-
return this.call("GET", "/managed/catalog",
|
|
1800
|
+
return this.call("GET", "/managed/catalog", z6.array(ManagedCatalogEntrySchema));
|
|
1703
1801
|
}
|
|
1704
1802
|
/** One kind's services, or every kind's when `kind` is left out. */
|
|
1705
1803
|
listManaged(kind, opts = {}) {
|
|
1706
|
-
return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`,
|
|
1804
|
+
return this.call("GET", `${kind === void 0 ? "/managed" : this.managedPath(kind)}${allQuery(opts)}`, z6.array(ManagedSchema), void 0, opts.org);
|
|
1707
1805
|
}
|
|
1708
1806
|
createManaged(kind, req) {
|
|
1709
1807
|
return this.call("POST", this.managedPath(kind), CreatedManagedSchema, req);
|
|
@@ -1713,7 +1811,7 @@ var ServerClient = class {
|
|
|
1713
1811
|
return this.call("GET", this.managedPath(kind, name), ManagedSchema);
|
|
1714
1812
|
}
|
|
1715
1813
|
deleteManaged(kind, name) {
|
|
1716
|
-
return this.call("DELETE", this.managedPath(kind, name),
|
|
1814
|
+
return this.call("DELETE", this.managedPath(kind, name), z6.undefined());
|
|
1717
1815
|
}
|
|
1718
1816
|
managedPassword(kind, name) {
|
|
1719
1817
|
return this.call("GET", this.managedPath(kind, name, "/password"), ManagedSecretSchema);
|
|
@@ -1744,14 +1842,14 @@ var ServerClient = class {
|
|
|
1744
1842
|
return this.call("POST", "/login", LoginResponseSchema, req);
|
|
1745
1843
|
}
|
|
1746
1844
|
logout() {
|
|
1747
|
-
return this.call("POST", "/logout",
|
|
1845
|
+
return this.call("POST", "/logout", z6.unknown()).then(() => void 0);
|
|
1748
1846
|
}
|
|
1749
1847
|
me() {
|
|
1750
1848
|
return this.call("GET", "/me", MeResponseSchema);
|
|
1751
1849
|
}
|
|
1752
1850
|
// ---- orgs (`kvbox org …`) ----
|
|
1753
1851
|
listOrgs() {
|
|
1754
|
-
return this.call("GET", "/orgs",
|
|
1852
|
+
return this.call("GET", "/orgs", z6.array(OrgMembershipSchema));
|
|
1755
1853
|
}
|
|
1756
1854
|
createOrg(req) {
|
|
1757
1855
|
return this.call("POST", "/orgs", CloudOrgSchema, req);
|
|
@@ -1760,16 +1858,16 @@ var ServerClient = class {
|
|
|
1760
1858
|
return this.call("GET", `/orgs/${encodeURIComponent(slug)}`, OrgDetailSchema);
|
|
1761
1859
|
}
|
|
1762
1860
|
deleteOrg(slug) {
|
|
1763
|
-
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`,
|
|
1861
|
+
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}`, z6.undefined());
|
|
1764
1862
|
}
|
|
1765
1863
|
addMember(slug, req) {
|
|
1766
|
-
return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`,
|
|
1864
|
+
return this.call("POST", `/orgs/${encodeURIComponent(slug)}/members`, z6.undefined(), req);
|
|
1767
1865
|
}
|
|
1768
1866
|
setRole(slug, username, role) {
|
|
1769
|
-
return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`,
|
|
1867
|
+
return this.call("PATCH", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z6.unknown(), { role }).then(() => void 0);
|
|
1770
1868
|
}
|
|
1771
1869
|
removeMember(slug, username) {
|
|
1772
|
-
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`,
|
|
1870
|
+
return this.call("DELETE", `/orgs/${encodeURIComponent(slug)}/members/${encodeURIComponent(username)}`, z6.undefined());
|
|
1773
1871
|
}
|
|
1774
1872
|
/** Sign this machine's key again (#51); the key must be one the user logged in with. */
|
|
1775
1873
|
sshCert(req) {
|
|
@@ -3967,13 +4065,21 @@ var usageCommand2 = new Command51("usage").description("what your boxes and volu
|
|
|
3967
4065
|
const cloud = client.target.kind === "cloud" ? { me: client.target.user } : void 0;
|
|
3968
4066
|
info(`${day2(report.window.from)} to ${day2(report.window.to)}`);
|
|
3969
4067
|
const volumes = report.volumes ?? [];
|
|
3970
|
-
|
|
4068
|
+
const storage = report.storage ?? [];
|
|
4069
|
+
if (report.boxes.length === 0 && volumes.length === 0 && storage.length === 0) info("no usage in this window");
|
|
3971
4070
|
else if (report.boxes.length > 0) table(perUser ? userRows(perUser) : usageRows(report, cloud));
|
|
3972
4071
|
if (volumes.length > 0) {
|
|
3973
4072
|
info(volumes.length === 1 ? "1 volume" : `${volumes.length} volumes`);
|
|
3974
4073
|
table(volumeRows(report, cloud));
|
|
3975
4074
|
}
|
|
3976
|
-
if (
|
|
4075
|
+
if (storage.length > 0) {
|
|
4076
|
+
info("object storage");
|
|
4077
|
+
table(storageRows(report, cloud));
|
|
4078
|
+
}
|
|
4079
|
+
if ((volumes.length > 0 || storage.length > 0) && report.totals.cost !== void 0) {
|
|
4080
|
+
const what = ["boxes", ...volumes.length > 0 ? ["volumes"] : [], ...storage.length > 0 ? ["object storage"] : []];
|
|
4081
|
+
info(`total: ${money(report.totals.cost.amount, report.totals.cost.currency)} ${color.dim(`(${what.slice(0, -1).join(", ")} and ${what.at(-1)}, estimated)`)}`);
|
|
4082
|
+
}
|
|
3977
4083
|
if (cloud) {
|
|
3978
4084
|
const line = await creditLine(client, cloud.me);
|
|
3979
4085
|
if (line !== void 0) info(line);
|
|
@@ -4052,6 +4158,17 @@ function volumeRows(report, cloud) {
|
|
|
4052
4158
|
});
|
|
4053
4159
|
return rows2;
|
|
4054
4160
|
}
|
|
4161
|
+
function storageRows(report, cloud) {
|
|
4162
|
+
const priced = report.totals.cost !== void 0;
|
|
4163
|
+
const currency = report.totals.cost?.currency ?? "";
|
|
4164
|
+
return (report.storage ?? []).map((s) => ({
|
|
4165
|
+
...cloud ? { owner: ownerCell2(s, cloud.me) } : {},
|
|
4166
|
+
status: s.status === "removed" ? color.dim("removed") : "present",
|
|
4167
|
+
size: `${s.sizeGib}GB`,
|
|
4168
|
+
hours: hours(s.volumeHours),
|
|
4169
|
+
...priced ? { cost: money(s.cost?.amount ?? 0, currency) } : {}
|
|
4170
|
+
}));
|
|
4171
|
+
}
|
|
4055
4172
|
function byUser(report) {
|
|
4056
4173
|
const groups = /* @__PURE__ */ new Map();
|
|
4057
4174
|
for (const b of report.boxes) {
|
|
@@ -4068,7 +4185,7 @@ function byUser(report) {
|
|
|
4068
4185
|
return u;
|
|
4069
4186
|
});
|
|
4070
4187
|
users.sort((a, b) => a.user === null ? 1 : b.user === null ? -1 : a.user.localeCompare(b.user));
|
|
4071
|
-
return { window: report.window, users, ...report.volumes === void 0 ? {} : { volumes: report.volumes }, totals: report.totals };
|
|
4188
|
+
return { window: report.window, users, ...report.volumes === void 0 ? {} : { volumes: report.volumes }, ...report.storage === void 0 ? {} : { storage: report.storage }, totals: report.totals };
|
|
4072
4189
|
}
|
|
4073
4190
|
function userRows(r) {
|
|
4074
4191
|
const priced = r.totals.cost !== void 0;
|
|
@@ -4150,7 +4267,7 @@ import { Command as Command54, InvalidArgumentError as InvalidArgumentError2, Op
|
|
|
4150
4267
|
// src/commands/deploy/config.ts
|
|
4151
4268
|
import { readFile as readFile6, writeFile as writeFile4 } from "fs/promises";
|
|
4152
4269
|
import { isAbsolute, join as join6, normalize, relative as relative2 } from "path";
|
|
4153
|
-
import { z as
|
|
4270
|
+
import { z as z7 } from "zod";
|
|
4154
4271
|
|
|
4155
4272
|
// src/commands/deploy/templates/docker.ts
|
|
4156
4273
|
import { readFile as readFile5 } from "fs/promises";
|
|
@@ -4574,21 +4691,21 @@ function detectTemplates(pkg, dir = NO_FACTS) {
|
|
|
4574
4691
|
var DEPLOY_AUTO_HIBERNATE_SEC = 3600;
|
|
4575
4692
|
var CONFIG_FILE = "kvbox.json";
|
|
4576
4693
|
var BOX_NAME_RE = /^[a-z0-9][a-z0-9-]{0,11}$/;
|
|
4577
|
-
var DeployConfigSchema =
|
|
4578
|
-
template:
|
|
4579
|
-
name:
|
|
4694
|
+
var DeployConfigSchema = z7.object({
|
|
4695
|
+
template: z7.enum(TEMPLATE_IDS),
|
|
4696
|
+
name: z7.string().regex(BOX_NAME_RE, "1-12 chars, lowercase letters, digits and '-', starting with a letter or digit"),
|
|
4580
4697
|
/** The org whose box it is; absent for the user's own. */
|
|
4581
|
-
org:
|
|
4698
|
+
org: z7.string().regex(ORG_SLUG_RE, "not an org slug").optional(),
|
|
4582
4699
|
/** The HTTPS name (`<subdomain>.kvbox.app`); absent when deploying to this machine's own host. */
|
|
4583
|
-
subdomain:
|
|
4700
|
+
subdomain: z7.string().check((ctx) => {
|
|
4584
4701
|
const problem = subdomainProblem(ctx.value);
|
|
4585
4702
|
if (problem) ctx.issues.push({ code: "custom", message: problem, input: ctx.value });
|
|
4586
4703
|
}).optional(),
|
|
4587
|
-
size:
|
|
4704
|
+
size: z7.enum(SIZE_NAMES).optional(),
|
|
4588
4705
|
/** The build output directory, relative to the app; the template's default when absent. */
|
|
4589
|
-
dist:
|
|
4706
|
+
dist: z7.string().optional(),
|
|
4590
4707
|
/** The port a Next.js app or Node server serves; the template's (3000) when absent. */
|
|
4591
|
-
port:
|
|
4708
|
+
port: z7.number().int().min(1).max(65535).optional()
|
|
4592
4709
|
});
|
|
4593
4710
|
var SERVICE_KEY_RE = /^[a-z][a-z0-9-]{0,19}$/;
|
|
4594
4711
|
var RESERVED_SERVICE_KEYS = ["app", "agent", "init", "volumes"];
|
|
@@ -4600,38 +4717,38 @@ var POSTGRES_PORT = 5432;
|
|
|
4600
4717
|
var POSTGRES_IMAGE = "postgres:17";
|
|
4601
4718
|
var POSTGRES_ENV = "DATABASE_URL";
|
|
4602
4719
|
var IMAGE_RE = /^[a-z0-9][a-z0-9._/:@-]*$/;
|
|
4603
|
-
var ServiceSchema =
|
|
4604
|
-
template:
|
|
4720
|
+
var ServiceSchema = z7.strictObject({
|
|
4721
|
+
template: z7.enum([...TEMPLATE_IDS, POSTGRES]),
|
|
4605
4722
|
/** The service's directory, relative to the one holding kvbox.json; every template but postgres has one. */
|
|
4606
|
-
dir:
|
|
4723
|
+
dir: z7.string().min(1).optional(),
|
|
4607
4724
|
/** A postgres service's image, `postgres:17` when absent (`pgvector/pgvector:pg17` for vectors). */
|
|
4608
|
-
image:
|
|
4725
|
+
image: z7.string().regex(IMAGE_RE, "an image name like postgres:17").optional(),
|
|
4609
4726
|
/** The volume (a key of `volumes`) a postgres service keeps its data on. */
|
|
4610
|
-
volume:
|
|
4727
|
+
volume: z7.string().optional(),
|
|
4611
4728
|
/** The box variable a postgres service's URL is written to, `DATABASE_URL` when absent. */
|
|
4612
|
-
env:
|
|
4729
|
+
env: z7.string().optional(),
|
|
4613
4730
|
/** A docker service's build context, relative to kvbox.json, when it is not `dir` (a monorepo built from its root); the Dockerfile stays in `dir`. */
|
|
4614
|
-
context:
|
|
4615
|
-
dist:
|
|
4731
|
+
context: z7.string().min(1).optional(),
|
|
4732
|
+
dist: z7.string().optional(),
|
|
4616
4733
|
/**
|
|
4617
4734
|
* A command run once per deploy in the service's new version (a docker service: in a container of
|
|
4618
4735
|
* the new image; node, nextjs: in the new source, installed and built), with the box's variables,
|
|
4619
4736
|
* before it replaces the running one. Migrations, mostly. A failing one stops that service's deploy.
|
|
4620
4737
|
*/
|
|
4621
|
-
release:
|
|
4738
|
+
release: z7.string().optional(),
|
|
4622
4739
|
/** The box port of a service with its own server; the template's (3000) when absent. */
|
|
4623
|
-
port:
|
|
4740
|
+
port: z7.number().int().min(1).max(65535).optional(),
|
|
4624
4741
|
/** The URL paths that go to this service, each with everything under it; the prefix is kept. */
|
|
4625
|
-
paths:
|
|
4742
|
+
paths: z7.array(z7.string().regex(ROUTE_RE, "a path like / or /api, no trailing slash")).min(1).optional()
|
|
4626
4743
|
});
|
|
4627
|
-
var StackConfigSchema =
|
|
4744
|
+
var StackConfigSchema = z7.strictObject({
|
|
4628
4745
|
name: DeployConfigSchema.shape.name.optional(),
|
|
4629
4746
|
org: DeployConfigSchema.shape.org,
|
|
4630
4747
|
subdomain: DeployConfigSchema.shape.subdomain,
|
|
4631
4748
|
size: DeployConfigSchema.shape.size,
|
|
4632
4749
|
/** The stack's volumes, name to size ("10GB"): made for its box and attached to it on the first deploy that needs one. */
|
|
4633
|
-
volumes:
|
|
4634
|
-
services:
|
|
4750
|
+
volumes: z7.record(z7.string(), z7.string()).optional(),
|
|
4751
|
+
services: z7.record(z7.string(), ServiceSchema)
|
|
4635
4752
|
});
|
|
4636
4753
|
function volumeGib(text2) {
|
|
4637
4754
|
const mib = parseMib(text2);
|
|
@@ -5735,11 +5852,230 @@ var rmCommand7 = new Command60("rm").alias("remove").description("delete a volum
|
|
|
5735
5852
|
var volumeCommand = new Command61("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(createCommand3).addCommand(lsCommand8).addCommand(attachCommand).addCommand(detachCommand).addCommand(growCommand).addCommand(rmCommand7);
|
|
5736
5853
|
for (const cmd of volumeCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal volumes)");
|
|
5737
5854
|
|
|
5855
|
+
// src/commands/bucket/index.ts
|
|
5856
|
+
import { Command as Command71 } from "commander";
|
|
5857
|
+
|
|
5858
|
+
// src/commands/bucket/create.ts
|
|
5859
|
+
import { Command as Command62 } from "commander";
|
|
5860
|
+
|
|
5861
|
+
// src/commands/bucket/shared.ts
|
|
5862
|
+
async function bucketClient(cmd) {
|
|
5863
|
+
const client = await clientFor(cmd.optsWithGlobals());
|
|
5864
|
+
if (client.target.kind !== "cloud") {
|
|
5865
|
+
await client.close();
|
|
5866
|
+
throw new KvboxError("object storage runs on the kvbox cloud: kvbox login first (this host's own socket has none)");
|
|
5867
|
+
}
|
|
5868
|
+
return client;
|
|
5869
|
+
}
|
|
5870
|
+
function shownName(b, client) {
|
|
5871
|
+
const context = client.target.kind === "cloud" ? client.target.org ?? client.target.user : void 0;
|
|
5872
|
+
return b.owner === context ? b.name : `${b.owner}/${b.name}`;
|
|
5873
|
+
}
|
|
5874
|
+
var fullness = (s) => s.usedBytes !== void 0 ? `${gb(s.usedBytes)} of ${s.sizeGib} GB used` : `${s.sizeGib} GB`;
|
|
5875
|
+
var nearlyFull = (s) => s.usedBytes !== void 0 && s.totalBytes !== void 0 && s.totalBytes > 0 && s.usedBytes / s.totalBytes >= 0.9;
|
|
5876
|
+
var priceText = (s) => `${money(s.price.perMonth, s.price.currency)} a month ${color.dim("(estimated)")}`;
|
|
5877
|
+
var endpointText = (endpoint) => endpoint ?? color.yellow("no address yet (asked for again at the next bucket create or info)");
|
|
5878
|
+
function printRows(rows2) {
|
|
5879
|
+
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
5880
|
+
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
5881
|
+
`);
|
|
5882
|
+
}
|
|
5883
|
+
|
|
5884
|
+
// src/commands/bucket/create.ts
|
|
5885
|
+
var createCommand4 = new Command62("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("--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) => {
|
|
5886
|
+
const sizeGib = opts.size === void 0 ? void 0 : parseGib2(opts.size);
|
|
5887
|
+
const client = await bucketClient(cmd);
|
|
5888
|
+
try {
|
|
5889
|
+
const made = await spin(`making bucket ${name}\u2026`, client.createBucket({ name, ...sizeGib !== void 0 ? { sizeGib } : {}, ...opts.near !== void 0 ? { near: opts.near } : {} }));
|
|
5890
|
+
if (opts.json) {
|
|
5891
|
+
json(made);
|
|
5892
|
+
return;
|
|
5893
|
+
}
|
|
5894
|
+
const shown = shownName(made, client);
|
|
5895
|
+
info(`${color.green("\u2713")} bucket ${color.bold(shown)} made`);
|
|
5896
|
+
if (made.storageCreated) info(` object storage made for ${made.owner}: ${made.storage.sizeGib} GB for all its buckets, ${priceText(made.storage)}`);
|
|
5897
|
+
info(` endpoint: ${endpointText(made.endpoint)} ${color.dim(`region ${made.region}, path-style`)}`);
|
|
5898
|
+
info(color.dim(` next: kvbox bucket key create ${shown} (an access key for your app)`));
|
|
5899
|
+
} finally {
|
|
5900
|
+
await client.close();
|
|
5901
|
+
}
|
|
5902
|
+
});
|
|
5903
|
+
|
|
5904
|
+
// src/commands/bucket/grow.ts
|
|
5905
|
+
import { Command as Command63 } from "commander";
|
|
5906
|
+
var growCommand2 = new Command63("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) => {
|
|
5907
|
+
const sizeGib = parseGib2(size, "size");
|
|
5908
|
+
const client = await bucketClient(cmd);
|
|
5909
|
+
try {
|
|
5910
|
+
const s = await spin(`growing your object storage to ${sizeGib} GB\u2026`, client.growStorage(sizeGib));
|
|
5911
|
+
if (opts.json) json(s);
|
|
5912
|
+
else info(`${color.green("\u2713")} the object storage of ${s.owner} is ${s.sizeGib} GB, ${priceText(s)}`);
|
|
5913
|
+
} finally {
|
|
5914
|
+
await client.close();
|
|
5915
|
+
}
|
|
5916
|
+
});
|
|
5917
|
+
|
|
5918
|
+
// src/commands/bucket/info.ts
|
|
5919
|
+
import { Command as Command64 } from "commander";
|
|
5920
|
+
var infoCommand = new Command64("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) => {
|
|
5921
|
+
const client = await bucketClient(cmd);
|
|
5922
|
+
try {
|
|
5923
|
+
const b = await client.getBucket(name);
|
|
5924
|
+
if (opts.json) {
|
|
5925
|
+
json(b);
|
|
5926
|
+
return;
|
|
5927
|
+
}
|
|
5928
|
+
const shown = shownName(b, client);
|
|
5929
|
+
const s = b.storage;
|
|
5930
|
+
const rows2 = [
|
|
5931
|
+
["name", color.bold(shown)],
|
|
5932
|
+
["endpoint", endpointText(b.endpoint)],
|
|
5933
|
+
["region", `${b.region} ${color.dim("(path-style addressing)")}`],
|
|
5934
|
+
["holds", b.objects === void 0 || b.bytes === void 0 ? color.dim(s.status === "running" ? "not answering yet" : `unknown (the storage is ${s.status})`) : `${b.objects} ${b.objects === 1 ? "object" : "objects"}, ${gb(b.bytes)}`],
|
|
5935
|
+
["keys", b.keys === 0 ? color.dim(`none (kvbox bucket key create ${shown})`) : `${b.keys} ${color.dim(`(kvbox bucket key ls ${shown})`)}`],
|
|
5936
|
+
["storage", `${fullness(s)}, ${s.buckets} ${s.buckets === 1 ? "bucket" : "buckets"}${nearlyFull(s) ? color.yellow(" almost full: kvbox bucket grow <GB>") : ""}`],
|
|
5937
|
+
["cost", `${priceText(s)} for the whole storage`],
|
|
5938
|
+
["created", `${age(b.createdAt)}${b.createdBy ? ` by ${b.createdBy}` : ""}`]
|
|
5939
|
+
];
|
|
5940
|
+
printRows(rows2);
|
|
5941
|
+
if (b.endpoint !== null) info(color.dim(`
|
|
5942
|
+
with the AWS CLI: aws s3 ls s3://${b.name} --endpoint-url ${b.endpoint}`));
|
|
5943
|
+
} finally {
|
|
5944
|
+
await client.close();
|
|
5945
|
+
}
|
|
5946
|
+
});
|
|
5947
|
+
|
|
5948
|
+
// src/commands/bucket/key/index.ts
|
|
5949
|
+
import { Command as Command68 } from "commander";
|
|
5950
|
+
|
|
5951
|
+
// src/commands/bucket/key/create.ts
|
|
5952
|
+
import { Command as Command65 } from "commander";
|
|
5953
|
+
var createCommand5 = new Command65("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) => {
|
|
5954
|
+
const client = await bucketClient(cmd);
|
|
5955
|
+
try {
|
|
5956
|
+
const key = await client.createBucketKey(bucket, { ...opts.name !== void 0 ? { name: opts.name } : {}, ...opts.readOnly ? { readOnly: true } : {} });
|
|
5957
|
+
if (opts.json) {
|
|
5958
|
+
json(key);
|
|
5959
|
+
return;
|
|
5960
|
+
}
|
|
5961
|
+
info(`${color.green("\u2713")} key ${color.bold(key.name)} ${key.readOnly ? "reads" : "reads and writes"} bucket ${color.bold(key.bucket)}`);
|
|
5962
|
+
printRows([
|
|
5963
|
+
["endpoint", endpointText(key.endpoint)],
|
|
5964
|
+
["region", key.region],
|
|
5965
|
+
["bucket", key.bucket],
|
|
5966
|
+
["access key", key.id],
|
|
5967
|
+
["secret key", key.secret]
|
|
5968
|
+
]);
|
|
5969
|
+
info(color.dim("\nThe secret key is shown only now. Clients must use path-style addressing (AWS SDKs: forcePathStyle)."));
|
|
5970
|
+
} finally {
|
|
5971
|
+
await client.close();
|
|
5972
|
+
}
|
|
5973
|
+
});
|
|
5974
|
+
|
|
5975
|
+
// src/commands/bucket/key/ls.ts
|
|
5976
|
+
import { Command as Command66 } from "commander";
|
|
5977
|
+
var lsCommand9 = new Command66("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) => {
|
|
5978
|
+
const client = await bucketClient(cmd);
|
|
5979
|
+
try {
|
|
5980
|
+
const keys = await client.listBucketKeys(bucket);
|
|
5981
|
+
if (opts.json) {
|
|
5982
|
+
json(keys);
|
|
5983
|
+
return;
|
|
5984
|
+
}
|
|
5985
|
+
if (keys.length === 0) {
|
|
5986
|
+
info(`bucket ${bucket} has no keys yet; make one with: kvbox bucket key create ${bucket}`);
|
|
5987
|
+
return;
|
|
5988
|
+
}
|
|
5989
|
+
table(keys.map((k) => ({ "access key": k.id, name: k.name, access: k.readOnly ? "read only" : "read and write", "made by": k.createdBy ?? "-", created: age(k.createdAt) })));
|
|
5990
|
+
} finally {
|
|
5991
|
+
await client.close();
|
|
5992
|
+
}
|
|
5993
|
+
});
|
|
5994
|
+
|
|
5995
|
+
// src/commands/bucket/key/rm.ts
|
|
5996
|
+
import { Command as Command67 } from "commander";
|
|
5997
|
+
var rmCommand8 = new Command67("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) => {
|
|
5998
|
+
const client = await bucketClient(cmd);
|
|
5999
|
+
try {
|
|
6000
|
+
if (!await confirm(`Delete key ${id} of bucket ${bucket}? Whatever uses it stops working.`, opts.yes ?? false)) {
|
|
6001
|
+
info("cancelled");
|
|
6002
|
+
process.exitCode = 1;
|
|
6003
|
+
return;
|
|
6004
|
+
}
|
|
6005
|
+
await client.deleteBucketKey(bucket, id);
|
|
6006
|
+
info(`${color.green("\u2713")} key ${id} deleted`);
|
|
6007
|
+
} finally {
|
|
6008
|
+
await client.close();
|
|
6009
|
+
}
|
|
6010
|
+
});
|
|
6011
|
+
|
|
6012
|
+
// src/commands/bucket/key/index.ts
|
|
6013
|
+
var keyCommand = new Command68("key").aliases(["keys"]).description("access keys of a bucket: what your app signs in with").addCommand(createCommand5).addCommand(lsCommand9).addCommand(rmCommand8);
|
|
6014
|
+
|
|
6015
|
+
// src/commands/bucket/ls.ts
|
|
6016
|
+
import { Command as Command69 } from "commander";
|
|
6017
|
+
var lsCommand10 = new Command69("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) => {
|
|
6018
|
+
const client = await bucketClient(cmd);
|
|
6019
|
+
try {
|
|
6020
|
+
const buckets = await client.listBuckets({ all: opts.all });
|
|
6021
|
+
if (opts.json) {
|
|
6022
|
+
json(buckets);
|
|
6023
|
+
return;
|
|
6024
|
+
}
|
|
6025
|
+
if (buckets.length === 0) {
|
|
6026
|
+
info("no buckets yet; make one with: kvbox bucket create <name>");
|
|
6027
|
+
return;
|
|
6028
|
+
}
|
|
6029
|
+
const me2 = client.target.kind === "cloud" ? client.target.user : void 0;
|
|
6030
|
+
table(
|
|
6031
|
+
buckets.map((b) => ({
|
|
6032
|
+
owner: b.owner === me2 ? "private" : b.owner,
|
|
6033
|
+
name: b.name,
|
|
6034
|
+
keys: b.keys,
|
|
6035
|
+
created: age(b.createdAt)
|
|
6036
|
+
}))
|
|
6037
|
+
);
|
|
6038
|
+
for (const s of await client.listStorage({ all: opts.all })) {
|
|
6039
|
+
info(`${color.dim(s.owner === me2 ? "your object storage:" : `object storage of ${s.owner}:`)} ${endpointText(s.endpoint)} ${s.sizeGib} GB ${priceText(s)}`);
|
|
6040
|
+
}
|
|
6041
|
+
} finally {
|
|
6042
|
+
await client.close();
|
|
6043
|
+
}
|
|
6044
|
+
});
|
|
6045
|
+
|
|
6046
|
+
// src/commands/bucket/rm.ts
|
|
6047
|
+
import { Command as Command70 } from "commander";
|
|
6048
|
+
var rmCommand9 = new Command70("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) => {
|
|
6049
|
+
const client = await bucketClient(cmd);
|
|
6050
|
+
try {
|
|
6051
|
+
const question = opts.force ? `Delete bucket ${name} with everything in it, and the object storage it is in?` : `Delete bucket ${name} and its keys?`;
|
|
6052
|
+
if (!await confirm(question, opts.yes ?? false)) {
|
|
6053
|
+
info("cancelled");
|
|
6054
|
+
process.exitCode = 1;
|
|
6055
|
+
return;
|
|
6056
|
+
}
|
|
6057
|
+
const before = (await client.listStorage()).length;
|
|
6058
|
+
await spin(`deleting bucket ${name}\u2026`, client.deleteBucket(name, opts.force ?? false));
|
|
6059
|
+
const gone = (await client.listStorage()).length < before;
|
|
6060
|
+
info(`${color.green("\u2713")} bucket ${name} deleted${gone ? color.dim(" (it was the last one: the object storage is removed and no longer charged)") : ""}`);
|
|
6061
|
+
} finally {
|
|
6062
|
+
await client.close();
|
|
6063
|
+
}
|
|
6064
|
+
});
|
|
6065
|
+
|
|
6066
|
+
// src/commands/bucket/index.ts
|
|
6067
|
+
var bucketCommand = new Command71("bucket").aliases(["buckets"]).description("object storage: S3 buckets for your files, and the access keys your apps use").addCommand(createCommand4).addCommand(lsCommand10).addCommand(infoCommand).addCommand(growCommand2).addCommand(rmCommand9).addCommand(keyCommand);
|
|
6068
|
+
var withOrg = (cmd) => cmd.option("--org <slug>", "act in this org (- for your personal buckets)");
|
|
6069
|
+
for (const cmd of bucketCommand.commands) {
|
|
6070
|
+
if (cmd === keyCommand) cmd.commands.forEach(withOrg);
|
|
6071
|
+
else withOrg(cmd);
|
|
6072
|
+
}
|
|
6073
|
+
|
|
5738
6074
|
// src/commands/managed/kind.ts
|
|
5739
|
-
import { Command as
|
|
6075
|
+
import { Command as Command84 } from "commander";
|
|
5740
6076
|
|
|
5741
6077
|
// src/commands/managed/create.ts
|
|
5742
|
-
import { Command as
|
|
6078
|
+
import { Command as Command73 } from "commander";
|
|
5743
6079
|
import { setTimeout as sleep3 } from "timers/promises";
|
|
5744
6080
|
|
|
5745
6081
|
// src/commands/managed/shared.ts
|
|
@@ -5772,9 +6108,9 @@ async function managedClient(cmd) {
|
|
|
5772
6108
|
}
|
|
5773
6109
|
return client;
|
|
5774
6110
|
}
|
|
5775
|
-
var
|
|
6111
|
+
var shownName2 = (m, user) => m.owner === user ? m.name : `${m.owner}/${m.name}`;
|
|
5776
6112
|
var storageText = (m) => m.health?.storageUsedBytes !== void 0 ? `${gb(m.health.storageUsedBytes)} of ${m.storageGib} GB used` : `${m.storageGib} GB`;
|
|
5777
|
-
var
|
|
6113
|
+
var nearlyFull2 = (m) => m.health?.storageUsedBytes !== void 0 && m.health.storageTotalBytes !== void 0 && m.health.storageTotalBytes > 0 && m.health.storageUsedBytes / m.health.storageTotalBytes >= 0.9;
|
|
5778
6114
|
function stateText(m) {
|
|
5779
6115
|
if (m.status === "stopped") return `${status(m.status)} ${color.dim("(only its storage is charged)")}`;
|
|
5780
6116
|
if (m.status !== "running" || m.health === void 0) return status(m.status);
|
|
@@ -5783,7 +6119,7 @@ function stateText(m) {
|
|
|
5783
6119
|
return `${status(m.status)}, ${m.health.accepting ? "accepting connections" : color.yellow("not accepting connections")}`;
|
|
5784
6120
|
}
|
|
5785
6121
|
function infoRows(spec, m, user) {
|
|
5786
|
-
const name =
|
|
6122
|
+
const name = shownName2(m, user);
|
|
5787
6123
|
const rows2 = [
|
|
5788
6124
|
["name", color.bold(name)],
|
|
5789
6125
|
["status", stateText(m)],
|
|
@@ -5791,7 +6127,7 @@ function infoRows(spec, m, user) {
|
|
|
5791
6127
|
];
|
|
5792
6128
|
if (user !== void 0 && m.owner !== user) rows2.push(["owner", m.owner]);
|
|
5793
6129
|
for (const fact of m.health?.facts ?? []) rows2.push([fact.title.toLowerCase(), fact.value]);
|
|
5794
|
-
rows2.push(["storage", `${storageText(m)}${
|
|
6130
|
+
rows2.push(["storage", `${storageText(m)}${nearlyFull2(m) ? color.yellow(` almost full: kvbox ${spec.command} grow ${name} <GB>`) : ""}`]);
|
|
5795
6131
|
rows2.push(...settingRows(spec, m.settings), ["password", color.dim(`kvbox ${spec.command} password ${name}`)]);
|
|
5796
6132
|
rows2.push(["private", `${m.urls.private} ${color.dim(m.links.length > 0 ? `(from ${m.links.join(", ")})` : `(no box is linked: kvbox ${spec.command} link ${name} <box>)`)}`]);
|
|
5797
6133
|
rows2.push(["public", m.urls.public ?? color.dim(`off (kvbox ${spec.command} public ${name} on)`)]);
|
|
@@ -5799,7 +6135,7 @@ function infoRows(spec, m, user) {
|
|
|
5799
6135
|
rows2.push(["created", `${age(m.createdAt)}${m.createdBy ? ` by ${m.createdBy}` : ""}`]);
|
|
5800
6136
|
return rows2;
|
|
5801
6137
|
}
|
|
5802
|
-
function
|
|
6138
|
+
function printRows2(rows2) {
|
|
5803
6139
|
const width2 = Math.max(...rows2.map(([label]) => label.length));
|
|
5804
6140
|
for (const [label, value] of rows2) process.stdout.write(`${color.dim(label.padEnd(width2))} ${value}
|
|
5805
6141
|
`);
|
|
@@ -5825,8 +6161,8 @@ function parseStorage(text2, flag) {
|
|
|
5825
6161
|
// src/commands/managed/create.ts
|
|
5826
6162
|
var READY_WAIT_MS = 9e4;
|
|
5827
6163
|
var READY_STEP_MS = 2e3;
|
|
5828
|
-
var
|
|
5829
|
-
const command = new
|
|
6164
|
+
var createCommand6 = (spec) => {
|
|
6165
|
+
const command = new Command73("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");
|
|
5830
6166
|
for (const o of spec.options) command.option(`--${o.name} <${o.arg}>`, o.help);
|
|
5831
6167
|
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) => {
|
|
5832
6168
|
const options = Object.fromEntries(spec.options.flatMap((o) => typeof opts[o.name] === "string" ? [[o.name, opts[o.name]]] : []));
|
|
@@ -5840,7 +6176,7 @@ var createCommand4 = (spec) => {
|
|
|
5840
6176
|
const client = await managedClient(cmd);
|
|
5841
6177
|
try {
|
|
5842
6178
|
const made = await spin(`creating ${spec.title} database ${name}\u2026`, client.createManaged(spec.kind, req));
|
|
5843
|
-
const shown =
|
|
6179
|
+
const shown = shownName2(made, me(client));
|
|
5844
6180
|
const ready = await spin(`starting ${spec.title}\u2026`, async () => {
|
|
5845
6181
|
for (const until = Date.now() + READY_WAIT_MS; Date.now() < until; await sleep3(READY_STEP_MS)) {
|
|
5846
6182
|
const now = await client.getManaged(spec.kind, shown).catch(() => void 0);
|
|
@@ -5853,7 +6189,7 @@ var createCommand4 = (spec) => {
|
|
|
5853
6189
|
return;
|
|
5854
6190
|
}
|
|
5855
6191
|
info(`${color.green("\u2713")} database ${color.bold(shown)} ${ready ? "is ready" : "is created and still starting"} ${color.dim(`(${spec.title} ${made.version}, ${made.storageGib} GB of storage)`)}`);
|
|
5856
|
-
|
|
6192
|
+
printRows2([...settingRows(spec, made.settings), ...secretRows(made.secret)].map(([label, value]) => [` ${label}`, value]));
|
|
5857
6193
|
info("");
|
|
5858
6194
|
info("Nobody can reach it yet. To let something in:");
|
|
5859
6195
|
info(` a box on the same host kvbox ${spec.command} link ${shown} <box> ${color.dim(`(a new one: kvbox new <box> --near ${shown})`)}`);
|
|
@@ -5867,8 +6203,8 @@ var createCommand4 = (spec) => {
|
|
|
5867
6203
|
};
|
|
5868
6204
|
|
|
5869
6205
|
// src/commands/managed/grow.ts
|
|
5870
|
-
import { Command as
|
|
5871
|
-
var
|
|
6206
|
+
import { Command as Command74 } from "commander";
|
|
6207
|
+
var growCommand3 = (spec) => new Command74("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) => {
|
|
5872
6208
|
const storageGib = parseStorage(size, "size");
|
|
5873
6209
|
const client = await managedClient(cmd);
|
|
5874
6210
|
try {
|
|
@@ -5881,21 +6217,21 @@ var growCommand2 = (spec) => new Command64("grow").description("give a database
|
|
|
5881
6217
|
});
|
|
5882
6218
|
|
|
5883
6219
|
// src/commands/managed/info.ts
|
|
5884
|
-
import { Command as
|
|
5885
|
-
var
|
|
6220
|
+
import { Command as Command75 } from "commander";
|
|
6221
|
+
var infoCommand2 = (spec) => new Command75("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) => {
|
|
5886
6222
|
const client = await managedClient(cmd);
|
|
5887
6223
|
try {
|
|
5888
6224
|
const m = await client.getManaged(spec.kind, name);
|
|
5889
6225
|
if (opts.json) json(m);
|
|
5890
|
-
else
|
|
6226
|
+
else printRows2(infoRows(spec, m, me(client)));
|
|
5891
6227
|
} finally {
|
|
5892
6228
|
await client.close();
|
|
5893
6229
|
}
|
|
5894
6230
|
});
|
|
5895
6231
|
|
|
5896
6232
|
// src/commands/managed/link.ts
|
|
5897
|
-
import { Command as
|
|
5898
|
-
var linkCommand2 = (spec) => new
|
|
6233
|
+
import { Command as Command76 } from "commander";
|
|
6234
|
+
var linkCommand2 = (spec) => new Command76("link").description("let a box reach a database privately (same host)").argument("<db>", "the database").argument("<box>", "the box that connects to it").option("--json", "print as JSON").action(async (name, box, opts, cmd) => {
|
|
5899
6235
|
const client = await managedClient(cmd);
|
|
5900
6236
|
try {
|
|
5901
6237
|
const m = await spin(`linking ${box} to ${name}\u2026`, client.linkManaged(spec.kind, name, box));
|
|
@@ -5911,7 +6247,7 @@ var linkCommand2 = (spec) => new Command66("link").description("let a box reach
|
|
|
5911
6247
|
});
|
|
5912
6248
|
|
|
5913
6249
|
// src/commands/managed/ls.ts
|
|
5914
|
-
import { Command as
|
|
6250
|
+
import { Command as Command77 } from "commander";
|
|
5915
6251
|
function listRows(items, user, kindColumn) {
|
|
5916
6252
|
return items.map((m) => ({
|
|
5917
6253
|
owner: m.owner === user ? "private" : m.owner,
|
|
@@ -5925,7 +6261,7 @@ function listRows(items, user, kindColumn) {
|
|
|
5925
6261
|
created: age(m.createdAt)
|
|
5926
6262
|
}));
|
|
5927
6263
|
}
|
|
5928
|
-
var
|
|
6264
|
+
var lsCommand11 = (spec) => new Command77("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) => {
|
|
5929
6265
|
const client = await managedClient(cmd);
|
|
5930
6266
|
try {
|
|
5931
6267
|
const items = await client.listManaged(spec?.kind, { all: opts.all });
|
|
@@ -5945,8 +6281,8 @@ var lsCommand9 = (spec) => new Command67("ls").alias("list").description(spec ?
|
|
|
5945
6281
|
});
|
|
5946
6282
|
|
|
5947
6283
|
// src/commands/managed/password.ts
|
|
5948
|
-
import { Command as
|
|
5949
|
-
var passwordCommand = (spec) => new
|
|
6284
|
+
import { Command as Command78 } from "commander";
|
|
6285
|
+
var passwordCommand = (spec) => new Command78("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) => {
|
|
5950
6286
|
const client = await managedClient(cmd);
|
|
5951
6287
|
try {
|
|
5952
6288
|
const secret = opts.reset ? await spin(`setting a new password on ${name}\u2026`, client.resetManagedPassword(spec.kind, name)) : await client.managedPassword(spec.kind, name);
|
|
@@ -5955,15 +6291,15 @@ var passwordCommand = (spec) => new Command68("password").description("show a da
|
|
|
5955
6291
|
return;
|
|
5956
6292
|
}
|
|
5957
6293
|
if (opts.reset) info(`${color.green("\u2713")} database ${name} has a new password; the old one no longer works`);
|
|
5958
|
-
|
|
6294
|
+
printRows2(secretRows(secret));
|
|
5959
6295
|
} finally {
|
|
5960
6296
|
await client.close();
|
|
5961
6297
|
}
|
|
5962
6298
|
});
|
|
5963
6299
|
|
|
5964
6300
|
// src/commands/managed/public.ts
|
|
5965
|
-
import { Command as
|
|
5966
|
-
var publicCommand = (spec) => new
|
|
6301
|
+
import { Command as Command79 } from "commander";
|
|
6302
|
+
var publicCommand = (spec) => new Command79("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) => {
|
|
5967
6303
|
if (state !== "on" && state !== "off") throw new KvboxError(`write on or off: kvbox ${spec.command} public ${name} on`);
|
|
5968
6304
|
const client = await managedClient(cmd);
|
|
5969
6305
|
try {
|
|
@@ -5984,8 +6320,8 @@ var publicCommand = (spec) => new Command69("public").description("open a databa
|
|
|
5984
6320
|
});
|
|
5985
6321
|
|
|
5986
6322
|
// src/commands/managed/rm.ts
|
|
5987
|
-
import { Command as
|
|
5988
|
-
var
|
|
6323
|
+
import { Command as Command80 } from "commander";
|
|
6324
|
+
var rmCommand10 = (spec) => new Command80("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) => {
|
|
5989
6325
|
const client = await managedClient(cmd);
|
|
5990
6326
|
try {
|
|
5991
6327
|
if (!await confirm(`Delete database ${name} and all its data? There is no backup.`, opts.yes ?? false)) {
|
|
@@ -6001,8 +6337,8 @@ var rmCommand8 = (spec) => new Command70("rm").alias("remove").description("dele
|
|
|
6001
6337
|
});
|
|
6002
6338
|
|
|
6003
6339
|
// src/commands/managed/start.ts
|
|
6004
|
-
import { Command as
|
|
6005
|
-
var startCommand2 = (spec) => new
|
|
6340
|
+
import { Command as Command81 } from "commander";
|
|
6341
|
+
var startCommand2 = (spec) => new Command81("start").description("run a stopped database again").argument("<db>", "its name").option("--json", "print as JSON").action(async (name, opts, cmd) => {
|
|
6006
6342
|
const client = await managedClient(cmd);
|
|
6007
6343
|
try {
|
|
6008
6344
|
const m = await spin(`starting ${name}\u2026`, client.startManaged(spec.kind, name));
|
|
@@ -6014,8 +6350,8 @@ var startCommand2 = (spec) => new Command71("start").description("run a stopped
|
|
|
6014
6350
|
});
|
|
6015
6351
|
|
|
6016
6352
|
// src/commands/managed/stop.ts
|
|
6017
|
-
import { Command as
|
|
6018
|
-
var stopCommand2 = (spec) => new
|
|
6353
|
+
import { Command as Command82 } from "commander";
|
|
6354
|
+
var stopCommand2 = (spec) => new Command82("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) => {
|
|
6019
6355
|
const client = await managedClient(cmd);
|
|
6020
6356
|
try {
|
|
6021
6357
|
const m = await spin(`stopping ${name}\u2026`, client.stopManaged(spec.kind, name));
|
|
@@ -6027,8 +6363,8 @@ var stopCommand2 = (spec) => new Command72("stop").description("shut a database
|
|
|
6027
6363
|
});
|
|
6028
6364
|
|
|
6029
6365
|
// src/commands/managed/unlink.ts
|
|
6030
|
-
import { Command as
|
|
6031
|
-
var unlinkCommand2 = (spec) => new
|
|
6366
|
+
import { Command as Command83 } from "commander";
|
|
6367
|
+
var unlinkCommand2 = (spec) => new Command83("unlink").description("stop a box from reaching a database").argument("<db>", "the database").argument("<box>", "the box that was linked to it").option("--json", "print as JSON").action(async (name, box, opts, cmd) => {
|
|
6032
6368
|
const client = await managedClient(cmd);
|
|
6033
6369
|
try {
|
|
6034
6370
|
const m = await spin(`unlinking ${box} from ${name}\u2026`, client.unlinkManaged(spec.kind, name, box));
|
|
@@ -6041,8 +6377,8 @@ var unlinkCommand2 = (spec) => new Command73("unlink").description("stop a box f
|
|
|
6041
6377
|
|
|
6042
6378
|
// src/commands/managed/kind.ts
|
|
6043
6379
|
function kindCommand(spec, description) {
|
|
6044
|
-
const command = new
|
|
6045
|
-
for (const make of [
|
|
6380
|
+
const command = new Command84(spec.command).aliases(spec.aliases).description(description);
|
|
6381
|
+
for (const make of [createCommand6, lsCommand11, infoCommand2, passwordCommand, publicCommand, linkCommand2, unlinkCommand2, growCommand3, stopCommand2, startCommand2, rmCommand10]) {
|
|
6046
6382
|
command.addCommand(make(spec).option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
6047
6383
|
}
|
|
6048
6384
|
return command;
|
|
@@ -6055,14 +6391,14 @@ var pgCommand = kindCommand(POSTGRES2, "managed PostgreSQL: a database kvbox run
|
|
|
6055
6391
|
var redisCommand = kindCommand(REDIS, "managed Redis (Valkey): a Redis kvbox runs for you, private until you link a box or make it public");
|
|
6056
6392
|
|
|
6057
6393
|
// src/commands/managed/index.ts
|
|
6058
|
-
import { Command as
|
|
6059
|
-
var managedCommand = new
|
|
6394
|
+
import { Command as Command85 } from "commander";
|
|
6395
|
+
var managedCommand = new Command85("managed").description(`databases kvbox runs for you, every kind together (${KINDS.map((k) => `${k.title}: kvbox ${k.command}`).join(", ")})`).addCommand(lsCommand11().option("--org <slug>", "act in this org (- for your personal databases)"));
|
|
6060
6396
|
|
|
6061
6397
|
// src/commands/env/index.ts
|
|
6062
|
-
import { Command as
|
|
6398
|
+
import { Command as Command89 } from "commander";
|
|
6063
6399
|
|
|
6064
6400
|
// src/commands/env/ls.ts
|
|
6065
|
-
import { Command as
|
|
6401
|
+
import { Command as Command86 } from "commander";
|
|
6066
6402
|
|
|
6067
6403
|
// src/commands/env/shared.ts
|
|
6068
6404
|
function requireCloud4(client) {
|
|
@@ -6089,7 +6425,7 @@ function firstBootHint(box, name) {
|
|
|
6089
6425
|
}
|
|
6090
6426
|
|
|
6091
6427
|
// src/commands/env/ls.ts
|
|
6092
|
-
var
|
|
6428
|
+
var lsCommand12 = new Command86("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) => {
|
|
6093
6429
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6094
6430
|
try {
|
|
6095
6431
|
if (opts.box !== void 0) {
|
|
@@ -6128,8 +6464,8 @@ var lsCommand10 = new Command76("ls").alias("list").description("list the variab
|
|
|
6128
6464
|
});
|
|
6129
6465
|
|
|
6130
6466
|
// src/commands/env/rm.ts
|
|
6131
|
-
import { Command as
|
|
6132
|
-
var
|
|
6467
|
+
import { Command as Command87 } from "commander";
|
|
6468
|
+
var rmCommand11 = new Command87("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) => {
|
|
6133
6469
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6134
6470
|
try {
|
|
6135
6471
|
const target = opts.box === void 0 ? void 0 : await findBox2(client, opts.box);
|
|
@@ -6166,8 +6502,8 @@ var rmCommand9 = new Command77("rm").alias("remove").description("remove variabl
|
|
|
6166
6502
|
});
|
|
6167
6503
|
|
|
6168
6504
|
// src/commands/env/set.ts
|
|
6169
|
-
import { Command as
|
|
6170
|
-
var setCommand2 = new
|
|
6505
|
+
import { Command as Command88 } from "commander";
|
|
6506
|
+
var setCommand2 = new Command88("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) => {
|
|
6171
6507
|
const client = await clientFor(cmd.optsWithGlobals(), { autoStart: false });
|
|
6172
6508
|
try {
|
|
6173
6509
|
const owner = opts.box === void 0 ? requireCloud4(client) : void 0;
|
|
@@ -6204,14 +6540,14 @@ var setCommand2 = new Command78("set").description("add or change a variable; bo
|
|
|
6204
6540
|
});
|
|
6205
6541
|
|
|
6206
6542
|
// src/commands/env/index.ts
|
|
6207
|
-
var envCommand = new
|
|
6543
|
+
var envCommand = new Command89("env").description("environment variables every box of yours gets when it starts (secrets too)").addCommand(lsCommand12, { isDefault: true }).addCommand(setCommand2).addCommand(rmCommand11);
|
|
6208
6544
|
for (const cmd of envCommand.commands) cmd.option("--org <slug>", "the org's variables instead of yours");
|
|
6209
6545
|
|
|
6210
6546
|
// src/commands/domain/index.ts
|
|
6211
|
-
import { Command as
|
|
6547
|
+
import { Command as Command93 } from "commander";
|
|
6212
6548
|
|
|
6213
6549
|
// src/commands/domain/add.ts
|
|
6214
|
-
import { Command as
|
|
6550
|
+
import { Command as Command90 } from "commander";
|
|
6215
6551
|
|
|
6216
6552
|
// src/commands/domain/shared.ts
|
|
6217
6553
|
function requireCloud5(client) {
|
|
@@ -6231,7 +6567,7 @@ function hostIn(name, zone) {
|
|
|
6231
6567
|
}
|
|
6232
6568
|
|
|
6233
6569
|
// src/commands/domain/add.ts
|
|
6234
|
-
var addCommand3 = new
|
|
6570
|
+
var addCommand3 = new Command90("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) => {
|
|
6235
6571
|
const domain = assertDomain(domainArg.trim().toLowerCase());
|
|
6236
6572
|
const port = opts.port === void 0 ? void 0 : parsePorts([opts.port])[0];
|
|
6237
6573
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
@@ -6267,8 +6603,8 @@ kvbox checks every minute; ${domain} is served at ${d.url} once its records are
|
|
|
6267
6603
|
});
|
|
6268
6604
|
|
|
6269
6605
|
// src/commands/domain/ls.ts
|
|
6270
|
-
import { Command as
|
|
6271
|
-
var
|
|
6606
|
+
import { Command as Command91 } from "commander";
|
|
6607
|
+
var lsCommand13 = new Command91("ls").alias("list").description("list your custom domains and whether they are live").option("--json", "print as JSON").action(async (opts, cmd) => {
|
|
6272
6608
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
6273
6609
|
try {
|
|
6274
6610
|
requireCloud5(client);
|
|
@@ -6297,8 +6633,8 @@ var lsCommand11 = new Command81("ls").alias("list").description("list your custo
|
|
|
6297
6633
|
});
|
|
6298
6634
|
|
|
6299
6635
|
// src/commands/domain/rm.ts
|
|
6300
|
-
import { Command as
|
|
6301
|
-
var
|
|
6636
|
+
import { Command as Command92 } from "commander";
|
|
6637
|
+
var rmCommand12 = new Command92("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) => {
|
|
6302
6638
|
const domain = domainArg.trim().toLowerCase();
|
|
6303
6639
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
6304
6640
|
try {
|
|
@@ -6319,7 +6655,7 @@ var rmCommand10 = new Command82("rm").alias("remove").description("stop serving
|
|
|
6319
6655
|
});
|
|
6320
6656
|
|
|
6321
6657
|
// src/commands/domain/index.ts
|
|
6322
|
-
var domainCommand = new
|
|
6658
|
+
var domainCommand = new Command93("domain").alias("domains").description("serve a box at a domain of your own").addCommand(addCommand3).addCommand(lsCommand13).addCommand(rmCommand12);
|
|
6323
6659
|
for (const cmd of domainCommand.commands) cmd.option("--org <slug>", "act in this org (- for your personal boxes)");
|
|
6324
6660
|
|
|
6325
6661
|
// src/commands/update.ts
|
|
@@ -6327,7 +6663,7 @@ import { spawn as spawn6 } from "child_process";
|
|
|
6327
6663
|
import { mkdtempSync, rmSync, writeFileSync as writeFileSync2 } from "fs";
|
|
6328
6664
|
import { tmpdir } from "os";
|
|
6329
6665
|
import { join as join9 } from "path";
|
|
6330
|
-
import { Command as
|
|
6666
|
+
import { Command as Command94 } from "commander";
|
|
6331
6667
|
|
|
6332
6668
|
// src/update.ts
|
|
6333
6669
|
import { mkdirSync, readFileSync as readFileSync3, writeFileSync } from "fs";
|
|
@@ -6446,7 +6782,7 @@ function run2(cmd, args) {
|
|
|
6446
6782
|
child.on("exit", (code, signal) => resolve4(code ?? (signal ? 1 : 0)));
|
|
6447
6783
|
});
|
|
6448
6784
|
}
|
|
6449
|
-
var selfUpdateCommand = new
|
|
6785
|
+
var selfUpdateCommand = new Command94("update").description("update kvbox to the latest version (reruns the installer from kvbox.sh, agent skill included)").action(async () => {
|
|
6450
6786
|
suppressUpdateNotice();
|
|
6451
6787
|
const inst = installerFor(process.platform, process.env["KVBOX_INSTALL_URL"] || INSTALL_BASE);
|
|
6452
6788
|
let code;
|
|
@@ -6510,6 +6846,7 @@ var HELP_GROUPS = [
|
|
|
6510
6846
|
["vm", "everything about boxes: fork, rescale, ports, hooks, backups"],
|
|
6511
6847
|
["snapshots", "freeze a running box into a snapshot, start new boxes from it"],
|
|
6512
6848
|
["volume", "disks of their own that move between boxes"],
|
|
6849
|
+
["bucket", "object storage: S3 buckets for your files"],
|
|
6513
6850
|
["pg", "managed PostgreSQL: a database kvbox runs for you"],
|
|
6514
6851
|
["redis", "managed Redis (Valkey): a Redis kvbox runs for you"],
|
|
6515
6852
|
["managed", "every managed database, whatever its kind"],
|
|
@@ -6570,10 +6907,11 @@ function installRootHelp(program) {
|
|
|
6570
6907
|
|
|
6571
6908
|
// src/program.ts
|
|
6572
6909
|
function buildProgram() {
|
|
6573
|
-
const program = new
|
|
6910
|
+
const program = new Command95("kvbox").description("self-hosted Firecracker microVMs with Docker-like ergonomics").version(VERSION, "-v, --version").option("--local", "use this machine's kvbox-server over its socket, ignoring kvbox login").option("--org <slug>", "the org: where kvbox new creates, and which box a name means when it is not one of yours; before the command here, or after it").showHelpAfterError().enablePositionalOptions();
|
|
6574
6911
|
program.addCommand(vmCommand);
|
|
6575
6912
|
program.addCommand(snapshotsCommand);
|
|
6576
6913
|
program.addCommand(volumeCommand);
|
|
6914
|
+
program.addCommand(bucketCommand);
|
|
6577
6915
|
program.addCommand(pgCommand);
|
|
6578
6916
|
program.addCommand(redisCommand);
|
|
6579
6917
|
program.addCommand(managedCommand);
|