withruntime 0.49.0 → 1.0.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/generated/apps.d.ts +309 -0
- package/dist/generated/apps.js +333 -0
- package/dist/generated/audit.d.ts +47 -0
- package/dist/generated/audit.js +14 -0
- package/dist/generated/browsers.d.ts +309 -0
- package/dist/generated/browsers.js +333 -0
- package/dist/generated/builds.d.ts +309 -0
- package/dist/generated/builds.js +333 -0
- package/dist/generated/ci.d.ts +309 -0
- package/dist/generated/ci.js +333 -0
- package/dist/generated/containers.d.ts +309 -0
- package/dist/generated/containers.js +333 -0
- package/dist/generated/desktops.d.ts +309 -0
- package/dist/generated/desktops.js +333 -0
- package/dist/generated/domains.d.ts +80 -0
- package/dist/generated/domains.js +58 -0
- package/dist/generated/egressIps.d.ts +36 -0
- package/dist/generated/egressIps.js +14 -0
- package/dist/generated/events.d.ts +37 -0
- package/dist/generated/events.js +14 -0
- package/dist/generated/feedback.d.ts +44 -0
- package/dist/generated/feedback.js +13 -0
- package/dist/generated/functions.d.ts +309 -0
- package/dist/generated/functions.js +333 -0
- package/dist/generated/identities.d.ts +36 -0
- package/dist/generated/identities.js +22 -0
- package/dist/generated/images.d.ts +200 -0
- package/dist/generated/images.js +65 -0
- package/dist/generated/index.d.ts +143 -0
- package/dist/generated/index.js +184 -0
- package/dist/generated/jobRuns.d.ts +68 -0
- package/dist/generated/jobRuns.js +22 -0
- package/dist/generated/jobs.d.ts +144 -0
- package/dist/generated/jobs.js +85 -0
- package/dist/generated/keys.d.ts +105 -0
- package/dist/generated/keys.js +26 -0
- package/dist/generated/me.d.ts +33 -0
- package/dist/generated/me.js +13 -0
- package/dist/generated/networks.d.ts +32 -0
- package/dist/generated/networks.js +14 -0
- package/dist/generated/notebooks.d.ts +309 -0
- package/dist/generated/notebooks.js +333 -0
- package/dist/generated/otel.d.ts +46 -0
- package/dist/generated/otel.js +22 -0
- package/dist/generated/ports.d.ts +55 -0
- package/dist/generated/ports.js +22 -0
- package/dist/generated/previews.d.ts +86 -0
- package/dist/generated/previews.js +67 -0
- package/dist/generated/projects.d.ts +47 -0
- package/dist/generated/projects.js +26 -0
- package/dist/generated/roles.d.ts +36 -0
- package/dist/generated/roles.js +22 -0
- package/dist/generated/routes.d.ts +3 -0
- package/dist/generated/routes.js +4 -0
- package/dist/generated/runtime.d.ts +176 -0
- package/dist/generated/runtime.js +416 -0
- package/dist/generated/sandboxes.d.ts +952 -0
- package/dist/generated/sandboxes.js +342 -0
- package/dist/generated/secrets.d.ts +116 -0
- package/dist/generated/secrets.js +54 -0
- package/dist/generated/sessions.d.ts +47 -0
- package/dist/generated/sessions.js +17 -0
- package/dist/generated/signing.d.ts +68 -0
- package/dist/generated/signing.js +187 -0
- package/dist/generated/sites.d.ts +309 -0
- package/dist/generated/sites.js +333 -0
- package/dist/generated/snapshots.d.ts +27 -0
- package/dist/generated/snapshots.js +22 -0
- package/dist/generated/tunnels.d.ts +68 -0
- package/dist/generated/tunnels.js +14 -0
- package/dist/generated/usage.d.ts +155 -0
- package/dist/generated/usage.js +17 -0
- package/dist/generated/volumes.d.ts +36 -0
- package/dist/generated/volumes.js +26 -0
- package/dist/generated/webhooks.d.ts +44 -0
- package/dist/generated/webhooks.js +22 -0
- package/dist/generated/workspaces.d.ts +309 -0
- package/dist/generated/workspaces.js +333 -0
- package/dist/v2/cli.d.ts +7 -0
- package/dist/v2/cli.js +283 -0
- package/dist/v2/index.d.ts +1 -0
- package/dist/v2/index.js +4 -0
- package/dist/v2/login.d.ts +35 -0
- package/dist/v2/login.js +225 -0
- package/dist/v2/mcp.d.ts +1 -0
- package/dist/v2/mcp.js +49 -0
- package/dist/v2/openapi.json +75750 -0
- package/dist/v2/shims/base.d.ts +33 -0
- package/dist/v2/shims/base.js +54 -0
- package/dist/v2/shims/blaxel.d.ts +60 -0
- package/dist/v2/shims/blaxel.js +71 -0
- package/dist/v2/shims/cloudflare.d.ts +52 -0
- package/dist/v2/shims/cloudflare.js +55 -0
- package/dist/v2/shims/daytona.d.ts +58 -0
- package/dist/v2/shims/daytona.js +74 -0
- package/dist/v2/shims/e2b.d.ts +142 -0
- package/dist/v2/shims/e2b.js +238 -0
- package/dist/v2/shims/fly.d.ts +6 -0
- package/dist/v2/shims/fly.js +91 -0
- package/dist/v2/shims/modal.d.ts +54 -0
- package/dist/v2/shims/modal.js +79 -0
- package/dist/v2/shims/morph.d.ts +60 -0
- package/dist/v2/shims/morph.js +87 -0
- package/dist/v2/shims/vercel.d.ts +53 -0
- package/dist/v2/shims/vercel.js +90 -0
- package/dist/v2/table.d.ts +53 -0
- package/dist/v2/table.js +122 -0
- package/package.json +20 -310
- package/BLAXEL.md +0 -290
- package/COMPATIBILITY.md +0 -447
- package/DAYTONA.md +0 -237
- package/E2B.md +0 -314
- package/README.md +0 -331
- package/README.src.md +0 -333
- package/VERCEL.md +0 -230
- package/agent-platforms-inventory.json +0 -387
- package/compatibility-lock.json +0 -305
- package/dist/agents/browser.d.ts +0 -12
- package/dist/agents/browser.js +0 -12
- package/dist/agents/index.d.ts +0 -11
- package/dist/agents/index.js +0 -11
- package/dist/agents-cli.d.ts +0 -16
- package/dist/agents-cli.js +0 -1237
- package/dist/agents-deploy.d.ts +0 -196
- package/dist/agents-deploy.js +0 -872
- package/dist/agents-file.d.ts +0 -19
- package/dist/agents-file.js +0 -135
- package/dist/ai/index.d.ts +0 -49
- package/dist/ai/index.js +0 -31
- package/dist/ai-harness/index.d.ts +0 -194
- package/dist/ai-harness/index.js +0 -522
- package/dist/api-defaults.d.ts +0 -17
- package/dist/api-defaults.js +0 -22
- package/dist/apps/index.d.ts +0 -10
- package/dist/apps/index.js +0 -11
- package/dist/apps-cli.d.ts +0 -16
- package/dist/apps-cli.js +0 -1021
- package/dist/billing-cli.d.ts +0 -23
- package/dist/billing-cli.js +0 -264
- package/dist/blaxel/client.d.ts +0 -59
- package/dist/blaxel/client.js +0 -86
- package/dist/blaxel/context.d.ts +0 -59
- package/dist/blaxel/context.js +0 -162
- package/dist/blaxel/errors.d.ts +0 -130
- package/dist/blaxel/errors.js +0 -315
- package/dist/blaxel/filesystem.d.ts +0 -147
- package/dist/blaxel/filesystem.js +0 -585
- package/dist/blaxel/index.d.ts +0 -287
- package/dist/blaxel/index.js +0 -351
- package/dist/blaxel/interpreter.d.ts +0 -71
- package/dist/blaxel/interpreter.js +0 -256
- package/dist/blaxel/lookup.d.ts +0 -39
- package/dist/blaxel/lookup.js +0 -84
- package/dist/blaxel/pagination.d.ts +0 -39
- package/dist/blaxel/pagination.js +0 -88
- package/dist/blaxel/preview.d.ts +0 -136
- package/dist/blaxel/preview.js +0 -304
- package/dist/blaxel/process.d.ts +0 -126
- package/dist/blaxel/process.js +0 -581
- package/dist/blaxel/sandbox.d.ts +0 -198
- package/dist/blaxel/sandbox.js +0 -856
- package/dist/blaxel/session.d.ts +0 -31
- package/dist/blaxel/session.js +0 -136
- package/dist/blaxel/snapshot.d.ts +0 -123
- package/dist/blaxel/snapshot.js +0 -199
- package/dist/blaxel/types.d.ts +0 -145
- package/dist/blaxel/types.js +0 -60
- package/dist/blaxel/unsupported.d.ts +0 -20
- package/dist/blaxel/unsupported.js +0 -32
- package/dist/browser-stub.d.ts +0 -1
- package/dist/browser-stub.js +0 -1
- package/dist/browsers/index.d.ts +0 -9
- package/dist/browsers/index.js +0 -10
- package/dist/browsers-cli.d.ts +0 -13
- package/dist/browsers-cli.js +0 -279
- package/dist/builds/index.d.ts +0 -10
- package/dist/builds/index.js +0 -11
- package/dist/ci/index.d.ts +0 -13
- package/dist/ci/index.js +0 -14
- package/dist/ci-cli.d.ts +0 -20
- package/dist/ci-cli.js +0 -537
- package/dist/ci-import.d.ts +0 -23
- package/dist/ci-import.js +0 -565
- package/dist/claude-agent-sdk/index.d.ts +0 -7
- package/dist/claude-agent-sdk/index.js +0 -65
- package/dist/cli/logs.d.ts +0 -21
- package/dist/cli/logs.js +0 -188
- package/dist/cli-extras.d.ts +0 -39
- package/dist/cli-extras.js +0 -267
- package/dist/cli-name.d.ts +0 -6
- package/dist/cli-name.js +0 -8
- package/dist/cli-update.d.ts +0 -11
- package/dist/cli-update.js +0 -46
- package/dist/cli-words.d.ts +0 -36
- package/dist/cli-words.js +0 -167
- package/dist/cli.d.ts +0 -92
- package/dist/cli.js +0 -5463
- package/dist/client.d.ts +0 -189
- package/dist/client.js +0 -205
- package/dist/cloudflare/errors.d.ts +0 -166
- package/dist/cloudflare/errors.js +0 -183
- package/dist/cloudflare/identity.d.ts +0 -7
- package/dist/cloudflare/identity.js +0 -13
- package/dist/cloudflare/index.d.ts +0 -545
- package/dist/cloudflare/index.js +0 -1106
- package/dist/cloudflare/interpreter.d.ts +0 -119
- package/dist/cloudflare/interpreter.js +0 -232
- package/dist/cloudflare/mime.d.ts +0 -1
- package/dist/cloudflare/mime.js +0 -66
- package/dist/cloudflare/streams.d.ts +0 -46
- package/dist/cloudflare/streams.js +0 -175
- package/dist/cloudflare/types.d.ts +0 -338
- package/dist/cloudflare/types.js +0 -80
- package/dist/cloudflare/watch.d.ts +0 -9
- package/dist/cloudflare/watch.js +0 -24
- package/dist/cloudflare/worker.d.ts +0 -706
- package/dist/cloudflare/worker.js +0 -633
- package/dist/codesandbox/guest-service.d.ts +0 -31
- package/dist/codesandbox/guest-service.js +0 -490
- package/dist/codesandbox/index.d.ts +0 -574
- package/dist/codesandbox/index.js +0 -1747
- package/dist/compat/core.d.ts +0 -58
- package/dist/compat/core.js +0 -267
- package/dist/compat/files.d.ts +0 -27
- package/dist/compat/files.js +0 -157
- package/dist/compat/lease.d.ts +0 -37
- package/dist/compat/lease.js +0 -93
- package/dist/compat/shell.d.ts +0 -4
- package/dist/compat/shell.js +0 -165
- package/dist/containers/index.d.ts +0 -10
- package/dist/containers/index.js +0 -11
- package/dist/credentials.d.ts +0 -71
- package/dist/credentials.js +0 -340
- package/dist/daytona/client.d.ts +0 -48
- package/dist/daytona/client.js +0 -45
- package/dist/daytona/computer-use.d.ts +0 -171
- package/dist/daytona/computer-use.js +0 -382
- package/dist/daytona/context.d.ts +0 -41
- package/dist/daytona/context.js +0 -50
- package/dist/daytona/daytona.d.ts +0 -213
- package/dist/daytona/daytona.js +0 -578
- package/dist/daytona/errors.d.ts +0 -117
- package/dist/daytona/errors.js +0 -201
- package/dist/daytona/filesystem.d.ts +0 -99
- package/dist/daytona/filesystem.js +0 -300
- package/dist/daytona/git.d.ts +0 -33
- package/dist/daytona/git.js +0 -128
- package/dist/daytona/image.d.ts +0 -49
- package/dist/daytona/image.js +0 -146
- package/dist/daytona/index.d.ts +0 -87
- package/dist/daytona/index.js +0 -102
- package/dist/daytona/process.d.ts +0 -143
- package/dist/daytona/process.js +0 -565
- package/dist/daytona/sandbox.d.ts +0 -222
- package/dist/daytona/sandbox.js +0 -505
- package/dist/desktops/index.d.ts +0 -9
- package/dist/desktops/index.js +0 -10
- package/dist/domains/index.d.ts +0 -9
- package/dist/domains/index.js +0 -10
- package/dist/e2b/client.d.ts +0 -76
- package/dist/e2b/client.js +0 -124
- package/dist/e2b/code-interpreter.d.ts +0 -134
- package/dist/e2b/code-interpreter.js +0 -239
- package/dist/e2b/commands.d.ts +0 -135
- package/dist/e2b/commands.js +0 -452
- package/dist/e2b/errors.d.ts +0 -125
- package/dist/e2b/errors.js +0 -247
- package/dist/e2b/filesystem.d.ts +0 -111
- package/dist/e2b/filesystem.js +0 -374
- package/dist/e2b/index.d.ts +0 -35
- package/dist/e2b/index.js +0 -69
- package/dist/e2b/pty.d.ts +0 -24
- package/dist/e2b/pty.js +0 -83
- package/dist/e2b/sandbox.d.ts +0 -248
- package/dist/e2b/sandbox.js +0 -781
- package/dist/e2b/unsupported.d.ts +0 -38
- package/dist/e2b/unsupported.js +0 -48
- package/dist/e2b/users.d.ts +0 -39
- package/dist/e2b/users.js +0 -207
- package/dist/errors.d.ts +0 -100
- package/dist/errors.js +0 -198
- package/dist/file-source.d.ts +0 -16
- package/dist/file-source.js +0 -162
- package/dist/fly/index.d.ts +0 -102
- package/dist/fly/index.js +0 -930
- package/dist/freestyle/index.d.ts +0 -629
- package/dist/freestyle/index.js +0 -1187
- package/dist/functions/index.d.ts +0 -10
- package/dist/functions/index.js +0 -11
- package/dist/identity.d.ts +0 -30
- package/dist/identity.js +0 -141
- package/dist/image-context.d.ts +0 -39
- package/dist/image-context.js +0 -176
- package/dist/images/index.d.ts +0 -9
- package/dist/images/index.js +0 -10
- package/dist/index.d.ts +0 -87
- package/dist/index.js +0 -51
- package/dist/inngest/index.d.ts +0 -96
- package/dist/inngest/index.js +0 -183
- package/dist/ips/index.d.ts +0 -9
- package/dist/ips/index.js +0 -10
- package/dist/jobs/index.d.ts +0 -9
- package/dist/jobs/index.js +0 -10
- package/dist/jobs-code/cron.d.ts +0 -12
- package/dist/jobs-code/cron.js +0 -93
- package/dist/jobs-code/registry.d.ts +0 -31
- package/dist/jobs-code/registry.js +0 -30
- package/dist/jobs-code/runner.d.ts +0 -1
- package/dist/jobs-code/runner.js +0 -74
- package/dist/jobs-deploy.d.ts +0 -22
- package/dist/jobs-deploy.js +0 -247
- package/dist/jobs-import.d.ts +0 -15
- package/dist/jobs-import.js +0 -231
- package/dist/keys.d.ts +0 -55
- package/dist/keys.js +0 -211
- package/dist/login.d.ts +0 -88
- package/dist/login.js +0 -369
- package/dist/machine.d.ts +0 -222
- package/dist/machine.js +0 -578
- package/dist/mcp.d.ts +0 -16
- package/dist/mcp.js +0 -377
- package/dist/modal/index.d.ts +0 -532
- package/dist/modal/index.js +0 -1284
- package/dist/morph/index.d.ts +0 -255
- package/dist/morph/index.js +0 -641
- package/dist/network-cli.d.ts +0 -17
- package/dist/network-cli.js +0 -523
- package/dist/networks/index.d.ts +0 -11
- package/dist/networks/index.js +0 -10
- package/dist/openai-agents/index.d.ts +0 -132
- package/dist/openai-agents/index.js +0 -738
- package/dist/page.d.ts +0 -13
- package/dist/page.js +0 -39
- package/dist/ports/index.d.ts +0 -9
- package/dist/ports/index.js +0 -10
- package/dist/product-names.d.ts +0 -52
- package/dist/product-names.js +0 -174
- package/dist/product-renames.d.ts +0 -103
- package/dist/product-renames.js +0 -189
- package/dist/products/agents.d.ts +0 -935
- package/dist/products/agents.js +0 -581
- package/dist/products/api-keys.d.ts +0 -113
- package/dist/products/api-keys.js +0 -32
- package/dist/products/apps.d.ts +0 -409
- package/dist/products/apps.js +0 -231
- package/dist/products/audit.d.ts +0 -51
- package/dist/products/audit.js +0 -10
- package/dist/products/balancers.d.ts +0 -87
- package/dist/products/balancers.js +0 -8
- package/dist/products/billing.d.ts +0 -76
- package/dist/products/billing.js +0 -26
- package/dist/products/browser.d.ts +0 -73
- package/dist/products/browser.js +0 -29
- package/dist/products/browsers.d.ts +0 -184
- package/dist/products/browsers.js +0 -180
- package/dist/products/builds.d.ts +0 -175
- package/dist/products/builds.js +0 -234
- package/dist/products/ci.d.ts +0 -406
- package/dist/products/ci.js +0 -133
- package/dist/products/containers.d.ts +0 -71
- package/dist/products/containers.js +0 -6
- package/dist/products/desktop.d.ts +0 -141
- package/dist/products/desktop.js +0 -83
- package/dist/products/desktops.d.ts +0 -71
- package/dist/products/desktops.js +0 -27
- package/dist/products/functions.d.ts +0 -2
- package/dist/products/functions.js +0 -5
- package/dist/products/images.d.ts +0 -229
- package/dist/products/images.js +0 -235
- package/dist/products/index.d.ts +0 -84
- package/dist/products/index.js +0 -105
- package/dist/products/interpreter.d.ts +0 -97
- package/dist/products/interpreter.js +0 -106
- package/dist/products/jobs.d.ts +0 -408
- package/dist/products/jobs.js +0 -256
- package/dist/products/limits.d.ts +0 -61
- package/dist/products/limits.js +0 -10
- package/dist/products/logs.d.ts +0 -245
- package/dist/products/logs.js +0 -274
- package/dist/products/mcp.d.ts +0 -88
- package/dist/products/mcp.js +0 -58
- package/dist/products/mounts.d.ts +0 -49
- package/dist/products/mounts.js +0 -21
- package/dist/products/network-products.d.ts +0 -268
- package/dist/products/network-products.js +0 -127
- package/dist/products/network.d.ts +0 -62
- package/dist/products/network.js +0 -19
- package/dist/products/observability.d.ts +0 -264
- package/dist/products/observability.js +0 -123
- package/dist/products/plans.d.ts +0 -133
- package/dist/products/plans.js +0 -24
- package/dist/products/previews.d.ts +0 -70
- package/dist/products/previews.js +0 -39
- package/dist/products/private-network.d.ts +0 -22
- package/dist/products/private-network.js +0 -10
- package/dist/products/queues.d.ts +0 -149
- package/dist/products/queues.js +0 -213
- package/dist/products/referrals.d.ts +0 -50
- package/dist/products/referrals.js +0 -8
- package/dist/products/reservations.d.ts +0 -108
- package/dist/products/reservations.js +0 -41
- package/dist/products/resources.d.ts +0 -55
- package/dist/products/resources.js +0 -122
- package/dist/products/secrets.d.ts +0 -316
- package/dist/products/secrets.js +0 -333
- package/dist/products/signed-requests.d.ts +0 -21
- package/dist/products/signed-requests.js +0 -11
- package/dist/products/sso.d.ts +0 -44
- package/dist/products/sso.js +0 -8
- package/dist/products/streams.d.ts +0 -73
- package/dist/products/streams.js +0 -17
- package/dist/products/switching.d.ts +0 -123
- package/dist/products/switching.js +0 -26
- package/dist/products/tailscale.d.ts +0 -57
- package/dist/products/tailscale.js +0 -17
- package/dist/products/uptime.d.ts +0 -97
- package/dist/products/uptime.js +0 -42
- package/dist/products/volumes.d.ts +0 -190
- package/dist/products/volumes.js +0 -114
- package/dist/products/watch.d.ts +0 -112
- package/dist/products/watch.js +0 -249
- package/dist/proxy.d.ts +0 -30
- package/dist/proxy.js +0 -200
- package/dist/record-cli.d.ts +0 -23
- package/dist/record-cli.js +0 -308
- package/dist/renamed-products.d.ts +0 -38
- package/dist/renamed-products.js +0 -34
- package/dist/resumable.d.ts +0 -32
- package/dist/resumable.js +0 -201
- package/dist/runloop/index.d.ts +0 -333
- package/dist/runloop/index.js +0 -560
- package/dist/runloop/pagination.d.ts +0 -46
- package/dist/runloop/pagination.js +0 -82
- package/dist/runloop/sdk.d.ts +0 -131
- package/dist/runloop/sdk.js +0 -167
- package/dist/runloop/snapshots.d.ts +0 -52
- package/dist/runloop/snapshots.js +0 -244
- package/dist/sandbox.d.ts +0 -371
- package/dist/sandbox.js +0 -1500
- package/dist/sandboxes/index.d.ts +0 -11
- package/dist/sandboxes/index.js +0 -12
- package/dist/sealing.d.ts +0 -6
- package/dist/sealing.js +0 -14
- package/dist/snapshots/index.d.ts +0 -9
- package/dist/snapshots/index.js +0 -11
- package/dist/snapshots.d.ts +0 -82
- package/dist/snapshots.js +0 -65
- package/dist/sprites/index.d.ts +0 -563
- package/dist/sprites/index.js +0 -1370
- package/dist/ssh.d.ts +0 -56
- package/dist/ssh.js +0 -416
- package/dist/switched-off.d.ts +0 -5
- package/dist/switched-off.js +0 -8
- package/dist/tar.d.ts +0 -15
- package/dist/tar.js +0 -526
- package/dist/terminal.d.ts +0 -24
- package/dist/terminal.js +0 -32
- package/dist/tools/index.d.ts +0 -62
- package/dist/tools/index.js +0 -181
- package/dist/transport.d.ts +0 -165
- package/dist/transport.js +0 -883
- package/dist/trigger/index.d.ts +0 -202
- package/dist/trigger/index.js +0 -244
- package/dist/tunnel.d.ts +0 -70
- package/dist/tunnel.js +0 -316
- package/dist/types.d.ts +0 -574
- package/dist/types.js +0 -1
- package/dist/vercel/client.d.ts +0 -40
- package/dist/vercel/client.js +0 -39
- package/dist/vercel/command.d.ts +0 -117
- package/dist/vercel/command.js +0 -391
- package/dist/vercel/errors.d.ts +0 -53
- package/dist/vercel/errors.js +0 -131
- package/dist/vercel/filesystem.d.ts +0 -153
- package/dist/vercel/filesystem.js +0 -297
- package/dist/vercel/index.d.ts +0 -24
- package/dist/vercel/index.js +0 -36
- package/dist/vercel/sandbox-user.d.ts +0 -70
- package/dist/vercel/sandbox-user.js +0 -207
- package/dist/vercel/sandbox.d.ts +0 -372
- package/dist/vercel/sandbox.js +0 -1037
- package/dist/vercel/snapshot.d.ts +0 -94
- package/dist/vercel/snapshot.js +0 -137
- package/dist/volumes/index.d.ts +0 -9
- package/dist/volumes/index.js +0 -10
- package/dist/wait.d.ts +0 -12
- package/dist/wait.js +0 -47
- package/dist/wallet.d.ts +0 -45
- package/dist/wallet.js +0 -56
- package/dist/wireguard.d.ts +0 -7
- package/dist/wireguard.js +0 -13
package/dist/apps-cli.js
DELETED
|
@@ -1,1021 +0,0 @@
|
|
|
1
|
-
import { me, named } from "./cli-name.js";
|
|
2
|
-
import { RuntimeError } from "./errors.js";
|
|
3
|
-
import { logStream } from "./terminal.js";
|
|
4
|
-
import { apps, functions, } from "./products/apps.js";
|
|
5
|
-
import { builds, } from "./products/builds.js";
|
|
6
|
-
import { containers, } from "./products/containers.js";
|
|
7
|
-
export const APP_HELP = `runtime apps <command>
|
|
8
|
-
|
|
9
|
-
An App serves your web server from an image or a build. Copies start when
|
|
10
|
-
requests come and stop when they end, between --min-copies and --max-copies.
|
|
11
|
-
In a private beta: outside it, each command says how to ask to join.
|
|
12
|
-
|
|
13
|
-
create [<name>] --vcpu <1-16> --memory <128-65536> --max-copies <1-plan limit>
|
|
14
|
-
[--min-copies 0] [--concurrency 100] [--spares 2] [--port 8080]
|
|
15
|
-
[--health-path /healthz] [--health-fail 60] [--stop-grace 30] [--cdn on|off]
|
|
16
|
-
[--release at-once|staged] [--soak 300] [--volume <volumeId>:<path>] [--label key=value]...
|
|
17
|
-
Make an App, waiting for its first deploy; prints its id.
|
|
18
|
-
--health-fail: seconds a live copy may fail its health
|
|
19
|
-
check before it is replaced. --stop-grace: seconds a
|
|
20
|
-
stopped copy has after SIGTERM. --release staged: a new
|
|
21
|
-
version goes live on one copy, then about 10%, 50% and
|
|
22
|
-
all of them, each stage running --soak seconds (60 to
|
|
23
|
-
3600) and judged on its visitors' errors and speed
|
|
24
|
-
before the next; a stage that does worse goes back and
|
|
25
|
-
the deploy fails, the live version never stopping.
|
|
26
|
-
--volume mounts one
|
|
27
|
-
volume of yours at a path under /data, /mnt, /state,
|
|
28
|
-
/storage or /volumes, in the App's one copy: it needs
|
|
29
|
-
--max-copies 1 (--min-copies is then 1, --spares 0), and
|
|
30
|
-
each deploy stops the old copy before the new one boots
|
|
31
|
-
ls [--all] Your Apps: state, live version, copies; --all, deleted too
|
|
32
|
-
get <app> One App, in full (an id or its name)
|
|
33
|
-
update <app> [--name <name>] [--vcpu n] [--memory n] [--min-copies n] [--max-copies n]
|
|
34
|
-
[--concurrency n] [--spares n] [--port n] [--health-path /path] [--health-fail n]
|
|
35
|
-
[--stop-grace n] [--volume <volumeId>:<path> | none] [--cdn on|off]
|
|
36
|
-
[--release at-once|staged] [--soak n] [--label key=value]...
|
|
37
|
-
Change its settings; --volume none takes the volume
|
|
38
|
-
away, only before its first deploy;
|
|
39
|
-
--cdn off sends visitors straight to Runtime's routers,
|
|
40
|
-
with nothing cached (on: Cloudflare's CDN in front)
|
|
41
|
-
rm <app> Delete it and stop its copies
|
|
42
|
-
deploy <app> (--image <image> | --build <buildId>) [--env KEY=VALUE]... [--keep-env]
|
|
43
|
-
[--port 8080] [--health-path /healthz] [--no-wait]
|
|
44
|
-
A new version. Waits until it is live, or says why it
|
|
45
|
-
failed; --no-wait prints the deploy's id at once.
|
|
46
|
-
--image: an image of yours (id, name, name:tag);
|
|
47
|
-
--build: a build that succeeded (runtime builds).
|
|
48
|
-
--env KEY alone sends KEY's value from your environment.
|
|
49
|
-
--keep-env keeps the last deploy's environment, sealed
|
|
50
|
-
deploys <app> [<deployId>] [--wait] Each version's deploy: state and address; with an id,
|
|
51
|
-
that one (--wait: until it ends)
|
|
52
|
-
versions <app> Its versions; the live and previous ones keep saved copies
|
|
53
|
-
copies <app> Its copies now: version, region, state
|
|
54
|
-
logs <app> [--follow] [--since 1h] [--version n] [--copy <copyId>] [--stream stdout|stderr]
|
|
55
|
-
[--limit 100] [--raw] What its copies printed: the newest lines since --since
|
|
56
|
-
(a time, or 30s, 15m, 2h, 7d; kept 14 days), or with
|
|
57
|
-
--follow every line as it comes, until Ctrl-C. On a
|
|
58
|
-
terminal control characters show as \\uXXXX unless --raw
|
|
59
|
-
exec <app> [--copy <id>] [--root] [--cwd <dir>] [--env K=V]... [--timeout <ms>] [--trace-files <file.json>] -- <command>
|
|
60
|
-
Run a command in its live copy
|
|
61
|
-
cp <file> <app>:/<path> [--copy <id>] Copy a file onto its live copy
|
|
62
|
-
cp <app>:/<path> <file> [--copy <id>] Copy a file off it
|
|
63
|
-
exec and cp go to a serving copy of the live version unless --copy names
|
|
64
|
-
one. A copy holds the App's secrets, so only an owner's or admin's key
|
|
65
|
-
reaches into one. A file written to a copy lasts as long as that copy; a
|
|
66
|
-
deploy replaces its copies.
|
|
67
|
-
rollback <app> [--no-wait] Put the previous version live again
|
|
68
|
-
restart <app> [--no-wait] Start the live version afresh, as a deploy of its own;
|
|
69
|
-
with a volume, the old copy stops first and the
|
|
70
|
-
downtime is said
|
|
71
|
-
|
|
72
|
-
Examples
|
|
73
|
-
runtime apps create web --vcpu 1 --memory 512 --max-copies 3
|
|
74
|
-
runtime apps deploy web --image web:latest --env NODE_ENV=production
|
|
75
|
-
runtime apps logs web --follow
|
|
76
|
-
runtime apps rollback web
|
|
77
|
-
runtime apps create db --vcpu 1 --memory 1024 --max-copies 1 --volume <volumeId>:/data
|
|
78
|
-
`;
|
|
79
|
-
export const FUNCTION_HELP = `runtime functions <command>
|
|
80
|
-
|
|
81
|
-
A Function serves your HTTP handler from an image or a build, at its own
|
|
82
|
-
address. Copies start when calls come, up to --max-copies, and sleep when
|
|
83
|
-
they stop: an idle Function has no copy awake.
|
|
84
|
-
In a private beta: outside it, each command says how to ask to join.
|
|
85
|
-
|
|
86
|
-
create [<name>] --vcpu <1-16> --memory <128-65536> --max-copies <1-plan limit>
|
|
87
|
-
[--concurrency 100] [--spares 2] [--port 8080]
|
|
88
|
-
[--health-path /healthz] [--health-fail 60] [--label key=value]...
|
|
89
|
-
Make a Function, waiting for its first deploy; prints its id.
|
|
90
|
-
--health-fail: seconds a live copy may fail its health
|
|
91
|
-
check before it is replaced
|
|
92
|
-
ls [--all] Your Functions: state, live version, copies; --all, deleted too
|
|
93
|
-
get <function> One Function, in full (an id or its name)
|
|
94
|
-
update <function> [--name <name>] [--vcpu n] [--memory n] [--max-copies n]
|
|
95
|
-
[--concurrency n] [--spares n] [--port n] [--health-path /path] [--health-fail n]
|
|
96
|
-
[--label key=value]...
|
|
97
|
-
Change its settings
|
|
98
|
-
rm <function> Delete it and stop its copies
|
|
99
|
-
deploy <function> (--image <image> | --build <buildId>) [--env KEY=VALUE]... [--keep-env]
|
|
100
|
-
[--port 8080] [--health-path /healthz] [--no-wait]
|
|
101
|
-
A new version. Waits until it is live, or says why it
|
|
102
|
-
failed; --no-wait prints the deploy's id at once.
|
|
103
|
-
--image: an image of yours (id, name, name:tag);
|
|
104
|
-
--build: a build that succeeded (runtime builds).
|
|
105
|
-
--env KEY alone sends KEY's value from your environment.
|
|
106
|
-
--keep-env keeps the last deploy's environment, sealed
|
|
107
|
-
deploys <function> [<deployId>] [--wait] Each version's deploy: state and address; with an id,
|
|
108
|
-
that one (--wait: until it ends)
|
|
109
|
-
versions <function> Its versions; the live and previous ones keep saved copies
|
|
110
|
-
copies <function> Its copies now: version, region, state
|
|
111
|
-
logs <function> [--follow] [--since 1h] [--version n] [--copy <copyId>] [--stream stdout|stderr]
|
|
112
|
-
[--limit 100] [--raw] What its copies printed: the newest lines since --since
|
|
113
|
-
(a time, or 30s, 15m, 2h, 7d; kept 14 days), or with
|
|
114
|
-
--follow every line as it comes, until Ctrl-C. On a
|
|
115
|
-
terminal control characters show as \\uXXXX unless --raw
|
|
116
|
-
rollback <function> [--no-wait] Put the previous version live again
|
|
117
|
-
restart <function> [--no-wait] Start the live version afresh, as a deploy of its own
|
|
118
|
-
|
|
119
|
-
Examples
|
|
120
|
-
runtime functions create resize --vcpu 1 --memory 512 --max-copies 10
|
|
121
|
-
runtime functions deploy resize --image resize:latest
|
|
122
|
-
runtime functions logs resize --follow
|
|
123
|
-
runtime functions rollback resize
|
|
124
|
-
`;
|
|
125
|
-
export const BUILD_HELP = `runtime builds <command>
|
|
126
|
-
|
|
127
|
-
A build turns a commit of a connected repository into a saved server an App
|
|
128
|
-
deploys. A push to the production branch builds and deploys by itself.
|
|
129
|
-
In a private beta: outside it, each command says how to ask to join.
|
|
130
|
-
|
|
131
|
-
repos connect <owner/name | https URL> --deploy <app name> [--branch main] [--no-previews]
|
|
132
|
-
[--root <folder>] [--install <command>] [--build <command>] [--start <command>]
|
|
133
|
-
[--port 8080] [--health-path /healthz] [--build-env KEY=VALUE]... [--name <name>]
|
|
134
|
-
Connect a repository; prints its id. --deploy takes an
|
|
135
|
-
App's name, or function:<name>. --start runs once the
|
|
136
|
-
build is done, with PORT set: the server the App deploys.
|
|
137
|
-
A command left out is the detected framework's (Next.js,
|
|
138
|
-
Vite, Remix, Astro, SvelteKit, Nuxt, Express, Hono,
|
|
139
|
-
FastAPI, Django, Flask, Rails, Go, Rust, a Dockerfile)
|
|
140
|
-
repos ls Connected repositories
|
|
141
|
-
repos change <repoId> [the options of connect but the repository]
|
|
142
|
-
Change its settings; its id and builds stay
|
|
143
|
-
repos disconnect <repoId> Stop building it; its builds stay
|
|
144
|
-
repos install A link to install Runtime's GitHub App, so a private
|
|
145
|
-
repository builds
|
|
146
|
-
create <repoId> [--ref main] [--branch <name>] [--name <name>]
|
|
147
|
-
Build a branch, tag or commit now; prints the build's id
|
|
148
|
-
run <repoId> [--ref main] [--branch <name>] [--name <name>] [--raw]
|
|
149
|
-
The same, then follows its log; exits 0 once it succeeds
|
|
150
|
-
ls [--repository <repoId>] [--commit <sha>] [--state <state>]...
|
|
151
|
-
Builds, oldest first; --commit: a full sha
|
|
152
|
-
get <buildId> One build: state, commit, framework, step times, what it
|
|
153
|
-
made
|
|
154
|
-
cancel <buildId> Stop a build that has not ended
|
|
155
|
-
logs <buildId> [--follow] [--raw] Its last 200 lines, or every line as it comes until it
|
|
156
|
-
ends; on a terminal control characters show as \\uXXXX
|
|
157
|
-
unless --raw
|
|
158
|
-
|
|
159
|
-
Examples
|
|
160
|
-
runtime builds repos connect acme/web --deploy web
|
|
161
|
-
runtime builds repos connect acme/api --deploy api --start "node dist/server.js"
|
|
162
|
-
runtime builds run <repoId> --ref main
|
|
163
|
-
runtime builds ls --commit $(git rev-parse HEAD)
|
|
164
|
-
`;
|
|
165
|
-
export const CONTAINER_HELP = `runtime containers <command>
|
|
166
|
-
|
|
167
|
-
A container runs one OCI image's process on its own microVM, billed at the
|
|
168
|
-
sandbox rates. It never sleeps unless --sleep; on exit it restarts when it
|
|
169
|
-
serves a port, else it stops (--on-exit sets either).
|
|
170
|
-
In a private beta: outside it, each command says how to ask to join.
|
|
171
|
-
|
|
172
|
-
create <image> --vcpu <1-16> --memory <128-65536> [--name <name>] [--label key=value]...
|
|
173
|
-
[--env KEY[=VALUE]]... [--entrypoint <program>] [--workdir /app] [--user <user>]
|
|
174
|
-
[--port <1-65535>] [--on-exit restart|stop] [--sleep] [-- <command...>]
|
|
175
|
-
Run it; prints its id. The image's digest is pinned.
|
|
176
|
-
--env KEY alone sends KEY's value from your environment.
|
|
177
|
-
--entrypoint drops the image's command; after --, the
|
|
178
|
-
command replaces the image's
|
|
179
|
-
ls [--all] [--state <state>]... [--label key=value]...
|
|
180
|
-
Your containers: all but deleting and deleted, unless
|
|
181
|
-
--all or --state
|
|
182
|
-
get <container> One container, in full (an id or its name): its
|
|
183
|
-
environment's names, never their values
|
|
184
|
-
update <container> [--name <name>] [--label key=value]...
|
|
185
|
-
Rename it or replace its labels
|
|
186
|
-
rm <container> [--wait] Delete it and stop its process; --wait: until deleted
|
|
187
|
-
|
|
188
|
-
Examples
|
|
189
|
-
runtime containers create nginx:1.27 --vcpu 1 --memory 512 --name web
|
|
190
|
-
runtime containers create python:3.12 --vcpu 1 --memory 1024 -- python3 -m http.server 8000
|
|
191
|
-
runtime containers rm web --wait
|
|
192
|
-
`;
|
|
193
|
-
const UUID = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
194
|
-
const when = (ms) => (ms == null ? "-" : new Date(ms).toISOString());
|
|
195
|
-
const ENDED = ["succeeded", "failed", "cancelled", "superseded"];
|
|
196
|
-
const seconds = (ms) => `${(ms / 1000).toFixed(1)} s`;
|
|
197
|
-
/** A stop-then-start's downtime, in a person's words. */
|
|
198
|
-
const downtime = (d) => d ? `down ${seconds(d.totalMs)} (stop ${seconds(d.stopMs)}, boot ${seconds(d.bootMs)})` : "-";
|
|
199
|
-
const APP = {
|
|
200
|
-
api: apps,
|
|
201
|
-
command: "apps",
|
|
202
|
-
one: "App",
|
|
203
|
-
many: "Apps",
|
|
204
|
-
help: APP_HELP,
|
|
205
|
-
minCopies: true,
|
|
206
|
-
example: "web --vcpu 1 --memory 512 --max-copies 2",
|
|
207
|
-
};
|
|
208
|
-
const FUNCTION = {
|
|
209
|
-
// The same calls under /v1/functions; the API answers minCopies 0.
|
|
210
|
-
api: functions,
|
|
211
|
-
command: "functions",
|
|
212
|
-
one: "Function",
|
|
213
|
-
many: "Functions",
|
|
214
|
-
help: FUNCTION_HELP,
|
|
215
|
-
minCopies: false,
|
|
216
|
-
example: "resize --vcpu 1 --memory 512 --max-copies 10",
|
|
217
|
-
};
|
|
218
|
-
/** An App's or Function's id from its id or its name: a name is looked up
|
|
219
|
-
* among those not deleted, and must be one's alone. */
|
|
220
|
-
async function appIdOf(api, target, kit, kind) {
|
|
221
|
-
if (UUID.test(target))
|
|
222
|
-
return target;
|
|
223
|
-
const found = (await api.list({ name: target, state: ["waiting", "live", "failed"] })).data;
|
|
224
|
-
if (found.length === 1)
|
|
225
|
-
return found[0].id;
|
|
226
|
-
throw kit.usage(found.length
|
|
227
|
-
? `${found.length} ${kind.many} are named ${target}; give one's id (${me} ${kind.command} ls).`
|
|
228
|
-
: `No ${kind.one} is named ${target}. Your ${kind.many}: ${me} ${kind.command} ls`);
|
|
229
|
-
}
|
|
230
|
-
/** `--cdn on` or `--cdn off`. */
|
|
231
|
-
function onOff(value, kit) {
|
|
232
|
-
if (value === "on")
|
|
233
|
-
return true;
|
|
234
|
-
if (value === "off")
|
|
235
|
-
return false;
|
|
236
|
-
throw kit.usage(`--cdn takes on or off, not ${value}.`);
|
|
237
|
-
}
|
|
238
|
-
/** --release at-once|staged and --soak <seconds>: how an App's new version
|
|
239
|
-
* goes live. */
|
|
240
|
-
function releases(args, kit) {
|
|
241
|
-
const given = kit.flag(args, "release");
|
|
242
|
-
const soak = kit.integer(args, "soak");
|
|
243
|
-
const stages = given?.replace("-", "_");
|
|
244
|
-
if (stages !== undefined && stages !== "at_once" && stages !== "staged")
|
|
245
|
-
throw kit.usage(`--release takes at-once or staged, not ${given}.`);
|
|
246
|
-
return {
|
|
247
|
-
...(stages === undefined ? {} : { releaseStages: stages }),
|
|
248
|
-
...(soak === undefined ? {} : { releaseSoakSeconds: soak }),
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
/** --volume <volumeId>:<path>, or none (an update's: no volume). */
|
|
252
|
-
function volume(args, kit) {
|
|
253
|
-
const given = kit.flag(args, "volume");
|
|
254
|
-
if (given === undefined)
|
|
255
|
-
return {};
|
|
256
|
-
if (given === "none")
|
|
257
|
-
return { volume: null };
|
|
258
|
-
const at = given.indexOf(":");
|
|
259
|
-
const volumeId = given.slice(0, at);
|
|
260
|
-
const path = given.slice(at + 1);
|
|
261
|
-
if (at < 0 || !UUID.test(volumeId) || !path.startsWith("/"))
|
|
262
|
-
throw kit.usage(`--volume takes a volume's id and where it mounts: --volume <volumeId>:/data (${me} volumes ls)`);
|
|
263
|
-
return { volume: { volumeId, path } };
|
|
264
|
-
}
|
|
265
|
-
/** The flags an App's settings are given with, as the API names them. A
|
|
266
|
-
* Function's leave out --min-copies, --stop-grace, --volume, --release and
|
|
267
|
-
* --soak, which its parse does not take. */
|
|
268
|
-
function settings(args, kit, kind) {
|
|
269
|
-
const { integer, flag } = kit;
|
|
270
|
-
const number = (name, field) => integer(args, name) === undefined ? {} : { [field]: integer(args, name) };
|
|
271
|
-
return {
|
|
272
|
-
...number("vcpu", "vcpu"),
|
|
273
|
-
...number("memory", "memoryMiB"),
|
|
274
|
-
...(kind.minCopies ? number("min-copies", "minCopies") : {}),
|
|
275
|
-
...number("max-copies", "maxCopies"),
|
|
276
|
-
...number("concurrency", "concurrency"),
|
|
277
|
-
...number("spares", "spares"),
|
|
278
|
-
...number("port", "port"),
|
|
279
|
-
...(flag(args, "health-path") === undefined ? {} : { healthPath: flag(args, "health-path") }),
|
|
280
|
-
...(flag(args, "cdn") === undefined ? {} : { cdn: onOff(flag(args, "cdn"), kit) }),
|
|
281
|
-
...number("health-fail", "healthFailSeconds"),
|
|
282
|
-
...(kind.minCopies
|
|
283
|
-
? {
|
|
284
|
-
...number("stop-grace", "stopGraceSeconds"),
|
|
285
|
-
...volume(args, kit),
|
|
286
|
-
...releases(args, kit),
|
|
287
|
-
}
|
|
288
|
-
: {}),
|
|
289
|
-
};
|
|
290
|
-
}
|
|
291
|
-
const SETTINGS = [
|
|
292
|
-
"vcpu",
|
|
293
|
-
"memory",
|
|
294
|
-
"min-copies",
|
|
295
|
-
"max-copies",
|
|
296
|
-
"concurrency",
|
|
297
|
-
"spares",
|
|
298
|
-
"port",
|
|
299
|
-
"health-path",
|
|
300
|
-
"cdn",
|
|
301
|
-
"health-fail",
|
|
302
|
-
"stop-grace",
|
|
303
|
-
"volume",
|
|
304
|
-
"release",
|
|
305
|
-
"soak",
|
|
306
|
-
"label",
|
|
307
|
-
];
|
|
308
|
-
const settingsOf = (kind) => kind.minCopies
|
|
309
|
-
? SETTINGS
|
|
310
|
-
: SETTINGS.filter((name) => !["min-copies", "stop-grace", "volume", "release", "soak"].includes(name));
|
|
311
|
-
/** A version's copies replaced while live: how many, and why. */
|
|
312
|
-
function replaced(list) {
|
|
313
|
-
if (!list?.length)
|
|
314
|
-
return "-";
|
|
315
|
-
const health = list.filter((r) => r.reason === "health").length;
|
|
316
|
-
const why = [
|
|
317
|
-
health ? `${health} health` : "",
|
|
318
|
-
list.length - health ? `${list.length - health} exited` : "",
|
|
319
|
-
];
|
|
320
|
-
return `${list.length} (${why.filter(Boolean).join(", ")})`;
|
|
321
|
-
}
|
|
322
|
-
/** A deploy that ended badly, said with its own words, hint and last output. */
|
|
323
|
-
function deployFailure(deploy) {
|
|
324
|
-
if (!deploy.error)
|
|
325
|
-
return undefined;
|
|
326
|
-
const last = deploy.error.lastOutput?.trim();
|
|
327
|
-
return new RuntimeError({
|
|
328
|
-
code: deploy.error.code,
|
|
329
|
-
status: 0,
|
|
330
|
-
message: `Version ${deploy.version} did not go live: ${deploy.error.message}${last ? `\nIts last output:\n${last}` : ""}`,
|
|
331
|
-
hint: deploy.error.hint,
|
|
332
|
-
details: { deploy },
|
|
333
|
-
});
|
|
334
|
-
}
|
|
335
|
-
export function appsCommand(argv, env, out, client, kit) {
|
|
336
|
-
return copiesCommand(APP, argv, env, out, client, kit);
|
|
337
|
-
}
|
|
338
|
-
export function functionsCommand(argv, env, out, client, kit) {
|
|
339
|
-
return copiesCommand(FUNCTION, argv, env, out, client, kit);
|
|
340
|
-
}
|
|
341
|
-
async function copiesCommand(kind, argv, env, out, client, kit) {
|
|
342
|
-
const { parse, flag, has, need, pairs, envPairs, table, usage } = kit;
|
|
343
|
-
const [verb, ...rest] = argv;
|
|
344
|
-
const print = (human, value) => out.write(out.json ? JSON.stringify(value) : human);
|
|
345
|
-
if (!verb || verb === "help" || verb === "--help") {
|
|
346
|
-
print(named(kind.help), { usage: named(kind.help) });
|
|
347
|
-
return 0;
|
|
348
|
-
}
|
|
349
|
-
const api = kind.api((await client()).transport);
|
|
350
|
-
const { command, one, many } = kind;
|
|
351
|
-
const idOf = (target) => appIdOf(api, need(target, `${one === "App" ? "an" : "a"} ${one}'s id or name`), kit, kind);
|
|
352
|
-
switch (verb) {
|
|
353
|
-
case "create": {
|
|
354
|
-
const args = parse(rest, [], settingsOf(kind));
|
|
355
|
-
if (args.positional.length > 1)
|
|
356
|
-
throw usage(`Give one name: ${me} ${command} create ${kind.example}`);
|
|
357
|
-
const given = settings(args, kit, kind);
|
|
358
|
-
if (given.volume === null)
|
|
359
|
-
throw usage(`--volume none is for update: leave --volume out to make an App without one.`);
|
|
360
|
-
for (const [option, field] of [
|
|
361
|
-
["vcpu", "vcpu"],
|
|
362
|
-
["memory", "memoryMiB"],
|
|
363
|
-
["max-copies", "maxCopies"],
|
|
364
|
-
])
|
|
365
|
-
if (given[field] === undefined)
|
|
366
|
-
throw usage(`Give --${option}: ${me} ${command} create ${args.positional[0]
|
|
367
|
-
? `${args.positional[0]} ${kind.example.replace(/^\S+ /, "")}`
|
|
368
|
-
: kind.example}`);
|
|
369
|
-
const input = {
|
|
370
|
-
...given,
|
|
371
|
-
...(args.positional[0] ? { name: args.positional[0] } : {}),
|
|
372
|
-
...(args.flags.has("label") ? { labels: pairs(args, "label") } : {}),
|
|
373
|
-
};
|
|
374
|
-
const app = await api.create(input);
|
|
375
|
-
if (!out.json)
|
|
376
|
-
out.error(`Created ${app.name ?? app.id}, waiting for its first version. Deploy one: ${me} ${command} deploy ${app.name ?? app.id} --image <image>`);
|
|
377
|
-
print(app.id, app);
|
|
378
|
-
return 0;
|
|
379
|
-
}
|
|
380
|
-
case "ls":
|
|
381
|
-
case "list": {
|
|
382
|
-
const args = parse(rest, ["all"], []);
|
|
383
|
-
const all = await (await api.list({
|
|
384
|
-
limit: 100,
|
|
385
|
-
...(has(args, "all")
|
|
386
|
-
? { state: ["waiting", "live", "failed", "deleting", "deleted"] }
|
|
387
|
-
: {}),
|
|
388
|
-
})).toArray(Infinity);
|
|
389
|
-
print(all.length
|
|
390
|
-
? table([
|
|
391
|
-
["ID", "NAME", "ADDRESS", "STATE", "LIVE", "COPIES", "SIZE", "CREATED"],
|
|
392
|
-
...all.map((a) => [
|
|
393
|
-
a.id,
|
|
394
|
-
a.name ?? "-",
|
|
395
|
-
a.url ?? "-",
|
|
396
|
-
// A copy waiting for room: its place in its region's line.
|
|
397
|
-
a.line ? `${a.state} (in line, place ${a.line.place})` : a.state,
|
|
398
|
-
a.liveVersion === null ? "-" : `v${a.liveVersion}`,
|
|
399
|
-
// A Function's copies all sleep when idle: up to its maximum.
|
|
400
|
-
kind.minCopies ? `${a.minCopies}-${a.maxCopies}` : `0-${a.maxCopies}`,
|
|
401
|
-
`${a.vcpu} vCPU, ${a.memoryMiB} MiB`,
|
|
402
|
-
when(a.createdAt),
|
|
403
|
-
]),
|
|
404
|
-
])
|
|
405
|
-
: `No ${many}. Make one: ${me} ${command} create ${kind.example}`, all);
|
|
406
|
-
return 0;
|
|
407
|
-
}
|
|
408
|
-
case "get": {
|
|
409
|
-
const app = await api.get(await idOf(rest[0]));
|
|
410
|
-
print(JSON.stringify(app, null, 2), app);
|
|
411
|
-
return 0;
|
|
412
|
-
}
|
|
413
|
-
case "update": {
|
|
414
|
-
const args = parse(rest, [], [...settingsOf(kind), "name"]);
|
|
415
|
-
const id = await idOf(args.positional[0]);
|
|
416
|
-
const change = {
|
|
417
|
-
...settings(args, kit, kind),
|
|
418
|
-
...(flag(args, "name") === undefined ? {} : { name: flag(args, "name") }),
|
|
419
|
-
...(args.flags.has("label") ? { labels: pairs(args, "label") } : {}),
|
|
420
|
-
};
|
|
421
|
-
if (!Object.keys(change).length)
|
|
422
|
-
throw usage(`Give a setting to change, such as ${me} ${command} update ${args.positional[0]} --max-copies 4`);
|
|
423
|
-
const app = await api.update(id, change);
|
|
424
|
-
print(`${app.name ?? app.id} updated.`, app);
|
|
425
|
-
return 0;
|
|
426
|
-
}
|
|
427
|
-
case "rm":
|
|
428
|
-
case "delete": {
|
|
429
|
-
const app = await api.delete(await idOf(rest[0]));
|
|
430
|
-
print(`${app.name ?? app.id} ${app.state}.`, app);
|
|
431
|
-
return 0;
|
|
432
|
-
}
|
|
433
|
-
case "deploy": {
|
|
434
|
-
const args = parse(rest, ["keep-env", "no-wait"], ["image", "build", "env", "port", "health-path"]);
|
|
435
|
-
const id = await idOf(args.positional[0]);
|
|
436
|
-
const image = flag(args, "image");
|
|
437
|
-
const build = flag(args, "build");
|
|
438
|
-
if ((image === undefined) === (build === undefined))
|
|
439
|
-
throw usage(`Give --image <image> to deploy an image of yours, or --build <buildId> for a build that succeeded.`);
|
|
440
|
-
const port = kit.integer(args, "port");
|
|
441
|
-
const healthPath = flag(args, "health-path");
|
|
442
|
-
const wait = !has(args, "no-wait");
|
|
443
|
-
const input = {
|
|
444
|
-
...(image !== undefined ? { image } : { build: build }),
|
|
445
|
-
...(args.flags.has("env") ? { env: envPairs(args, env) } : {}),
|
|
446
|
-
...(has(args, "keep-env") ? { keepEnv: true } : {}),
|
|
447
|
-
...(port === undefined ? {} : { port }),
|
|
448
|
-
...(healthPath === undefined ? {} : { healthPath }),
|
|
449
|
-
wait,
|
|
450
|
-
};
|
|
451
|
-
// A staged App's deploy walks up to four stages, each soaking.
|
|
452
|
-
const app = wait && kind.minCopies ? await api.get(id) : undefined;
|
|
453
|
-
const staged = app && "releaseStages" in app && app.releaseStages === "staged" ? app : undefined;
|
|
454
|
-
if (wait && !out.json)
|
|
455
|
-
out.error(staged
|
|
456
|
-
? `Deploying ${args.positional[0]} in stages, each soaking ${staged.releaseSoakSeconds} s...`
|
|
457
|
-
: `Deploying ${args.positional[0]}...`);
|
|
458
|
-
const deploy = await api.deploy(id, input, {
|
|
459
|
-
timeoutMs: 15 * 60_000 + (staged ? 4 * staged.releaseSoakSeconds * 1000 : 0),
|
|
460
|
-
});
|
|
461
|
-
const failed = deployFailure(deploy);
|
|
462
|
-
if (failed && !out.json)
|
|
463
|
-
throw failed;
|
|
464
|
-
print(deploy.state === "live"
|
|
465
|
-
? `Version ${deploy.version} is live at ${deploy.url}${deploy.downtime ? `, ${downtime(deploy.downtime)}` : ""}`
|
|
466
|
-
: `Version ${deploy.version}: ${deploy.state}. Follow it: ${me} ${command} deploys ${args.positional[0]} ${deploy.id} --wait`, deploy);
|
|
467
|
-
return failed ? 1 : 0;
|
|
468
|
-
}
|
|
469
|
-
case "deploys": {
|
|
470
|
-
const args = parse(rest, ["wait"], []);
|
|
471
|
-
const id = await idOf(args.positional[0]);
|
|
472
|
-
const deployId = args.positional[1];
|
|
473
|
-
if (deployId) {
|
|
474
|
-
const deploy = has(args, "wait")
|
|
475
|
-
? await api.waitDeploy(id, deployId, { timeoutMs: 15 * 60_000 })
|
|
476
|
-
: await api.getDeploy(id, deployId);
|
|
477
|
-
const failed = deployFailure(deploy);
|
|
478
|
-
if (failed && !out.json)
|
|
479
|
-
throw failed;
|
|
480
|
-
print(JSON.stringify(deploy, null, 2), deploy);
|
|
481
|
-
return failed ? 1 : 0;
|
|
482
|
-
}
|
|
483
|
-
// Newest first; a version's deploy is read once per line, so the list
|
|
484
|
-
// stops at the last 20.
|
|
485
|
-
const versions = (await api.versions(id)).sort((a, b) => b.version - a.version).slice(0, 20);
|
|
486
|
-
const deploys = await Promise.all(versions.map((v) => api.getDeploy(id, v.deploy)));
|
|
487
|
-
print(deploys.length
|
|
488
|
-
? table([
|
|
489
|
-
["VERSION", "DEPLOY", "STATE", "FROM", "DOWNTIME", "ADDRESS"],
|
|
490
|
-
...deploys.map((d, i) => [
|
|
491
|
-
`v${d.version}${versions[i].live ? " (live)" : versions[i].previous ? " (previous)" : ""}`,
|
|
492
|
-
d.id,
|
|
493
|
-
d.state,
|
|
494
|
-
d.restartOf != null
|
|
495
|
-
? `restart of v${d.restartOf}`
|
|
496
|
-
: versions[i].build
|
|
497
|
-
? `build ${versions[i].build}`
|
|
498
|
-
: "image",
|
|
499
|
-
downtime(d.downtime),
|
|
500
|
-
d.url,
|
|
501
|
-
]),
|
|
502
|
-
])
|
|
503
|
-
: `No deploys yet. Deploy one: ${me} ${command} deploy ${args.positional[0]} --image <image>`, deploys);
|
|
504
|
-
return 0;
|
|
505
|
-
}
|
|
506
|
-
case "versions": {
|
|
507
|
-
const id = await idOf(rest[0]);
|
|
508
|
-
const versions = (await api.versions(id)).sort((a, b) => b.version - a.version);
|
|
509
|
-
print(versions.length
|
|
510
|
-
? table([
|
|
511
|
-
["VERSION", "LIVE", "PREVIOUS", "SAVED", "BOOT", "DEPLOY", "BUILD", "REPLACED"],
|
|
512
|
-
...versions.map((v) => [
|
|
513
|
-
`v${v.version}${v.restartOf == null ? "" : ` (restart of v${v.restartOf})`}`,
|
|
514
|
-
v.live ? "yes" : "-",
|
|
515
|
-
v.previous ? "yes" : "-",
|
|
516
|
-
v.saved ? "yes" : "-",
|
|
517
|
-
v.boot ?? "-",
|
|
518
|
-
v.deploy,
|
|
519
|
-
v.build ?? "-",
|
|
520
|
-
replaced(v.replacements),
|
|
521
|
-
]),
|
|
522
|
-
])
|
|
523
|
-
: "No versions yet.", versions);
|
|
524
|
-
return 0;
|
|
525
|
-
}
|
|
526
|
-
case "copies": {
|
|
527
|
-
const id = await idOf(rest[0]);
|
|
528
|
-
const copies = await api.copies(id);
|
|
529
|
-
print(copies.length
|
|
530
|
-
? table([
|
|
531
|
-
["COPY", "VERSION", "REGION", "STATE", "SINCE"],
|
|
532
|
-
...copies.map((c) => [c.id, `v${c.version}`, c.region, c.state, when(c.since)]),
|
|
533
|
-
])
|
|
534
|
-
: `No copies awake. ${one === "App" ? "A request" : "A call"} starts one.`, copies);
|
|
535
|
-
return 0;
|
|
536
|
-
}
|
|
537
|
-
case "exec": {
|
|
538
|
-
const args = parse(rest, ["root"], ["cwd", "env", "timeout", "copy", "trace-files"]);
|
|
539
|
-
const command = args.rest ?? args.positional.slice(1);
|
|
540
|
-
if (!command.length)
|
|
541
|
-
throw usage(`Give the command after --: ${me} apps exec <app> -- ls -la`);
|
|
542
|
-
const copy = await api.copy(await idOf(args.positional[0]), {
|
|
543
|
-
...(flag(args, "copy") ? { copy: flag(args, "copy") } : {}),
|
|
544
|
-
});
|
|
545
|
-
return kit.execute(copy, command, args, out, env);
|
|
546
|
-
}
|
|
547
|
-
case "cp": {
|
|
548
|
-
const args = parse(rest, [], ["copy"]);
|
|
549
|
-
const [from, to] = args.positional;
|
|
550
|
-
await kit.copyFile(need(from, "a source"), need(to, "a destination"), async (app) => api.copy(await idOf(app), {
|
|
551
|
-
...(flag(args, "copy") ? { copy: flag(args, "copy") } : {}),
|
|
552
|
-
}), "<app>");
|
|
553
|
-
print(`Copied ${from} to ${to}.`, { from, to });
|
|
554
|
-
return 0;
|
|
555
|
-
}
|
|
556
|
-
case "logs": {
|
|
557
|
-
const args = parse(rest, ["f", "follow", "raw"], ["since", "version", "copy", "stream", "limit"]);
|
|
558
|
-
const id = await idOf(args.positional[0]);
|
|
559
|
-
const named = flag(args, "stream");
|
|
560
|
-
const stream = ["stdout", "stderr"].find((s) => s === named);
|
|
561
|
-
if (named !== undefined && stream === undefined)
|
|
562
|
-
throw usage(`--stream is stdout or stderr: ${me} ${command} logs ${args.positional[0]} --stream stderr`);
|
|
563
|
-
const version = kit.integer(args, "version");
|
|
564
|
-
const limit = kit.integer(args, "limit");
|
|
565
|
-
const query = {
|
|
566
|
-
...(flag(args, "since") === undefined ? {} : { since: flag(args, "since") }),
|
|
567
|
-
...(version === undefined ? {} : { version }),
|
|
568
|
-
...(flag(args, "copy") === undefined ? {} : { copy: flag(args, "copy") }),
|
|
569
|
-
...(stream === undefined ? {} : { stream }),
|
|
570
|
-
...(limit === undefined ? {} : { limit }),
|
|
571
|
-
};
|
|
572
|
-
const raw = has(args, "raw");
|
|
573
|
-
const [stdout, stderr] = [logStream(process.stdout, raw), logStream(process.stderr, raw)];
|
|
574
|
-
const write = (line) => (line.stream === "stderr" ? stderr : stdout)(line.text.endsWith("\n") ? line.text : `${line.text}\n`);
|
|
575
|
-
if (!has(args, "f") && !has(args, "follow")) {
|
|
576
|
-
const page = await api.logs(id, query);
|
|
577
|
-
if (out.json)
|
|
578
|
-
out.write(JSON.stringify(page));
|
|
579
|
-
else if (page.lines.length)
|
|
580
|
-
page.lines.forEach(write);
|
|
581
|
-
else
|
|
582
|
-
out.error(`[no lines ${query.since ? `since ${query.since}` : "in the last hour"}; try --since 1d, or --follow]`);
|
|
583
|
-
if (!out.json && page.hasMore)
|
|
584
|
-
out.error(`[older lines are kept: --since further back, or --limit up to 500]`);
|
|
585
|
-
return 0;
|
|
586
|
-
}
|
|
587
|
-
// Until Ctrl-C: the SDK reconnects across the server's two-minute calls.
|
|
588
|
-
for await (const event of api.logs(id, { ...query, follow: true }, { timeoutMs: 0 })) {
|
|
589
|
-
if (out.json)
|
|
590
|
-
out.write(JSON.stringify(event));
|
|
591
|
-
else if (event.type === "line")
|
|
592
|
-
write(event);
|
|
593
|
-
else
|
|
594
|
-
out.error("[some lines were dropped before they were read; going on]");
|
|
595
|
-
}
|
|
596
|
-
return 0;
|
|
597
|
-
}
|
|
598
|
-
case "rollback": {
|
|
599
|
-
const args = parse(rest, ["no-wait"], []);
|
|
600
|
-
const id = await idOf(args.positional[0]);
|
|
601
|
-
const deploy = await api.rollback(id, {
|
|
602
|
-
wait: !has(args, "no-wait"),
|
|
603
|
-
timeoutMs: 15 * 60_000,
|
|
604
|
-
});
|
|
605
|
-
const failed = deployFailure(deploy);
|
|
606
|
-
if (failed && !out.json)
|
|
607
|
-
throw failed;
|
|
608
|
-
print(deploy.state === "live"
|
|
609
|
-
? `Version ${deploy.version} is live again at ${deploy.url}`
|
|
610
|
-
: `Rolling back to version ${deploy.version}: ${deploy.state}.`, deploy);
|
|
611
|
-
return failed ? 1 : 0;
|
|
612
|
-
}
|
|
613
|
-
case "restart": {
|
|
614
|
-
const args = parse(rest, ["no-wait"], []);
|
|
615
|
-
const id = await idOf(args.positional[0]);
|
|
616
|
-
const deploy = await api.restart(id, {
|
|
617
|
-
wait: !has(args, "no-wait"),
|
|
618
|
-
timeoutMs: 15 * 60_000,
|
|
619
|
-
});
|
|
620
|
-
const failed = deployFailure(deploy);
|
|
621
|
-
if (failed && !out.json)
|
|
622
|
-
throw failed;
|
|
623
|
-
print(deploy.state === "live"
|
|
624
|
-
? `Version ${deploy.version} restarted, live at ${deploy.url}${deploy.downtime ? `, ${downtime(deploy.downtime)}` : ""}`
|
|
625
|
-
: `Restarting version ${deploy.version}: ${deploy.state}. Follow it: ${me} ${command} deploys ${args.positional[0]} ${deploy.id} --wait`, deploy);
|
|
626
|
-
return failed ? 1 : 0;
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
throw kit.unknown(`${command} command`, verb, [
|
|
630
|
-
"create",
|
|
631
|
-
"ls",
|
|
632
|
-
"get",
|
|
633
|
-
"update",
|
|
634
|
-
"rm",
|
|
635
|
-
"deploy",
|
|
636
|
-
"deploys",
|
|
637
|
-
"versions",
|
|
638
|
-
"copies",
|
|
639
|
-
"exec",
|
|
640
|
-
"cp",
|
|
641
|
-
"logs",
|
|
642
|
-
"rollback",
|
|
643
|
-
"restart",
|
|
644
|
-
]);
|
|
645
|
-
}
|
|
646
|
-
/** A repository as connect takes it: GitHub's owner/name, a github.com
|
|
647
|
-
* address read as that, or any other https address as plain git. */
|
|
648
|
-
function source(repository) {
|
|
649
|
-
const github = /^(?:https:\/\/github\.com\/)?([\w.-]+\/[\w.-]+?)(?:\.git)?\/?$/.exec(repository);
|
|
650
|
-
return github ? { provider: "github", repository: github[1] } : { provider: "git", repository };
|
|
651
|
-
}
|
|
652
|
-
/** connect's and change's settings. */
|
|
653
|
-
function repositorySettings(args, kit) {
|
|
654
|
-
const { flag, has, integer, pairs } = kit;
|
|
655
|
-
const text = (name, field) => flag(args, name) === undefined ? {} : { [field]: flag(args, name) };
|
|
656
|
-
const deploy = flag(args, "deploy");
|
|
657
|
-
return {
|
|
658
|
-
...(deploy === undefined
|
|
659
|
-
? {}
|
|
660
|
-
: {
|
|
661
|
-
deploy: (/^(app|function|container):/.test(deploy)
|
|
662
|
-
? deploy
|
|
663
|
-
: `app:${deploy}`),
|
|
664
|
-
}),
|
|
665
|
-
...text("branch", "productionBranch"),
|
|
666
|
-
...(has(args, "no-previews") ? { previews: false } : {}),
|
|
667
|
-
...text("root", "rootDirectory"),
|
|
668
|
-
...text("install", "installCommand"),
|
|
669
|
-
...text("build", "buildCommand"),
|
|
670
|
-
...text("start", "startCommand"),
|
|
671
|
-
...(integer(args, "port") === undefined ? {} : { port: integer(args, "port") }),
|
|
672
|
-
...text("health-path", "healthPath"),
|
|
673
|
-
...(args.flags.has("build-env") ? { buildEnv: pairs(args, "build-env") } : {}),
|
|
674
|
-
...text("name", "name"),
|
|
675
|
-
};
|
|
676
|
-
}
|
|
677
|
-
const REPOSITORY_VALUES = [
|
|
678
|
-
"deploy",
|
|
679
|
-
"branch",
|
|
680
|
-
"root",
|
|
681
|
-
"install",
|
|
682
|
-
"build",
|
|
683
|
-
"start",
|
|
684
|
-
"port",
|
|
685
|
-
"health-path",
|
|
686
|
-
"build-env",
|
|
687
|
-
"name",
|
|
688
|
-
];
|
|
689
|
-
export async function buildsCommand(argv, out, client, kit) {
|
|
690
|
-
const { parse, flag, has, need, table, usage } = kit;
|
|
691
|
-
const [verb, ...rest] = argv;
|
|
692
|
-
const print = (human, value) => out.write(out.json ? JSON.stringify(value) : human);
|
|
693
|
-
if (!verb || verb === "help" || verb === "--help") {
|
|
694
|
-
print(named(BUILD_HELP), { usage: named(BUILD_HELP) });
|
|
695
|
-
return 0;
|
|
696
|
-
}
|
|
697
|
-
const api = builds((await client()).transport);
|
|
698
|
-
const buildRow = (b) => [
|
|
699
|
-
b.id,
|
|
700
|
-
b.state,
|
|
701
|
-
b.ref,
|
|
702
|
-
b.commit ? b.commit.slice(0, 12) : "-",
|
|
703
|
-
when(b.createdAt),
|
|
704
|
-
b.reason ?? "-",
|
|
705
|
-
];
|
|
706
|
-
/** A build's log, its last lines or followed to its end. */
|
|
707
|
-
const logs = async (id, follow, raw) => {
|
|
708
|
-
const [stdout, stderr] = [logStream(process.stdout, raw), logStream(process.stderr, raw)];
|
|
709
|
-
const write = (line) => (line.stream === "stderr" ? stderr : stdout)(line.text.endsWith("\n") ? line.text : `${line.text}\n`);
|
|
710
|
-
if (!follow) {
|
|
711
|
-
const log = await api.logs(id);
|
|
712
|
-
if (out.json) {
|
|
713
|
-
out.write(JSON.stringify(log));
|
|
714
|
-
return 0;
|
|
715
|
-
}
|
|
716
|
-
log.lines.forEach(write);
|
|
717
|
-
if (log.failingStep)
|
|
718
|
-
out.error(`[${log.state} at ${log.failingStep.name}${log.failingStep.exitCode === null ? "" : `, exit code ${log.failingStep.exitCode}`}]`);
|
|
719
|
-
else
|
|
720
|
-
out.error(ENDED.includes(log.state)
|
|
721
|
-
? `[${log.state}${log.reason ? `, ${log.reason}` : ""}]`
|
|
722
|
-
: `[${log.state}; follow it: ${me} builds logs ${id} --follow]`);
|
|
723
|
-
return 0;
|
|
724
|
-
}
|
|
725
|
-
// A follow lasts until the build ends: no deadline of the SDK's own.
|
|
726
|
-
for await (const event of api.logs(id, { follow: true }, { timeoutMs: 0 })) {
|
|
727
|
-
if (out.json)
|
|
728
|
-
out.write(JSON.stringify(event));
|
|
729
|
-
else if (event.type === "line")
|
|
730
|
-
write(event);
|
|
731
|
-
else if (event.type === "gap")
|
|
732
|
-
out.error("[older lines were dropped before they were read; going on from the oldest kept]");
|
|
733
|
-
if (event.type === "terminal") {
|
|
734
|
-
if (!out.json) {
|
|
735
|
-
out.error(`[${event.state}, ${event.reason}]`);
|
|
736
|
-
if (event.failingStep)
|
|
737
|
-
out.error(`${event.failingStep.name} failed${event.failingStep.exitCode === null ? "" : ` with exit code ${event.failingStep.exitCode}`}. Its last lines:\n${event.failingStep.lastLines.join("\n")}`);
|
|
738
|
-
}
|
|
739
|
-
return event.state === "succeeded" ? 0 : 1;
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
return 1;
|
|
743
|
-
};
|
|
744
|
-
switch (verb) {
|
|
745
|
-
case "repos":
|
|
746
|
-
case "repositories": {
|
|
747
|
-
const [action, ...more] = rest;
|
|
748
|
-
switch (action) {
|
|
749
|
-
case "connect": {
|
|
750
|
-
const args = parse(more, ["no-previews"], REPOSITORY_VALUES);
|
|
751
|
-
const repository = need(args.positional[0], "the repository, such as acme/web");
|
|
752
|
-
const given = repositorySettings(args, kit);
|
|
753
|
-
if (!given.deploy)
|
|
754
|
-
throw usage(`Give --deploy with the App it deploys: ${me} builds repos connect ${repository} --deploy web`);
|
|
755
|
-
const repo = await api.repositories.connect({
|
|
756
|
-
...source(repository),
|
|
757
|
-
...given,
|
|
758
|
-
});
|
|
759
|
-
if (!out.json)
|
|
760
|
-
out.error(`Connected ${repo.repository}: a push to ${repo.productionBranch} builds and deploys ${repo.deploy}. Build now: ${me} builds run ${repo.id}`);
|
|
761
|
-
print(repo.id, repo);
|
|
762
|
-
return 0;
|
|
763
|
-
}
|
|
764
|
-
case "ls":
|
|
765
|
-
case "list": {
|
|
766
|
-
const all = await (await api.repositories.list({ limit: 100 })).toArray(Infinity);
|
|
767
|
-
print(all.length
|
|
768
|
-
? table([
|
|
769
|
-
["ID", "REPOSITORY", "BRANCH", "DEPLOYS", "STATE"],
|
|
770
|
-
...all.map((r) => [
|
|
771
|
-
r.id,
|
|
772
|
-
r.repository,
|
|
773
|
-
r.productionBranch,
|
|
774
|
-
r.deploy,
|
|
775
|
-
r.state,
|
|
776
|
-
]),
|
|
777
|
-
])
|
|
778
|
-
: `No repositories. Connect one: ${me} builds repos connect acme/web --deploy web`, all);
|
|
779
|
-
return 0;
|
|
780
|
-
}
|
|
781
|
-
case "change":
|
|
782
|
-
case "update": {
|
|
783
|
-
const args = parse(more, ["no-previews"], REPOSITORY_VALUES);
|
|
784
|
-
const id = need(args.positional[0], "a repository's id");
|
|
785
|
-
const change = repositorySettings(args, kit);
|
|
786
|
-
if (!Object.keys(change).length)
|
|
787
|
-
throw usage(`Give a setting to change, such as --branch main or --start "npm start".`);
|
|
788
|
-
const repo = await api.repositories.update(id, change);
|
|
789
|
-
print(`${repo.repository} changed.`, repo);
|
|
790
|
-
return 0;
|
|
791
|
-
}
|
|
792
|
-
case "disconnect":
|
|
793
|
-
case "rm": {
|
|
794
|
-
const repo = await api.repositories.disconnect(need(more[0], "a repository's id"));
|
|
795
|
-
print(`${repo.repository} disconnected; its builds stay.`, repo);
|
|
796
|
-
return 0;
|
|
797
|
-
}
|
|
798
|
-
case "install": {
|
|
799
|
-
const link = await api.repositories.installGithub();
|
|
800
|
-
print(`Open this within 15 minutes, install the App on the repositories Runtime may read, and confirm the organization:\n${link.url}`, link);
|
|
801
|
-
return 0;
|
|
802
|
-
}
|
|
803
|
-
}
|
|
804
|
-
throw kit.unknown("repos command", action ?? "", [
|
|
805
|
-
"connect",
|
|
806
|
-
"ls",
|
|
807
|
-
"change",
|
|
808
|
-
"disconnect",
|
|
809
|
-
"install",
|
|
810
|
-
]);
|
|
811
|
-
}
|
|
812
|
-
case "create":
|
|
813
|
-
case "run": {
|
|
814
|
-
const args = parse(rest, verb === "run" ? ["raw"] : [], ["ref", "branch", "name"]);
|
|
815
|
-
const repositoryId = need(args.positional[0], "a repository's id (runtime builds repos ls)");
|
|
816
|
-
const build = await api.create({
|
|
817
|
-
repositoryId,
|
|
818
|
-
ref: flag(args, "ref") ?? flag(args, "branch") ?? "main",
|
|
819
|
-
...(flag(args, "branch") ? { branch: flag(args, "branch") } : {}),
|
|
820
|
-
...(flag(args, "name") ? { name: flag(args, "name") } : {}),
|
|
821
|
-
});
|
|
822
|
-
if (verb === "create") {
|
|
823
|
-
if (!out.json)
|
|
824
|
-
out.error(`Building ${build.ref}${build.commit ? ` at ${build.commit.slice(0, 12)}` : ""}. Follow it: ${me} builds logs ${build.id} --follow`);
|
|
825
|
-
print(build.id, build);
|
|
826
|
-
return 0;
|
|
827
|
-
}
|
|
828
|
-
if (!out.json)
|
|
829
|
-
out.error(`Build ${build.id}, ${build.ref}${build.commit ? ` at ${build.commit.slice(0, 12)}` : ""}:`);
|
|
830
|
-
else
|
|
831
|
-
out.write(JSON.stringify(build));
|
|
832
|
-
return logs(build.id, true, has(args, "raw"));
|
|
833
|
-
}
|
|
834
|
-
case "ls":
|
|
835
|
-
case "list": {
|
|
836
|
-
const args = parse(rest, [], ["repository", "commit", "state"]);
|
|
837
|
-
const commit = flag(args, "commit");
|
|
838
|
-
if (commit !== undefined && !/^([0-9a-f]{40}|[0-9a-f]{64})$/.test(commit))
|
|
839
|
-
throw usage(`--commit takes a full sha in lower case: ${me} builds ls --commit $(git rev-parse HEAD)`);
|
|
840
|
-
const states = args.flags.get("state");
|
|
841
|
-
const all = await (await api.list({
|
|
842
|
-
limit: 100,
|
|
843
|
-
...(flag(args, "repository") ? { repositoryId: flag(args, "repository") } : {}),
|
|
844
|
-
...(commit ? { commit } : {}),
|
|
845
|
-
...(states ? { state: states } : {}),
|
|
846
|
-
})).toArray(Infinity);
|
|
847
|
-
print(all.length
|
|
848
|
-
? table([["ID", "STATE", "REF", "COMMIT", "CREATED", "REASON"], ...all.map(buildRow)])
|
|
849
|
-
: "No builds.", all);
|
|
850
|
-
return 0;
|
|
851
|
-
}
|
|
852
|
-
case "get": {
|
|
853
|
-
const build = await api.get(need(rest[0], "a build's id"));
|
|
854
|
-
print(JSON.stringify(build, null, 2), build);
|
|
855
|
-
return 0;
|
|
856
|
-
}
|
|
857
|
-
case "cancel": {
|
|
858
|
-
const build = await api.cancel(need(rest[0], "a build's id"));
|
|
859
|
-
print(`${build.id} ${build.state}.`, build);
|
|
860
|
-
return 0;
|
|
861
|
-
}
|
|
862
|
-
case "logs": {
|
|
863
|
-
const args = parse(rest, ["f", "follow", "raw"], []);
|
|
864
|
-
const id = need(args.positional[0], "a build's id");
|
|
865
|
-
return logs(id, has(args, "f") || has(args, "follow"), has(args, "raw"));
|
|
866
|
-
}
|
|
867
|
-
}
|
|
868
|
-
throw kit.unknown("builds command", verb, [
|
|
869
|
-
"repos",
|
|
870
|
-
"create",
|
|
871
|
-
"run",
|
|
872
|
-
"ls",
|
|
873
|
-
"get",
|
|
874
|
-
"cancel",
|
|
875
|
-
"logs",
|
|
876
|
-
]);
|
|
877
|
-
}
|
|
878
|
-
const CONTAINER_STATES = [
|
|
879
|
-
"waiting",
|
|
880
|
-
"running",
|
|
881
|
-
"sleeping",
|
|
882
|
-
"stopped",
|
|
883
|
-
"failed",
|
|
884
|
-
"deleting",
|
|
885
|
-
"deleted",
|
|
886
|
-
];
|
|
887
|
-
const CONTAINER_VALUES = [
|
|
888
|
-
"vcpu",
|
|
889
|
-
"memory",
|
|
890
|
-
"name",
|
|
891
|
-
"label",
|
|
892
|
-
"env",
|
|
893
|
-
"entrypoint",
|
|
894
|
-
"workdir",
|
|
895
|
-
"user",
|
|
896
|
-
"port",
|
|
897
|
-
"on-exit",
|
|
898
|
-
];
|
|
899
|
-
export async function containersCommand(argv, env, out, client, kit) {
|
|
900
|
-
const { parse, flag, has, integer, need, pairs, envPairs, table, usage } = kit;
|
|
901
|
-
const [verb, ...rest] = argv;
|
|
902
|
-
const print = (human, value) => out.write(out.json ? JSON.stringify(value) : human);
|
|
903
|
-
if (!verb || verb === "help" || verb === "--help") {
|
|
904
|
-
print(named(CONTAINER_HELP), { usage: named(CONTAINER_HELP) });
|
|
905
|
-
return 0;
|
|
906
|
-
}
|
|
907
|
-
const api = containers((await client()).transport);
|
|
908
|
-
/** A container's id from its id or its name: a name is looked up among the
|
|
909
|
-
* containers not deleted, and must be one container's alone. */
|
|
910
|
-
const idOf = async (target) => {
|
|
911
|
-
const given = need(target, "a container's id or name");
|
|
912
|
-
if (UUID.test(given))
|
|
913
|
-
return given;
|
|
914
|
-
const found = (await api.list({ name: given })).data;
|
|
915
|
-
if (found.length === 1)
|
|
916
|
-
return found[0].id;
|
|
917
|
-
throw usage(found.length
|
|
918
|
-
? `${found.length} containers are named ${given}; give one's id (${me} containers ls).`
|
|
919
|
-
: `No container is named ${given}. Your containers: ${me} containers ls`);
|
|
920
|
-
};
|
|
921
|
-
switch (verb) {
|
|
922
|
-
case "create": {
|
|
923
|
-
const args = parse(rest, ["sleep"], CONTAINER_VALUES);
|
|
924
|
-
if (args.positional.length !== 1)
|
|
925
|
-
throw usage(`Give one image: ${me} containers create nginx:1.27 --vcpu 1 --memory 512 [-- <command...>]`);
|
|
926
|
-
const image = args.positional[0];
|
|
927
|
-
const vcpu = integer(args, "vcpu");
|
|
928
|
-
const memoryMiB = integer(args, "memory");
|
|
929
|
-
if (vcpu === undefined || memoryMiB === undefined)
|
|
930
|
-
throw usage(`Give --vcpu and --memory: ${me} containers create ${image} --vcpu 1 --memory 512`);
|
|
931
|
-
const onExit = flag(args, "on-exit");
|
|
932
|
-
if (onExit !== undefined && onExit !== "restart" && onExit !== "stop")
|
|
933
|
-
throw usage("--on-exit takes restart or stop.");
|
|
934
|
-
const port = integer(args, "port");
|
|
935
|
-
const entrypoint = flag(args, "entrypoint");
|
|
936
|
-
const workingDir = flag(args, "workdir");
|
|
937
|
-
const user = flag(args, "user");
|
|
938
|
-
const name = flag(args, "name");
|
|
939
|
-
const input = {
|
|
940
|
-
image,
|
|
941
|
-
vcpu,
|
|
942
|
-
memoryMiB,
|
|
943
|
-
...(name === undefined ? {} : { name }),
|
|
944
|
-
...(args.flags.has("label") ? { labels: pairs(args, "label") } : {}),
|
|
945
|
-
...(args.flags.has("env") ? { env: envPairs(args, env) } : {}),
|
|
946
|
-
...(entrypoint === undefined ? {} : { entrypoint: [entrypoint] }),
|
|
947
|
-
...(args.rest?.length ? { command: args.rest } : {}),
|
|
948
|
-
...(workingDir === undefined ? {} : { workingDir }),
|
|
949
|
-
...(user === undefined ? {} : { user }),
|
|
950
|
-
...(port === undefined ? {} : { port }),
|
|
951
|
-
...(onExit === undefined ? {} : { onExit }),
|
|
952
|
-
...(has(args, "sleep") ? { sleep: true } : {}),
|
|
953
|
-
};
|
|
954
|
-
const made = await api.create(input);
|
|
955
|
-
if (!out.json)
|
|
956
|
-
out.error(`${made.name ?? made.id} is ${made.state}, running ${made.image}. Read it: ${me} containers get ${made.name ?? made.id}`);
|
|
957
|
-
print(made.id, made);
|
|
958
|
-
return 0;
|
|
959
|
-
}
|
|
960
|
-
case "ls":
|
|
961
|
-
case "list": {
|
|
962
|
-
const args = parse(rest, ["all"], ["state", "label"]);
|
|
963
|
-
const states = args.flags.get("state");
|
|
964
|
-
for (const state of states ?? [])
|
|
965
|
-
if (!CONTAINER_STATES.includes(state))
|
|
966
|
-
throw usage(`--state takes ${CONTAINER_STATES.join(", ")}.`);
|
|
967
|
-
// --label key=value, as the list's key:value filters.
|
|
968
|
-
const labels = Object.entries(pairs(args, "label")).map(([k, v]) => `${k}:${v}`);
|
|
969
|
-
const all = await (await api.list({
|
|
970
|
-
limit: 100,
|
|
971
|
-
...(states
|
|
972
|
-
? { state: states }
|
|
973
|
-
: has(args, "all")
|
|
974
|
-
? { state: CONTAINER_STATES }
|
|
975
|
-
: {}),
|
|
976
|
-
...(labels.length ? { label: labels } : {}),
|
|
977
|
-
})).toArray(Infinity);
|
|
978
|
-
print(all.length
|
|
979
|
-
? table([
|
|
980
|
-
["ID", "NAME", "STATE", "IMAGE", "PORT", "SIZE", "CREATED"],
|
|
981
|
-
...all.map((c) => [
|
|
982
|
-
c.id,
|
|
983
|
-
c.name ?? "-",
|
|
984
|
-
c.state,
|
|
985
|
-
c.image,
|
|
986
|
-
c.port === null ? "-" : String(c.port),
|
|
987
|
-
`${c.vcpu} vCPU, ${c.memoryMiB} MiB`,
|
|
988
|
-
when(c.createdAt),
|
|
989
|
-
]),
|
|
990
|
-
])
|
|
991
|
-
: `No containers. Run one: ${me} containers create nginx:1.27 --vcpu 1 --memory 512`, all);
|
|
992
|
-
return 0;
|
|
993
|
-
}
|
|
994
|
-
case "get": {
|
|
995
|
-
const found = await api.get(await idOf(rest[0]));
|
|
996
|
-
print(JSON.stringify(found, null, 2), found);
|
|
997
|
-
return 0;
|
|
998
|
-
}
|
|
999
|
-
case "update": {
|
|
1000
|
-
const args = parse(rest, [], ["name", "label"]);
|
|
1001
|
-
const id = await idOf(args.positional[0]);
|
|
1002
|
-
const change = {
|
|
1003
|
-
...(flag(args, "name") === undefined ? {} : { name: flag(args, "name") }),
|
|
1004
|
-
...(args.flags.has("label") ? { labels: pairs(args, "label") } : {}),
|
|
1005
|
-
};
|
|
1006
|
-
if (!Object.keys(change).length)
|
|
1007
|
-
throw usage(`Give --name or --label: ${me} containers update ${args.positional[0]} --name web`);
|
|
1008
|
-
const updated = await api.update(id, change);
|
|
1009
|
-
print(`${updated.name ?? updated.id} updated.`, updated);
|
|
1010
|
-
return 0;
|
|
1011
|
-
}
|
|
1012
|
-
case "rm":
|
|
1013
|
-
case "delete": {
|
|
1014
|
-
const args = parse(rest, ["wait"], []);
|
|
1015
|
-
const gone = await api.delete(await idOf(args.positional[0]), { wait: has(args, "wait") });
|
|
1016
|
-
print(`${gone.name ?? gone.id} ${gone.state}.`, gone);
|
|
1017
|
-
return 0;
|
|
1018
|
-
}
|
|
1019
|
-
}
|
|
1020
|
-
throw kit.unknown("containers command", verb, ["create", "ls", "get", "update", "rm"]);
|
|
1021
|
-
}
|