netlify-cli 19.1.5 → 19.1.7
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/bin/run.js +31 -23
- package/dist/commands/api/api.d.ts +3 -3
- package/dist/commands/api/api.d.ts.map +1 -1
- package/dist/commands/api/api.js +10 -8
- package/dist/commands/api/api.js.map +1 -1
- package/dist/commands/base-command.d.ts +8 -8
- package/dist/commands/base-command.d.ts.map +1 -1
- package/dist/commands/base-command.js +42 -31
- package/dist/commands/base-command.js.map +1 -1
- package/dist/commands/blobs/blobs-delete.d.ts +1 -1
- package/dist/commands/blobs/blobs-delete.d.ts.map +1 -1
- package/dist/commands/blobs/blobs-delete.js +2 -3
- package/dist/commands/blobs/blobs-delete.js.map +1 -1
- package/dist/commands/blobs/blobs-get.d.ts +1 -1
- package/dist/commands/blobs/blobs-get.d.ts.map +1 -1
- package/dist/commands/blobs/blobs-get.js +3 -5
- package/dist/commands/blobs/blobs-get.js.map +1 -1
- package/dist/commands/blobs/blobs-list.d.ts +1 -1
- package/dist/commands/blobs/blobs-list.d.ts.map +1 -1
- package/dist/commands/blobs/blobs-list.js +3 -4
- package/dist/commands/blobs/blobs-list.js.map +1 -1
- package/dist/commands/blobs/blobs-set.d.ts +1 -1
- package/dist/commands/blobs/blobs-set.d.ts.map +1 -1
- package/dist/commands/blobs/blobs-set.js +7 -12
- package/dist/commands/blobs/blobs-set.js.map +1 -1
- package/dist/commands/build/build.d.ts +2 -2
- package/dist/commands/build/build.d.ts.map +1 -1
- package/dist/commands/build/build.js +5 -5
- package/dist/commands/build/build.js.map +1 -1
- package/dist/commands/completion/completion.d.ts +2 -2
- package/dist/commands/completion/completion.d.ts.map +1 -1
- package/dist/commands/completion/completion.js +3 -5
- package/dist/commands/completion/completion.js.map +1 -1
- package/dist/commands/deploy/deploy.d.ts +2 -2
- package/dist/commands/deploy/deploy.d.ts.map +1 -1
- package/dist/commands/deploy/deploy.js +24 -34
- package/dist/commands/deploy/deploy.js.map +1 -1
- package/dist/commands/dev/dev.d.ts +1 -1
- package/dist/commands/dev/dev.d.ts.map +1 -1
- package/dist/commands/dev/dev.js +12 -22
- package/dist/commands/dev/dev.js.map +1 -1
- package/dist/commands/env/env-clone.d.ts.map +1 -1
- package/dist/commands/env/env-clone.js +3 -5
- package/dist/commands/env/env-clone.js.map +1 -1
- package/dist/commands/env/env-set.d.ts.map +1 -1
- package/dist/commands/env/env-set.js +4 -7
- package/dist/commands/env/env-set.js.map +1 -1
- package/dist/commands/functions/functions-build.d.ts +2 -2
- package/dist/commands/functions/functions-build.d.ts.map +1 -1
- package/dist/commands/functions/functions-build.js +1 -3
- package/dist/commands/functions/functions-build.js.map +1 -1
- package/dist/commands/functions/functions-create.d.ts.map +1 -1
- package/dist/commands/functions/functions-create.js +10 -14
- package/dist/commands/functions/functions-create.js.map +1 -1
- package/dist/commands/functions/functions-invoke.d.ts +1 -1
- package/dist/commands/functions/functions-invoke.d.ts.map +1 -1
- package/dist/commands/functions/functions-invoke.js +4 -4
- package/dist/commands/functions/functions-invoke.js.map +1 -1
- package/dist/commands/functions/functions-list.d.ts.map +1 -1
- package/dist/commands/functions/functions-list.js +4 -5
- package/dist/commands/functions/functions-list.js.map +1 -1
- package/dist/commands/functions/functions-serve.d.ts.map +1 -1
- package/dist/commands/functions/functions-serve.js +2 -1
- package/dist/commands/functions/functions-serve.js.map +1 -1
- package/dist/commands/init/init.d.ts +3 -2
- package/dist/commands/init/init.d.ts.map +1 -1
- package/dist/commands/init/init.js +21 -46
- package/dist/commands/init/init.js.map +1 -1
- package/dist/commands/link/link.d.ts +2 -1
- package/dist/commands/link/link.d.ts.map +1 -1
- package/dist/commands/link/link.js +38 -37
- package/dist/commands/link/link.js.map +1 -1
- package/dist/commands/main.d.ts +0 -2
- package/dist/commands/main.d.ts.map +1 -1
- package/dist/commands/main.js +13 -13
- package/dist/commands/main.js.map +1 -1
- package/dist/commands/open/open-admin.d.ts +2 -3
- package/dist/commands/open/open-admin.d.ts.map +1 -1
- package/dist/commands/open/open-admin.js +1 -2
- package/dist/commands/open/open-admin.js.map +1 -1
- package/dist/commands/open/open-site.d.ts.map +1 -1
- package/dist/commands/open/open-site.js +0 -1
- package/dist/commands/open/open-site.js.map +1 -1
- package/dist/commands/serve/serve.d.ts +2 -2
- package/dist/commands/serve/serve.d.ts.map +1 -1
- package/dist/commands/serve/serve.js +2 -2
- package/dist/commands/serve/serve.js.map +1 -1
- package/dist/commands/sites/sites-create-template.d.ts +4 -4
- package/dist/commands/sites/sites-create-template.d.ts.map +1 -1
- package/dist/commands/sites/sites-create-template.js +20 -15
- package/dist/commands/sites/sites-create-template.js.map +1 -1
- package/dist/commands/sites/sites-create.d.ts +4 -3
- package/dist/commands/sites/sites-create.d.ts.map +1 -1
- package/dist/commands/sites/sites-create.js +9 -12
- package/dist/commands/sites/sites-create.js.map +1 -1
- package/dist/commands/sites/sites-delete.d.ts +3 -3
- package/dist/commands/sites/sites-delete.d.ts.map +1 -1
- package/dist/commands/sites/sites-delete.js +7 -10
- package/dist/commands/sites/sites-delete.js.map +1 -1
- package/dist/commands/status/status-hooks.d.ts +3 -3
- package/dist/commands/status/status-hooks.d.ts.map +1 -1
- package/dist/commands/status/status-hooks.js +8 -7
- package/dist/commands/status/status-hooks.js.map +1 -1
- package/dist/commands/status/status.d.ts +1 -1
- package/dist/commands/status/status.d.ts.map +1 -1
- package/dist/commands/status/status.js +10 -9
- package/dist/commands/status/status.js.map +1 -1
- package/dist/commands/watch/watch.d.ts +2 -3
- package/dist/commands/watch/watch.d.ts.map +1 -1
- package/dist/commands/watch/watch.js +3 -3
- package/dist/commands/watch/watch.js.map +1 -1
- package/dist/lib/api.d.ts +10 -6
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +8 -6
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/build.d.ts +86 -15
- package/dist/lib/build.d.ts.map +1 -1
- package/dist/lib/build.js +6 -4
- package/dist/lib/build.js.map +1 -1
- package/dist/lib/edge-functions/proxy.d.ts +17 -18
- package/dist/lib/edge-functions/proxy.d.ts.map +1 -1
- package/dist/lib/edge-functions/proxy.js +6 -11
- package/dist/lib/edge-functions/proxy.js.map +1 -1
- package/dist/lib/edge-functions/registry.d.ts +3 -7
- package/dist/lib/edge-functions/registry.d.ts.map +1 -1
- package/dist/lib/edge-functions/registry.js.map +1 -1
- package/dist/lib/exec-fetcher.d.ts +15 -26
- package/dist/lib/exec-fetcher.d.ts.map +1 -1
- package/dist/lib/exec-fetcher.js +9 -37
- package/dist/lib/exec-fetcher.js.map +1 -1
- package/dist/lib/fs.d.ts +3 -5
- package/dist/lib/fs.d.ts.map +1 -1
- package/dist/lib/fs.js +9 -16
- package/dist/lib/fs.js.map +1 -1
- package/dist/lib/functions/background.d.ts +4 -2
- package/dist/lib/functions/background.d.ts.map +1 -1
- package/dist/lib/functions/background.js +0 -2
- package/dist/lib/functions/background.js.map +1 -1
- package/dist/lib/functions/config.d.ts +22 -5
- package/dist/lib/functions/config.d.ts.map +1 -1
- package/dist/lib/functions/config.js +8 -14
- package/dist/lib/functions/config.js.map +1 -1
- package/dist/lib/functions/form-submissions-handler.d.ts.map +1 -1
- package/dist/lib/functions/form-submissions-handler.js +8 -5
- package/dist/lib/functions/form-submissions-handler.js.map +1 -1
- package/dist/lib/functions/local-proxy.d.ts +8 -8
- package/dist/lib/functions/local-proxy.d.ts.map +1 -1
- package/dist/lib/functions/local-proxy.js +4 -6
- package/dist/lib/functions/local-proxy.js.map +1 -1
- package/dist/lib/functions/memoized-build.d.ts +10 -5
- package/dist/lib/functions/memoized-build.d.ts.map +1 -1
- package/dist/lib/functions/memoized-build.js +3 -4
- package/dist/lib/functions/memoized-build.js.map +1 -1
- package/dist/lib/functions/netlify-function.d.ts +56 -36
- package/dist/lib/functions/netlify-function.d.ts.map +1 -1
- package/dist/lib/functions/netlify-function.js +24 -48
- package/dist/lib/functions/netlify-function.js.map +1 -1
- package/dist/lib/functions/registry.d.ts +41 -21
- package/dist/lib/functions/registry.d.ts.map +1 -1
- package/dist/lib/functions/registry.js +37 -71
- package/dist/lib/functions/registry.js.map +1 -1
- package/dist/lib/functions/runtimes/go/index.d.ts +9 -23
- package/dist/lib/functions/runtimes/go/index.d.ts.map +1 -1
- package/dist/lib/functions/runtimes/go/index.js +8 -11
- package/dist/lib/functions/runtimes/go/index.js.map +1 -1
- package/dist/lib/functions/runtimes/index.d.ts +41 -24
- package/dist/lib/functions/runtimes/index.d.ts.map +1 -1
- package/dist/lib/functions/runtimes/index.js.map +1 -1
- package/dist/lib/functions/runtimes/js/builders/netlify-lambda.d.ts +10 -8
- package/dist/lib/functions/runtimes/js/builders/netlify-lambda.d.ts.map +1 -1
- package/dist/lib/functions/runtimes/js/builders/netlify-lambda.js +17 -14
- package/dist/lib/functions/runtimes/js/builders/netlify-lambda.js.map +1 -1
- package/dist/lib/functions/runtimes/js/builders/zisi.d.ts +28 -39
- package/dist/lib/functions/runtimes/js/builders/zisi.d.ts.map +1 -1
- package/dist/lib/functions/runtimes/js/builders/zisi.js +38 -83
- package/dist/lib/functions/runtimes/js/builders/zisi.js.map +1 -1
- package/dist/lib/functions/runtimes/js/index.d.ts +17 -21
- package/dist/lib/functions/runtimes/js/index.d.ts.map +1 -1
- package/dist/lib/functions/runtimes/js/index.js +26 -19
- package/dist/lib/functions/runtimes/js/index.js.map +1 -1
- package/dist/lib/functions/runtimes/js/worker.d.ts +7 -1
- package/dist/lib/functions/runtimes/js/worker.d.ts.map +1 -1
- package/dist/lib/functions/runtimes/js/worker.js +26 -15
- package/dist/lib/functions/runtimes/js/worker.js.map +1 -1
- package/dist/lib/functions/runtimes/rust/index.d.ts +8 -22
- package/dist/lib/functions/runtimes/rust/index.d.ts.map +1 -1
- package/dist/lib/functions/runtimes/rust/index.js +13 -10
- package/dist/lib/functions/runtimes/rust/index.js.map +1 -1
- package/dist/lib/functions/scheduled.d.ts +15 -11
- package/dist/lib/functions/scheduled.d.ts.map +1 -1
- package/dist/lib/functions/scheduled.js +6 -10
- package/dist/lib/functions/scheduled.js.map +1 -1
- package/dist/lib/functions/server.d.ts +19 -12
- package/dist/lib/functions/server.d.ts.map +1 -1
- package/dist/lib/functions/server.js +17 -25
- package/dist/lib/functions/server.js.map +1 -1
- package/dist/lib/functions/synchronous.d.ts +9 -6
- package/dist/lib/functions/synchronous.d.ts.map +1 -1
- package/dist/lib/functions/synchronous.js +36 -40
- package/dist/lib/functions/synchronous.js.map +1 -1
- package/dist/lib/functions/utils.d.ts +5 -8
- package/dist/lib/functions/utils.d.ts.map +1 -1
- package/dist/lib/functions/utils.js +8 -10
- package/dist/lib/functions/utils.js.map +1 -1
- package/dist/lib/geo-location.d.ts +1 -1
- package/dist/lib/geo-location.js +1 -1
- package/dist/lib/images/proxy.d.ts +5 -9
- package/dist/lib/images/proxy.d.ts.map +1 -1
- package/dist/lib/images/proxy.js +10 -12
- package/dist/lib/images/proxy.js.map +1 -1
- package/dist/lib/path.d.ts +1 -1
- package/dist/lib/path.d.ts.map +1 -1
- package/dist/lib/path.js +0 -1
- package/dist/lib/path.js.map +1 -1
- package/dist/recipes/ai-context/index.d.ts +1 -1
- package/dist/recipes/ai-context/index.d.ts.map +1 -1
- package/dist/recipes/ai-context/index.js +3 -5
- package/dist/recipes/ai-context/index.js.map +1 -1
- package/dist/recipes/blobs-migrate/index.d.ts +1 -1
- package/dist/recipes/blobs-migrate/index.d.ts.map +1 -1
- package/dist/recipes/blobs-migrate/index.js +6 -8
- package/dist/recipes/blobs-migrate/index.js.map +1 -1
- package/dist/recipes/vscode/index.d.ts +1 -1
- package/dist/recipes/vscode/index.d.ts.map +1 -1
- package/dist/recipes/vscode/index.js +2 -2
- package/dist/recipes/vscode/index.js.map +1 -1
- package/dist/recipes/vscode/settings.js +1 -1
- package/dist/recipes/vscode/settings.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/utils/addons/prepare.js +3 -3
- package/dist/utils/addons/prepare.js.map +1 -1
- package/dist/utils/build-info.d.ts +4 -4
- package/dist/utils/build-info.d.ts.map +1 -1
- package/dist/utils/build-info.js +0 -1
- package/dist/utils/build-info.js.map +1 -1
- package/dist/utils/{state-config.d.ts → cli-state.d.ts} +4 -3
- package/dist/utils/cli-state.d.ts.map +1 -0
- package/dist/utils/{state-config.js → cli-state.js} +3 -10
- package/dist/utils/cli-state.js.map +1 -0
- package/dist/utils/command-helpers.d.ts +15 -21
- package/dist/utils/command-helpers.d.ts.map +1 -1
- package/dist/utils/command-helpers.js +29 -45
- package/dist/utils/command-helpers.js.map +1 -1
- package/dist/utils/create-deferred.d.ts +4 -4
- package/dist/utils/create-deferred.d.ts.map +1 -1
- package/dist/utils/create-deferred.js.map +1 -1
- package/dist/utils/detect-server-settings.d.ts +94 -1
- package/dist/utils/detect-server-settings.d.ts.map +1 -1
- package/dist/utils/detect-server-settings.js +17 -17
- package/dist/utils/detect-server-settings.js.map +1 -1
- package/dist/utils/dev.d.ts.map +1 -1
- package/dist/utils/dev.js +4 -4
- package/dist/utils/dev.js.map +1 -1
- package/dist/utils/env/index.js +2 -2
- package/dist/utils/env/index.js.map +1 -1
- package/dist/utils/feature-flags.d.ts +3 -7
- package/dist/utils/feature-flags.d.ts.map +1 -1
- package/dist/utils/feature-flags.js +0 -4
- package/dist/utils/feature-flags.js.map +1 -1
- package/dist/utils/framework-server.d.ts +1 -1
- package/dist/utils/framework-server.d.ts.map +1 -1
- package/dist/utils/framework-server.js +3 -4
- package/dist/utils/framework-server.js.map +1 -1
- package/dist/utils/frameworks-api.d.ts +1 -1
- package/dist/utils/frameworks-api.d.ts.map +1 -1
- package/dist/utils/functions/functions.d.ts +11 -14
- package/dist/utils/functions/functions.d.ts.map +1 -1
- package/dist/utils/functions/functions.js +6 -12
- package/dist/utils/functions/functions.js.map +1 -1
- package/dist/utils/get-cli-package-json.d.ts +4 -0
- package/dist/utils/get-cli-package-json.d.ts.map +1 -0
- package/dist/utils/get-cli-package-json.js +22 -0
- package/dist/utils/get-cli-package-json.js.map +1 -0
- package/dist/utils/get-global-config-store.d.ts +16 -0
- package/dist/utils/get-global-config-store.d.ts.map +1 -0
- package/dist/utils/get-global-config-store.js +87 -0
- package/dist/utils/get-global-config-store.js.map +1 -0
- package/dist/utils/get-repo-data.d.ts +8 -22
- package/dist/utils/get-repo-data.d.ts.map +1 -1
- package/dist/utils/get-repo-data.js +3 -10
- package/dist/utils/get-repo-data.js.map +1 -1
- package/dist/utils/get-site.d.ts +3 -1
- package/dist/utils/get-site.d.ts.map +1 -1
- package/dist/utils/get-site.js +5 -6
- package/dist/utils/get-site.js.map +1 -1
- package/dist/utils/gh-auth.d.ts +7 -4
- package/dist/utils/gh-auth.d.ts.map +1 -1
- package/dist/utils/gh-auth.js +6 -18
- package/dist/utils/gh-auth.js.map +1 -1
- package/dist/utils/headers.d.ts +7 -13
- package/dist/utils/headers.d.ts.map +1 -1
- package/dist/utils/headers.js +4 -16
- package/dist/utils/headers.js.map +1 -1
- package/dist/utils/hooks/requires-site-info.d.ts +2 -2
- package/dist/utils/hooks/requires-site-info.d.ts.map +1 -1
- package/dist/utils/hooks/requires-site-info.js +7 -11
- package/dist/utils/hooks/requires-site-info.js.map +1 -1
- package/dist/utils/init/config-github.d.ts +9 -15
- package/dist/utils/init/config-github.d.ts.map +1 -1
- package/dist/utils/init/config-github.js +13 -42
- package/dist/utils/init/config-github.js.map +1 -1
- package/dist/utils/init/config-manual.d.ts +6 -10
- package/dist/utils/init/config-manual.d.ts.map +1 -1
- package/dist/utils/init/config-manual.js +9 -32
- package/dist/utils/init/config-manual.js.map +1 -1
- package/dist/utils/init/config.d.ts +7 -12
- package/dist/utils/init/config.d.ts.map +1 -1
- package/dist/utils/init/config.js +4 -13
- package/dist/utils/init/config.js.map +1 -1
- package/dist/utils/init/plugins.d.ts +6 -2
- package/dist/utils/init/plugins.d.ts.map +1 -1
- package/dist/utils/init/plugins.js +3 -12
- package/dist/utils/init/plugins.js.map +1 -1
- package/dist/utils/init/utils.d.ts +134 -34
- package/dist/utils/init/utils.d.ts.map +1 -1
- package/dist/utils/init/utils.js +16 -49
- package/dist/utils/init/utils.js.map +1 -1
- package/dist/utils/live-tunnel.d.ts +8 -7
- package/dist/utils/live-tunnel.d.ts.map +1 -1
- package/dist/utils/live-tunnel.js +18 -26
- package/dist/utils/live-tunnel.js.map +1 -1
- package/dist/utils/nodejs-compile-cache.d.ts +24 -0
- package/dist/utils/nodejs-compile-cache.d.ts.map +1 -0
- package/dist/utils/nodejs-compile-cache.js +44 -0
- package/dist/utils/nodejs-compile-cache.js.map +1 -0
- package/dist/utils/open-browser.d.ts +1 -1
- package/dist/utils/open-browser.d.ts.map +1 -1
- package/dist/utils/proxy-server.d.ts +10 -9
- package/dist/utils/proxy-server.d.ts.map +1 -1
- package/dist/utils/proxy-server.js.map +1 -1
- package/dist/utils/proxy.d.ts +6 -3
- package/dist/utils/proxy.d.ts.map +1 -1
- package/dist/utils/proxy.js +13 -21
- package/dist/utils/proxy.js.map +1 -1
- package/dist/utils/rules-proxy.d.ts +12 -10
- package/dist/utils/rules-proxy.d.ts.map +1 -1
- package/dist/utils/rules-proxy.js +4 -21
- package/dist/utils/rules-proxy.js.map +1 -1
- package/dist/utils/run-build.d.ts +0 -9
- package/dist/utils/run-build.d.ts.map +1 -1
- package/dist/utils/run-build.js +4 -8
- package/dist/utils/run-build.js.map +1 -1
- package/dist/utils/sites/create-template.d.ts +1 -1
- package/dist/utils/sites/create-template.d.ts.map +1 -1
- package/dist/utils/sites/create-template.js.map +1 -1
- package/dist/utils/sites/utils.d.ts.map +1 -1
- package/dist/utils/sites/utils.js +2 -2
- package/dist/utils/sites/utils.js.map +1 -1
- package/dist/utils/telemetry/report-error.js +2 -2
- package/dist/utils/telemetry/report-error.js.map +1 -1
- package/dist/utils/telemetry/request.js +1 -1
- package/dist/utils/telemetry/request.js.map +1 -1
- package/dist/utils/telemetry/telemetry.js +3 -3
- package/dist/utils/telemetry/telemetry.js.map +1 -1
- package/dist/utils/telemetry/utils.d.ts +1 -1
- package/dist/utils/telemetry/utils.d.ts.map +1 -1
- package/dist/utils/telemetry/utils.js +2 -2
- package/dist/utils/telemetry/utils.js.map +1 -1
- package/dist/utils/types.d.ts +17 -5
- package/dist/utils/types.d.ts.map +1 -1
- package/dist/utils/types.js +1 -1
- package/dist/utils/types.js.map +1 -1
- package/npm-shrinkwrap.json +394 -346
- package/package.json +12 -13
- package/dist/utils/get-global-config.d.ts +0 -7
- package/dist/utils/get-global-config.d.ts.map +0 -1
- package/dist/utils/get-global-config.js +0 -41
- package/dist/utils/get-global-config.js.map +0 -1
- package/dist/utils/get-package-json.d.ts +0 -3
- package/dist/utils/get-package-json.d.ts.map +0 -1
- package/dist/utils/get-package-json.js +0 -16
- package/dist/utils/get-package-json.js.map +0 -1
- package/dist/utils/state-config.d.ts.map +0 -1
- package/dist/utils/state-config.js.map +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { readFile } from 'fs/promises';
|
|
2
2
|
import { resolve } from 'path';
|
|
3
3
|
import { Command } from 'commander';
|
|
4
|
+
import normalizePackageData from 'normalize-package-data';
|
|
4
5
|
import execa from '../../../../../utils/execa.js';
|
|
5
6
|
import { fileExistsAsync } from '../../../../fs.js';
|
|
6
7
|
import { memoizedBuild } from '../../../memoized-build.js';
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!((dependencies && dependencies['netlify-lambda']) || (devDependencies && devDependencies['netlify-lambda']))) {
|
|
8
|
+
export const detectNetlifyLambda = async ({ packageJson }) => {
|
|
9
|
+
const { dependencies, devDependencies, scripts } = packageJson;
|
|
10
|
+
if (!(dependencies?.['netlify-lambda'] || devDependencies?.['netlify-lambda'])) {
|
|
11
11
|
return false;
|
|
12
12
|
}
|
|
13
13
|
const program = new Command()
|
|
@@ -17,18 +17,20 @@ export const detectNetlifyLambda = async function ({ packageJson } = {}) {
|
|
|
17
17
|
.option('-b, --babelrc [file]')
|
|
18
18
|
.option('-t, --timeout [delay]');
|
|
19
19
|
program.allowExcessArguments();
|
|
20
|
-
|
|
21
|
-
const matchingScripts = Object.entries(scripts).filter(([, script]) => script.match(/netlify-lambda\s+build/));
|
|
20
|
+
const matchingScripts = Object.entries(scripts ?? []).filter(([, script]) => /netlify-lambda\s+build/.exec(script));
|
|
22
21
|
for (const [key, script] of matchingScripts) {
|
|
23
22
|
// E.g. ["netlify-lambda", "build", "functions/folder"]
|
|
24
23
|
// these are all valid options for netlify-lambda
|
|
25
|
-
program.parse(script.split(' ')
|
|
24
|
+
program.parse(script.split(' '));
|
|
26
25
|
// We are not interested in 'netlify-lambda' and 'build' commands
|
|
27
26
|
const functionDirectories = program.args.filter((arg) => !['netlify-lambda', 'build'].includes(arg));
|
|
28
27
|
if (functionDirectories.length === 1) {
|
|
29
28
|
const srcFiles = [resolve(functionDirectories[0])];
|
|
30
29
|
const yarnExists = await fileExistsAsync('yarn.lock');
|
|
31
|
-
const buildCommand = () =>
|
|
30
|
+
const buildCommand = async () => {
|
|
31
|
+
await execa(yarnExists ? 'yarn' : 'npm', ['run', key]);
|
|
32
|
+
return;
|
|
33
|
+
};
|
|
32
34
|
return {
|
|
33
35
|
build: async ({ cache = {} } = {}) => {
|
|
34
36
|
await memoizedBuild({ cache, cacheKey: `netlify-lambda-${key}`, command: buildCommand });
|
|
@@ -50,13 +52,14 @@ export const detectNetlifyLambda = async function ({ packageJson } = {}) {
|
|
|
50
52
|
}
|
|
51
53
|
return false;
|
|
52
54
|
};
|
|
53
|
-
export default async function
|
|
54
|
-
|
|
55
|
-
|
|
55
|
+
export default async function detectNetlifyLambdaBuilder() {
|
|
56
|
+
try {
|
|
57
|
+
const packageData = JSON.parse(await readFile('package.json', 'utf-8'));
|
|
58
|
+
normalizePackageData(packageData);
|
|
59
|
+
return await detectNetlifyLambda({ packageJson: packageData });
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
56
62
|
return false;
|
|
57
63
|
}
|
|
58
|
-
const content = await readFile('package.json', 'utf-8');
|
|
59
|
-
const packageJson = JSON.parse(content);
|
|
60
|
-
return detectNetlifyLambda({ packageJson });
|
|
61
64
|
}
|
|
62
65
|
//# sourceMappingURL=netlify-lambda.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"netlify-lambda.js","sourceRoot":"","sources":["../../../../../../src/lib/functions/runtimes/js/builders/netlify-lambda.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"netlify-lambda.js","sourceRoot":"","sources":["../../../../../../src/lib/functions/runtimes/js/builders/netlify-lambda.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAE9B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAA;AACnC,OAAO,oBAAsC,MAAM,wBAAwB,CAAA;AAE3E,OAAO,KAAK,MAAM,+BAA+B,CAAA;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAK1D,MAAM,CAAC,MAAM,mBAAmB,GAAG,KAAK,EAAE,EAAE,WAAW,EAA4B,EAAE,EAAE;IACrF,MAAM,EAAE,YAAY,EAAE,eAAe,EAAE,OAAO,EAAE,GAAG,WAAW,CAAA;IAC9D,IAAI,CAAC,CAAC,YAAY,EAAE,CAAC,gBAAgB,CAAC,IAAI,eAAe,EAAE,CAAC,gBAAgB,CAAC,CAAC,EAAE,CAAC;QAC/E,OAAO,KAAK,CAAA;IACd,CAAC;IAED,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE;SAC1B,MAAM,CAAC,cAAc,CAAC;SACtB,MAAM,CAAC,qBAAqB,CAAC;SAC7B,MA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AAK,EAAE,QAAQ,EAAE,kBAAkB,GAAG,EAAE,EAAE,OAAO,EAAE,YAAY,EAAE,CAAC,CAAA;oBAExF,OAAO;wBACL,QAAQ;qBACT,CAAA;gBACH,CAAC;gBACD,WAAW,EAAE,gBAAgB;gBAE7B,iCAAiC;gBACjC,SAAS,EAAE,GAAG;aACf,CAAA;QACH,CAAC;QACD,IAAI,mBAAmB,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACrC,OAAO,CAAC,IAAI,CAAC,0DAA0D,GAAG,sCAAsC,CAAC,CAAA;QACnH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CACV,0DAA0D,GAAG,6CAA6C,CAC3G,CAAA;QACH,CAAC;IACH,CAAC;IAED,OAAO,KAAK,CAAA;AACd,CAAC,CAAA;AAED,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,0BAA0B;IACtD,IAAI,CAAC;QACH,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CAA4B,CAAA;QAClG,oBAAoB,CAAC,WAAW,CAAC,CAAA;QACjC,OAAO,MAAM,mBAAmB,CAAC,EAAE,WAAW,EAAE,WAAsB,EAAE,CAAC,CAAA;IAC3E,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAA;IACd,CAAC;AACH,CAAC"}
|
|
@@ -1,46 +1,35 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
1
|
+
import { type FunctionResult } from '@netlify/zip-it-and-ship-it';
|
|
2
|
+
import { type NormalizedCachedConfigConfig } from '../../../../../utils/command-helpers.js';
|
|
3
|
+
import { type BuildCommandCache } from '../../../memoized-build.js';
|
|
4
|
+
import type NetlifyFunction from '../../../netlify-function.js';
|
|
5
|
+
import type { BaseBuildResult } from '../../index.js';
|
|
6
|
+
import type { JsBuildResult } from '../index.js';
|
|
7
|
+
export type ZisiBuildResult = BaseBuildResult & {
|
|
8
|
+
buildPath: string;
|
|
9
|
+
includedFiles: FunctionResult['includedFiles'];
|
|
10
|
+
outputModuleFormat: FunctionResult['outputModuleFormat'];
|
|
11
|
+
mainFile: FunctionResult['mainFile'];
|
|
12
|
+
runtimeAPIVersion: FunctionResult['runtimeAPIVersion'];
|
|
13
|
+
};
|
|
14
|
+
export declare const getFunctionMetadata: ({ config, mainFile, projectRoot, }: {
|
|
15
|
+
config: NormalizedCachedConfigConfig;
|
|
16
|
+
mainFile: string;
|
|
17
|
+
projectRoot: string;
|
|
11
18
|
}) => Promise<import("@netlify/zip-it-and-ship-it").ListedFunction | undefined>;
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
* @param {string} param0.projectRoot
|
|
21
|
-
*/
|
|
22
|
-
export default function handler({ config, directory, errorExit, func, metadata, projectRoot }: {
|
|
23
|
-
config: any;
|
|
24
|
-
directory: any;
|
|
25
|
-
errorExit: any;
|
|
26
|
-
func: any;
|
|
27
|
-
metadata: any;
|
|
28
|
-
projectRoot: any;
|
|
19
|
+
type FunctionMetadata = NonNullable<Awaited<ReturnType<typeof getFunctionMetadata>>>;
|
|
20
|
+
export default function detectZisiBuilder({ config, directory, errorExit, func, metadata, projectRoot, }: {
|
|
21
|
+
config: NormalizedCachedConfigConfig;
|
|
22
|
+
directory?: string | undefined;
|
|
23
|
+
errorExit: (msg: string) => void;
|
|
24
|
+
func: NetlifyFunction<JsBuildResult>;
|
|
25
|
+
metadata?: FunctionMetadata | undefined;
|
|
26
|
+
projectRoot: string;
|
|
29
27
|
}): Promise<false | {
|
|
30
28
|
build: ({ cache }: {
|
|
31
|
-
cache?:
|
|
32
|
-
}) => Promise<
|
|
33
|
-
buildPath: string;
|
|
34
|
-
excludedRoutes: any;
|
|
35
|
-
includedFiles: any;
|
|
36
|
-
outputModuleFormat: any;
|
|
37
|
-
mainFile: any;
|
|
38
|
-
routes: any;
|
|
39
|
-
runtimeAPIVersion: any;
|
|
40
|
-
srcFiles: any;
|
|
41
|
-
schedule: any;
|
|
42
|
-
}>;
|
|
29
|
+
cache?: BuildCommandCache<FunctionResult>;
|
|
30
|
+
}) => Promise<ZisiBuildResult>;
|
|
43
31
|
builderName: string;
|
|
44
32
|
target: string;
|
|
45
33
|
}>;
|
|
34
|
+
export {};
|
|
46
35
|
//# sourceMappingURL=zisi.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zisi.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/functions/runtimes/js/builders/zisi.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"zisi.d.ts","sourceRoot":"","sources":["../../../../../../src/lib/functions/runtimes/js/builders/zisi.ts"],"names":[],"mappings":"AAIA,OAAO,EAA6C,KAAK,cAAc,EAAE,MAAM,6BAA6B,CAAA;AAO5G,OAAO,EAAiB,KAAK,4BAA4B,EAAE,MAAM,yCAAyC,CAAA;AAI1G,OAAO,EAAE,KAAK,iBAAiB,EAAiB,MAAM,4BAA4B,CAAA;AAClF,OAAO,KAAK,eAAe,MAAM,8BAA8B,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AACrD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAIhD,MAAM,MAAM,eAAe,GAAG,eAAe,GAAG;IAC9C,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,cAAc,CAAC,eAAe,CAAC,CAAA;IAC9C,kBAAkB,EAAE,cAAc,CAAC,oBAAoB,CAAC,CAAA;IACxD,QAAQ,EAAE,cAAc,CAAC,UAAU,CAAC,CAAA;IACpC,iBAAiB,EAAE,cAAc,CAAC,mBAAmB,CAAC,CAAA;CACvD,CAAA;AAkGD,eAAO,MAAM,mBAAmB,uCAI7B;IACD,MAAM,EAAE,4BAA4B,CAAA;IACpC,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;CACpB,8EAMG,CAAA;AAEJ,KAAK,gBAAgB,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,OAAO,mBAAmB,CAAC,CAAC,CAAC,CAAA;AAqCpF,wBAA8B,iBAAiB,CAAC,EAC9C,MAAM,EACN,SAAS,EACT,SAAS,EACT,IAAI,EACJ,QAAQ,EACR,WAAW,GACZ,EAAE;IACD,MAAM,EAAE,4BAA4B,CAAA;IACpC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;IAC9B,SAAS,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAA;IAGhC,IAAI,EAAE,eAAe,CAAC,aAAa,CAAC,CAAA;IACpC,QAAQ,CAAC,EAAE,gBAAgB,GAAG,SAAS,CAAA;IACvC,WAAW,EAAE,MAAM,CAAA;CACpB;uBAoCsC;QAAE,KAAK,CAAC,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAA;KAAE;;;GAiBnF"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { mkdir, writeFile } from 'fs/promises';
|
|
2
2
|
import { createRequire } from 'module';
|
|
3
3
|
import path from 'path';
|
|
4
|
-
import { zipFunction, listFunction } from '@netlify/zip-it-and-ship-it';
|
|
4
|
+
import { ARCHIVE_FORMAT, zipFunction, listFunction } from '@netlify/zip-it-and-ship-it';
|
|
5
5
|
import decache from 'decache';
|
|
6
6
|
import { readPackageUp } from 'read-package-up';
|
|
7
7
|
import sourceMapSupport from 'source-map-support';
|
|
@@ -11,7 +11,6 @@ import { getPathInProject } from '../../../../settings.js';
|
|
|
11
11
|
import { normalizeFunctionsConfig } from '../../../config.js';
|
|
12
12
|
import { memoizedBuild } from '../../../memoized-build.js';
|
|
13
13
|
const require = createRequire(import.meta.url);
|
|
14
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'config' implicitly has an 'any' type.
|
|
15
14
|
const addFunctionsConfigDefaults = (config) => ({
|
|
16
15
|
...config,
|
|
17
16
|
'*': {
|
|
@@ -19,29 +18,9 @@ const addFunctionsConfigDefaults = (config) => ({
|
|
|
19
18
|
...config['*'],
|
|
20
19
|
},
|
|
21
20
|
});
|
|
22
|
-
|
|
23
|
-
* @param {object} params
|
|
24
|
-
* @param {import("@netlify/zip-it-and-ship-it/dist/feature_flags.js").FeatureFlags} params.featureFlags
|
|
25
|
-
*/
|
|
26
|
-
const buildFunction = async ({
|
|
27
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'cache' implicitly has an 'any' ty... Remove this comment to see the full error message
|
|
28
|
-
cache,
|
|
29
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
30
|
-
config,
|
|
31
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'directory' implicitly has an 'any... Remove this comment to see the full error message
|
|
32
|
-
directory,
|
|
33
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'featureFlags' implicitly has an '... Remove this comment to see the full error message
|
|
34
|
-
featureFlags,
|
|
35
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'func' implicitly has an 'any' typ... Remove this comment to see the full error message
|
|
36
|
-
func,
|
|
37
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'hasTypeModule' implicitly has an ... Remove this comment to see the full error message
|
|
38
|
-
hasTypeModule,
|
|
39
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'projectRoot' implicitly has an 'a... Remove this comment to see the full error message
|
|
40
|
-
projectRoot,
|
|
41
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'targetDirectory' implicitly has a... Remove this comment to see the full error message
|
|
42
|
-
targetDirectory, }) => {
|
|
21
|
+
const buildFunction = async ({ cache, config, directory, featureFlags, func, hasTypeModule, projectRoot, targetDirectory, }) => {
|
|
43
22
|
const zipOptions = {
|
|
44
|
-
archiveFormat:
|
|
23
|
+
archiveFormat: ARCHIVE_FORMAT.NONE,
|
|
45
24
|
basePath: projectRoot,
|
|
46
25
|
config,
|
|
47
26
|
featureFlags: { ...featureFlags, zisi_functions_api_v2: true },
|
|
@@ -58,16 +37,20 @@ targetDirectory, }) => {
|
|
|
58
37
|
const { entryFilename, excludedRoutes, includedFiles, inputs, mainFile, outputModuleFormat, path: functionPath, routes, runtimeAPIVersion, schedule, } = await memoizedBuild({
|
|
59
38
|
cache,
|
|
60
39
|
cacheKey: `zisi-${entryPath}`,
|
|
61
|
-
|
|
62
|
-
|
|
40
|
+
command: async () => {
|
|
41
|
+
const result = await zipFunction(entryPath, targetDirectory, zipOptions);
|
|
42
|
+
if (result == null) {
|
|
43
|
+
throw new Error('Failed to build function');
|
|
44
|
+
}
|
|
45
|
+
return result;
|
|
46
|
+
},
|
|
63
47
|
});
|
|
64
|
-
|
|
65
|
-
const srcFiles = inputs.filter((inputPath) => !inputPath.includes(`${path.sep}node_modules${path.sep}`));
|
|
48
|
+
const srcFiles = (inputs ?? []).filter((inputPath) => !inputPath.includes(`${path.sep}node_modules${path.sep}`));
|
|
66
49
|
const buildPath = path.join(functionPath, entryFilename);
|
|
67
50
|
// some projects include a package.json with "type=module", forcing Node to interpret every descending file
|
|
68
51
|
// as ESM. ZISI outputs CJS, so we emit an overriding directive into the output directory.
|
|
69
52
|
if (hasTypeModule) {
|
|
70
|
-
await writeFile(path.join(functionPath,
|
|
53
|
+
await writeFile(path.join(functionPath, 'package.json'), JSON.stringify({
|
|
71
54
|
type: 'commonjs',
|
|
72
55
|
}));
|
|
73
56
|
}
|
|
@@ -84,37 +67,22 @@ targetDirectory, }) => {
|
|
|
84
67
|
schedule,
|
|
85
68
|
};
|
|
86
69
|
};
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
* @param {string} params.mainFile
|
|
91
|
-
* @param {string} params.projectRoot
|
|
92
|
-
*/
|
|
93
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
94
|
-
export const parseFunctionForMetadata = async ({ config, mainFile, projectRoot }) => await listFunction(mainFile, {
|
|
70
|
+
export const getFunctionMetadata = async ({ config, mainFile, projectRoot, }) =>
|
|
71
|
+
// TODO(serhalp): Throw if this returns `undefined`? It doesn't seem like this is expected.
|
|
72
|
+
await listFunction(mainFile, {
|
|
95
73
|
config: netlifyConfigToZisiConfig({ config, projectRoot }),
|
|
96
|
-
|
|
97
|
-
featureFlags: { zisi_functions_api_v2: true },
|
|
74
|
+
featureFlags: {},
|
|
98
75
|
parseISC: true,
|
|
99
76
|
});
|
|
100
|
-
// Clears the cache for any files inside the directory from which functions are
|
|
101
|
-
// served.
|
|
102
|
-
// @ts-expect-error TS(7006) FIXME: Parameter 'functionsPath' implicitly has an 'any' ... Remove this comment to see the full error message
|
|
77
|
+
// Clears the cache for any files inside the directory from which functions are served.
|
|
103
78
|
const clearFunctionsCache = (functionsPath) => {
|
|
104
79
|
Object.keys(require.cache)
|
|
105
80
|
.filter((key) => key.startsWith(functionsPath))
|
|
106
|
-
// @ts-expect-error
|
|
107
|
-
|
|
81
|
+
// @ts-expect-error(serhalp) -- `decache` is typed but TS thinks it isn't callable. Investigate.
|
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return -- What in the world is going on?
|
|
83
|
+
.forEach((key) => decache(key));
|
|
108
84
|
};
|
|
109
|
-
|
|
110
|
-
*
|
|
111
|
-
* @param {object} config
|
|
112
|
-
* @param {string} config.projectRoot
|
|
113
|
-
* @param {(msg: string) => void} config.errorExit
|
|
114
|
-
* @returns
|
|
115
|
-
*/
|
|
116
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'errorExit' implicitly has an 'any... Remove this comment to see the full error message
|
|
117
|
-
const getTargetDirectory = async ({ errorExit, projectRoot }) => {
|
|
85
|
+
const getTargetDirectory = async ({ errorExit, projectRoot, }) => {
|
|
118
86
|
const targetDirectory = path.resolve(projectRoot, getPathInProject([SERVE_FUNCTIONS_FOLDER]));
|
|
119
87
|
try {
|
|
120
88
|
await mkdir(targetDirectory, { recursive: true });
|
|
@@ -124,29 +92,15 @@ const getTargetDirectory = async ({ errorExit, projectRoot }) => {
|
|
|
124
92
|
}
|
|
125
93
|
return targetDirectory;
|
|
126
94
|
};
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
*
|
|
131
|
-
* @param {object} param0
|
|
132
|
-
* @param {*} param0.config
|
|
133
|
-
* @param {*} param0.directory
|
|
134
|
-
* @param {*} param0.errorExit
|
|
135
|
-
* @param {*} param0.func
|
|
136
|
-
* @param {*} param0.metadata
|
|
137
|
-
* @param {string} param0.projectRoot
|
|
138
|
-
*/
|
|
139
|
-
// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
|
|
140
|
-
export default async function handler({ config, directory, errorExit, func, metadata, projectRoot }) {
|
|
95
|
+
const netlifyConfigToZisiConfig = ({ config, projectRoot, }) => addFunctionsConfigDefaults(normalizeFunctionsConfig({ functionsConfig: config.functions, projectRoot }));
|
|
96
|
+
export default async function detectZisiBuilder({ config, directory, errorExit, func, metadata, projectRoot, }) {
|
|
141
97
|
const functionsConfig = netlifyConfigToZisiConfig({ config, projectRoot });
|
|
98
|
+
// @ts-expect-error(serhalp) -- We seem to be incorrectly using this function, but it seems to work... Investigate.
|
|
142
99
|
const packageJson = await readPackageUp(func.mainFile);
|
|
143
|
-
const hasTypeModule = packageJson
|
|
144
|
-
/** @type {import("@netlify/zip-it-and-ship-it/dist/feature_flags.js").FeatureFlags} */
|
|
100
|
+
const hasTypeModule = packageJson?.packageJson.type === 'module';
|
|
145
101
|
const featureFlags = {};
|
|
146
|
-
if (metadata
|
|
147
|
-
// @ts-expect-error TS(2339) FIXME: Property 'zisi_pure_esm' does not exist on type '{... Remove this comment to see the full error message
|
|
102
|
+
if (metadata?.runtimeAPIVersion === 2) {
|
|
148
103
|
featureFlags.zisi_pure_esm = true;
|
|
149
|
-
// @ts-expect-error TS(2339) FIXME: Property 'zisi_pure_esm_mjs' does not exist on typ... Remove this comment to see the full error message
|
|
150
104
|
featureFlags.zisi_pure_esm_mjs = true;
|
|
151
105
|
}
|
|
152
106
|
else {
|
|
@@ -158,7 +112,7 @@ export default async function handler({ config, directory, errorExit, func, meta
|
|
|
158
112
|
}
|
|
159
113
|
// TODO: Resolve functions config globs so that we can check for the bundler
|
|
160
114
|
// on a per-function basis.
|
|
161
|
-
const isUsingEsbuild = ['esbuild_zisi', 'esbuild'].includes(functionsConfig['*'].nodeBundler);
|
|
115
|
+
const isUsingEsbuild = functionsConfig['*'].nodeBundler != null && ['esbuild_zisi', 'esbuild'].includes(functionsConfig['*'].nodeBundler);
|
|
162
116
|
if (!isUsingEsbuild) {
|
|
163
117
|
return false;
|
|
164
118
|
}
|
|
@@ -166,17 +120,18 @@ export default async function handler({ config, directory, errorExit, func, meta
|
|
|
166
120
|
// Enable source map support.
|
|
167
121
|
sourceMapSupport.install();
|
|
168
122
|
const targetDirectory = await getTargetDirectory({ projectRoot, errorExit });
|
|
123
|
+
const build = async ({ cache = {} }) => buildFunction({
|
|
124
|
+
cache,
|
|
125
|
+
config: functionsConfig,
|
|
126
|
+
directory,
|
|
127
|
+
func,
|
|
128
|
+
projectRoot,
|
|
129
|
+
targetDirectory,
|
|
130
|
+
hasTypeModule,
|
|
131
|
+
featureFlags,
|
|
132
|
+
});
|
|
169
133
|
return {
|
|
170
|
-
build
|
|
171
|
-
cache,
|
|
172
|
-
config: functionsConfig,
|
|
173
|
-
directory,
|
|
174
|
-
func,
|
|
175
|
-
projectRoot,
|
|
176
|
-
targetDirectory,
|
|
177
|
-
hasTypeModule,
|
|
178
|
-
featureFlags,
|
|
179
|
-
}),
|
|
134
|
+
build,
|
|
180
135
|
builderName: 'zip-it-and-ship-it',
|
|
181
136
|
target: targetDirectory,
|
|
182
137
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zisi.js","sourceRoot":"","sources":["../../../../../../src/lib/functions/runtimes/js/builders/zisi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,WAAW,EAAE,YAAY,
|
|
1
|
+
{"version":3,"file":"zisi.js","sourceRoot":"","sources":["../../../../../../src/lib/functions/runtimes/js/builders/zisi.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAA;AACtC,OAAO,IAAI,MAAM,MAAM,CAAA;AAEvB,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,YAAY,EAAuB,MAAM,6BAA6B,CAAA;AAG5G,OAAO,OAAO,MAAM,SAAS,CAAA;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAA;AAC/C,OAAO,gBAAgB,MAAM,oBAAoB,CAAA;AAEjD,OAAO,EAAE,aAAa,EAAqC,MAAM,yCAAyC,CAAA;AAC1G,OAAO,EAAE,sBAAsB,EAAE,MAAM,6CAA6C,CAAA;AACpF,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC1D,OAAO,EAAkC,wBAAwB,EAAE,MAAM,oBAAoB,CAAA;AAC7F,OAAO,EAA0B,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAKlF,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAU9C,MAAM,0BAA0B,GAAG,CAAC,MAAiC,EAAE,EAAE,CAAC,CAAC;IACzE,GAAG,MAAM;IACT,GAAG,EAAE;QACH,aAAa,EAAE,IAAI;QACnB,GAAG,MAAM,CAAC,GAAG,CAAC;KACf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Aa,GAAG,CAAC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAA;QAC3F,MAAM,cAAc,GAAG,aAAa,IAAI,aAAa,CAAA;QAErD,IAAI,cAAc,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,WAAW,EAAE,CAAC;YACxD,eAAe,CAAC,GAAG,CAAC,CAAC,WAAW,GAAG,SAAS,CAAA;QAC9C,CAAC;QAED,4EAA4E;QAC5E,2BAA2B;QAC3B,MAAM,cAAc,GAClB,eAAe,CAAC,GAAG,CAAC,CAAC,WAAW,IAAI,IAAI,IAAI,CAAC,cAAc,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,CAAA;QAEpH,IAAI,CAAC,cAAc,EAAE,CAAC;YACpB,OAAO,KAAK,CAAA;QACd,CAAC;IACH,CAAC;IAED,6BAA6B;IAC7B,gBAAgB,CAAC,OAAO,EAAE,CAAA;IAE1B,MAAM,eAAe,GAAG,MAAM,kBAAkB,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,CAAC,CAAA;IAE5E,MAAM,KAAK,GAAG,KAAK,EAAE,EAAE,KAAK,GAAG,EAAE,EAAiD,EAAE,EAAE,CACpF,aAAa,CAAC;QACZ,KAAK;QACL,MAAM,EAAE,eAAe;QACvB,SAAS;QACT,IAAI;QACJ,WAAW;QACX,eAAe;QACf,aAAa;QACb,YAAY;KACb,CAAC,CAAA;IAEJ,OAAO;QACL,KAAK;QACL,WAAW,EAAE,oBAAoB;QACjC,MAAM,EAAE,eAAe;KACxB,CAAA;AACH,CAAC"}
|
|
@@ -1,25 +1,21 @@
|
|
|
1
|
+
import { type LambdaEvent } from 'lambda-local';
|
|
2
|
+
import type { BuildFunction, GetBuildFunction, InvokeFunction, OnDirectoryScanFunction } from '../index.js';
|
|
1
3
|
import type NetlifyFunction from '../../netlify-function.js';
|
|
2
|
-
import {
|
|
4
|
+
import { type NetlifyLambdaBuildResult } from './builders/netlify-lambda.js';
|
|
5
|
+
import { ZisiBuildResult } from './builders/zisi.js';
|
|
6
|
+
import type { WorkerMessage } from './worker.js';
|
|
3
7
|
export declare const name = "js";
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
event: any;
|
|
15
|
-
func: any;
|
|
16
|
-
timeout: any;
|
|
17
|
-
}) => Promise<unknown>;
|
|
18
|
-
export declare const invokeFunctionDirectly: ({ context, event, func, timeout, }: {
|
|
19
|
-
context: $TSFixMe;
|
|
20
|
-
event: $TSFixMe;
|
|
21
|
-
func: NetlifyFunction;
|
|
8
|
+
export type JsBuildResult = ZisiBuildResult | NetlifyLambdaBuildResult;
|
|
9
|
+
export type JsInvokeFunctionResult = WorkerMessage | LambdaEvent;
|
|
10
|
+
export declare function getBuildFunction({ config, directory, errorExit, func, projectRoot, }: Parameters<GetBuildFunction<JsBuildResult>>[0]): Promise<(({ cache }: {
|
|
11
|
+
cache?: import("../../memoized-build.js").BuildCommandCache<import("@netlify/zip-it-and-ship-it").FunctionResult>;
|
|
12
|
+
}) => Promise<ZisiBuildResult>) | BuildFunction<JsBuildResult>>;
|
|
13
|
+
export declare const invokeFunction: ({ context, environment, event, func, timeout, }: Parameters<InvokeFunction<JsBuildResult>>[0]) => Promise<JsInvokeFunctionResult>;
|
|
14
|
+
export declare const invokeFunctionDirectly: <BuildResult extends JsBuildResult>({ context, event, func, timeout, }: {
|
|
15
|
+
context: Record<string, unknown>;
|
|
16
|
+
event: Record<string, unknown>;
|
|
17
|
+
func: NetlifyFunction<BuildResult>;
|
|
22
18
|
timeout: number;
|
|
23
|
-
}) => Promise<
|
|
24
|
-
export declare const onDirectoryScan:
|
|
19
|
+
}) => Promise<LambdaEvent>;
|
|
20
|
+
export declare const onDirectoryScan: OnDirectoryScanFunction;
|
|
25
21
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/functions/runtimes/js/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/lib/functions/runtimes/js/index.ts"],"names":[],"mappings":"AAKA,OAAoB,EAAE,KAAK,WAAW,EAAE,MAAM,cAAc,CAAA;AAE5D,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAA;AAE3G,OAAO,KAAK,eAAe,MAAM,2BAA2B,CAAA;AAE5D,OAAmC,EACjC,KAAK,wBAAwB,EAE9B,MAAM,8BAA8B,CAAA;AACrC,OAA0B,EAAuB,eAAe,EAAE,MAAM,oBAAoB,CAAA;AAE5F,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAEhD,eAAO,MAAM,IAAI,OAAO,CAAA;AAExB,MAAM,MAAM,aAAa,GAAG,eAAe,GAAG,wBAAwB,CAAA;AAItE,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG,WAAW,CAAA;AAiBhE,wBAAsB,gBAAgB,CAAC,EACrC,MAAM,EACN,SAAS,EACT,SAAS,EACT,IAAI,EACJ,WAAW,GACZ,EAAE,UAAU,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;SAqIgtC,CAAC;gEA/GjwC;AAID,eAAO,MAAM,cAAc,oDAMxB,UAAU,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC,KAAG,OAAO,CAAC,sBAAsB,CAkD/E,CAAA;AAED,eAAO,MAAM,sBAAsB,GAAU,WAAW,SAAS,aAAa,sCAK3E;IACD,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;IAC9B,IAAI,EAAE,eAAe,CAAC,WAAW,CAAC,CAAA;IAClC,OAAO,EAAE,MAAM,CAAA;CAChB,KAAG,OAAO,CAAC,WAAW,CA2BtB,CAAA;AAED,eAAO,MAAM,eAAe,EAAE,uBAS7B,CAAA"}
|
|
@@ -5,30 +5,26 @@ import { Worker } from 'worker_threads';
|
|
|
5
5
|
import lambdaLocal from 'lambda-local';
|
|
6
6
|
import { BLOBS_CONTEXT_VARIABLE } from '../../../blobs/blobs.js';
|
|
7
7
|
import detectNetlifyLambdaBuilder from './builders/netlify-lambda.js';
|
|
8
|
-
import detectZisiBuilder, {
|
|
8
|
+
import detectZisiBuilder, { getFunctionMetadata } from './builders/zisi.js';
|
|
9
9
|
import { SECONDS_TO_MILLISECONDS } from './constants.js';
|
|
10
10
|
export const name = 'js';
|
|
11
|
-
// @ts-expect-error TS(7034) FIXME: Variable 'netlifyLambdaDetectorCache' implicitly h... Remove this comment to see the full error message
|
|
12
11
|
let netlifyLambdaDetectorCache;
|
|
13
12
|
lambdaLocal.getLogger().level = 'alert';
|
|
14
13
|
// The netlify-lambda builder can't be enabled or disabled on a per-function
|
|
15
14
|
// basis and its detection mechanism is also quite expensive, so we detect
|
|
16
15
|
// it once and cache the result.
|
|
17
|
-
const detectNetlifyLambdaWithCache = () => {
|
|
18
|
-
// @ts-expect-error TS(7005) FIXME: Variable 'netlifyLambdaDetectorCache' implicitly h... Remove this comment to see the full error message
|
|
16
|
+
const detectNetlifyLambdaWithCache = async () => {
|
|
19
17
|
if (netlifyLambdaDetectorCache === undefined) {
|
|
20
|
-
netlifyLambdaDetectorCache = detectNetlifyLambdaBuilder();
|
|
18
|
+
netlifyLambdaDetectorCache = await detectNetlifyLambdaBuilder();
|
|
21
19
|
}
|
|
22
|
-
// @ts-expect-error TS(7005) FIXME: Variable 'netlifyLambdaDetectorCache' implicitly h... Remove this comment to see the full error message
|
|
23
20
|
return netlifyLambdaDetectorCache;
|
|
24
21
|
};
|
|
25
|
-
|
|
26
|
-
export const getBuildFunction = async ({ config, directory, errorExit, func, projectRoot }) => {
|
|
22
|
+
export async function getBuildFunction({ config, directory, errorExit, func, projectRoot, }) {
|
|
27
23
|
const netlifyLambdaBuilder = await detectNetlifyLambdaWithCache();
|
|
28
24
|
if (netlifyLambdaBuilder) {
|
|
29
25
|
return netlifyLambdaBuilder.build;
|
|
30
26
|
}
|
|
31
|
-
const metadata = await
|
|
27
|
+
const metadata = await getFunctionMetadata({ mainFile: func.mainFile, config, projectRoot });
|
|
32
28
|
const zisiBuilder = await detectZisiBuilder({ config, directory, errorExit, func, metadata, projectRoot });
|
|
33
29
|
if (zisiBuilder) {
|
|
34
30
|
return zisiBuilder.build;
|
|
@@ -38,13 +34,18 @@ export const getBuildFunction = async ({ config, directory, errorExit, func, pro
|
|
|
38
34
|
// main file otherwise.
|
|
39
35
|
const functionDirectory = dirname(func.mainFile);
|
|
40
36
|
const srcFiles = functionDirectory === directory ? [func.mainFile] : [functionDirectory];
|
|
41
|
-
|
|
42
|
-
return
|
|
43
|
-
}
|
|
37
|
+
const build = () => Promise.resolve({ schedule: metadata?.schedule, srcFiles });
|
|
38
|
+
return build;
|
|
39
|
+
}
|
|
44
40
|
const workerURL = new URL('worker.js', import.meta.url);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
41
|
+
export const invokeFunction = async ({ context, environment, event, func, timeout, }) => {
|
|
42
|
+
const { buildData } = func;
|
|
43
|
+
// I have no idea why, but it appears that treating the case of a missing `buildData` or missing
|
|
44
|
+
// `buildData.runtimeAPIVersion` as V1 is important.
|
|
45
|
+
const runtimeAPIVersion = buildData != null && 'runtimeAPIVersion' in buildData && typeof buildData.runtimeAPIVersion === 'number'
|
|
46
|
+
? buildData.runtimeAPIVersion
|
|
47
|
+
: null;
|
|
48
|
+
if (runtimeAPIVersion == null || runtimeAPIVersion !== 2) {
|
|
48
49
|
return await invokeFunctionDirectly({ context, event, func, timeout });
|
|
49
50
|
}
|
|
50
51
|
const workerData = {
|
|
@@ -54,13 +55,16 @@ export const invokeFunction = async ({ context, environment, event, func, timeou
|
|
|
54
55
|
// If a function builder has defined a `buildPath` property, we use it.
|
|
55
56
|
// Otherwise, we'll invoke the function's main file.
|
|
56
57
|
// Because we use import() we have to use file:// URLs for Windows.
|
|
57
|
-
entryFilePath: pathToFileURL(
|
|
58
|
+
entryFilePath: pathToFileURL(buildData != null && 'buildPath' in buildData && buildData.buildPath ? buildData.buildPath : func.mainFile).href,
|
|
58
59
|
timeoutMs: timeout * SECONDS_TO_MILLISECONDS,
|
|
59
60
|
};
|
|
60
61
|
const worker = new Worker(workerURL, { workerData });
|
|
61
62
|
return await new Promise((resolve, reject) => {
|
|
62
63
|
worker.on('message', (result) => {
|
|
63
|
-
|
|
64
|
+
// TODO(serhalp): Improve `WorkerMessage` type. It sure would be nice to keep it simple as it
|
|
65
|
+
// is now, but technically this is an arbitrary type from the user function return...
|
|
66
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
67
|
+
if (result?.streamPort != null) {
|
|
64
68
|
const client = createConnection({
|
|
65
69
|
port: result.streamPort,
|
|
66
70
|
host: 'localhost',
|
|
@@ -78,10 +82,13 @@ export const invokeFunction = async ({ context, environment, event, func, timeou
|
|
|
78
82
|
});
|
|
79
83
|
};
|
|
80
84
|
export const invokeFunctionDirectly = async ({ context, event, func, timeout, }) => {
|
|
85
|
+
const buildData = await func.getBuildData();
|
|
86
|
+
if (buildData == null) {
|
|
87
|
+
throw new Error('Cannot invoke a function that has not been built');
|
|
88
|
+
}
|
|
81
89
|
// If a function builder has defined a `buildPath` property, we use it.
|
|
82
90
|
// Otherwise, we'll invoke the function's main file.
|
|
83
|
-
const
|
|
84
|
-
const lambdaPath = buildPath ?? func.mainFile;
|
|
91
|
+
const lambdaPath = 'buildPath' in buildData && typeof buildData.buildPath === 'string' ? buildData.buildPath : func.mainFile;
|
|
85
92
|
const result = await lambdaLocal.execute({
|
|
86
93
|
clientContext: JSON.stringify(context),
|
|
87
94
|
environment: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/functions/runtimes/js/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/lib/functions/runtimes/js/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,KAAK,CAAA;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,KAAK,CAAA;AACnC,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAEvC,OAAO,WAAiC,MAAM,cAAc,CAAA;AAG5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAA;AAGhE,OAAO,0BAGN,MAAM,8BAA8B,CAAA;AACrC,OAAO,iBAAiB,EAAE,EAAE,mBAAmB,EAAmB,MAAM,oBAAoB,CAAA;AAC5F,OAAO,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAA;AAGxD,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAA;AAQxB,IAAI,0BAA4D,CAAA;AAEhE,WAAW,CAAC,SAAS,EAAE,CAAC,KAAK,GAAG,OAAO,CAAA;AAEvC,4EAA4E;AAC5E,0EAA0E;AAC1E,gCAAgC;AAChC,MAAM,4BAA4B,GAAG,KAAK,IAAI,EAAE;IAC9C,IAAI,0BAA0B,KAAK,SAAS,EAAE,CAAC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ACpC;QACD,KAAK;QACL,UAAU;QACV,SAAS,EAAE,OAAO,GAAG,uBAAuB;QAC5C,YAAY,EAAE,CAAC;QACf,GAAG,EAAE,UAAU,CAAC,QAAQ,CAAC,MAAM,CAAC;KACjC,CAAC,CAAA;IAEF,OAAO,MAAM,CAAA;AACf,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAA4B,KAAK,IAAI,EAAE;IACjE,MAAM,oBAAoB,GAAG,MAAM,4BAA4B,EAAE,CAAA;IAEjE,6EAA6E;IAC7E,0EAA0E;IAC1E,kDAAkD;IAClD,IAAI,oBAAoB,EAAE,CAAC;QACzB,MAAM,oBAAoB,CAAC,KAAK,EAAE,CAAA;IACpC,CAAC;AACH,CAAC,CAAA"}
|
|
@@ -1,2 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { type LambdaEvent, type Options as LambdaLocalOptions } from 'lambda-local';
|
|
2
|
+
export type WorkerData = LambdaLocalOptions & {
|
|
3
|
+
entryFilePath: string;
|
|
4
|
+
};
|
|
5
|
+
export interface WorkerMessage extends LambdaEvent {
|
|
6
|
+
streamPort?: number;
|
|
7
|
+
}
|
|
2
8
|
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../../src/lib/functions/runtimes/js/worker.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../../../../src/lib/functions/runtimes/js/worker.ts"],"names":[],"mappings":"AAKA,OAAoB,EAAE,KAAK,WAAW,EAAE,KAAK,OAAO,IAAI,kBAAkB,EAAE,MAAM,cAAc,CAAA;AAGhG,MAAM,MAAM,UAAU,GAAG,kBAAkB,GAAG;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAA;AAEvE,MAAM,WAAW,aAAc,SAAQ,WAAW;IAChD,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB"}
|