@tonbo/cli 0.10.1 → 0.11.0
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/bin/tonbo.js +33 -5
- package/package.json +1 -1
package/dist/bin/tonbo.js
CHANGED
|
@@ -3592,6 +3592,7 @@ function machineFields(machine, billing, etag = null, lastEnd = null) {
|
|
|
3592
3592
|
["Env", Object.keys(machine.env).sort().join(", ") || "none"],
|
|
3593
3593
|
["Stop grace", `${machine.stop_grace_seconds} s`],
|
|
3594
3594
|
["Volume", volumeText(machine)],
|
|
3595
|
+
...deleteFields(machine),
|
|
3595
3596
|
["Database", `${machine.database.name} (${machine.database.url})`],
|
|
3596
3597
|
["Logs", machine.logs.url],
|
|
3597
3598
|
["Durability", DURABILITY_LINK],
|
|
@@ -3602,6 +3603,17 @@ function machineFields(machine, billing, etag = null, lastEnd = null) {
|
|
|
3602
3603
|
["Updated", machine.updated_at]
|
|
3603
3604
|
]);
|
|
3604
3605
|
}
|
|
3606
|
+
function deleteFields(machine) {
|
|
3607
|
+
const seconds = machine.delete_after_seconds;
|
|
3608
|
+
if (seconds === void 0 || seconds === null) return [];
|
|
3609
|
+
const at = machine.status.delete_at;
|
|
3610
|
+
return [
|
|
3611
|
+
[
|
|
3612
|
+
"Deletes",
|
|
3613
|
+
at ? `at ${at}, after ${seconds} s asleep` : `${seconds} s after this activation ends`
|
|
3614
|
+
]
|
|
3615
|
+
];
|
|
3616
|
+
}
|
|
3605
3617
|
function volumeText(machine) {
|
|
3606
3618
|
const binding = machine.volumes?.[0];
|
|
3607
3619
|
return binding ? `${binding.volume} at ${binding.path}` : "none";
|
|
@@ -3702,6 +3714,10 @@ async function waitForMachine(deps, key, name, firstWait, every, timeout, settle
|
|
|
3702
3714
|
wait = every;
|
|
3703
3715
|
}
|
|
3704
3716
|
}
|
|
3717
|
+
function deleteAfterSeconds(option) {
|
|
3718
|
+
if (typeof option === "number") return option;
|
|
3719
|
+
return option === false ? null : void 0;
|
|
3720
|
+
}
|
|
3705
3721
|
async function machineListCommand(deps, options = {}) {
|
|
3706
3722
|
await machineCommand(async () => {
|
|
3707
3723
|
const page = await deps.api.listMachines(await deps.auth.apiKey(), {
|
|
@@ -3852,7 +3868,8 @@ async function machineCreateCommand(deps, name, command, options = {}) {
|
|
|
3852
3868
|
sleep_after_seconds: options.sleepAfter,
|
|
3853
3869
|
idle_action: options.idleAction,
|
|
3854
3870
|
stop_grace_seconds: options.stopGrace,
|
|
3855
|
-
...bound ? { volumes: [bound.binding] } : {}
|
|
3871
|
+
...bound ? { volumes: [bound.binding] } : {},
|
|
3872
|
+
delete_after_seconds: deleteAfterSeconds(options.deleteAfter)
|
|
3856
3873
|
},
|
|
3857
3874
|
options.idempotencyKey ?? randomUUID4()
|
|
3858
3875
|
);
|
|
@@ -3942,6 +3959,10 @@ function appliesText(name, change) {
|
|
|
3942
3959
|
const lines = [];
|
|
3943
3960
|
if (change.ports !== void 0 || change.sleep_after_seconds !== void 0)
|
|
3944
3961
|
lines.push("Ports and sleep-after apply now.");
|
|
3962
|
+
if (change.delete_after_seconds !== void 0)
|
|
3963
|
+
lines.push(
|
|
3964
|
+
change.delete_after_seconds === null ? "The Machine is no longer deleted for being asleep." : "Delete-after applies now; `tonbo machine show` says when."
|
|
3965
|
+
);
|
|
3945
3966
|
const later = [change.image, change.command, change.shape, change.env, change.volumes].some(
|
|
3946
3967
|
(field) => field !== void 0
|
|
3947
3968
|
);
|
|
@@ -3974,7 +3995,8 @@ async function machineUpdateCommand(deps, name, command, options = {}) {
|
|
|
3974
3995
|
command: options.imageCommand ? null : command.length ? command : void 0,
|
|
3975
3996
|
sleep_after_seconds: options.sleepAfter,
|
|
3976
3997
|
idle_action: options.idleAction,
|
|
3977
|
-
stop_grace_seconds: options.stopGrace
|
|
3998
|
+
stop_grace_seconds: options.stopGrace,
|
|
3999
|
+
delete_after_seconds: deleteAfterSeconds(options.deleteAfter)
|
|
3978
4000
|
};
|
|
3979
4001
|
if (options.clearPorts) change.ports = [];
|
|
3980
4002
|
else if (options.port?.length) {
|
|
@@ -4471,7 +4493,8 @@ var COMMAND_HELP = {
|
|
|
4471
4493
|
"--default-port": "the first --port",
|
|
4472
4494
|
"--region": "the --volume's region, else the account's default region",
|
|
4473
4495
|
"--idempotency-key": "a new UUID",
|
|
4474
|
-
"--timeout": String(DEFAULT_WAIT_SECONDS)
|
|
4496
|
+
"--timeout": String(DEFAULT_WAIT_SECONDS),
|
|
4497
|
+
"--delete-after": "never"
|
|
4475
4498
|
}
|
|
4476
4499
|
},
|
|
4477
4500
|
"tonbo machine show": {
|
|
@@ -4485,7 +4508,8 @@ var COMMAND_HELP = {
|
|
|
4485
4508
|
"tonbo machine update": {
|
|
4486
4509
|
about: [
|
|
4487
4510
|
"Changes only what its options name. It reads the Machine and sends the ETag it read, or `--if-match`'s, so a change someone made in between is refused with `precondition_failed` rather than overwritten; a Machine whose creation failed is refused with `machine_failed`. `--env` and `--unset-env` change single variables; `--port` replaces every port, and the current default port stays the default while it is still listed.",
|
|
4488
|
-
"Ports and `--sleep-after` apply at once. The image, command, shape and env apply at the next boot, and the command says how to apply them now: `tonbo machine sleep`, after which the next request boots the new spec. Naming the same tag again resolves its digest again."
|
|
4511
|
+
"Ports and `--sleep-after` apply at once. The image, command, shape and env apply at the next boot, and the command says how to apply them now: `tonbo machine sleep`, after which the next request boots the new spec. Naming the same tag again resolves its digest again.",
|
|
4512
|
+
"`--delete-after` applies at once and keeps the clock, which counts from the end of the Machine's last activation (or its creation), so a lower value can delete a Machine that has already slept that long; `--no-delete-after` turns it off. `tonbo machine show` prints when it will be deleted."
|
|
4489
4513
|
],
|
|
4490
4514
|
examples: ["tonbo machine update web --env MODE=staging --sleep-after 300"],
|
|
4491
4515
|
arguments: {
|
|
@@ -4739,6 +4763,10 @@ function machineSpecOptions(command, update) {
|
|
|
4739
4763
|
).option(
|
|
4740
4764
|
"--volume <name:path>",
|
|
4741
4765
|
`mount the Volume <name> (see tonbo volume list) at <path>; a Machine has at most one, of its own region${update ? "; applies at the next boot" : ""}`
|
|
4766
|
+
).option(
|
|
4767
|
+
"--delete-after <seconds>",
|
|
4768
|
+
`delete the Machine once it has been asleep, never woken or failed this long (3600 to 7776000)${update ? "; applies at once, from its last activation's end" : ""}`,
|
|
4769
|
+
parseWhole
|
|
4742
4770
|
);
|
|
4743
4771
|
}
|
|
4744
4772
|
function parseExpiresIn(value) {
|
|
@@ -5031,7 +5059,7 @@ function createProgram(dependencies = createDependencies) {
|
|
|
5031
5059
|
machineSpecOptions(
|
|
5032
5060
|
machine.command("update <name> [command...]").description(
|
|
5033
5061
|
"change a Machine; [command...] after -- replaces its command at the next boot"
|
|
5034
|
-
).option("--image <reference>", "a new image, named as for create; applies at the next boot").option("--image-command", "run the image's own CMD again at the next boot").option("--unset-env <KEY>", "remove an environment variable; repeat for several", repeated).option("--clear-ports", "remove every port").option("--if-match <etag>", ifMatchHelp("change")).option("--discard-snapshot", "apply a change that discards the Machine's snapshot").option("--no-volume", "remove the Machine's Volume at the next boot; the Volume is kept"),
|
|
5062
|
+
).option("--image <reference>", "a new image, named as for create; applies at the next boot").option("--image-command", "run the image's own CMD again at the next boot").option("--unset-env <KEY>", "remove an environment variable; repeat for several", repeated).option("--clear-ports", "remove every port").option("--if-match <etag>", ifMatchHelp("change")).option("--discard-snapshot", "apply a change that discards the Machine's snapshot").option("--no-volume", "remove the Machine's Volume at the next boot; the Volume is kept").option("--no-delete-after", "never delete the Machine for being asleep"),
|
|
5035
5063
|
true
|
|
5036
5064
|
),
|
|
5037
5065
|
"updateMachine"
|