netlify-cli 19.1.1 → 19.1.3
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/commands/api/api.d.ts +4 -0
- package/dist/commands/api/api.d.ts.map +1 -0
- package/dist/commands/api/api.js +40 -0
- package/dist/commands/api/api.js.map +1 -0
- package/dist/commands/api/index.d.ts +3 -0
- package/dist/commands/api/index.d.ts.map +1 -0
- package/dist/commands/api/index.js +14 -0
- package/dist/commands/api/index.js.map +1 -0
- package/dist/commands/base-command.d.ts +85 -0
- package/dist/commands/base-command.d.ts.map +1 -0
- package/dist/commands/base-command.js +602 -0
- package/dist/commands/base-command.js.map +1 -0
- package/dist/commands/blobs/blobs-delete.d.ts +5 -0
- package/dist/commands/blobs/blobs-delete.d.ts.map +1 -0
- package/dist/commands/blobs/blobs-delete.js +27 -0
- package/dist/commands/blobs/blobs-delete.js.map +1 -0
- package/dist/commands/blobs/blobs-get.d.ts +8 -0
- package/dist/commands/blobs/blobs-get.d.ts.map +1 -0
- package/dist/commands/blobs/blobs-get.js +32 -0
- package/dist/commands/blobs/blobs-get.js.map +1 -0
- package/dist/commands/blobs/blobs-list.d.ts +10 -0
- package/dist/commands/blobs/blobs-list.d.ts.map +1 -0
- package/dist/commands/blobs/blobs-list.js +37 -0
- package/dist/commands/blobs/blobs-list.js.map +1 -0
- package/dist/commands/blobs/blobs-set.d.ts +9 -0
- package/dist/commands/blobs/blobs-set.d.ts.map +1 -0
- package/dist/commands/blobs/blobs-set.js +48 -0
- package/dist/commands/blobs/blobs-set.js.map +1 -0
- package/dist/commands/blobs/blobs.d.ts +6 -0
- package/dist/commands/blobs/blobs.d.ts.map +1 -0
- package/dist/commands/blobs/blobs.js +75 -0
- package/dist/commands/blobs/blobs.js.map +1 -0
- package/dist/commands/build/build.d.ts +6 -0
- package/dist/commands/build/build.d.ts.map +1 -0
- package/dist/commands/build/build.js +39 -0
- package/dist/commands/build/build.js.map +1 -0
- package/dist/commands/build/index.d.ts +3 -0
- package/dist/commands/build/index.d.ts.map +1 -0
- package/dist/commands/build/index.js +14 -0
- package/dist/commands/build/index.js.map +1 -0
- package/dist/commands/completion/completion.d.ts +5 -0
- package/dist/commands/completion/completion.d.ts.map +1 -0
- package/dist/commands/completion/completion.js +69 -0
- package/dist/commands/completion/completion.js.map +1 -0
- package/dist/commands/completion/index.d.ts +3 -0
- package/dist/commands/completion/index.d.ts.map +1 -0
- package/dist/commands/completion/index.js +27 -0
- package/dist/commands/completion/index.js.map +1 -0
- package/dist/commands/deploy/deploy.d.ts +4 -0
- package/dist/commands/deploy/deploy.d.ts.map +1 -0
- package/dist/commands/deploy/deploy.js +720 -0
- package/dist/commands/deploy/deploy.js.map +1 -0
- package/dist/commands/deploy/index.d.ts +3 -0
- package/dist/commands/deploy/index.d.ts.map +1 -0
- package/dist/commands/deploy/index.js +107 -0
- package/dist/commands/deploy/index.js.map +1 -0
- package/dist/commands/dev/dev-exec.d.ts +5 -0
- package/dist/commands/dev/dev-exec.d.ts.map +1 -0
- package/dist/commands/dev/dev-exec.js +21 -0
- package/dist/commands/dev/dev-exec.js.map +1 -0
- package/dist/commands/dev/dev.d.ts +5 -0
- package/dist/commands/dev/dev.d.ts.map +1 -0
- package/dist/commands/dev/dev.js +249 -0
- package/dist/commands/dev/dev.js.map +1 -0
- package/dist/commands/dev/index.d.ts +2 -0
- package/dist/commands/dev/index.d.ts.map +1 -0
- package/dist/commands/dev/index.js +2 -0
- package/dist/commands/dev/index.js.map +1 -0
- package/dist/commands/env/env-clone.d.ts +4 -0
- package/dist/commands/env/env-clone.d.ts.map +1 -0
- package/dist/commands/env/env-clone.js +83 -0
- package/dist/commands/env/env-clone.js.map +1 -0
- package/dist/commands/env/env-get.d.ts +4 -0
- package/dist/commands/env/env-get.d.ts.map +1 -0
- package/dist/commands/env/env-get.js +28 -0
- package/dist/commands/env/env-get.js.map +1 -0
- package/dist/commands/env/env-import.d.ts +4 -0
- package/dist/commands/env/env-import.d.ts.map +1 -0
- package/dist/commands/env/env-import.js +78 -0
- package/dist/commands/env/env-import.js.map +1 -0
- package/dist/commands/env/env-list.d.ts +4 -0
- package/dist/commands/env/env-list.d.ts.map +1 -0
- package/dist/commands/env/env-list.js +85 -0
- package/dist/commands/env/env-list.js.map +1 -0
- package/dist/commands/env/env-set.d.ts +4 -0
- package/dist/commands/env/env-set.d.ts.map +1 -0
- package/dist/commands/env/env-set.js +123 -0
- package/dist/commands/env/env-set.js.map +1 -0
- package/dist/commands/env/env-unset.d.ts +4 -0
- package/dist/commands/env/env-unset.d.ts.map +1 -0
- package/dist/commands/env/env-unset.js +76 -0
- package/dist/commands/env/env-unset.js.map +1 -0
- package/dist/commands/env/env.d.ts +3 -0
- package/dist/commands/env/env.d.ts.map +1 -0
- package/dist/commands/env/env.js +129 -0
- package/dist/commands/env/env.js.map +1 -0
- package/dist/commands/env/index.d.ts +2 -0
- package/dist/commands/env/index.d.ts.map +1 -0
- package/dist/commands/env/index.js +2 -0
- package/dist/commands/env/index.js.map +1 -0
- package/dist/commands/functions/functions-build.d.ts +4 -0
- package/dist/commands/functions/functions-build.d.ts.map +1 -0
- package/dist/commands/functions/functions-build.js +27 -0
- package/dist/commands/functions/functions-build.js.map +1 -0
- package/dist/commands/functions/functions-create.d.ts +4 -0
- package/dist/commands/functions/functions-create.d.ts.map +1 -0
- package/dist/commands/functions/functions-create.js +635 -0
- package/dist/commands/functions/functions-create.js.map +1 -0
- package/dist/commands/functions/functions-invoke.d.ts +4 -0
- package/dist/commands/functions/functions-invoke.d.ts.map +1 -0
- package/dist/commands/functions/functions-invoke.js +210 -0
- package/dist/commands/functions/functions-invoke.js.map +1 -0
- package/dist/commands/functions/functions-list.d.ts +4 -0
- package/dist/commands/functions/functions-list.d.ts.map +1 -0
- package/dist/commands/functions/functions-list.js +41 -0
- package/dist/commands/functions/functions-list.js.map +1 -0
- package/dist/commands/functions/functions-serve.d.ts +4 -0
- package/dist/commands/functions/functions-serve.d.ts.map +1 -0
- package/dist/commands/functions/functions-serve.js +52 -0
- package/dist/commands/functions/functions-serve.js.map +1 -0
- package/dist/commands/functions/functions.d.ts +3 -0
- package/dist/commands/functions/functions.d.ts.map +1 -0
- package/dist/commands/functions/functions.js +101 -0
- package/dist/commands/functions/functions.js.map +1 -0
- package/dist/commands/functions/index.d.ts +2 -0
- package/dist/commands/functions/index.d.ts.map +1 -0
- package/dist/commands/functions/index.js +2 -0
- package/dist/commands/functions/index.js.map +1 -0
- package/dist/commands/index.d.ts +3 -0
- package/dist/commands/index.d.ts.map +1 -0
- package/dist/commands/index.js +3 -0
- package/dist/commands/index.js.map +1 -0
- package/dist/commands/init/index.d.ts +3 -0
- package/dist/commands/init/index.d.ts.map +1 -0
- package/dist/commands/init/index.js +10 -0
- package/dist/commands/init/index.js.map +1 -0
- package/dist/commands/init/init.d.ts +4 -0
- package/dist/commands/init/init.d.ts.map +1 -0
- package/dist/commands/init/init.js +194 -0
- package/dist/commands/init/init.js.map +1 -0
- package/dist/commands/link/index.d.ts +3 -0
- package/dist/commands/link/index.d.ts.map +1 -0
- package/dist/commands/link/index.js +12 -0
- package/dist/commands/link/index.js.map +1 -0
- package/dist/commands/link/link.d.ts +4 -0
- package/dist/commands/link/link.d.ts.map +1 -0
- package/dist/commands/link/link.js +295 -0
- package/dist/commands/link/link.js.map +1 -0
- package/dist/commands/login/index.d.ts +3 -0
- package/dist/commands/login/index.d.ts.map +1 -0
- package/dist/commands/login/index.js +10 -0
- package/dist/commands/login/index.js.map +1 -0
- package/dist/commands/login/login.d.ts +4 -0
- package/dist/commands/login/login.d.ts.map +1 -0
- package/dist/commands/login/login.js +30 -0
- package/dist/commands/login/login.js.map +1 -0
- package/dist/commands/logout/index.d.ts +3 -0
- package/dist/commands/logout/index.d.ts.map +1 -0
- package/dist/commands/logout/index.js +8 -0
- package/dist/commands/logout/index.js.map +1 -0
- package/dist/commands/logout/logout.d.ts +4 -0
- package/dist/commands/logout/logout.d.ts.map +1 -0
- package/dist/commands/logout/logout.js +23 -0
- package/dist/commands/logout/logout.js.map +1 -0
- package/dist/commands/logs/build.d.ts +8 -0
- package/dist/commands/logs/build.d.ts.map +1 -0
- package/dist/commands/logs/build.js +72 -0
- package/dist/commands/logs/build.js.map +1 -0
- package/dist/commands/logs/functions.d.ts +4 -0
- package/dist/commands/logs/functions.d.ts.map +1 -0
- package/dist/commands/logs/functions.js +79 -0
- package/dist/commands/logs/functions.js.map +1 -0
- package/dist/commands/logs/index.d.ts +5 -0
- package/dist/commands/logs/index.d.ts.map +1 -0
- package/dist/commands/logs/index.js +40 -0
- package/dist/commands/logs/index.js.map +1 -0
- package/dist/commands/logs/log-levels.d.ts +11 -0
- package/dist/commands/logs/log-levels.d.ts.map +1 -0
- package/dist/commands/logs/log-levels.js +12 -0
- package/dist/commands/logs/log-levels.js.map +1 -0
- package/dist/commands/main.d.ts +38 -0
- package/dist/commands/main.d.ts.map +1 -0
- package/dist/commands/main.js +215 -0
- package/dist/commands/main.js.map +1 -0
- package/dist/commands/open/index.d.ts +3 -0
- package/dist/commands/open/index.d.ts.map +1 -0
- package/dist/commands/open/index.js +32 -0
- package/dist/commands/open/index.js.map +1 -0
- package/dist/commands/open/open-admin.d.ts +4 -0
- package/dist/commands/open/open-admin.d.ts.map +1 -0
- package/dist/commands/open/open-admin.js +12 -0
- package/dist/commands/open/open-admin.js.map +1 -0
- package/dist/commands/open/open-site.d.ts +4 -0
- package/dist/commands/open/open-site.d.ts.map +1 -0
- package/dist/commands/open/open-site.js +13 -0
- package/dist/commands/open/open-site.js.map +1 -0
- package/dist/commands/open/open.d.ts +4 -0
- package/dist/commands/open/open.d.ts.map +1 -0
- package/dist/commands/open/open.js +14 -0
- package/dist/commands/open/open.js.map +1 -0
- package/dist/commands/recipes/common.d.ts +3 -0
- package/dist/commands/recipes/common.d.ts.map +1 -0
- package/dist/commands/recipes/common.js +26 -0
- package/dist/commands/recipes/common.js.map +1 -0
- package/dist/commands/recipes/index.d.ts +3 -0
- package/dist/commands/recipes/index.d.ts.map +1 -0
- package/dist/commands/recipes/index.js +21 -0
- package/dist/commands/recipes/index.js.map +1 -0
- package/dist/commands/recipes/recipes-list.d.ts +5 -0
- package/dist/commands/recipes/recipes-list.d.ts.map +1 -0
- package/dist/commands/recipes/recipes-list.js +15 -0
- package/dist/commands/recipes/recipes-list.js.map +1 -0
- package/dist/commands/recipes/recipes.d.ts +12 -0
- package/dist/commands/recipes/recipes.d.ts.map +1 -0
- package/dist/commands/recipes/recipes.js +52 -0
- package/dist/commands/recipes/recipes.js.map +1 -0
- package/dist/commands/serve/index.d.ts +3 -0
- package/dist/commands/serve/index.d.ts.map +1 -0
- package/dist/commands/serve/index.js +26 -0
- package/dist/commands/serve/index.js.map +1 -0
- package/dist/commands/serve/serve.d.ts +4 -0
- package/dist/commands/serve/serve.d.ts.map +1 -0
- package/dist/commands/serve/serve.js +149 -0
- package/dist/commands/serve/serve.js.map +1 -0
- package/dist/commands/sites/index.d.ts +2 -0
- package/dist/commands/sites/index.d.ts.map +1 -0
- package/dist/commands/sites/index.js +2 -0
- package/dist/commands/sites/index.js.map +1 -0
- package/dist/commands/sites/sites-create-template.d.ts +5 -0
- package/dist/commands/sites/sites-create-template.d.ts.map +1 -0
- package/dist/commands/sites/sites-create-template.js +230 -0
- package/dist/commands/sites/sites-create-template.js.map +1 -0
- package/dist/commands/sites/sites-create.d.ts +7 -0
- package/dist/commands/sites/sites-create.d.ts.map +1 -0
- package/dist/commands/sites/sites-create.js +125 -0
- package/dist/commands/sites/sites-create.js.map +1 -0
- package/dist/commands/sites/sites-delete.d.ts +4 -0
- package/dist/commands/sites/sites-delete.d.ts.map +1 -0
- package/dist/commands/sites/sites-delete.js +77 -0
- package/dist/commands/sites/sites-delete.js.map +1 -0
- package/dist/commands/sites/sites-list.d.ts +4 -0
- package/dist/commands/sites/sites-list.d.ts.map +1 -0
- package/dist/commands/sites/sites-list.js +59 -0
- package/dist/commands/sites/sites-list.js.map +1 -0
- package/dist/commands/sites/sites.d.ts +5 -0
- package/dist/commands/sites/sites.d.ts.map +1 -0
- package/dist/commands/sites/sites.js +77 -0
- package/dist/commands/sites/sites.js.map +1 -0
- package/dist/commands/status/index.d.ts +3 -0
- package/dist/commands/status/index.d.ts.map +1 -0
- package/dist/commands/status/index.js +21 -0
- package/dist/commands/status/index.js.map +1 -0
- package/dist/commands/status/status-hooks.d.ts +4 -0
- package/dist/commands/status/status-hooks.d.ts.map +1 -0
- package/dist/commands/status/status-hooks.js +29 -0
- package/dist/commands/status/status-hooks.js.map +1 -0
- package/dist/commands/status/status.d.ts +4 -0
- package/dist/commands/status/status.d.ts.map +1 -0
- package/dist/commands/status/status.js +78 -0
- package/dist/commands/status/status.js.map +1 -0
- package/dist/commands/switch/index.d.ts +3 -0
- package/dist/commands/switch/index.d.ts.map +1 -0
- package/dist/commands/switch/index.js +8 -0
- package/dist/commands/switch/index.js.map +1 -0
- package/dist/commands/switch/switch.d.ts +4 -0
- package/dist/commands/switch/switch.d.ts.map +1 -0
- package/dist/commands/switch/switch.js +31 -0
- package/dist/commands/switch/switch.js.map +1 -0
- package/dist/commands/unlink/index.d.ts +3 -0
- package/dist/commands/unlink/index.d.ts.map +1 -0
- package/dist/commands/unlink/index.js +8 -0
- package/dist/commands/unlink/index.js.map +1 -0
- package/dist/commands/unlink/unlink.d.ts +4 -0
- package/dist/commands/unlink/unlink.d.ts.map +1 -0
- package/dist/commands/unlink/unlink.js +22 -0
- package/dist/commands/unlink/unlink.js.map +1 -0
- package/dist/commands/watch/index.d.ts +3 -0
- package/dist/commands/watch/index.d.ts.map +1 -0
- package/dist/commands/watch/index.js +9 -0
- package/dist/commands/watch/index.js.map +1 -0
- package/dist/commands/watch/watch.d.ts +4 -0
- package/dist/commands/watch/watch.d.ts.map +1 -0
- package/dist/commands/watch/watch.js +90 -0
- package/dist/commands/watch/watch.js.map +1 -0
- package/dist/lib/account.d.ts +6 -0
- package/dist/lib/account.d.ts.map +1 -0
- package/dist/lib/account.js +14 -0
- package/dist/lib/account.js.map +1 -0
- package/dist/lib/api.d.ts +10 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +25 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/blobs/blobs.d.ts +47 -0
- package/dist/lib/blobs/blobs.d.ts.map +1 -0
- package/dist/lib/blobs/blobs.js +82 -0
- package/dist/lib/blobs/blobs.js.map +1 -0
- package/dist/lib/build.d.ts +43 -0
- package/dist/lib/build.d.ts.map +1 -0
- package/dist/lib/build.js +73 -0
- package/dist/lib/build.js.map +1 -0
- package/dist/lib/completion/constants.d.ts +2 -0
- package/dist/lib/completion/constants.d.ts.map +1 -0
- package/dist/lib/completion/constants.js +3 -0
- package/dist/lib/completion/constants.js.map +1 -0
- package/dist/lib/completion/generate-autocompletion.d.ts +8 -0
- package/dist/lib/completion/generate-autocompletion.d.ts.map +1 -0
- package/dist/lib/completion/generate-autocompletion.js +42 -0
- package/dist/lib/completion/generate-autocompletion.js.map +1 -0
- package/dist/lib/completion/get-autocompletion.d.ts +13 -0
- package/dist/lib/completion/get-autocompletion.d.ts.map +1 -0
- package/dist/lib/completion/get-autocompletion.js +45 -0
- package/dist/lib/completion/get-autocompletion.js.map +1 -0
- package/dist/lib/completion/index.d.ts +2 -0
- package/dist/lib/completion/index.d.ts.map +1 -0
- package/dist/lib/completion/index.js +2 -0
- package/dist/lib/completion/index.js.map +1 -0
- package/dist/lib/completion/script.d.ts +3 -0
- package/dist/lib/completion/script.d.ts.map +1 -0
- package/dist/lib/completion/script.js +19 -0
- package/dist/lib/completion/script.js.map +1 -0
- package/dist/lib/edge-functions/bootstrap.d.ts +3 -0
- package/dist/lib/edge-functions/bootstrap.d.ts.map +1 -0
- package/dist/lib/edge-functions/bootstrap.js +20 -0
- package/dist/lib/edge-functions/bootstrap.js.map +1 -0
- package/dist/lib/edge-functions/consts.d.ts +11 -0
- package/dist/lib/edge-functions/consts.d.ts.map +1 -0
- package/dist/lib/edge-functions/consts.js +13 -0
- package/dist/lib/edge-functions/consts.js.map +1 -0
- package/dist/lib/edge-functions/deploy.d.ts +8 -0
- package/dist/lib/edge-functions/deploy.d.ts.map +1 -0
- package/dist/lib/edge-functions/deploy.js +34 -0
- package/dist/lib/edge-functions/deploy.js.map +1 -0
- package/dist/lib/edge-functions/editor-helper.d.ts +9 -0
- package/dist/lib/edge-functions/editor-helper.d.ts.map +1 -0
- package/dist/lib/edge-functions/editor-helper.js +31 -0
- package/dist/lib/edge-functions/editor-helper.js.map +1 -0
- package/dist/lib/edge-functions/headers.d.ts +35 -0
- package/dist/lib/edge-functions/headers.d.ts.map +1 -0
- package/dist/lib/edge-functions/headers.js +42 -0
- package/dist/lib/edge-functions/headers.js.map +1 -0
- package/dist/lib/edge-functions/proxy.d.ts +39 -0
- package/dist/lib/edge-functions/proxy.d.ts.map +1 -0
- package/dist/lib/edge-functions/proxy.js +156 -0
- package/dist/lib/edge-functions/proxy.js.map +1 -0
- package/dist/lib/edge-functions/registry.d.ts +107 -0
- package/dist/lib/edge-functions/registry.d.ts.map +1 -0
- package/dist/lib/edge-functions/registry.js +451 -0
- package/dist/lib/edge-functions/registry.js.map +1 -0
- package/dist/lib/exec-fetcher.d.ts +31 -0
- package/dist/lib/exec-fetcher.d.ts.map +1 -0
- package/dist/lib/exec-fetcher.js +132 -0
- package/dist/lib/exec-fetcher.js.map +1 -0
- package/dist/lib/fs.d.ts +12 -0
- package/dist/lib/fs.d.ts.map +1 -0
- package/dist/lib/fs.js +45 -0
- package/dist/lib/fs.js.map +1 -0
- package/dist/lib/functions/background.d.ts +3 -0
- package/dist/lib/functions/background.d.ts.map +1 -0
- package/dist/lib/functions/background.js +19 -0
- package/dist/lib/functions/background.js.map +1 -0
- package/dist/lib/functions/config.d.ts +6 -0
- package/dist/lib/functions/config.d.ts.map +1 -0
- package/dist/lib/functions/config.js +25 -0
- package/dist/lib/functions/config.js.map +1 -0
- package/dist/lib/functions/form-submissions-handler.d.ts +11 -0
- package/dist/lib/functions/form-submissions-handler.d.ts.map +1 -0
- package/dist/lib/functions/form-submissions-handler.js +144 -0
- package/dist/lib/functions/form-submissions-handler.js.map +1 -0
- package/dist/lib/functions/local-proxy.d.ts +9 -0
- package/dist/lib/functions/local-proxy.d.ts.map +1 -0
- package/dist/lib/functions/local-proxy.js +40 -0
- package/dist/lib/functions/local-proxy.js.map +1 -0
- package/dist/lib/functions/memoized-build.d.ts +6 -0
- package/dist/lib/functions/memoized-build.d.ts.map +1 -0
- package/dist/lib/functions/memoized-build.js +30 -0
- package/dist/lib/functions/memoized-build.js.map +1 -0
- package/dist/lib/functions/netlify-function.d.ts +71 -0
- package/dist/lib/functions/netlify-function.d.ts.map +1 -0
- package/dist/lib/functions/netlify-function.js +266 -0
- package/dist/lib/functions/netlify-function.js.map +1 -0
- package/dist/lib/functions/registry.d.ts +106 -0
- package/dist/lib/functions/registry.d.ts.map +1 -0
- package/dist/lib/functions/registry.js +485 -0
- package/dist/lib/functions/registry.js.map +1 -0
- package/dist/lib/functions/runtimes/go/index.d.ts +25 -0
- package/dist/lib/functions/runtimes/go/index.d.ts.map +1 -0
- package/dist/lib/functions/runtimes/go/index.js +68 -0
- package/dist/lib/functions/runtimes/go/index.js.map +1 -0
- package/dist/lib/functions/runtimes/index.d.ts +42 -0
- package/dist/lib/functions/runtimes/index.d.ts.map +1 -0
- package/dist/lib/functions/runtimes/index.js +10 -0
- package/dist/lib/functions/runtimes/index.js.map +1 -0
- package/dist/lib/functions/runtimes/js/builders/netlify-lambda.d.ts +19 -0
- package/dist/lib/functions/runtimes/js/builders/netlify-lambda.d.ts.map +1 -0
- package/dist/lib/functions/runtimes/js/builders/netlify-lambda.js +62 -0
- package/dist/lib/functions/runtimes/js/builders/netlify-lambda.js.map +1 -0
- package/dist/lib/functions/runtimes/js/builders/zisi.d.ts +46 -0
- package/dist/lib/functions/runtimes/js/builders/zisi.d.ts.map +1 -0
- package/dist/lib/functions/runtimes/js/builders/zisi.js +184 -0
- package/dist/lib/functions/runtimes/js/builders/zisi.js.map +1 -0
- package/dist/lib/functions/runtimes/js/constants.d.ts +2 -0
- package/dist/lib/functions/runtimes/js/constants.d.ts.map +1 -0
- package/dist/lib/functions/runtimes/js/constants.js +2 -0
- package/dist/lib/functions/runtimes/js/constants.js.map +1 -0
- package/dist/lib/functions/runtimes/js/index.d.ts +25 -0
- package/dist/lib/functions/runtimes/js/index.d.ts.map +1 -0
- package/dist/lib/functions/runtimes/js/index.js +112 -0
- package/dist/lib/functions/runtimes/js/index.js.map +1 -0
- package/dist/lib/functions/runtimes/js/worker.d.ts +2 -0
- package/dist/lib/functions/runtimes/js/worker.d.ts.map +1 -0
- package/dist/lib/functions/runtimes/js/worker.js +53 -0
- package/dist/lib/functions/runtimes/js/worker.js.map +1 -0
- package/dist/lib/functions/runtimes/rust/index.d.ts +25 -0
- package/dist/lib/functions/runtimes/rust/index.d.ts.map +1 -0
- package/dist/lib/functions/runtimes/rust/index.js +69 -0
- package/dist/lib/functions/runtimes/rust/index.js.map +1 -0
- package/dist/lib/functions/scheduled.d.ts +17 -0
- package/dist/lib/functions/scheduled.d.ts.map +1 -0
- package/dist/lib/functions/scheduled.js +81 -0
- package/dist/lib/functions/scheduled.js.map +1 -0
- package/dist/lib/functions/server.d.ts +31 -0
- package/dist/lib/functions/server.d.ts.map +1 -0
- package/dist/lib/functions/server.js +303 -0
- package/dist/lib/functions/server.js.map +1 -0
- package/dist/lib/functions/synchronous.d.ts +8 -0
- package/dist/lib/functions/synchronous.d.ts.map +1 -0
- package/dist/lib/functions/synchronous.js +141 -0
- package/dist/lib/functions/synchronous.js.map +1 -0
- package/dist/lib/functions/utils.d.ts +11 -0
- package/dist/lib/functions/utils.d.ts.map +1 -0
- package/dist/lib/functions/utils.js +47 -0
- package/dist/lib/functions/utils.js.map +1 -0
- package/dist/lib/geo-location.d.ts +46 -0
- package/dist/lib/geo-location.d.ts.map +1 -0
- package/dist/lib/geo-location.js +108 -0
- package/dist/lib/geo-location.js.map +1 -0
- package/dist/lib/http-agent.d.ts +18 -0
- package/dist/lib/http-agent.d.ts.map +1 -0
- package/dist/lib/http-agent.js +97 -0
- package/dist/lib/http-agent.js.map +1 -0
- package/dist/lib/images/proxy.d.ts +34 -0
- package/dist/lib/images/proxy.d.ts.map +1 -0
- package/dist/lib/images/proxy.js +122 -0
- package/dist/lib/images/proxy.js.map +1 -0
- package/dist/lib/log.d.ts +3 -0
- package/dist/lib/log.d.ts.map +1 -0
- package/dist/lib/log.js +16 -0
- package/dist/lib/log.js.map +1 -0
- package/dist/lib/path.d.ts +2 -0
- package/dist/lib/path.d.ts.map +1 -0
- package/dist/lib/path.js +3 -0
- package/dist/lib/path.js.map +1 -0
- package/dist/lib/render-error-template.d.ts +3 -0
- package/dist/lib/render-error-template.d.ts.map +1 -0
- package/dist/lib/render-error-template.js +21 -0
- package/dist/lib/render-error-template.js.map +1 -0
- package/dist/lib/settings.d.ts +14 -0
- package/dist/lib/settings.d.ts.map +1 -0
- package/dist/lib/settings.js +19 -0
- package/dist/lib/settings.js.map +1 -0
- package/dist/lib/spinner.d.ts +23 -0
- package/dist/lib/spinner.d.ts.map +1 -0
- package/dist/lib/spinner.js +30 -0
- package/dist/lib/spinner.js.map +1 -0
- package/dist/lib/string.d.ts +2 -0
- package/dist/lib/string.d.ts.map +1 -0
- package/dist/lib/string.js +6 -0
- package/dist/lib/string.js.map +1 -0
- package/dist/recipes/ai-context/context.d.ts +33 -0
- package/dist/recipes/ai-context/context.d.ts.map +1 -0
- package/dist/recipes/ai-context/context.js +101 -0
- package/dist/recipes/ai-context/context.js.map +1 -0
- package/dist/recipes/ai-context/index.d.ts +4 -0
- package/dist/recipes/ai-context/index.d.ts.map +1 -0
- package/dist/recipes/ai-context/index.js +86 -0
- package/dist/recipes/ai-context/index.js.map +1 -0
- package/dist/recipes/blobs-migrate/index.d.ts +9 -0
- package/dist/recipes/blobs-migrate/index.d.ts.map +1 -0
- package/dist/recipes/blobs-migrate/index.js +77 -0
- package/dist/recipes/blobs-migrate/index.js.map +1 -0
- package/dist/recipes/vscode/index.d.ts +12 -0
- package/dist/recipes/vscode/index.d.ts.map +1 -0
- package/dist/recipes/vscode/index.js +91 -0
- package/dist/recipes/vscode/index.js.map +1 -0
- package/dist/recipes/vscode/settings.d.ts +18 -0
- package/dist/recipes/vscode/settings.d.ts.map +1 -0
- package/dist/recipes/vscode/settings.js +61 -0
- package/dist/recipes/vscode/settings.js.map +1 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/utils/addons/prepare.d.ts +13 -0
- package/dist/utils/addons/prepare.d.ts.map +1 -0
- package/dist/utils/addons/prepare.js +26 -0
- package/dist/utils/addons/prepare.js.map +1 -0
- package/dist/utils/banner.d.ts +4 -0
- package/dist/utils/banner.d.ts.map +1 -0
- package/dist/utils/banner.js +12 -0
- package/dist/utils/banner.js.map +1 -0
- package/dist/utils/build-info.d.ts +21 -0
- package/dist/utils/build-info.d.ts.map +1 -0
- package/dist/utils/build-info.js +124 -0
- package/dist/utils/build-info.js.map +1 -0
- package/dist/utils/command-helpers.d.ts +116 -0
- package/dist/utils/command-helpers.d.ts.map +1 -0
- package/dist/utils/command-helpers.js +264 -0
- package/dist/utils/command-helpers.js.map +1 -0
- package/dist/utils/copy-template-dir/copy-template-dir.d.ts +2 -0
- package/dist/utils/copy-template-dir/copy-template-dir.d.ts.map +1 -0
- package/dist/utils/copy-template-dir/copy-template-dir.js +75 -0
- package/dist/utils/copy-template-dir/copy-template-dir.js.map +1 -0
- package/dist/utils/create-deferred.d.ts +7 -0
- package/dist/utils/create-deferred.d.ts.map +1 -0
- package/dist/utils/create-deferred.js +11 -0
- package/dist/utils/create-deferred.js.map +1 -0
- package/dist/utils/create-stream-promise.d.ts +5 -0
- package/dist/utils/create-stream-promise.d.ts.map +1 -0
- package/dist/utils/create-stream-promise.js +46 -0
- package/dist/utils/create-stream-promise.js.map +1 -0
- package/dist/utils/deploy/constants.d.ts +10 -0
- package/dist/utils/deploy/constants.d.ts.map +1 -0
- package/dist/utils/deploy/constants.js +18 -0
- package/dist/utils/deploy/constants.js.map +1 -0
- package/dist/utils/deploy/deploy-site.d.ts +24 -0
- package/dist/utils/deploy/deploy-site.d.ts.map +1 -0
- package/dist/utils/deploy/deploy-site.js +157 -0
- package/dist/utils/deploy/deploy-site.js.map +1 -0
- package/dist/utils/deploy/hash-config.d.ts +10 -0
- package/dist/utils/deploy/hash-config.d.ts.map +1 -0
- package/dist/utils/deploy/hash-config.js +26 -0
- package/dist/utils/deploy/hash-config.js.map +1 -0
- package/dist/utils/deploy/hash-files.d.ts +14 -0
- package/dist/utils/deploy/hash-files.d.ts.map +1 -0
- package/dist/utils/deploy/hash-files.js +31 -0
- package/dist/utils/deploy/hash-files.js.map +1 -0
- package/dist/utils/deploy/hash-fns.d.ts +17 -0
- package/dist/utils/deploy/hash-fns.d.ts.map +1 -0
- package/dist/utils/deploy/hash-fns.js +143 -0
- package/dist/utils/deploy/hash-fns.js.map +1 -0
- package/dist/utils/deploy/hasher-segments.d.ts +14 -0
- package/dist/utils/deploy/hasher-segments.d.ts.map +1 -0
- package/dist/utils/deploy/hasher-segments.js +69 -0
- package/dist/utils/deploy/hasher-segments.js.map +1 -0
- package/dist/utils/deploy/upload-files.d.ts +7 -0
- package/dist/utils/deploy/upload-files.d.ts.map +1 -0
- package/dist/utils/deploy/upload-files.js +113 -0
- package/dist/utils/deploy/upload-files.js.map +1 -0
- package/dist/utils/deploy/util.d.ts +5 -0
- package/dist/utils/deploy/util.d.ts.map +1 -0
- package/dist/utils/deploy/util.js +94 -0
- package/dist/utils/deploy/util.js.map +1 -0
- package/dist/utils/detect-server-settings.d.ts +15 -0
- package/dist/utils/detect-server-settings.d.ts.map +1 -0
- package/dist/utils/detect-server-settings.js +252 -0
- package/dist/utils/detect-server-settings.js.map +1 -0
- package/dist/utils/dev.d.ts +62 -0
- package/dist/utils/dev.d.ts.map +1 -0
- package/dist/utils/dev.js +197 -0
- package/dist/utils/dev.js.map +1 -0
- package/dist/utils/dot-env.d.ts +26 -0
- package/dist/utils/dot-env.d.ts.map +1 -0
- package/dist/utils/dot-env.js +43 -0
- package/dist/utils/dot-env.js.map +1 -0
- package/dist/utils/env/index.d.ts +100 -0
- package/dist/utils/env/index.d.ts.map +1 -0
- package/dist/utils/env/index.js +231 -0
- package/dist/utils/env/index.js.map +1 -0
- package/dist/utils/execa.d.ts +4 -0
- package/dist/utils/execa.d.ts.map +1 -0
- package/dist/utils/execa.js +16 -0
- package/dist/utils/execa.js.map +1 -0
- package/dist/utils/feature-flags.d.ts +21 -0
- package/dist/utils/feature-flags.d.ts.map +1 -0
- package/dist/utils/feature-flags.js +25 -0
- package/dist/utils/feature-flags.js.map +1 -0
- package/dist/utils/framework-server.d.ts +13 -0
- package/dist/utils/framework-server.d.ts.map +1 -0
- package/dist/utils/framework-server.js +61 -0
- package/dist/utils/framework-server.js.map +1 -0
- package/dist/utils/frameworks-api.d.ts +20 -0
- package/dist/utils/frameworks-api.d.ts.map +1 -0
- package/dist/utils/frameworks-api.js +54 -0
- package/dist/utils/frameworks-api.js.map +1 -0
- package/dist/utils/functions/constants.d.ts +2 -0
- package/dist/utils/functions/constants.d.ts.map +1 -0
- package/dist/utils/functions/constants.js +2 -0
- package/dist/utils/functions/constants.js.map +1 -0
- package/dist/utils/functions/functions.d.ts +35 -0
- package/dist/utils/functions/functions.d.ts.map +1 -0
- package/dist/utils/functions/functions.js +41 -0
- package/dist/utils/functions/functions.js.map +1 -0
- package/dist/utils/functions/get-functions.d.ts +10 -0
- package/dist/utils/functions/get-functions.d.ts.map +1 -0
- package/dist/utils/functions/get-functions.js +35 -0
- package/dist/utils/functions/get-functions.js.map +1 -0
- package/dist/utils/functions/index.d.ts +4 -0
- package/dist/utils/functions/index.d.ts.map +1 -0
- package/dist/utils/functions/index.js +4 -0
- package/dist/utils/functions/index.js.map +1 -0
- package/dist/utils/get-global-config.d.ts +7 -0
- package/dist/utils/get-global-config.d.ts.map +1 -0
- package/dist/utils/get-global-config.js +41 -0
- package/dist/utils/get-global-config.js.map +1 -0
- package/dist/utils/get-package-json.d.ts +3 -0
- package/dist/utils/get-package-json.d.ts.map +1 -0
- package/dist/utils/get-package-json.js +16 -0
- package/dist/utils/get-package-json.js.map +1 -0
- package/dist/utils/get-repo-data.d.ts +31 -0
- package/dist/utils/get-repo-data.d.ts.map +1 -0
- package/dist/utils/get-repo-data.js +66 -0
- package/dist/utils/get-repo-data.js.map +1 -0
- package/dist/utils/get-site.d.ts +2 -0
- package/dist/utils/get-site.d.ts.map +1 -0
- package/dist/utils/get-site.js +22 -0
- package/dist/utils/get-site.js.map +1 -0
- package/dist/utils/gh-auth.d.ts +11 -0
- package/dist/utils/gh-auth.d.ts.map +1 -0
- package/dist/utils/gh-auth.js +105 -0
- package/dist/utils/gh-auth.js.map +1 -0
- package/dist/utils/gitignore.d.ts +2 -0
- package/dist/utils/gitignore.d.ts.map +1 -0
- package/dist/utils/gitignore.js +36 -0
- package/dist/utils/gitignore.js.map +1 -0
- package/dist/utils/headers.d.ts +21 -0
- package/dist/utils/headers.d.ts.map +1 -0
- package/dist/utils/headers.js +51 -0
- package/dist/utils/headers.js.map +1 -0
- package/dist/utils/hooks/requires-site-info.d.ts +7 -0
- package/dist/utils/hooks/requires-site-info.d.ts.map +1 -0
- package/dist/utils/hooks/requires-site-info.js +31 -0
- package/dist/utils/hooks/requires-site-info.js.map +1 -0
- package/dist/utils/init/config-github.d.ts +21 -0
- package/dist/utils/init/config-github.d.ts.map +1 -0
- package/dist/utils/init/config-github.js +247 -0
- package/dist/utils/init/config-github.js.map +1 -0
- package/dist/utils/init/config-manual.d.ts +12 -0
- package/dist/utils/init/config-manual.d.ts.map +1 -0
- package/dist/utils/init/config-manual.js +109 -0
- package/dist/utils/init/config-manual.js.map +1 -0
- package/dist/utils/init/config.d.ts +14 -0
- package/dist/utils/init/config.d.ts.map +1 -0
- package/dist/utils/init/config.js +38 -0
- package/dist/utils/init/config.js.map +1 -0
- package/dist/utils/init/plugins.d.ts +3 -0
- package/dist/utils/init/plugins.d.ts.map +1 -0
- package/dist/utils/init/plugins.js +13 -0
- package/dist/utils/init/plugins.js.map +1 -0
- package/dist/utils/init/utils.d.ts +54 -0
- package/dist/utils/init/utils.d.ts.map +1 -0
- package/dist/utils/init/utils.js +199 -0
- package/dist/utils/init/utils.js.map +1 -0
- package/dist/utils/live-tunnel.d.ts +8 -0
- package/dist/utils/live-tunnel.d.ts.map +1 -0
- package/dist/utils/live-tunnel.js +128 -0
- package/dist/utils/live-tunnel.js.map +1 -0
- package/dist/utils/multimap.d.ts +6 -0
- package/dist/utils/multimap.d.ts.map +1 -0
- package/dist/utils/multimap.js +10 -0
- package/dist/utils/multimap.js.map +1 -0
- package/dist/utils/open-browser.d.ts +7 -0
- package/dist/utils/open-browser.d.ts.map +1 -0
- package/dist/utils/open-browser.js +33 -0
- package/dist/utils/open-browser.js.map +1 -0
- package/dist/utils/parse-raw-flags.d.ts +3 -0
- package/dist/utils/parse-raw-flags.d.ts.map +1 -0
- package/dist/utils/parse-raw-flags.js +54 -0
- package/dist/utils/parse-raw-flags.js.map +1 -0
- package/dist/utils/prompts/blob-delete-prompts.d.ts +2 -0
- package/dist/utils/prompts/blob-delete-prompts.d.ts.map +1 -0
- package/dist/utils/prompts/blob-delete-prompts.js +12 -0
- package/dist/utils/prompts/blob-delete-prompts.js.map +1 -0
- package/dist/utils/prompts/blob-set-prompt.d.ts +2 -0
- package/dist/utils/prompts/blob-set-prompt.d.ts.map +1 -0
- package/dist/utils/prompts/blob-set-prompt.js +12 -0
- package/dist/utils/prompts/blob-set-prompt.js.map +1 -0
- package/dist/utils/prompts/confirm-prompt.d.ts +2 -0
- package/dist/utils/prompts/confirm-prompt.d.ts.map +1 -0
- package/dist/utils/prompts/confirm-prompt.js +21 -0
- package/dist/utils/prompts/confirm-prompt.js.map +1 -0
- package/dist/utils/prompts/env-clone-prompt.d.ts +11 -0
- package/dist/utils/prompts/env-clone-prompt.d.ts.map +1 -0
- package/dist/utils/prompts/env-clone-prompt.js +28 -0
- package/dist/utils/prompts/env-clone-prompt.js.map +1 -0
- package/dist/utils/prompts/env-set-prompts.d.ts +2 -0
- package/dist/utils/prompts/env-set-prompts.d.ts.map +1 -0
- package/dist/utils/prompts/env-set-prompts.js +12 -0
- package/dist/utils/prompts/env-set-prompts.js.map +1 -0
- package/dist/utils/prompts/env-unset-prompts.d.ts +8 -0
- package/dist/utils/prompts/env-unset-prompts.d.ts.map +1 -0
- package/dist/utils/prompts/env-unset-prompts.js +18 -0
- package/dist/utils/prompts/env-unset-prompts.js.map +1 -0
- package/dist/utils/prompts/prompt-messages.d.ts +25 -0
- package/dist/utils/prompts/prompt-messages.d.ts.map +1 -0
- package/dist/utils/prompts/prompt-messages.js +26 -0
- package/dist/utils/prompts/prompt-messages.js.map +1 -0
- package/dist/utils/proxy-server.d.ts +38 -0
- package/dist/utils/proxy-server.d.ts.map +1 -0
- package/dist/utils/proxy-server.js +50 -0
- package/dist/utils/proxy-server.js.map +1 -0
- package/dist/utils/proxy.d.ts +10 -0
- package/dist/utils/proxy.d.ts.map +1 -0
- package/dist/utils/proxy.js +776 -0
- package/dist/utils/proxy.js.map +1 -0
- package/dist/utils/read-repo-url.d.ts +12 -0
- package/dist/utils/read-repo-url.d.ts.map +1 -0
- package/dist/utils/read-repo-url.js +62 -0
- package/dist/utils/read-repo-url.js.map +1 -0
- package/dist/utils/redirects.d.ts +6 -0
- package/dist/utils/redirects.d.ts.map +1 -0
- package/dist/utils/redirects.js +59 -0
- package/dist/utils/redirects.js.map +1 -0
- package/dist/utils/request-id.d.ts +2 -0
- package/dist/utils/request-id.d.ts.map +1 -0
- package/dist/utils/request-id.js +3 -0
- package/dist/utils/request-id.js.map +1 -0
- package/dist/utils/rules-proxy.d.ts +14 -0
- package/dist/utils/rules-proxy.d.ts.map +1 -0
- package/dist/utils/rules-proxy.js +103 -0
- package/dist/utils/rules-proxy.js.map +1 -0
- package/dist/utils/run-build.d.ts +42 -0
- package/dist/utils/run-build.d.ts.map +1 -0
- package/dist/utils/run-build.js +130 -0
- package/dist/utils/run-build.js.map +1 -0
- package/dist/utils/run-program.d.ts +3 -0
- package/dist/utils/run-program.d.ts.map +1 -0
- package/dist/utils/run-program.js +13 -0
- package/dist/utils/run-program.js.map +1 -0
- package/dist/utils/scripted-commands.d.ts +3 -0
- package/dist/utils/scripted-commands.d.ts.map +1 -0
- package/dist/utils/scripted-commands.js +18 -0
- package/dist/utils/scripted-commands.js.map +1 -0
- package/dist/utils/shell.d.ts +8 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +114 -0
- package/dist/utils/shell.js.map +1 -0
- package/dist/utils/sign-redirect.d.ts +7 -0
- package/dist/utils/sign-redirect.d.ts.map +1 -0
- package/dist/utils/sign-redirect.js +16 -0
- package/dist/utils/sign-redirect.js.map +1 -0
- package/dist/utils/sites/create-template.d.ts +14 -0
- package/dist/utils/sites/create-template.d.ts.map +1 -0
- package/dist/utils/sites/create-template.js +47 -0
- package/dist/utils/sites/create-template.js.map +1 -0
- package/dist/utils/sites/utils.d.ts +16 -0
- package/dist/utils/sites/utils.d.ts.map +1 -0
- package/dist/utils/sites/utils.js +63 -0
- package/dist/utils/sites/utils.js.map +1 -0
- package/dist/utils/state-config.d.ts +12 -0
- package/dist/utils/state-config.d.ts.map +1 -0
- package/dist/utils/state-config.js +113 -0
- package/dist/utils/state-config.js.map +1 -0
- package/dist/utils/static-server.d.ts +10 -0
- package/dist/utils/static-server.d.ts.map +1 -0
- package/dist/utils/static-server.js +36 -0
- package/dist/utils/static-server.js.map +1 -0
- package/dist/utils/telemetry/index.d.ts +3 -0
- package/dist/utils/telemetry/index.d.ts.map +1 -0
- package/dist/utils/telemetry/index.js +3 -0
- package/dist/utils/telemetry/index.js.map +1 -0
- package/dist/utils/telemetry/report-error.d.ts +10 -0
- package/dist/utils/telemetry/report-error.d.ts.map +1 -0
- package/dist/utils/telemetry/report-error.js +53 -0
- package/dist/utils/telemetry/report-error.js.map +1 -0
- package/dist/utils/telemetry/request.d.ts +2 -0
- package/dist/utils/telemetry/request.d.ts.map +1 -0
- package/dist/utils/telemetry/request.js +41 -0
- package/dist/utils/telemetry/request.js.map +1 -0
- package/dist/utils/telemetry/telemetry.d.ts +14 -0
- package/dist/utils/telemetry/telemetry.d.ts.map +1 -0
- package/dist/utils/telemetry/telemetry.js +94 -0
- package/dist/utils/telemetry/telemetry.js.map +1 -0
- package/dist/utils/telemetry/utils.d.ts +3 -0
- package/dist/utils/telemetry/utils.d.ts.map +1 -0
- package/dist/utils/telemetry/utils.js +7 -0
- package/dist/utils/telemetry/utils.js.map +1 -0
- package/dist/utils/telemetry/validation.d.ts +2 -0
- package/dist/utils/telemetry/validation.d.ts.map +1 -0
- package/dist/utils/telemetry/validation.js +63 -0
- package/dist/utils/telemetry/validation.js.map +1 -0
- package/dist/utils/types.d.ts +202 -0
- package/dist/utils/types.d.ts.map +1 -0
- package/dist/utils/types.js +2 -0
- package/dist/utils/types.js.map +1 -0
- package/dist/utils/validation.d.ts +6 -0
- package/dist/utils/validation.d.ts.map +1 -0
- package/dist/utils/validation.js +17 -0
- package/dist/utils/validation.js.map +1 -0
- package/dist/utils/websockets/index.d.ts +3 -0
- package/dist/utils/websockets/index.d.ts.map +1 -0
- package/dist/utils/websockets/index.js +3 -0
- package/dist/utils/websockets/index.js.map +1 -0
- package/functions-templates/javascript/scheduled-function/package.json +1 -1
- package/functions-templates/typescript/hello-world/package-lock.json +15 -15
- package/functions-templates/typescript/hello-world/package.json +1 -1
- package/functions-templates/typescript/scheduled-function/package.json +1 -1
- package/npm-shrinkwrap.json +32 -48
- package/package.json +4 -4
|
@@ -0,0 +1,635 @@
|
|
|
1
|
+
import cp from 'child_process';
|
|
2
|
+
import fs from 'fs';
|
|
3
|
+
import { mkdir, readdir, unlink } from 'fs/promises';
|
|
4
|
+
import { createRequire } from 'module';
|
|
5
|
+
import path, { dirname, join, relative } from 'path';
|
|
6
|
+
import process from 'process';
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from 'url';
|
|
8
|
+
import { findUp } from 'find-up';
|
|
9
|
+
import fuzzy from 'fuzzy';
|
|
10
|
+
import inquirer from 'inquirer';
|
|
11
|
+
import fetch from 'node-fetch';
|
|
12
|
+
import { createSpinner } from 'nanospinner';
|
|
13
|
+
import { fileExistsAsync } from '../../lib/fs.js';
|
|
14
|
+
import { getAddons, getCurrentAddon, getSiteData } from '../../utils/addons/prepare.js';
|
|
15
|
+
import { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log, } from '../../utils/command-helpers.js';
|
|
16
|
+
import { copyTemplateDir } from '../../utils/copy-template-dir/copy-template-dir.js';
|
|
17
|
+
import { getDotEnvVariables, injectEnvVariables } from '../../utils/dev.js';
|
|
18
|
+
import execa from '../../utils/execa.js';
|
|
19
|
+
import { readRepoURL, validateRepoURL } from '../../utils/read-repo-url.js';
|
|
20
|
+
const require = createRequire(import.meta.url);
|
|
21
|
+
const templatesDir = path.resolve(dirname(fileURLToPath(import.meta.url)), '../../../functions-templates');
|
|
22
|
+
/**
|
|
23
|
+
* Ensure that there's a sub-directory in `/functions-templates` named after
|
|
24
|
+
* each `value` property in this list.
|
|
25
|
+
*/
|
|
26
|
+
const languages = [
|
|
27
|
+
{ name: 'JavaScript', value: 'javascript' },
|
|
28
|
+
{ name: 'TypeScript', value: 'typescript' },
|
|
29
|
+
{ name: 'Go', value: 'go' },
|
|
30
|
+
{ name: 'Rust', value: 'rust' },
|
|
31
|
+
];
|
|
32
|
+
const MOON_SPINNER = {
|
|
33
|
+
interval: 80,
|
|
34
|
+
frames: ['🌑 ', '🌒 ', '🌓 ', '🌔 ', '🌕 ', '🌖 ', '🌗 ', '🌘 '],
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* prompt for a name if name not supplied
|
|
38
|
+
* @param {string} argumentName
|
|
39
|
+
* @param {import('commander').OptionValues} options
|
|
40
|
+
* @param {string} [defaultName]
|
|
41
|
+
* @returns
|
|
42
|
+
*/
|
|
43
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'argumentName' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
44
|
+
const getNameFromArgs = async function (argumentName, options, defaultName) {
|
|
45
|
+
if (options.name) {
|
|
46
|
+
if (argumentName) {
|
|
47
|
+
throw new Error('function name specified in both flag and arg format, pick one');
|
|
48
|
+
}
|
|
49
|
+
return options.name;
|
|
50
|
+
}
|
|
51
|
+
if (argumentName) {
|
|
52
|
+
return argumentName;
|
|
53
|
+
}
|
|
54
|
+
const { name } = await inquirer.prompt([
|
|
55
|
+
{
|
|
56
|
+
name: 'name',
|
|
57
|
+
message: 'Name your function:',
|
|
58
|
+
default: defaultName,
|
|
59
|
+
type: 'input',
|
|
60
|
+
validate: (val) => Boolean(val) && /^[\w.-]+$/i.test(val),
|
|
61
|
+
// make sure it is not undefined and is a valid filename.
|
|
62
|
+
// this has some nuance i have ignored, eg crossenv and i18n concerns
|
|
63
|
+
},
|
|
64
|
+
]);
|
|
65
|
+
return name;
|
|
66
|
+
};
|
|
67
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'registry' implicitly has an 'any' type.
|
|
68
|
+
const filterRegistry = function (registry, input) {
|
|
69
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type.
|
|
70
|
+
const temp = registry.map((value) => value.name + value.description);
|
|
71
|
+
// TODO: remove once https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1394 is fixed
|
|
72
|
+
// eslint-disable-next-line unicorn/no-array-method-this-argument
|
|
73
|
+
const filteredTemplates = fuzzy.filter(input, temp);
|
|
74
|
+
const filteredTemplateNames = new Set(filteredTemplates.map((filteredTemplate) => (input ? filteredTemplate.string : filteredTemplate)));
|
|
75
|
+
return (registry
|
|
76
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type.
|
|
77
|
+
.filter((t) => filteredTemplateNames.has(t.name + t.description))
|
|
78
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type.
|
|
79
|
+
.map((t) => {
|
|
80
|
+
// add the score
|
|
81
|
+
// @ts-expect-error TS(2339) FIXME: Property 'score' does not exist on type 'FilterRes... Remove this comment to see the full error message
|
|
82
|
+
const { score } = filteredTemplates.find((filteredTemplate) => filteredTemplate.string === t.name + t.description);
|
|
83
|
+
t.score = score;
|
|
84
|
+
return t;
|
|
85
|
+
}));
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* @param {string} lang
|
|
89
|
+
* @param {'edge' | 'serverless'} funcType
|
|
90
|
+
*/
|
|
91
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'lang' implicitly has an 'any' type.
|
|
92
|
+
const formatRegistryArrayForInquirer = async function (lang, funcType) {
|
|
93
|
+
const folders = await readdir(path.join(templatesDir, lang), { withFileTypes: true });
|
|
94
|
+
const imports = await Promise.all(folders
|
|
95
|
+
.filter((folder) => Boolean(folder?.isDirectory()))
|
|
96
|
+
.map(async ({ name }) => {
|
|
97
|
+
try {
|
|
98
|
+
const templatePath = path.join(templatesDir, lang, name, '.netlify-function-template.mjs');
|
|
99
|
+
// @ts-expect-error TS(7036) FIXME: Dynamic import's specifier must be of type 'string... Remove this comment to see the full error message
|
|
100
|
+
const template = await import(pathToFileURL(templatePath));
|
|
101
|
+
return template.default;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
// noop if import fails we don't break the whole inquirer
|
|
105
|
+
}
|
|
106
|
+
}));
|
|
107
|
+
const registry = imports
|
|
108
|
+
.filter((template) => template?.functionType === funcType)
|
|
109
|
+
.sort((templateA, templateB) => {
|
|
110
|
+
const priorityDiff = (templateA.priority || DEFAULT_PRIORITY) - (templateB.priority || DEFAULT_PRIORITY);
|
|
111
|
+
if (priorityDiff !== 0) {
|
|
112
|
+
return priorityDiff;
|
|
113
|
+
}
|
|
114
|
+
// This branch is needed because `Array.prototype.sort` was not stable
|
|
115
|
+
// until Node 11, so the original sorting order from `fs.readdirSync`
|
|
116
|
+
// was not respected. We can simplify this once we drop support for
|
|
117
|
+
// Node 10.
|
|
118
|
+
return templateA - templateB;
|
|
119
|
+
})
|
|
120
|
+
.map((t) => {
|
|
121
|
+
t.lang = lang;
|
|
122
|
+
return {
|
|
123
|
+
// confusing but this is the format inquirer wants
|
|
124
|
+
name: `[${t.name}] ${t.description}`,
|
|
125
|
+
value: t,
|
|
126
|
+
short: `${lang}-${t.name}`,
|
|
127
|
+
};
|
|
128
|
+
});
|
|
129
|
+
return registry;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* pick template from our existing templates
|
|
133
|
+
* @param {import('commander').OptionValues} config
|
|
134
|
+
* @param {'edge' | 'serverless'} funcType
|
|
135
|
+
*/
|
|
136
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'languageFromFlag' implicitly has ... Remove this comment to see the full error message
|
|
137
|
+
const pickTemplate = async function ({ language: languageFromFlag }, funcType) {
|
|
138
|
+
const specialCommands = [
|
|
139
|
+
new inquirer.Separator(),
|
|
140
|
+
{
|
|
141
|
+
name: `Clone template from GitHub URL`,
|
|
142
|
+
value: 'url',
|
|
143
|
+
short: 'gh-url',
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
name: `Report issue with, or suggest a new template`,
|
|
147
|
+
value: 'report',
|
|
148
|
+
short: 'gh-report',
|
|
149
|
+
},
|
|
150
|
+
new inquirer.Separator(),
|
|
151
|
+
];
|
|
152
|
+
let language = languageFromFlag;
|
|
153
|
+
if (language === undefined) {
|
|
154
|
+
const langs = funcType === 'edge'
|
|
155
|
+
? languages.filter((lang) => lang.value === 'javascript' || lang.value === 'typescript')
|
|
156
|
+
: languages.filter(Boolean);
|
|
157
|
+
const { language: languageFromPrompt } = await inquirer.prompt({
|
|
158
|
+
choices: langs,
|
|
159
|
+
message: 'Select the language of your function',
|
|
160
|
+
name: 'language',
|
|
161
|
+
type: 'list',
|
|
162
|
+
});
|
|
163
|
+
language = languageFromPrompt;
|
|
164
|
+
}
|
|
165
|
+
let templatesForLanguage;
|
|
166
|
+
try {
|
|
167
|
+
templatesForLanguage = await formatRegistryArrayForInquirer(language, funcType);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
throw error(`Invalid language: ${language}`);
|
|
171
|
+
}
|
|
172
|
+
const { chosenTemplate } = await inquirer.prompt({
|
|
173
|
+
name: 'chosenTemplate',
|
|
174
|
+
message: 'Pick a template',
|
|
175
|
+
// @ts-expect-error TS(2769) FIXME: No overload matches this call.
|
|
176
|
+
type: 'autocomplete',
|
|
177
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'answersSoFar' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
178
|
+
source(answersSoFar, input) {
|
|
179
|
+
// if Edge Functions template, don't show url option
|
|
180
|
+
// @ts-expect-error TS(2339) FIXME: Property 'value' does not exist on type 'Separator... Remove this comment to see the full error message
|
|
181
|
+
const edgeCommands = specialCommands.filter((val) => val.value !== 'url');
|
|
182
|
+
const parsedSpecialCommands = funcType === 'edge' ? edgeCommands : specialCommands;
|
|
183
|
+
if (!input || input === '') {
|
|
184
|
+
// show separators
|
|
185
|
+
return [...templatesForLanguage, ...parsedSpecialCommands];
|
|
186
|
+
}
|
|
187
|
+
// only show filtered results sorted by score
|
|
188
|
+
const answers = [...filterRegistry(templatesForLanguage, input), ...parsedSpecialCommands].sort((answerA, answerB) => answerB.score - answerA.score);
|
|
189
|
+
return answers;
|
|
190
|
+
},
|
|
191
|
+
});
|
|
192
|
+
return chosenTemplate;
|
|
193
|
+
};
|
|
194
|
+
const DEFAULT_PRIORITY = 999;
|
|
195
|
+
/** @returns {Promise<'edge' | 'serverless'>} */
|
|
196
|
+
const selectTypeOfFunc = async () => {
|
|
197
|
+
const functionTypes = [
|
|
198
|
+
{ name: 'Edge function (Deno)', value: 'edge' },
|
|
199
|
+
{ name: 'Serverless function (Node/Go/Rust)', value: 'serverless' },
|
|
200
|
+
];
|
|
201
|
+
const { functionType } = await inquirer.prompt([
|
|
202
|
+
{
|
|
203
|
+
name: 'functionType',
|
|
204
|
+
message: "Select the type of function you'd like to create",
|
|
205
|
+
type: 'list',
|
|
206
|
+
choices: functionTypes,
|
|
207
|
+
},
|
|
208
|
+
]);
|
|
209
|
+
return functionType;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* @param {import('../base-command.js').default} command
|
|
213
|
+
*/
|
|
214
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
|
|
215
|
+
const ensureEdgeFuncDirExists = function (command) {
|
|
216
|
+
const { config, site } = command.netlify;
|
|
217
|
+
const siteId = site.id;
|
|
218
|
+
if (!siteId) {
|
|
219
|
+
error(`${NETLIFYDEVERR} No site id found, please run inside a site directory or \`netlify link\``);
|
|
220
|
+
}
|
|
221
|
+
const functionsDir = config.build?.edge_functions ?? join(command.workingDir, 'netlify/edge-functions');
|
|
222
|
+
const relFunctionsDir = relative(command.workingDir, functionsDir);
|
|
223
|
+
if (!fs.existsSync(functionsDir)) {
|
|
224
|
+
log(`${NETLIFYDEVLOG} Edge Functions directory ${chalk.magenta.inverse(relFunctionsDir)} does not exist yet, creating it...`);
|
|
225
|
+
fs.mkdirSync(functionsDir, { recursive: true });
|
|
226
|
+
log(`${NETLIFYDEVLOG} Edge Functions directory ${chalk.magenta.inverse(relFunctionsDir)} created.`);
|
|
227
|
+
}
|
|
228
|
+
return functionsDir;
|
|
229
|
+
};
|
|
230
|
+
/**
|
|
231
|
+
* Prompts the user to choose a functions directory
|
|
232
|
+
* @param {import('../base-command.js').default} command
|
|
233
|
+
* @returns {Promise<string>} - functions directory or throws an error
|
|
234
|
+
*/
|
|
235
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
|
|
236
|
+
const promptFunctionsDirectory = async (command) => {
|
|
237
|
+
const { api, relConfigFilePath, site } = command.netlify;
|
|
238
|
+
log(`\n${NETLIFYDEVLOG} functions directory not specified in ${relConfigFilePath} or UI settings`);
|
|
239
|
+
if (!site.id) {
|
|
240
|
+
error(`${NETLIFYDEVERR} No site id found, please run inside a site directory or \`netlify link\``);
|
|
241
|
+
}
|
|
242
|
+
const { functionsDir } = await inquirer.prompt([
|
|
243
|
+
{
|
|
244
|
+
type: 'input',
|
|
245
|
+
name: 'functionsDir',
|
|
246
|
+
message: 'Enter the path, relative to your site, where your functions should live:',
|
|
247
|
+
default: 'netlify/functions',
|
|
248
|
+
},
|
|
249
|
+
]);
|
|
250
|
+
try {
|
|
251
|
+
log(`${NETLIFYDEVLOG} updating site settings with ${chalk.magenta.inverse(functionsDir)}`);
|
|
252
|
+
await api.updateSite({
|
|
253
|
+
siteId: site.id,
|
|
254
|
+
body: {
|
|
255
|
+
build_settings: {
|
|
256
|
+
functions_dir: functionsDir,
|
|
257
|
+
},
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
log(`${NETLIFYDEVLOG} functions directory ${chalk.magenta.inverse(functionsDir)} updated in site settings`);
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
throw error('Error updating site settings');
|
|
264
|
+
}
|
|
265
|
+
return functionsDir;
|
|
266
|
+
};
|
|
267
|
+
/**
|
|
268
|
+
* Get functions directory (and make it if necessary)
|
|
269
|
+
* @param {import('../base-command.js').default} command
|
|
270
|
+
* @returns {Promise<string>} - functions directory or throws an error
|
|
271
|
+
*/
|
|
272
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
|
|
273
|
+
const ensureFunctionDirExists = async function (command) {
|
|
274
|
+
const { config } = command.netlify;
|
|
275
|
+
const functionsDirHolder = config.functionsDirectory || join(command.workingDir, await promptFunctionsDirectory(command));
|
|
276
|
+
const relFunctionsDirHolder = relative(command.workingDir, functionsDirHolder);
|
|
277
|
+
if (!fs.existsSync(functionsDirHolder)) {
|
|
278
|
+
log(`${NETLIFYDEVLOG} functions directory ${chalk.magenta.inverse(relFunctionsDirHolder)} does not exist yet, creating it...`);
|
|
279
|
+
await mkdir(functionsDirHolder, { recursive: true });
|
|
280
|
+
log(`${NETLIFYDEVLOG} functions directory ${chalk.magenta.inverse(relFunctionsDirHolder)} created`);
|
|
281
|
+
}
|
|
282
|
+
return functionsDirHolder;
|
|
283
|
+
};
|
|
284
|
+
/**
|
|
285
|
+
* Download files from a given GitHub URL
|
|
286
|
+
* @param {import('../base-command.js').default} command
|
|
287
|
+
* @param {import('commander').OptionValues} options
|
|
288
|
+
* @param {string} argumentName
|
|
289
|
+
* @param {string} functionsDir
|
|
290
|
+
*/
|
|
291
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
|
|
292
|
+
const downloadFromURL = async function (command, options, argumentName, functionsDir) {
|
|
293
|
+
const folderContents = await readRepoURL(options.url);
|
|
294
|
+
const [functionName] = options.url.split('/').slice(-1);
|
|
295
|
+
const nameToUse = await getNameFromArgs(argumentName, options, functionName);
|
|
296
|
+
const fnFolder = path.join(functionsDir, nameToUse);
|
|
297
|
+
if (fs.existsSync(`${fnFolder}.js`) && fs.lstatSync(`${fnFolder}.js`).isFile()) {
|
|
298
|
+
log(`${NETLIFYDEVWARN}: A single file version of the function ${nameToUse} already exists at ${fnFolder}.js. Terminating without further action.`);
|
|
299
|
+
process.exit(1);
|
|
300
|
+
}
|
|
301
|
+
try {
|
|
302
|
+
await mkdir(fnFolder, { recursive: true });
|
|
303
|
+
}
|
|
304
|
+
catch {
|
|
305
|
+
// Ignore
|
|
306
|
+
}
|
|
307
|
+
await Promise.all(
|
|
308
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'downloadUrl' implicitly has an 'a... Remove this comment to see the full error message
|
|
309
|
+
folderContents.map(async ({ download_url: downloadUrl, name }) => {
|
|
310
|
+
try {
|
|
311
|
+
const res = await fetch(downloadUrl);
|
|
312
|
+
const finalName = path.basename(name, '.js') === functionName ? `${nameToUse}.js` : name;
|
|
313
|
+
const dest = fs.createWriteStream(path.join(fnFolder, finalName));
|
|
314
|
+
res.body?.pipe(dest);
|
|
315
|
+
}
|
|
316
|
+
catch (error_) {
|
|
317
|
+
throw new Error(`Error while retrieving ${downloadUrl} ${error_}`);
|
|
318
|
+
}
|
|
319
|
+
}));
|
|
320
|
+
log(`${NETLIFYDEVLOG} Installing dependencies for ${nameToUse}...`);
|
|
321
|
+
cp.exec('npm i', { cwd: path.join(functionsDir, nameToUse) }, () => {
|
|
322
|
+
log(`${NETLIFYDEVLOG} Installing dependencies for ${nameToUse} complete `);
|
|
323
|
+
});
|
|
324
|
+
// read, execute, and delete function template file if exists
|
|
325
|
+
const fnTemplateFile = path.join(fnFolder, '.netlify-function-template.mjs');
|
|
326
|
+
if (await fileExistsAsync(fnTemplateFile)) {
|
|
327
|
+
const { default: { addons = [], onComplete }, } = await import(pathToFileURL(fnTemplateFile).href);
|
|
328
|
+
await installAddons(command, addons, path.resolve(fnFolder));
|
|
329
|
+
await handleOnComplete({ command, onComplete });
|
|
330
|
+
// delete
|
|
331
|
+
await unlink(fnTemplateFile);
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
/**
|
|
335
|
+
* Takes a list of existing packages and a list of packages required by a
|
|
336
|
+
* function, and returns the packages from the latter that aren't present
|
|
337
|
+
* in the former. The packages are returned as an array of strings with the
|
|
338
|
+
* name and version range (e.g. '@netlify/functions@0.1.0').
|
|
339
|
+
*/
|
|
340
|
+
const getNpmInstallPackages = (existingPackages = {}, neededPackages = {}) => Object.entries(neededPackages)
|
|
341
|
+
// @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message
|
|
342
|
+
.filter(([name]) => existingPackages[name] === undefined)
|
|
343
|
+
.map(([name, version]) => `${name}@${version}`);
|
|
344
|
+
/**
|
|
345
|
+
* When installing a function's dependencies, we first try to find a site-level
|
|
346
|
+
* `package.json` file. If we do, we look for any dependencies of the function
|
|
347
|
+
* that aren't already listed as dependencies of the site and install them. If
|
|
348
|
+
* we don't do this check, we may be upgrading the version of a module used in
|
|
349
|
+
* another part of the project, which we don't want to do.
|
|
350
|
+
*/
|
|
351
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'functionPackageJson' implicitly h... Remove this comment to see the full error message
|
|
352
|
+
const installDeps = async ({ functionPackageJson, functionPath, functionsDir }) => {
|
|
353
|
+
const { dependencies: functionDependencies, devDependencies: functionDevDependencies } = require(functionPackageJson);
|
|
354
|
+
const sitePackageJson = await findUp('package.json', { cwd: functionsDir });
|
|
355
|
+
const npmInstallFlags = ['--no-audit', '--no-fund'];
|
|
356
|
+
// If there is no site-level `package.json`, we fall back to the old behavior
|
|
357
|
+
// of keeping that file in the function directory and running `npm install`
|
|
358
|
+
// from there.
|
|
359
|
+
if (!sitePackageJson) {
|
|
360
|
+
await execa('npm', ['i', ...npmInstallFlags], { cwd: functionPath });
|
|
361
|
+
return;
|
|
362
|
+
}
|
|
363
|
+
const { dependencies: siteDependencies, devDependencies: siteDevDependencies } = require(sitePackageJson);
|
|
364
|
+
const dependencies = getNpmInstallPackages(siteDependencies, functionDependencies);
|
|
365
|
+
const devDependencies = getNpmInstallPackages(siteDevDependencies, functionDevDependencies);
|
|
366
|
+
const npmInstallPath = path.dirname(sitePackageJson);
|
|
367
|
+
if (dependencies.length !== 0) {
|
|
368
|
+
await execa('npm', ['i', ...dependencies, '--save', ...npmInstallFlags], { cwd: npmInstallPath });
|
|
369
|
+
}
|
|
370
|
+
if (devDependencies.length !== 0) {
|
|
371
|
+
await execa('npm', ['i', ...devDependencies, '--save-dev', ...npmInstallFlags], { cwd: npmInstallPath });
|
|
372
|
+
}
|
|
373
|
+
// We installed the function's dependencies in the site-level `package.json`,
|
|
374
|
+
// so there's no reason to keep the one copied over from the template.
|
|
375
|
+
fs.unlinkSync(functionPackageJson);
|
|
376
|
+
// Similarly, if the template has a `package-lock.json` file, we delete it.
|
|
377
|
+
try {
|
|
378
|
+
const functionPackageLock = path.join(functionPath, 'package-lock.json');
|
|
379
|
+
fs.unlinkSync(functionPackageLock);
|
|
380
|
+
}
|
|
381
|
+
catch {
|
|
382
|
+
// no-op
|
|
383
|
+
}
|
|
384
|
+
};
|
|
385
|
+
/**
|
|
386
|
+
* no --url flag specified, pick from a provided template
|
|
387
|
+
* @param {import('../base-command.js').default} command
|
|
388
|
+
* @param {import('commander').OptionValues} options
|
|
389
|
+
* @param {string} argumentName
|
|
390
|
+
* @param {string} functionsDir Absolute path of the functions directory
|
|
391
|
+
* @param {'edge' | 'serverless'} funcType
|
|
392
|
+
*/
|
|
393
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
|
|
394
|
+
const scaffoldFromTemplate = async function (command, options, argumentName, functionsDir, funcType) {
|
|
395
|
+
// pull the rest of the metadata from the template
|
|
396
|
+
const chosenTemplate = await pickTemplate(options, funcType);
|
|
397
|
+
if (chosenTemplate === 'url') {
|
|
398
|
+
const { chosenUrl } = await inquirer.prompt([
|
|
399
|
+
{
|
|
400
|
+
name: 'chosenUrl',
|
|
401
|
+
message: 'URL to clone: ',
|
|
402
|
+
type: 'input',
|
|
403
|
+
validate: (/** @type {string} */ val) => Boolean(validateRepoURL(val)),
|
|
404
|
+
// make sure it is not undefined and is a valid filename.
|
|
405
|
+
// this has some nuance i have ignored, eg crossenv and i18n concerns
|
|
406
|
+
},
|
|
407
|
+
]);
|
|
408
|
+
options.url = chosenUrl.trim();
|
|
409
|
+
try {
|
|
410
|
+
await downloadFromURL(command, options, argumentName, functionsDir);
|
|
411
|
+
}
|
|
412
|
+
catch (error_) {
|
|
413
|
+
error(`$${NETLIFYDEVERR} Error downloading from URL: ${options.url}`);
|
|
414
|
+
error(error_);
|
|
415
|
+
process.exit(1);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
else if (chosenTemplate === 'report') {
|
|
419
|
+
log(`${NETLIFYDEVLOG} Open in browser: https://github.com/netlify/cli/issues/new`);
|
|
420
|
+
}
|
|
421
|
+
else {
|
|
422
|
+
const { addons = [], lang, name: templateName, onComplete } = chosenTemplate;
|
|
423
|
+
const pathToTemplate = path.join(templatesDir, lang, templateName);
|
|
424
|
+
if (!fs.existsSync(pathToTemplate)) {
|
|
425
|
+
throw new Error(`There isn't a corresponding directory to the selected name. Template '${templateName}' is misconfigured`);
|
|
426
|
+
}
|
|
427
|
+
const name = await getNameFromArgs(argumentName, options, templateName);
|
|
428
|
+
log(`${NETLIFYDEVLOG} Creating function ${chalk.cyan.inverse(name)}`);
|
|
429
|
+
const functionPath = ensureFunctionPathIsOk(functionsDir, name);
|
|
430
|
+
const vars = { name };
|
|
431
|
+
let functionPackageJson;
|
|
432
|
+
// These files will not be part of the log message because they'll likely
|
|
433
|
+
// be removed before the command finishes.
|
|
434
|
+
const omittedFromOutput = new Set(['.netlify-function-template.mjs', 'package.json', 'package-lock.json']);
|
|
435
|
+
const createdFiles = await copyTemplateDir(pathToTemplate, functionPath, vars);
|
|
436
|
+
createdFiles.forEach((filePath) => {
|
|
437
|
+
const filename = path.basename(filePath);
|
|
438
|
+
if (!omittedFromOutput.has(filename)) {
|
|
439
|
+
log(`${NETLIFYDEVLOG} ${chalk.greenBright('Created')} ${filePath}`);
|
|
440
|
+
}
|
|
441
|
+
fs.chmodSync(path.resolve(filePath), TEMPLATE_PERMISSIONS);
|
|
442
|
+
if (filePath.includes('package.json')) {
|
|
443
|
+
functionPackageJson = path.resolve(filePath);
|
|
444
|
+
}
|
|
445
|
+
});
|
|
446
|
+
// delete function template file that was copied over by copydir
|
|
447
|
+
await unlink(path.join(functionPath, '.netlify-function-template.mjs'));
|
|
448
|
+
// npm install
|
|
449
|
+
if (functionPackageJson !== undefined) {
|
|
450
|
+
const spinner = createSpinner(`Installing dependencies for ${name}`, MOON_SPINNER).start();
|
|
451
|
+
await installDeps({ functionPackageJson, functionPath, functionsDir });
|
|
452
|
+
spinner.success(`Installed dependencies for ${name}`);
|
|
453
|
+
}
|
|
454
|
+
if (funcType === 'edge') {
|
|
455
|
+
await registerEFInToml(name, command.netlify);
|
|
456
|
+
}
|
|
457
|
+
await installAddons(command, addons, path.resolve(functionPath));
|
|
458
|
+
await handleOnComplete({ command, onComplete });
|
|
459
|
+
log();
|
|
460
|
+
log(chalk.greenBright(`Function created!`));
|
|
461
|
+
if (lang == 'rust') {
|
|
462
|
+
log(chalk.green(`Please note that Rust functions require setting the NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE environment variable to 'true' on your site.`));
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
};
|
|
466
|
+
const TEMPLATE_PERMISSIONS = 0o777;
|
|
467
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message
|
|
468
|
+
const createFunctionAddon = async function ({ addonName, addons, api, siteData, siteId }) {
|
|
469
|
+
try {
|
|
470
|
+
const addon = getCurrentAddon({ addons, addonName });
|
|
471
|
+
if (addon && addon.id) {
|
|
472
|
+
log(`The "${addonName} add-on" already exists for ${siteData.name}`);
|
|
473
|
+
return false;
|
|
474
|
+
}
|
|
475
|
+
await api.createServiceInstance({
|
|
476
|
+
siteId,
|
|
477
|
+
addon: addonName,
|
|
478
|
+
body: { config: {} },
|
|
479
|
+
});
|
|
480
|
+
log(`Add-on "${addonName}" created for ${siteData.name}`);
|
|
481
|
+
return true;
|
|
482
|
+
}
|
|
483
|
+
catch (error_) {
|
|
484
|
+
error(error_.message);
|
|
485
|
+
}
|
|
486
|
+
};
|
|
487
|
+
/**
|
|
488
|
+
*
|
|
489
|
+
* @param {object} config
|
|
490
|
+
* @param {import('../base-command.js').default} config.command
|
|
491
|
+
* @param {(command: import('../base-command.js').default) => any} config.onComplete
|
|
492
|
+
*/
|
|
493
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message
|
|
494
|
+
const handleOnComplete = async ({ command, onComplete }) => {
|
|
495
|
+
const { config } = command.netlify;
|
|
496
|
+
if (onComplete) {
|
|
497
|
+
const env = await getDotEnvVariables({
|
|
498
|
+
devConfig: { ...config.dev },
|
|
499
|
+
env: command.netlify.cachedConfig.env,
|
|
500
|
+
site: command.netlify.site,
|
|
501
|
+
});
|
|
502
|
+
injectEnvVariables(env);
|
|
503
|
+
await onComplete.call(command);
|
|
504
|
+
}
|
|
505
|
+
};
|
|
506
|
+
/**
|
|
507
|
+
*
|
|
508
|
+
* @param {object} config
|
|
509
|
+
* @param {*} config.addonCreated
|
|
510
|
+
* @param {*} config.addonDidInstall
|
|
511
|
+
* @param {import('../base-command.js').default} config.command
|
|
512
|
+
* @param {string} config.fnPath
|
|
513
|
+
*/
|
|
514
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'addonCreated' implicitly has an '... Remove this comment to see the full error message
|
|
515
|
+
const handleAddonDidInstall = async ({ addonCreated, addonDidInstall, command, fnPath }) => {
|
|
516
|
+
const { config } = command.netlify;
|
|
517
|
+
if (!addonCreated || !addonDidInstall) {
|
|
518
|
+
return;
|
|
519
|
+
}
|
|
520
|
+
const { confirmPostInstall } = await inquirer.prompt([
|
|
521
|
+
{
|
|
522
|
+
type: 'confirm',
|
|
523
|
+
name: 'confirmPostInstall',
|
|
524
|
+
message: `This template has an optional setup script that runs after addon install. This can be helpful for first time users to try out templates. Run the script?`,
|
|
525
|
+
default: false,
|
|
526
|
+
},
|
|
527
|
+
]);
|
|
528
|
+
if (!confirmPostInstall) {
|
|
529
|
+
return;
|
|
530
|
+
}
|
|
531
|
+
await injectEnvVariables({
|
|
532
|
+
devConfig: { ...config.dev },
|
|
533
|
+
env: command.netlify.cachedConfig.env,
|
|
534
|
+
site: command.netlify.site,
|
|
535
|
+
});
|
|
536
|
+
addonDidInstall(fnPath);
|
|
537
|
+
};
|
|
538
|
+
/**
|
|
539
|
+
*
|
|
540
|
+
* @param {import('../base-command.js').default} command
|
|
541
|
+
* @param {*} functionAddons
|
|
542
|
+
* @param {*} fnPath
|
|
543
|
+
* @returns
|
|
544
|
+
*/
|
|
545
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
|
|
546
|
+
const installAddons = async function (command, functionAddons, fnPath) {
|
|
547
|
+
if (functionAddons.length === 0) {
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
const { api, site } = command.netlify;
|
|
551
|
+
const siteId = site.id;
|
|
552
|
+
if (!siteId) {
|
|
553
|
+
log('No site id found, please run inside a site directory or `netlify link`');
|
|
554
|
+
return false;
|
|
555
|
+
}
|
|
556
|
+
log(`${NETLIFYDEVLOG} checking Netlify APIs...`);
|
|
557
|
+
const [siteData, siteAddons] = await Promise.all([getSiteData({ api, siteId }), getAddons({ api, siteId })]);
|
|
558
|
+
// @ts-expect-error TS(7031) FIXME: Binding element 'addonDidInstall' implicitly has a... Remove this comment to see the full error message
|
|
559
|
+
const arr = functionAddons.map(async ({ addonDidInstall, addonName }) => {
|
|
560
|
+
log(`${NETLIFYDEVLOG} installing addon: ${chalk.yellow.inverse(addonName)}`);
|
|
561
|
+
try {
|
|
562
|
+
const addonCreated = await createFunctionAddon({
|
|
563
|
+
api,
|
|
564
|
+
addons: siteAddons,
|
|
565
|
+
siteId,
|
|
566
|
+
addonName,
|
|
567
|
+
siteData,
|
|
568
|
+
});
|
|
569
|
+
await handleAddonDidInstall({ addonCreated, addonDidInstall, command, fnPath });
|
|
570
|
+
}
|
|
571
|
+
catch (error_) {
|
|
572
|
+
error(`${NETLIFYDEVERR} Error installing addon: ${error_}`);
|
|
573
|
+
}
|
|
574
|
+
});
|
|
575
|
+
return Promise.all(arr);
|
|
576
|
+
};
|
|
577
|
+
/**
|
|
578
|
+
*
|
|
579
|
+
* @param {string} funcName
|
|
580
|
+
* @param {import('../types.js').NetlifyOptions} options
|
|
581
|
+
*/
|
|
582
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'funcName' implicitly has an 'any' type.
|
|
583
|
+
const registerEFInToml = async (funcName, options) => {
|
|
584
|
+
const { configFilePath, relConfigFilePath } = options;
|
|
585
|
+
if (!fs.existsSync(configFilePath)) {
|
|
586
|
+
log(`${NETLIFYDEVLOG} \`${relConfigFilePath}\` file does not exist yet. Creating it...`);
|
|
587
|
+
}
|
|
588
|
+
let { funcPath } = await inquirer.prompt([
|
|
589
|
+
{
|
|
590
|
+
type: 'input',
|
|
591
|
+
name: 'funcPath',
|
|
592
|
+
message: `What route do you want your edge function to be invoked on?`,
|
|
593
|
+
default: '/test',
|
|
594
|
+
validate: (val) => Boolean(val),
|
|
595
|
+
// Make sure route isn't undefined and is valid
|
|
596
|
+
// Todo: add more validation?
|
|
597
|
+
},
|
|
598
|
+
]);
|
|
599
|
+
// Make sure path begins with a '/'
|
|
600
|
+
if (funcPath[0] !== '/') {
|
|
601
|
+
funcPath = `/${funcPath}`;
|
|
602
|
+
}
|
|
603
|
+
const functionRegister = `\n\n[[edge_functions]]\nfunction = "${funcName}"\npath = "${funcPath}"`;
|
|
604
|
+
try {
|
|
605
|
+
fs.promises.appendFile(configFilePath, functionRegister);
|
|
606
|
+
log(`${NETLIFYDEVLOG} Function '${funcName}' registered for route \`${funcPath}\`. To change, edit your \`${relConfigFilePath}\` file.`);
|
|
607
|
+
}
|
|
608
|
+
catch {
|
|
609
|
+
error(`${NETLIFYDEVERR} Unable to register function. Please check your \`${relConfigFilePath}\` file.`);
|
|
610
|
+
}
|
|
611
|
+
};
|
|
612
|
+
/**
|
|
613
|
+
* we used to allow for a --dir command,
|
|
614
|
+
* but have retired that to force every scaffolded function to be a directory
|
|
615
|
+
* @param {string} functionsDir
|
|
616
|
+
* @param {string} name
|
|
617
|
+
* @returns
|
|
618
|
+
*/
|
|
619
|
+
// @ts-expect-error TS(7006) FIXME: Parameter 'functionsDir' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
620
|
+
const ensureFunctionPathIsOk = function (functionsDir, name) {
|
|
621
|
+
const functionPath = path.join(functionsDir, name);
|
|
622
|
+
if (fs.existsSync(functionPath)) {
|
|
623
|
+
log(`${NETLIFYDEVLOG} Function ${functionPath} already exists, cancelling...`);
|
|
624
|
+
process.exit(1);
|
|
625
|
+
}
|
|
626
|
+
return functionPath;
|
|
627
|
+
};
|
|
628
|
+
export const functionsCreate = async (name, options, command) => {
|
|
629
|
+
const functionType = await selectTypeOfFunc();
|
|
630
|
+
const functionsDir = functionType === 'edge' ? await ensureEdgeFuncDirExists(command) : await ensureFunctionDirExists(command);
|
|
631
|
+
/* either download from URL or scaffold from template */
|
|
632
|
+
const mainFunc = options.url ? downloadFromURL : scaffoldFromTemplate;
|
|
633
|
+
await mainFunc(command, options, name, functionsDir, functionType);
|
|
634
|
+
};
|
|
635
|
+
//# sourceMappingURL=functions-create.js.map
|