@kvbox/cli 0.5.34 → 0.5.35
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 +34 -20
- package/dist/kvbox.js.map +1 -1
- package/package.json +1 -1
package/dist/kvbox.js
CHANGED
|
@@ -164,7 +164,7 @@ function versionOf(srcFileUrl, injected) {
|
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
// src/version.ts
|
|
167
|
-
var VERSION = versionOf(import.meta.url, true ? "0.5.
|
|
167
|
+
var VERSION = versionOf(import.meta.url, true ? "0.5.35" : void 0);
|
|
168
168
|
|
|
169
169
|
// src/commands/vm/index.ts
|
|
170
170
|
import { Command as Command33 } from "commander";
|
|
@@ -645,7 +645,12 @@ var RescaleMachineRequest = z2.object({
|
|
|
645
645
|
size: SizeSchema.optional(),
|
|
646
646
|
vcpu: z2.number().int().min(1).max(64).optional(),
|
|
647
647
|
memMib: z2.number().int().min(256).optional(),
|
|
648
|
-
diskGib: z2.number().int().min(1).optional()
|
|
648
|
+
diskGib: z2.number().int().min(1).optional(),
|
|
649
|
+
/** Skip the capacity guard when a running box grows (#37). */
|
|
650
|
+
force: z2.boolean().optional()
|
|
651
|
+
});
|
|
652
|
+
var StartMachineRequest = z2.object({
|
|
653
|
+
force: z2.boolean().optional()
|
|
649
654
|
});
|
|
650
655
|
var SetMachineRequest = z2.object({
|
|
651
656
|
/** Seconds without network traffic before the box is hibernated (#47); 0: never. */
|
|
@@ -1179,8 +1184,8 @@ var ServerClient = class {
|
|
|
1179
1184
|
stopMachine(name) {
|
|
1180
1185
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/stop`, MachineSchema);
|
|
1181
1186
|
}
|
|
1182
|
-
startMachine(name) {
|
|
1183
|
-
return this.call("POST", `/machines/${encodeURIComponent(name)}/start`, MachineSchema);
|
|
1187
|
+
startMachine(name, force = false) {
|
|
1188
|
+
return this.call("POST", `/machines/${encodeURIComponent(name)}/start`, MachineSchema, force ? { force } : void 0);
|
|
1184
1189
|
}
|
|
1185
1190
|
pauseMachine(name) {
|
|
1186
1191
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/pause`, MachineSchema);
|
|
@@ -1191,8 +1196,8 @@ var ServerClient = class {
|
|
|
1191
1196
|
hibernateMachine(name) {
|
|
1192
1197
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/hibernate`, MachineSchema);
|
|
1193
1198
|
}
|
|
1194
|
-
wakeMachine(name) {
|
|
1195
|
-
return this.call("POST", `/machines/${encodeURIComponent(name)}/wake`, MachineSchema);
|
|
1199
|
+
wakeMachine(name, force = false) {
|
|
1200
|
+
return this.call("POST", `/machines/${encodeURIComponent(name)}/wake`, MachineSchema, force ? { force } : void 0);
|
|
1196
1201
|
}
|
|
1197
1202
|
updateMachine(name) {
|
|
1198
1203
|
return this.call("POST", `/machines/${encodeURIComponent(name)}/update`, MachineSchema);
|
|
@@ -2568,7 +2573,7 @@ for (const cmd of hookCommand.commands) cmd.option("--org <slug>", "act in this
|
|
|
2568
2573
|
|
|
2569
2574
|
// src/commands/vm/rescale.ts
|
|
2570
2575
|
import { Command as Command22, Option as Option3 } from "commander";
|
|
2571
|
-
var rescaleCommand = new Command22("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("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
2576
|
+
var rescaleCommand = new Command22("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) => {
|
|
2572
2577
|
const req = {
|
|
2573
2578
|
...opts.size !== void 0 ? { size: opts.size } : {},
|
|
2574
2579
|
...opts.vcpu !== void 0 ? { vcpu: parseCount(opts.vcpu) } : {},
|
|
@@ -2576,11 +2581,12 @@ var rescaleCommand = new Command22("rescale").description("change a box's vCPUs,
|
|
|
2576
2581
|
...opts.disk !== void 0 ? { diskGib: parseGib("--disk", opts.disk) } : {}
|
|
2577
2582
|
};
|
|
2578
2583
|
if (Object.keys(req).length === 0) throw new KvboxError("nothing to change: give --size, --vcpu, --mem or --disk");
|
|
2584
|
+
const body = opts.force ? { ...req, force: true } : req;
|
|
2579
2585
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
2580
2586
|
try {
|
|
2581
2587
|
const before = pickRef(await boxesFor(client, name), name, me(client));
|
|
2582
2588
|
if (!before) throw new KvboxError(`box ${name}: not found (kvbox ls)`);
|
|
2583
|
-
const box = await spin(`rescaling ${name}\u2026`, client.rescaleMachine(displayName(before, me(client)),
|
|
2589
|
+
const box = await spin(`rescaling ${name}\u2026`, client.rescaleMachine(displayName(before, me(client)), body));
|
|
2584
2590
|
if (opts.json) {
|
|
2585
2591
|
json(box);
|
|
2586
2592
|
return;
|
|
@@ -2682,10 +2688,10 @@ function parseIdleCheck(text2) {
|
|
|
2682
2688
|
|
|
2683
2689
|
// src/commands/vm/start.ts
|
|
2684
2690
|
import { Command as Command26 } from "commander";
|
|
2685
|
-
var startCommand = new Command26("start").description("boot a stopped box again (same name, IP and disk)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
2691
|
+
var startCommand = new Command26("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) => {
|
|
2686
2692
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
2687
2693
|
try {
|
|
2688
|
-
const box = await spin(`booting ${name}\u2026`, client.startMachine(name));
|
|
2694
|
+
const box = await spin(`booting ${name}\u2026`, client.startMachine(name, opts.force ?? false));
|
|
2689
2695
|
if (opts.json) json(box);
|
|
2690
2696
|
else info(`${color.green("\u2713")} ${describe(box)}`);
|
|
2691
2697
|
} finally {
|
|
@@ -2862,10 +2868,10 @@ function block(u) {
|
|
|
2862
2868
|
|
|
2863
2869
|
// src/commands/vm/wake.ts
|
|
2864
2870
|
import { Command as Command32 } from "commander";
|
|
2865
|
-
var wakeCommand = new Command32("wake").description("continue a hibernated box where it left off (same name, IP and disk)").argument("<name>", "box name").option("--json", "print the box as JSON").action(async (name, opts, cmd) => {
|
|
2871
|
+
var wakeCommand = new Command32("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) => {
|
|
2866
2872
|
const client = await clientFor(cmd.optsWithGlobals());
|
|
2867
2873
|
try {
|
|
2868
|
-
const box = await spin(`waking ${name} (loading its memory from disk)\u2026`, client.wakeMachine(name));
|
|
2874
|
+
const box = await spin(`waking ${name} (loading its memory from disk)\u2026`, client.wakeMachine(name, opts.force ?? false));
|
|
2869
2875
|
if (opts.json) json(box);
|
|
2870
2876
|
else info(`${color.green("\u2713")} box ${name} is awake, running where it left off`);
|
|
2871
2877
|
} finally {
|
|
@@ -3725,9 +3731,10 @@ function serverRemote(opts) {
|
|
|
3725
3731
|
var nextjsTemplate = {
|
|
3726
3732
|
id: "nextjs",
|
|
3727
3733
|
label: "Next.js",
|
|
3728
|
-
hint: "source shipped; installed, built and run in the box on
|
|
3734
|
+
hint: "source shipped; installed, built and run in the box on $PORT (3000)",
|
|
3729
3735
|
size: "s",
|
|
3730
3736
|
port: 3e3,
|
|
3737
|
+
customPort: true,
|
|
3731
3738
|
detect(pkg) {
|
|
3732
3739
|
if (!pkg) return false;
|
|
3733
3740
|
return "next" in { ...pkg.dependencies, ...pkg.devDependencies };
|
|
@@ -3866,7 +3873,7 @@ var DeployConfigSchema = z5.object({
|
|
|
3866
3873
|
size: z5.enum(SIZE_NAMES).optional(),
|
|
3867
3874
|
/** The build output directory, relative to the app; the template's default when absent. */
|
|
3868
3875
|
dist: z5.string().optional(),
|
|
3869
|
-
/** The port
|
|
3876
|
+
/** The port a Next.js app or Node server serves; the template's (3000) when absent. */
|
|
3870
3877
|
port: z5.number().int().min(1).max(65535).optional()
|
|
3871
3878
|
});
|
|
3872
3879
|
async function readConfig(dir) {
|
|
@@ -3956,7 +3963,7 @@ async function ship(ep, dir, remote, exclude = []) {
|
|
|
3956
3963
|
var shipping = { ship, measure, waitForSsh };
|
|
3957
3964
|
|
|
3958
3965
|
// src/commands/deploy/index.ts
|
|
3959
|
-
var deployCommand = new Command57("deploy").description("put the app in this directory (React, Next.js or a Node server) 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 when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the port a Node server listens on
|
|
3966
|
+
var deployCommand = new Command57("deploy").description("put the app in this directory (React, Next.js or a Node server) 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 when not given)").choices(TEMPLATE_IDS)).option("-n, --name <name>", "the box's name (default: the directory's name)").option("--sub <subdomain>", "its HTTPS name, https://<subdomain>.kvbox.app (default: the box's name)").addOption(new Option5("-s, --size <size>", "size of the box when it has to be made").choices(SIZE_NAMES)).option("--port <port>", "the port a Next.js app or Node server listens on (default 3000; saved to kvbox.json)", parsePort).option("-y, --yes", "ask nothing: take the defaults for whatever the flags and kvbox.json leave open").option("--json", "print the result as JSON").option("--org <slug>", "deploy into this org's boxes (saved to kvbox.json)").action(async (dirArg, opts, cmd) => {
|
|
3960
3967
|
const dir = resolve2(dirArg ?? ".");
|
|
3961
3968
|
const pkg = await readPackageJson(dir);
|
|
3962
3969
|
const saved = await readConfig(dir);
|
|
@@ -4028,10 +4035,13 @@ ${result.output.trim()}`);
|
|
|
4028
4035
|
await client.close();
|
|
4029
4036
|
}
|
|
4030
4037
|
});
|
|
4031
|
-
function
|
|
4038
|
+
function portProblem(v) {
|
|
4032
4039
|
const n = Number(v);
|
|
4033
|
-
|
|
4034
|
-
|
|
4040
|
+
return !/^\d+$/.test(v) || n < 1 || n > 65535;
|
|
4041
|
+
}
|
|
4042
|
+
function parsePort(v) {
|
|
4043
|
+
if (portProblem(v)) throw new InvalidArgumentError2("expected a port, 1-65535");
|
|
4044
|
+
return Number(v);
|
|
4035
4045
|
}
|
|
4036
4046
|
async function readPackageJson(dir) {
|
|
4037
4047
|
try {
|
|
@@ -4095,8 +4105,12 @@ async function settle(dir, pkg, saved, opts, orgFlag, cloud) {
|
|
|
4095
4105
|
if (open.size && ask) {
|
|
4096
4106
|
size = await select("Box size", SIZE_NAMES.map((s) => ({ value: s, label: s, hint: `${SIZES[s].vcpu} vCPU, ${SIZES[s].memMib / 1024} GB RAM, ${SIZES[s].diskGib} GB disk` })), SIZE_NAMES.indexOf(template.size));
|
|
4097
4107
|
}
|
|
4098
|
-
if (opts.port !== void 0 && !template.customPort) throw new KvboxError(`--port is for a Node server; the ${template.label} template serves port ${template.port}`);
|
|
4099
|
-
|
|
4108
|
+
if (opts.port !== void 0 && !template.customPort) throw new KvboxError(`--port is for a Next.js app or a Node server; the ${template.label} template serves port ${template.port}`);
|
|
4109
|
+
let port = opts.port ?? (template.customPort ? saved?.port : void 0);
|
|
4110
|
+
if (template.customPort && port === void 0 && fresh && ask) {
|
|
4111
|
+
const answer = await text("Port", { default: String(template.port), validate: (a) => portProblem(a) ? "expected a port, 1-65535" : void 0 });
|
|
4112
|
+
port = Number(answer);
|
|
4113
|
+
}
|
|
4100
4114
|
const org = orgFlag ?? saved?.org;
|
|
4101
4115
|
const config = {
|
|
4102
4116
|
template: template.id,
|