@synteq/cli 0.2.0 → 1.1.1
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/api/client.d.ts +362 -5
- package/dist/api/client.js +559 -44
- package/dist/api/client.js.map +1 -1
- package/dist/api/factory.js +5 -2
- package/dist/api/factory.js.map +1 -1
- package/dist/api/types.d.ts +892 -3
- package/dist/apps-support/deploy.d.ts +197 -0
- package/dist/apps-support/deploy.js +639 -0
- package/dist/apps-support/deploy.js.map +1 -0
- package/dist/apps-support/dotenv.d.ts +67 -0
- package/dist/apps-support/dotenv.js +136 -0
- package/dist/apps-support/dotenv.js.map +1 -0
- package/dist/apps-support/env-rollout.d.ts +18 -0
- package/dist/apps-support/env-rollout.js +52 -0
- package/dist/apps-support/env-rollout.js.map +1 -0
- package/dist/apps-support/git.d.ts +14 -0
- package/dist/apps-support/git.js +25 -0
- package/dist/apps-support/git.js.map +1 -0
- package/dist/apps-support/link.d.ts +25 -0
- package/dist/apps-support/link.js +39 -0
- package/dist/apps-support/link.js.map +1 -0
- package/dist/apps-support/log-stream.d.ts +25 -0
- package/dist/apps-support/log-stream.js +85 -0
- package/dist/apps-support/log-stream.js.map +1 -0
- package/dist/apps-support/paid-app.d.ts +64 -0
- package/dist/apps-support/paid-app.js +195 -0
- package/dist/apps-support/paid-app.js.map +1 -0
- package/dist/apps-support/plans.d.ts +44 -0
- package/dist/apps-support/plans.js +43 -0
- package/dist/apps-support/plans.js.map +1 -0
- package/dist/apps-support/resolve.d.ts +10 -0
- package/dist/apps-support/resolve.js +53 -0
- package/dist/apps-support/resolve.js.map +1 -0
- package/dist/apps-support/time.d.ts +20 -0
- package/dist/apps-support/time.js +82 -0
- package/dist/apps-support/time.js.map +1 -0
- package/dist/auth/scope.js +4 -0
- package/dist/auth/scope.js.map +1 -1
- package/dist/auth/tokens.d.ts +3 -0
- package/dist/auth/tokens.js +6 -4
- package/dist/auth/tokens.js.map +1 -1
- package/dist/base/command.d.ts +35 -0
- package/dist/base/command.js +87 -4
- package/dist/base/command.js.map +1 -1
- package/dist/commands/agents.d.ts +10 -0
- package/dist/commands/agents.js +53 -0
- package/dist/commands/agents.js.map +1 -0
- package/dist/commands/api.d.ts +0 -1
- package/dist/commands/api.js +6 -5
- package/dist/commands/api.js.map +1 -1
- package/dist/commands/app/deployment/list.d.ts +14 -0
- package/dist/commands/app/deployment/list.js +45 -0
- package/dist/commands/app/deployment/list.js.map +1 -0
- package/dist/commands/app/deployment/rollback.d.ts +18 -0
- package/dist/commands/app/deployment/rollback.js +57 -0
- package/dist/commands/app/deployment/rollback.js.map +1 -0
- package/dist/commands/app/deployment/show.d.ts +26 -0
- package/dist/commands/app/deployment/show.js +98 -0
- package/dist/commands/app/deployment/show.js.map +1 -0
- package/dist/commands/app/domain/add.d.ts +17 -0
- package/dist/commands/app/domain/add.js +59 -0
- package/dist/commands/app/domain/add.js.map +1 -0
- package/dist/commands/app/domain/list.d.ts +14 -0
- package/dist/commands/app/domain/list.js +42 -0
- package/dist/commands/app/domain/list.js.map +1 -0
- package/dist/commands/app/domain/remove.d.ts +16 -0
- package/dist/commands/app/domain/remove.js +51 -0
- package/dist/commands/app/domain/remove.js.map +1 -0
- package/dist/commands/app/domain/verify.d.ts +15 -0
- package/dist/commands/app/domain/verify.js +39 -0
- package/dist/commands/app/domain/verify.js.map +1 -0
- package/dist/commands/app/env/add.d.ts +22 -0
- package/dist/commands/app/env/add.js +103 -0
- package/dist/commands/app/env/add.js.map +1 -0
- package/dist/commands/app/env/list.d.ts +17 -0
- package/dist/commands/app/env/list.js +40 -0
- package/dist/commands/app/env/list.js.map +1 -0
- package/dist/commands/app/env/reveal.d.ts +17 -0
- package/dist/commands/app/env/reveal.js +40 -0
- package/dist/commands/app/env/reveal.js.map +1 -0
- package/dist/commands/app/env/rm.d.ts +16 -0
- package/dist/commands/app/env/rm.js +48 -0
- package/dist/commands/app/env/rm.js.map +1 -0
- package/dist/commands/app/health.d.ts +14 -0
- package/dist/commands/app/health.js +40 -0
- package/dist/commands/app/health.js.map +1 -0
- package/dist/commands/app/index.d.ts +6 -0
- package/dist/commands/app/index.js +7 -0
- package/dist/commands/app/index.js.map +1 -0
- package/dist/commands/app/link.d.ts +22 -0
- package/dist/commands/app/link.js +31 -0
- package/dist/commands/app/link.js.map +1 -0
- package/dist/commands/app/logs.d.ts +25 -0
- package/dist/commands/app/logs.js +121 -0
- package/dist/commands/app/logs.js.map +1 -0
- package/dist/commands/app/metrics.d.ts +21 -0
- package/dist/commands/app/metrics.js +123 -0
- package/dist/commands/app/metrics.js.map +1 -0
- package/dist/commands/app/plan/change.d.ts +18 -0
- package/dist/commands/app/plan/change.js +79 -0
- package/dist/commands/app/plan/change.js.map +1 -0
- package/dist/commands/app/plan/show.d.ts +14 -0
- package/dist/commands/app/plan/show.js +40 -0
- package/dist/commands/app/plan/show.js.map +1 -0
- package/dist/commands/app/settings/set.d.ts +25 -0
- package/dist/commands/app/settings/set.js +96 -0
- package/dist/commands/app/settings/set.js.map +1 -0
- package/dist/commands/app/settings/show.d.ts +14 -0
- package/dist/commands/app/settings/show.js +48 -0
- package/dist/commands/app/settings/show.js.map +1 -0
- package/dist/commands/app/unlink.d.ts +8 -0
- package/dist/commands/app/unlink.js +25 -0
- package/dist/commands/app/unlink.js.map +1 -0
- package/dist/commands/apps/create.d.ts +26 -0
- package/dist/commands/apps/create.js +91 -0
- package/dist/commands/apps/create.js.map +1 -0
- package/dist/commands/apps/list.d.ts +16 -0
- package/dist/commands/apps/list.js +54 -0
- package/dist/commands/apps/list.js.map +1 -0
- package/dist/commands/baremetal/activity.d.ts +14 -0
- package/dist/commands/baremetal/activity.js +53 -0
- package/dist/commands/baremetal/activity.js.map +1 -0
- package/dist/commands/baremetal/bandwidth.d.ts +10 -0
- package/dist/commands/baremetal/bandwidth.js +86 -0
- package/dist/commands/baremetal/bandwidth.js.map +1 -0
- package/dist/commands/baremetal/console.d.ts +20 -0
- package/dist/commands/baremetal/console.js +72 -0
- package/dist/commands/baremetal/console.js.map +1 -0
- package/dist/commands/baremetal/details.d.ts +11 -0
- package/dist/commands/baremetal/details.js +116 -0
- package/dist/commands/baremetal/details.js.map +1 -0
- package/dist/commands/baremetal/index.d.ts +5 -0
- package/dist/commands/baremetal/index.js +6 -0
- package/dist/commands/baremetal/index.js.map +1 -0
- package/dist/commands/baremetal/install-password.d.ts +14 -0
- package/dist/commands/baremetal/install-password.js +80 -0
- package/dist/commands/baremetal/install-password.js.map +1 -0
- package/dist/commands/baremetal/list.d.ts +11 -0
- package/dist/commands/baremetal/list.js +59 -0
- package/dist/commands/baremetal/list.js.map +1 -0
- package/dist/commands/baremetal/order.d.ts +34 -0
- package/dist/commands/baremetal/order.js +394 -0
- package/dist/commands/baremetal/order.js.map +1 -0
- package/dist/commands/baremetal/power.d.ts +18 -0
- package/dist/commands/baremetal/power.js +168 -0
- package/dist/commands/baremetal/power.js.map +1 -0
- package/dist/commands/baremetal/reinstall.d.ts +21 -0
- package/dist/commands/baremetal/reinstall.js +168 -0
- package/dist/commands/baremetal/reinstall.js.map +1 -0
- package/dist/commands/config/profile/add.d.ts +11 -0
- package/dist/commands/config/profile/add.js +51 -0
- package/dist/commands/config/profile/add.js.map +1 -0
- package/dist/commands/config/profile/list.d.ts +7 -0
- package/dist/commands/config/profile/list.js +29 -0
- package/dist/commands/config/profile/list.js.map +1 -0
- package/dist/commands/config/profile/remove.d.ts +11 -0
- package/dist/commands/config/profile/remove.js +35 -0
- package/dist/commands/config/profile/remove.js.map +1 -0
- package/dist/commands/config/profile/use.d.ts +10 -0
- package/dist/commands/config/profile/use.js +44 -0
- package/dist/commands/config/profile/use.js.map +1 -0
- package/dist/commands/config/show.js +4 -1
- package/dist/commands/config/show.js.map +1 -1
- package/dist/commands/credits/add.js +2 -2
- package/dist/commands/credits/add.js.map +1 -1
- package/dist/commands/credits/index.js +5 -1
- package/dist/commands/credits/index.js.map +1 -1
- package/dist/commands/deploy.d.ts +51 -0
- package/dist/commands/deploy.js +515 -0
- package/dist/commands/deploy.js.map +1 -0
- package/dist/commands/function/create.d.ts +29 -0
- package/dist/commands/function/create.js +113 -0
- package/dist/commands/function/create.js.map +1 -0
- package/dist/commands/function/credits/add.d.ts +29 -0
- package/dist/commands/function/credits/add.js +209 -0
- package/dist/commands/function/credits/add.js.map +1 -0
- package/dist/commands/function/credits/auto-reload.d.ts +27 -0
- package/dist/commands/function/credits/auto-reload.js +107 -0
- package/dist/commands/function/credits/auto-reload.js.map +1 -0
- package/dist/commands/function/credits/index.d.ts +22 -0
- package/dist/commands/function/credits/index.js +80 -0
- package/dist/commands/function/credits/index.js.map +1 -0
- package/dist/commands/function/cron/add.d.ts +19 -0
- package/dist/commands/function/cron/add.js +74 -0
- package/dist/commands/function/cron/add.js.map +1 -0
- package/dist/commands/function/cron/list.d.ts +12 -0
- package/dist/commands/function/cron/list.js +55 -0
- package/dist/commands/function/cron/list.js.map +1 -0
- package/dist/commands/function/cron/rm.d.ts +17 -0
- package/dist/commands/function/cron/rm.js +73 -0
- package/dist/commands/function/cron/rm.js.map +1 -0
- package/dist/commands/function/cron/run.d.ts +16 -0
- package/dist/commands/function/cron/run.js +59 -0
- package/dist/commands/function/cron/run.js.map +1 -0
- package/dist/commands/function/cron/update.d.ts +21 -0
- package/dist/commands/function/cron/update.js +87 -0
- package/dist/commands/function/cron/update.js.map +1 -0
- package/dist/commands/function/delete.d.ts +23 -0
- package/dist/commands/function/delete.js +90 -0
- package/dist/commands/function/delete.js.map +1 -0
- package/dist/commands/function/deploy.d.ts +64 -0
- package/dist/commands/function/deploy.js +608 -0
- package/dist/commands/function/deploy.js.map +1 -0
- package/dist/commands/function/env/list.d.ts +12 -0
- package/dist/commands/function/env/list.js +46 -0
- package/dist/commands/function/env/list.js.map +1 -0
- package/dist/commands/function/env/reveal.d.ts +21 -0
- package/dist/commands/function/env/reveal.js +54 -0
- package/dist/commands/function/env/reveal.js.map +1 -0
- package/dist/commands/function/env/rm.d.ts +17 -0
- package/dist/commands/function/env/rm.js +62 -0
- package/dist/commands/function/env/rm.js.map +1 -0
- package/dist/commands/function/env/set.d.ts +28 -0
- package/dist/commands/function/env/set.js +124 -0
- package/dist/commands/function/env/set.js.map +1 -0
- package/dist/commands/function/index.d.ts +14 -0
- package/dist/commands/function/index.js +11 -0
- package/dist/commands/function/index.js.map +1 -0
- package/dist/commands/function/init.d.ts +47 -0
- package/dist/commands/function/init.js +269 -0
- package/dist/commands/function/init.js.map +1 -0
- package/dist/commands/function/invoke.d.ts +29 -0
- package/dist/commands/function/invoke.js +138 -0
- package/dist/commands/function/invoke.js.map +1 -0
- package/dist/commands/function/link.d.ts +23 -0
- package/dist/commands/function/link.js +80 -0
- package/dist/commands/function/link.js.map +1 -0
- package/dist/commands/function/list.d.ts +16 -0
- package/dist/commands/function/list.js +55 -0
- package/dist/commands/function/list.js.map +1 -0
- package/dist/commands/function/logs.d.ts +29 -0
- package/dist/commands/function/logs.js +171 -0
- package/dist/commands/function/logs.js.map +1 -0
- package/dist/commands/function/pause.d.ts +19 -0
- package/dist/commands/function/pause.js +50 -0
- package/dist/commands/function/pause.js.map +1 -0
- package/dist/commands/function/releases.d.ts +15 -0
- package/dist/commands/function/releases.js +62 -0
- package/dist/commands/function/releases.js.map +1 -0
- package/dist/commands/function/resume.d.ts +16 -0
- package/dist/commands/function/resume.js +47 -0
- package/dist/commands/function/resume.js.map +1 -0
- package/dist/commands/function/rollback.d.ts +18 -0
- package/dist/commands/function/rollback.js +69 -0
- package/dist/commands/function/rollback.js.map +1 -0
- package/dist/commands/function/settings/set.d.ts +23 -0
- package/dist/commands/function/settings/set.js +119 -0
- package/dist/commands/function/settings/set.js.map +1 -0
- package/dist/commands/function/show.d.ts +15 -0
- package/dist/commands/function/show.js +80 -0
- package/dist/commands/function/show.js.map +1 -0
- package/dist/commands/function/unlink.d.ts +9 -0
- package/dist/commands/function/unlink.js +34 -0
- package/dist/commands/function/unlink.js.map +1 -0
- package/dist/commands/link.d.ts +77 -0
- package/dist/commands/link.js +530 -0
- package/dist/commands/link.js.map +1 -0
- package/dist/commands/login.js +9 -0
- package/dist/commands/login.js.map +1 -1
- package/dist/commands/order.js +3 -1
- package/dist/commands/order.js.map +1 -1
- package/dist/commands/payments/methods/delete.js +2 -2
- package/dist/commands/payments/methods/delete.js.map +1 -1
- package/dist/commands/resources.js +50 -7
- package/dist/commands/resources.js.map +1 -1
- package/dist/commands/status.d.ts +12 -0
- package/dist/commands/status.js +71 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/commands/storage/detach.js +1 -1
- package/dist/commands/storage/detach.js.map +1 -1
- package/dist/commands/storage/list.js +6 -2
- package/dist/commands/storage/list.js.map +1 -1
- package/dist/commands/storage/order.d.ts +2 -0
- package/dist/commands/storage/order.js +100 -18
- package/dist/commands/storage/order.js.map +1 -1
- package/dist/commands/storage/resize.js +19 -6
- package/dist/commands/storage/resize.js.map +1 -1
- package/dist/commands/tickets/create.d.ts +2 -0
- package/dist/commands/tickets/create.js +40 -1
- package/dist/commands/tickets/create.js.map +1 -1
- package/dist/commands/tickets/download.d.ts +18 -0
- package/dist/commands/tickets/download.js +138 -0
- package/dist/commands/tickets/download.js.map +1 -0
- package/dist/commands/tickets/list.js +13 -7
- package/dist/commands/tickets/list.js.map +1 -1
- package/dist/commands/tickets/reply.d.ts +2 -0
- package/dist/commands/tickets/reply.js +33 -4
- package/dist/commands/tickets/reply.js.map +1 -1
- package/dist/commands/vds/order.js +72 -7
- package/dist/commands/vds/order.js.map +1 -1
- package/dist/commands/vps/console.js +14 -6
- package/dist/commands/vps/console.js.map +1 -1
- package/dist/commands/vps/details.js +7 -1
- package/dist/commands/vps/details.js.map +1 -1
- package/dist/commands/vps/ip/add.js +76 -9
- package/dist/commands/vps/ip/add.js.map +1 -1
- package/dist/commands/vps/list.js +13 -4
- package/dist/commands/vps/list.js.map +1 -1
- package/dist/commands/vps/order.d.ts +19 -0
- package/dist/commands/vps/order.js +179 -23
- package/dist/commands/vps/order.js.map +1 -1
- package/dist/commands/vps/power.js +2 -2
- package/dist/commands/vps/power.js.map +1 -1
- package/dist/commands/vps/reinstall.js +2 -2
- package/dist/commands/vps/reinstall.js.map +1 -1
- package/dist/commands/vps/resize.js +36 -13
- package/dist/commands/vps/resize.js.map +1 -1
- package/dist/commands/whoami.d.ts +5 -0
- package/dist/commands/whoami.js +8 -3
- package/dist/commands/whoami.js.map +1 -1
- package/dist/config/paths.d.ts +1 -1
- package/dist/config/paths.js +6 -1
- package/dist/config/paths.js.map +1 -1
- package/dist/config/store.d.ts +58 -0
- package/dist/config/store.js +84 -2
- package/dist/config/store.js.map +1 -1
- package/dist/functions-support/credits.d.ts +64 -0
- package/dist/functions-support/credits.js +181 -0
- package/dist/functions-support/credits.js.map +1 -0
- package/dist/functions-support/cron.d.ts +17 -0
- package/dist/functions-support/cron.js +99 -0
- package/dist/functions-support/cron.js.map +1 -0
- package/dist/functions-support/env.d.ts +23 -0
- package/dist/functions-support/env.js +44 -0
- package/dist/functions-support/env.js.map +1 -0
- package/dist/functions-support/link.d.ts +25 -0
- package/dist/functions-support/link.js +51 -0
- package/dist/functions-support/link.js.map +1 -0
- package/dist/functions-support/poll.d.ts +40 -0
- package/dist/functions-support/poll.js +109 -0
- package/dist/functions-support/poll.js.map +1 -0
- package/dist/functions-support/resolve.d.ts +3 -0
- package/dist/functions-support/resolve.js +31 -0
- package/dist/functions-support/resolve.js.map +1 -0
- package/dist/functions-support/runtime.d.ts +30 -0
- package/dist/functions-support/runtime.js +52 -0
- package/dist/functions-support/runtime.js.map +1 -0
- package/dist/functions-support/source.d.ts +92 -0
- package/dist/functions-support/source.js +343 -0
- package/dist/functions-support/source.js.map +1 -0
- package/dist/help/scope-aware-help.js +10 -1
- package/dist/help/scope-aware-help.js.map +1 -1
- package/dist/tui/App.js +10 -25
- package/dist/tui/App.js.map +1 -1
- package/dist/tui/components/Menu.d.ts +3 -1
- package/dist/tui/components/Menu.js +7 -3
- package/dist/tui/components/Menu.js.map +1 -1
- package/dist/tui/router.d.ts +1 -1
- package/dist/tui/router.js.map +1 -1
- package/dist/tui/screens/Billing.js +56 -4
- package/dist/tui/screens/Billing.js.map +1 -1
- package/dist/tui/screens/Dashboard.js +8 -7
- package/dist/tui/screens/Dashboard.js.map +1 -1
- package/dist/tui/screens/Deploy.d.ts +2 -0
- package/dist/tui/screens/Deploy.js +912 -0
- package/dist/tui/screens/Deploy.js.map +1 -0
- package/dist/tui/screens/Order.js +359 -26
- package/dist/tui/screens/Order.js.map +1 -1
- package/dist/tui/screens/Resources.js +273 -31
- package/dist/tui/screens/Resources.js.map +1 -1
- package/dist/tui/screens/Tickets.js +18 -6
- package/dist/tui/screens/Tickets.js.map +1 -1
- package/dist/tui/screens/deployPreset.d.ts +20 -0
- package/dist/tui/screens/deployPreset.js +11 -0
- package/dist/tui/screens/deployPreset.js.map +1 -0
- package/dist/tui/screens/resources/AppDetail.d.ts +7 -0
- package/dist/tui/screens/resources/AppDetail.js +810 -0
- package/dist/tui/screens/resources/AppDetail.js.map +1 -0
- package/dist/tui/screens/resources/FunctionDetail.d.ts +7 -0
- package/dist/tui/screens/resources/FunctionDetail.js +751 -0
- package/dist/tui/screens/resources/FunctionDetail.js.map +1 -0
- package/dist/ui/attach.d.ts +15 -0
- package/dist/ui/attach.js +63 -0
- package/dist/ui/attach.js.map +1 -0
- package/dist/ui/baremetal-resolve.d.ts +10 -0
- package/dist/ui/baremetal-resolve.js +50 -0
- package/dist/ui/baremetal-resolve.js.map +1 -0
- package/dist/ui/confirm.js +1 -1
- package/dist/ui/confirm.js.map +1 -1
- package/dist/ui/cycle.d.ts +66 -0
- package/dist/ui/cycle.js +96 -0
- package/dist/ui/cycle.js.map +1 -0
- package/dist/ui/deploy-ui.d.ts +75 -0
- package/dist/ui/deploy-ui.js +243 -0
- package/dist/ui/deploy-ui.js.map +1 -0
- package/dist/ui/order-result.d.ts +4 -0
- package/dist/ui/order-result.js +32 -0
- package/dist/ui/order-result.js.map +1 -0
- package/dist/ui/payment-gate.d.ts +26 -0
- package/dist/ui/payment-gate.js +70 -0
- package/dist/ui/payment-gate.js.map +1 -0
- package/dist/ui/payment.js +10 -3
- package/dist/ui/payment.js.map +1 -1
- package/dist/ui/portal.d.ts +1 -1
- package/dist/ui/portal.js +7 -2
- package/dist/ui/portal.js.map +1 -1
- package/dist/ui/project-resolve.d.ts +25 -0
- package/dist/ui/project-resolve.js +31 -0
- package/dist/ui/project-resolve.js.map +1 -0
- package/dist/ui/render-mode.d.ts +5 -0
- package/dist/ui/render-mode.js +1 -1
- package/dist/ui/render-mode.js.map +1 -1
- package/dist/ui/resource-detail.js +0 -3
- package/dist/ui/resource-detail.js.map +1 -1
- package/dist/ui/resource-resolve.d.ts +9 -2
- package/dist/ui/resource-resolve.js +11 -4
- package/dist/ui/resource-resolve.js.map +1 -1
- package/dist/ui/spinner.d.ts +10 -1
- package/dist/ui/spinner.js +12 -3
- package/dist/ui/spinner.js.map +1 -1
- package/dist/ui/table.d.ts +7 -0
- package/dist/ui/table.js +11 -0
- package/dist/ui/table.js.map +1 -1
- package/dist/ui/tax.d.ts +10 -0
- package/dist/ui/tax.js +31 -0
- package/dist/ui/tax.js.map +1 -0
- package/dist/ui/ticket-resolve.d.ts +9 -1
- package/dist/ui/ticket-resolve.js +13 -2
- package/dist/ui/ticket-resolve.js.map +1 -1
- package/dist/ui/volume-resolve.js +4 -1
- package/dist/ui/volume-resolve.js.map +1 -1
- package/dist/ui/wait.d.ts +4 -0
- package/dist/ui/wait.js +7 -2
- package/dist/ui/wait.js.map +1 -1
- package/dist/ui/wizard.d.ts +2 -1
- package/dist/ui/wizard.js +1 -1
- package/dist/ui/wizard.js.map +1 -1
- package/dist/version-check-bin.js +2 -2
- package/dist/version-check-bin.js.map +1 -1
- package/dist/version-check.d.ts +5 -0
- package/dist/version-check.js +6 -1
- package/dist/version-check.js.map +1 -1
- package/package.json +53 -6
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { existsSync, statSync, readdirSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { BaseCommand } from "../../base/command.js";
|
|
5
|
+
import { panel, isInteractive } from "../../ui/wizard.js";
|
|
6
|
+
import { ensurePaymentMethod, PaymentMethodRequired } from "../../ui/payment-gate.js";
|
|
7
|
+
import { withSpinner } from "../../ui/spinner.js";
|
|
8
|
+
import { ok, dim, statusColor } from "../../ui/glyphs.js";
|
|
9
|
+
import { resolveFunction } from "../../functions-support/resolve.js";
|
|
10
|
+
import { functionLink } from "../../functions-support/link.js";
|
|
11
|
+
import { linkKind } from "../../config/store.js";
|
|
12
|
+
import { HANDLER_ENTRIES, RUNTIMES, RUNTIME_LABELS, STARTERS, entryFor, inferRuntime, } from "../../functions-support/runtime.js";
|
|
13
|
+
/**
|
|
14
|
+
* `synteq function init` — one command from an empty directory to a function
|
|
15
|
+
* you can deploy. It is the second step of the grammar the portal's New
|
|
16
|
+
* Function wizard prints:
|
|
17
|
+
*
|
|
18
|
+
* synteq login
|
|
19
|
+
* synteq function init <slug>
|
|
20
|
+
* synteq function deploy --name <slug>
|
|
21
|
+
*
|
|
22
|
+
* Three things happen, each skipped when already done, so re-running is a
|
|
23
|
+
* no-op that says so:
|
|
24
|
+
* 1. The function is reused when a function with that slug already exists,
|
|
25
|
+
* otherwise the name is checked (POST /functions/check-name) and created.
|
|
26
|
+
* 2. A starter handler is written when the directory has neither a
|
|
27
|
+
* recognised handler entry nor a Dockerfile. An existing file is never
|
|
28
|
+
* overwritten.
|
|
29
|
+
* 3. The directory is linked to the function, so every later
|
|
30
|
+
* `synteq function …` in this tree resolves it without --name.
|
|
31
|
+
*/
|
|
32
|
+
export default class FunctionInit extends BaseCommand {
|
|
33
|
+
static apiKeyScope = "none";
|
|
34
|
+
static description = [
|
|
35
|
+
"Scaffold a function in this directory and link it for flag-free deploys.",
|
|
36
|
+
"",
|
|
37
|
+
"Reuses an existing function of the same name, otherwise creates one. Writes",
|
|
38
|
+
"a starter handler only when the directory has no recognised entry file and",
|
|
39
|
+
"no Dockerfile — an existing file is never overwritten. Re-running is a",
|
|
40
|
+
"no-op that reports what was already in place.",
|
|
41
|
+
].join("\n");
|
|
42
|
+
static examples = [
|
|
43
|
+
"<%= config.bin %> function init my-fn",
|
|
44
|
+
"<%= config.bin %> function init my-fn --runtime python312",
|
|
45
|
+
"<%= config.bin %> function init my-fn --dir ./api --location dfw",
|
|
46
|
+
"<%= config.bin %> function init my-fn --no-scaffold # link only; bring your own handler",
|
|
47
|
+
"<%= config.bin %> function init my-fn -o json",
|
|
48
|
+
];
|
|
49
|
+
static args = {
|
|
50
|
+
name: Args.string({
|
|
51
|
+
description: "Function name/slug. Optional when this directory is already linked to a function.",
|
|
52
|
+
}),
|
|
53
|
+
};
|
|
54
|
+
static flags = {
|
|
55
|
+
runtime: Flags.string({
|
|
56
|
+
options: [...RUNTIMES],
|
|
57
|
+
description: `Handler runtime for a newly created function: ${RUNTIMES.join(" or ")} (default: node22, or whatever the directory's files already imply).`,
|
|
58
|
+
}),
|
|
59
|
+
plan: Flags.string({
|
|
60
|
+
description: "Plan tier slug for a newly created function (default: the first tier in the catalog).",
|
|
61
|
+
}),
|
|
62
|
+
location: Flags.string({
|
|
63
|
+
description: "Location code, e.g. dfw, for a newly created function (default: the first location).",
|
|
64
|
+
}),
|
|
65
|
+
dir: Flags.string({
|
|
66
|
+
description: "Directory to scaffold and link (default: the current directory).",
|
|
67
|
+
}),
|
|
68
|
+
"no-scaffold": Flags.boolean({
|
|
69
|
+
description: "Don't write a starter handler; only create/reuse the function and link the directory.",
|
|
70
|
+
}),
|
|
71
|
+
project: Flags.string({
|
|
72
|
+
description: "Project id to create/look the function up in (defaults to the active project).",
|
|
73
|
+
}),
|
|
74
|
+
"from-deploy": Flags.boolean({
|
|
75
|
+
hidden: true,
|
|
76
|
+
description: "Internal: called by `function deploy` on a first run; skips the next-steps hint.",
|
|
77
|
+
}),
|
|
78
|
+
};
|
|
79
|
+
async run() {
|
|
80
|
+
await this.initClients();
|
|
81
|
+
const { args, flags } = await this.parse(FunctionInit);
|
|
82
|
+
try {
|
|
83
|
+
const dir = resolve(flags.dir && flags.dir !== "" ? flags.dir : ".");
|
|
84
|
+
if (!existsSync(dir) || !statSync(dir).isDirectory()) {
|
|
85
|
+
this.error(`Not a directory: ${dir}`, { exit: 1 });
|
|
86
|
+
}
|
|
87
|
+
// A name is optional only when this directory already points at a function.
|
|
88
|
+
const existingLink = this.clients.config.linkFor(dir);
|
|
89
|
+
let name = args.name;
|
|
90
|
+
if (!name) {
|
|
91
|
+
if (existingLink && linkKind(existingLink) === "function") {
|
|
92
|
+
name = existingLink.app_slug;
|
|
93
|
+
}
|
|
94
|
+
else {
|
|
95
|
+
this.error("Give the function a name: `synteq function init <name>`. (A name is optional only in a directory already linked to a function.)", { exit: 1 });
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
// 1. Reuse or create.
|
|
99
|
+
const topLevel = readdirSync(dir);
|
|
100
|
+
const inferred = inferRuntime(topLevel);
|
|
101
|
+
const runtime = flags.runtime ?? inferred ?? "node22";
|
|
102
|
+
let fn;
|
|
103
|
+
let created = false;
|
|
104
|
+
const found = await resolveFunction(this.clients.api, name, flags.project).catch((e) => {
|
|
105
|
+
// A plain Error is "no such function" — the create path. An ApiError
|
|
106
|
+
// (has `status`) is a real fault and must propagate.
|
|
107
|
+
if (e instanceof Error && !("status" in e))
|
|
108
|
+
return null;
|
|
109
|
+
throw e;
|
|
110
|
+
});
|
|
111
|
+
if (found) {
|
|
112
|
+
fn = found;
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
const check = await withSpinner(`Checking ${name}`, () => this.clients.api.functions.checkName(name));
|
|
116
|
+
if (!check.available) {
|
|
117
|
+
this.error(`The name "${name}" isn't available${check.reason ? `: ${check.reason}` : "."}`, { exit: 1 });
|
|
118
|
+
}
|
|
119
|
+
// Every tier needs a payment method on the team, free included.
|
|
120
|
+
await ensurePaymentMethod({
|
|
121
|
+
api: this.clients.api,
|
|
122
|
+
apiBaseUrl: this.clients.config.get().api_base_url,
|
|
123
|
+
interactive: isInteractive() && this.outputFormat === "table",
|
|
124
|
+
log: (l) => this.log(l),
|
|
125
|
+
action: "create the function",
|
|
126
|
+
}).catch((e) => {
|
|
127
|
+
if (e instanceof PaymentMethodRequired)
|
|
128
|
+
this.error(e.message, { exit: 1 });
|
|
129
|
+
throw e;
|
|
130
|
+
});
|
|
131
|
+
const body = {
|
|
132
|
+
name: name,
|
|
133
|
+
planTier: flags.plan ?? (await this.defaultPlan()),
|
|
134
|
+
runtime,
|
|
135
|
+
};
|
|
136
|
+
const locationId = await this.resolveLocation(flags.location);
|
|
137
|
+
if (locationId)
|
|
138
|
+
body.locationId = locationId;
|
|
139
|
+
fn = await withSpinner(`Creating ${name}`, () => this.clients.api.functions.create(body, flags.project));
|
|
140
|
+
created = true;
|
|
141
|
+
}
|
|
142
|
+
// 2. Scaffold, unless the directory already says what it runs.
|
|
143
|
+
const fnRuntime = RUNTIMES.includes(fn.runtime)
|
|
144
|
+
? fn.runtime
|
|
145
|
+
: runtime;
|
|
146
|
+
const hasDockerfile = topLevel.includes("Dockerfile");
|
|
147
|
+
let entryFile = null;
|
|
148
|
+
let entryKept = false;
|
|
149
|
+
if (flags["no-scaffold"]) {
|
|
150
|
+
// nothing to write
|
|
151
|
+
}
|
|
152
|
+
else if (inferred || hasDockerfile) {
|
|
153
|
+
entryKept = true;
|
|
154
|
+
entryFile = inferred ? this.existingEntry(topLevel, inferred) : "Dockerfile";
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
const candidate = entryFor(fnRuntime);
|
|
158
|
+
const target = join(dir, candidate);
|
|
159
|
+
if (existsSync(target)) {
|
|
160
|
+
// A file with the entry name exists but wasn't recognised as an
|
|
161
|
+
// entry (e.g. a directory named index.mjs). Never clobber it.
|
|
162
|
+
entryKept = true;
|
|
163
|
+
entryFile = candidate;
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
writeFileSync(target, STARTERS[fnRuntime], { encoding: "utf8", flag: "wx" });
|
|
167
|
+
entryFile = candidate;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// 3. Link the directory.
|
|
171
|
+
const alreadyLinked = existingLink !== undefined &&
|
|
172
|
+
linkKind(existingLink) === "function" &&
|
|
173
|
+
existingLink.app_id === fn.id;
|
|
174
|
+
const teamId = await this.resolveTeamId();
|
|
175
|
+
const projectId = flags.project ?? existingLink?.project_id ?? (await this.resolveProjectId(teamId));
|
|
176
|
+
this.clients.config.setLink(dir, functionLink(fn, teamId, projectId));
|
|
177
|
+
const payload = {
|
|
178
|
+
directory: dir,
|
|
179
|
+
created,
|
|
180
|
+
alreadyLinked,
|
|
181
|
+
entryFile,
|
|
182
|
+
entryWritten: Boolean(entryFile) && !entryKept,
|
|
183
|
+
function: fn,
|
|
184
|
+
};
|
|
185
|
+
this.emit(payload, () => {
|
|
186
|
+
const noop = !created && alreadyLinked && (entryKept || !entryFile);
|
|
187
|
+
this.log("");
|
|
188
|
+
this.log(panel(created ? "Function created" : noop ? "Already set up" : "Function linked", [
|
|
189
|
+
["Slug", fn.slug],
|
|
190
|
+
["Hostname", fn.hostname],
|
|
191
|
+
["Status", statusColor(fn.status)],
|
|
192
|
+
["Runtime", `${fn.runtime} ${dim(RUNTIME_LABELS[fnRuntime] ?? "")}`.trim()],
|
|
193
|
+
["Directory", dir],
|
|
194
|
+
[
|
|
195
|
+
"Entry",
|
|
196
|
+
entryFile
|
|
197
|
+
? entryKept
|
|
198
|
+
? `${entryFile} ${dim("(kept existing)")}`
|
|
199
|
+
: `${entryFile} ${dim("(written)")}`
|
|
200
|
+
: dim("no scaffold"),
|
|
201
|
+
],
|
|
202
|
+
]));
|
|
203
|
+
this.log("");
|
|
204
|
+
if (noop)
|
|
205
|
+
this.log(dim("Nothing to do — this directory was already initialised."));
|
|
206
|
+
if (!flags["from-deploy"]) {
|
|
207
|
+
this.log(ok(`Deploy it: synteq function deploy --name ${fn.slug}`));
|
|
208
|
+
this.log(dim(" (or just `synteq function deploy` from this directory)"));
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
catch (err) {
|
|
213
|
+
this.fail(err);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
/** Which recognised entry filename the directory actually carries — the
|
|
217
|
+
* first HANDLER_ENTRIES hit, i.e. the one the backend's shaping step picks. */
|
|
218
|
+
existingEntry(names, rt) {
|
|
219
|
+
const set = new Set(names);
|
|
220
|
+
return HANDLER_ENTRIES[rt].find((e) => set.has(e)) ?? entryFor(rt);
|
|
221
|
+
}
|
|
222
|
+
async defaultPlan() {
|
|
223
|
+
const plans = await this.clients.api.functions.plans();
|
|
224
|
+
if (plans.length === 0) {
|
|
225
|
+
this.error("No function plans are available on this account.", { exit: 1 });
|
|
226
|
+
}
|
|
227
|
+
return plans[0].name;
|
|
228
|
+
}
|
|
229
|
+
async resolveLocation(code) {
|
|
230
|
+
const locations = await this.clients.api.functions.locations();
|
|
231
|
+
if (locations.length === 0) {
|
|
232
|
+
if (code)
|
|
233
|
+
this.error(`Unknown location "${code}" — no locations are available.`, { exit: 1 });
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
if (!code)
|
|
237
|
+
return locations[0].locationId;
|
|
238
|
+
const hit = locations.find((l) => l.code.toLowerCase() === code.toLowerCase());
|
|
239
|
+
if (!hit) {
|
|
240
|
+
this.error(`Unknown location "${code}". Available: ${locations.map((l) => l.code).join(", ")}.`, { exit: 1 });
|
|
241
|
+
}
|
|
242
|
+
return hit.locationId;
|
|
243
|
+
}
|
|
244
|
+
/** The team the link records: the active team, else the default team. */
|
|
245
|
+
async resolveTeamId() {
|
|
246
|
+
const configured = this.clients.config.get().active_team_id;
|
|
247
|
+
if (configured)
|
|
248
|
+
return configured;
|
|
249
|
+
const teams = await this.clients.api.auth.teams();
|
|
250
|
+
if (teams.length === 0) {
|
|
251
|
+
this.error("No teams on this account — sign in to the portal to create one.", { exit: 1 });
|
|
252
|
+
}
|
|
253
|
+
return (teams.find((t) => t.is_default) ?? teams[0]).id;
|
|
254
|
+
}
|
|
255
|
+
/** The project the link records: the configured default, else the team's. */
|
|
256
|
+
async resolveProjectId(teamId) {
|
|
257
|
+
const configured = this.clients.config.get().default_project_id;
|
|
258
|
+
if (configured)
|
|
259
|
+
return configured;
|
|
260
|
+
const projects = await this.clients.api.projects.list();
|
|
261
|
+
const inTeam = projects.filter((p) => !teamId || p.team_id === teamId);
|
|
262
|
+
const pool = inTeam.length > 0 ? inTeam : projects;
|
|
263
|
+
if (pool.length === 0) {
|
|
264
|
+
this.error("This team has no projects — create one in the portal first.", { exit: 1 });
|
|
265
|
+
}
|
|
266
|
+
return (pool.find((p) => p.is_default) ?? pool[0]).id;
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../../src/commands/function/init.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC3E,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CAAC;AACrE,OAAO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,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC1D,CAAC;IAED,6EAA6E;IACrE,KAAK,CAAC,gBAAgB,CAAC,MAAc;QAC3C,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,CAAC,kBAAkB,CAAC;QAChE,IAAI,UAAU;YAAE,OAAO,UAAU,CAAC;QAClC,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxD,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,OAAO,KAAK,MAAM,CAAC,CAAC;QACvE,MAAM,IAAI,GAAG,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC;QACnD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,KAAK,CAAC,6DAA6D,EAAE,EAAE,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC;QACzF,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACxD,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { BaseCommand } from "../../base/command.js";
|
|
2
|
+
/**
|
|
3
|
+
* `synteq function invoke` — call a deployed function over HTTPS.
|
|
4
|
+
*
|
|
5
|
+
* This one does NOT go through ApiClient: a function is served from its own
|
|
6
|
+
* hostname, not the portal API, and it takes no Synteq auth. It's a plain
|
|
7
|
+
* fetch, so the response is whatever the handler returned.
|
|
8
|
+
*
|
|
9
|
+
* `--insecure` is honoured here the same way ApiClient honours it (an undici
|
|
10
|
+
* dispatcher with certificate verification off) so a locally-served function
|
|
11
|
+
* behind a self-signed cert can be invoked in dev.
|
|
12
|
+
*/
|
|
13
|
+
export default class FunctionInvoke extends BaseCommand {
|
|
14
|
+
static apiKeyScope: string;
|
|
15
|
+
static description: string;
|
|
16
|
+
static examples: string[];
|
|
17
|
+
static args: {
|
|
18
|
+
name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
19
|
+
};
|
|
20
|
+
static flags: {
|
|
21
|
+
name: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
22
|
+
path: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
23
|
+
method: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
24
|
+
data: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
25
|
+
"content-type": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
26
|
+
header: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
27
|
+
};
|
|
28
|
+
run(): Promise<void>;
|
|
29
|
+
}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { BaseCommand } from "../../base/command.js";
|
|
3
|
+
import { resolveLinkedFunction } from "../../functions-support/link.js";
|
|
4
|
+
import { statusColor, dim, cyan, G } from "../../ui/glyphs.js";
|
|
5
|
+
/**
|
|
6
|
+
* `synteq function invoke` — call a deployed function over HTTPS.
|
|
7
|
+
*
|
|
8
|
+
* This one does NOT go through ApiClient: a function is served from its own
|
|
9
|
+
* hostname, not the portal API, and it takes no Synteq auth. It's a plain
|
|
10
|
+
* fetch, so the response is whatever the handler returned.
|
|
11
|
+
*
|
|
12
|
+
* `--insecure` is honoured here the same way ApiClient honours it (an undici
|
|
13
|
+
* dispatcher with certificate verification off) so a locally-served function
|
|
14
|
+
* behind a self-signed cert can be invoked in dev.
|
|
15
|
+
*/
|
|
16
|
+
export default class FunctionInvoke extends BaseCommand {
|
|
17
|
+
static apiKeyScope = "none";
|
|
18
|
+
static description = [
|
|
19
|
+
"Invoke a deployed function over HTTPS and print its response.",
|
|
20
|
+
"",
|
|
21
|
+
"A plain HTTP request to the function's hostname — no Synteq credentials are",
|
|
22
|
+
"attached, so what you see is exactly what any caller sees. JSON bodies are",
|
|
23
|
+
"pretty-printed; anything else is printed as-is.",
|
|
24
|
+
].join("\n");
|
|
25
|
+
static examples = [
|
|
26
|
+
"<%= config.bin %> function invoke # bare: GET / on the linked function",
|
|
27
|
+
"<%= config.bin %> function invoke my-fn --path /health",
|
|
28
|
+
`<%= config.bin %> function invoke my-fn --method POST --data '{"x":1}'`,
|
|
29
|
+
'<%= config.bin %> function invoke my-fn --header "X-Trace: abc" --header "Accept: text/plain"',
|
|
30
|
+
"<%= config.bin %> function invoke my-fn -o json # {status, ms, headers, body}",
|
|
31
|
+
];
|
|
32
|
+
static args = {
|
|
33
|
+
name: Args.string({
|
|
34
|
+
description: "Function slug (or uuid). Omit to use this directory's linked function.",
|
|
35
|
+
}),
|
|
36
|
+
};
|
|
37
|
+
static flags = {
|
|
38
|
+
name: Flags.string({
|
|
39
|
+
description: "Function slug (or uuid) — the flag form of the positional arg.",
|
|
40
|
+
}),
|
|
41
|
+
path: Flags.string({
|
|
42
|
+
default: "/",
|
|
43
|
+
description: "Request path (and query string) to call (default: /).",
|
|
44
|
+
}),
|
|
45
|
+
method: Flags.string({
|
|
46
|
+
default: "GET",
|
|
47
|
+
description: "HTTP method (default: GET).",
|
|
48
|
+
}),
|
|
49
|
+
data: Flags.string({
|
|
50
|
+
char: "d",
|
|
51
|
+
description: "Request body. Sets Content-Type: application/json unless --content-type says otherwise.",
|
|
52
|
+
}),
|
|
53
|
+
"content-type": Flags.string({
|
|
54
|
+
description: "Content-Type for --data (default: application/json).",
|
|
55
|
+
}),
|
|
56
|
+
header: Flags.string({
|
|
57
|
+
multiple: true,
|
|
58
|
+
description: "Extra request header as KEY:VALUE. Repeat for more than one.",
|
|
59
|
+
}),
|
|
60
|
+
};
|
|
61
|
+
async run() {
|
|
62
|
+
await this.initClients();
|
|
63
|
+
const { args, flags } = await this.parse(FunctionInvoke);
|
|
64
|
+
try {
|
|
65
|
+
const { fn, clients } = await resolveLinkedFunction(this.clients, {
|
|
66
|
+
...flags,
|
|
67
|
+
name: args.name ?? flags.name,
|
|
68
|
+
}).catch((e) => {
|
|
69
|
+
if (e instanceof Error && !("status" in e))
|
|
70
|
+
this.error(e.message, { exit: 1 });
|
|
71
|
+
throw e;
|
|
72
|
+
});
|
|
73
|
+
this.clients = clients;
|
|
74
|
+
const path = flags.path.startsWith("/") ? flags.path : `/${flags.path}`;
|
|
75
|
+
const url = /^https?:\/\//.test(fn.hostname)
|
|
76
|
+
? `${fn.hostname.replace(/\/+$/, "")}${path}`
|
|
77
|
+
: `https://${fn.hostname}${path}`;
|
|
78
|
+
const headers = {};
|
|
79
|
+
for (const raw of flags.header ?? []) {
|
|
80
|
+
const colon = raw.indexOf(":");
|
|
81
|
+
if (colon <= 0) {
|
|
82
|
+
this.error(`Bad --header "${raw}". Use KEY:VALUE (e.g. --header "X-Trace: abc").`, {
|
|
83
|
+
exit: 1,
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
headers[raw.slice(0, colon).trim()] = raw.slice(colon + 1).trim();
|
|
87
|
+
}
|
|
88
|
+
if (flags.data != null && !Object.keys(headers).some((h) => h.toLowerCase() === "content-type")) {
|
|
89
|
+
headers["Content-Type"] = flags["content-type"] ?? "application/json";
|
|
90
|
+
}
|
|
91
|
+
const init = {
|
|
92
|
+
method: flags.method.toUpperCase(),
|
|
93
|
+
headers,
|
|
94
|
+
body: flags.data,
|
|
95
|
+
};
|
|
96
|
+
if (flags.insecure) {
|
|
97
|
+
const { Agent } = (await import("undici"));
|
|
98
|
+
init.dispatcher = new Agent({ connect: { rejectUnauthorized: false } });
|
|
99
|
+
}
|
|
100
|
+
const started = Date.now();
|
|
101
|
+
let res;
|
|
102
|
+
try {
|
|
103
|
+
res = await fetch(url, init);
|
|
104
|
+
}
|
|
105
|
+
catch (e) {
|
|
106
|
+
this.error(`Could not reach ${url}: ${e.message}`, { exit: 3 });
|
|
107
|
+
}
|
|
108
|
+
const ms = Date.now() - started;
|
|
109
|
+
const text = await res.text();
|
|
110
|
+
const responseHeaders = {};
|
|
111
|
+
res.headers.forEach((v, k) => {
|
|
112
|
+
responseHeaders[k] = v;
|
|
113
|
+
});
|
|
114
|
+
let parsed;
|
|
115
|
+
let isJson = false;
|
|
116
|
+
try {
|
|
117
|
+
parsed = JSON.parse(text);
|
|
118
|
+
isJson = true;
|
|
119
|
+
}
|
|
120
|
+
catch {
|
|
121
|
+
parsed = text;
|
|
122
|
+
}
|
|
123
|
+
this.emit({ status: res.status, ms, headers: responseHeaders, body: parsed }, () => {
|
|
124
|
+
this.log(`${statusColor(`${res.status} ${res.statusText}`.trim())} ${dim(G.bullet)} ${ms}ms ${dim(G.bullet)} ${cyan(url)}`);
|
|
125
|
+
this.log("");
|
|
126
|
+
this.log(isJson ? JSON.stringify(parsed, null, 2) : text);
|
|
127
|
+
});
|
|
128
|
+
// A non-2xx is the function's answer, not a CLI failure — but scripts
|
|
129
|
+
// still want a signal, so mirror curl --fail's spirit on 5xx only.
|
|
130
|
+
if (res.status >= 500)
|
|
131
|
+
this.exit(1);
|
|
132
|
+
}
|
|
133
|
+
catch (err) {
|
|
134
|
+
this.fail(err);
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
//# sourceMappingURL=invoke.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invoke.js","sourceRoot":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GAAG,CACtF,CAAC,CAAC,MAAM,CACT,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CACjB,CAAC;gBACF,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;gBACb,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;YAC5D,CAAC,CAAC,CAAC;YAEH,sEAAsE;YACtE,mEAAmE;YACnE,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG;gBAAE,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACtC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACjB,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { BaseCommand } from "../../base/command.js";
|
|
2
|
+
/**
|
|
3
|
+
* `synteq function link [name]` — link this directory to a function without
|
|
4
|
+
* touching its files: `function init <name> --no-scaffold`, with a picker
|
|
5
|
+
* when no name is given on a TTY. The apps side is `synteq app link`.
|
|
6
|
+
*/
|
|
7
|
+
export default class FunctionLink extends BaseCommand {
|
|
8
|
+
static apiKeyScope: string;
|
|
9
|
+
static description: string;
|
|
10
|
+
static examples: string[];
|
|
11
|
+
static args: {
|
|
12
|
+
name: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
|
|
13
|
+
};
|
|
14
|
+
static flags: {
|
|
15
|
+
dir: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
16
|
+
project: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
17
|
+
"no-interactive": import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
18
|
+
};
|
|
19
|
+
run(): Promise<void>;
|
|
20
|
+
/** One of the project's functions, or a name for a new one (created with
|
|
21
|
+
* init's defaults — plan and location prompts follow on a TTY). */
|
|
22
|
+
private pick;
|
|
23
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Args, Flags } from "@oclif/core";
|
|
2
|
+
import { BaseCommand } from "../../base/command.js";
|
|
3
|
+
import FunctionInit from "./init.js";
|
|
4
|
+
import { withSpinner } from "../../ui/spinner.js";
|
|
5
|
+
import { dim } from "../../ui/glyphs.js";
|
|
6
|
+
import { isInteractive, pickFromCatalog, promptString } from "../../ui/wizard.js";
|
|
7
|
+
import { slugify } from "../link.js";
|
|
8
|
+
const CREATE = "\0create";
|
|
9
|
+
/**
|
|
10
|
+
* `synteq function link [name]` — link this directory to a function without
|
|
11
|
+
* touching its files: `function init <name> --no-scaffold`, with a picker
|
|
12
|
+
* when no name is given on a TTY. The apps side is `synteq app link`.
|
|
13
|
+
*/
|
|
14
|
+
export default class FunctionLink extends BaseCommand {
|
|
15
|
+
static apiKeyScope = "none";
|
|
16
|
+
static description = [
|
|
17
|
+
"Link the current directory to a function: name one by slug or id, or pick one on a TTY.",
|
|
18
|
+
"Nothing is written to the directory (`function init` is the one that scaffolds a",
|
|
19
|
+
"handler). A linked directory deploys with a bare `synteq function deploy`.",
|
|
20
|
+
].join("\n");
|
|
21
|
+
static examples = [
|
|
22
|
+
"<%= config.bin %> function link # interactive: pick one of the project's functions, or create one",
|
|
23
|
+
"<%= config.bin %> function link my-fn # straight to an existing function by slug",
|
|
24
|
+
"<%= config.bin %> function link 01931234-... # or by id",
|
|
25
|
+
"<%= config.bin %> function link my-fn --dir ./api --project 01931234-...",
|
|
26
|
+
];
|
|
27
|
+
static args = {
|
|
28
|
+
name: Args.string({
|
|
29
|
+
description: "Function slug (or uuid) to link to. Omit on a TTY to pick from the project's functions.",
|
|
30
|
+
}),
|
|
31
|
+
};
|
|
32
|
+
static flags = {
|
|
33
|
+
dir: Flags.string({ description: "Directory to link (default: the current directory)." }),
|
|
34
|
+
project: Flags.string({
|
|
35
|
+
description: "Project id to look the function up in, and whose functions the picker lists (default: the active project).",
|
|
36
|
+
}),
|
|
37
|
+
"no-interactive": Flags.boolean({ description: "Never prompt; requires a name (errors when it's missing)." }),
|
|
38
|
+
};
|
|
39
|
+
async run() {
|
|
40
|
+
await this.initClients();
|
|
41
|
+
const { args, flags } = await this.parse(FunctionLink);
|
|
42
|
+
try {
|
|
43
|
+
let name = args.name;
|
|
44
|
+
if (!name) {
|
|
45
|
+
if (!isInteractive() || this.outputFormat !== "table" || flags["no-interactive"]) {
|
|
46
|
+
this.error("Provide a function slug or id (or run on a TTY to pick one).", { exit: 1 });
|
|
47
|
+
}
|
|
48
|
+
name = await this.pick(flags.project ?? this.clients.config.get().default_project_id ?? undefined);
|
|
49
|
+
}
|
|
50
|
+
const argv = [name, "--no-scaffold"];
|
|
51
|
+
if (flags.dir)
|
|
52
|
+
argv.push("--dir", flags.dir);
|
|
53
|
+
if (flags.project)
|
|
54
|
+
argv.push("--project", flags.project);
|
|
55
|
+
await FunctionInit.run(argv, this.config);
|
|
56
|
+
}
|
|
57
|
+
catch (err) {
|
|
58
|
+
this.fail(err);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
/** One of the project's functions, or a name for a new one (created with
|
|
62
|
+
* init's defaults — plan and location prompts follow on a TTY). */
|
|
63
|
+
async pick(projectId) {
|
|
64
|
+
const fns = await withSpinner("Loading functions", () => this.clients.api.functions.list(projectId));
|
|
65
|
+
const items = [
|
|
66
|
+
...fns.map((f) => ({ value: f.id, name: f.slug, description: `${f.status} · ${f.runtime} · ${f.region}` })),
|
|
67
|
+
{ value: CREATE, name: "Create a new function…", description: "Name it; plan and location follow." },
|
|
68
|
+
];
|
|
69
|
+
if (fns.length === 0)
|
|
70
|
+
this.log(dim("No functions in this project yet."));
|
|
71
|
+
const choice = fns.length === 0 ? CREATE : await pickFromCatalog("Which function should this directory deploy?", items);
|
|
72
|
+
if (choice !== CREATE)
|
|
73
|
+
return choice;
|
|
74
|
+
const raw = await promptString("Function name", {
|
|
75
|
+
validate: (s) => (slugify(s).length >= 2 ? true : "At least two letters or digits."),
|
|
76
|
+
});
|
|
77
|
+
return slugify(raw);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=link.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"link.js","sourceRoot":"","sources":["../../../src/commands/function/link.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,YAAY,MAAM,WAAW,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,YAAY,EAAwB,MAAM,oBAAoB,CAAC;AACxG,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAErC,MAAM,MAAM,GAAG,UAAU,CAAC;AAE1B;;;;GAIG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IACnD,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,WAAW,GAAG;QACnB,yFAAyF;QACzF,kFAAkF;QAClF,4EAA4E;KAC7E,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACb,MAAM,CAAC,QAAQ,GAAG;QAChB,mHAAmH;QACnH,4FAA4F;QAC5F,4DAA4D;QAC5D,0EAA0E;KAC3E,CAAC;IACF,MAAM,CAAC,IAAI,GAAG;QACZ,IAAI,EAAE,IAAI,CAAC,MAAM,CAAC;YAChB,WAAW,EAAE,yFAAyF;SACvG,CAAC;KACH,CAAC;IACF,MAAM,CAAC,KAAK,GAAG;QACb,GAAG,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,WAAW,EAAE,qD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AAG,CAAC,CAAC;IACtB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { BaseCommand } from "../../base/command.js";
|
|
2
|
+
/**
|
|
3
|
+
* `synteq function list` — serverless functions in the active project.
|
|
4
|
+
*
|
|
5
|
+
* Backend: GET /functions. Scoping matches `apps list` — the server resolves
|
|
6
|
+
* the active project from the `X-Project-Id` header, so `--project` overrides it.
|
|
7
|
+
*/
|
|
8
|
+
export default class FunctionList extends BaseCommand {
|
|
9
|
+
static apiKeyScope: string;
|
|
10
|
+
static description: string;
|
|
11
|
+
static examples: string[];
|
|
12
|
+
static flags: {
|
|
13
|
+
project: import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Flags } from "@oclif/core";
|
|
2
|
+
import { BaseCommand } from "../../base/command.js";
|
|
3
|
+
import { renderTable, shortId, truncationNote } from "../../ui/table.js";
|
|
4
|
+
import { statusColor } from "../../ui/glyphs.js";
|
|
5
|
+
/**
|
|
6
|
+
* `synteq function list` — serverless functions in the active project.
|
|
7
|
+
*
|
|
8
|
+
* Backend: GET /functions. Scoping matches `apps list` — the server resolves
|
|
9
|
+
* the active project from the `X-Project-Id` header, so `--project` overrides it.
|
|
10
|
+
*/
|
|
11
|
+
export default class FunctionList extends BaseCommand {
|
|
12
|
+
static apiKeyScope = "none";
|
|
13
|
+
static description = "List serverless functions in the active project.";
|
|
14
|
+
static examples = [
|
|
15
|
+
"<%= config.bin %> function list",
|
|
16
|
+
"<%= config.bin %> function list --project 019e... # scope to a specific project",
|
|
17
|
+
"<%= config.bin %> function list -o json",
|
|
18
|
+
];
|
|
19
|
+
static flags = {
|
|
20
|
+
project: Flags.string({
|
|
21
|
+
description: "Project id to scope to (defaults to the active project).",
|
|
22
|
+
}),
|
|
23
|
+
};
|
|
24
|
+
async run() {
|
|
25
|
+
await this.initClients();
|
|
26
|
+
const { flags } = await this.parse(FunctionList);
|
|
27
|
+
try {
|
|
28
|
+
const page = await this.clients.api.functions.listPage(flags.project);
|
|
29
|
+
const fns = page.items;
|
|
30
|
+
const note = truncationNote(fns.length, page.total, "--project");
|
|
31
|
+
this.emit(fns, () => {
|
|
32
|
+
if (fns.length === 0) {
|
|
33
|
+
this.log("No functions. Create one with `synteq function init <name>`.");
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
this.log(renderTable(["ID", "SLUG", "STATUS", "RUNTIME", "PLAN", "REGION", "REL", "HOSTNAME"], fns.map((f) => [
|
|
37
|
+
shortId(f.id),
|
|
38
|
+
f.slug,
|
|
39
|
+
statusColor(f.status),
|
|
40
|
+
f.runtime,
|
|
41
|
+
f.planTier,
|
|
42
|
+
f.region,
|
|
43
|
+
f.currentReleaseNumber != null ? String(f.currentReleaseNumber) : "—",
|
|
44
|
+
f.hostname,
|
|
45
|
+
])));
|
|
46
|
+
});
|
|
47
|
+
if (note)
|
|
48
|
+
this.info(note);
|
|
49
|
+
}
|
|
50
|
+
catch (err) {
|
|
51
|
+
this.fail(err);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=list.js.map
|