From b6cae92c2178ae3d428e9c6924ea43717fb543b1 Mon Sep 17 00:00:00 2001 From: Erica Pisani Date: Wed, 15 Nov 2023 10:00:39 -0500 Subject: [PATCH] feat: convert src/ folder to Typescript (#6136) * refactor: convert parse-raw-flags * refactor: update package.json and tsconfig.json * refactor: remove ts-check We can't address the type issues in these just yet. Removing the type so we can type check the files we're converting * refactor: remove files I didn't mean to check in * refactor: convert src/utils/lm * refactor: rename everything in the src directory * refactor: work-in-progress commit * refactor: it's building now * refactor: include types files * refactor: update github workflow commands to compile the project before running tests * refactor: temporarily remove postinstall * refactor: put the postinstall script back in * refactor: remove .github changes, update package.json postinstall script * refactor: add type * style: lint * style: update eslint rules * style: line * style: cleanup * refactor: fix clean command * style: ignore compiled files in src dir * fix: merge changed the clean command * test: testing adding/removing mjs files to deal with bad merge * Revert "test: testing adding/removing mjs files to deal with bad merge" This reverts commit 39305687e3a07be31b87d260675da9b0b8652aa8. * fix: lint rules * refactor: update scripts * style: notation * style: prettier * fix: fix the gitignore paths * fix: leave function templates as-is * refactor: forgot to add tsconfig change * Merge conflicted main files into branch * style: lint * fix: missing expect error comment * test: test was failing because of a trailing newline * test: another test failing because of a newline * refactor: ts conversion things * fix: file extension * chore: update scripts and pin version * chore: remove reference to built types the exception for .mts files at the end is removing them so need to revisit this at another time * fix: preserve build script * fix: revert earlier changes --------- Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com> --- .eslintrc.cjs | 6 +- .gitignore | 6 + .prettierignore | 2 + package-lock.json | 71 ++++ package.json | 14 +- scripts/prepare-for-publish.mjs | 13 +- site/scripts/docs.mjs | 2 +- site/scripts/generate-command-data.mjs | 2 +- .../{addons-auth.mjs => addons-auth.mts} | 7 +- .../{addons-config.mjs => addons-config.mts} | 11 +- .../{addons-create.mjs => addons-create.mts} | 10 +- .../{addons-delete.mjs => addons-delete.mts} | 6 +- .../{addons-list.mjs => addons-list.mts} | 9 +- .../addons/{addons.mjs => addons.mts} | 4 +- src/commands/addons/{index.mjs => index.mts} | 0 src/commands/api/{api.mjs => api.mts} | 6 +- src/commands/api/{index.mjs => index.mts} | 0 .../{base-command.mjs => base-command.mts} | 57 ++- src/commands/build/{build.mjs => build.mts} | 10 +- src/commands/build/{index.mjs => index.mts} | 0 .../{completion.mjs => completion.mts} | 5 + .../completion/{index.mjs => index.mts} | 0 .../deploy/{deploy.mjs => deploy.mts} | 78 +++- src/commands/deploy/{index.mjs => index.mts} | 0 .../dev/{dev-exec.mjs => dev-exec.mts} | 2 + src/commands/dev/{dev.mjs => dev.mts} | 9 +- src/commands/dev/{index.mjs => index.mts} | 0 .../env/{env-clone.mjs => env-clone.mts} | 16 +- src/commands/env/{env-get.mjs => env-get.mts} | 6 +- .../env/{env-import.mjs => env-import.mts} | 14 +- .../env/{env-list.mjs => env-list.mts} | 13 +- src/commands/env/{env-set.mjs => env-set.mts} | 18 +- .../env/{env-unset.mjs => env-unset.mts} | 13 +- src/commands/env/{env.mjs => env.mts} | 4 +- src/commands/env/{index.mjs => index.mts} | 0 ...unctions-build.mjs => functions-build.mts} | 6 +- ...ctions-create.mjs => functions-create.mts} | 47 ++- ...ctions-invoke.mjs => functions-invoke.mts} | 18 +- ...{functions-list.mjs => functions-list.mts} | 9 +- ...unctions-serve.mjs => functions-serve.mts} | 5 +- .../{functions.mjs => functions.mts} | 4 +- .../functions/{index.mjs => index.mts} | 0 src/commands/{index.mjs => index.mts} | 0 src/commands/init/{index.mjs => index.mts} | 0 src/commands/init/{init.mjs => init.mts} | 12 +- .../integration/{deploy.mjs => deploy.mts} | 35 ++ .../integration/{index.mjs => index.mts} | 2 + src/commands/link/{index.mjs => index.mts} | 0 src/commands/link/{link.mjs => link.mts} | 25 +- src/commands/lm/{index.mjs => index.mts} | 0 src/commands/lm/{lm-info.mjs => lm-info.mts} | 4 +- .../lm/{lm-install.mjs => lm-install.mts} | 4 +- .../lm/{lm-setup.mjs => lm-setup.mts} | 11 +- .../lm/{lm-uninstall.mjs => lm-uninstall.mts} | 3 +- src/commands/lm/{lm.mjs => lm.mts} | 4 +- src/commands/login/{index.mjs => index.mts} | 0 src/commands/login/{login.mjs => login.mts} | 6 +- src/commands/logout/{index.mjs => index.mts} | 0 .../logout/{logout.mjs => logout.mts} | 5 +- src/commands/{main.mjs => main.mts} | 10 +- src/commands/open/{index.mjs => index.mts} | 0 .../open/{open-admin.mjs => open-admin.mts} | 3 + .../open/{open-site.mjs => open-site.mts} | 3 + src/commands/open/{open.mjs => open.mts} | 2 + .../recipes/{common.mjs => common.mts} | 1 + src/commands/recipes/{index.mjs => index.mts} | 0 .../{recipes-list.mjs => recipes-list.mts} | 4 +- .../recipes/{recipes.mjs => recipes.mts} | 8 +- src/commands/serve/{index.mjs => index.mts} | 0 src/commands/serve/{serve.mjs => serve.mts} | 8 +- src/commands/sites/{index.mjs => index.mts} | 0 ...template.mjs => sites-create-template.mts} | 28 +- .../{sites-create.mjs => sites-create.mts} | 20 +- .../{sites-delete.mjs => sites-delete.mts} | 7 +- .../sites/{sites-list.mjs => sites-list.mts} | 10 +- src/commands/sites/{sites.mjs => sites.mts} | 4 +- src/commands/status/{index.mjs => index.mts} | 0 .../{status-hooks.mjs => status-hooks.mts} | 7 +- .../status/{status.mjs => status.mts} | 16 +- src/commands/switch/{index.mjs => index.mts} | 0 .../switch/{switch.mjs => switch.mts} | 9 +- src/commands/unlink/{index.mjs => index.mts} | 0 .../unlink/{unlink.mjs => unlink.mts} | 4 +- src/commands/watch/{index.mjs => index.mts} | 0 src/commands/watch/{watch.mjs => watch.mts} | 9 +- .../javascript/hello/{{name}}.js | 5 +- src/lib/{account.mjs => account.mts} | 4 +- src/lib/{api.mjs => api.mts} | 3 + src/lib/blobs/{blobs.mjs => blobs.mts} | 3 + src/lib/{build.mjs => build.mts} | 12 +- .../{constants.mjs => constants.mts} | 2 +- ...letion.mjs => generate-autocompletion.mts} | 6 +- ...ocompletion.mjs => get-autocompletion.mts} | 7 +- src/lib/completion/{index.mjs => index.mts} | 0 src/lib/completion/{script.mjs => script.mts} | 3 +- .../{bootstrap.mjs => bootstrap.mts} | 0 .../edge-functions/{consts.mjs => consts.mts} | 0 .../edge-functions/{deploy.mjs => deploy.mts} | 5 +- .../{editor-helper.mjs => editor-helper.mts} | 1 + .../{headers.mjs => headers.mts} | 5 +- .../{internal.mjs => internal.mts} | 5 +- .../edge-functions/{proxy.mjs => proxy.mts} | 44 ++- .../{registry.mjs => registry.mts} | 71 +++- .../{exec-fetcher.mjs => exec-fetcher.mts} | 19 +- src/lib/{fs.mjs => fs.mts} | 9 +- .../{background.mjs => background.mts} | 2 + src/lib/functions/{config.mjs => config.mts} | 7 + ...ndler.mjs => form-submissions-handler.mts} | 23 +- .../{local-proxy.mjs => local-proxy.mts} | 6 +- ...{memoized-build.mjs => memoized-build.mts} | 1 + src/lib/functions/netlify-function.mjs | 265 -------------- src/lib/functions/netlify-function.mts | 338 ++++++++++++++++++ .../functions/{registry.mjs => registry.mts} | 80 ++++- .../runtimes/go/{index.mjs => index.mts} | 10 +- .../runtimes/{index.mjs => index.mts} | 0 ...{netlify-lambda.mjs => netlify-lambda.mts} | 7 +- .../js/builders/{zisi.mjs => zisi.mts} | 21 ++ .../js/{constants.mjs => constants.mts} | 0 .../runtimes/js/{index.mjs => index.mts} | 7 + .../runtimes/js/{worker.mjs => worker.mts} | 8 + .../runtimes/rust/{index.mjs => index.mts} | 10 +- .../{scheduled.mjs => scheduled.mts} | 3 + src/lib/functions/{server.mjs => server.mts} | 16 +- .../{synchronous.mjs => synchronous.mts} | 14 +- src/lib/functions/{utils.mjs => utils.mts} | 6 +- .../{geo-location.mjs => geo-location.mts} | 4 +- src/lib/{http-agent.mjs => http-agent.mts} | 12 +- src/lib/images/{proxy.mjs => proxy.mts} | 17 +- src/lib/{log.mjs => log.mts} | 0 src/lib/path.mjs | 1 - src/lib/path.mts | 2 + ...template.mjs => render-error-template.mts} | 3 + src/lib/{settings.mjs => settings.mts} | 3 + src/lib/{spinner.mjs => spinner.mts} | 5 +- src/lib/string.mjs | 3 - src/lib/string.mts | 5 + src/recipes/vscode/{index.mjs => index.mts} | 8 +- .../vscode/{settings.mjs => settings.mts} | 6 + src/utils/addons/{compare.mjs => compare.mts} | 2 + .../addons/diffs/{index.mjs => index.mts} | 6 +- .../addons/diffs/{options.mjs => options.mts} | 5 +- src/utils/addons/{prepare.mjs => prepare.mts} | 15 +- src/utils/addons/{prompts.mjs => prompts.mts} | 8 +- src/utils/addons/{render.mjs => render.mts} | 6 +- src/utils/addons/validation.mjs | 18 - src/utils/addons/validation.mts | 24 ++ src/utils/{banner.mjs => banner.mts} | 3 +- src/utils/{build-info.mjs => build-info.mts} | 13 +- ...ommand-helpers.mjs => command-helpers.mts} | 26 +- ...reate-deferred.mjs => create-deferred.mts} | 2 +- src/utils/create-stream-promise.mjs | 49 --- src/utils/create-stream-promise.mts | 62 ++++ .../deploy/{constants.mjs => constants.mts} | 0 .../{deploy-site.mjs => deploy-site.mts} | 28 +- .../{hash-config.mjs => hash-config.mts} | 4 + .../deploy/{hash-files.mjs => hash-files.mts} | 7 + .../deploy/{hash-fns.mjs => hash-fns.mts} | 23 ++ ...asher-segments.mjs => hasher-segments.mts} | 11 + .../{upload-files.mjs => upload-files.mts} | 10 + src/utils/deploy/{util.mjs => util.mts} | 9 +- ...ettings.mjs => detect-server-settings.mts} | 31 +- src/utils/{dev.mjs => dev.mts} | 24 +- src/utils/{dot-env.mjs => dot-env.mts} | 8 +- src/utils/env/{index.mjs => index.mts} | 21 ++ src/utils/{execa.mjs => execa.mts} | 0 .../{feature-flags.mjs => feature-flags.mts} | 1 + ...mework-server.mjs => framework-server.mts} | 6 +- .../{constants.mjs => constants.mts} | 0 .../{functions.mjs => functions.mts} | 7 +- .../{get-functions.mjs => get-functions.mts} | 9 +- src/utils/functions/{index.mjs => index.mts} | 0 ...lobal-config.mjs => get-global-config.mts} | 5 + src/utils/get-package-json.mjs | 16 - src/utils/get-package-json.mts | 19 + .../{get-repo-data.mjs => get-repo-data.mts} | 7 +- src/utils/{get-site.mjs => get-site.mts} | 2 + src/utils/{gh-auth.mjs => gh-auth.mts} | 8 +- src/utils/{gitignore.mjs => gitignore.mts} | 6 +- src/utils/{headers.mjs => headers.mts} | 8 +- ...s-site-info.mjs => requires-site-info.mts} | 4 + .../{config-github.mjs => config-github.mts} | 22 +- .../{config-manual.mjs => config-manual.mts} | 7 +- src/utils/init/{config.mjs => config.mts} | 4 +- .../{node-version.mjs => node-version.mts} | 5 +- src/utils/init/plugins.mjs | 8 - src/utils/init/plugins.mts | 14 + src/utils/init/{utils.mjs => utils.mts} | 21 +- .../{live-tunnel.mjs => live-tunnel.mts} | 14 +- src/utils/lm/{install.mjs => install.mts} | 16 +- .../lm/{requirements.mjs => requirements.mts} | 8 +- src/utils/lm/{steps.mjs => steps.mts} | 5 + src/utils/lm/{ui.mjs => ui.mts} | 1 + .../{open-browser.mjs => open-browser.mts} | 4 + ...arse-raw-flags.mjs => parse-raw-flags.mts} | 3 + src/utils/proxy-server.mjs | 107 ------ src/utils/proxy-server.mts | 127 +++++++ src/utils/{proxy.mjs => proxy.mts} | 95 ++++- .../{read-repo-url.mjs => read-repo-url.mts} | 7 +- src/utils/{redirects.mjs => redirects.mts} | 11 +- src/utils/{request-id.mjs => request-id.mts} | 2 +- .../{rules-proxy.mjs => rules-proxy.mts} | 20 +- src/utils/{run-build.mjs => run-build.mts} | 9 +- src/utils/{shell.mjs => shell.mts} | 16 +- .../{sign-redirect.mjs => sign-redirect.mts} | 2 + src/utils/sites/{utils.mjs => utils.mts} | 5 + .../{state-config.mjs => state-config.mts} | 18 + .../{static-server.mjs => static-server.mts} | 3 +- src/utils/telemetry/{index.mjs => index.mts} | 0 .../{report-error.mjs => report-error.mts} | 5 + .../telemetry/{request.mjs => request.mts} | 3 +- .../{telemetry.mjs => telemetry.mts} | 9 +- src/utils/telemetry/{utils.mjs => utils.mts} | 1 + .../{validation.mjs => validation.mts} | 5 + src/utils/{validation.mjs => validation.mts} | 3 +- .../functions/brotli.mjs | 6 +- .../functions/custom-path-root.mjs | 2 +- .../functions/delete.mjs | 2 +- .../functions/log.mjs | 6 +- .../public/v2-to-custom-without-force.html | 2 +- .../public/v2-to-legacy-without-force.html | 2 +- .../.netlify/edge-functions-import-map.json | 2 +- .../dist/index.html | 2 +- .../plugin/index.js | 8 +- .../plugin/manifest.yml | 2 +- .../plugin/package.json | 4 +- tests/integration/commands/dev/v2-api.test.ts | 6 +- tests/integration/utils/call-cli.mjs | 1 - tests/integration/utils/site-builder.mjs | 1 - .../generate-autocompletion.test.mjs | 1 - .../completion/get-autocompletion.test.mjs | 1 - tests/unit/lib/exec-fetcher.test.mjs | 1 - tests/unit/utils/init/config-github.test.mjs | 1 - tools/affected-test.mjs | 2 +- tools/project-graph/dependency-graph.mjs | 1 - tools/project-graph/file-visitor.mjs | 1 - tools/project-graph/visitor-plugins.mjs | 1 - tsconfig.json | 10 +- 237 files changed, 2374 insertions(+), 648 deletions(-) create mode 100644 .prettierignore rename src/commands/addons/{addons-auth.mjs => addons-auth.mts} (71%) rename src/commands/addons/{addons-config.mjs => addons-config.mts} (85%) rename src/commands/addons/{addons-create.mjs => addons-create.mts} (85%) rename src/commands/addons/{addons-delete.mjs => addons-delete.mts} (85%) rename src/commands/addons/{addons-list.mjs => addons-list.mts} (70%) rename src/commands/addons/{addons.mjs => addons.mts} (88%) rename src/commands/addons/{index.mjs => index.mts} (100%) rename src/commands/api/{api.mjs => api.mts} (80%) rename src/commands/api/{index.mjs => index.mts} (100%) rename src/commands/{base-command.mjs => base-command.mts} (81%) rename src/commands/build/{build.mjs => build.mts} (77%) rename src/commands/build/{index.mjs => index.mts} (100%) rename src/commands/completion/{completion.mjs => completion.mts} (77%) rename src/commands/completion/{index.mjs => index.mts} (100%) rename src/commands/deploy/{deploy.mjs => deploy.mts} (74%) rename src/commands/deploy/{index.mjs => index.mts} (100%) rename src/commands/dev/{dev-exec.mjs => dev-exec.mts} (90%) rename src/commands/dev/{dev.mjs => dev.mts} (94%) rename src/commands/dev/{index.mjs => index.mts} (100%) rename src/commands/env/{env-clone.mjs => env-clone.mts} (79%) rename src/commands/env/{env-get.mjs => env-get.mts} (87%) rename src/commands/env/{env-import.mjs => env-import.mts} (78%) rename src/commands/env/{env-list.mjs => env-list.mts} (83%) rename src/commands/env/{env-set.mjs => env-set.mts} (82%) rename src/commands/env/{env-unset.mjs => env-unset.mts} (81%) rename src/commands/env/{env.mjs => env.mts} (87%) rename src/commands/env/{index.mjs => index.mts} (100%) rename src/commands/functions/{functions-build.mjs => functions-build.mts} (82%) rename src/commands/functions/{functions-create.mjs => functions-create.mts} (83%) rename src/commands/functions/{functions-invoke.mjs => functions-invoke.mts} (84%) rename src/commands/functions/{functions-list.mjs => functions-list.mts} (76%) rename src/commands/functions/{functions-serve.mjs => functions-serve.mts} (90%) rename src/commands/functions/{functions.mjs => functions.mts} (89%) rename src/commands/functions/{index.mjs => index.mts} (100%) rename src/commands/{index.mjs => index.mts} (100%) rename src/commands/init/{index.mjs => index.mts} (100%) rename src/commands/init/{init.mjs => init.mts} (86%) rename src/commands/integration/{deploy.mjs => deploy.mts} (76%) rename src/commands/integration/{index.mjs => index.mts} (78%) rename src/commands/link/{index.mjs => index.mts} (100%) rename src/commands/link/{link.mjs => link.mts} (79%) rename src/commands/lm/{index.mjs => index.mts} (100%) rename src/commands/lm/{lm-info.mjs => lm-info.mts} (85%) rename src/commands/lm/{lm-install.mjs => lm-install.mts} (79%) rename src/commands/lm/{lm-setup.mjs => lm-setup.mts} (74%) rename src/commands/lm/{lm-uninstall.mjs => lm-uninstall.mts} (86%) rename src/commands/lm/{lm.mjs => lm.mts} (85%) rename src/commands/login/{index.mjs => index.mts} (100%) rename src/commands/login/{login.mjs => login.mts} (81%) rename src/commands/logout/{index.mjs => index.mts} (100%) rename src/commands/logout/{logout.mjs => logout.mts} (82%) rename src/commands/{main.mjs => main.mts} (90%) rename src/commands/open/{index.mjs => index.mts} (100%) rename src/commands/open/{open-admin.mjs => open-admin.mts} (75%) rename src/commands/open/{open-site.mjs => open-site.mts} (75%) rename src/commands/open/{open.mjs => open.mts} (86%) rename src/commands/recipes/{common.mjs => common.mts} (91%) rename src/commands/recipes/{index.mjs => index.mts} (100%) rename src/commands/recipes/{recipes-list.mjs => recipes-list.mts} (77%) rename src/commands/recipes/{recipes.mjs => recipes.mts} (81%) rename src/commands/serve/{index.mjs => index.mts} (100%) rename src/commands/serve/{serve.mjs => serve.mts} (92%) rename src/commands/sites/{index.mjs => index.mts} (100%) rename src/commands/sites/{sites-create-template.mjs => sites-create-template.mts} (76%) rename src/commands/sites/{sites-create.mjs => sites-create.mts} (76%) rename src/commands/sites/{sites-delete.mjs => sites-delete.mts} (89%) rename src/commands/sites/{sites-list.mjs => sites-list.mts} (76%) rename src/commands/sites/{sites.mjs => sites.mts} (85%) rename src/commands/status/{index.mjs => index.mts} (100%) rename src/commands/status/{status-hooks.mjs => status-hooks.mts} (71%) rename src/commands/status/{status.mjs => status.mts} (73%) rename src/commands/switch/{index.mjs => index.mts} (100%) rename src/commands/switch/{switch.mjs => switch.mts} (74%) rename src/commands/unlink/{index.mjs => index.mts} (100%) rename src/commands/unlink/{unlink.mjs => unlink.mts} (85%) rename src/commands/watch/{index.mjs => index.mts} (100%) rename src/commands/watch/{watch.mjs => watch.mts} (81%) rename src/lib/{account.mjs => account.mts} (67%) rename src/lib/{api.mjs => api.mts} (69%) rename src/lib/blobs/{blobs.mjs => blobs.mts} (73%) rename src/lib/{build.mjs => build.mts} (68%) rename src/lib/completion/{constants.mjs => constants.mts} (90%) rename src/lib/completion/{generate-autocompletion.mjs => generate-autocompletion.mts} (79%) rename src/lib/completion/{get-autocompletion.mjs => get-autocompletion.mts} (69%) rename src/lib/completion/{index.mjs => index.mts} (100%) rename src/lib/completion/{script.mjs => script.mts} (87%) rename src/lib/edge-functions/{bootstrap.mjs => bootstrap.mts} (100%) rename src/lib/edge-functions/{consts.mjs => consts.mts} (100%) rename src/lib/edge-functions/{deploy.mjs => deploy.mts} (74%) rename src/lib/edge-functions/{editor-helper.mjs => editor-helper.mts} (90%) rename src/lib/edge-functions/{headers.mjs => headers.mts} (81%) rename src/lib/edge-functions/{internal.mjs => internal.mts} (72%) rename src/lib/edge-functions/{proxy.mjs => proxy.mts} (57%) rename src/lib/edge-functions/{registry.mjs => registry.mts} (69%) rename src/lib/{exec-fetcher.mjs => exec-fetcher.mts} (63%) rename src/lib/{fs.mjs => fs.mts} (64%) rename src/lib/functions/{background.mjs => background.mts} (74%) rename src/lib/functions/{config.mjs => config.mts} (57%) rename src/lib/functions/{form-submissions-handler.mjs => form-submissions-handler.mts} (71%) rename src/lib/functions/{local-proxy.mjs => local-proxy.mts} (67%) rename src/lib/functions/{memoized-build.mjs => memoized-build.mts} (89%) delete mode 100644 src/lib/functions/netlify-function.mjs create mode 100644 src/lib/functions/netlify-function.mts rename src/lib/functions/{registry.mjs => registry.mts} (63%) rename src/lib/functions/runtimes/go/{index.mjs => index.mts} (65%) rename src/lib/functions/runtimes/{index.mjs => index.mts} (100%) rename src/lib/functions/runtimes/js/builders/{netlify-lambda.mjs => netlify-lambda.mts} (82%) rename src/lib/functions/runtimes/js/builders/{zisi.mjs => zisi.mts} (68%) rename src/lib/functions/runtimes/js/{constants.mjs => constants.mts} (100%) rename src/lib/functions/runtimes/js/{index.mjs => index.mts} (81%) rename src/lib/functions/runtimes/js/{worker.mjs => worker.mts} (64%) rename src/lib/functions/runtimes/rust/{index.mjs => index.mts} (69%) rename src/lib/functions/{scheduled.mjs => scheduled.mts} (88%) rename src/lib/functions/{server.mjs => server.mts} (88%) rename src/lib/functions/{synchronous.mjs => synchronous.mts} (76%) rename src/lib/functions/{utils.mjs => utils.mts} (75%) rename src/lib/{geo-location.mjs => geo-location.mts} (92%) rename src/lib/{http-agent.mjs => http-agent.mts} (67%) rename src/lib/images/{proxy.mjs => proxy.mts} (64%) rename src/lib/{log.mjs => log.mts} (100%) delete mode 100644 src/lib/path.mjs create mode 100644 src/lib/path.mts rename src/lib/{render-error-template.mjs => render-error-template.mts} (60%) rename src/lib/{settings.mjs => settings.mts} (78%) rename src/lib/{spinner.mjs => spinner.mts} (68%) delete mode 100644 src/lib/string.mjs create mode 100644 src/lib/string.mts rename src/recipes/vscode/{index.mjs => index.mts} (79%) rename src/recipes/vscode/{settings.mjs => settings.mts} (74%) rename src/utils/addons/{compare.mjs => compare.mts} (80%) rename src/utils/addons/diffs/{index.mjs => index.mts} (64%) rename src/utils/addons/diffs/{options.mjs => options.mts} (90%) rename src/utils/addons/{prepare.mjs => prepare.mts} (68%) rename src/utils/addons/{prompts.mjs => prompts.mts} (81%) rename src/utils/addons/{render.mjs => render.mts} (72%) delete mode 100644 src/utils/addons/validation.mjs create mode 100644 src/utils/addons/validation.mts rename src/utils/{banner.mjs => banner.mts} (70%) rename src/utils/{build-info.mjs => build-info.mts} (76%) rename src/utils/{command-helpers.mjs => command-helpers.mts} (78%) rename src/utils/{create-deferred.mjs => create-deferred.mts} (95%) delete mode 100644 src/utils/create-stream-promise.mjs create mode 100644 src/utils/create-stream-promise.mts rename src/utils/deploy/{constants.mjs => constants.mts} (100%) rename src/utils/deploy/{deploy-site.mjs => deploy-site.mts} (63%) rename src/utils/deploy/{hash-config.mjs => hash-config.mts} (61%) rename src/utils/deploy/{hash-files.mjs => hash-files.mts} (52%) rename src/utils/deploy/{hash-fns.mjs => hash-fns.mts} (58%) rename src/utils/deploy/{hasher-segments.mjs => hasher-segments.mts} (64%) rename src/utils/deploy/{upload-files.mjs => upload-files.mts} (73%) rename src/utils/deploy/{util.mjs => util.mts} (81%) rename src/utils/{detect-server-settings.mjs => detect-server-settings.mts} (80%) rename src/utils/{dev.mjs => dev.mts} (72%) rename src/utils/{dot-env.mjs => dot-env.mts} (71%) rename src/utils/env/{index.mjs => index.mts} (81%) rename src/utils/{execa.mjs => execa.mts} (100%) rename src/utils/{feature-flags.mjs => feature-flags.mts} (89%) rename src/utils/{framework-server.mjs => framework-server.mts} (78%) rename src/utils/functions/{constants.mjs => constants.mts} (100%) rename src/utils/functions/{functions.mjs => functions.mts} (74%) rename src/utils/functions/{get-functions.mjs => get-functions.mts} (56%) rename src/utils/functions/{index.mjs => index.mts} (100%) rename src/utils/{get-global-config.mjs => get-global-config.mts} (61%) delete mode 100644 src/utils/get-package-json.mjs create mode 100644 src/utils/get-package-json.mts rename src/utils/{get-repo-data.mjs => get-repo-data.mts} (75%) rename src/utils/{get-site.mjs => get-site.mts} (65%) rename src/utils/{gh-auth.mjs => gh-auth.mts} (85%) rename src/utils/{gitignore.mjs => gitignore.mts} (76%) rename src/utils/{headers.mjs => headers.mts} (64%) rename src/utils/hooks/{requires-site-info.mjs => requires-site-info.mts} (70%) rename src/utils/init/{config-github.mjs => config-github.mts} (76%) rename src/utils/init/{config-manual.mjs => config-manual.mts} (81%) rename src/utils/init/{config.mjs => config.mts} (84%) rename src/utils/init/{node-version.mjs => node-version.mts} (78%) delete mode 100644 src/utils/init/plugins.mjs create mode 100644 src/utils/init/plugins.mts rename src/utils/init/{utils.mjs => utils.mts} (76%) rename src/utils/{live-tunnel.mjs => live-tunnel.mts} (72%) rename src/utils/lm/{install.mjs => install.mts} (83%) rename src/utils/lm/{requirements.mjs => requirements.mts} (77%) rename src/utils/lm/{steps.mjs => steps.mts} (67%) rename src/utils/lm/{ui.mjs => ui.mts} (88%) rename src/utils/{open-browser.mjs => open-browser.mts} (71%) rename src/utils/{parse-raw-flags.mjs => parse-raw-flags.mts} (80%) delete mode 100644 src/utils/proxy-server.mjs create mode 100644 src/utils/proxy-server.mts rename src/utils/{proxy.mjs => proxy.mts} (66%) rename src/utils/{read-repo-url.mjs => read-repo-url.mts} (81%) rename src/utils/{redirects.mjs => redirects.mts} (54%) rename src/utils/{request-id.mjs => request-id.mts} (85%) rename src/utils/{rules-proxy.mjs => rules-proxy.mts} (58%) rename src/utils/{run-build.mjs => run-build.mts} (87%) rename src/utils/{shell.mjs => shell.mts} (71%) rename src/utils/{sign-redirect.mjs => sign-redirect.mts} (60%) rename src/utils/sites/{utils.mjs => utils.mts} (71%) rename src/utils/{state-config.mjs => state-config.mts} (58%) rename src/utils/{static-server.mjs => static-server.mts} (88%) rename src/utils/telemetry/{index.mjs => index.mts} (100%) rename src/utils/telemetry/{report-error.mjs => report-error.mts} (76%) rename src/utils/telemetry/{request.mjs => request.mts} (89%) rename src/utils/telemetry/{telemetry.mjs => telemetry.mts} (80%) rename src/utils/telemetry/{utils.mjs => utils.mts} (71%) rename src/utils/telemetry/{validation.mjs => validation.mts} (78%) rename src/utils/{validation.mjs => validation.mts} (80%) diff --git a/.eslintrc.cjs b/.eslintrc.cjs index 90bf4483e57..406834ec1f9 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -15,6 +15,8 @@ module.exports = { }, }, }, + // .mjs files in this folder are compiled from TS + ignorePatterns: ['src/**/*.mjs'], rules: { 'workspace/no-process-cwd': 'error', // Those rules from @netlify/eslint-config-node are currently disabled @@ -87,7 +89,7 @@ module.exports = { }, }, { - files: ['src/**/*.mjs', 'bin/**/*.mjs'], + files: ['bin/**/*.mjs'], parserOptions: { ecmaVersion: '2020', sourceType: 'module', @@ -116,7 +118,7 @@ module.exports = { }, }, { - files: ['*.ts'], + files: ['*.mts'], rules: { // Pure ES modules with TypeScript require using `.js` instead of `.ts` // in imports diff --git a/.gitignore b/.gitignore index 1a94167da46..365fde02afd 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,12 @@ coverage !.vscode/launch.json .github/styles +# compiled files +src/**/*.mjs +!src/functions-templates/**/*.mjs +src/**/*.d.mts +tsconfig.tsbuildinfo + # node sdk vendor diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000000..a712d06c958 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,2 @@ +node_modules +src/**/*.mjs diff --git a/package-lock.json b/package-lock.json index 44e88943b5c..c7865e140bb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -130,6 +130,7 @@ "@netlify/eslint-config-node": "7.0.0", "@netlify/functions": "2.0.2", "@types/fs-extra": "11.0.1", + "@types/inquirer": "9.0.7", "@types/prettyjson": "0.0.30", "@types/semver": "7.5.0", "@vitest/coverage-v8": "1.0.0-beta.4", @@ -6857,6 +6858,31 @@ "@types/node": "*" } }, + "node_modules/@types/inquirer": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-9.0.7.tgz", + "integrity": "sha512-Q0zyBupO6NxGRZut/JdmqYKOnN95Eg5V8Csg3PGKkP+FnvsUZx1jAyK7fztIszxxMuoBA6E3KXWvdZVXIpx60g==", + "dev": true, + "dependencies": { + "@types/through": "*", + "rxjs": "^7.2.0" + } + }, + "node_modules/@types/inquirer/node_modules/rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dev": true, + "dependencies": { + "tslib": "^2.1.0" + } + }, + "node_modules/@types/inquirer/node_modules/tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "dev": true + }, "node_modules/@types/istanbul-lib-coverage": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", @@ -7006,6 +7032,15 @@ "@types/node": "*" } }, + "node_modules/@types/through": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@types/through/-/through-0.0.33.tgz", + "integrity": "sha512-HsJ+z3QuETzP3cswwtzt2vEIiHBk/dCcHGhbmG5X3ecnwFD/lPrMpliGXxSCg03L9AhrdwA4Oz/qfspkDW+xGQ==", + "dev": true, + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/unist": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz", @@ -29188,6 +29223,33 @@ "@types/node": "*" } }, + "@types/inquirer": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/@types/inquirer/-/inquirer-9.0.7.tgz", + "integrity": "sha512-Q0zyBupO6NxGRZut/JdmqYKOnN95Eg5V8Csg3PGKkP+FnvsUZx1jAyK7fztIszxxMuoBA6E3KXWvdZVXIpx60g==", + "dev": true, + "requires": { + "@types/through": "*", + "rxjs": "^7.2.0" + }, + "dependencies": { + "rxjs": { + "version": "7.8.1", + "resolved": "https://registry.npmjs.org/rxjs/-/rxjs-7.8.1.tgz", + "integrity": "sha512-AA3TVj+0A2iuIoQkWEK/tqFjBq2j+6PO6Y0zJcvzLAFhEFIO3HL0vls9hWLncZbAAbK0mar7oZ4V079I/qPMxg==", + "dev": true, + "requires": { + "tslib": "^2.1.0" + } + }, + "tslib": { + "version": "2.6.2", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz", + "integrity": "sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==", + "dev": true + } + } + }, "@types/istanbul-lib-coverage": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.4.tgz", @@ -29337,6 +29399,15 @@ "@types/node": "*" } }, + "@types/through": { + "version": "0.0.33", + "resolved": "https://registry.npmjs.org/@types/through/-/through-0.0.33.tgz", + "integrity": "sha512-HsJ+z3QuETzP3cswwtzt2vEIiHBk/dCcHGhbmG5X3ecnwFD/lPrMpliGXxSCg03L9AhrdwA4Oz/qfspkDW+xGQ==", + "dev": true, + "requires": { + "@types/node": "*" + } + }, "@types/unist": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.6.tgz", diff --git a/package.json b/package.json index 2bfea2f3583..8064cd96e12 100644 --- a/package.json +++ b/package.json @@ -11,15 +11,16 @@ "/bin", "/npm-shrinkwrap.json", "/scripts/postinstall.mjs", - "/src/**/*.cjs", "/src/**/*.js", "/src/**/*.mjs", + "/src/**/types.d.ts", "/src/**/*.sh", "/src/**/*.ps1", "/src/functions-templates/**", "/src/lib/templates/**", "!/src/**/node_modules/**", - "!/src/**/*.test.js" + "!/src/**/*.test.js", + "!/src/**/*.mts" ], "homepage": "https://github.com/netlify/cli", "keywords": [ @@ -40,6 +41,7 @@ "scripts": { "prepare": "is-ci || husky install node_modules/@netlify/eslint-config-node/.husky/", "start": "node ./bin/run.mjs", + "build": "tsc", "test": "run-s format test:dev", "format": "run-s format:check-fix:*", "format:ci": "run-s format:check:*", @@ -47,8 +49,8 @@ "format:check:lint": "cross-env-shell eslint $npm_package_config_eslint", "format:fix:lint": "cross-env-shell eslint --fix $npm_package_config_eslint", "format:check-fix:prettier": "run-e format:check:prettier format:fix:prettier", - "format:check:prettier": "cross-env-shell prettier --check $npm_package_config_prettier", - "format:fix:prettier": "cross-env-shell prettier --write $npm_package_config_prettier", + "format:check:prettier": "cross-env-shell prettier --check $npm_package_config_prettier --ignore-path .prettierignore", + "format:fix:prettier": "cross-env-shell prettier --write $npm_package_config_prettier --ignore-path .prettierignore", "test:dev": "run-s certs test:init:* test:dev:*", "test:init": "run-s test:init:*", "test:init:cli-version": "npm run start -- --version", @@ -65,7 +67,8 @@ "site:build": "run-s site:build:*", "site:build:install": "cd site && npm install --no-audit", "site:build:assets": "cd site && npm run build", - "postinstall": "node ./scripts/postinstall.mjs", + "postinstall-pack": "node ./scripts/postinstall.mjs", + "postinstall": "npm run build && node ./scripts/postinstall.mjs", "prepublishOnly": "node ./scripts/prepare-for-publish.mjs", "certs": "openssl req -x509 -out localhost.crt -keyout localhost.key -newkey rsa:2048 -nodes -sha256 -subj \"/CN=localhost\" -extensions EXT -config certconf" }, @@ -190,6 +193,7 @@ "@netlify/eslint-config-node": "7.0.0", "@netlify/functions": "2.0.2", "@types/fs-extra": "11.0.1", + "@types/inquirer": "9.0.7", "@types/prettyjson": "0.0.30", "@types/semver": "7.5.0", "@vitest/coverage-v8": "1.0.0-beta.4", diff --git a/scripts/prepare-for-publish.mjs b/scripts/prepare-for-publish.mjs index 575ff702ab3..1145db3bc5b 100644 --- a/scripts/prepare-for-publish.mjs +++ b/scripts/prepare-for-publish.mjs @@ -6,7 +6,14 @@ import execa from 'execa' import ora from 'ora' // These scripts from package.json need to be preserved on publish -const preserveScripts = new Set(['postinstall', 'postpack', 'preinstall', 'prepack', 'prepublish', 'prepublishOnly']) +const preserveScripts = new Set([ + 'postinstall-pack', + 'postpack', + 'preinstall', + 'prepack', + 'prepublish', + 'prepublishOnly', +]) let spinner = ora({ spinner: 'star', @@ -27,6 +34,10 @@ for (const scriptName in pkgJson.scripts) { delete pkgJson.scripts[scriptName] } + +pkgJson.scripts.postinstall = pkgJson.scripts['postinstall-pack'] +delete pkgJson.scripts['postinstall-pack'] + await writeFile(packageJsonPath, JSON.stringify(pkgJson, null, 2)) spinner.succeed() diff --git a/site/scripts/docs.mjs b/site/scripts/docs.mjs index bfb09a13a5f..6757c6dcfde 100644 --- a/site/scripts/docs.mjs +++ b/site/scripts/docs.mjs @@ -1,4 +1,4 @@ -// @ts-check + import { basename } from 'path' import { env } from 'process' import { fileURLToPath } from 'url' diff --git a/site/scripts/generate-command-data.mjs b/site/scripts/generate-command-data.mjs index 37d883daba2..b52538a75b6 100644 --- a/site/scripts/generate-command-data.mjs +++ b/site/scripts/generate-command-data.mjs @@ -1,4 +1,4 @@ -// @ts-check + import { createMainCommand } from '../../src/commands/index.mjs' import { sortOptions } from '../../src/utils/command-helpers.mjs' diff --git a/src/commands/addons/addons-auth.mjs b/src/commands/addons/addons-auth.mts similarity index 71% rename from src/commands/addons/addons-auth.mjs rename to src/commands/addons/addons-auth.mts index f83cf4f19eb..5845cddd36a 100644 --- a/src/commands/addons/addons-auth.mjs +++ b/src/commands/addons/addons-auth.mts @@ -1,4 +1,4 @@ -// @ts-check + import { ADDON_VALIDATION, prepareAddonCommand } from '../../utils/addons/prepare.mjs' import { exit, log } from '../../utils/command-helpers.mjs' import openBrowser from '../../utils/open-browser.mjs' @@ -10,11 +10,11 @@ import openBrowser from '../../utils/open-browser.mjs' * @param {import('../base-command.mjs').default} command * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message const addonsAuth = async (addonName, options, command) => { const { addon } = await prepareAddonCommand({ command, addonName, - // @ts-ignore when migrating to typescript this should be a const enum validation: ADDON_VALIDATION.EXISTS, }) @@ -28,6 +28,7 @@ const addonsAuth = async (addonName, options, command) => { log() log(addon.auth_url) log() + // @ts-expect-error TS(2345) FIXME: Argument of type '{ url: any; }' is not assignable... Remove this comment to see the full error message await openBrowser({ url: addon.auth_url }) exit() } @@ -37,12 +38,14 @@ const addonsAuth = async (addonName, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createAddonsAuthCommand = (program) => program .command('addons:auth', { hidden: true }) .alias('addon:auth') .argument('', 'Add-on slug') .description('Login to add-on provider') + // @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message .action(async (addonName, options, command) => { await addonsAuth(addonName, options, command) }) diff --git a/src/commands/addons/addons-config.mjs b/src/commands/addons/addons-config.mts similarity index 85% rename from src/commands/addons/addons-config.mjs rename to src/commands/addons/addons-config.mts index 46e51ab0016..ea9f6754aca 100644 --- a/src/commands/addons/addons-config.mjs +++ b/src/commands/addons/addons-config.mts @@ -1,4 +1,4 @@ -// @ts-check + import inquirer from 'inquirer' import isEmpty from 'lodash/isEmpty.js' @@ -11,6 +11,7 @@ import { missingConfigValues, requiredConfigValues, updateConfigValues } from '. import { chalk, error, log } from '../../utils/command-helpers.mjs' import { parseRawFlags } from '../../utils/parse-raw-flags.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message const update = async function ({ addonName, api, currentConfig, instanceId, newConfig, siteId }) { const codeDiff = diffValues(currentConfig, newConfig) if (!codeDiff) { @@ -33,6 +34,7 @@ const update = async function ({ addonName, api, currentConfig, instanceId, newC }) log(`Add-on "${addonName}" successfully updated`) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(error_.message) } } @@ -44,11 +46,11 @@ const update = async function ({ addonName, api, currentConfig, instanceId, newC * @param {import('../base-command.mjs').default} command * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message const addonsConfig = async (addonName, options, command) => { const { addon, manifest, siteData } = await prepareAddonCommand({ command, addonName, - // @ts-ignore validation: ADDON_VALIDATION.EXISTS, }) @@ -122,6 +124,7 @@ const addonsConfig = async (addonName, options, command) => { const diffs = compare(currentConfig, newConfig) // log('compare', diffs) + // @ts-expect-error TS(2339) FIXME: Property 'isEqual' does not exist on type 'string'... Remove this comment to see the full error message if (diffs.isEqual) { log(`No changes. exiting early`) return false @@ -129,7 +132,9 @@ const addonsConfig = async (addonName, options, command) => { log() log(`${chalk.yellowBright.bold.underline('Confirm your updates:')}`) log() + // @ts-expect-error TS(2339) FIXME: Property 'keys' does not exist on type 'string'. diffs.keys.forEach((key) => { + // @ts-expect-error TS(2339) FIXME: Property 'diffs' does not exist on type 'string'. const { newValue, oldValue } = diffs.diffs[key] const oldVal = oldValue || 'NO VALUE' log(`${chalk.cyan(key)} changed from ${chalk.whiteBright(oldVal)} to ${chalk.green(newValue)}`) @@ -166,6 +171,7 @@ const addonsConfig = async (addonName, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createAddonsConfigCommand = (program) => program .command('addons:config', { hidden: true }) @@ -174,6 +180,7 @@ export const createAddonsConfigCommand = (program) => .description('Configure add-on settings') // allow for any flags. Handy for variadic configuration options .allowUnknownOption(true) + // @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message .action(async (addonName, options, command) => { await addonsConfig(addonName, options, command) }) diff --git a/src/commands/addons/addons-create.mjs b/src/commands/addons/addons-create.mts similarity index 85% rename from src/commands/addons/addons-create.mjs rename to src/commands/addons/addons-create.mts index ba40be412ba..5dc9520a6d2 100644 --- a/src/commands/addons/addons-create.mjs +++ b/src/commands/addons/addons-create.mts @@ -1,4 +1,4 @@ -// @ts-check + import inquirer from 'inquirer' import isEmpty from 'lodash/isEmpty.js' @@ -9,6 +9,7 @@ import { missingConfigValues, requiredConfigValues, updateConfigValues } from '. import { chalk, error, log } from '../../utils/command-helpers.mjs' import { parseRawFlags } from '../../utils/parse-raw-flags.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message const createAddon = async ({ addonName, api, config, siteData, siteId }) => { try { const response = await api.createServiceInstance({ @@ -22,6 +23,7 @@ const createAddon = async ({ addonName, api, config, siteData, siteId }) => { log(`${response.config.message}`) } } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(error_.message) } } @@ -33,11 +35,11 @@ const createAddon = async ({ addonName, api, config, siteData, siteId }) => { * @param {import('../base-command.mjs').default} command * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message const addonsCreate = async (addonName, options, command) => { const { manifest, siteData } = await prepareAddonCommand({ command, addonName, - // @ts-ignore validation: ADDON_VALIDATION.NOT_EXISTS, }) @@ -80,6 +82,7 @@ const addonsCreate = async (addonName, options, command) => { const words = `The ${addonName} add-on has the following configurable options:` log(` ${chalk.yellowBright.bold(words)}`) + // @ts-expect-error TS(2554) FIXME: Expected 3 arguments, but got 2. renderConfigValues(addonName, manifest.config) log() log(` ${chalk.greenBright.bold('Lets configure those!')}`) @@ -99,6 +102,7 @@ const addonsCreate = async (addonName, options, command) => { configValues = updateConfigValues(manifest.config, rawFlags, userInput) const missingRequiredValues = missingConfigValues(required, configValues) if (missingRequiredValues && missingRequiredValues.length !== 0) { + // @ts-expect-error TS(7006) FIXME: Parameter 'val' implicitly has an 'any' type. missingRequiredValues.forEach((val) => { log(`Missing required value "${val}". Please run the command again`) }) @@ -114,6 +118,7 @@ const addonsCreate = async (addonName, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createAddonsCreateCommand = (program) => program .command('addons:create', { hidden: true }) @@ -125,6 +130,7 @@ Add-ons are a way to extend the functionality of your Netlify site`, ) // allow for any flags. Handy for variadic configuration options .allowUnknownOption(true) + // @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message .action(async (addonName, options, command) => { await addonsCreate(addonName, options, command) }) diff --git a/src/commands/addons/addons-delete.mjs b/src/commands/addons/addons-delete.mts similarity index 85% rename from src/commands/addons/addons-delete.mjs rename to src/commands/addons/addons-delete.mts index 14902cbb5e4..71967918636 100644 --- a/src/commands/addons/addons-delete.mjs +++ b/src/commands/addons/addons-delete.mts @@ -1,4 +1,4 @@ -// @ts-check + import inquirer from 'inquirer' import { ADDON_VALIDATION, prepareAddonCommand } from '../../utils/addons/prepare.mjs' @@ -10,11 +10,11 @@ import { error, exit, log } from '../../utils/command-helpers.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message const addonsDelete = async (addonName, options, command) => { const { addon } = await prepareAddonCommand({ command, addonName, - // @ts-ignore. validation: ADDON_VALIDATION.EXISTS, }) if (!options.force && !options.f) { @@ -37,6 +37,7 @@ const addonsDelete = async (addonName, options, command) => { }) log(`Addon "${addonName}" deleted`) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(error_.message) } } @@ -46,6 +47,7 @@ const addonsDelete = async (addonName, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createAddonsDeleteCommand = (program) => program .command('addons:delete', { hidden: true }) diff --git a/src/commands/addons/addons-list.mjs b/src/commands/addons/addons-list.mts similarity index 70% rename from src/commands/addons/addons-list.mjs rename to src/commands/addons/addons-list.mts index 3e7c617e6a0..3a9b5f211cb 100644 --- a/src/commands/addons/addons-list.mjs +++ b/src/commands/addons/addons-list.mts @@ -1,4 +1,5 @@ -// @ts-check + +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'asci... Remove this comment to see the full error message import AsciiTable from 'ascii-table' import { prepareAddonCommand } from '../../utils/addons/prepare.mjs' @@ -10,7 +11,9 @@ import { log, logJson } from '../../utils/command-helpers.mjs' * @param {import('../base-command.mjs').default} command * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const addonsList = async (options, command) => { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ command: any; }' is not assign... Remove this comment to see the full error message const { addons, siteData } = await prepareAddonCommand({ command }) // Return json response for piping commands if (options.json) { @@ -24,6 +27,7 @@ const addonsList = async (options, command) => { return false } + // @ts-expect-error TS(7006) FIXME: Parameter 'addon' implicitly has an 'any' type. const addonData = addons.map((addon) => ({ namespace: addon.service_path.replace('/.netlify/', ''), name: addon.service_name, @@ -36,6 +40,7 @@ const addonsList = async (options, command) => { table.setHeading('NameSpace', 'Name', 'Instance Id') + // @ts-expect-error TS(7031) FIXME: Binding element 'id' implicitly has an 'any' type. addonData.forEach(({ id, name, namespace }) => { table.addRow(namespace, name, id) }) @@ -48,12 +53,14 @@ const addonsList = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createAddonsListCommand = (program) => program .command('addons:list', { hidden: true }) .alias('addon:list') .description(`List currently installed add-ons for site`) .option('--json', 'Output add-on data as JSON') + // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. .action(async (options, command) => { await addonsList(options, command) }) diff --git a/src/commands/addons/addons.mjs b/src/commands/addons/addons.mts similarity index 88% rename from src/commands/addons/addons.mjs rename to src/commands/addons/addons.mts index 8ad26239611..307787b3ea7 100644 --- a/src/commands/addons/addons.mjs +++ b/src/commands/addons/addons.mts @@ -1,4 +1,4 @@ -// @ts-check + import { createAddonsAuthCommand } from './addons-auth.mjs' import { createAddonsConfigCommand } from './addons-config.mjs' import { createAddonsCreateCommand } from './addons-create.mjs' @@ -10,6 +10,7 @@ import { createAddonsListCommand } from './addons-list.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const addons = (options, command) => { command.help() } @@ -19,6 +20,7 @@ const addons = (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createAddonsCommand = (program) => { createAddonsAuthCommand(program) createAddonsConfigCommand(program) diff --git a/src/commands/addons/index.mjs b/src/commands/addons/index.mts similarity index 100% rename from src/commands/addons/index.mjs rename to src/commands/addons/index.mts diff --git a/src/commands/api/api.mjs b/src/commands/api/api.mts similarity index 80% rename from src/commands/api/api.mjs rename to src/commands/api/api.mts index c31744c63fa..01b136f9b71 100644 --- a/src/commands/api/api.mjs +++ b/src/commands/api/api.mts @@ -1,4 +1,5 @@ -// @ts-check + +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'asci... Remove this comment to see the full error message import AsciiTable from 'ascii-table' import { methods } from 'netlify' @@ -10,6 +11,7 @@ import { chalk, error, exit, log, logJson } from '../../utils/command-helpers.mj * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'apiMethod' implicitly has an 'any' type... Remove this comment to see the full error message const apiCommand = async (apiMethod, options, command) => { const { api } = command.netlify @@ -45,6 +47,7 @@ const apiCommand = async (apiMethod, options, command) => { const apiResponse = await api[apiMethod](payload) logJson(apiResponse) } catch (error_) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } @@ -54,6 +57,7 @@ const apiCommand = async (apiMethod, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createApiCommand = (program) => program .command('api') diff --git a/src/commands/api/index.mjs b/src/commands/api/index.mts similarity index 100% rename from src/commands/api/index.mjs rename to src/commands/api/index.mts diff --git a/src/commands/base-command.mjs b/src/commands/base-command.mts similarity index 81% rename from src/commands/base-command.mjs rename to src/commands/base-command.mts index fcf0aaba17a..3e05ab36199 100644 --- a/src/commands/base-command.mjs +++ b/src/commands/base-command.mts @@ -1,4 +1,4 @@ -// @ts-check + import { existsSync } from 'fs' import { join, relative, resolve } from 'path' import process from 'process' @@ -7,11 +7,14 @@ import { format } from 'util' import { DefaultLogger, Project } from '@netlify/build-info' // eslint-disable-next-line import/extensions, n/no-missing-import import { NodeFS, NoopLogger } from '@netlify/build-info/node' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module '@net... Remove this comment to see the full error message import { resolveConfig } from '@netlify/config' import { Command, Option } from 'commander' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'debu... Remove this comment to see the full error message import debug from 'debug' import { findUp } from 'find-up' import inquirer from 'inquirer' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'inqu... Remove this comment to see the full error message import inquirerAutocompletePrompt from 'inquirer-autocomplete-prompt' import merge from 'lodash/merge.js' import { NetlifyAPI } from 'netlify' @@ -65,6 +68,7 @@ const COMMANDS_WITHOUT_WORKSPACE_OPTIONS = new Set(['api', 'recipes', 'completio * @param {string[]} textArray * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'textArray' implicitly has an 'any' type... Remove this comment to see the full error message const formatHelpList = (textArray) => textArray.join('\n').replace(/^/gm, ' '.repeat(HELP_INDENT_WIDTH)) /** @@ -72,6 +76,7 @@ const formatHelpList = (textArray) => textArray.join('\n').replace(/^/gm, ' '.re * @param {bigint} startTime * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'startTime' implicitly has an 'any' type... Remove this comment to see the full error message const getDuration = function (startTime) { const durationNs = process.hrtime.bigint() - startTime return Math.round(Number(durationNs / BigInt(NANO_SECS_TO_MSECS))) @@ -84,7 +89,9 @@ const getDuration = function (startTime) { * @param {string=} filter * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'project' implicitly has an 'any' type. async function selectWorkspace(project, filter) { + // @ts-expect-error TS(7006) FIXME: Parameter 'pkg' implicitly has an 'any' type. const selected = project.workspace?.packages.find((pkg) => { if ( project.relativeBaseDirectory && @@ -102,11 +109,15 @@ async function selectWorkspace(project, filter) { const { result } = await inquirer.prompt({ name: 'result', + // @ts-expect-error TS(2769) FIXME: No overload matches this call. type: 'autocomplete', message: 'Select the site you want to work with', + // @ts-expect-error TS(7006) FIXME: Parameter '_' implicitly has an 'any' type. source: (/** @type {string} */ _, input = '') => (project.workspace?.packages || []) + // @ts-expect-error TS(7006) FIXME: Parameter 'pkg' implicitly has an 'any' type. .filter((pkg) => pkg.path.includes(input)) + // @ts-expect-error TS(7006) FIXME: Parameter 'pkg' implicitly has an 'any' type. .map((pkg) => ({ name: `${pkg.name ? `${chalk.bold(pkg.name)} ` : ''}${pkg.path} ${chalk.dim( `--filter ${pkg.name || pkg.path}`, @@ -126,12 +137,14 @@ export default class BaseCommand extends Command { * The netlify object inside each command with the state * @type {import('./types.js').NetlifyOptions} */ + // @ts-expect-error TS(7008) FIXME: Member 'netlify' implicitly has an 'any' type. netlify /** @type {{ startTime: bigint, payload?: any}} */ analytics = { startTime: process.hrtime.bigint() } /** @type {Project} */ + // @ts-expect-error TS(7008) FIXME: Member 'project' implicitly has an 'any' type. project /** @@ -148,11 +161,13 @@ export default class BaseCommand extends Command { * Must not be the repository root! * @type {string|undefined} */ + // @ts-expect-error TS(7008) FIXME: Member 'jsWorkspaceRoot' implicitly has an 'any' t... Remove this comment to see the full error message jsWorkspaceRoot /** * The current workspace package we should execute the commands in * @type {string|undefined} */ + // @ts-expect-error TS(7008) FIXME: Member 'workspacePackage' implicitly has an 'any' ... Remove this comment to see the full error message workspacePackage /** @@ -161,6 +176,7 @@ export default class BaseCommand extends Command { * @param {string} name The command name * @returns */ + // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. createCommand(name) { const base = new BaseCommand(name) // If --silent or --json flag passed disable logger @@ -208,7 +224,6 @@ export default class BaseCommand extends Command { } debug(`${name}:preAction`)('start') this.analytics = { startTime: process.hrtime.bigint() } - // @ts-ignore cannot type actionCommand as BaseCommand await this.init(actionCommand) debug(`${name}:preAction`)('end') }) @@ -230,6 +245,7 @@ export default class BaseCommand extends Command { * Set examples for the command * @param {string[]} examples */ + // @ts-expect-error TS(7006) FIXME: Parameter 'examples' implicitly has an 'any' type. addExamples(examples) { this.examples = examples return this @@ -254,9 +270,11 @@ export default class BaseCommand extends Command { /** * @param {BaseCommand} command */ + // @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. const getCommands = (command) => { const parentCommand = this.name() === 'netlify' ? command : command.parent return ( + // @ts-expect-error TS(7006) FIXME: Parameter 'cmd' implicitly has an 'any' type. parentCommand?.commands.filter((cmd) => { if (cmd._hidden) return false // the root command @@ -275,6 +293,7 @@ export default class BaseCommand extends Command { * @returns {number} */ help.longestSubcommandTermLength = (command) => + // @ts-expect-error TS(7006) FIXME: Parameter 'max' implicitly has an 'any' type. getCommands(command).reduce((max, cmd) => Math.max(max, cmd.name().length), 0) /** @@ -284,6 +303,7 @@ export default class BaseCommand extends Command { * @returns {number} */ help.longestOptionTermLength = (command, helper) => + // @ts-expect-error TS(2551) FIXME: Property 'noBaseOptions' does not exist on type 'C... Remove this comment to see the full error message (command.noBaseOptions === false && helper.visibleOptions(command).reduce((max, option) => Math.max(max, helper.optionTerm(option).length), 0)) || 0 @@ -305,6 +325,7 @@ export default class BaseCommand extends Command { * @param {boolean} [isCommand] * @returns {string} */ + // @ts-expect-error TS(7006) FIXME: Parameter 'term' implicitly has an 'any' type. const formatItem = (term, description, isCommand = false) => { const bang = isCommand ? `${HELP_$} ` : '' @@ -318,20 +339,24 @@ export default class BaseCommand extends Command { } /** @type {string[]} */ + // @ts-expect-error TS(7034) FIXME: Variable 'output' implicitly has type 'any[]' in s... Remove this comment to see the full error message let output = [] // Description const [topDescription, ...commandDescription] = (helper.commandDescription(command) || '').split('\n') if (topDescription.length !== 0) { + // @ts-expect-error TS(7005) FIXME: Variable 'output' implicitly has an 'any[]' type. output = [...output, topDescription, ''] } // on the parent help command the version should be displayed if (this.name() === 'netlify') { + // @ts-expect-error TS(7005) FIXME: Variable 'output' implicitly has an 'any[]' type. output = [...output, chalk.bold('VERSION'), formatHelpList([formatItem(USER_AGENT)]), ''] } // Usage + // @ts-expect-error TS(7005) FIXME: Variable 'output' implicitly has an 'any[]' type. output = [...output, chalk.bold('USAGE'), helper.commandUsage(command), ''] // Arguments @@ -342,6 +367,7 @@ export default class BaseCommand extends Command { output = [...output, chalk.bold('ARGUMENTS'), formatHelpList(argumentList), ''] } + // @ts-expect-error TS(2551) FIXME: Property 'noBaseOptions' does not exist on type 'C... Remove this comment to see the full error message if (command.noBaseOptions === false) { // Options const optionList = helper @@ -360,20 +386,25 @@ export default class BaseCommand extends Command { // Aliases + // @ts-expect-error TS(2551) FIXME: Property '_aliases' does not exist on type 'Comman... Remove this comment to see the full error message if (command._aliases.length !== 0) { + // @ts-expect-error TS(2551) FIXME: Property '_aliases' does not exist on type 'Comman... Remove this comment to see the full error message const aliases = command._aliases.map((alias) => formatItem(`${parentCommand.name()} ${alias}`, null, true)) output = [...output, chalk.bold('ALIASES'), formatHelpList(aliases), ''] } + // @ts-expect-error TS(2339) FIXME: Property 'examples' does not exist on type 'Comman... Remove this comment to see the full error message if (command.examples.length !== 0) { output = [ ...output, chalk.bold('EXAMPLES'), + // @ts-expect-error TS(2339) FIXME: Property 'examples' does not exist on type 'Comman... Remove this comment to see the full error message formatHelpList(command.examples.map((example) => `${HELP_$} ${example}`)), '', ] } + // @ts-expect-error TS(7006) FIXME: Parameter 'cmd' implicitly has an 'any' type. const commandList = getCommands(command).map((cmd) => formatItem(cmd.name(), helper.subcommandDescription(cmd).split('\n')[0], true), ) @@ -390,7 +421,9 @@ export default class BaseCommand extends Command { * Will be called on the end of an action to track the metrics * @param {*} [error_] */ + // @ts-expect-error TS(7006) FIXME: Parameter 'error_' implicitly has an 'any' type. async onEnd(error_) { + // @ts-expect-error TS(2339) FIXME: Property 'payload' does not exist on type '{ start... Remove this comment to see the full error message const { payload, startTime } = this.analytics const duration = getDuration(startTime) const status = error_ === undefined ? 'success' : 'error' @@ -409,6 +442,7 @@ export default class BaseCommand extends Command { } catch {} if (error_ !== undefined) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'string | Error' is not assignabl... Remove this comment to see the full error message error(error_ instanceof Error ? error_ : format(error_), { exit: false }) exit(1) } @@ -419,6 +453,7 @@ export default class BaseCommand extends Command { * @param {string|undefined} tokenFromFlag * @returns */ + // @ts-expect-error TS(7006) FIXME: Parameter 'tokenFromFlag' implicitly has an 'any' ... Remove this comment to see the full error message async authenticate(tokenFromFlag) { const [token] = await getToken(tokenFromFlag) if (token) { @@ -432,7 +467,6 @@ export default class BaseCommand extends Command { log(`Logging into your Netlify account...`) // Create ticket for auth - // @ts-ignore Types from api are wrong and they don't recognize `createTicket` const ticket = await this.netlify.api.createTicket({ clientId: CLIENT_ID, }) @@ -441,6 +475,7 @@ export default class BaseCommand extends Command { const authLink = `${webUI}/authorize?response_type=ticket&ticket=${ticket.id}` log(`Opening ${authLink}`) + // @ts-expect-error TS(2345) FIXME: Argument of type '{ url: string; }' is not assigna... Remove this comment to see the full error message await openBrowser({ url: authLink }) const accessToken = await pollForToken({ @@ -448,7 +483,6 @@ export default class BaseCommand extends Command { ticket, }) - // @ts-ignore Types from api are wrong and they don't recognize `getCurrentUser` const { email, full_name: name, id: userId } = await this.netlify.api.getCurrentUser() const userData = merge(this.netlify.globalConfig.get(`users.${userId}`), { @@ -492,8 +526,11 @@ export default class BaseCommand extends Command { * Adds some data to the analytics payload * @param {Record} payload */ + // @ts-expect-error TS(7006) FIXME: Parameter 'payload' implicitly has an 'any' type. setAnalyticsPayload(payload) { + // @ts-expect-error TS(2339) FIXME: Property 'payload' does not exist on type '{ start... Remove this comment to see the full error message const newPayload = { ...this.analytics.payload, ...payload } + // @ts-expect-error TS(2322) FIXME: Type '{ payload: any; startTime: bigint; }' is not... Remove this comment to see the full error message this.analytics = { ...this.analytics, payload: newPayload } } @@ -502,6 +539,7 @@ export default class BaseCommand extends Command { * @param {BaseCommand} actionCommand The command of the action that is run (`this.` gets the parent command) * @private */ + // @ts-expect-error TS(7006) FIXME: Parameter 'actionCommand' implicitly has an 'any' ... Remove this comment to see the full error message async init(actionCommand) { debug(`${actionCommand.name()}:init`)('start') const flags = actionCommand.opts() @@ -515,6 +553,7 @@ export default class BaseCommand extends Command { // ================================================== // retrieve the repository root + // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. const rootDir = await getRepositoryRoot() // Get framework, add to analytics payload for every command, if a framework is set const fs = new NodeFS() @@ -563,8 +602,11 @@ export default class BaseCommand extends Command { if (process.env.NETLIFY_API_URL) { const apiUrl = new URL(process.env.NETLIFY_API_URL) + // @ts-expect-error TS(2339) FIXME: Property 'scheme' does not exist on type '{ userAg... Remove this comment to see the full error message apiUrlOpts.scheme = apiUrl.protocol.slice(0, -1) + // @ts-expect-error TS(2339) FIXME: Property 'host' does not exist on type '{ userAgen... Remove this comment to see the full error message apiUrlOpts.host = apiUrl.host + // @ts-expect-error TS(2339) FIXME: Property 'pathPrefix' does not exist on type '{ us... Remove this comment to see the full error message apiUrlOpts.pathPrefix = process.env.NETLIFY_API_URL === `${apiUrl.protocol}//${apiUrl.host}` ? '/api/v1' : apiUrl.pathname } @@ -608,6 +650,7 @@ export default class BaseCommand extends Command { // ================================================== // Perform analytics reporting // ================================================== + // @ts-expect-error TS(7006) FIXME: Parameter 'framework' implicitly has an 'any' type... Remove this comment to see the full error message const frameworkIDs = frameworks?.map((framework) => framework.id) if (frameworkIDs?.length !== 0) { this.setAnalyticsPayload({ frameworks: frameworkIDs }) @@ -615,6 +658,7 @@ export default class BaseCommand extends Command { this.setAnalyticsPayload({ monorepo: Boolean(this.project.workspace), packageManager: this.project.packageManager?.name, + // @ts-expect-error TS(7031) FIXME: Binding element 'id' implicitly has an 'any' type. buildSystem: this.project.buildSystems.map(({ id }) => id), }) @@ -677,6 +721,7 @@ export default class BaseCommand extends Command { * @param {string=} config.scheme * @returns {ReturnType} */ + // @ts-expect-error TS(7023) FIXME: 'getConfig' implicitly has return type 'any' becau... Remove this comment to see the full error message async getConfig(config) { // the flags that are passed to the command like `--debug` or `--offline` const flags = this.opts() @@ -699,6 +744,7 @@ export default class BaseCommand extends Command { siteFeatureFlagPrefix: 'cli', }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. const isUserError = error_.customErrorInfo !== undefined && error_.customErrorInfo.type === 'resolveConfig' // If we're failing due to an error thrown by us, it might be because the token we're using is invalid. @@ -709,6 +755,7 @@ export default class BaseCommand extends Command { // the option to say that we don't need API data.) if (isUserError && !config.offline && config.token) { if (flags.debug) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_, { exit: false }) warn('Failed to resolve config, falling back to offline resolution') } @@ -716,6 +763,7 @@ export default class BaseCommand extends Command { return this.getConfig({ ...config, offline: true }) } + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. const message = isUserError ? error_.message : error_.stack error(message, { exit: true }) } @@ -739,6 +787,7 @@ export default class BaseCommand extends Command { * @param {string} [cwd] The optional current working directory * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'cwd' implicitly has an 'any' type. async function getRepositoryRoot(cwd) { const res = await findUp('.git', { cwd, type: 'directory' }) if (res) { diff --git a/src/commands/build/build.mjs b/src/commands/build/build.mts similarity index 77% rename from src/commands/build/build.mjs rename to src/commands/build/build.mts index 2db11fc1126..2195df3b665 100644 --- a/src/commands/build/build.mjs +++ b/src/commands/build/build.mts @@ -1,4 +1,4 @@ -// @ts-check + import process from 'process' import { getBuildOptions, runBuild } from '../../lib/build.mjs' @@ -9,7 +9,9 @@ import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.mjs' /** * @param {import('../../lib/build.mjs').BuildConfig} options */ +// @ts-expect-error TS(7031) FIXME: Binding element 'token' implicitly has an 'any' ty... Remove this comment to see the full error message export const checkOptions = ({ cachedConfig: { siteInfo = {} }, token }) => { + // @ts-expect-error TS(2339) FIXME: Property 'id' does not exist on type '{}'. if (!siteInfo.id) { error( 'Could not find the site ID. If your site is not on Netlify, please run `netlify init` or `netlify deploy` first. If it is, please run `netlify link`.', @@ -21,6 +23,7 @@ export const checkOptions = ({ cachedConfig: { siteInfo = {} }, token }) => { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. const injectEnv = async function (command, { api, buildOptions, context, siteInfo }) { const isUsingEnvelope = siteInfo && siteInfo.use_envelope @@ -35,10 +38,12 @@ const injectEnv = async function (command, { api, buildOptions, context, siteInf * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const build = async (options, command) => { const { cachedConfig, siteInfo } = command.netlify command.setAnalyticsPayload({ dry: options.dry }) // Retrieve Netlify Build options + // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. const [token] = await getToken() const settings = await detectFrameworkSettings(command, 'build') @@ -48,6 +53,7 @@ const build = async (options, command) => { cachedConfig.config.build.commandOrigin = 'heuristics' } + // @ts-expect-error TS(2345) FIXME: Argument of type '{ cachedConfig: any; packagePath... Remove this comment to see the full error message const buildOptions = await getBuildOptions({ cachedConfig, packagePath: command.workspacePackage, @@ -60,6 +66,7 @@ const build = async (options, command) => { checkOptions(buildOptions) const { api, site } = command.netlify const { context } = options + // @ts-expect-error TS(2345) FIXME: Argument of type '{ api: any; buildOptions: { cach... Remove this comment to see the full error message await injectEnv(command, { api, buildOptions, context, site, siteInfo }) } @@ -72,6 +79,7 @@ const build = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createBuildCommand = (program) => program .command('build') diff --git a/src/commands/build/index.mjs b/src/commands/build/index.mts similarity index 100% rename from src/commands/build/index.mjs rename to src/commands/build/index.mts diff --git a/src/commands/completion/completion.mjs b/src/commands/completion/completion.mts similarity index 77% rename from src/commands/completion/completion.mjs rename to src/commands/completion/completion.mts index 72fe7b0a74d..bb0d68b3dff 100644 --- a/src/commands/completion/completion.mjs +++ b/src/commands/completion/completion.mts @@ -1,6 +1,7 @@ import { dirname, join } from 'path' import { fileURLToPath } from 'url' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'tabt... Remove this comment to see the full error message import { install, uninstall } from 'tabtab' import { generateAutocompletion } from '../../lib/completion/index.mjs' @@ -12,6 +13,7 @@ const completer = join(dirname(fileURLToPath(import.meta.url)), '../../lib/compl * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const completionGenerate = async (options, command) => { const { parent } = command @@ -30,6 +32,7 @@ const completionGenerate = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createCompletionCommand = (program) => { program .command('completion:install') @@ -42,6 +45,7 @@ export const createCompletionCommand = (program) => { .alias('completion:remove') .description('Uninstalls the installed completions') .addExamples(['netlify completion:uninstall']) + // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. .action(async (options, command) => { await uninstall({ name: command.parent.name(), @@ -52,6 +56,7 @@ export const createCompletionCommand = (program) => { .command('completion') .description('Generate shell completion script\nRun this command to see instructions for your shell.') .addExamples(['netlify completion:install']) + // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. .action((options, command) => { command.help() }) diff --git a/src/commands/completion/index.mjs b/src/commands/completion/index.mts similarity index 100% rename from src/commands/completion/index.mjs rename to src/commands/completion/index.mts diff --git a/src/commands/deploy/deploy.mjs b/src/commands/deploy/deploy.mts similarity index 74% rename from src/commands/deploy/deploy.mjs rename to src/commands/deploy/deploy.mts index 87712897993..7d82fc9911c 100644 --- a/src/commands/deploy/deploy.mjs +++ b/src/commands/deploy/deploy.mts @@ -1,4 +1,4 @@ -// @ts-check + import { stat } from 'fs/promises' import { basename, resolve } from 'path' import { env } from 'process' @@ -39,10 +39,12 @@ import openBrowser from '../../utils/open-browser.mjs' import { link } from '../link/index.mjs' import { sitesCreate } from '../sites/index.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const triggerDeploy = async ({ api, options, siteData, siteId }) => { try { const siteBuild = await api.createSiteBuild({ siteId }) if (options.json) { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ site_id: any; site_name: any; ... Remove this comment to see the full error message logJson({ site_id: siteId, site_name: siteData.name, @@ -55,9 +57,11 @@ const triggerDeploy = async ({ api, options, siteData, siteId }) => { ) } } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 404) { error('Site not found. Please rerun "netlify link" and make sure that your site has CI configured.') } else { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(error_.message) } } @@ -73,6 +77,7 @@ const triggerDeploy = async ({ api, options, siteData, siteId }) => { * @param {object} config.siteData * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message const getDeployFolder = async ({ command, config, options, site, siteData }) => { let deployFolder // if the `--dir .` flag is provided we should resolve it to the working directory. @@ -108,17 +113,20 @@ const getDeployFolder = async ({ command, config, options, site, siteData }) => /** * @param {string} deployFolder */ +// @ts-expect-error TS(7006) FIXME: Parameter 'deployFolder' implicitly has an 'any' t... Remove this comment to see the full error message const validateDeployFolder = async (deployFolder) => { /** @type {import('fs').Stats} */ let stats try { stats = await stat(deployFolder) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.code === 'ENOENT') { return error(`No such directory ${deployFolder}! Did you forget to run a build?`) } // Improve the message of permission errors + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.code === 'EACCES') { return error('Permission error when trying to access deploy folder') } @@ -141,6 +149,7 @@ const validateDeployFolder = async (deployFolder) => { * @param {string} config.workingDir // The process working directory * @returns {string|undefined} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message const getFunctionsFolder = ({ config, options, site, siteData, workingDir }) => { let functionsFolder // Support "functions" and "Functions" @@ -159,6 +168,7 @@ const getFunctionsFolder = ({ config, options, site, siteData, workingDir }) => * * @param {string|undefined} functionsFolder */ +// @ts-expect-error TS(7006) FIXME: Parameter 'functionsFolder' implicitly has an 'any... Remove this comment to see the full error message const validateFunctionsFolder = async (functionsFolder) => { /** @type {import('fs').Stats|undefined} */ let stats @@ -168,12 +178,14 @@ const validateFunctionsFolder = async (functionsFolder) => { try { stats = await stat(functionsFolder) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.code === 'ENOENT') { log( `Functions folder "${functionsFolder}" specified but it doesn't exist! Will proceed without deploying functions`, ) } // Improve the message of permission errors + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.code === 'EACCES') { error('Permission error when trying to access functions folder') } @@ -187,6 +199,7 @@ const validateFunctionsFolder = async (functionsFolder) => { return stats } +// @ts-expect-error TS(7031) FIXME: Binding element 'deployFolder' implicitly has an '... Remove this comment to see the full error message const validateFolders = async ({ deployFolder, functionsFolder }) => { const deployFolderStat = await validateDeployFolder(deployFolder) const functionsFolderStat = await validateFunctionsFolder(functionsFolder) @@ -199,6 +212,7 @@ const validateFolders = async ({ deployFolder, functionsFolder }) => { * @param {*} config.site * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'deployFolder' implicitly has an '... Remove this comment to see the full error message const getDeployFilesFilter = ({ deployFolder, site }) => { // site.root === deployFolder can happen when users run `netlify deploy --dir .` // in that specific case we don't want to publish the repo node_modules @@ -208,6 +222,7 @@ const getDeployFilesFilter = ({ deployFolder, site }) => { /** * @param {string} filename */ + // @ts-expect-error TS(7006) FIXME: Parameter 'filename' implicitly has an 'any' type. return (filename) => { if (filename == null) { return false @@ -234,6 +249,7 @@ const SEC_TO_MILLISEC = 1e3 // 100 bytes const SYNC_FILE_LIMIT = 1e2 +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const prepareProductionDeploy = async ({ api, siteData }) => { if (isObject(siteData.published_deploy) && siteData.published_deploy.locked) { log(`\n${NETLIFYDEVERR} Deployments are "locked" for production context of this site\n`) @@ -252,6 +268,7 @@ const prepareProductionDeploy = async ({ api, siteData }) => { log('Deploying to main site URL...') } +// @ts-expect-error TS(7006) FIXME: Parameter 'actual' implicitly has an 'any' type. const hasErrorMessage = (actual, expected) => { if (typeof actual === 'string') { return actual.includes(expected) @@ -259,6 +276,7 @@ const hasErrorMessage = (actual, expected) => { return false } +// @ts-expect-error TS(7031) FIXME: Binding element 'error_' implicitly has an 'any' t... Remove this comment to see the full error message const reportDeployError = ({ error_, failAndExit }) => { switch (true) { case error_.name === 'JSONHTTPError': { @@ -294,15 +312,18 @@ const deployProgressCb = function () { * @type {Record} */ const events = {} + // @ts-expect-error TS(7006) FIXME: Parameter 'event' implicitly has an 'any' type. return (event) => { switch (event.phase) { case 'start': { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message events[event.type] = startSpinner({ text: event.msg, }) return } case 'progress': { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message const spinner = events[event.type] if (spinner) { spinner.text = event.msg @@ -310,12 +331,16 @@ const deployProgressCb = function () { return } case 'error': + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message stopSpinner({ error: true, spinner: events[event.type], text: event.msg }) + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message delete events[event.type] return case 'stop': default: { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ spinner: any; text: any; }' is... Remove this comment to see the full error message stopSpinner({ spinner: events[event.type], text: event.msg }) + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message delete events[event.type] } } @@ -323,21 +348,37 @@ const deployProgressCb = function () { } const runDeploy = async ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'alias' implicitly has an 'any' ty... Remove this comment to see the full error message alias, + // @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message api, + // @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message command, + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message config, + // @ts-expect-error TS(7031) FIXME: Binding element 'deployFolder' implicitly has an '... Remove this comment to see the full error message deployFolder, + // @ts-expect-error TS(7031) FIXME: Binding element 'deployTimeout' implicitly has an ... Remove this comment to see the full error message deployTimeout, + // @ts-expect-error TS(7031) FIXME: Binding element 'deployToProduction' implicitly ha... Remove this comment to see the full error message deployToProduction, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionsConfig' implicitly has a... Remove this comment to see the full error message functionsConfig, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionsFolder' implicitly has a... Remove this comment to see the full error message functionsFolder, + // @ts-expect-error TS(7031) FIXME: Binding element 'packagePath' implicitly has an 'a... Remove this comment to see the full error message packagePath, + // @ts-expect-error TS(7031) FIXME: Binding element 'silent' implicitly has an 'any' t... Remove this comment to see the full error message silent, + // @ts-expect-error TS(7031) FIXME: Binding element 'site' implicitly has an 'any' typ... Remove this comment to see the full error message site, + // @ts-expect-error TS(7031) FIXME: Binding element 'siteData' implicitly has an 'any'... Remove this comment to see the full error message siteData, + // @ts-expect-error TS(7031) FIXME: Binding element 'siteId' implicitly has an 'any' t... Remove this comment to see the full error message siteId, + // @ts-expect-error TS(7031) FIXME: Binding element 'skipFunctionsCache' implicitly ha... Remove this comment to see the full error message skipFunctionsCache, + // @ts-expect-error TS(7031) FIXME: Binding element 'title' implicitly has an 'any' ty... Remove this comment to see the full error message title, }) => { let results @@ -354,6 +395,7 @@ const runDeploy = async ({ results = await api.createSiteDeploy({ siteId, title, body: { draft, branch: alias } }) deployId = results.id + // @ts-expect-error TS(2345) FIXME: Argument of type '{ base: any; packagePath: any; }... Remove this comment to see the full error message const internalFunctionsFolder = await getInternalFunctionsDir({ base: site.root, packagePath }) // The order of the directories matter: zip-it-and-ship-it will prioritize @@ -375,18 +417,19 @@ const runDeploy = async ({ const { headers } = await parseAllHeaders({ configHeaders: config.headers, - // @ts-ignore + // @ts-expect-error TS(2322) FIXME: Type 'string' is not assignable to type 'never'. headersFiles: [headersPath], minimal: true, }) config.headers = headers - // @ts-ignore results = await deploySite(api, siteId, deployFolder, { config, + // @ts-expect-error TS(2322) FIXME: Type 'any[]' is not assignable to type 'never[]'. fnDir: functionDirectories, functionsConfig, + // @ts-expect-error TS(2322) FIXME: Type '(event: any) => void' is not assignable to t... Remove this comment to see the full error message statusCb: silent ? () => {} : deployProgressCb(), deployTimeout, syncFileLimit: SYNC_FILE_LIMIT, @@ -436,10 +479,12 @@ const runDeploy = async ({ * @param {import('commander').OptionValues} config.options The options of the command * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'cachedConfig' implicitly has an '... Remove this comment to see the full error message const handleBuild = async ({ cachedConfig, currentDir, deployHandler, options, packagePath }) => { if (!options.build) { return {} } + // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. const [token] = await getToken() const resolvedOptions = await getBuildOptions({ cachedConfig, @@ -462,6 +507,7 @@ const handleBuild = async ({ cachedConfig, currentDir, deployHandler, options, p * @param {import('..//base-command.mjs').default} command * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const bundleEdgeFunctions = async (options, command) => { // eslint-disable-next-line n/prefer-global/process, unicorn/prefer-set-has const argv = process.argv.slice(2) @@ -509,6 +555,7 @@ const bundleEdgeFunctions = async (options, command) => { * @param {object} config.results * @returns {void} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'deployToProduction' implicitly ha... Remove this comment to see the full error message const printResults = ({ deployToProduction, isIntegrationDeploy, json, results, runBuildCommand }) => { const msgData = { 'Build logs': results.logsUrl, @@ -516,9 +563,12 @@ const printResults = ({ deployToProduction, isIntegrationDeploy, json, results, } if (deployToProduction) { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message msgData['Unique deploy URL'] = results.deployUrl + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message msgData['Website URL'] = results.siteUrl } else { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message msgData['Website draft URL'] = results.deployUrl } @@ -536,9 +586,11 @@ const printResults = ({ deployToProduction, isIntegrationDeploy, json, results, logs: results.logsUrl, } if (deployToProduction) { + // @ts-expect-error TS(2339) FIXME: Property 'url' does not exist on type '{ name: any... Remove this comment to see the full error message jsonData.url = results.siteUrl } + // @ts-expect-error TS(2345) FIXME: Argument of type '{ name: any; site_id: any; site_... Remove this comment to see the full error message logJson(jsonData) exit(0) } else { @@ -558,14 +610,23 @@ const printResults = ({ deployToProduction, isIntegrationDeploy, json, results, } const prepAndRunDeploy = async ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message api, + // @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message command, + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message config, + // @ts-expect-error TS(7031) FIXME: Binding element 'deployToProduction' implicitly ha... Remove this comment to see the full error message deployToProduction, + // @ts-expect-error TS(7031) FIXME: Binding element 'options' implicitly has an 'any' ... Remove this comment to see the full error message options, + // @ts-expect-error TS(7031) FIXME: Binding element 'site' implicitly has an 'any' typ... Remove this comment to see the full error message site, + // @ts-expect-error TS(7031) FIXME: Binding element 'siteData' implicitly has an 'any'... Remove this comment to see the full error message siteData, + // @ts-expect-error TS(7031) FIXME: Binding element 'siteId' implicitly has an 'any' t... Remove this comment to see the full error message siteId, + // @ts-expect-error TS(7031) FIXME: Binding element 'workingDir' implicitly has an 'an... Remove this comment to see the full error message workingDir, }) => { const alias = options.alias || options.branch @@ -649,6 +710,7 @@ const prepAndRunDeploy = async ({ * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const deploy = async (options, command) => { const { workingDir } = command const { api, site, siteInfo } = command.netlify @@ -671,6 +733,7 @@ export const deploy = async (options, command) => { let siteData = {} if (siteId && !isEmpty(siteInfo)) { siteData = siteInfo + // @ts-expect-error TS(2339) FIXME: Property 'id' does not exist on type '{}'. siteId = siteData.id } else { log("This folder isn't linked to a site yet") @@ -689,11 +752,14 @@ export const deploy = async (options, command) => { ]) // create site or search for one if (initChoice === NEW_SITE) { + // @ts-expect-error TS(2322) FIXME: Type 'undefined' is not assignable to type '{}'. siteData = await sitesCreate({}, command) + // @ts-expect-error TS(2339) FIXME: Property 'id' does not exist on type '{}'. site.id = siteData.id siteId = site.id } else if (initChoice === EXISTING_SITE) { siteData = await link({}, command) + // @ts-expect-error TS(2339) FIXME: Property 'id' does not exist on type '{}'. site.id = siteData.id siteId = site.id } @@ -703,6 +769,7 @@ export const deploy = async (options, command) => { return triggerDeploy({ api, options, siteData, siteId }) } + // @ts-expect-error TS(2339) FIXME: Property 'published_deploy' does not exist on type... Remove this comment to see the full error message const deployToProduction = options.prod || (options.prodIfUnlocked && !siteData.published_deploy.locked) let results = {} @@ -713,6 +780,7 @@ export const deploy = async (options, command) => { cachedConfig: command.netlify.cachedConfig, currentDir: command.workingDir, options, + // @ts-expect-error TS(7031) FIXME: Binding element 'netlifyConfig' implicitly has an ... Remove this comment to see the full error message deployHandler: async ({ netlifyConfig }) => { results = await prepAndRunDeploy({ command, @@ -753,7 +821,9 @@ export const deploy = async (options, command) => { }) if (options.open) { + // @ts-expect-error TS(2339) FIXME: Property 'siteUrl' does not exist on type '{}'. const urlToOpen = deployToProduction ? results.siteUrl : results.deployUrl + // @ts-expect-error TS(2345) FIXME: Argument of type '{ url: any; }' is not assignable... Remove this comment to see the full error message await openBrowser({ url: urlToOpen }) exit() } @@ -764,6 +834,7 @@ export const deploy = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createDeployCommand = (program) => program .command('deploy') @@ -862,6 +933,7 @@ Support for package.json's main field, and intrinsic index.js entrypoints are co .option('-a, --auth ', 'Netlify auth token to deploy with', env.NETLIFY_AUTH_TOKEN) .option('-s, --site ', 'A site name or ID to deploy to', env.NETLIFY_SITE_ID) .option('--json', 'Output deployment data as JSON') + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. .option('--timeout ', 'Timeout to wait for deployment to finish', (value) => Number.parseInt(value)) .option('--trigger', 'Trigger a new build of your site on Netlify without uploading local files') .option('--build', 'Run build command before deploying') diff --git a/src/commands/deploy/index.mjs b/src/commands/deploy/index.mts similarity index 100% rename from src/commands/deploy/index.mjs rename to src/commands/deploy/index.mts diff --git a/src/commands/dev/dev-exec.mjs b/src/commands/dev/dev-exec.mts similarity index 90% rename from src/commands/dev/dev-exec.mjs rename to src/commands/dev/dev-exec.mts index a63e7f0ca86..14b333e9325 100644 --- a/src/commands/dev/dev-exec.mjs +++ b/src/commands/dev/dev-exec.mts @@ -8,6 +8,7 @@ import { getEnvelopeEnv, normalizeContext } from '../../utils/env/index.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'cmd' implicitly has an 'any' type. const devExec = async (cmd, options, command) => { const { api, cachedConfig, config, site, siteInfo } = command.netlify @@ -29,6 +30,7 @@ const devExec = async (cmd, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createDevExecCommand = (program) => program .command('dev:exec') diff --git a/src/commands/dev/dev.mjs b/src/commands/dev/dev.mts similarity index 94% rename from src/commands/dev/dev.mjs rename to src/commands/dev/dev.mts index ed34a4b9054..a06670bf808 100644 --- a/src/commands/dev/dev.mjs +++ b/src/commands/dev/dev.mts @@ -1,4 +1,4 @@ -// @ts-check + import process from 'process' import { Option } from 'commander' @@ -40,6 +40,7 @@ import { createDevExecCommand } from './dev-exec.mjs' * @param {*} config.state * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const handleLiveTunnel = async ({ api, options, settings, site, state }) => { const { live } = options @@ -71,6 +72,7 @@ const handleLiveTunnel = async ({ api, options, settings, site, state }) => { /** * @param {string} args */ +// @ts-expect-error TS(7006) FIXME: Parameter 'args' implicitly has an 'any' type. const validateShortFlagArgs = (args) => { if (args.startsWith('=')) { throw new Error( @@ -92,6 +94,7 @@ const validateShortFlagArgs = (args) => { * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const dev = async (options, command) => { log(`${NETLIFYDEV}`) const { api, cachedConfig, config, repositoryRoot, site, siteInfo, state } = command.netlify @@ -242,6 +245,7 @@ const dev = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createDevCommand = (program) => { createDevExecCommand(program) @@ -257,6 +261,7 @@ export const createDevCommand = (program) => { 'Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")', normalizeContext, ) + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. .option('-p ,--port ', 'port of netlify dev', (value) => Number.parseInt(value)) .addOption( new Option('--targetPort ', 'Old, prefer --target-port. Port of target app server') @@ -264,6 +269,7 @@ export const createDevCommand = (program) => { .hideHelp(true), ) .addOption(new Option('--no-open', 'disables the automatic opening of a browser window')) + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. .option('--target-port ', 'port of target app server', (value) => Number.parseInt(value)) .option('--framework ', 'framework to use. Defaults to #auto which automatically detects a framework') .option('-d ,--dir ', 'dir with static files') @@ -279,6 +285,7 @@ export const createDevCommand = (program) => { .argParser((value) => Number.parseInt(value)) .hideHelp(true), ) + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. .option('--functions-port ', 'port of functions server', (value) => Number.parseInt(value)) .addOption( new Option( diff --git a/src/commands/dev/index.mjs b/src/commands/dev/index.mts similarity index 100% rename from src/commands/dev/index.mjs rename to src/commands/dev/index.mts diff --git a/src/commands/env/env-clone.mjs b/src/commands/env/env-clone.mts similarity index 79% rename from src/commands/env/env-clone.mjs rename to src/commands/env/env-clone.mts index bba9a29d34c..74b475f11fc 100644 --- a/src/commands/env/env-clone.mjs +++ b/src/commands/env/env-clone.mts @@ -1,7 +1,8 @@ -// @ts-check + import { chalk, error as logError, log } from '../../utils/command-helpers.mjs' import { translateFromEnvelopeToMongo, translateFromMongoToEnvelope } from '../../utils/env/index.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'api' implicitly has an 'any' type. const safeGetSite = async (api, siteId) => { try { const data = await api.getSite({ siteId }) @@ -19,6 +20,7 @@ const safeGetSite = async (api, siteId) => { * @param {import('../base-command.mjs').default} command * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const envClone = async (options, command) => { const { api, site } = command.netlify @@ -75,6 +77,7 @@ const envClone = async (options, command) => { * Copies the env from a site not configured with Envelope to a different site not configured with Envelope * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const mongoToMongo = async ({ api, siteFrom, siteTo }) => { const [ { @@ -113,6 +116,7 @@ const mongoToMongo = async ({ api, siteFrom, siteTo }) => { * Copies the env from a site not configured with Envelope to a site configured with Envelope * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const mongoToEnvelope = async ({ api, siteFrom, siteTo }) => { const envFrom = siteFrom.build_settings.env || {} const keysFrom = Object.keys(envFrom) @@ -127,8 +131,10 @@ const mongoToEnvelope = async ({ api, siteFrom, siteTo }) => { const envelopeTo = await api.getEnvVars({ accountId, siteId }) + // @ts-expect-error TS(7031) FIXME: Binding element 'key' implicitly has an 'any' type... Remove this comment to see the full error message const envVarsToDelete = envelopeTo.filter(({ key }) => keysFrom.includes(key)) // delete marked env vars in parallel + // @ts-expect-error TS(7031) FIXME: Binding element 'key' implicitly has an 'any' type... Remove this comment to see the full error message await Promise.all(envVarsToDelete.map(({ key }) => api.deleteEnvVar({ accountId, siteId, key }))) // hit create endpoint @@ -136,6 +142,7 @@ const mongoToEnvelope = async ({ api, siteFrom, siteTo }) => { try { await api.createEnvVars({ accountId, siteId, body }) } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. throw error.json ? error.json.msg : error } @@ -146,6 +153,7 @@ const mongoToEnvelope = async ({ api, siteFrom, siteTo }) => { * Copies the env from a site configured with Envelope to a site not configured with Envelope * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const envelopeToMongo = async ({ api, siteFrom, siteTo }) => { const envelopeVariables = await api.getEnvVars({ accountId: siteFrom.account_slug, siteId: siteFrom.id }) const envFrom = translateFromEnvelopeToMongo(envelopeVariables) @@ -180,12 +188,14 @@ const envelopeToMongo = async ({ api, siteFrom, siteTo }) => { * Copies the env from a site configured with Envelope to a different site configured with Envelope * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const envelopeToEnvelope = async ({ api, siteFrom, siteTo }) => { const [envelopeFrom, envelopeTo] = await Promise.all([ api.getEnvVars({ accountId: siteFrom.account_slug, siteId: siteFrom.id }), api.getEnvVars({ accountId: siteTo.account_slug, siteId: siteTo.id }), ]) + // @ts-expect-error TS(7031) FIXME: Binding element 'key' implicitly has an 'any' type... Remove this comment to see the full error message const keysFrom = envelopeFrom.map(({ key }) => key) if (keysFrom.length === 0) { @@ -195,14 +205,17 @@ const envelopeToEnvelope = async ({ api, siteFrom, siteTo }) => { const accountId = siteTo.account_slug const siteId = siteTo.id + // @ts-expect-error TS(7031) FIXME: Binding element 'key' implicitly has an 'any' type... Remove this comment to see the full error message const envVarsToDelete = envelopeTo.filter(({ key }) => keysFrom.includes(key)) // delete marked env vars in parallel + // @ts-expect-error TS(7031) FIXME: Binding element 'key' implicitly has an 'any' type... Remove this comment to see the full error message await Promise.all(envVarsToDelete.map(({ key }) => api.deleteEnvVar({ accountId, siteId, key }))) // hit create endpoint try { await api.createEnvVars({ accountId, siteId, body: envelopeFrom }) } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. throw error.json ? error.json.msg : error } @@ -214,6 +227,7 @@ const envelopeToEnvelope = async ({ api, siteFrom, siteTo }) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createEnvCloneCommand = (program) => program .command('env:clone') diff --git a/src/commands/env/env-get.mjs b/src/commands/env/env-get.mts similarity index 87% rename from src/commands/env/env-get.mjs rename to src/commands/env/env-get.mts index f835e4439bd..644bc052bb1 100644 --- a/src/commands/env/env-get.mjs +++ b/src/commands/env/env-get.mts @@ -1,4 +1,4 @@ -// @ts-check + import { Option } from 'commander' import { chalk, error, log, logJson } from '../../utils/command-helpers.mjs' @@ -10,6 +10,7 @@ import { AVAILABLE_CONTEXTS, getEnvelopeEnv, normalizeContext } from '../../util * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. const envGet = async (name, options, command) => { const { context, scope } = options const { api, cachedConfig, site } = command.netlify @@ -38,6 +39,7 @@ const envGet = async (name, options, command) => { // Return json response for piping commands if (options.json) { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ [x: number]: any; }' is not as... Remove this comment to see the full error message logJson(value ? { [name]: value } : {}) return false } @@ -58,6 +60,7 @@ const envGet = async (name, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createEnvGetCommand = (program) => program .command('env:get') @@ -80,6 +83,7 @@ export const createEnvGetCommand = (program) => 'netlify env:get MY_VAR --scope functions', ]) .description('Get resolved value of specified environment variable (includes netlify.toml)') + // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. .action(async (name, options, command) => { await envGet(name, options, command) }) diff --git a/src/commands/env/env-import.mjs b/src/commands/env/env-import.mts similarity index 78% rename from src/commands/env/env-import.mjs rename to src/commands/env/env-import.mts index 4c5e7866fa7..5263afc3d9c 100644 --- a/src/commands/env/env-import.mjs +++ b/src/commands/env/env-import.mts @@ -1,6 +1,7 @@ -// @ts-check + import { readFile } from 'fs/promises' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'asci... Remove this comment to see the full error message import AsciiTable from 'ascii-table' import { Option } from 'commander' import dotenv from 'dotenv' @@ -15,6 +16,7 @@ import { translateFromEnvelopeToMongo, translateFromMongoToEnvelope } from '../. * @param {import('../base-command.mjs').default} command * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'fileName' implicitly has an 'any' type. const envImport = async (fileName, options, command) => { const { api, cachedConfig, site } = command.netlify const siteId = site.id @@ -29,6 +31,7 @@ const envImport = async (fileName, options, command) => { const envFileContents = await readFile(fileName, 'utf-8') importedEnv = dotenv.parse(envFileContents) } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. log(error.message) exit(1) } @@ -62,6 +65,7 @@ const envImport = async (fileName, options, command) => { * Updates the imported env in the site record * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const importIntoMongo = async ({ api, importedEnv, options, siteInfo }) => { const { env = {} } = siteInfo.build_settings const siteId = siteInfo.id @@ -87,20 +91,24 @@ const importIntoMongo = async ({ api, importedEnv, options, siteInfo }) => { * Saves the imported env in the Envelope service * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const importIntoEnvelope = async ({ api, importedEnv, options, siteInfo }) => { // fetch env vars const accountId = siteInfo.account_slug const siteId = siteInfo.id const dotEnvKeys = Object.keys(importedEnv) const envelopeVariables = await api.getEnvVars({ accountId, siteId }) + // @ts-expect-error TS(7031) FIXME: Binding element 'key' implicitly has an 'any' type... Remove this comment to see the full error message const envelopeKeys = envelopeVariables.map(({ key }) => key) // if user intends to replace all existing env vars // either replace; delete all existing env vars on the site // or, merge; delete only the existing env vars that would collide with new .env entries + // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. const keysToDelete = options.replaceExisting ? envelopeKeys : envelopeKeys.filter((key) => dotEnvKeys.includes(key)) // delete marked env vars in parallel + // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. await Promise.all(keysToDelete.map((key) => api.deleteEnvVar({ accountId, siteId, key }))) // hit create endpoint @@ -108,11 +116,13 @@ const importIntoEnvelope = async ({ api, importedEnv, options, siteInfo }) => { try { await api.createEnvVars({ accountId, siteId, body }) } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. throw error.json ? error.json.msg : error } // return final env to aid in --json output (for testing) return { + // @ts-expect-error TS(7031) FIXME: Binding element 'key' implicitly has an 'any' type... Remove this comment to see the full error message ...translateFromEnvelopeToMongo(envelopeVariables.filter(({ key }) => !keysToDelete.includes(key))), ...importedEnv, } @@ -123,6 +133,7 @@ const importIntoEnvelope = async ({ api, importedEnv, options, siteInfo }) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createEnvImportCommand = (program) => program .command('env:import') @@ -141,6 +152,7 @@ export const createEnvImportCommand = (program) => false, ) .description('Import and set environment variables from .env file') + // @ts-expect-error TS(7006) FIXME: Parameter 'fileName' implicitly has an 'any' type. .action(async (fileName, options, command) => { await envImport(fileName, options, command) }) diff --git a/src/commands/env/env-list.mjs b/src/commands/env/env-list.mts similarity index 83% rename from src/commands/env/env-list.mjs rename to src/commands/env/env-list.mts index 0187fb2b7a5..45196e12ff5 100644 --- a/src/commands/env/env-list.mjs +++ b/src/commands/env/env-list.mts @@ -1,5 +1,6 @@ -// @ts-check + import ansiEscapes from 'ansi-escapes' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'asci... Remove this comment to see the full error message import AsciiTable from 'ascii-table' import { isCI } from 'ci-info' import { Option } from 'commander' @@ -12,6 +13,7 @@ import { AVAILABLE_CONTEXTS, getEnvelopeEnv, getHumanReadableScopes, normalizeCo const MASK_LENGTH = 50 const MASK = '*'.repeat(MASK_LENGTH) +// @ts-expect-error TS(7031) FIXME: Binding element 'environment' implicitly has an 'a... Remove this comment to see the full error message const getTable = ({ environment, hideValues, scopesColumn }) => { const table = new AsciiTable(`Environment variables`) const headings = ['Key', 'Value', scopesColumn && 'Scope'].filter(Boolean) @@ -22,8 +24,10 @@ const getTable = ({ environment, hideValues, scopesColumn }) => { // Key key, // Value + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. hideValues ? MASK : variable.value || ' ', // Scope + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. scopesColumn && getHumanReadableScopes(variable.scopes), ].filter(Boolean), ), @@ -37,6 +41,7 @@ const getTable = ({ environment, hideValues, scopesColumn }) => { * @param {import('../base-command.mjs').default} command * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const envList = async (options, command) => { const { context, scope } = options const { api, cachedConfig, site } = command.netlify @@ -64,20 +69,24 @@ const envList = async (options, command) => { // filter out general sources environment = Object.fromEntries( + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. Object.entries(environment).filter(([, variable]) => variable.sources[0] !== 'general'), ) // Return json response for piping commands if (options.json) { const envDictionary = Object.fromEntries( + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. Object.entries(environment).map(([key, variable]) => [key, variable.value]), ) + // @ts-expect-error TS(2345) FIXME: Argument of type '{ [k: string]: any; }' is not as... Remove this comment to see the full error message logJson(envDictionary) return false } if (options.plain) { const plaintext = Object.entries(environment) + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. .map(([key, variable]) => `${key}=${variable.value}`) .join('\n') log(plaintext) @@ -125,6 +134,7 @@ const envList = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createEnvListCommand = (program) => program .command('env:list') @@ -149,6 +159,7 @@ export const createEnvListCommand = (program) => 'netlify env:list --plain', ]) .description('Lists resolved environment variables for site (includes netlify.toml)') + // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. .action(async (options, command) => { await envList(options, command) }) diff --git a/src/commands/env/env-set.mjs b/src/commands/env/env-set.mts similarity index 82% rename from src/commands/env/env-set.mjs rename to src/commands/env/env-set.mts index f6d214f4196..7b2bc0878a5 100644 --- a/src/commands/env/env-set.mjs +++ b/src/commands/env/env-set.mts @@ -1,4 +1,4 @@ -// @ts-check + import { Option } from 'commander' import { chalk, error, log, logJson } from '../../utils/command-helpers.mjs' @@ -17,6 +17,7 @@ import { * @param {import('../base-command.mjs').default} command * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. const envSet = async (key, value, options, command) => { const { context, scope, secret } = options @@ -69,6 +70,7 @@ const envSet = async (key, value, options, command) => { * Updates the env for a site record with a new key/value pair * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const setInMongo = async ({ api, key, siteInfo, value }) => { const { env = {} } = siteInfo.build_settings const newEnv = { @@ -91,11 +93,13 @@ const setInMongo = async ({ api, key, siteInfo, value }) => { * Updates the env for a site configured with Envelope with a new key/value pair * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const setInEnvelope = async ({ api, context, key, scope, secret, siteInfo, value }) => { const accountId = siteInfo.account_slug const siteId = siteInfo.id // secret values may not be used in the post-processing scope + // @ts-expect-error TS(7006) FIXME: Parameter 'sco' implicitly has an 'any' type. if (secret && scope && scope.some((sco) => /post[-_]processing/.test(sco))) { error(`Secret values cannot be used within the post-processing scope.`) return false @@ -116,14 +120,17 @@ const setInEnvelope = async ({ api, context, key, scope, secret, siteInfo, value if (secret) { // post_processing (aka post-processing) scope is not allowed with secrets + // @ts-expect-error TS(7006) FIXME: Parameter 'sco' implicitly has an 'any' type. scopes = scopes.filter((sco) => !/post[-_]processing/.test(sco)) } // if the passed context is unknown, it is actually a branch name + // @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. let values = contexts.map((ctx) => AVAILABLE_CONTEXTS.includes(ctx) ? { context: ctx, value } : { context: 'branch', context_parameter: ctx, value }, ) + // @ts-expect-error TS(7006) FIXME: Parameter 'envVar' implicitly has an 'any' type. const existing = envelopeVariables.find((envVar) => envVar.key === key) const params = { accountId, siteId, key } @@ -145,17 +152,21 @@ const setInEnvelope = async ({ api, context, key, scope, secret, siteInfo, value } if (context) { // update individual value(s) + // @ts-expect-error TS(7006) FIXME: Parameter 'val' implicitly has an 'any' type. await Promise.all(values.map((val) => api.setEnvVarValue({ ...params, body: val }))) } else { // otherwise update whole env var if (secret) { + // @ts-expect-error TS(7006) FIXME: Parameter 'sco' implicitly has an 'any' type. scopes = scopes.filter((sco) => !/post[-_]processing/.test(sco)) + // @ts-expect-error TS(7006) FIXME: Parameter 'val' implicitly has an 'any' type. if (values.some((val) => val.context === 'all')) { log(`This secret's value will be empty in the dev context.`) log(`Run \`netlify env:set ${key} --context dev\` to set a new value for the dev context.`) values = AVAILABLE_CONTEXTS.filter((ctx) => ctx !== 'all').map((ctx) => ({ context: ctx, // empty out dev value so that secret is indeed secret + // @ts-expect-error TS(7006) FIXME: Parameter 'val' implicitly has an 'any' type. value: ctx === 'dev' ? '' : values.find((val) => val.context === 'all').value, })) } @@ -169,12 +180,14 @@ const setInEnvelope = async ({ api, context, key, scope, secret, siteInfo, value await api.createEnvVars({ ...params, body }) } } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. throw error_.json ? error_.json.msg : error_ } const env = translateFromEnvelopeToMongo(envelopeVariables, context ? context[0] : 'dev') return { ...env, + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message [key]: value || env[key], } } @@ -184,6 +197,7 @@ const setInEnvelope = async ({ api, context, key, scope, secret, siteInfo, value * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createEnvSetCommand = (program) => program .command('env:set') @@ -193,6 +207,7 @@ export const createEnvSetCommand = (program) => '-c, --context ', 'Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev") (default: all contexts)', // spread over an array for variadic options + // @ts-expect-error TS(7006) FIXME: Parameter 'context' implicitly has an 'any' type. (context, previous = []) => [...previous, normalizeContext(context)], ) .addOption( @@ -214,6 +229,7 @@ export const createEnvSetCommand = (program) => 'netlify env:set VAR_NAME value --scope builds functions', 'netlify env:set VAR_NAME --secret # convert existing variable to secret', ]) + // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. .action(async (key, value, options, command) => { await envSet(key, value, options, command) }) diff --git a/src/commands/env/env-unset.mjs b/src/commands/env/env-unset.mts similarity index 81% rename from src/commands/env/env-unset.mjs rename to src/commands/env/env-unset.mts index 665f71a52f5..c5ab1f41671 100644 --- a/src/commands/env/env-unset.mjs +++ b/src/commands/env/env-unset.mts @@ -1,4 +1,4 @@ -// @ts-check + import { chalk, error, log, logJson } from '../../utils/command-helpers.mjs' import { AVAILABLE_CONTEXTS, normalizeContext, translateFromEnvelopeToMongo } from '../../utils/env/index.mjs' @@ -9,6 +9,7 @@ import { AVAILABLE_CONTEXTS, normalizeContext, translateFromEnvelopeToMongo } fr * @param {import('../base-command.mjs').default} command * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. const envUnset = async (key, options, command) => { const { context } = options const { api, cachedConfig, site } = command.netlify @@ -49,6 +50,7 @@ const envUnset = async (key, options, command) => { * Deletes a given key from the env of a site record * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const unsetInMongo = async ({ api, key, siteInfo }) => { // Get current environment variables set in the UI const { @@ -77,6 +79,7 @@ const unsetInMongo = async ({ api, key, siteInfo }) => { * Deletes a given key from the env of a site configured with Envelope * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const unsetInEnvelope = async ({ api, context, key, siteInfo }) => { const accountId = siteInfo.account_slug const siteId = siteInfo.id @@ -87,6 +90,7 @@ const unsetInEnvelope = async ({ api, context, key, siteInfo }) => { const env = translateFromEnvelopeToMongo(envelopeVariables, context ? context[0] : 'dev') // check if the given key exists + // @ts-expect-error TS(7006) FIXME: Parameter 'envVar' implicitly has an 'any' type. const variable = envelopeVariables.find((envVar) => envVar.key === key) if (!variable) { // if not, no need to call delete; return early @@ -97,10 +101,12 @@ const unsetInEnvelope = async ({ api, context, key, siteInfo }) => { try { if (context) { // if context(s) are passed, delete the matching contexts / branches, and the `all` context + // @ts-expect-error TS(7006) FIXME: Parameter 'val' implicitly has an 'any' type. const values = variable.values.filter((val) => [...contexts, 'all'].includes(val.context_parameter || val.context), ) if (values) { + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. await Promise.all(values.map((value) => api.deleteEnvVarValue({ ...params, id: value.id }))) // if this was the `all` context, we need to create 3 values in the other contexts if (values.length === 1 && values[0].context === 'all') { @@ -118,9 +124,11 @@ const unsetInEnvelope = async ({ api, context, key, siteInfo }) => { await api.deleteEnvVar({ accountId, siteId, key }) } } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. throw error_.json ? error_.json.msg : error_ } + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message delete env[key] return env @@ -131,6 +139,7 @@ const unsetInEnvelope = async ({ api, context, key, siteInfo }) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createEnvUnsetCommand = (program) => program .command('env:unset') @@ -140,6 +149,7 @@ export const createEnvUnsetCommand = (program) => '-c, --context ', 'Specify a deploy context or branch (contexts: "production", "deploy-preview", "branch-deploy", "dev") (default: all contexts)', // spread over an array for variadic options + // @ts-expect-error TS(7006) FIXME: Parameter 'context' implicitly has an 'any' type. (context, previous = []) => [...previous, normalizeContext(context)], ) .addExamples([ @@ -148,6 +158,7 @@ export const createEnvUnsetCommand = (program) => 'netlify env:unset VAR_NAME --context production deploy-preview', ]) .description('Unset an environment variable which removes it from the UI') + // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. .action(async (key, options, command) => { await envUnset(key, options, command) }) diff --git a/src/commands/env/env.mjs b/src/commands/env/env.mts similarity index 87% rename from src/commands/env/env.mjs rename to src/commands/env/env.mts index 8e0609c83b8..d89e6c687b5 100644 --- a/src/commands/env/env.mjs +++ b/src/commands/env/env.mts @@ -1,4 +1,4 @@ -// @ts-check + import { createEnvCloneCommand } from './env-clone.mjs' import { createEnvGetCommand } from './env-get.mjs' import { createEnvImportCommand } from './env-import.mjs' @@ -11,6 +11,7 @@ import { createEnvUnsetCommand } from './env-unset.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const env = (options, command) => { command.help() } @@ -20,6 +21,7 @@ const env = (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createEnvCommand = (program) => { createEnvGetCommand(program) createEnvImportCommand(program) diff --git a/src/commands/env/index.mjs b/src/commands/env/index.mts similarity index 100% rename from src/commands/env/index.mjs rename to src/commands/env/index.mts diff --git a/src/commands/functions/functions-build.mjs b/src/commands/functions/functions-build.mts similarity index 82% rename from src/commands/functions/functions-build.mjs rename to src/commands/functions/functions-build.mts index 648eb2f0be0..1ee96b123a8 100644 --- a/src/commands/functions/functions-build.mjs +++ b/src/commands/functions/functions-build.mts @@ -1,4 +1,4 @@ -// @ts-check + import { mkdir } from 'fs/promises' import { zipFunctions } from '@netlify/zip-it-and-ship-it' @@ -11,10 +11,12 @@ import { getFunctionsDir } from '../../utils/functions/index.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const functionsBuild = async (options, command) => { const { config } = command.netlify const src = options.src || config.build.functionsSource + // @ts-expect-error TS(2554) FIXME: Expected 2 arguments, but got 1. const dst = getFunctionsDir({ options, config }) if (src === dst) { @@ -38,6 +40,7 @@ const functionsBuild = async (options, command) => { log(`${NETLIFYDEVLOG} Building functions`) + // @ts-expect-error TS(2345) FIXME: Argument of type '{ skipGo: boolean; }' is not ass... Remove this comment to see the full error message zipFunctions(src, dst, { skipGo: true }) log(`${NETLIFYDEVLOG} Functions built to `, dst) } @@ -47,6 +50,7 @@ const functionsBuild = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createFunctionsBuildCommand = (program) => program .command('functions:build') diff --git a/src/commands/functions/functions-create.mjs b/src/commands/functions/functions-create.mts similarity index 83% rename from src/commands/functions/functions-create.mjs rename to src/commands/functions/functions-create.mts index f0fca7fdbf6..09927b58612 100644 --- a/src/commands/functions/functions-create.mjs +++ b/src/commands/functions/functions-create.mts @@ -1,4 +1,4 @@ -// @ts-check + import cp from 'child_process' import fs from 'fs' import { mkdir, readdir, unlink } from 'fs/promises' @@ -8,10 +8,12 @@ import process from 'process' import { fileURLToPath, pathToFileURL } from 'url' import { promisify } from 'util' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'copy... Remove this comment to see the full error message import copyTemplateDirOriginal from 'copy-template-dir' import { findUp } from 'find-up' import fuzzy from 'fuzzy' import inquirer from 'inquirer' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message import fetch from 'node-fetch' import ora from 'ora' @@ -19,6 +21,7 @@ import { fileExistsAsync } from '../../lib/fs.mjs' import { getAddons, getCurrentAddon, getSiteData } from '../../utils/addons/prepare.mjs' import { NETLIFYDEVERR, NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log } from '../../utils/command-helpers.mjs' import { getDotEnvVariables, injectEnvVariables } from '../../utils/dev.mjs' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../../utils/execa.mjs' import { readRepoURL, validateRepoURL } from '../../utils/read-repo-url.mjs' @@ -48,6 +51,7 @@ const languages = [ * @param {string} [defaultName] * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'argumentName' implicitly has an 'any' t... Remove this comment to see the full error message const getNameFromArgs = async function (argumentName, options, defaultName) { if (options.name) { if (argumentName) { @@ -74,7 +78,9 @@ const getNameFromArgs = async function (argumentName, options, defaultName) { return name } +// @ts-expect-error TS(7006) FIXME: Parameter 'registry' implicitly has an 'any' type. const filterRegistry = function (registry, input) { + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. const temp = registry.map((value) => value.name + value.description) // TODO: remove once https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1394 is fixed // eslint-disable-next-line unicorn/no-array-method-this-argument @@ -83,9 +89,12 @@ const filterRegistry = function (registry, input) { filteredTemplates.map((filteredTemplate) => (input ? filteredTemplate.string : filteredTemplate)), ) return registry + // @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type. .filter((t) => filteredTemplateNames.has(t.name + t.description)) + // @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type. .map((t) => { // add the score + // @ts-expect-error TS(2339) FIXME: Property 'score' does not exist on type 'FilterRes... Remove this comment to see the full error message const { score } = filteredTemplates.find((filteredTemplate) => filteredTemplate.string === t.name + t.description) t.score = score return t @@ -96,6 +105,7 @@ const filterRegistry = function (registry, input) { * @param {string} lang * @param {'edge' | 'serverless'} funcType */ +// @ts-expect-error TS(7006) FIXME: Parameter 'lang' implicitly has an 'any' type. const formatRegistryArrayForInquirer = async function (lang, funcType) { const folders = await readdir(path.join(templatesDir, lang), { withFileTypes: true }) @@ -105,6 +115,7 @@ const formatRegistryArrayForInquirer = async function (lang, funcType) { .map(async ({ name }) => { try { const templatePath = path.join(templatesDir, lang, name, '.netlify-function-template.mjs') + // @ts-expect-error TS(7036) FIXME: Dynamic import's specifier must be of type 'string... Remove this comment to see the full error message const template = await import(pathToFileURL(templatePath)) return template.default } catch { @@ -144,6 +155,7 @@ const formatRegistryArrayForInquirer = async function (lang, funcType) { * @param {import('commander').OptionValues} config * @param {'edge' | 'serverless'} funcType */ +// @ts-expect-error TS(7031) FIXME: Binding element 'languageFromFlag' implicitly has ... Remove this comment to see the full error message const pickTemplate = async function ({ language: languageFromFlag }, funcType) { const specialCommands = [ new inquirer.Separator(), @@ -165,10 +177,12 @@ const pickTemplate = async function ({ language: languageFromFlag }, funcType) { if (language === undefined) { const langs = funcType === 'edge' + // @ts-expect-error TS(2339) FIXME: Property 'value' does not exist on type 'false | {... Remove this comment to see the full error message ? languages.filter((lang) => lang.value === 'javascript' || lang.value === 'typescript') : languages.filter(Boolean) const { language: languageFromPrompt } = await inquirer.prompt({ + // @ts-expect-error choices: langs, message: 'Select the language of your function', name: 'language', @@ -178,6 +192,7 @@ const pickTemplate = async function ({ language: languageFromFlag }, funcType) { language = languageFromPrompt } + // @ts-expect-error TS(7034) FIXME: Variable 'templatesForLanguage' implicitly has typ... Remove this comment to see the full error message let templatesForLanguage try { @@ -189,17 +204,22 @@ const pickTemplate = async function ({ language: languageFromFlag }, funcType) { const { chosenTemplate } = await inquirer.prompt({ name: 'chosenTemplate', message: 'Pick a template', + // @ts-expect-error TS(2769) FIXME: No overload matches this call. type: 'autocomplete', + // @ts-expect-error TS(7006) FIXME: Parameter 'answersSoFar' implicitly has an 'any' t... Remove this comment to see the full error message source(answersSoFar, input) { // if Edge Functions template, don't show url option + // @ts-expect-error TS(2339) FIXME: Property 'value' does not exist on type 'Separator... Remove this comment to see the full error message const edgeCommands = specialCommands.filter((val) => val.value !== 'url') const parsedSpecialCommands = funcType === 'edge' ? edgeCommands : specialCommands if (!input || input === '') { // show separators + // @ts-expect-error TS(7005) FIXME: Variable 'templatesForLanguage' implicitly has an ... Remove this comment to see the full error message return [...templatesForLanguage, ...parsedSpecialCommands] } // only show filtered results sorted by score + // @ts-expect-error TS(7005) FIXME: Variable 'templatesForLanguage' implicitly has an ... Remove this comment to see the full error message const answers = [...filterRegistry(templatesForLanguage, input), ...parsedSpecialCommands].sort( (answerA, answerB) => answerB.score - answerA.score, ) @@ -232,6 +252,7 @@ const selectTypeOfFunc = async () => { /** * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. const ensureEdgeFuncDirExists = function (command) { const { config, site } = command.netlify const siteId = site.id @@ -263,6 +284,7 @@ const ensureEdgeFuncDirExists = function (command) { * @param {import('../base-command.mjs').default} command * @returns {Promise} - functions directory or throws an error */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. const promptFunctionsDirectory = async (command) => { const { api, relConfigFilePath, site } = command.netlify log(`\n${NETLIFYDEVLOG} functions directory not specified in ${relConfigFilePath} or UI settings`) @@ -283,7 +305,6 @@ const promptFunctionsDirectory = async (command) => { try { log(`${NETLIFYDEVLOG} updating site settings with ${chalk.magenta.inverse(functionsDir)}`) - // @ts-ignore Typings of API are not correct await api.updateSite({ siteId: site.id, body: { @@ -305,6 +326,7 @@ const promptFunctionsDirectory = async (command) => { * @param {import('../base-command.mjs').default} command * @returns {Promise} - functions directory or throws an error */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. const ensureFunctionDirExists = async function (command) { const { config } = command.netlify const functionsDirHolder = @@ -333,6 +355,7 @@ const ensureFunctionDirExists = async function (command) { * @param {string} argumentName * @param {string} functionsDir */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. const downloadFromURL = async function (command, options, argumentName, functionsDir) { const folderContents = await readRepoURL(options.url) const [functionName] = options.url.split('/').slice(-1) @@ -352,6 +375,7 @@ const downloadFromURL = async function (command, options, argumentName, function // Ignore } await Promise.all( + // @ts-expect-error TS(7031) FIXME: Binding element 'downloadUrl' implicitly has an 'a... Remove this comment to see the full error message folderContents.map(async ({ download_url: downloadUrl, name }) => { try { const res = await fetch(downloadUrl) @@ -391,6 +415,7 @@ const downloadFromURL = async function (command, options, argumentName, function */ const getNpmInstallPackages = (existingPackages = {}, neededPackages = {}) => Object.entries(neededPackages) + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message .filter(([name]) => existingPackages[name] === undefined) .map(([name, version]) => `${name}@${version}`) @@ -401,6 +426,7 @@ const getNpmInstallPackages = (existingPackages = {}, neededPackages = {}) => * we don't do this check, we may be upgrading the version of a module used in * another part of the project, which we don't want to do. */ +// @ts-expect-error TS(7031) FIXME: Binding element 'functionPackageJson' implicitly h... Remove this comment to see the full error message const installDeps = async ({ functionPackageJson, functionPath, functionsDir }) => { const { dependencies: functionDependencies, devDependencies: functionDevDependencies } = require(functionPackageJson) const sitePackageJson = await findUp('package.json', { cwd: functionsDir }) @@ -410,6 +436,7 @@ const installDeps = async ({ functionPackageJson, functionPath, functionsDir }) // of keeping that file in the function directory and running `npm install` // from there. if (!sitePackageJson) { + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. await execa('npm', ['i', ...npmInstallFlags], { cwd: functionPath }) return @@ -421,10 +448,12 @@ const installDeps = async ({ functionPackageJson, functionPath, functionsDir }) const npmInstallPath = path.dirname(sitePackageJson) if (dependencies.length !== 0) { + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. await execa('npm', ['i', ...dependencies, '--save', ...npmInstallFlags], { cwd: npmInstallPath }) } if (devDependencies.length !== 0) { + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. await execa('npm', ['i', ...devDependencies, '--save-dev', ...npmInstallFlags], { cwd: npmInstallPath }) } @@ -450,6 +479,7 @@ const installDeps = async ({ functionPackageJson, functionPath, functionsDir }) * @param {string} functionsDir Absolute path of the functions directory * @param {'edge' | 'serverless'} funcType */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. // eslint-disable-next-line max-params const scaffoldFromTemplate = async function (command, options, argumentName, functionsDir, funcType) { // pull the rest of the metadata from the template @@ -470,6 +500,7 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun await downloadFromURL(command, options, argumentName, functionsDir) } catch (error_) { error(`$${NETLIFYDEVERR} Error downloading from URL: ${options.url}`) + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) process.exit(1) } @@ -496,6 +527,7 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun // be removed before the command finishes. const omittedFromOutput = new Set(['.netlify-function-template.mjs', 'package.json', 'package-lock.json']) const createdFiles = await copyTemplateDir(pathToTemplate, functionPath, vars) + // @ts-expect-error TS(7006) FIXME: Parameter 'filePath' implicitly has an 'any' type. createdFiles.forEach((filePath) => { const filename = path.basename(filePath) @@ -533,6 +565,7 @@ const scaffoldFromTemplate = async function (command, options, argumentName, fun const TEMPLATE_PERMISSIONS = 0o777 +// @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message const createFunctionAddon = async function ({ addonName, addons, api, siteData, siteId }) { try { const addon = getCurrentAddon({ addons, addonName }) @@ -548,6 +581,7 @@ const createFunctionAddon = async function ({ addonName, addons, api, siteData, log(`Add-on "${addonName}" created for ${siteData.name}`) return true } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(error_.message) } } @@ -558,6 +592,7 @@ const createFunctionAddon = async function ({ addonName, addons, api, siteData, * @param {import('../base-command.mjs').default} config.command * @param {(command: import('../base-command.mjs').default) => any} config.onComplete */ +// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message const handleOnComplete = async ({ command, onComplete }) => { const { config } = command.netlify @@ -579,6 +614,7 @@ const handleOnComplete = async ({ command, onComplete }) => { * @param {import('../base-command.mjs').default} config.command * @param {string} config.fnPath */ +// @ts-expect-error TS(7031) FIXME: Binding element 'addonCreated' implicitly has an '... Remove this comment to see the full error message const handleAddonDidInstall = async ({ addonCreated, addonDidInstall, command, fnPath }) => { const { config } = command.netlify @@ -614,6 +650,7 @@ const handleAddonDidInstall = async ({ addonCreated, addonDidInstall, command, f * @param {*} fnPath * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. const installAddons = async function (command, functionAddons, fnPath) { if (functionAddons.length === 0) { return @@ -629,6 +666,7 @@ const installAddons = async function (command, functionAddons, fnPath) { const [siteData, siteAddons] = await Promise.all([getSiteData({ api, siteId }), getAddons({ api, siteId })]) + // @ts-expect-error TS(7031) FIXME: Binding element 'addonDidInstall' implicitly has a... Remove this comment to see the full error message const arr = functionAddons.map(async ({ addonDidInstall, addonName }) => { log(`${NETLIFYDEVLOG} installing addon: ${chalk.yellow.inverse(addonName)}`) try { @@ -642,6 +680,7 @@ const installAddons = async function (command, functionAddons, fnPath) { await handleAddonDidInstall({ addonCreated, addonDidInstall, command, fnPath }) } catch (error_) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(`${NETLIFYDEVERR} Error installing addon: `, error_) } }) @@ -653,6 +692,7 @@ const installAddons = async function (command, functionAddons, fnPath) { * @param {string} funcName * @param {import('../types.js').NetlifyOptions} options */ +// @ts-expect-error TS(7006) FIXME: Parameter 'funcName' implicitly has an 'any' type. const registerEFInToml = async (funcName, options) => { const { configFilePath, relConfigFilePath } = options if (!fs.existsSync(configFilePath)) { @@ -695,6 +735,7 @@ const registerEFInToml = async (funcName, options) => { * @param {string} name * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'functionsDir' implicitly has an 'any' t... Remove this comment to see the full error message const ensureFunctionPathIsOk = function (functionsDir, name) { const functionPath = path.join(functionsDir, name) if (fs.existsSync(functionPath)) { @@ -710,6 +751,7 @@ const ensureFunctionPathIsOk = function (functionsDir, name) { * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. const functionsCreate = async (name, options, command) => { const functionType = await selectTypeOfFunc() const functionsDir = @@ -725,6 +767,7 @@ const functionsCreate = async (name, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createFunctionsCreateCommand = (program) => program .command('functions:create') diff --git a/src/commands/functions/functions-invoke.mjs b/src/commands/functions/functions-invoke.mts similarity index 84% rename from src/commands/functions/functions-invoke.mjs rename to src/commands/functions/functions-invoke.mts index d120d51df27..cd270098b3c 100644 --- a/src/commands/functions/functions-invoke.mjs +++ b/src/commands/functions/functions-invoke.mts @@ -1,9 +1,10 @@ -// @ts-check + import fs from 'fs' import { createRequire } from 'module' import path from 'path' import inquirer from 'inquirer' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message import fetch from 'node-fetch' import { NETLIFYDEVWARN, chalk, error, exit } from '../../utils/command-helpers.mjs' @@ -32,6 +33,7 @@ const eventTriggeredFunctions = new Set([...events, ...events.map((name) => `${n const DEFAULT_PORT = 8888 // https://stackoverflow.com/questions/3710204/how-to-check-if-a-string-is-a-valid-json-string-in-javascript-without-using-try +// @ts-expect-error TS(7006) FIXME: Parameter 'jsonString' implicitly has an 'any' typ... Remove this comment to see the full error message const tryParseJSON = function (jsonString) { try { const parsedValue = JSON.parse(jsonString) @@ -48,6 +50,7 @@ const tryParseJSON = function (jsonString) { return false } +// @ts-expect-error TS(7006) FIXME: Parameter 'querystring' implicitly has an 'any' ty... Remove this comment to see the full error message const formatQstring = function (querystring) { if (querystring) { return `?${querystring}` @@ -60,6 +63,7 @@ const formatQstring = function (querystring) { * @param {string} payloadString * @param {string} workingDir */ +// @ts-expect-error TS(7006) FIXME: Parameter 'payloadString' implicitly has an 'any' ... Remove this comment to see the full error message const processPayloadFromFlag = function (payloadString, workingDir) { if (payloadString) { // case 1: jsonstring @@ -91,8 +95,10 @@ const processPayloadFromFlag = function (payloadString, workingDir) { * @param {string} [argumentName] The name that might be provided as argument (optional argument) * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'functions' implicitly has an 'any' type... Remove this comment to see the full error message const getNameFromArgs = async function (functions, options, argumentName) { const functionToTrigger = getFunctionToTrigger(options, argumentName) + // @ts-expect-error TS(7031) FIXME: Binding element 'name' implicitly has an 'any' typ... Remove this comment to see the full error message const functionNames = functions.map(({ name }) => name) if (functionToTrigger) { @@ -124,6 +130,7 @@ const getNameFromArgs = async function (functions, options, argumentName) { * @param {string} [argumentName] The name that might be provided as argument (optional argument) * @returns {string} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const getFunctionToTrigger = function (options, argumentName) { if (options.name) { if (argumentName) { @@ -143,6 +150,7 @@ const getFunctionToTrigger = function (options, argumentName) { * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'nameArgument' implicitly has an 'any' t... Remove this comment to see the full error message const functionsInvoke = async (nameArgument, options, command) => { const { config, relConfigFilePath } = command.netlify @@ -162,6 +170,7 @@ const functionsInvoke = async (nameArgument, options, command) => { let headers = {} let body = {} + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. if (functionObj.schedule) { headers = { 'user-agent': CLOCKWORK_USERAGENT, @@ -172,7 +181,9 @@ const functionsInvoke = async (nameArgument, options, command) => { const [name, event] = functionToTrigger.split('-') if (name === 'identity') { // https://docs.netlify.com/functions/functions-and-identity/#trigger-functions-on-identity-events + // @ts-expect-error TS(2339) FIXME: Property 'event' does not exist on type '{}'. body.event = event + // @ts-expect-error TS(2339) FIXME: Property 'user' does not exist on type '{}'. body.user = { id: '1111a1a1-a11a-1111-aa11-aaa11111a11a', aud: '', @@ -190,9 +201,11 @@ const functionsInvoke = async (nameArgument, options, command) => { } else { // non identity functions seem to have a different shape // https://docs.netlify.com/functions/trigger-on-events/#payload + // @ts-expect-error TS(2339) FIXME: Property 'payload' does not exist on type '{}'. body.payload = { TODO: 'mock up payload data better', } + // @ts-expect-error TS(2339) FIXME: Property 'site' does not exist on type '{}'. body.site = { TODO: 'mock up site data better', } @@ -228,6 +241,7 @@ const functionsInvoke = async (nameArgument, options, command) => { const data = await response.text() console.log(data) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(`Ran into an error invoking your function: ${error_.message}`) } } @@ -237,6 +251,7 @@ const functionsInvoke = async (nameArgument, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createFunctionsInvokeCommand = (program) => program .command('functions:invoke') @@ -258,6 +273,7 @@ export const createFunctionsInvokeCommand = (program) => '--no-identity', 'simulate Netlify Identity authentication JWT. pass --no-identity to affirm unauthenticated request', ) + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. .option('--port ', 'Port where netlify dev is accessible. e.g. 8888', (value) => Number.parseInt(value)) .addExamples([ 'netlify functions:invoke', diff --git a/src/commands/functions/functions-list.mjs b/src/commands/functions/functions-list.mts similarity index 76% rename from src/commands/functions/functions-list.mjs rename to src/commands/functions/functions-list.mts index 4de34ad3445..2378fe2da4d 100644 --- a/src/commands/functions/functions-list.mjs +++ b/src/commands/functions/functions-list.mts @@ -1,11 +1,14 @@ -// @ts-check + +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'asci... Remove this comment to see the full error message import AsciiTable from 'ascii-table' import { exit, log, logJson } from '../../utils/command-helpers.mjs' import { getFunctions, getFunctionsDir } from '../../utils/functions/index.mjs' import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'deployedFunctions' implicitly has an 'a... Remove this comment to see the full error message const normalizeFunction = function (deployedFunctions, { name, urlPath: url }) { + // @ts-expect-error TS(7006) FIXME: Parameter 'deployedFunction' implicitly has an 'an... Remove this comment to see the full error message const isDeployed = deployedFunctions.some((deployedFunction) => deployedFunction.n === name) return { name, url, isDeployed } } @@ -15,12 +18,14 @@ const normalizeFunction = function (deployedFunctions, { name, urlPath: url }) { * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const functionsList = async (options, command) => { const { config, relConfigFilePath, siteInfo } = command.netlify const deploy = siteInfo.published_deploy || {} const deployedFunctions = deploy.available_functions || [] + // @ts-expect-error TS(2554) FIXME: Expected 2 arguments, but got 1. const functionsDir = getFunctionsDir({ options, config }) if (typeof functionsDir === 'undefined') { @@ -39,6 +44,7 @@ const functionsList = async (options, command) => { } if (options.json) { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ name: any; url: any; isDeploye... Remove this comment to see the full error message logJson(normalizedFunctions) exit() } @@ -58,6 +64,7 @@ const functionsList = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createFunctionsListCommand = (program) => program .command('functions:list') diff --git a/src/commands/functions/functions-serve.mjs b/src/commands/functions/functions-serve.mts similarity index 90% rename from src/commands/functions/functions-serve.mjs rename to src/commands/functions/functions-serve.mts index ecc2d029e49..4c56c9d8aff 100644 --- a/src/commands/functions/functions-serve.mjs +++ b/src/commands/functions/functions-serve.mts @@ -1,4 +1,4 @@ -// @ts-check + import { join } from 'path' import { startFunctionsServer } from '../../lib/functions/server.mjs' @@ -14,6 +14,7 @@ const DEFAULT_PORT = 9999 * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const functionsServe = async (options, command) => { const { api, config, site, siteInfo, state } = command.netlify @@ -67,12 +68,14 @@ const functionsServe = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createFunctionsServeCommand = (program) => program .command('functions:serve') .alias('function:serve') .description('Serve functions locally') .option('-f, --functions ', 'Specify a functions directory to serve') + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. .option('-p, --port ', 'Specify a port for the functions server', (value) => Number.parseInt(value)) .option('-o, --offline', 'disables any features that require network access') .addHelpText('after', 'Helpful for debugging functions.') diff --git a/src/commands/functions/functions.mjs b/src/commands/functions/functions.mts similarity index 89% rename from src/commands/functions/functions.mjs rename to src/commands/functions/functions.mts index 9d40545b4f6..f24daca4a09 100644 --- a/src/commands/functions/functions.mjs +++ b/src/commands/functions/functions.mts @@ -1,4 +1,4 @@ -// @ts-check + import { chalk } from '../../utils/command-helpers.mjs' import { createFunctionsBuildCommand } from './functions-build.mjs' @@ -12,6 +12,7 @@ import { createFunctionsServeCommand } from './functions-serve.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const functions = (options, command) => { command.help() } @@ -21,6 +22,7 @@ const functions = (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createFunctionsCommand = (program) => { createFunctionsBuildCommand(program) createFunctionsCreateCommand(program) diff --git a/src/commands/functions/index.mjs b/src/commands/functions/index.mts similarity index 100% rename from src/commands/functions/index.mjs rename to src/commands/functions/index.mts diff --git a/src/commands/index.mjs b/src/commands/index.mts similarity index 100% rename from src/commands/index.mjs rename to src/commands/index.mts diff --git a/src/commands/init/index.mjs b/src/commands/init/index.mts similarity index 100% rename from src/commands/init/index.mjs rename to src/commands/init/index.mts diff --git a/src/commands/init/init.mjs b/src/commands/init/init.mts similarity index 86% rename from src/commands/init/init.mjs rename to src/commands/init/init.mts index f1c8a0aed8e..e5e03667ff5 100644 --- a/src/commands/init/init.mjs +++ b/src/commands/init/init.mts @@ -1,4 +1,4 @@ -// @ts-check + import { Option } from 'commander' import inquirer from 'inquirer' import isEmpty from 'lodash/isEmpty.js' @@ -11,6 +11,7 @@ import { track } from '../../utils/telemetry/index.mjs' import { link } from '../link/index.mjs' import { sitesCreate } from '../sites/index.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'siteInfo' implicitly has an 'any'... Remove this comment to see the full error message const persistState = ({ siteInfo, state }) => { // Save to .netlify/state.json file state.set('siteId', siteInfo.id) @@ -20,8 +21,10 @@ const persistState = ({ siteInfo, state }) => { * @param {{} | undefined} siteInfo * @returns {string | undefined} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'siteInfo' implicitly has an 'any' type. const getRepoUrl = (siteInfo) => siteInfo?.build_settings?.repo_url +// @ts-expect-error TS(7031) FIXME: Binding element 'siteInfo' implicitly has an 'any'... Remove this comment to see the full error message const logExistingAndExit = ({ siteInfo }) => { log() log(`This site has been initialized`) @@ -44,9 +47,11 @@ const logExistingAndExit = ({ siteInfo }) => { * @param {*} config.state * @param {import('../base-command.mjs').default} config.command */ +// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message const createNewSiteAndExit = async ({ command, state }) => { const siteInfo = await sitesCreate({}, command) + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. log(`"${siteInfo.name}" site was created`) log() log(`To deploy to this site. Run your site build and then ${chalk.cyanBright.bold('netlify deploy')}`) @@ -96,6 +101,7 @@ const logGitSetupInstructionsAndExit = () => { * @param {object} config.error * @param {object} config.state */ +// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message const handleNoGitRemoteAndExit = async ({ command, error, state }) => { log() log(`${chalk.yellow('No git remote was found, would you like to set one up?')}`) @@ -136,6 +142,7 @@ git remote add origin https://github.com/YourUserName/RepoName.git * Creates a new site or links an existing one to the repository * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. const createOrLinkSiteToRepo = async (command) => { const NEW_SITE = '+ Create & configure a new site' const EXISTING_SITE = '⇄ Connect this directory to an existing Netlify site' @@ -165,6 +172,7 @@ const createOrLinkSiteToRepo = async (command) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'repoUrl' implicitly has an 'any' ... Remove this comment to see the full error message const logExistingRepoSetupAndExit = ({ repoUrl, siteName }) => { log() log(chalk.underline.bold(`Success`)) @@ -178,6 +186,7 @@ const logExistingRepoSetupAndExit = ({ repoUrl, siteName }) => { * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const init = async (options, command) => { command.setAnalyticsPayload({ manual: options.manual, force: options.force }) @@ -225,6 +234,7 @@ export const init = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createInitCommand = (program) => program .command('init') diff --git a/src/commands/integration/deploy.mjs b/src/commands/integration/deploy.mts similarity index 76% rename from src/commands/integration/deploy.mjs rename to src/commands/integration/deploy.mts index 4e62abdc034..984bbd80ce7 100644 --- a/src/commands/integration/deploy.mjs +++ b/src/commands/integration/deploy.mts @@ -3,7 +3,9 @@ import { resolve } from 'path' import { exit, env } from 'process' import inquirer from 'inquirer' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'js-y... Remove this comment to see the full error message import yaml from 'js-yaml' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message import fetch from 'node-fetch' import { z } from 'zod' @@ -17,14 +19,17 @@ function getIntegrationAPIUrl() { return env.INTEGRATION_URL || 'https://api.netlifysdk.com' } +// @ts-expect-error TS(7006) FIXME: Parameter 'localScopes' implicitly has an 'any' ty... Remove this comment to see the full error message export function areScopesEqual(localScopes, remoteScopes) { if (localScopes.length !== remoteScopes.length) { return false } + // @ts-expect-error TS(7006) FIXME: Parameter 'scope' implicitly has an 'any' type. return localScopes.every((scope) => remoteScopes.includes(scope)) } +// @ts-expect-error TS(7006) FIXME: Parameter 'localScopes' implicitly has an 'any' ty... Remove this comment to see the full error message function logScopeConfirmationMessage(localScopes, remoteScopes) { log(chalk.yellow(`This integration is already registered. The current required scopes are:`)) for (const scope of remoteScopes) { @@ -37,6 +42,7 @@ function logScopeConfirmationMessage(localScopes, remoteScopes) { log(chalk.yellow('if you continue. This will only affect future installations of the integration.')) } +// @ts-expect-error TS(7006) FIXME: Parameter 'registeredIntegrationScopes' implicitly... Remove this comment to see the full error message function formatScopesToWrite(registeredIntegrationScopes) { let scopesToWrite = {} @@ -46,15 +52,19 @@ function formatScopesToWrite(registeredIntegrationScopes) { scopesToWrite = { all: true } break } else { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message if (!scopesToWrite[resource]) { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message scopesToWrite[resource] = [] } + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message scopesToWrite[resource].push(permission) } } return scopesToWrite } +// @ts-expect-error TS(7006) FIXME: Parameter 'scopes' implicitly has an 'any' type. function formatScopesForRemote(scopes) { const scopesToWrite = [] if (scopes.all) { @@ -63,6 +73,7 @@ function formatScopesForRemote(scopes) { const scopeResources = Object.keys(scopes) scopeResources.forEach((resource) => { const permissionsRequested = scopes[resource] + // @ts-expect-error TS(7006) FIXME: Parameter 'permission' implicitly has an 'any' typ... Remove this comment to see the full error message permissionsRequested.forEach((permission) => { scopesToWrite.push(`${resource}:${permission}`) }) @@ -71,6 +82,7 @@ function formatScopesForRemote(scopes) { return scopesToWrite.join(',') } +// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. function verifyRequiredFieldsAreInConfig(name, description, scopes, integrationLevel) { const missingFields = [] @@ -104,6 +116,7 @@ function verifyRequiredFieldsAreInConfig(name, description, scopes, integrationL return true } +// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message // eslint-disable-next-line max-params export async function registerIntegration(workingDir, siteId, accountId, localIntegrationConfig, token) { const { description, integrationLevel, name, scopes, slug } = localIntegrationConfig @@ -150,6 +163,7 @@ export async function registerIntegration(workingDir, siteId, accountId, localIn scopes: formatScopesForRemote(scopes), integrationLevel, }), + // @ts-expect-error TS(7006) FIXME: Parameter 'res' implicitly has an 'any' type. }).then(async (res) => { const response = await res.json() return { body: response, statusCode: res.status } @@ -180,12 +194,19 @@ export async function registerIntegration(workingDir, siteId, accountId, localIn // eslint-disable-next-line max-params export async function updateIntegration( + // @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message workingDir, + // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. options, + // @ts-expect-error TS(7006) FIXME: Parameter 'siteId' implicitly has an 'any' type. siteId, + // @ts-expect-error TS(7006) FIXME: Parameter 'accountId' implicitly has an 'any' type... Remove this comment to see the full error message accountId, + // @ts-expect-error TS(7006) FIXME: Parameter 'localIntegrationConfig' implicitly has ... Remove this comment to see the full error message localIntegrationConfig, + // @ts-expect-error TS(7006) FIXME: Parameter 'token' implicitly has an 'any' type. token, + // @ts-expect-error TS(7006) FIXME: Parameter 'registeredIntegration' implicitly has a... Remove this comment to see the full error message registeredIntegration, ) { let { description, integrationLevel, name, scopes, slug } = localIntegrationConfig @@ -218,6 +239,7 @@ export async function updateIntegration( const registeredIntegrationScopes = registeredIntegration.scopes.split(',') const scopeResources = Object.keys(scopes) + // @ts-expect-error TS(7034) FIXME: Variable 'localScopes' implicitly has type 'any[]'... Remove this comment to see the full error message let localScopes = [] if (scopeResources.includes('all')) { @@ -225,13 +247,16 @@ export async function updateIntegration( } else { scopeResources.forEach((resource) => { const permissionsRequested = scopes[resource] + // @ts-expect-error TS(7006) FIXME: Parameter 'permission' implicitly has an 'any' typ... Remove this comment to see the full error message permissionsRequested.forEach((permission) => { localScopes.push(`${resource}:${permission}`) }) }) } + // @ts-expect-error TS(7005) FIXME: Variable 'localScopes' implicitly has an 'any[]' t... Remove this comment to see the full error message if (!areScopesEqual(localScopes, registeredIntegrationScopes)) { + // @ts-expect-error TS(7005) FIXME: Variable 'localScopes' implicitly has an 'any[]' t... Remove this comment to see the full error message logScopeConfirmationMessage(localScopes, registeredIntegrationScopes) const scopePrompt = await inquirer.prompt([ @@ -258,10 +283,12 @@ export async function updateIntegration( name, description, hostSiteId: siteId, + // @ts-expect-error TS(7005) FIXME: Variable 'localScopes' implicitly has an 'any[]' t... Remove this comment to see the full error message scopes: localScopes.join(','), integrationLevel, }), }, + // @ts-expect-error TS(7006) FIXME: Parameter 'res' implicitly has an 'any' type. ).then(async (res) => { const response = await res.json() return { updateResponse: response, statusCode: res.status } @@ -323,6 +350,7 @@ const IntegrationConfigurationSchema = z.object({ integrationLevel: z.enum(['site', 'team', 'team-and-site']).optional(), }) +// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message const getConfigurationFile = (workingDir) => { const pwd = workingDir @@ -331,6 +359,7 @@ const getConfigurationFile = (workingDir) => { return fileName } +// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message export const getConfiguration = (workingDir) => { const pwd = workingDir @@ -366,11 +395,14 @@ export const getConfiguration = (workingDir) => { * @param {import('commander').OptionValues} options * * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const deploy = async (options, command) => { const { api, cachedConfig, site, siteInfo } = command.netlify const { id: siteId } = site + // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. const [token] = await getToken() const workingDir = resolve(command.workingDir) + // @ts-expect-error TS(2345) FIXME: Argument of type '{ cachedConfig: any; packagePath... Remove this comment to see the full error message const buildOptions = await getBuildOptions({ cachedConfig, packagePath: command.workspacePackage, @@ -385,6 +417,7 @@ const deploy = async (options, command) => { const { description, integrationLevel, name, scopes, slug } = await getConfiguration(command.workingDir) const localIntegrationConfig = { name, description, scopes, slug, integrationLevel } + // @ts-expect-error TS(2345) FIXME: Argument of type '{ api: any; site: any; siteInfo:... Remove this comment to see the full error message const { accountId } = await getSiteInformation({ api, site, @@ -398,6 +431,7 @@ const deploy = async (options, command) => { 'netlify-token': token, }, }, + // @ts-expect-error TS(7006) FIXME: Parameter 'res' implicitly has an 'any' type. ).then(async (res) => { const body = await res.json() return { body, statusCode: res.status } @@ -436,6 +470,7 @@ const deploy = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createDeployCommand = (program) => program .command('integration:deploy') diff --git a/src/commands/integration/index.mjs b/src/commands/integration/index.mts similarity index 78% rename from src/commands/integration/index.mjs rename to src/commands/integration/index.mts index 48118f0b849..2d703d83571 100644 --- a/src/commands/integration/index.mjs +++ b/src/commands/integration/index.mts @@ -5,6 +5,7 @@ import { createDeployCommand } from './deploy.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const integrations = (options, command) => { command.help() } @@ -14,6 +15,7 @@ const integrations = (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createIntegrationCommand = (program) => { createDeployCommand(program) diff --git a/src/commands/link/index.mjs b/src/commands/link/index.mts similarity index 100% rename from src/commands/link/index.mjs rename to src/commands/link/index.mts diff --git a/src/commands/link/link.mjs b/src/commands/link/link.mts similarity index 79% rename from src/commands/link/link.mjs rename to src/commands/link/link.mts index 86b4b6a640e..b1c1270ee11 100644 --- a/src/commands/link/link.mjs +++ b/src/commands/link/link.mts @@ -1,4 +1,4 @@ -// @ts-check + import { Option } from 'commander' import inquirer from 'inquirer' import isEmpty from 'lodash/isEmpty.js' @@ -14,6 +14,7 @@ import { track } from '../../utils/telemetry/index.mjs' * @param {import('../base-command.mjs').default} command * @param {import('commander').OptionValues} options */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. const linkPrompt = async (command, options) => { const { api, state } = command.netlify @@ -60,6 +61,7 @@ const linkPrompt = async (command, options) => { } const matchingSites = sites.filter( + // @ts-expect-error TS(2339) FIXME: Property 'repo_url' does not exist on type '{}'. ({ build_settings: buildSettings = {} }) => repoData.httpsUrl === buildSettings.repo_url, ) @@ -90,6 +92,7 @@ Run ${chalk.cyanBright('git remote -v')} to see a list of your git remotes.`) type: 'list', name: 'selectedSite', message: 'Which site do you want to link?', + // @ts-expect-error TS(7006) FIXME: Parameter 'matchingSite' implicitly has an 'any' t... Remove this comment to see the full error message choices: matchingSites.map((matchingSite) => ({ name: `${matchingSite.name} - ${matchingSite.ssl_url}`, value: matchingSite, @@ -122,9 +125,11 @@ Run ${chalk.cyanBright('git remote -v')} to see a list of your git remotes.`) options: { name: searchTerm, filter: 'all' }, }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 404) { error(`'${searchTerm}' not found`) } else { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } @@ -144,6 +149,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`) name: 'selectedSite', message: 'Which site do you want to link?', paginated: true, + // @ts-expect-error TS(7006) FIXME: Parameter 'matchingSite' implicitly has an 'any' t... Remove this comment to see the full error message choices: matchingSites.map((matchingSite) => ({ name: matchingSite.name, value: matchingSite })), }, ]) @@ -166,6 +172,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`) try { sites = await listSites({ api, options: { maxPages: 1, filter: 'all' } }) } catch (error_) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } @@ -179,6 +186,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`) name: 'selectedSite', message: 'Which site do you want to link?', paginated: true, + // @ts-expect-error TS(7006) FIXME: Parameter 'matchingSite' implicitly has an 'any' t... Remove this comment to see the full error message choices: sites.map((matchingSite) => ({ name: matchingSite.name, value: matchingSite })), }, ]) @@ -199,12 +207,14 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`) ]) try { - // @ts-ignore types from API are wrong they cannot recognize `getSite` of API site = await api.getSite({ siteId }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 404) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'Error' is not assignable to para... Remove this comment to see the full error message error(new Error(`Site ID '${siteId}' not found`)) } else { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } @@ -215,6 +225,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`) } if (!site) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'Error' is not assignable to para... Remove this comment to see the full error message error(new Error(`No site found`)) } @@ -244,6 +255,7 @@ or run ${chalk.cyanBright('netlify sites:create')} to create a site.`) * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const link = async (options, command) => { await command.authenticate() @@ -275,12 +287,14 @@ export const link = async (options, command) => { log(`To unlink this site, run: ${chalk.cyanBright('netlify unlink')}`) } else if (options.id) { try { - // @ts-ignore types from API are wrong they cannot recognize `getSite` of API siteData = await api.getSite({ site_id: options.id }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 404) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'Error' is not assignable to para... Remove this comment to see the full error message error(new Error(`Site id ${options.id} not found`)) } else { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } @@ -305,14 +319,18 @@ export const link = async (options, command) => { }, }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 404) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'Error' is not assignable to para... Remove this comment to see the full error message error(new Error(`${options.name} not found`)) } else { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } if (results.length === 0) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'Error' is not assignable to para... Remove this comment to see the full error message error(new Error(`No sites found named ${options.name}`)) } const [firstSiteData] = results @@ -336,6 +354,7 @@ export const link = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createLinkCommand = (program) => program .command('link') diff --git a/src/commands/lm/index.mjs b/src/commands/lm/index.mts similarity index 100% rename from src/commands/lm/index.mjs rename to src/commands/lm/index.mts diff --git a/src/commands/lm/lm-info.mjs b/src/commands/lm/lm-info.mts similarity index 85% rename from src/commands/lm/lm-info.mjs rename to src/commands/lm/lm-info.mts index 8ca486ccce4..052670a8b4f 100644 --- a/src/commands/lm/lm-info.mjs +++ b/src/commands/lm/lm-info.mts @@ -1,4 +1,4 @@ -// @ts-check + import { Listr } from 'listr2' import { @@ -15,6 +15,7 @@ const lmInfo = async () => { const steps = [ checkGitVersionStep, checkGitLFSVersionStep, + // @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. checkLFSFiltersStep((ctx, task, installed) => { if (!installed) { throw new Error('Git LFS filters are not installed, run `git lfs install` to install them') @@ -36,5 +37,6 @@ const lmInfo = async () => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createLmInfoCommand = (program) => program.command('lm:info', { hidden: true }).description('Show large media requirements information.').action(lmInfo) diff --git a/src/commands/lm/lm-install.mjs b/src/commands/lm/lm-install.mts similarity index 79% rename from src/commands/lm/lm-install.mjs rename to src/commands/lm/lm-install.mts index e15e58e4aa7..6bf6b17edeb 100644 --- a/src/commands/lm/lm-install.mjs +++ b/src/commands/lm/lm-install.mts @@ -1,4 +1,4 @@ -// @ts-check + import { installPlatform } from '../../utils/lm/install.mjs' import { printBanner } from '../../utils/lm/ui.mjs' @@ -6,6 +6,7 @@ import { printBanner } from '../../utils/lm/ui.mjs' * The lm:install command * @param {import('commander').OptionValues} options */ +// @ts-expect-error TS(7031) FIXME: Binding element 'force' implicitly has an 'any' ty... Remove this comment to see the full error message const lmInstall = async ({ force }) => { const installed = await installPlatform({ force }) if (installed) { @@ -18,6 +19,7 @@ const lmInstall = async ({ force }) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createLmInstallCommand = (program) => program .command('lm:install', { hidden: true }) diff --git a/src/commands/lm/lm-setup.mjs b/src/commands/lm/lm-setup.mts similarity index 74% rename from src/commands/lm/lm-setup.mjs rename to src/commands/lm/lm-setup.mts index af4669889c6..de1df6fc2b0 100644 --- a/src/commands/lm/lm-setup.mjs +++ b/src/commands/lm/lm-setup.mts @@ -1,12 +1,14 @@ -// @ts-check + import { Listr } from 'listr2' import { error } from '../../utils/command-helpers.mjs' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../../utils/execa.mjs' import { installPlatform } from '../../utils/lm/install.mjs' import { checkHelperVersion } from '../../utils/lm/requirements.mjs' import { printBanner } from '../../utils/lm/ui.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'force' implicitly has an 'any' ty... Remove this comment to see the full error message const installHelperIfMissing = async function ({ force }) { let installHelper = false try { @@ -25,6 +27,7 @@ const installHelperIfMissing = async function ({ force }) { return false } +// @ts-expect-error TS(7006) FIXME: Parameter 'siteId' implicitly has an 'any' type. const provisionService = async function (siteId, api) { const addonName = 'large-media' @@ -39,14 +42,17 @@ const provisionService = async function (siteId, api) { }) } catch (error_) { // error is JSONHTTPError + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. throw new Error(error_.json.error) } } +// @ts-expect-error TS(7006) FIXME: Parameter 'siteId' implicitly has an 'any' type. const configureLFSURL = async function (siteId, api) { const siteInfo = await api.getSite({ siteId }) const url = `https://${siteInfo.id_domain}/.netlify/large-media` + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. return execa('git', ['config', '-f', '.lfsconfig', 'lfs.url', url]) } @@ -55,6 +61,7 @@ const configureLFSURL = async function (siteId, api) { * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const lmSetup = async (options, command) => { await command.authenticate() @@ -65,6 +72,7 @@ const lmSetup = async (options, command) => { try { helperInstalled = await installHelperIfMissing({ force: options.forceInstall }) } catch (error_) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } @@ -95,6 +103,7 @@ const lmSetup = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createLmSetupCommand = (program) => program .command('lm:setup', { hidden: true }) diff --git a/src/commands/lm/lm-uninstall.mjs b/src/commands/lm/lm-uninstall.mts similarity index 86% rename from src/commands/lm/lm-uninstall.mjs rename to src/commands/lm/lm-uninstall.mts index 80d28fc933e..c62e22c23d8 100644 --- a/src/commands/lm/lm-uninstall.mjs +++ b/src/commands/lm/lm-uninstall.mts @@ -1,4 +1,4 @@ -// @ts-check + import { uninstall } from '../../utils/lm/install.mjs' /** @@ -13,6 +13,7 @@ const lmUninstall = async () => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createLmUninstallCommand = (program) => program .command('lm:uninstall', { hidden: true }) diff --git a/src/commands/lm/lm.mjs b/src/commands/lm/lm.mts similarity index 85% rename from src/commands/lm/lm.mjs rename to src/commands/lm/lm.mts index f000d7c1835..992464d669e 100644 --- a/src/commands/lm/lm.mjs +++ b/src/commands/lm/lm.mts @@ -1,4 +1,4 @@ -// @ts-check + import { createLmInfoCommand } from './lm-info.mjs' import { createLmInstallCommand } from './lm-install.mjs' import { createLmSetupCommand } from './lm-setup.mjs' @@ -9,6 +9,7 @@ import { createLmUninstallCommand } from './lm-uninstall.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const lm = (options, command) => { command.help() } @@ -18,6 +19,7 @@ const lm = (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createLmCommand = (program) => { createLmInfoCommand(program) createLmInstallCommand(program) diff --git a/src/commands/login/index.mjs b/src/commands/login/index.mts similarity index 100% rename from src/commands/login/index.mjs rename to src/commands/login/index.mts diff --git a/src/commands/login/login.mjs b/src/commands/login/login.mts similarity index 81% rename from src/commands/login/login.mjs rename to src/commands/login/login.mts index 7c9a2a6c383..73451e51fe3 100644 --- a/src/commands/login/login.mjs +++ b/src/commands/login/login.mts @@ -1,6 +1,7 @@ -// @ts-check + import { chalk, exit, getToken, log } from '../../utils/command-helpers.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'location' implicitly has an 'any' type. const msg = function (location) { switch (location) { case 'env': @@ -19,7 +20,9 @@ const msg = function (location) { * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const login = async (options, command) => { + // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. const [accessToken, location] = await getToken() command.setAnalyticsPayload({ new: options.new }) @@ -44,6 +47,7 @@ export const login = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createLoginCommand = (program) => program .command('login') diff --git a/src/commands/logout/index.mjs b/src/commands/logout/index.mts similarity index 100% rename from src/commands/logout/index.mjs rename to src/commands/logout/index.mts diff --git a/src/commands/logout/logout.mjs b/src/commands/logout/logout.mts similarity index 82% rename from src/commands/logout/logout.mjs rename to src/commands/logout/logout.mts index f0e60ff7198..d7efe299063 100644 --- a/src/commands/logout/logout.mjs +++ b/src/commands/logout/logout.mts @@ -1,4 +1,4 @@ -// @ts-check + import { exit, getToken, log } from '../../utils/command-helpers.mjs' import { track } from '../../utils/telemetry/index.mjs' @@ -7,7 +7,9 @@ import { track } from '../../utils/telemetry/index.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const logout = async (options, command) => { + // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. const [accessToken, location] = await getToken() if (!accessToken) { @@ -38,5 +40,6 @@ const logout = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createLogoutCommand = (program) => program.command('logout', { hidden: true }).description('Logout of your Netlify account').action(logout) diff --git a/src/commands/main.mjs b/src/commands/main.mts similarity index 90% rename from src/commands/main.mjs rename to src/commands/main.mts index a6a4afeaa87..8bbbdee327a 100644 --- a/src/commands/main.mjs +++ b/src/commands/main.mts @@ -1,12 +1,14 @@ -// @ts-check + import process from 'process' import { Option } from 'commander' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'envi... Remove this comment to see the full error message import envinfo from 'envinfo' import { closest } from 'fastest-levenshtein' import inquirer from 'inquirer' import { BANG, chalk, error, exit, log, NETLIFY_CYAN, USER_AGENT, warn } from '../utils/command-helpers.mjs' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../utils/execa.mjs' import getGlobalConfig from '../utils/get-global-config.mjs' import getPackageJson from '../utils/get-package-json.mjs' @@ -88,6 +90,7 @@ ${USER_AGENT} * @param {import('commander').OptionValues} options * @param {import('./base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const mainCommand = async function (options, command) { const globalConfig = await getGlobalConfig() @@ -133,6 +136,7 @@ const mainCommand = async function (options, command) { if (command.args[0] === 'help') { if (command.args[1]) { + // @ts-expect-error TS(7006) FIXME: Parameter 'cmd' implicitly has an 'any' type. const subCommand = command.commands.find((cmd) => cmd.name() === command.args[1]) if (!subCommand) { error(`command ${command.args[1]} not found`) @@ -144,6 +148,7 @@ const mainCommand = async function (options, command) { warn(`${chalk.yellow(command.args[0])} is not a ${command.name()} command.`) + // @ts-expect-error TS(7006) FIXME: Parameter 'cmd' implicitly has an 'any' type. const allCommands = command.commands.map((cmd) => cmd.name()) const suggestion = closest(command.args[0], allCommands) @@ -156,7 +161,7 @@ const mainCommand = async function (options, command) { }) setTimeout(() => { - // @ts-ignore + // @ts-expect-error TS(2445) FIXME: Property 'close' is protected and only accessible ... Remove this comment to see the full error message prompt.ui.close() resolve(false) }, SUGGESTION_TIMEOUT) @@ -171,6 +176,7 @@ const mainCommand = async function (options, command) { error(`Run ${NETLIFY_CYAN(`${command.name()} help`)} for a list of available commands.`) } + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. await execa(process.argv[0], [process.argv[1], suggestion], { stdio: 'inherit' }) } diff --git a/src/commands/open/index.mjs b/src/commands/open/index.mts similarity index 100% rename from src/commands/open/index.mjs rename to src/commands/open/index.mts diff --git a/src/commands/open/open-admin.mjs b/src/commands/open/open-admin.mts similarity index 75% rename from src/commands/open/open-admin.mjs rename to src/commands/open/open-admin.mts index 196b184861a..a0b8ee8998d 100644 --- a/src/commands/open/open-admin.mjs +++ b/src/commands/open/open-admin.mts @@ -7,6 +7,7 @@ import openBrowser from '../../utils/open-browser.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const openAdmin = async (options, command) => { const { siteInfo } = command.netlify @@ -15,6 +16,7 @@ export const openAdmin = async (options, command) => { log(`Opening "${siteInfo.name}" site admin UI:`) log(`> ${siteInfo.admin_url}`) + // @ts-expect-error TS(2345) FIXME: Argument of type '{ url: any; }' is not assignable... Remove this comment to see the full error message await openBrowser({ url: siteInfo.admin_url }) exit() } @@ -24,6 +26,7 @@ export const openAdmin = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createOpenAdminCommand = (program) => program .command('open:admin') diff --git a/src/commands/open/open-site.mjs b/src/commands/open/open-site.mts similarity index 75% rename from src/commands/open/open-site.mjs rename to src/commands/open/open-site.mts index 3faacac33a6..e644c91454d 100644 --- a/src/commands/open/open-site.mjs +++ b/src/commands/open/open-site.mts @@ -7,6 +7,7 @@ import openBrowser from '../../utils/open-browser.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const openSite = async (options, command) => { const { siteInfo } = command.netlify @@ -16,6 +17,7 @@ export const openSite = async (options, command) => { log(`Opening "${siteInfo.name}" site url:`) log(`> ${url}`) + // @ts-expect-error TS(2345) FIXME: Argument of type '{ url: any; }' is not assignable... Remove this comment to see the full error message await openBrowser({ url }) exit() } @@ -25,6 +27,7 @@ export const openSite = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createOpenSiteCommand = (program) => program .command('open:site') diff --git a/src/commands/open/open.mjs b/src/commands/open/open.mts similarity index 86% rename from src/commands/open/open.mjs rename to src/commands/open/open.mts index 2d9af9518f8..7a2699dddb0 100644 --- a/src/commands/open/open.mjs +++ b/src/commands/open/open.mts @@ -8,6 +8,7 @@ import { createOpenSiteCommand, openSite } from './open-site.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const open = async (options, command) => { if (!options.site || !options.admin) { log(command.helpInformation()) @@ -25,6 +26,7 @@ const open = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createOpenCommand = (program) => { createOpenAdminCommand(program) createOpenSiteCommand(program) diff --git a/src/commands/recipes/common.mjs b/src/commands/recipes/common.mts similarity index 91% rename from src/commands/recipes/common.mjs rename to src/commands/recipes/common.mts index 4da0ff84269..e5a162d5331 100644 --- a/src/commands/recipes/common.mjs +++ b/src/commands/recipes/common.mts @@ -4,6 +4,7 @@ import { fileURLToPath, pathToFileURL } from 'url' const directoryPath = dirname(fileURLToPath(import.meta.url)) +// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. export const getRecipe = async (name) => { const recipePath = resolve(directoryPath, '../../recipes', name, 'index.mjs') diff --git a/src/commands/recipes/index.mjs b/src/commands/recipes/index.mts similarity index 100% rename from src/commands/recipes/index.mjs rename to src/commands/recipes/index.mts diff --git a/src/commands/recipes/recipes-list.mjs b/src/commands/recipes/recipes-list.mts similarity index 77% rename from src/commands/recipes/recipes-list.mjs rename to src/commands/recipes/recipes-list.mts index 6e4606c3daa..864d6106673 100644 --- a/src/commands/recipes/recipes-list.mjs +++ b/src/commands/recipes/recipes-list.mts @@ -1,4 +1,5 @@ -// @ts-check + +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'asci... Remove this comment to see the full error message import AsciiTable from 'ascii-table' import { listRecipes } from './common.mjs' @@ -24,6 +25,7 @@ const recipesListCommand = async () => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createRecipesListCommand = (program) => program .command('recipes:list') diff --git a/src/commands/recipes/recipes.mjs b/src/commands/recipes/recipes.mts similarity index 81% rename from src/commands/recipes/recipes.mjs rename to src/commands/recipes/recipes.mts index 7d65f153cbb..c64d32ef883 100644 --- a/src/commands/recipes/recipes.mjs +++ b/src/commands/recipes/recipes.mts @@ -1,4 +1,4 @@ -// @ts-check + import { basename } from 'path' import { closest } from 'fastest-levenshtein' @@ -17,6 +17,7 @@ const SUGGESTION_TIMEOUT = 1e4 * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7023) FIXME: 'recipesCommand' implicitly has return type 'any' ... Remove this comment to see the full error message const recipesCommand = async (recipeName, options, command) => { const { config, repositoryRoot } = command.netlify const sanitizedRecipeName = basename(recipeName || '').toLowerCase() @@ -30,6 +31,7 @@ const recipesCommand = async (recipeName, options, command) => { } catch (error) { if ( // The ESM loader throws this instead of MODULE_NOT_FOUND + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error.code !== 'ERR_MODULE_NOT_FOUND' ) { throw error @@ -49,7 +51,7 @@ const recipesCommand = async (recipeName, options, command) => { }) setTimeout(() => { - // @ts-ignore + // @ts-expect-error TS(2445) FIXME: Property 'close' is protected and only accessible ... Remove this comment to see the full error message prompt.ui.close() resolve(false) }, SUGGESTION_TIMEOUT) @@ -64,6 +66,7 @@ const recipesCommand = async (recipeName, options, command) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message export const runRecipe = async ({ config, recipeName, repositoryRoot }) => { const recipe = await getRecipe(recipeName) @@ -75,6 +78,7 @@ export const runRecipe = async ({ config, recipeName, repositoryRoot }) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createRecipesCommand = (program) => { createRecipesListCommand(program) diff --git a/src/commands/serve/index.mjs b/src/commands/serve/index.mts similarity index 100% rename from src/commands/serve/index.mjs rename to src/commands/serve/index.mts diff --git a/src/commands/serve/serve.mjs b/src/commands/serve/serve.mts similarity index 92% rename from src/commands/serve/serve.mjs rename to src/commands/serve/serve.mts index 0cae11f1586..5fb31ba10f5 100644 --- a/src/commands/serve/serve.mjs +++ b/src/commands/serve/serve.mts @@ -1,4 +1,4 @@ -// @ts-check + import process from 'process' import { Option } from 'commander' @@ -30,6 +30,7 @@ import { getGeoCountryArgParser } from '../../utils/validation.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const serve = async (options, command) => { const { api, cachedConfig, config, repositoryRoot, site, siteInfo, state } = command.netlify config.dev = { ...config.dev } @@ -76,6 +77,7 @@ const serve = async (options, command) => { cachedConfig.config = getConfigWithPlugins(cachedConfig.config, settings) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. log(NETLIFYDEVERR, error_.message) exit(1) } @@ -128,6 +130,7 @@ const serve = async (options, command) => { } const inspectSettings = generateInspectSettings(options.edgeInspect, options.edgeInspectBrk) + // @ts-expect-error TS(2345) FIXME: Argument of type '{ addonsUrls: { [k: string]: any... Remove this comment to see the full error message const url = await startProxyServer({ addonsUrls, config, @@ -163,6 +166,7 @@ const serve = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createServeCommand = (program) => program .command('serve') @@ -174,6 +178,7 @@ export const createServeCommand = (program) => 'Specify a deploy context or branch for environment variables (contexts: "production", "deploy-preview", "branch-deploy", "dev")', normalizeContext, ) + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. .option('-p ,--port ', 'port of netlify dev', (value) => Number.parseInt(value)) .option('-d ,--dir ', 'dir with static files') .option('-f ,--functions ', 'specify a functions folder to serve') @@ -183,6 +188,7 @@ export const createServeCommand = (program) => .argParser((value) => Number.parseInt(value)) .hideHelp(true), ) + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. .option('--functions-port ', 'port of functions server', (value) => Number.parseInt(value)) .addOption( new Option( diff --git a/src/commands/sites/index.mjs b/src/commands/sites/index.mts similarity index 100% rename from src/commands/sites/index.mjs rename to src/commands/sites/index.mts diff --git a/src/commands/sites/sites-create-template.mjs b/src/commands/sites/sites-create-template.mts similarity index 76% rename from src/commands/sites/sites-create-template.mjs rename to src/commands/sites/sites-create-template.mts index 0c4b51b8060..90b7977c8d7 100644 --- a/src/commands/sites/sites-create-template.mjs +++ b/src/commands/sites/sites-create-template.mts @@ -1,11 +1,13 @@ -// @ts-check + import inquirer from 'inquirer' import pick from 'lodash/pick.js' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'pars... Remove this comment to see the full error message import parseGitHubUrl from 'parse-github-url' import { render } from 'prettyjson' import { chalk, error, getTerminalLink, log, logJson, warn } from '../../utils/command-helpers.mjs' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../../utils/execa.mjs' import getRepoData from '../../utils/get-repo-data.mjs' import { getGitHubToken } from '../../utils/init/config-github.mjs' @@ -15,11 +17,14 @@ import { track } from '../../utils/telemetry/index.mjs' import { getSiteNameInput } from './sites-create.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'token' implicitly has an 'any' type. export const fetchTemplates = async (token) => { const templatesFromGithubOrg = await getTemplatesFromGitHub(token) return templatesFromGithubOrg + // @ts-expect-error TS(7006) FIXME: Parameter 'repo' implicitly has an 'any' type. .filter((repo) => !repo.archived && !repo.disabled) + // @ts-expect-error TS(7006) FIXME: Parameter 'template' implicitly has an 'any' type. .map((template) => ({ name: template.name, sourceCodeUrl: template.html_url, @@ -27,6 +32,7 @@ export const fetchTemplates = async (token) => { })) } +// @ts-expect-error TS(7031) FIXME: Binding element 'ghToken' implicitly has an 'any' ... Remove this comment to see the full error message const getTemplateName = async ({ ghToken, options, repository }) => { if (repository) { const { repo } = parseGitHubUrl(repository) @@ -47,6 +53,7 @@ const getTemplateName = async ({ ghToken, options, repository }) => { type: 'list', name: 'templateName', message: 'Template:', + // @ts-expect-error TS(7006) FIXME: Parameter 'template' implicitly has an 'any' type. choices: templates.map((template) => ({ value: template.slug, name: template.name, @@ -57,6 +64,7 @@ const getTemplateName = async ({ ghToken, options, repository }) => { return templateName } +// @ts-expect-error TS(7031) FIXME: Binding element 'options' implicitly has an 'any' ... Remove this comment to see the full error message const getGitHubLink = ({ options, templateName }) => options.url || `https://github.com/${templateName}` /** @@ -65,6 +73,7 @@ const getGitHubLink = ({ options, templateName }) => options.url || `https://git * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'repository' implicitly has an 'any' typ... Remove this comment to see the full error message const sitesCreateTemplate = async (repository, options, command) => { const { api } = command.netlify @@ -101,6 +110,7 @@ const sitesCreateTemplate = async (repository, options, command) => { type: 'list', name: 'accountSlug', message: 'Team:', + // @ts-expect-error TS(7006) FIXME: Parameter 'account' implicitly has an 'any' type. choices: accounts.map((account) => ({ value: account.slug, name: account.name, @@ -115,6 +125,7 @@ const sitesCreateTemplate = async (repository, options, command) => { let repoResp // Allow the user to reenter site name if selected one isn't available + // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. const inputSiteName = async (name) => { const { name: inputName } = await getSiteNameInput(name) @@ -129,6 +140,7 @@ const sitesCreateTemplate = async (repository, options, command) => { warn( `Oh no! We found already a repository with this name. It seems you have already created a template with the name ${templateName}. Please try to run the command again and provide a different name.`, ) + // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. await inputSiteName() } else { throw new Error( @@ -150,12 +162,15 @@ const sitesCreateTemplate = async (repository, options, command) => { }) } } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 422 || error_.message === 'Duplicate repo') { warn( `${name}.netlify.app already exists or a repository named ${name} already exists on this account. Please try a different slug.`, ) + // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. await inputSiteName() } else { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(`createSiteInTeam error: ${error_.status}: ${error_.message}`) } } @@ -167,18 +182,24 @@ const sitesCreateTemplate = async (repository, options, command) => { log(chalk.greenBright.bold.underline(`Site Created`)) log() + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. const siteUrl = site.ssl_url || site.url log( render({ + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. 'Admin URL': site.admin_url, URL: siteUrl, + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. 'Site ID': site.id, + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. 'Repo URL': site.build_settings.repo_url, }), ) track('sites_createdFromTemplate', { + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. siteId: site.id, + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. adminUrl: site.admin_url, siteUrl, }) @@ -191,13 +212,17 @@ const sitesCreateTemplate = async (repository, options, command) => { }) if (cloneConfirm) { log() + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. await execa('git', ['clone', repoResp.clone_url, `${repoResp.name}`]) + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. log(`🚀 Repository cloned successfully. You can find it under the ${chalk.magenta(repoResp.name)} folder`) } if (options.withCi) { log('Configuring CI') + // @ts-expect-error TS(2345) FIXME: Argument of type '{ workingDir: any; }' is not ass... Remove this comment to see the full error message const repoData = await getRepoData({ workingDir: command.workingDir }) + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. await configureRepo({ command, siteId: site.id, repoData, manual: options.manual }) } @@ -239,6 +264,7 @@ const sitesCreateTemplate = async (repository, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createSitesFromTemplateCommand = (program) => program .command('sites:create-template') diff --git a/src/commands/sites/sites-create.mjs b/src/commands/sites/sites-create.mts similarity index 76% rename from src/commands/sites/sites-create.mjs rename to src/commands/sites/sites-create.mts index 5023e0bb3be..26d1403f515 100644 --- a/src/commands/sites/sites-create.mjs +++ b/src/commands/sites/sites-create.mts @@ -1,4 +1,4 @@ -// @ts-check + import { InvalidArgumentError } from 'commander' import inquirer from 'inquirer' import pick from 'lodash/pick.js' @@ -10,6 +10,7 @@ import { configureRepo } from '../../utils/init/config.mjs' import { track } from '../../utils/telemetry/index.mjs' import { link } from '../link/index.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. export const getSiteNameInput = async (name) => { if (!name) { const { name: nameInput } = await inquirer.prompt([ @@ -32,6 +33,7 @@ export const getSiteNameInput = async (name) => { * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const sitesCreate = async (options, command) => { const { api } = command.netlify @@ -46,6 +48,7 @@ export const sitesCreate = async (options, command) => { type: 'list', name: 'accountSlug', message: 'Team:', + // @ts-expect-error TS(7006) FIXME: Parameter 'account' implicitly has an 'any' type. choices: accounts.map((account) => ({ value: account.slug, name: account.name, @@ -58,11 +61,13 @@ export const sitesCreate = async (options, command) => { let site // Allow the user to reenter site name if selected one isn't available + // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. const inputSiteName = async (name) => { const { name: siteName } = await getSiteNameInput(name) const body = {} if (typeof siteName === 'string') { + // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type '{}'. body.name = siteName.trim() } try { @@ -71,10 +76,13 @@ export const sitesCreate = async (options, command) => { body, }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 422) { warn(`${siteName}.netlify.app already exists. Please try a different slug.`) + // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. await inputSiteName() } else { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(`createSiteInTeam error: ${error_.status}: ${error_.message}`) } } @@ -85,24 +93,31 @@ export const sitesCreate = async (options, command) => { log(chalk.greenBright.bold.underline(`Site Created`)) log() + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. const siteUrl = site.ssl_url || site.url log( prettyjson.render({ + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. 'Admin URL': site.admin_url, URL: siteUrl, + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. 'Site ID': site.id, }), ) track('sites_created', { + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. siteId: site.id, + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. adminUrl: site.admin_url, siteUrl, }) if (options.withCi) { log('Configuring CI') + // @ts-expect-error TS(2345) FIXME: Argument of type '{ workingDir: any; }' is not ass... Remove this comment to see the full error message const repoData = await getRepoData({ workingDir: command.workingDir }) + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. await configureRepo({ command, siteId: site.id, repoData, manual: options.manual }) } @@ -138,6 +153,7 @@ export const sitesCreate = async (options, command) => { if (!options.disableLinking) { log() + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. await link({ id: site.id }, command) } @@ -145,6 +161,7 @@ export const sitesCreate = async (options, command) => { } const MAX_SITE_NAME_LENGTH = 63 +// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. const validateName = function (value) { // netlify sites:create --name if (typeof value === 'string' && value.length > MAX_SITE_NAME_LENGTH) { @@ -159,6 +176,7 @@ const validateName = function (value) { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createSitesCreateCommand = (program) => program .command('sites:create') diff --git a/src/commands/sites/sites-delete.mjs b/src/commands/sites/sites-delete.mts similarity index 89% rename from src/commands/sites/sites-delete.mjs rename to src/commands/sites/sites-delete.mts index ec4f0014bec..9d600324724 100644 --- a/src/commands/sites/sites-delete.mjs +++ b/src/commands/sites/sites-delete.mts @@ -1,4 +1,4 @@ -// @ts-check + import inquirer from 'inquirer' import { chalk, error, exit, log } from '../../utils/command-helpers.mjs' @@ -9,6 +9,7 @@ import { chalk, error, exit, log } from '../../utils/command-helpers.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'siteId' implicitly has an 'any' type. const sitesDelete = async (siteId, options, command) => { command.setAnalyticsPayload({ force: options.force }) @@ -22,6 +23,7 @@ const sitesDelete = async (siteId, options, command) => { try { siteData = await api.getSite({ siteId }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 404) { error(`No site with id ${siteId} found. Please verify the siteId & try again.`) } @@ -78,9 +80,11 @@ const sitesDelete = async (siteId, options, command) => { try { await api.deleteSite({ site_id: siteId }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 404) { error(`No site with id ${siteId} found. Please verify the siteId & try again.`) } else { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(`Delete Site error: ${error_.status}: ${error_.message}`) } } @@ -92,6 +96,7 @@ const sitesDelete = async (siteId, options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createSitesDeleteCommand = (program) => program .command('sites:delete') diff --git a/src/commands/sites/sites-list.mjs b/src/commands/sites/sites-list.mts similarity index 76% rename from src/commands/sites/sites-list.mjs rename to src/commands/sites/sites-list.mts index 453d258524d..a3edbef24fc 100644 --- a/src/commands/sites/sites-list.mjs +++ b/src/commands/sites/sites-list.mts @@ -1,4 +1,4 @@ -// @ts-check + import { listSites } from '../../lib/api.mjs' import { startSpinner, stopSpinner } from '../../lib/spinner.mjs' import { chalk, log, logJson } from '../../utils/command-helpers.mjs' @@ -9,6 +9,7 @@ import { chalk, log, logJson } from '../../utils/command-helpers.mjs' * @param {import('../base-command.mjs').default} command * @returns {Promise<{ id: any; name: any; ssl_url: any; account_name: any; }|boolean>} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const sitesList = async (options, command) => { const { api } = command.netlify /** @type {import('ora').Ora} */ @@ -20,10 +21,12 @@ const sitesList = async (options, command) => { const sites = await listSites({ api, options: { filter: 'all' } }) if (!options.json) { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ spinner: Ora | undefined; }' i... Remove this comment to see the full error message stopSpinner({ spinner }) } if (sites && sites.length !== 0) { + // @ts-expect-error TS(7006) FIXME: Parameter 'site' implicitly has an 'any' type. const logSites = sites.map((site) => { const siteInfo = { id: site.id, @@ -33,6 +36,7 @@ const sitesList = async (options, command) => { } if (site.build_settings && site.build_settings.repo_url) { + // @ts-expect-error TS(2339) FIXME: Property 'repo_url' does not exist on type '{ id: ... Remove this comment to see the full error message siteInfo.repo_url = site.build_settings.repo_url } @@ -41,6 +45,7 @@ const sitesList = async (options, command) => { // Json response for piping commands if (options.json) { + // @ts-expect-error TS(7006) FIXME: Parameter 'site' implicitly has an 'any' type. const redactedSites = sites.map((site) => { if (site && site.build_settings) { delete site.build_settings.env @@ -59,6 +64,7 @@ const sitesList = async (options, command) => { Count: ${logSites.length} `) + // @ts-expect-error TS(7006) FIXME: Parameter 'logSite' implicitly has an 'any' type. logSites.forEach((logSite) => { log(`${chalk.greenBright(logSite.name)} - ${logSite.id}`) log(` ${chalk.whiteBright.bold('url:')} ${chalk.yellowBright(logSite.ssl_url)}`) @@ -77,11 +83,13 @@ Count: ${logSites.length} * Creates the `netlify sites:list` command * @param {import('../base-command.mjs').default} program */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createSitesListCommand = (program) => program .command('sites:list') .description('List all sites you have access to') .option('--json', 'Output site data as JSON') + // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. .action(async (options, command) => { await sitesList(options, command) }) diff --git a/src/commands/sites/sites.mjs b/src/commands/sites/sites.mts similarity index 85% rename from src/commands/sites/sites.mjs rename to src/commands/sites/sites.mts index 8983c0363b9..69728fa3f21 100644 --- a/src/commands/sites/sites.mjs +++ b/src/commands/sites/sites.mts @@ -1,4 +1,4 @@ -// @ts-check + import { createSitesFromTemplateCommand } from './sites-create-template.mjs' import { createSitesCreateCommand } from './sites-create.mjs' import { createSitesDeleteCommand } from './sites-delete.mjs' @@ -9,6 +9,7 @@ import { createSitesListCommand } from './sites-list.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const sites = (options, command) => { command.help() } @@ -18,6 +19,7 @@ const sites = (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createSitesCommand = (program) => { createSitesCreateCommand(program) createSitesFromTemplateCommand(program) diff --git a/src/commands/status/index.mjs b/src/commands/status/index.mts similarity index 100% rename from src/commands/status/index.mjs rename to src/commands/status/index.mts diff --git a/src/commands/status/status-hooks.mjs b/src/commands/status/status-hooks.mts similarity index 71% rename from src/commands/status/status-hooks.mjs rename to src/commands/status/status-hooks.mts index 56603e4e57f..633a303f267 100644 --- a/src/commands/status/status-hooks.mjs +++ b/src/commands/status/status-hooks.mts @@ -1,4 +1,4 @@ -// @ts-check + import prettyjson from 'prettyjson' import { log } from '../../utils/command-helpers.mjs' @@ -9,6 +9,7 @@ import requiresSiteInfo from '../../utils/hooks/requires-site-info.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const statusHooks = async (options, command) => { const { api, siteInfo } = command.netlify @@ -19,7 +20,9 @@ const statusHooks = async (options, command) => { site: siteInfo.name, hooks: {}, } + // @ts-expect-error TS(7006) FIXME: Parameter 'hook' implicitly has an 'any' type. ntlHooks.forEach((hook) => { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message data.hooks[hook.id] = { type: hook.type, event: hook.event, @@ -27,6 +30,7 @@ const statusHooks = async (options, command) => { disabled: hook.disabled, } if (siteInfo.build_settings?.repo_url) { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message data.hooks[hook.id].repo_url = siteInfo.build_settings.repo_url } }) @@ -41,6 +45,7 @@ Site Hook Status │ * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createStatusHooksCommand = (program) => program .command('status:hooks') diff --git a/src/commands/status/status.mjs b/src/commands/status/status.mts similarity index 73% rename from src/commands/status/status.mjs rename to src/commands/status/status.mts index 6772f244746..2047035cb9b 100644 --- a/src/commands/status/status.mjs +++ b/src/commands/status/status.mts @@ -1,4 +1,4 @@ -// @ts-check + import clean from 'clean-deep' import prettyjson from 'prettyjson' @@ -11,9 +11,11 @@ import { createStatusHooksCommand } from './status-hooks.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const status = async (options, command) => { const { api, globalConfig, site } = command.netlify const current = globalConfig.get('userId') + // @ts-expect-error TS(2554) FIXME: Expected 1 arguments, but got 0. const [accessToken] = await getToken() if (!accessToken) { @@ -33,8 +35,9 @@ const status = async (options, command) => { let user try { - ;[accounts, user] = await Promise.all([api.listAccountsForUser(), api.getCurrentUser()]) + [accounts, user] = await Promise.all([api.listAccountsForUser(), api.getCurrentUser()]) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 401) { error('Your session has expired. Please try to re-authenticate by running `netlify logout` and `netlify login`.') } @@ -48,12 +51,16 @@ const status = async (options, command) => { } const teamsData = {} + // @ts-expect-error TS(7006) FIXME: Parameter 'team' implicitly has an 'any' type. accounts.forEach((team) => { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message teamsData[team.name] = team.roles_allowed.join(' ') }) + // @ts-expect-error TS(2339) FIXME: Property 'Teams' does not exist on type '{ Name: a... Remove this comment to see the full error message accountData.Teams = teamsData + // @ts-expect-error const cleanAccountData = clean(accountData) log(prettyjson.render(cleanAccountData)) @@ -67,19 +74,23 @@ const status = async (options, command) => { siteData = await api.getSite({ siteId }) } catch (error_) { // unauthorized + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 401) { warn(`Log in with a different account or re-link to a site you have permission for`) error(`Not authorized to view the currently linked site (${siteId})`) } // missing + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 404) { error(`The site this folder is linked to can't be found`) } + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } // Json only logs out if --json flag is passed if (options.json) { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ account: Partial<{ Name: any; ... Remove this comment to see the full error message logJson({ account: cleanAccountData, siteData: { @@ -112,6 +123,7 @@ const status = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createStatusCommand = (program) => { createStatusHooksCommand(program) diff --git a/src/commands/switch/index.mjs b/src/commands/switch/index.mts similarity index 100% rename from src/commands/switch/index.mjs rename to src/commands/switch/index.mts diff --git a/src/commands/switch/switch.mjs b/src/commands/switch/switch.mts similarity index 74% rename from src/commands/switch/switch.mjs rename to src/commands/switch/switch.mts index 196d0b2e4ae..b7a2ca702b7 100644 --- a/src/commands/switch/switch.mjs +++ b/src/commands/switch/switch.mts @@ -1,4 +1,4 @@ -// @ts-check + import inquirer from 'inquirer' import { chalk, log } from '../../utils/command-helpers.mjs' @@ -11,9 +11,11 @@ const LOGIN_NEW = 'I would like to login to a new account' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const switchCommand = async (options, command) => { const availableUsersChoices = Object.values(command.netlify.globalConfig.get('users') || {}).reduce( (prev, current) => + // @ts-expect-error TS(2769) FIXME: No overload matches this call. Object.assign(prev, { [current.id]: current.name ? `${current.name} (${current.email})` : current.email }), {}, ) @@ -23,6 +25,7 @@ const switchCommand = async (options, command) => { type: 'list', name: 'accountSwitchChoice', message: 'Please select the account you want to use:', + // @ts-expect-error TS(2769) FIXME: No overload matches this call. choices: [...Object.entries(availableUsersChoices).map(([, val]) => val), LOGIN_NEW], }, ]) @@ -30,11 +33,14 @@ const switchCommand = async (options, command) => { if (accountSwitchChoice === LOGIN_NEW) { await login({ new: true }, command) } else { + // @ts-expect-error TS(2769) FIXME: No overload matches this call. const selectedAccount = Object.entries(availableUsersChoices).find( ([, availableUsersChoice]) => availableUsersChoice === accountSwitchChoice, ) + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. command.netlify.globalConfig.set('userId', selectedAccount[0]) log('') + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. log(`You're now using ${chalk.bold(selectedAccount[1])}.`) } } @@ -44,5 +50,6 @@ const switchCommand = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createSwitchCommand = (program) => program.command('switch').description('Switch your active Netlify account').action(switchCommand) diff --git a/src/commands/unlink/index.mjs b/src/commands/unlink/index.mts similarity index 100% rename from src/commands/unlink/index.mjs rename to src/commands/unlink/index.mts diff --git a/src/commands/unlink/unlink.mjs b/src/commands/unlink/unlink.mts similarity index 85% rename from src/commands/unlink/unlink.mjs rename to src/commands/unlink/unlink.mts index 25df772d794..fa330fbffc9 100644 --- a/src/commands/unlink/unlink.mjs +++ b/src/commands/unlink/unlink.mts @@ -1,4 +1,4 @@ -// @ts-check + import { exit, log } from '../../utils/command-helpers.mjs' import { track } from '../../utils/telemetry/index.mjs' @@ -7,6 +7,7 @@ import { track } from '../../utils/telemetry/index.mjs' * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const unlink = async (options, command) => { const { site, siteInfo, state } = command.netlify const siteId = site.id @@ -36,5 +37,6 @@ const unlink = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createUnlinkCommand = (program) => program.command('unlink').description('Unlink a local folder from a Netlify site').action(unlink) diff --git a/src/commands/watch/index.mjs b/src/commands/watch/index.mts similarity index 100% rename from src/commands/watch/index.mjs rename to src/commands/watch/index.mts diff --git a/src/commands/watch/watch.mjs b/src/commands/watch/watch.mts similarity index 81% rename from src/commands/watch/watch.mjs rename to src/commands/watch/watch.mts index 63518c3ee69..36074c30b0d 100644 --- a/src/commands/watch/watch.mjs +++ b/src/commands/watch/watch.mts @@ -1,4 +1,4 @@ -// @ts-check + import pWaitFor from 'p-wait-for' import prettyjson from 'prettyjson' @@ -21,18 +21,21 @@ const BUILD_FINISH_TIMEOUT = 12e5 * @param {import('ora').Ora} spinner * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'api' implicitly has an 'any' type. const waitForBuildFinish = async function (api, siteId, spinner) { let firstPass = true const waitForBuildToFinish = async function () { const builds = await api.listSiteBuilds({ siteId }) // build.error + // @ts-expect-error TS(7006) FIXME: Parameter 'build' implicitly has an 'any' type. const currentBuilds = builds.filter((build) => !build.done) // if build.error // @TODO implement build error messages into this if (!currentBuilds || currentBuilds.length === 0) { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ spinner: any; }' is not assign... Remove this comment to see the full error message stopSpinner({ spinner }) return true } @@ -57,6 +60,7 @@ const waitForBuildFinish = async function (api, siteId, spinner) { * @param {import('commander').OptionValues} options * @param {import('../base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const watch = async (options, command) => { await command.authenticate() const client = command.netlify.api @@ -71,6 +75,7 @@ const watch = async (options, command) => { // wait for 1 sec for everything to kickoff console.time('Deploy time') await new Promise((resolve) => { + // @ts-expect-error TS(2794) FIXME: Expected 1 arguments, but got 0. Did you forget to... Remove this comment to see the full error message setTimeout(() => resolve(), INIT_WAIT) }) @@ -114,6 +119,7 @@ const watch = async (options, command) => { ) console.timeEnd('Deploy time') } catch (error_) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } @@ -123,6 +129,7 @@ const watch = async (options, command) => { * @param {import('../base-command.mjs').default} program * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. export const createWatchCommand = (program) => program .command('watch') diff --git a/src/functions-templates/javascript/hello/{{name}}.js b/src/functions-templates/javascript/hello/{{name}}.js index b15a882471c..0dec5c39fd4 100644 --- a/src/functions-templates/javascript/hello/{{name}}.js +++ b/src/functions-templates/javascript/hello/{{name}}.js @@ -1,5 +1,4 @@ -export default async (request) => { - return new Response('Hello, World!', { +export default async (request) => + new Response('Hello, World!', { headers: { 'content-type': 'text/html' }, }) -} diff --git a/src/lib/account.mjs b/src/lib/account.mts similarity index 67% rename from src/lib/account.mjs rename to src/lib/account.mts index c9923609a81..f9ab875b908 100644 --- a/src/lib/account.mjs +++ b/src/lib/account.mts @@ -1,14 +1,16 @@ -// @ts-check + /** * @param {any} account * @param {string} capability * @returns {boolean} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'account' implicitly has an 'any' type. const supportsBooleanCapability = (account, capability) => Boolean(account?.capabilities?.[capability]?.included) /** * @param {any} account * @returns {boolean} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'account' implicitly has an 'any' type. export const supportsBackgroundFunctions = (account) => supportsBooleanCapability(account, 'background_functions') diff --git a/src/lib/api.mjs b/src/lib/api.mts similarity index 69% rename from src/lib/api.mjs rename to src/lib/api.mts index bce2b2e671d..369ce342c1c 100644 --- a/src/lib/api.mjs +++ b/src/lib/api.mts @@ -1,9 +1,11 @@ import { warn } from '../utils/command-helpers.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message export const cancelDeploy = async ({ api, deployId }) => { try { await api.cancelSiteDeploy({ deploy_id: deployId }) } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. warn(`Failed canceling deploy with id ${deployId}: ${error.message}`) } } @@ -11,6 +13,7 @@ export const cancelDeploy = async ({ api, deployId }) => { const FIRST_PAGE = 1 const MAX_PAGES = 10 const MAX_PER_PAGE = 100 +// @ts-expect-error TS(7023) FIXME: 'listSites' implicitly has return type 'any' becau... Remove this comment to see the full error message export const listSites = async ({ api, options }) => { const { maxPages = MAX_PAGES, page = FIRST_PAGE, ...rest } = options const sites = await api.listSites({ page, per_page: MAX_PER_PAGE, ...rest }) diff --git a/src/lib/blobs/blobs.mjs b/src/lib/blobs/blobs.mts similarity index 73% rename from src/lib/blobs/blobs.mjs rename to src/lib/blobs/blobs.mts index ed7df652cc0..5dfdb31ed44 100644 --- a/src/lib/blobs/blobs.mjs +++ b/src/lib/blobs/blobs.mts @@ -1,6 +1,7 @@ import path from 'path' import { BlobsServer } from '@netlify/blobs' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'uuid... Remove this comment to see the full error message import { v4 as uuidv4 } from 'uuid' import { getPathInProject } from '../settings.mjs' @@ -24,6 +25,7 @@ import { getPathInProject } from '../settings.mjs' * @param {string} options.siteID * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'debug' implicitly has an 'any' ty... Remove this comment to see the full error message export const getBlobsContext = async ({ debug, projectRoot, siteID }) => { const token = uuidv4() const { port } = await startBlobsServer({ debug, projectRoot, token }) @@ -37,6 +39,7 @@ export const getBlobsContext = async ({ debug, projectRoot, siteID }) => { return context } +// @ts-expect-error TS(7031) FIXME: Binding element 'debug' implicitly has an 'any' ty... Remove this comment to see the full error message const startBlobsServer = async ({ debug, projectRoot, token }) => { const directory = path.resolve(projectRoot, getPathInProject(['blobs'])) const server = new BlobsServer({ diff --git a/src/lib/build.mjs b/src/lib/build.mts similarity index 68% rename from src/lib/build.mjs rename to src/lib/build.mts index a538aacd136..018961fd5fa 100644 --- a/src/lib/build.mjs +++ b/src/lib/build.mts @@ -1,8 +1,8 @@ -// @ts-check import fs from 'fs' import process from 'process' import build from '@netlify/build' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'toml... Remove this comment to see the full error message import tomlify from 'tomlify-j0.4' import { isFeatureFlagEnabled } from '../utils/feature-flags.mjs' @@ -31,15 +31,22 @@ import { featureFlags as edgeFunctionsFeatureFlags } from './edge-functions/cons * @returns {BuildConfig} */ export const getBuildOptions = ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'cachedConfig' implicitly has an '... Remove this comment to see the full error message cachedConfig, + // @ts-expect-error TS(7031) FIXME: Binding element 'currentDir' implicitly has an 'an... Remove this comment to see the full error message currentDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'deployHandler' implicitly has an ... Remove this comment to see the full error message deployHandler, + // @ts-expect-error TS(7031) FIXME: Binding element 'context' implicitly has an 'any' ... Remove this comment to see the full error message options: { context, cwd, debug, dry, json, offline, silent }, + // @ts-expect-error TS(7031) FIXME: Binding element 'packagePath' implicitly has an 'a... Remove this comment to see the full error message packagePath, + // @ts-expect-error TS(7031) FIXME: Binding element 'token' implicitly has an 'any' ty... Remove this comment to see the full error message token, }) => { const eventHandlers = { onEnd: { + // @ts-expect-error TS(7031) FIXME: Binding element 'netlifyConfig' implicitly has an ... Remove this comment to see the full error message handler: ({ netlifyConfig }) => { const string = tomlify.toToml(netlifyConfig) @@ -55,6 +62,7 @@ export const getBuildOptions = ({ } if (deployHandler) { + // @ts-expect-error TS(2339) FIXME: Property 'onPostBuild' does not exist on type '{ o... Remove this comment to see the full error message eventHandlers.onPostBuild = { handler: deployHandler, description: 'Deploy Site', @@ -89,6 +97,7 @@ export const getBuildOptions = ({ * @param {*} siteInfo * @returns {Record} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'siteInfo' implicitly has an 'any' type. const getFeatureFlagsFromSiteInfo = (siteInfo) => ({ ...siteInfo.feature_flags, // see https://github.com/netlify/pod-dev-foundations/issues/581#issuecomment-1731022753 @@ -100,6 +109,7 @@ const getFeatureFlagsFromSiteInfo = (siteInfo) => ({ * @param {BuildConfig} options * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const runBuild = async (options) => { // If netlify NETLIFY_API_URL is set we need to pass this information to @netlify/build // TODO don't use testOpts, but add real properties to do this. diff --git a/src/lib/completion/constants.mjs b/src/lib/completion/constants.mts similarity index 90% rename from src/lib/completion/constants.mjs rename to src/lib/completion/constants.mts index b29329fa962..8a6b6113f60 100644 --- a/src/lib/completion/constants.mjs +++ b/src/lib/completion/constants.mts @@ -1,4 +1,4 @@ -// @ts-check + import { getPathInHome } from '../settings.mjs' export const AUTOCOMPLETION_FILE = getPathInHome(['autocompletion.json']) diff --git a/src/lib/completion/generate-autocompletion.mjs b/src/lib/completion/generate-autocompletion.mts similarity index 79% rename from src/lib/completion/generate-autocompletion.mjs rename to src/lib/completion/generate-autocompletion.mts index 527f92136a8..8f00ae94a34 100644 --- a/src/lib/completion/generate-autocompletion.mjs +++ b/src/lib/completion/generate-autocompletion.mts @@ -1,4 +1,4 @@ -// @ts-check + import fs from 'fs' import { dirname } from 'path' @@ -11,17 +11,21 @@ import { AUTOCOMPLETION_FILE } from './constants.mjs' * @param {import('../../commands/base-command.mjs').default} program * @returns {void} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'program' implicitly has an 'any' type. const generateAutocompletion = (program) => { try { const autocomplete = program.commands.reduce( + // @ts-expect-error TS(7006) FIXME: Parameter 'prev' implicitly has an 'any' type. (prev, cmd) => ({ ...prev, [cmd.name()]: { name: cmd.name(), description: cmd.description().split('\n')[0], options: cmd.options + // @ts-expect-error TS(7006) FIXME: Parameter 'option' implicitly has an 'any' type. .filter((option) => !option.hidden) .sort(sortOptions) + // @ts-expect-error TS(7006) FIXME: Parameter 'opt' implicitly has an 'any' type. .map((opt) => ({ name: `--${opt.name()}`, description: opt.description })), }, }), diff --git a/src/lib/completion/get-autocompletion.mjs b/src/lib/completion/get-autocompletion.mts similarity index 69% rename from src/lib/completion/get-autocompletion.mjs rename to src/lib/completion/get-autocompletion.mts index b58b51e3f27..d1d932f6c8c 100644 --- a/src/lib/completion/get-autocompletion.mjs +++ b/src/lib/completion/get-autocompletion.mts @@ -1,4 +1,4 @@ -// @ts-check + /** * @typedef CompletionItem @@ -10,12 +10,14 @@ * @param {Record} program * @returns {CompletionItem[]|void} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'env' implicitly has an 'any' type. const getAutocompletion = function (env, program) { if (!env.complete) { return } // means that we are currently in the first command (the root command) if (env.words === 1) { + // @ts-expect-error TS(2345) FIXME: Argument of type '({ description, name }: { descri... Remove this comment to see the full error message const rootCommands = Object.values(program).map(({ description, name }) => ({ name, description })) // suggest all commands @@ -26,6 +28,7 @@ const getAutocompletion = function (env, program) { // $ netlify add // we can now check if a command starts with the last partial + // @ts-expect-error TS(2769) FIXME: No overload matches this call. const autocomplete = rootCommands.filter(({ name }) => name.startsWith(env.lastPartial)) return autocomplete } @@ -34,9 +37,11 @@ const getAutocompletion = function (env, program) { if (program[command]) { const usedArgs = new Set(args) + // @ts-expect-error TS(7031) FIXME: Binding element 'name' implicitly has an 'any' typ... Remove this comment to see the full error message const unusedOptions = program[command].options.filter(({ name }) => !usedArgs.has(name)) if (env.lastPartial.length !== 0) { + // @ts-expect-error TS(7031) FIXME: Binding element 'name' implicitly has an 'any' typ... Remove this comment to see the full error message return unusedOptions.filter(({ name }) => name.startsWith(env.lastPartial)) } diff --git a/src/lib/completion/index.mjs b/src/lib/completion/index.mts similarity index 100% rename from src/lib/completion/index.mjs rename to src/lib/completion/index.mts diff --git a/src/lib/completion/script.mjs b/src/lib/completion/script.mts similarity index 87% rename from src/lib/completion/script.mjs rename to src/lib/completion/script.mts index f15ab5cce58..8b8565bcc45 100755 --- a/src/lib/completion/script.mjs +++ b/src/lib/completion/script.mts @@ -1,5 +1,5 @@ #!/usr/bin/env node -// @ts-check + // This script is run by the completion (every log output will be displayed on tab) // src/commands/completion/completion.mjs -> dynamically references this file @@ -7,6 +7,7 @@ import { existsSync, readFileSync } from 'fs' import process from 'process' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'tabt... Remove this comment to see the full error message import { log, parseEnv } from 'tabtab' import { AUTOCOMPLETION_FILE } from './constants.mjs' diff --git a/src/lib/edge-functions/bootstrap.mjs b/src/lib/edge-functions/bootstrap.mts similarity index 100% rename from src/lib/edge-functions/bootstrap.mjs rename to src/lib/edge-functions/bootstrap.mts diff --git a/src/lib/edge-functions/consts.mjs b/src/lib/edge-functions/consts.mts similarity index 100% rename from src/lib/edge-functions/consts.mjs rename to src/lib/edge-functions/consts.mts diff --git a/src/lib/edge-functions/deploy.mjs b/src/lib/edge-functions/deploy.mts similarity index 74% rename from src/lib/edge-functions/deploy.mjs rename to src/lib/edge-functions/deploy.mts index fba6549298f..60eeaf463d2 100644 --- a/src/lib/edge-functions/deploy.mjs +++ b/src/lib/edge-functions/deploy.mts @@ -1,4 +1,4 @@ -// @ts-check + import { stat } from 'fs/promises' import { join } from 'path' @@ -12,6 +12,7 @@ const distPath = getPathInProject([EDGE_FUNCTIONS_FOLDER]) * @param {string} workingDir * @param {*} file */ +// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message export const deployFileNormalizer = (workingDir, file) => { const absoluteDistPath = join(workingDir, distPath) const isEdgeFunction = file.root === absoluteDistPath @@ -26,6 +27,7 @@ export const deployFileNormalizer = (workingDir, file) => { /** * @param {string} workingDir */ +// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message export const getDistPathIfExists = async (workingDir) => { try { const absoluteDistPath = join(workingDir, distPath) @@ -41,4 +43,5 @@ export const getDistPathIfExists = async (workingDir) => { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'filePath' implicitly has an 'any' type. export const isEdgeFunctionFile = (filePath) => filePath.startsWith(`${PUBLIC_URL_PATH}/`) diff --git a/src/lib/edge-functions/editor-helper.mjs b/src/lib/edge-functions/editor-helper.mts similarity index 90% rename from src/lib/edge-functions/editor-helper.mjs rename to src/lib/edge-functions/editor-helper.mts index 8eea604aaa1..2e96b789cd1 100644 --- a/src/lib/edge-functions/editor-helper.mjs +++ b/src/lib/edge-functions/editor-helper.mts @@ -6,6 +6,7 @@ import { runRecipe } from '../../commands/recipes/index.mjs' const STATE_PROMPT_PROPERTY = 'promptVSCodeSettings' +// @ts-expect-error TS(7031) FIXME: Binding element 'NETLIFYDEVLOG' implicitly has an ... Remove this comment to see the full error message export const promptEditorHelper = async ({ NETLIFYDEVLOG, chalk, config, log, repositoryRoot, state }) => { // This prevents tests from hanging when running them inside the VS Code // terminal, as otherwise we'll show the prompt and wait for a response. diff --git a/src/lib/edge-functions/headers.mjs b/src/lib/edge-functions/headers.mts similarity index 81% rename from src/lib/edge-functions/headers.mjs rename to src/lib/edge-functions/headers.mts index 1c788ddfe7d..139d4fdff04 100644 --- a/src/lib/edge-functions/headers.mjs +++ b/src/lib/edge-functions/headers.mts @@ -1,4 +1,4 @@ -// @ts-check + import { Buffer } from 'buffer' export const headers = { @@ -26,7 +26,9 @@ export const headers = { * @param {Array} featureFlags * @returns {string} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'featureFlags' implicitly has an 'any' t... Remove this comment to see the full error message export const getFeatureFlagsHeader = (featureFlags) => { + // @ts-expect-error TS(7006) FIXME: Parameter 'acc' implicitly has an 'any' type. const featureFlagsObject = featureFlags.reduce((acc, flagName) => ({ ...acc, [flagName]: true }), {}) return Buffer.from(JSON.stringify(featureFlagsObject)).toString('base64') @@ -39,4 +41,5 @@ export const getFeatureFlagsHeader = (featureFlags) => { * @param {object} metadata * @returns {string} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'metadata' implicitly has an 'any' type. export const getInvocationMetadataHeader = (metadata) => Buffer.from(JSON.stringify(metadata)).toString('base64') diff --git a/src/lib/edge-functions/internal.mjs b/src/lib/edge-functions/internal.mts similarity index 72% rename from src/lib/edge-functions/internal.mjs rename to src/lib/edge-functions/internal.mts index 630523148a3..bdac806f02f 100644 --- a/src/lib/edge-functions/internal.mjs +++ b/src/lib/edge-functions/internal.mts @@ -1,4 +1,4 @@ -// @ts-check + import { readFile, stat } from 'fs/promises' import { dirname, join, resolve } from 'path' @@ -9,6 +9,7 @@ import { INTERNAL_EDGE_FUNCTIONS_FOLDER } from './consts.mjs' /** * @param {string} workingDir */ +// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message export const getInternalFunctions = async (workingDir) => { const path = join(workingDir, getPathInProject([INTERNAL_EDGE_FUNCTIONS_FOLDER])) @@ -27,6 +28,7 @@ export const getInternalFunctions = async (workingDir) => { try { const manifestPath = join(path, 'manifest.json') + // @ts-expect-error TS(2345) FIXME: Argument of type 'Buffer' is not assignable to par... Remove this comment to see the full error message const manifest = JSON.parse(await readFile(manifestPath)) if (manifest.version !== 1) { @@ -39,6 +41,7 @@ export const getInternalFunctions = async (workingDir) => { } if (manifest.import_map) { + // @ts-expect-error TS(2339) FIXME: Property 'importMap' does not exist on type '{ fun... Remove this comment to see the full error message data.importMap = resolve(dirname(manifestPath), manifest.import_map) } diff --git a/src/lib/edge-functions/proxy.mjs b/src/lib/edge-functions/proxy.mts similarity index 57% rename from src/lib/edge-functions/proxy.mjs rename to src/lib/edge-functions/proxy.mts index bc9069e6e0f..49a889dc0b6 100644 --- a/src/lib/edge-functions/proxy.mjs +++ b/src/lib/edge-functions/proxy.mts @@ -1,4 +1,4 @@ -// @ts-check + import { Buffer } from 'buffer' import { rm } from 'fs/promises' import { join, resolve } from 'path' @@ -23,12 +23,15 @@ const headersSymbol = Symbol('Edge Functions Headers') const LOCAL_HOST = '127.0.0.1' const getDownloadUpdateFunctions = () => { + // @ts-expect-error TS(7034) FIXME: Variable 'spinner' implicitly has type 'any' in so... Remove this comment to see the full error message let spinner /** * @param {Error=} error_ */ + // @ts-expect-error TS(7006) FIXME: Parameter 'error_' implicitly has an 'any' type. const onAfterDownload = (error_) => { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ error: boolean; spinner: any; ... Remove this comment to see the full error message stopSpinner({ error: Boolean(error_), spinner }) } @@ -42,6 +45,7 @@ const getDownloadUpdateFunctions = () => { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. export const handleProxyRequest = (req, proxyReq) => { Object.entries(req[headersSymbol]).forEach(([header, value]) => { proxyReq.setHeader(header, value) @@ -49,6 +53,7 @@ export const handleProxyRequest = (req, proxyReq) => { } export const createSiteInfoHeader = (siteInfo = {}) => { + // @ts-expect-error TS(2339) FIXME: Property 'id' does not exist on type '{}'. const { id, name, url } = siteInfo const site = { id, name, url } const siteString = JSON.stringify(site) @@ -56,6 +61,7 @@ export const createSiteInfoHeader = (siteInfo = {}) => { } export const createAccountInfoHeader = (accountInfo = {}) => { + // @ts-expect-error TS(2339) FIXME: Property 'id' does not exist on type '{}'. const { id } = accountInfo const account = { id } const accountString = JSON.stringify(account) @@ -85,27 +91,46 @@ export const createAccountInfoHeader = (accountInfo = {}) => { * @returns */ export const initializeProxy = async ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'accountId' implicitly has an 'any... Remove this comment to see the full error message accountId, + // @ts-expect-error TS(7031) FIXME: Binding element 'blobsContext' implicitly has an '... Remove this comment to see the full error message blobsContext, + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message config, + // @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message configPath, + // @ts-expect-error TS(7031) FIXME: Binding element 'debug' implicitly has an 'any' ty... Remove this comment to see the full error message debug, + // @ts-expect-error TS(7031) FIXME: Binding element 'configEnv' implicitly has an 'any... Remove this comment to see the full error message env: configEnv, + // @ts-expect-error TS(7031) FIXME: Binding element 'geoCountry' implicitly has an 'an... Remove this comment to see the full error message geoCountry, + // @ts-expect-error TS(7031) FIXME: Binding element 'geolocationMode' implicitly has a... Remove this comment to see the full error message geolocationMode, + // @ts-expect-error TS(7031) FIXME: Binding element 'getUpdatedConfig' implicitly has ... Remove this comment to see the full error message getUpdatedConfig, + // @ts-expect-error TS(7031) FIXME: Binding element 'inspectSettings' implicitly has a... Remove this comment to see the full error message inspectSettings, + // @ts-expect-error TS(7031) FIXME: Binding element 'mainPort' implicitly has an 'any'... Remove this comment to see the full error message mainPort, + // @ts-expect-error TS(7031) FIXME: Binding element 'offline' implicitly has an 'any' ... Remove this comment to see the full error message offline, + // @ts-expect-error TS(7031) FIXME: Binding element 'passthroughPort' implicitly has a... Remove this comment to see the full error message passthroughPort, + // @ts-expect-error TS(7031) FIXME: Binding element 'projectDir' implicitly has an 'an... Remove this comment to see the full error message projectDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'repositoryRoot' implicitly has an... Remove this comment to see the full error message repositoryRoot, + // @ts-expect-error TS(7031) FIXME: Binding element 'settings' implicitly has an 'any'... Remove this comment to see the full error message settings, + // @ts-expect-error TS(7031) FIXME: Binding element 'siteInfo' implicitly has an 'any'... Remove this comment to see the full error message siteInfo, + // @ts-expect-error TS(7031) FIXME: Binding element 'state' implicitly has an 'any' ty... Remove this comment to see the full error message state, }) => { const { functions: internalFunctions, + // @ts-expect-error TS(2339) FIXME: Property 'importMap' does not exist on type '{ fun... Remove this comment to see the full error message importMap, path: internalFunctionsPath, } = await getInternalFunctions(projectDir) @@ -137,6 +162,7 @@ export const initializeProxy = async ({ }) const hasEdgeFunctions = userFunctionsPath !== undefined || internalFunctionsPath + // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. return async (req) => { if (req.headers[headers.Passthrough] !== undefined || !hasEdgeFunctions) { return @@ -189,22 +215,37 @@ export const initializeProxy = async ({ } } +// @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. export const isEdgeFunctionsRequest = (req) => req[headersSymbol] !== undefined const prepareServer = async ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message config, + // @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message configPath, + // @ts-expect-error TS(7031) FIXME: Binding element 'debug' implicitly has an 'any' ty... Remove this comment to see the full error message debug, + // @ts-expect-error TS(7031) FIXME: Binding element 'directory' implicitly has an 'any... Remove this comment to see the full error message directory, + // @ts-expect-error TS(7031) FIXME: Binding element 'configEnv' implicitly has an 'any... Remove this comment to see the full error message env: configEnv, + // @ts-expect-error TS(7031) FIXME: Binding element 'featureFlags' implicitly has an '... Remove this comment to see the full error message featureFlags, + // @ts-expect-error TS(7031) FIXME: Binding element 'getUpdatedConfig' implicitly has ... Remove this comment to see the full error message getUpdatedConfig, + // @ts-expect-error TS(7031) FIXME: Binding element 'importMaps' implicitly has an 'an... Remove this comment to see the full error message importMaps, + // @ts-expect-error TS(7031) FIXME: Binding element 'inspectSettings' implicitly has a... Remove this comment to see the full error message inspectSettings, + // @ts-expect-error TS(7031) FIXME: Binding element 'internalDirectory' implicitly has... Remove this comment to see the full error message internalDirectory, + // @ts-expect-error TS(7031) FIXME: Binding element 'internalFunctions' implicitly has... Remove this comment to see the full error message internalFunctions, + // @ts-expect-error TS(7031) FIXME: Binding element 'port' implicitly has an 'any' typ... Remove this comment to see the full error message port, + // @ts-expect-error TS(7031) FIXME: Binding element 'projectDir' implicitly has an 'an... Remove this comment to see the full error message projectDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'repositoryRoot' implicitly has an... Remove this comment to see the full error message repositoryRoot, }) => { // Merging internal with user-defined import maps. @@ -252,6 +293,7 @@ const prepareServer = async ({ return registry } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. printError(error.message, { exit: false }) } } diff --git a/src/lib/edge-functions/registry.mjs b/src/lib/edge-functions/registry.mts similarity index 69% rename from src/lib/edge-functions/registry.mjs rename to src/lib/edge-functions/registry.mts index f8e7ae158cb..2b28a636f87 100644 --- a/src/lib/edge-functions/registry.mjs +++ b/src/lib/edge-functions/registry.mts @@ -1,4 +1,4 @@ -// @ts-check + import { fileURLToPath } from 'url' import { @@ -101,17 +101,29 @@ export class EdgeFunctionsRegistry { * @param {string} opts.servePath */ constructor({ + // @ts-expect-error TS(7031) FIXME: Binding element 'bundler' implicitly has an 'any' ... Remove this comment to see the full error message bundler, + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message config, + // @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message configPath, + // @ts-expect-error TS(7031) FIXME: Binding element 'debug' implicitly has an 'any' ty... Remove this comment to see the full error message debug, + // @ts-expect-error TS(7031) FIXME: Binding element 'directories' implicitly has an 'a... Remove this comment to see the full error message directories, + // @ts-expect-error TS(7031) FIXME: Binding element 'env' implicitly has an 'any' type... Remove this comment to see the full error message env, + // @ts-expect-error TS(7031) FIXME: Binding element 'getUpdatedConfig' implicitly has ... Remove this comment to see the full error message getUpdatedConfig, + // @ts-expect-error TS(7031) FIXME: Binding element 'internalDirectories' implicitly h... Remove this comment to see the full error message internalDirectories, + // @ts-expect-error TS(7031) FIXME: Binding element 'internalFunctions' implicitly has... Remove this comment to see the full error message internalFunctions, + // @ts-expect-error TS(7031) FIXME: Binding element 'projectDir' implicitly has an 'an... Remove this comment to see the full error message projectDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'runIsolate' implicitly has an 'an... Remove this comment to see the full error message runIsolate, + // @ts-expect-error TS(7031) FIXME: Binding element 'servePath' implicitly has an 'any... Remove this comment to see the full error message servePath, }) { this.#bundler = bundler @@ -149,6 +161,7 @@ export class EdgeFunctionsRegistry { const { warnings } = await this.#build() this.#functions.forEach((func) => { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ functionName: any; warnings: a... Remove this comment to see the full error message this.#logEvent('loaded', { functionName: func.name, warnings: warnings[func.name] }) }) } catch { @@ -187,6 +200,7 @@ export class EdgeFunctionsRegistry { /** @type {Record} */ const internalFunctionConfigs = this.#internalFunctions.reduce( + // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'never'. // eslint-disable-next-line no-plusplus (acc, func) => ({ ...acc, [func.name]: functionsConfig[index++] }), {}, @@ -194,6 +208,7 @@ export class EdgeFunctionsRegistry { /** @type {Record} */ const userFunctionConfigs = this.#userFunctions.reduce( + // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'never'. // eslint-disable-next-line no-plusplus (acc, func) => ({ ...acc, [func.name]: functionsConfig[index++] }), {}, @@ -202,18 +217,25 @@ export class EdgeFunctionsRegistry { const { manifest, routes, unroutedFunctions } = this.#buildRoutes(internalFunctionConfigs, userFunctionConfigs) this.#manifest = manifest + // @ts-expect-error TS(2322) FIXME: Type 'any[]' is not assignable to type 'never[]'. this.#routes = routes + // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. unroutedFunctions.forEach((name) => { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message warnings[name] = warnings[name] || [] + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message warnings[name].push( `Edge function is not accessible because it does not have a path configured. Learn more at https://ntl.fyi/edge-create.`, ) }) for (const functionName in userFunctionConfigs) { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message if ('paths' in userFunctionConfigs[functionName]) { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message warnings[functionName] = warnings[functionName] || [] + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message warnings[functionName].push(`Unknown 'paths' configuration property. Did you mean 'path'?`) } } @@ -221,6 +243,7 @@ export class EdgeFunctionsRegistry { this.#processGraph(graph) if (npmSpecifiersWithExtraneousFiles.length !== 0) { + // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. const modules = npmSpecifiersWithExtraneousFiles.map((name) => chalk.yellow(name)).join(', ') log( @@ -230,6 +253,7 @@ export class EdgeFunctionsRegistry { return { warnings } } catch (error) { + // @ts-expect-error TS(2322) FIXME: Type 'unknown' is not assignable to type 'null'. this.#buildError = error throw error @@ -245,6 +269,7 @@ export class EdgeFunctionsRegistry { * @param {Record} internalFunctionConfigs * @param {Record} userFunctionConfigs */ + // @ts-expect-error TS(7006) FIXME: Parameter 'internalFunctionConfigs' implicitly has... Remove this comment to see the full error message #buildRoutes(internalFunctionConfigs, userFunctionConfigs) { const declarations = this.#bundler.mergeDeclarations( this.#declarationsFromTOML, @@ -282,10 +307,12 @@ export class EdgeFunctionsRegistry { const { warnings } = await this.#build() deletedFunctions.forEach((func) => { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ functionName: any; warnings: a... Remove this comment to see the full error message this.#logEvent('removed', { functionName: func.name, warnings: warnings[func.name] }) }) newFunctions.forEach((func) => { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ functionName: any; warnings: a... Remove this comment to see the full error message this.#logEvent('loaded', { functionName: func.name, warnings: warnings[func.name] }) }) } catch { @@ -297,6 +324,7 @@ export class EdgeFunctionsRegistry { * @param {any} config * @returns {Declaration[]} */ + // @ts-expect-error TS(7006) FIXME: Parameter 'config' implicitly has an 'any' type. static #getDeclarationsFromTOML(config) { const { edge_functions: edgeFunctions = [] } = config @@ -307,16 +335,23 @@ export class EdgeFunctionsRegistry { * @param {Record} envConfig * @returns {Record} */ + // @ts-expect-error TS(7006) FIXME: Parameter 'envConfig' implicitly has an 'any' type... Remove this comment to see the full error message static #getEnvironmentVariables(envConfig) { const env = Object.create(null) Object.entries(envConfig).forEach(([key, variable]) => { if ( + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. variable.sources.includes('ui') || + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. variable.sources.includes('account') || + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. variable.sources.includes('addons') || + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. variable.sources.includes('internal') || + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. variable.sources.some((source) => source.startsWith('.env')) ) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. env[key] = variable.value } }) @@ -330,10 +365,13 @@ export class EdgeFunctionsRegistry { * @param {string[]} paths * @returns {Promise} */ + // @ts-expect-error TS(7006) FIXME: Parameter 'paths' implicitly has an 'any' type. async #handleFileChange(paths) { const matchingFunctions = new Set( [ + // @ts-expect-error TS(7006) FIXME: Parameter 'path' implicitly has an 'any' type. ...paths.map((path) => this.#functionPaths.get(path)), + // @ts-expect-error TS(7006) FIXME: Parameter 'path' implicitly has an 'any' type. ...paths.flatMap((path) => this.#dependencyPaths.get(path)), ].filter(Boolean), ) @@ -346,6 +384,7 @@ export class EdgeFunctionsRegistry { return } + // @ts-expect-error TS(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message this.#logEvent('reloading', {}) try { @@ -353,13 +392,16 @@ export class EdgeFunctionsRegistry { const functionNames = [...matchingFunctions] if (functionNames.length === 0) { + // @ts-expect-error TS(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message this.#logEvent('reloaded', {}) } else { functionNames.forEach((functionName) => { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ functionName: any; warnings: a... Remove this comment to see the full error message this.#logEvent('reloaded', { functionName, warnings: warnings[functionName] }) }) } } catch (error) { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ buildError: any; }' is not ass... Remove this comment to see the full error message this.#logEvent('buildError', { buildError: error?.message }) } } @@ -381,6 +423,7 @@ export class EdgeFunctionsRegistry { * @param {string[]} [data.warnings] * @returns */ + // @ts-expect-error TS(7006) FIXME: Parameter 'event' implicitly has an 'any' type. #logEvent(event, { buildError, functionName, warnings = [] }) { const subject = functionName ? `edge function ${chalk.yellow(this.#getDisplayName(functionName))}` @@ -430,22 +473,28 @@ export class EdgeFunctionsRegistry { * @param {string} urlPath * @param {string} method */ + // @ts-expect-error TS(7006) FIXME: Parameter 'urlPath' implicitly has an 'any' type. matchURLPath(urlPath, method) { /** @type string[] */ + // @ts-expect-error TS(7034) FIXME: Variable 'functionNames' implicitly has type 'any[... Remove this comment to see the full error message const functionNames = [] /** @type number[] */ + // @ts-expect-error TS(7034) FIXME: Variable 'routeIndexes' implicitly has type 'any[]... Remove this comment to see the full error message const routeIndexes = [] this.#routes.forEach((route, index) => { + // @ts-expect-error TS(2339) FIXME: Property 'methods' does not exist on type 'never'. if (route.methods && route.methods.length !== 0 && !route.methods.includes(method)) { return } + // @ts-expect-error TS(2339) FIXME: Property 'pattern' does not exist on type 'never'. if (!route.pattern.test(urlPath)) { return } + // @ts-expect-error TS(2339) FIXME: Property 'function_config' does not exist on type ... Remove this comment to see the full error message const isExcluded = this.#manifest?.function_config[route.function]?.excluded_patterns?.some((pattern) => new RegExp(pattern).test(urlPath), ) @@ -454,12 +503,16 @@ export class EdgeFunctionsRegistry { return } + // @ts-expect-error TS(2339) FIXME: Property 'function' does not exist on type 'never'... Remove this comment to see the full error message functionNames.push(route.function) routeIndexes.push(index) }) const invocationMetadata = { + // @ts-expect-error TS(2339) FIXME: Property 'function_config' does not exist on type ... Remove this comment to see the full error message function_config: this.#manifest?.function_config, + // @ts-expect-error TS(7005) FIXME: Variable 'routeIndexes' implicitly has an 'any[]' ... Remove this comment to see the full error message req_routes: routeIndexes, + // @ts-expect-error TS(2339) FIXME: Property 'routes' does not exist on type 'never'. routes: this.#manifest?.routes.map((route) => ({ function: route.function, path: route.path, @@ -467,6 +520,7 @@ export class EdgeFunctionsRegistry { })), } + // @ts-expect-error TS(7005) FIXME: Variable 'functionNames' implicitly has an 'any[]'... Remove this comment to see the full error message return { functionNames, invocationMetadata } } @@ -476,6 +530,7 @@ export class EdgeFunctionsRegistry { * * @param {ModuleGraph} graph */ + // @ts-expect-error TS(7006) FIXME: Parameter 'graph' implicitly has an 'any' type. #processGraph(graph) { if (!graph) { warn('Could not process edge functions dependency graph. Live reload will not be available.') @@ -486,12 +541,14 @@ export class EdgeFunctionsRegistry { // Creating a Map from `this.#functions` that map function paths to function // names. This allows us to match modules against functions in O(1) time as // opposed to O(n). + // @ts-expect-error TS(2339) FIXME: Property 'path' does not exist on type 'never'. // eslint-disable-next-line unicorn/prefer-spread const functionPaths = new Map(Array.from(this.#functions, (func) => [func.path, func.name])) // Mapping file URLs to names of functions that use them as dependencies. const dependencyPaths = new Map() + // @ts-expect-error TS(7031) FIXME: Binding element 'specifier' implicitly has an 'any... Remove this comment to see the full error message graph.modules.forEach(({ dependencies = [], specifier }) => { if (!specifier.startsWith('file://')) { return @@ -508,13 +565,17 @@ export class EdgeFunctionsRegistry { // We're interested in tracking local dependencies, so we only look at // specifiers with the `file:` protocol. if ( + // @ts-expect-error TS(2339) FIXME: Property 'code' does not exist on type 'never'. dependency.code === undefined || + // @ts-expect-error TS(2339) FIXME: Property 'code' does not exist on type 'never'. typeof dependency.code.specifier !== 'string' || + // @ts-expect-error TS(2339) FIXME: Property 'code' does not exist on type 'never'. !dependency.code.specifier.startsWith('file://') ) { return } + // @ts-expect-error TS(2339) FIXME: Property 'code' does not exist on type 'never'. const { specifier: dependencyURL } = dependency.code const dependencyPath = fileURLToPath(dependencyURL) const functions = dependencyPaths.get(dependencyPath) || [] @@ -567,6 +628,7 @@ export class EdgeFunctionsRegistry { const newFunctions = functions.filter((func) => { const functionExists = this.#functions.some( + // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'never'. (existingFunc) => func.name === existingFunc.name && func.path === existingFunc.path, ) @@ -574,6 +636,7 @@ export class EdgeFunctionsRegistry { }) const deletedFunctions = this.#functions.filter((existingFunc) => { const functionExists = functions.some( + // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'never'. (func) => func.name === existingFunc.name && func.path === existingFunc.path, ) @@ -589,10 +652,12 @@ export class EdgeFunctionsRegistry { /** * @param {string} projectDir */ + // @ts-expect-error TS(7006) FIXME: Parameter 'projectDir' implicitly has an 'any' typ... Remove this comment to see the full error message async #setupWatchers(projectDir) { if (this.#configPath) { // Creating a watcher for the config file. When it changes, we update the // declarations and see if we need to register or unregister any functions. + // @ts-expect-error TS(2345) FIXME: Argument of type '{ onChange: () => Promise;... Remove this comment to see the full error message await watchDebounced(this.#configPath, { onChange: async () => { const newConfig = await this.#getUpdatedConfig() @@ -615,11 +680,14 @@ export class EdgeFunctionsRegistry { * @param {string} directory * @returns {Promise} */ + // @ts-expect-error TS(7006) FIXME: Parameter 'directory' implicitly has an 'any' type... Remove this comment to see the full error message async #setupWatcherForDirectory(directory) { const ignored = [`${this.#servePath}/**`] const watcher = await watchDebounced(directory, { + // @ts-expect-error TS(2322) FIXME: Type 'string[]' is not assignable to type 'never[]... Remove this comment to see the full error message ignored, onAdd: () => this.#checkForAddedOrDeletedFunctions(), + // @ts-expect-error TS(2322) FIXME: Type '(paths: any) => Promise' is not assign... Remove this comment to see the full error message onChange: (paths) => this.#handleFileChange(paths), onUnlink: () => this.#checkForAddedOrDeletedFunctions(), }) @@ -631,6 +699,7 @@ export class EdgeFunctionsRegistry { * @param {string} func * @returns {string | undefined} */ + // @ts-expect-error TS(7006) FIXME: Parameter 'func' implicitly has an 'any' type. #getDisplayName(func) { const declarations = [...this.#declarationsFromTOML, ...this.#declarationsFromDeployConfig] diff --git a/src/lib/exec-fetcher.mjs b/src/lib/exec-fetcher.mts similarity index 63% rename from src/lib/exec-fetcher.mjs rename to src/lib/exec-fetcher.mts index 4d85c838a91..8180f17fc63 100644 --- a/src/lib/exec-fetcher.mjs +++ b/src/lib/exec-fetcher.mts @@ -1,17 +1,21 @@ -// @ts-check + import path from 'path' import process from 'process' import { fetchLatest, fetchVersion, newerVersion, updateAvailable } from 'gh-release-fetch' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'isex... Remove this comment to see the full error message import isExe from 'isexe' import { NETLIFYDEVWARN, error, getTerminalLink, log } from '../utils/command-helpers.mjs' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../utils/execa.mjs' const isWindows = () => process.platform === 'win32' +// @ts-expect-error TS(7031) FIXME: Binding element 'packageName' implicitly has an 'a... Remove this comment to see the full error message const getRepository = ({ packageName }) => `netlify/${packageName}` +// @ts-expect-error TS(7031) FIXME: Binding element 'execName' implicitly has an 'any'... Remove this comment to see the full error message export const getExecName = ({ execName }) => (isWindows() ? `${execName}.exe` : execName) const getOptions = () => { @@ -24,6 +28,7 @@ const getOptions = () => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'currentVersion' implicitly has an... Remove this comment to see the full error message const isVersionOutdated = async ({ currentVersion, latestVersion, packageName }) => { if (latestVersion) { return newerVersion(latestVersion, currentVersion) @@ -34,11 +39,17 @@ const isVersionOutdated = async ({ currentVersion, latestVersion, packageName }) } export const shouldFetchLatestVersion = async ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'binPath' implicitly has an 'any' ... Remove this comment to see the full error message binPath, + // @ts-expect-error TS(7031) FIXME: Binding element 'execArgs' implicitly has an 'any'... Remove this comment to see the full error message execArgs, + // @ts-expect-error TS(7031) FIXME: Binding element 'execName' implicitly has an 'any'... Remove this comment to see the full error message execName, + // @ts-expect-error TS(7031) FIXME: Binding element 'latestVersion' implicitly has an ... Remove this comment to see the full error message latestVersion, + // @ts-expect-error TS(7031) FIXME: Binding element 'packageName' implicitly has an 'a... Remove this comment to see the full error message packageName, + // @ts-expect-error TS(7031) FIXME: Binding element 'pattern' implicitly has an 'any' ... Remove this comment to see the full error message pattern, }) => { const execPath = path.join(binPath, getExecName({ execName })) @@ -48,6 +59,7 @@ export const shouldFetchLatestVersion = async ({ return true } + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. const { stdout } = await execa(execPath, execArgs) if (!stdout) { @@ -98,6 +110,7 @@ export const getArch = () => { * @param {string} config.packageName * @param {string} [config.latestVersion ] */ +// @ts-expect-error TS(7031) FIXME: Binding element 'destination' implicitly has an 'a... Remove this comment to see the full error message export const fetchLatestVersion = async ({ destination, execName, extension, latestVersion, packageName }) => { const win = isWindows() const arch = getArch() @@ -113,12 +126,15 @@ export const fetchLatestVersion = async ({ destination, execName, extension, lat const options = getOptions() const fetch = latestVersion + // @ts-expect-error TS(2345) FIXME: Argument of type '{ headers: { Authorization: stri... Remove this comment to see the full error message ? fetchVersion({ ...release, version: latestVersion }, options) + // @ts-expect-error TS(2345) FIXME: Argument of type '{ repository: string; package: s... Remove this comment to see the full error message : fetchLatest(release, options) try { await fetch } catch (error_) { + // @ts-expect-error TS(2531) FIXME: Object is possibly 'null'. if (typeof error_ === 'object' && 'statusCode' in error_ && error_.statusCode === 404) { const createIssueLink = new URL('https://github.com/netlify/cli/issues/new') createIssueLink.searchParams.set('assignees', '') @@ -137,6 +153,7 @@ Please open up an issue on our CLI repository so that we can support it: ${issueLink}`) } + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } diff --git a/src/lib/fs.mjs b/src/lib/fs.mts similarity index 64% rename from src/lib/fs.mjs rename to src/lib/fs.mts index 908f5a1d04c..212c3db2fcd 100644 --- a/src/lib/fs.mjs +++ b/src/lib/fs.mts @@ -1,7 +1,8 @@ -// @ts-check + import { constants } from 'fs' import { access, stat } from 'fs/promises' +// @ts-expect-error TS(7006) FIXME: Parameter 'filePath' implicitly has an 'any' type. export const fileExistsAsync = async (filePath) => { try { await access(filePath, constants.F_OK) @@ -16,12 +17,14 @@ export const fileExistsAsync = async (filePath) => { * @param {string} filePath * @param {keyof import('fs').StatsBase} type For example `isDirectory` or `isFile` */ +// @ts-expect-error TS(7006) FIXME: Parameter 'filePath' implicitly has an 'any' type. const isType = async (filePath, type) => { try { const stats = await stat(filePath) - // @ts-ignore + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message return typeof stats[type] === 'function' ? stats[type]() : stats[type] } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.code === 'ENOENT') { return false } @@ -34,10 +37,12 @@ const isType = async (filePath, type) => { * Checks if the provided filePath is a file * @param {string} filePath */ +// @ts-expect-error TS(7006) FIXME: Parameter 'filePath' implicitly has an 'any' type. export const isFileAsync = (filePath) => isType(filePath, 'isFile') /** * Checks if the provided filePath is a directory * @param {string} filePath */ +// @ts-expect-error TS(7006) FIXME: Parameter 'filePath' implicitly has an 'any' type. export const isDirectoryAsync = (filePath) => isType(filePath, 'isDirectory') diff --git a/src/lib/functions/background.mjs b/src/lib/functions/background.mts similarity index 74% rename from src/lib/functions/background.mjs rename to src/lib/functions/background.mts index f30bd4c23bd..5c6d6dfb135 100644 --- a/src/lib/functions/background.mjs +++ b/src/lib/functions/background.mts @@ -4,12 +4,14 @@ import { formatLambdaError, styleFunctionName } from './utils.mjs' const BACKGROUND_FUNCTION_STATUS_CODE = 202 +// @ts-expect-error TS(7006) FIXME: Parameter 'functionName' implicitly has an 'any' t... Remove this comment to see the full error message export const handleBackgroundFunction = (functionName, response) => { console.log(`${NETLIFYDEVLOG} Queueing background function ${styleFunctionName(functionName)} for execution`) response.status(BACKGROUND_FUNCTION_STATUS_CODE) response.end() } +// @ts-expect-error TS(7006) FIXME: Parameter 'functionName' implicitly has an 'any' t... Remove this comment to see the full error message export const handleBackgroundFunctionResult = (functionName, err) => { if (err) { console.log( diff --git a/src/lib/functions/config.mjs b/src/lib/functions/config.mts similarity index 57% rename from src/lib/functions/config.mjs rename to src/lib/functions/config.mts index 01d01163452..2ed0674cfc6 100644 --- a/src/lib/functions/config.mjs +++ b/src/lib/functions/config.mts @@ -1,18 +1,25 @@ // The function configuration keys returned by @netlify/config are not an exact // match to the properties that @netlify/zip-it-and-ship-it expects. We do that // translation here. +// @ts-expect-error TS(7031) FIXME: Binding element 'projectRoot' implicitly has an 'a... Remove this comment to see the full error message export const normalizeFunctionsConfig = ({ functionsConfig = {}, projectRoot, siteEnv = {} }) => Object.entries(functionsConfig).reduce( (result, [pattern, config]) => ({ ...result, [pattern]: { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. externalNodeModules: config.external_node_modules, + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. includedFiles: config.included_files, includedFilesBasePath: projectRoot, + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. ignoredNodeModules: config.ignored_node_modules, + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. nodeBundler: config.node_bundler === 'esbuild' ? 'esbuild_zisi' : config.node_bundler, + // @ts-expect-error TS(2339) FIXME: Property 'AWS_LAMBDA_JS_RUNTIME' does not exist on... Remove this comment to see the full error message nodeVersion: siteEnv.AWS_LAMBDA_JS_RUNTIME, processDynamicNodeImports: true, + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. schedule: config.schedule, zipGo: true, }, diff --git a/src/lib/functions/form-submissions-handler.mjs b/src/lib/functions/form-submissions-handler.mts similarity index 71% rename from src/lib/functions/form-submissions-handler.mjs rename to src/lib/functions/form-submissions-handler.mts index b31605e476c..a801fdf177b 100644 --- a/src/lib/functions/form-submissions-handler.mjs +++ b/src/lib/functions/form-submissions-handler.mts @@ -1,7 +1,9 @@ -// @ts-check + import { Readable } from 'stream' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'cont... Remove this comment to see the full error message import { parse as parseContentType } from 'content-type' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'mult... Remove this comment to see the full error message import multiparty from 'multiparty' import getRawBody from 'raw-body' @@ -9,6 +11,7 @@ import { warn } from '../../utils/command-helpers.mjs' import { BACKGROUND } from '../../utils/functions/index.mjs' import { capitalize } from '../string.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'functionsRegistry' implicitly has... Remove this comment to see the full error message const getFormHandler = function ({ functionsRegistry }) { const handlers = ['submission-created', `submission-created${BACKGROUND}`] .map((name) => functionsRegistry.get(name)) @@ -27,7 +30,9 @@ const getFormHandler = function ({ functionsRegistry }) { return handlers[0] } +// @ts-expect-error TS(7031) FIXME: Binding element 'functionsRegistry' implicitly has... Remove this comment to see the full error message export const createFormSubmissionHandler = function ({ functionsRegistry, siteUrl }) { + // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. return async function formSubmissionHandler(req, res, next) { if ( req.url.startsWith('/.netlify/') || @@ -42,6 +47,7 @@ export const createFormSubmissionHandler = function ({ functionsRegistry, siteUr this.push(null) }, }) + // @ts-expect-error TS(2339) FIXME: Property 'headers' does not exist on type 'Readabl... Remove this comment to see the full error message fakeRequest.headers = req.headers const handlerName = getFormHandler({ functionsRegistry }) @@ -65,13 +71,15 @@ export const createFormSubmissionHandler = function ({ functionsRegistry, siteUr fields = Object.fromEntries(new URLSearchParams(bodyData.toString())) } else if (ct.type === 'multipart/form-data') { try { - ;[fields, files] = await new Promise((resolve, reject) => { + [fields, files] = await new Promise((resolve, reject) => { const form = new multiparty.Form({ encoding: ct.parameters.charset || 'utf8' }) + // @ts-expect-error TS(7006) FIXME: Parameter 'err' implicitly has an 'any' type. form.parse(fakeRequest, (err, Fields, Files) => { if (err) return reject(err) Files = Object.entries(Files).reduce( (prev, [name, values]) => ({ ...prev, + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. [name]: values.map((value) => ({ filename: value.originalFilename, size: value.size, @@ -83,10 +91,12 @@ export const createFormSubmissionHandler = function ({ functionsRegistry, siteUr ) return resolve([ Object.entries(Fields).reduce( + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. (prev, [name, values]) => ({ ...prev, [name]: values.length > 1 ? values : values[0] }), {}, ), Object.entries(Files).reduce( + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. (prev, [name, values]) => ({ ...prev, [name]: values.length > 1 ? values : values[0] }), {}, ), @@ -94,6 +104,7 @@ export const createFormSubmissionHandler = function ({ functionsRegistry, siteUr }) }) } catch (error) { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message warn(error) return next() } @@ -104,20 +115,26 @@ export const createFormSubmissionHandler = function ({ functionsRegistry, siteUr const data = JSON.stringify({ payload: { company: + // @ts-expect-error TS(2538) FIXME: Type 'undefined' cannot be used as an index type. fields[Object.keys(fields).find((name) => ['company', 'business', 'employer'].includes(name.toLowerCase()))], last_name: + // @ts-expect-error TS(2538) FIXME: Type 'undefined' cannot be used as an index type. fields[Object.keys(fields).find((name) => ['lastname', 'surname', 'byname'].includes(name.toLowerCase()))], first_name: fields[ + // @ts-expect-error TS(2538) FIXME: Type 'undefined' cannot be used as an index type. Object.keys(fields).find((name) => ['firstname', 'givenname', 'forename'].includes(name.toLowerCase())) ], + // @ts-expect-error TS(2538) FIXME: Type 'undefined' cannot be used as an index type. name: fields[Object.keys(fields).find((name) => ['name', 'fullname'].includes(name.toLowerCase()))], email: fields[ + // @ts-expect-error TS(2538) FIXME: Type 'undefined' cannot be used as an index type. Object.keys(fields).find((name) => ['email', 'mail', 'from', 'twitter', 'sender'].includes(name.toLowerCase()), ) ], + // @ts-expect-error TS(2538) FIXME: Type 'undefined' cannot be used as an index type. title: fields[Object.keys(fields).find((name) => ['title', 'subject'].includes(name.toLowerCase()))], data: { ...fields, @@ -129,10 +146,12 @@ export const createFormSubmissionHandler = function ({ functionsRegistry, siteUr created_at: new Date().toISOString(), human_fields: Object.entries({ ...fields, + // @ts-expect-error TS(2339) FIXME: Property 'url' does not exist on type 'unknown'. ...Object.entries(files).reduce((prev, [name, { url }]) => ({ ...prev, [name]: url }), {}), }).reduce((prev, [key, val]) => ({ ...prev, [capitalize(key)]: val }), {}), ordered_human_fields: Object.entries({ ...fields, + // @ts-expect-error TS(2339) FIXME: Property 'url' does not exist on type 'unknown'. ...Object.entries(files).reduce((prev, [name, { url }]) => ({ ...prev, [name]: url }), {}), }).map(([key, val]) => ({ title: capitalize(key), name: key, value: val })), site_url: siteUrl, diff --git a/src/lib/functions/local-proxy.mjs b/src/lib/functions/local-proxy.mts similarity index 67% rename from src/lib/functions/local-proxy.mjs rename to src/lib/functions/local-proxy.mts index 1b1c002653a..53576c4deeb 100644 --- a/src/lib/functions/local-proxy.mjs +++ b/src/lib/functions/local-proxy.mts @@ -1,10 +1,13 @@ -// @ts-check + import { stdout } from 'process' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module '@net... Remove this comment to see the full error message import { getBinaryPath as getFunctionsProxyPath } from '@netlify/local-functions-proxy' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../../utils/execa.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'binaryPath' implicitly has an 'an... Remove this comment to see the full error message export const runFunctionsProxy = ({ binaryPath, context, directory, event, name, timeout }) => { const functionsProxyPath = getFunctionsProxyPath() const requestData = { @@ -37,6 +40,7 @@ export const runFunctionsProxy = ({ binaryPath, context, directory, event, name, '--timeout', `${timeout}s`, ] + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. const proxyProcess = execa(functionsProxyPath, parameters) proxyProcess.stderr.pipe(stdout) diff --git a/src/lib/functions/memoized-build.mjs b/src/lib/functions/memoized-build.mts similarity index 89% rename from src/lib/functions/memoized-build.mjs rename to src/lib/functions/memoized-build.mts index 2802ccbcfb6..2f16b075eb5 100644 --- a/src/lib/functions/memoized-build.mjs +++ b/src/lib/functions/memoized-build.mts @@ -8,6 +8,7 @@ const DEBOUNCE_INTERVAL = 300 // This allows us to discard any duplicate filesystem events, while ensuring // that actual updates happening during the zip operation will be executed // after it finishes (only the last update will run). +// @ts-expect-error TS(7031) FIXME: Binding element 'cache' implicitly has an 'any' ty... Remove this comment to see the full error message export const memoizedBuild = ({ cache, cacheKey, command }) => { if (cache[cacheKey] === undefined) { cache[cacheKey] = { diff --git a/src/lib/functions/netlify-function.mjs b/src/lib/functions/netlify-function.mjs deleted file mode 100644 index 811d8c3f380..00000000000 --- a/src/lib/functions/netlify-function.mjs +++ /dev/null @@ -1,265 +0,0 @@ -// @ts-check -import { Buffer } from 'buffer' -import { basename, extname } from 'path' -import { version as nodeVersion } from 'process' - -import CronParser from 'cron-parser' -import semver from 'semver' - -import { error as errorExit } from '../../utils/command-helpers.mjs' -import { BACKGROUND } from '../../utils/functions/get-functions.mjs' - -const TYPESCRIPT_EXTENSIONS = new Set(['.cts', '.mts', '.ts']) -const V2_MIN_NODE_VERSION = '18.14.0' - -// Returns a new set with all elements of `setA` that don't exist in `setB`. -const difference = (setA, setB) => new Set([...setA].filter((item) => !setB.has(item))) - -const getNextRun = function (schedule) { - const cron = CronParser.parseExpression(schedule, { - tz: 'Etc/UTC', - }) - return cron.next().toDate() -} - -export default class NetlifyFunction { - constructor({ - blobsContext, - config, - directory, - displayName, - mainFile, - name, - projectRoot, - runtime, - settings, - timeoutBackground, - timeoutSynchronous, - }) { - this.blobsContext = blobsContext - this.buildError = null - this.config = config - this.directory = directory - this.errorExit = errorExit - this.mainFile = mainFile - this.name = name - this.displayName = displayName ?? name - this.projectRoot = projectRoot - this.runtime = runtime - this.timeoutBackground = timeoutBackground - this.timeoutSynchronous = timeoutSynchronous - this.settings = settings - - // Determines whether this is a background function based on the function - // name. - this.isBackground = name.endsWith(BACKGROUND) - - const functionConfig = config.functions && config.functions[name] - this.schedule = functionConfig && functionConfig.schedule - - // List of the function's source files. This starts out as an empty set - // and will get populated on every build. - this.srcFiles = new Set() - } - - get filename() { - if (!this.buildData?.mainFile) { - return null - } - - return basename(this.buildData.mainFile) - } - - getRecommendedExtension() { - if (this.buildData?.runtimeAPIVersion !== 2) { - return - } - - const extension = this.buildData?.mainFile ? extname(this.buildData.mainFile) : undefined - const moduleFormat = this.buildData?.outputModuleFormat - - if (moduleFormat === 'esm') { - return - } - - if (extension === '.ts') { - return '.mts' - } - - if (extension === '.js') { - return '.mjs' - } - } - - hasValidName() { - // same as https://github.com/netlify/bitballoon/blob/fbd7881e6c8e8c48e7a0145da4ee26090c794108/app/models/deploy.rb#L482 - // eslint-disable-next-line unicorn/better-regex - return /^[A-Za-z0-9_-]+$/.test(this.name) - } - - async isScheduled() { - await this.buildQueue - - return Boolean(this.schedule) - } - - isSupported() { - return !(this.buildData?.runtimeAPIVersion === 2 && semver.lt(nodeVersion, V2_MIN_NODE_VERSION)) - } - - isTypeScript() { - if (this.filename === null) { - return false - } - - return TYPESCRIPT_EXTENSIONS.has(extname(this.filename)) - } - - async getNextRun() { - if (!(await this.isScheduled())) { - return null - } - - return getNextRun(this.schedule) - } - - // The `build` method transforms source files into invocable functions. Its - // return value is an object with: - // - // - `srcFilesDiff`: Files that were added and removed since the last time - // the function was built. - async build({ cache }) { - const buildFunction = await this.runtime.getBuildFunction({ - config: this.config, - directory: this.directory, - errorExit: this.errorExit, - func: this, - projectRoot: this.projectRoot, - }) - - this.buildQueue = buildFunction({ cache }) - - try { - const { includedFiles = [], schedule, srcFiles, ...buildData } = await this.buildQueue - const srcFilesSet = new Set(srcFiles) - const srcFilesDiff = this.getSrcFilesDiff(srcFilesSet) - - this.buildData = buildData - this.buildError = null - this.srcFiles = srcFilesSet - this.schedule = schedule || this.schedule - - if (!this.isSupported()) { - throw new Error( - `Function requires Node.js version ${V2_MIN_NODE_VERSION} or above, but ${nodeVersion.slice( - 1, - )} is installed. Refer to https://ntl.fyi/functions-runtime for information on how to update.`, - ) - } - - return { includedFiles, srcFilesDiff } - } catch (error) { - this.buildError = error - - return { error } - } - } - - async getBuildData() { - await this.buildQueue - - return this.buildData - } - - // Compares a new set of source files against a previous one, returning an - // object with two Sets, one with added and the other with deleted files. - getSrcFilesDiff(newSrcFiles) { - const added = difference(newSrcFiles, this.srcFiles) - const deleted = difference(this.srcFiles, newSrcFiles) - - return { - added, - deleted, - } - } - - // Invokes the function and returns its response object. - async invoke(event = {}, context = {}) { - await this.buildQueue - - if (this.buildError) { - return { result: null, error: { errorMessage: this.buildError.message } } - } - - const timeout = this.isBackground ? this.timeoutBackground : this.timeoutSynchronous - const environment = {} - - if (this.blobsContext) { - const payload = JSON.stringify({ - url: this.blobsContext.edgeURL, - token: this.blobsContext.token, - }) - - event.blobs = Buffer.from(payload).toString('base64') - } - - try { - const result = await this.runtime.invokeFunction({ - context, - environment, - event, - func: this, - timeout, - }) - return { result, error: null } - } catch (error) { - return { result: null, error } - } - } - - /** - * Matches all routes agains the incoming request. If a match is found, then the matched route is returned. - * @param {string} rawPath - * @param {string} method - * @returns matched route - */ - async matchURLPath(rawPath, method) { - await this.buildQueue - - let path = rawPath !== '/' && rawPath.endsWith('/') ? rawPath.slice(0, -1) : rawPath - path = path.toLowerCase() - const { routes = [] } = this.buildData - return routes.find(({ expression, literal, methods }) => { - if (methods.length !== 0 && !methods.includes(method)) { - return false - } - - if (literal !== undefined) { - return path === literal - } - - if (expression !== undefined) { - const regex = new RegExp(expression) - - return regex.test(path) - } - - return false - }) - } - - get runtimeAPIVersion() { - return this.buildData?.runtimeAPIVersion ?? 1 - } - - get url() { - // This line fixes the issue here https://github.com/netlify/cli/issues/4116 - // Not sure why `settings.port` was used here nor does a valid reference exist. - // However, it remains here to serve whatever purpose for which it was added. - const port = this.settings.port || this.settings.functionsPort - const protocol = this.settings.https ? 'https' : 'http' - const url = new URL(`/.netlify/functions/${this.name}`, `${protocol}://localhost:${port}`) - - return url.href - } -} diff --git a/src/lib/functions/netlify-function.mts b/src/lib/functions/netlify-function.mts new file mode 100644 index 00000000000..cb8c8c33be8 --- /dev/null +++ b/src/lib/functions/netlify-function.mts @@ -0,0 +1,338 @@ +import { Buffer } from 'buffer' +import { basename, extname } from 'path' +import { version as nodeVersion } from 'process' + +import CronParser from 'cron-parser' +import semver from 'semver' + +import { error as errorExit } from '../../utils/command-helpers.mjs' +import { BACKGROUND } from '../../utils/functions/get-functions.mjs' + +const TYPESCRIPT_EXTENSIONS = new Set(['.cts', '.mts', '.ts']) +const V2_MIN_NODE_VERSION = '18.14.0' + +// Returns a new set with all elements of `setA` that don't exist in `setB`. +// @ts-expect-error TS(7006) FIXME: Parameter 'setA' implicitly has an 'any' type. +const difference = (setA, setB) => new Set([...setA].filter((item) => !setB.has(item))) + +// @ts-expect-error TS(7006) FIXME: Parameter 'schedule' implicitly has an 'any' type. +const getNextRun = function (schedule) { + const cron = CronParser.parseExpression(schedule, { + tz: 'Etc/UTC', + }) + return cron.next().toDate() +} + +export default class NetlifyFunction { + constructor({ + // @ts-expect-error TS(7031) FIXME: Binding element 'blobsContext' implicitly has an '... Remove this comment to see the full error message + blobsContext, + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message + config, + // @ts-expect-error TS(7031) FIXME: Binding element 'directory' implicitly has an 'any... Remove this comment to see the full error message + directory, + // @ts-expect-error TS(7031) FIXME: Binding element 'displayName' implicitly has an 'a... Remove this comment to see the full error message + displayName, + // @ts-expect-error TS(7031) FIXME: Binding element 'mainFile' implicitly has an 'any'... Remove this comment to see the full error message + mainFile, + // @ts-expect-error TS(7031) FIXME: Binding element 'name' implicitly has an 'any' typ... Remove this comment to see the full error message + name, + // @ts-expect-error TS(7031) FIXME: Binding element 'projectRoot' implicitly has an 'a... Remove this comment to see the full error message + projectRoot, + // @ts-expect-error TS(7031) FIXME: Binding element 'runtime' implicitly has an 'any' ... Remove this comment to see the full error message + runtime, + // @ts-expect-error TS(7031) FIXME: Binding element 'settings' implicitly has an 'any'... Remove this comment to see the full error message + settings, + // @ts-expect-error TS(7031) FIXME: Binding element 'timeoutBackground' implicitly has... Remove this comment to see the full error message + timeoutBackground, + // @ts-expect-error TS(7031) FIXME: Binding element 'timeoutSynchronous' implicitly ha... Remove this comment to see the full error message + timeoutSynchronous, + }) { + // @ts-expect-error TS(2339) FIXME: Property 'blobsContext' does not exist on type 'Ne... Remove this comment to see the full error message + this.blobsContext = blobsContext + // @ts-expect-error TS(2339) FIXME: Property 'buildError' does not exist on type 'Netl... Remove this comment to see the full error message + this.buildError = null + // @ts-expect-error TS(2339) FIXME: Property 'config' does not exist on type 'NetlifyF... Remove this comment to see the full error message + this.config = config + // @ts-expect-error TS(2339) FIXME: Property 'directory' does not exist on type 'Netli... Remove this comment to see the full error message + this.directory = directory + // @ts-expect-error TS(2339) FIXME: Property 'errorExit' does not exist on type 'Netli... Remove this comment to see the full error message + this.errorExit = errorExit + // @ts-expect-error TS(2339) FIXME: Property 'mainFile' does not exist on type 'Netlif... Remove this comment to see the full error message + this.mainFile = mainFile + // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'NetlifyFun... Remove this comment to see the full error message + this.name = name + // @ts-expect-error TS(2339) FIXME: Property 'displayName' does not exist on type 'Net... Remove this comment to see the full error message + this.displayName = displayName ?? name + // @ts-expect-error TS(2339) FIXME: Property 'projectRoot' does not exist on type 'Net... Remove this comment to see the full error message + this.projectRoot = projectRoot + // @ts-expect-error TS(2339) FIXME: Property 'runtime' does not exist on type 'Netlify... Remove this comment to see the full error message + this.runtime = runtime + // @ts-expect-error TS(2339) FIXME: Property 'timeoutBackground' does not exist on typ... Remove this comment to see the full error message + this.timeoutBackground = timeoutBackground + // @ts-expect-error TS(2339) FIXME: Property 'timeoutSynchronous' does not exist on ty... Remove this comment to see the full error message + this.timeoutSynchronous = timeoutSynchronous + // @ts-expect-error TS(2339) FIXME: Property 'settings' does not exist on type 'Netlif... Remove this comment to see the full error message + this.settings = settings + + // Determines whether this is a background function based on the function + // name. + // @ts-expect-error TS(2339) FIXME: Property 'isBackground' does not exist on type 'Ne... Remove this comment to see the full error message + this.isBackground = name.endsWith(BACKGROUND) + + const functionConfig = config.functions && config.functions[name] + // @ts-expect-error TS(2339) FIXME: Property 'schedule' does not exist on type 'Netlif... Remove this comment to see the full error message + this.schedule = functionConfig && functionConfig.schedule + + // List of the function's source files. This starts out as an empty set + // and will get populated on every build. + // @ts-expect-error TS(2339) FIXME: Property 'srcFiles' does not exist on type 'Netlif... Remove this comment to see the full error message + this.srcFiles = new Set() + } + + get filename() { + // @ts-expect-error TS(2339) FIXME: Property 'buildData' does not exist on type 'Netli... Remove this comment to see the full error message + if (!this.buildData?.mainFile) { + return null + } + + // @ts-expect-error TS(2339) FIXME: Property 'buildData' does not exist on type 'Netli... Remove this comment to see the full error message + return basename(this.buildData.mainFile) + } + + getRecommendedExtension() { + // @ts-expect-error TS(2339) FIXME: Property 'buildData' does not exist on type 'Netli... Remove this comment to see the full error message + if (this.buildData?.runtimeAPIVersion !== 2) { + return + } + + // @ts-expect-error TS(2339) FIXME: Property 'buildData' does not exist on type 'Netli... Remove this comment to see the full error message + const extension = this.buildData?.mainFile ? extname(this.buildData.mainFile) : undefined + // @ts-expect-error TS(2339) FIXME: Property 'buildData' does not exist on type 'Netli... Remove this comment to see the full error message + const moduleFormat = this.buildData?.outputModuleFormat + + if (moduleFormat === 'esm') { + return + } + + if (extension === '.ts') { + return '.mts' + } + + if (extension === '.js') { + return '.mjs' + } + } + + hasValidName() { + // same as https://github.com/netlify/bitballoon/blob/fbd7881e6c8e8c48e7a0145da4ee26090c794108/app/models/deploy.rb#L482 + // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'NetlifyFun... Remove this comment to see the full error message + // eslint-disable-next-line unicorn/better-regex + return /^[A-Za-z0-9_-]+$/.test(this.name) + } + + async isScheduled() { + // @ts-expect-error TS(2339) FIXME: Property 'buildQueue' does not exist on type 'Netl... Remove this comment to see the full error message + await this.buildQueue + + // @ts-expect-error TS(2339) FIXME: Property 'schedule' does not exist on type 'Netlif... Remove this comment to see the full error message + return Boolean(this.schedule) + } + + isSupported() { + // @ts-expect-error TS(2339) FIXME: Property 'buildData' does not exist on type 'Netli... Remove this comment to see the full error message + return !(this.buildData?.runtimeAPIVersion === 2 && semver.lt(nodeVersion, V2_MIN_NODE_VERSION)) + } + + isTypeScript() { + if (this.filename === null) { + return false + } + + return TYPESCRIPT_EXTENSIONS.has(extname(this.filename)) + } + + async getNextRun() { + if (!(await this.isScheduled())) { + return null + } + + // @ts-expect-error TS(2339) FIXME: Property 'schedule' does not exist on type 'Netlif... Remove this comment to see the full error message + return getNextRun(this.schedule) + } + + // The `build` method transforms source files into invocable functions. Its + // return value is an object with: + // + // - `srcFilesDiff`: Files that were added and removed since the last time + // the function was built. + // @ts-expect-error TS(7031) FIXME: Binding element 'cache' implicitly has an 'any' ty... Remove this comment to see the full error message + async build({ cache }) { + // @ts-expect-error TS(2339) FIXME: Property 'runtime' does not exist on type 'Netlify... Remove this comment to see the full error message + const buildFunction = await this.runtime.getBuildFunction({ + // @ts-expect-error TS(2339) FIXME: Property 'config' does not exist on type 'NetlifyF... Remove this comment to see the full error message + config: this.config, + // @ts-expect-error TS(2339) FIXME: Property 'directory' does not exist on type 'Netli... Remove this comment to see the full error message + directory: this.directory, + // @ts-expect-error TS(2339) FIXME: Property 'errorExit' does not exist on type 'Netli... Remove this comment to see the full error message + errorExit: this.errorExit, + func: this, + // @ts-expect-error TS(2339) FIXME: Property 'projectRoot' does not exist on type 'Net... Remove this comment to see the full error message + projectRoot: this.projectRoot, + }) + + // @ts-expect-error TS(2339) FIXME: Property 'buildQueue' does not exist on type 'Netl... Remove this comment to see the full error message + this.buildQueue = buildFunction({ cache }) + + try { + // @ts-expect-error TS(2339) FIXME: Property 'buildQueue' does not exist on type 'Netl... Remove this comment to see the full error message + const { includedFiles = [], schedule, srcFiles, ...buildData } = await this.buildQueue + const srcFilesSet = new Set(srcFiles) + const srcFilesDiff = this.getSrcFilesDiff(srcFilesSet) + + // @ts-expect-error TS(2339) FIXME: Property 'buildData' does not exist on type 'Netli... Remove this comment to see the full error message + this.buildData = buildData + // @ts-expect-error TS(2339) FIXME: Property 'buildError' does not exist on type 'Netl... Remove this comment to see the full error message + this.buildError = null + // @ts-expect-error TS(2339) FIXME: Property 'srcFiles' does not exist on type 'Netlif... Remove this comment to see the full error message + this.srcFiles = srcFilesSet + // @ts-expect-error TS(2339) FIXME: Property 'schedule' does not exist on type 'Netlif... Remove this comment to see the full error message + this.schedule = schedule || this.schedule + + if (!this.isSupported()) { + throw new Error( + `Function requires Node.js version ${V2_MIN_NODE_VERSION} or above, but ${nodeVersion.slice( + 1, + )} is installed. Refer to https://ntl.fyi/functions-runtime for information on how to update.`, + ) + } + + return { includedFiles, srcFilesDiff } + } catch (error) { + // @ts-expect-error TS(2339) FIXME: Property 'buildError' does not exist on type 'Netl... Remove this comment to see the full error message + this.buildError = error + + return { error } + } + } + + async getBuildData() { + // @ts-expect-error TS(2339) FIXME: Property 'buildQueue' does not exist on type 'Netl... Remove this comment to see the full error message + await this.buildQueue + + // @ts-expect-error TS(2339) FIXME: Property 'buildData' does not exist on type 'Netli... Remove this comment to see the full error message + return this.buildData + } + + // Compares a new set of source files against a previous one, returning an + // object with two Sets, one with added and the other with deleted files. + // @ts-expect-error TS(7006) FIXME: Parameter 'newSrcFiles' implicitly has an 'any' ty... Remove this comment to see the full error message + getSrcFilesDiff(newSrcFiles) { + // @ts-expect-error TS(2339) FIXME: Property 'srcFiles' does not exist on type 'Netlif... Remove this comment to see the full error message + const added = difference(newSrcFiles, this.srcFiles) + // @ts-expect-error TS(2339) FIXME: Property 'srcFiles' does not exist on type 'Netlif... Remove this comment to see the full error message + const deleted = difference(this.srcFiles, newSrcFiles) + + return { + added, + deleted, + } + } + + // Invokes the function and returns its response object. + async invoke(event = {}, context = {}) { + // @ts-expect-error TS(2339) FIXME: Property 'buildQueue' does not exist on type 'Netl... Remove this comment to see the full error message + await this.buildQueue + + // @ts-expect-error TS(2339) FIXME: Property 'buildError' does not exist on type 'Netl... Remove this comment to see the full error message + if (this.buildError) { + // @ts-expect-error TS(2339) FIXME: Property 'buildError' does not exist on type 'Netl... Remove this comment to see the full error message + return { result: null, error: { errorMessage: this.buildError.message } } + } + + // @ts-expect-error TS(2339) FIXME: Property 'isBackground' does not exist on type 'Ne... Remove this comment to see the full error message + const timeout = this.isBackground ? this.timeoutBackground : this.timeoutSynchronous + const environment = {} + + // @ts-expect-error TS(2339) FIXME: Property 'blobsContext' does not exist on type 'Ne... Remove this comment to see the full error message + if (this.blobsContext) { + const payload = JSON.stringify({ + // @ts-expect-error TS(2339) FIXME: Property 'blobsContext' does not exist on type 'Ne... Remove this comment to see the full error message + url: this.blobsContext.edgeURL, + // @ts-expect-error TS(2339) FIXME: Property 'blobsContext' does not exist on type 'Ne... Remove this comment to see the full error message + token: this.blobsContext.token, + }) + + // @ts-expect-error TS(2339) FIXME: Property 'blobs' does not exist on type '{}'. + event.blobs = Buffer.from(payload).toString('base64') + } + + try { + // @ts-expect-error TS(2339) FIXME: Property 'runtime' does not exist on type 'Netlify... Remove this comment to see the full error message + const result = await this.runtime.invokeFunction({ + context, + environment, + event, + func: this, + timeout, + }) + return { result, error: null } + } catch (error) { + return { result: null, error } + } + } + + /** + * Matches all routes agains the incoming request. If a match is found, then the matched route is returned. + * @param {string} rawPath + * @param {string} method + * @returns matched route + */ + // @ts-expect-error TS(7006) FIXME: Parameter 'rawPath' implicitly has an 'any' type. + async matchURLPath(rawPath, method) { + // @ts-expect-error TS(2339) FIXME: Property 'buildQueue' does not exist on type 'Netl... Remove this comment to see the full error message + await this.buildQueue + + let path = rawPath !== '/' && rawPath.endsWith('/') ? rawPath.slice(0, -1) : rawPath + path = path.toLowerCase() + // @ts-expect-error TS(2339) FIXME: Property 'buildData' does not exist on type 'Netli... Remove this comment to see the full error message + const { routes = [] } = this.buildData + // @ts-expect-error TS(7031) FIXME: Binding element 'expression' implicitly has an 'an... Remove this comment to see the full error message + return routes.find(({ expression, literal, methods }) => { + if (methods.length !== 0 && !methods.includes(method)) { + return false + } + + if (literal !== undefined) { + return path === literal + } + + if (expression !== undefined) { + const regex = new RegExp(expression) + + return regex.test(path) + } + + return false + }) + } + + get runtimeAPIVersion() { + // @ts-expect-error TS(2339) FIXME: Property 'buildData' does not exist on type 'Netli... Remove this comment to see the full error message + return this.buildData?.runtimeAPIVersion ?? 1 + } + + get url() { + // This line fixes the issue here https://github.com/netlify/cli/issues/4116 + // Not sure why `settings.port` was used here nor does a valid reference exist. + // However, it remains here to serve whatever purpose for which it was added. + // @ts-expect-error TS(2339) FIXME: Property 'settings' does not exist on type 'Netlif... Remove this comment to see the full error message + const port = this.settings.port || this.settings.functionsPort + // @ts-expect-error TS(2339) FIXME: Property 'settings' does not exist on type 'Netlif... Remove this comment to see the full error message + const protocol = this.settings.https ? 'https' : 'http' + // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'NetlifyFun... Remove this comment to see the full error message + const url = new URL(`/.netlify/functions/${this.name}`, `${protocol}://localhost:${port}`) + + return url.href + } +} diff --git a/src/lib/functions/registry.mjs b/src/lib/functions/registry.mts similarity index 63% rename from src/lib/functions/registry.mjs rename to src/lib/functions/registry.mts index 469846cce58..b5b87cfc7b5 100644 --- a/src/lib/functions/registry.mjs +++ b/src/lib/functions/registry.mts @@ -1,4 +1,4 @@ -// @ts-check + import { mkdir, stat } from 'fs/promises' import { createRequire } from 'module' import { basename, extname, isAbsolute, join, resolve } from 'path' @@ -34,23 +34,38 @@ const ZIP_EXTENSION = '.zip' export class FunctionsRegistry { constructor({ + // @ts-expect-error TS(7031) FIXME: Binding element 'blobsContext' implicitly has an '... Remove this comment to see the full error message blobsContext, + // @ts-expect-error TS(7031) FIXME: Binding element 'capabilities' implicitly has an '... Remove this comment to see the full error message capabilities, + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message config, debug = false, isConnected = false, + // @ts-expect-error TS(7031) FIXME: Binding element 'logLambdaCompat' implicitly has a... Remove this comment to see the full error message logLambdaCompat, + // @ts-expect-error TS(7031) FIXME: Binding element 'manifest' implicitly has an 'any'... Remove this comment to see the full error message manifest, + // @ts-expect-error TS(7031) FIXME: Binding element 'projectRoot' implicitly has an 'a... Remove this comment to see the full error message projectRoot, + // @ts-expect-error TS(7031) FIXME: Binding element 'settings' implicitly has an 'any'... Remove this comment to see the full error message settings, + // @ts-expect-error TS(7031) FIXME: Binding element 'timeouts' implicitly has an 'any'... Remove this comment to see the full error message timeouts, }) { + // @ts-expect-error TS(2339) FIXME: Property 'capabilities' does not exist on type 'Fu... Remove this comment to see the full error message this.capabilities = capabilities + // @ts-expect-error TS(2339) FIXME: Property 'config' does not exist on type 'Function... Remove this comment to see the full error message this.config = config + // @ts-expect-error TS(2339) FIXME: Property 'debug' does not exist on type 'Functions... Remove this comment to see the full error message this.debug = debug + // @ts-expect-error TS(2339) FIXME: Property 'isConnected' does not exist on type 'Fun... Remove this comment to see the full error message this.isConnected = isConnected + // @ts-expect-error TS(2339) FIXME: Property 'projectRoot' does not exist on type 'Fun... Remove this comment to see the full error message this.projectRoot = projectRoot + // @ts-expect-error TS(2339) FIXME: Property 'timeouts' does not exist on type 'Functi... Remove this comment to see the full error message this.timeouts = timeouts + // @ts-expect-error TS(2339) FIXME: Property 'settings' does not exist on type 'Functi... Remove this comment to see the full error message this.settings = settings /** @@ -58,6 +73,7 @@ export class FunctionsRegistry { * * @type {import("../blobs/blobs.mjs").BlobsContext} */ + // @ts-expect-error TS(2339) FIXME: Property 'blobsContext' does not exist on type 'Fu... Remove this comment to see the full error message this.blobsContext = blobsContext /** @@ -67,6 +83,7 @@ export class FunctionsRegistry { * * @type {Record} */ + // @ts-expect-error TS(2339) FIXME: Property 'buildCache' does not exist on type 'Func... Remove this comment to see the full error message this.buildCache = {} /** @@ -76,6 +93,7 @@ export class FunctionsRegistry { * * @type {Map>>} */ + // @ts-expect-error TS(2339) FIXME: Property 'directoryWatchers' does not exist on typ... Remove this comment to see the full error message this.directoryWatchers = new Map() /** @@ -83,6 +101,7 @@ export class FunctionsRegistry { * * @type {Map} */ + // @ts-expect-error TS(2339) FIXME: Property 'functions' does not exist on type 'Funct... Remove this comment to see the full error message this.functions = new Map() /** @@ -91,12 +110,14 @@ export class FunctionsRegistry { * * @type {Map>>} */ + // @ts-expect-error TS(2339) FIXME: Property 'functionWatchers' does not exist on type... Remove this comment to see the full error message this.functionWatchers = new Map() /** * Keeps track of whether we've checked whether `TYPES_PACKAGE` is * installed. */ + // @ts-expect-error TS(2339) FIXME: Property 'hasCheckedTypesPackage' does not exist o... Remove this comment to see the full error message this.hasCheckedTypesPackage = false /** @@ -104,6 +125,7 @@ export class FunctionsRegistry { * * @type {boolean} */ + // @ts-expect-error TS(2339) FIXME: Property 'logLambdaCompat' does not exist on type ... Remove this comment to see the full error message this.logLambdaCompat = Boolean(logLambdaCompat) /** @@ -112,22 +134,29 @@ export class FunctionsRegistry { * * @type {object} */ + // @ts-expect-error TS(2339) FIXME: Property 'manifest' does not exist on type 'Functi... Remove this comment to see the full error message this.manifest = manifest } checkTypesPackage() { + // @ts-expect-error TS(2339) FIXME: Property 'hasCheckedTypesPackage' does not exist o... Remove this comment to see the full error message if (this.hasCheckedTypesPackage) { return } + // @ts-expect-error TS(2339) FIXME: Property 'hasCheckedTypesPackage' does not exist o... Remove this comment to see the full error message this.hasCheckedTypesPackage = true + // @ts-expect-error TS(2339) FIXME: Property 'projectRoot' does not exist on type 'Fun... Remove this comment to see the full error message const require = createRequire(this.projectRoot) try { + // @ts-expect-error TS(2339) FIXME: Property 'projectRoot' does not exist on type 'Fun... Remove this comment to see the full error message require.resolve(TYPES_PACKAGE, { paths: [this.projectRoot] }) } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error?.code === 'MODULE_NOT_FOUND') { + // @ts-expect-error TS(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message FunctionsRegistry.logEvent('missing-types-package', {}) } } @@ -140,6 +169,7 @@ export class FunctionsRegistry { * * @param {string} directory */ + // @ts-expect-error TS(7006) FIXME: Parameter 'directory' implicitly has an 'any' type... Remove this comment to see the full error message static async prepareDirectoryScan(directory) { await mkdir(directory, { recursive: true }) @@ -148,10 +178,12 @@ export class FunctionsRegistry { // `onDirectoryScan` hook, we run it. await Promise.all( Object.values(runtimes).map((runtime) => { + // @ts-expect-error TS(2339) FIXME: Property 'onDirectoryScan' does not exist on type ... Remove this comment to see the full error message if (typeof runtime.onDirectoryScan !== 'function') { return null } + // @ts-expect-error TS(2339) FIXME: Property 'onDirectoryScan' does not exist on type ... Remove this comment to see the full error message return runtime.onDirectoryScan({ directory }) }), ) @@ -165,11 +197,13 @@ export class FunctionsRegistry { * @param {boolean} [firstLoad ] * @returns */ + // @ts-expect-error TS(7006) FIXME: Parameter 'func' implicitly has an 'any' type. async buildFunctionAndWatchFiles(func, firstLoad = false) { if (!firstLoad) { FunctionsRegistry.logEvent('reloading', { func }) } + // @ts-expect-error TS(2339) FIXME: Property 'buildCache' does not exist on type 'Func... Remove this comment to see the full error message const { error: buildError, includedFiles, srcFilesDiff } = await func.build({ cache: this.buildCache }) if (buildError) { @@ -188,6 +222,7 @@ export class FunctionsRegistry { : `refer to https://ntl.fyi/functions-runtime` const warning = `The function is using the legacy CommonJS format. To start using ES modules, ${action}.` + // @ts-expect-error TS(2322) FIXME: Type 'string' is not assignable to type 'never'. FunctionsRegistry.logEvent(event, { func, warnings: [warning] }) } else { FunctionsRegistry.logEvent(event, { func }) @@ -204,15 +239,18 @@ export class FunctionsRegistry { return } + // @ts-expect-error TS(2339) FIXME: Property 'functionWatchers' does not exist on type... Remove this comment to see the full error message const watcher = this.functionWatchers.get(func.name) // If there is already a watcher for this function, we need to unwatch any // files that have been removed and watch any files that have been added. if (watcher) { + // @ts-expect-error TS(7006) FIXME: Parameter 'path' implicitly has an 'any' type. srcFilesDiff.deleted.forEach((path) => { watcher.unwatch(path) }) + // @ts-expect-error TS(7006) FIXME: Parameter 'path' implicitly has an 'any' type. srcFilesDiff.added.forEach((path) => { watcher.add(path) }) @@ -224,12 +262,14 @@ export class FunctionsRegistry { // we create a new watcher and watch them. if (srcFilesDiff.added.size !== 0) { const filesToWatch = [...srcFilesDiff.added, ...includedFiles] + // @ts-expect-error TS(2345) FIXME: Argument of type '{ onChange: () => void; }' is no... Remove this comment to see the full error message const newWatcher = await watchDebounced(filesToWatch, { onChange: () => { this.buildFunctionAndWatchFiles(func, false) }, }) + // @ts-expect-error TS(2339) FIXME: Property 'functionWatchers' does not exist on type... Remove this comment to see the full error message this.functionWatchers.set(func.name, newWatcher) } } @@ -239,7 +279,9 @@ export class FunctionsRegistry { * * @param {string} name */ + // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. get(name) { + // @ts-expect-error TS(2339) FIXME: Property 'functions' does not exist on type 'Funct... Remove this comment to see the full error message return this.functions.get(name) } @@ -253,6 +295,7 @@ export class FunctionsRegistry { * @param {string} url * @param {string} method */ + // @ts-expect-error TS(7006) FIXME: Parameter 'url' implicitly has an 'any' type. async getFunctionForURLPath(url, method) { // We're constructing a URL object just so that we can extract the path from // the incoming URL. It doesn't really matter that we don't have the actual @@ -270,6 +313,7 @@ export class FunctionsRegistry { const { routes = [] } = await func.getBuildData() if (routes.length !== 0) { + // @ts-expect-error TS(7006) FIXME: Parameter 'route' implicitly has an 'any' type. const paths = routes.map((route) => chalk.underline(route.pattern)).join(', ') warn( @@ -284,6 +328,7 @@ export class FunctionsRegistry { return { func, route: null } } + // @ts-expect-error TS(2339) FIXME: Property 'functions' does not exist on type 'Funct... Remove this comment to see the full error message for (const func of this.functions.values()) { const route = await func.matchURLPath(urlPath, method) @@ -302,6 +347,7 @@ export class FunctionsRegistry { * @param {string[]} [data.warnings] * @returns */ + // @ts-expect-error TS(7006) FIXME: Parameter 'event' implicitly has an 'any' type. static logEvent(event, { func, warnings = [] }) { let warningsText = '' @@ -331,6 +377,7 @@ export class FunctionsRegistry { const icon = warningsText ? NETLIFYDEVWARN : NETLIFYDEVLOG const color = warningsText ? chalk.yellow : chalk.green const mode = + // @ts-expect-error TS(2339) FIXME: Property 'logLambdaCompat' does not exist on type ... Remove this comment to see the full error message func?.runtimeAPIVersion === 1 && this.logLambdaCompat ? ` in ${getTerminalLink('Lambda compatibility mode', 'https://ntl.fyi/lambda-compat')}` : '' @@ -376,6 +423,7 @@ export class FunctionsRegistry { * @param {boolean} [isReload] * @returns */ + // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. async registerFunction(name, funcBeforeHook, isReload = false) { const { runtime } = funcBeforeHook @@ -388,6 +436,7 @@ export class FunctionsRegistry { return } + // @ts-expect-error TS(2339) FIXME: Property 'isConnected' does not exist on type 'Fun... Remove this comment to see the full error message if (func.isBackground && this.isConnected && !this.capabilities.backgroundFunctions) { warn(BACKGROUND_FUNCTIONS_WARNING) } @@ -403,12 +452,14 @@ export class FunctionsRegistry { if (extname(func.mainFile) === ZIP_EXTENSION) { const unzippedDirectory = await this.unzipFunction(func) + // @ts-expect-error TS(2339) FIXME: Property 'debug' does not exist on type 'Functions... Remove this comment to see the full error message if (this.debug) { FunctionsRegistry.logEvent('extracted', { func }) } // If there's a manifest file, look up the function in order to extract // the build data. + // @ts-expect-error TS(2339) FIXME: Property 'manifest' does not exist on type 'Functi... Remove this comment to see the full error message const manifestEntry = (this.manifest?.functions || []).find((manifestFunc) => manifestFunc.name === func.name) func.buildData = manifestEntry?.buildData || {} @@ -430,6 +481,7 @@ export class FunctionsRegistry { this.buildFunctionAndWatchFiles(func, !isReload) } + // @ts-expect-error TS(2339) FIXME: Property 'functions' does not exist on type 'Funct... Remove this comment to see the full error message this.functions.set(name, func) } @@ -439,8 +491,10 @@ export class FunctionsRegistry { * @param {Parameters} args * @returns */ + // @ts-expect-error TS(7019) FIXME: Rest parameter 'args' implicitly has an 'any[]' ty... Remove this comment to see the full error message // eslint-disable-next-line class-methods-use-this async listFunctions(...args) { + // @ts-expect-error TS(2556) FIXME: A spread argument must either have a tuple type or... Remove this comment to see the full error message return await listFunctions(...args) } @@ -451,7 +505,9 @@ export class FunctionsRegistry { * * @param {string[]} relativeDirs */ + // @ts-expect-error TS(7006) FIXME: Parameter 'relativeDirs' implicitly has an 'any' t... Remove this comment to see the full error message async scan(relativeDirs) { + // @ts-expect-error TS(7006) FIXME: Parameter 'dir' implicitly has an 'any' type. const directories = relativeDirs.filter(Boolean).map((dir) => (isAbsolute(dir) ? dir : join(this.projectRoot, dir))) // check after filtering to filter out [undefined] for example @@ -459,6 +515,7 @@ export class FunctionsRegistry { return } + // @ts-expect-error TS(7006) FIXME: Parameter 'path' implicitly has an 'any' type. await Promise.all(directories.map((path) => FunctionsRegistry.prepareDirectoryScan(path))) const functions = await this.listFunctions(directories, { @@ -466,11 +523,13 @@ export class FunctionsRegistry { buildRustSource: env.NETLIFY_EXPERIMENTAL_BUILD_RUST_SOURCE === 'true', }, configFileDirectories: [getPathInProject([INTERNAL_FUNCTIONS_FOLDER])], + // @ts-expect-error TS(2339) FIXME: Property 'config' does not exist on type 'Function... Remove this comment to see the full error message config: this.config.functions, }) // Before registering any functions, we look for any functions that were on // the previous list but are missing from the new one. We unregister them. + // @ts-expect-error TS(2339) FIXME: Property 'functions' does not exist on type 'Funct... Remove this comment to see the full error message const deletedFunctions = [...this.functions.values()].filter((oldFunc) => { const isFound = functions.some( (newFunc) => newFunc.name === oldFunc.name && newFunc.mainFile === oldFunc.mainFile, @@ -496,21 +555,29 @@ export class FunctionsRegistry { } // If this function has already been registered, we skip it. + // @ts-expect-error TS(2339) FIXME: Property 'functions' does not exist on type 'Funct... Remove this comment to see the full error message if (this.functions.has(name)) { return } const func = new NetlifyFunction({ + // @ts-expect-error TS(2339) FIXME: Property 'blobsContext' does not exist on type 'Fu... Remove this comment to see the full error message blobsContext: this.blobsContext, + // @ts-expect-error TS(2339) FIXME: Property 'config' does not exist on type 'Function... Remove this comment to see the full error message config: this.config, + // @ts-expect-error TS(7006) FIXME: Parameter 'directory' implicitly has an 'any' type... Remove this comment to see the full error message directory: directories.find((directory) => mainFile.startsWith(directory)), mainFile, name, displayName, + // @ts-expect-error TS(2339) FIXME: Property 'projectRoot' does not exist on type 'Fun... Remove this comment to see the full error message projectRoot: this.projectRoot, runtime, + // @ts-expect-error TS(2339) FIXME: Property 'timeouts' does not exist on type 'Functi... Remove this comment to see the full error message timeoutBackground: this.timeouts.backgroundFunctions, + // @ts-expect-error TS(2339) FIXME: Property 'timeouts' does not exist on type 'Functi... Remove this comment to see the full error message timeoutSynchronous: this.timeouts.syncFunctions, + // @ts-expect-error TS(2339) FIXME: Property 'settings' does not exist on type 'Functi... Remove this comment to see the full error message settings: this.settings, }) @@ -524,6 +591,7 @@ export class FunctionsRegistry { return func }), ) + // @ts-expect-error TS(2339) FIXME: Property 'name' does not exist on type 'NetlifyFun... Remove this comment to see the full error message const addedFunctionNames = new Set(addedFunctions.filter(Boolean).map((func) => func?.name)) deletedFunctions.forEach((func) => { @@ -536,6 +604,7 @@ export class FunctionsRegistry { FunctionsRegistry.logEvent('removed', { func }) }) + // @ts-expect-error TS(7006) FIXME: Parameter 'path' implicitly has an 'any' type. await Promise.all(directories.map((path) => this.setupDirectoryWatcher(path))) } @@ -546,7 +615,9 @@ export class FunctionsRegistry { * * @param {string} directory */ + // @ts-expect-error TS(7006) FIXME: Parameter 'directory' implicitly has an 'any' type... Remove this comment to see the full error message async setupDirectoryWatcher(directory) { + // @ts-expect-error TS(2339) FIXME: Property 'directoryWatchers' does not exist on typ... Remove this comment to see the full error message if (this.directoryWatchers.has(directory)) { return } @@ -561,6 +632,7 @@ export class FunctionsRegistry { }, }) + // @ts-expect-error TS(2339) FIXME: Property 'directoryWatchers' does not exist on typ... Remove this comment to see the full error message this.directoryWatchers.set(directory, watcher) } @@ -569,17 +641,21 @@ export class FunctionsRegistry { * * @param {NetlifyFunction} func */ + // @ts-expect-error TS(7006) FIXME: Parameter 'func' implicitly has an 'any' type. async unregisterFunction(func) { const { name } = func + // @ts-expect-error TS(2339) FIXME: Property 'functions' does not exist on type 'Funct... Remove this comment to see the full error message this.functions.delete(name) + // @ts-expect-error TS(2339) FIXME: Property 'functionWatchers' does not exist on type... Remove this comment to see the full error message const watcher = this.functionWatchers.get(name) if (watcher) { await watcher.close() } + // @ts-expect-error TS(2339) FIXME: Property 'functionWatchers' does not exist on type... Remove this comment to see the full error message this.functionWatchers.delete(name) } @@ -588,8 +664,10 @@ export class FunctionsRegistry { * * @param {NetlifyFunction} func */ + // @ts-expect-error TS(7006) FIXME: Parameter 'func' implicitly has an 'any' type. async unzipFunction(func) { const targetDirectory = resolve( + // @ts-expect-error TS(2339) FIXME: Property 'projectRoot' does not exist on type 'Fun... Remove this comment to see the full error message this.projectRoot, getPathInProject([SERVE_FUNCTIONS_FOLDER, '.unzipped', func.name]), ) diff --git a/src/lib/functions/runtimes/go/index.mjs b/src/lib/functions/runtimes/go/index.mts similarity index 65% rename from src/lib/functions/runtimes/go/index.mjs rename to src/lib/functions/runtimes/go/index.mts index 8814d14a5bf..e79b16c5638 100644 --- a/src/lib/functions/runtimes/go/index.mjs +++ b/src/lib/functions/runtimes/go/index.mts @@ -1,9 +1,10 @@ -// @ts-check + import { dirname, extname } from 'path' import { platform } from 'process' import { temporaryFile } from 'tempy' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../../../../utils/execa.mjs' import { runFunctionsProxy } from '../../local-proxy.mjs' @@ -11,8 +12,10 @@ const isWindows = platform === 'win32' export const name = 'go' +// @ts-expect-error TS(7031) FIXME: Binding element 'binaryPath' implicitly has an 'an... Remove this comment to see the full error message const build = async ({ binaryPath, functionDirectory }) => { try { + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. await execa('go', ['build', '-o', binaryPath], { cwd: functionDirectory }) return { binaryPath, srcFiles: [functionDirectory] } @@ -29,8 +32,10 @@ const build = async ({ binaryPath, functionDirectory }) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'cwd' implicitly has an 'any' type... Remove this comment to see the full error message const checkGoInstallation = async ({ cwd }) => { try { + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. await execa('go', ['version'], { cwd }) return true @@ -39,6 +44,7 @@ const checkGoInstallation = async ({ cwd }) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'func' implicitly has an 'any' typ... Remove this comment to see the full error message export const getBuildFunction = ({ func }) => { const functionDirectory = dirname(func.mainFile) const binaryPath = temporaryFile(isWindows ? { extension: 'exe' } : undefined) @@ -46,6 +52,7 @@ export const getBuildFunction = ({ func }) => { return () => build({ binaryPath, functionDirectory }) } +// @ts-expect-error TS(7031) FIXME: Binding element 'context' implicitly has an 'any' ... Remove this comment to see the full error message export const invokeFunction = async ({ context, event, func, timeout }) => { const { stdout } = await runFunctionsProxy({ binaryPath: func.buildData.binaryPath, @@ -72,6 +79,7 @@ export const invokeFunction = async ({ context, event, func, timeout }) => { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'func' implicitly has an 'any' type. export const onRegister = (func) => { const isSource = extname(func.mainFile) === '.go' diff --git a/src/lib/functions/runtimes/index.mjs b/src/lib/functions/runtimes/index.mts similarity index 100% rename from src/lib/functions/runtimes/index.mjs rename to src/lib/functions/runtimes/index.mts diff --git a/src/lib/functions/runtimes/js/builders/netlify-lambda.mjs b/src/lib/functions/runtimes/js/builders/netlify-lambda.mts similarity index 82% rename from src/lib/functions/runtimes/js/builders/netlify-lambda.mjs rename to src/lib/functions/runtimes/js/builders/netlify-lambda.mts index 206fd2ebb2f..b9247837e36 100644 --- a/src/lib/functions/runtimes/js/builders/netlify-lambda.mjs +++ b/src/lib/functions/runtimes/js/builders/netlify-lambda.mts @@ -1,23 +1,27 @@ -// @ts-check + import { readFile } from 'fs/promises' import { resolve } from 'path' import minimist from 'minimist' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../../../../../utils/execa.mjs' import { fileExistsAsync } from '../../../../fs.mjs' import { memoizedBuild } from '../../../memoized-build.mjs' +// @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message export const detectNetlifyLambda = async function ({ packageJson } = {}) { const { dependencies, devDependencies, scripts } = packageJson || {} if (!((dependencies && dependencies['netlify-lambda']) || (devDependencies && devDependencies['netlify-lambda']))) { return false } + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. const matchingScripts = Object.entries(scripts).filter(([, script]) => script.match(/netlify-lambda\s+build/)) for (const [key, script] of matchingScripts) { // E.g. ["netlify-lambda", "build", "functions/folder"] + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. const match = minimist(script.split(' '), { // these are all valid options for netlify-lambda boolean: ['s', 'static'], @@ -29,6 +33,7 @@ export const detectNetlifyLambda = async function ({ packageJson } = {}) { const srcFiles = [resolve(functionDirectories[0])] const yarnExists = await fileExistsAsync('yarn.lock') + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. const buildCommand = () => execa(yarnExists ? 'yarn' : 'npm', ['run', key]) return { diff --git a/src/lib/functions/runtimes/js/builders/zisi.mjs b/src/lib/functions/runtimes/js/builders/zisi.mts similarity index 68% rename from src/lib/functions/runtimes/js/builders/zisi.mjs rename to src/lib/functions/runtimes/js/builders/zisi.mts index 056d9f18758..45fcecfd5db 100644 --- a/src/lib/functions/runtimes/js/builders/zisi.mjs +++ b/src/lib/functions/runtimes/js/builders/zisi.mts @@ -5,6 +5,7 @@ import path from 'path' import { zipFunction, listFunction } from '@netlify/zip-it-and-ship-it' import decache from 'decache' import { readPackageUp } from 'read-pkg-up' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'sour... Remove this comment to see the full error message import sourceMapSupport from 'source-map-support' import { NETLIFYDEVERR } from '../../../../../utils/command-helpers.mjs' @@ -15,6 +16,7 @@ import { memoizedBuild } from '../../../memoized-build.mjs' const require = createRequire(import.meta.url) +// @ts-expect-error TS(7006) FIXME: Parameter 'config' implicitly has an 'any' type. const addFunctionsConfigDefaults = (config) => ({ ...config, '*': { @@ -28,13 +30,21 @@ const addFunctionsConfigDefaults = (config) => ({ * @param {import("@netlify/zip-it-and-ship-it/dist/feature_flags.js").FeatureFlags} params.featureFlags */ const buildFunction = async ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'cache' implicitly has an 'any' ty... Remove this comment to see the full error message cache, + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message config, + // @ts-expect-error TS(7031) FIXME: Binding element 'directory' implicitly has an 'any... Remove this comment to see the full error message directory, + // @ts-expect-error TS(7031) FIXME: Binding element 'featureFlags' implicitly has an '... Remove this comment to see the full error message featureFlags, + // @ts-expect-error TS(7031) FIXME: Binding element 'func' implicitly has an 'any' typ... Remove this comment to see the full error message func, + // @ts-expect-error TS(7031) FIXME: Binding element 'hasTypeModule' implicitly has an ... Remove this comment to see the full error message hasTypeModule, + // @ts-expect-error TS(7031) FIXME: Binding element 'projectRoot' implicitly has an 'a... Remove this comment to see the full error message projectRoot, + // @ts-expect-error TS(7031) FIXME: Binding element 'targetDirectory' implicitly has a... Remove this comment to see the full error message targetDirectory, }) => { const zipOptions = { @@ -66,8 +76,10 @@ const buildFunction = async ({ } = await memoizedBuild({ cache, cacheKey: `zisi-${entryPath}`, + // @ts-expect-error TS(2345) FIXME: Argument of type '{ archiveFormat: string; basePat... Remove this comment to see the full error message command: () => zipFunction(entryPath, targetDirectory, zipOptions), }) + // @ts-expect-error TS(7006) FIXME: Parameter 'inputPath' implicitly has an 'any' type... Remove this comment to see the full error message const srcFiles = inputs.filter((inputPath) => !inputPath.includes(`${path.sep}node_modules${path.sep}`)) const buildPath = path.join(functionPath, entryFilename) @@ -93,18 +105,22 @@ const buildFunction = async ({ * @param {string} params.mainFile * @param {string} params.projectRoot */ +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message export const parseFunctionForMetadata = async ({ config, mainFile, projectRoot }) => await listFunction(mainFile, { config: netlifyConfigToZisiConfig({ config, projectRoot }), + // @ts-expect-error TS(2322) FIXME: Type '{ zisi_functions_api_v2: true; }' is not ass... Remove this comment to see the full error message featureFlags: { zisi_functions_api_v2: true }, parseISC: true, }) // Clears the cache for any files inside the directory from which functions are // served. +// @ts-expect-error TS(7006) FIXME: Parameter 'functionsPath' implicitly has an 'any' ... Remove this comment to see the full error message const clearFunctionsCache = (functionsPath) => { Object.keys(require.cache) .filter((key) => key.startsWith(functionsPath)) + // @ts-expect-error .forEach(decache) } @@ -115,6 +131,7 @@ const clearFunctionsCache = (functionsPath) => { * @param {(msg: string) => void} config.errorExit * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'errorExit' implicitly has an 'any... Remove this comment to see the full error message const getTargetDirectory = async ({ errorExit, projectRoot }) => { const targetDirectory = path.resolve(projectRoot, getPathInProject([SERVE_FUNCTIONS_FOLDER])) @@ -127,6 +144,7 @@ const getTargetDirectory = async ({ errorExit, projectRoot }) => { return targetDirectory } +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message const netlifyConfigToZisiConfig = ({ config, projectRoot }) => addFunctionsConfigDefaults(normalizeFunctionsConfig({ functionsConfig: config.functions, projectRoot })) @@ -140,6 +158,7 @@ const netlifyConfigToZisiConfig = ({ config, projectRoot }) => * @param {*} param0.metadata * @param {string} param0.projectRoot */ +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message export default async function handler({ config, directory, errorExit, func, metadata, projectRoot }) { const functionsConfig = netlifyConfigToZisiConfig({ config, projectRoot }) @@ -150,7 +169,9 @@ export default async function handler({ config, directory, errorExit, func, meta const featureFlags = {} if (metadata.runtimeAPIVersion === 2) { + // @ts-expect-error TS(2339) FIXME: Property 'zisi_pure_esm' does not exist on type '{... Remove this comment to see the full error message featureFlags.zisi_pure_esm = true + // @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 featureFlags.zisi_pure_esm_mjs = true } else { // We must use esbuild for certain file extensions. diff --git a/src/lib/functions/runtimes/js/constants.mjs b/src/lib/functions/runtimes/js/constants.mts similarity index 100% rename from src/lib/functions/runtimes/js/constants.mjs rename to src/lib/functions/runtimes/js/constants.mts diff --git a/src/lib/functions/runtimes/js/index.mjs b/src/lib/functions/runtimes/js/index.mts similarity index 81% rename from src/lib/functions/runtimes/js/index.mjs rename to src/lib/functions/runtimes/js/index.mts index 493f9691a7f..136e0f114a4 100644 --- a/src/lib/functions/runtimes/js/index.mjs +++ b/src/lib/functions/runtimes/js/index.mts @@ -11,6 +11,7 @@ import { SECONDS_TO_MILLISECONDS } from './constants.mjs' export const name = 'js' +// @ts-expect-error TS(7034) FIXME: Variable 'netlifyLambdaDetectorCache' implicitly h... Remove this comment to see the full error message let netlifyLambdaDetectorCache lambdaLocal.getLogger().level = 'alert' @@ -19,13 +20,16 @@ lambdaLocal.getLogger().level = 'alert' // basis and its detection mechanism is also quite expensive, so we detect // it once and cache the result. const detectNetlifyLambdaWithCache = () => { + // @ts-expect-error TS(7005) FIXME: Variable 'netlifyLambdaDetectorCache' implicitly h... Remove this comment to see the full error message if (netlifyLambdaDetectorCache === undefined) { netlifyLambdaDetectorCache = detectNetlifyLambdaBuilder() } + // @ts-expect-error TS(7005) FIXME: Variable 'netlifyLambdaDetectorCache' implicitly h... Remove this comment to see the full error message return netlifyLambdaDetectorCache } +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message export const getBuildFunction = async ({ config, directory, errorExit, func, projectRoot }) => { const netlifyLambdaBuilder = await detectNetlifyLambdaWithCache() @@ -46,11 +50,13 @@ export const getBuildFunction = async ({ config, directory, errorExit, func, pro const functionDirectory = dirname(func.mainFile) const srcFiles = functionDirectory === directory ? [func.mainFile] : [functionDirectory] + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. return () => ({ schedule: metadata.schedule, srcFiles }) } const workerURL = new URL('worker.mjs', import.meta.url) +// @ts-expect-error TS(7031) FIXME: Binding element 'context' implicitly has an 'any' ... Remove this comment to see the full error message export const invokeFunction = async ({ context, environment, event, func, timeout }) => { if (func.buildData.runtimeAPIVersion !== 2) { return await invokeFunctionDirectly({ context, event, func, timeout }) @@ -91,6 +97,7 @@ export const invokeFunction = async ({ context, environment, event, func, timeou }) } +// @ts-expect-error TS(7031) FIXME: Binding element 'context' implicitly has an 'any' ... Remove this comment to see the full error message export const invokeFunctionDirectly = async ({ context, event, func, timeout }) => { // If a function builder has defined a `buildPath` property, we use it. // Otherwise, we'll invoke the function's main file. diff --git a/src/lib/functions/runtimes/js/worker.mjs b/src/lib/functions/runtimes/js/worker.mts similarity index 64% rename from src/lib/functions/runtimes/js/worker.mjs rename to src/lib/functions/runtimes/js/worker.mts index 5b2d9f2583b..fcaa12e2cfd 100644 --- a/src/lib/functions/runtimes/js/worker.mjs +++ b/src/lib/functions/runtimes/js/worker.mts @@ -4,6 +4,7 @@ import { isMainThread, workerData, parentPort } from 'worker_threads' import { isStream } from 'is-stream' import lambdaLocal from 'lambda-local' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'sour... Remove this comment to see the full error message import sourceMapSupport from 'source-map-support' if (isMainThread) { @@ -34,8 +35,11 @@ const result = await lambdaLocal.execute({ // When the result body is a StreamResponse // we open up a http server that proxies back to the main thread. +// @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (result && isStream(result.body)) { + // @ts-expect-error TS(2339) FIXME: Property 'body' does not exist on type 'unknown'. const { body } = result + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. delete result.body await new Promise((resolve, reject) => { const server = createServer((socket) => { @@ -45,11 +49,15 @@ if (result && isStream(result.body)) { reject(error) }) server.listen({ port: 0, host: 'localhost' }, () => { + // @ts-expect-error TS(2339) FIXME: Property 'port' does not exist on type 'string | A... Remove this comment to see the full error message const { port } = server.address() + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. result.streamPort = port + // @ts-expect-error TS(2794) FIXME: Expected 1 arguments, but got 0. Did you forget to... Remove this comment to see the full error message resolve() }) }) } +// @ts-expect-error TS(2531) FIXME: Object is possibly 'null'. parentPort.postMessage(result) diff --git a/src/lib/functions/runtimes/rust/index.mjs b/src/lib/functions/runtimes/rust/index.mts similarity index 69% rename from src/lib/functions/runtimes/rust/index.mjs rename to src/lib/functions/runtimes/rust/index.mts index 08e897c47cc..e304f13933b 100644 --- a/src/lib/functions/runtimes/rust/index.mjs +++ b/src/lib/functions/runtimes/rust/index.mts @@ -1,4 +1,4 @@ -// @ts-check + import { readFile } from 'fs/promises' import { dirname, extname, join, resolve } from 'path' import { platform } from 'process' @@ -6,6 +6,7 @@ import { platform } from 'process' import { findUp } from 'find-up' import toml from 'toml' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../../../../utils/execa.mjs' import { SERVE_FUNCTIONS_FOLDER } from '../../../../utils/functions/functions.mjs' import { getPathInProject } from '../../../settings.mjs' @@ -15,6 +16,7 @@ const isWindows = platform === 'win32' export const name = 'rs' +// @ts-expect-error TS(7031) FIXME: Binding element 'func' implicitly has an 'any' typ... Remove this comment to see the full error message const build = async ({ func }) => { const functionDirectory = dirname(func.mainFile) const cacheDirectory = resolve(getPathInProject([SERVE_FUNCTIONS_FOLDER])) @@ -23,6 +25,7 @@ const build = async ({ func }) => { const binaryName = `${crateName}${isWindows ? '.exe' : ''}` const binaryPath = join(targetDirectory, 'debug', binaryName) + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. await execa('cargo', ['build', '--target-dir', targetDirectory], { cwd: functionDirectory, }) @@ -34,18 +37,22 @@ const build = async ({ func }) => { } export const getBuildFunction = + // @ts-expect-error TS(7031) FIXME: Binding element 'func' implicitly has an 'any' typ... Remove this comment to see the full error message ({ func }) => () => build({ func }) +// @ts-expect-error TS(7006) FIXME: Parameter 'cwd' implicitly has an 'any' type. const getCrateName = async (cwd) => { const manifestPath = await findUp('Cargo.toml', { cwd, type: 'file' }) + // @ts-expect-error TS(2769) FIXME: No overload matches this call. const manifest = await readFile(manifestPath, 'utf-8') const { package: CargoPackage } = toml.parse(manifest) return CargoPackage.name } +// @ts-expect-error TS(7031) FIXME: Binding element 'context' implicitly has an 'any' ... Remove this comment to see the full error message export const invokeFunction = async ({ context, event, func, timeout }) => { const { stdout } = await runFunctionsProxy({ binaryPath: func.buildData.binaryPath, @@ -72,6 +79,7 @@ export const invokeFunction = async ({ context, event, func, timeout }) => { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'func' implicitly has an 'any' type. export const onRegister = (func) => { const isSource = extname(func.mainFile) === '.rs' diff --git a/src/lib/functions/scheduled.mjs b/src/lib/functions/scheduled.mts similarity index 88% rename from src/lib/functions/scheduled.mjs rename to src/lib/functions/scheduled.mts index fa7d76ef26b..6752f9dee0d 100644 --- a/src/lib/functions/scheduled.mjs +++ b/src/lib/functions/scheduled.mts @@ -6,9 +6,11 @@ import { formatLambdaError } from './utils.mjs' const ansiToHtml = new AnsiToHtml() +// @ts-expect-error TS(7031) FIXME: Binding element 'error' implicitly has an 'any' ty... Remove this comment to see the full error message export const buildHelpResponse = ({ error, headers, path, result }) => { const acceptsHtml = headers.accept && headers.accept.includes('text/html') + // @ts-expect-error TS(7006) FIXME: Parameter 'text' implicitly has an 'any' type. const paragraph = (text) => { text = text.trim() @@ -84,6 +86,7 @@ At the moment, Netlify does nothing about that. In the future, there might be a } } +// @ts-expect-error TS(7031) FIXME: Binding element 'error' implicitly has an 'any' ty... Remove this comment to see the full error message export const handleScheduledFunction = ({ error, request, response, result }) => { const { contentType, message, statusCode } = buildHelpResponse({ error, diff --git a/src/lib/functions/server.mjs b/src/lib/functions/server.mts similarity index 88% rename from src/lib/functions/server.mjs rename to src/lib/functions/server.mts index 5f5f7f8abd3..d827c056eae 100644 --- a/src/lib/functions/server.mjs +++ b/src/lib/functions/server.mts @@ -1,9 +1,9 @@ -// @ts-check import { Buffer } from 'buffer' import { promises as fs } from 'fs' import path from 'path' import express from 'express' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'expr... Remove this comment to see the full error message import expressLogging from 'express-logging' import jwtDecode from 'jwt-decode' @@ -26,6 +26,7 @@ import { handleScheduledFunction } from './scheduled.mjs' import { handleSynchronousFunction } from './synchronous.mjs' import { shouldBase64Encode } from './utils.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'headers' implicitly has an 'any' type. const buildClientContext = function (headers) { // inject a client context based on auth header, ported over from netlify-lambda (https://github.com/netlify/netlify-lambda/pull/57) if (!headers.authorization) return @@ -46,6 +47,7 @@ const buildClientContext = function (headers) { // "testData": "NETLIFY_DEV_LOCALLY_EMULATED_IDENTITY" // } }, + // @ts-expect-error user: jwtDecode(parts[1]), } } catch { @@ -53,6 +55,7 @@ const buildClientContext = function (headers) { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. const hasBody = (req) => // copied from is-type package // eslint-disable-next-line unicorn/prefer-number-properties @@ -60,9 +63,11 @@ const hasBody = (req) => // we expect a string or a buffer, because we use the two bodyParsers(text, raw) from express (typeof req.body === 'string' || Buffer.isBuffer(req.body)) +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const createHandler = function (options) { const { functionsRegistry } = options + // @ts-expect-error TS(7006) FIXME: Parameter 'request' implicitly has an 'any' type. return async function handler(request, response) { // If these headers are set, it means we've already matched a function and we // can just grab its name directly. We delete the header from the request @@ -118,6 +123,7 @@ export const createHandler = function (options) { const searchParams = new URLSearchParams(request.header('x-netlify-original-search')) for (const key of searchParams.keys()) { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message newRequestQuery[key] = searchParams.getAll(key) } @@ -149,10 +155,12 @@ export const createHandler = function (options) { path: requestPath, httpMethod: request.method, queryStringParameters: Object.entries(queryParams).reduce( + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. (prev, [key, value]) => ({ ...prev, [key]: value.join(', ') }), {}, ), multiValueQueryStringParameters: queryParams, + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. headers: Object.entries(headers).reduce((prev, [key, value]) => ({ ...prev, [key]: value.join(', ') }), {}), multiValueHeaders: headers, body, @@ -212,6 +220,7 @@ export const createHandler = function (options) { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const getFunctionsServer = (options) => { const { buildersPrefix = '', functionsPrefix = '', functionsRegistry, siteUrl } = options const app = express() @@ -255,6 +264,7 @@ const getFunctionsServer = (options) => { * @param {*} options.timeouts * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const startFunctionsServer = async (options) => { const { blobsContext, @@ -269,6 +279,7 @@ export const startFunctionsServer = async (options) => { siteUrl, timeouts, } = options + // @ts-expect-error TS(2345) FIXME: Argument of type '{ base: any; }' is not assignabl... Remove this comment to see the full error message const internalFunctionsDir = await getInternalFunctionsDir({ base: site.root }) const functionsDirectories = [] let manifest @@ -344,14 +355,17 @@ export const startFunctionsServer = async (options) => { * @param {ReturnType>} config.server * @param {*} config.settings */ +// @ts-expect-error TS(7031) FIXME: Binding element 'debug' implicitly has an 'any' ty... Remove this comment to see the full error message const startWebServer = async ({ debug, server, settings }) => { await new Promise((/** @type {(resolve: void) => void} */ resolve) => { + // @ts-expect-error TS(7006) FIXME: Parameter 'err' implicitly has an 'any' type. server.listen(settings.functionsPort, (/** @type {unknown} */ err) => { if (err) { errorExit(`${NETLIFYDEVERR} Unable to start functions server: ${err}`) } else if (debug) { log(`${NETLIFYDEVLOG} Functions server is listening on ${settings.functionsPort}`) } + // @ts-expect-error TS(2794) FIXME: Expected 1 arguments, but got 0. Did you forget to... Remove this comment to see the full error message resolve() }) }) diff --git a/src/lib/functions/synchronous.mjs b/src/lib/functions/synchronous.mts similarity index 76% rename from src/lib/functions/synchronous.mjs rename to src/lib/functions/synchronous.mts index 499cd901d5e..862151972c6 100644 --- a/src/lib/functions/synchronous.mjs +++ b/src/lib/functions/synchronous.mts @@ -1,4 +1,4 @@ -// @ts-check + import { Buffer } from 'buffer' import { isStream } from 'is-stream' @@ -15,6 +15,7 @@ import { detectAwsSdkError } from './utils.mjs' * @property {Array} stackTrace */ +// @ts-expect-error TS(7006) FIXME: Parameter 'headers' implicitly has an 'any' type. const addHeaders = (headers, response) => { if (!headers) { return @@ -26,10 +27,15 @@ const addHeaders = (headers, response) => { } export const handleSynchronousFunction = function ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'invocationError' implicitly has a... Remove this comment to see the full error message error: invocationError, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionName' implicitly has an '... Remove this comment to see the full error message functionName, + // @ts-expect-error TS(7031) FIXME: Binding element 'request' implicitly has an 'any' ... Remove this comment to see the full error message request, + // @ts-expect-error TS(7031) FIXME: Binding element 'response' implicitly has an 'any'... Remove this comment to see the full error message response, + // @ts-expect-error TS(7031) FIXME: Binding element 'result' implicitly has an 'any' t... Remove this comment to see the full error message result, }) { if (invocationError) { @@ -87,6 +93,7 @@ export const handleSynchronousFunction = function ({ * @param {InvocationError|Error} error * @returns {InvocationError} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'error' implicitly has an 'any' type. const getNormalizedError = (error) => { if (error instanceof Error) { const normalizedError = { @@ -108,6 +115,7 @@ const getNormalizedError = (error) => { // Formatting stack trace lines in the same way that Node.js formats native // errors. + // @ts-expect-error TS(7006) FIXME: Parameter 'line' implicitly has an 'any' type. const stackTrace = error.stackTrace.map((line) => ` at ${line}`) return { @@ -117,6 +125,7 @@ const getNormalizedError = (error) => { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'rawError' implicitly has an 'any' type. const formatLambdaLocalError = (rawError, acceptsHTML) => { const error = getNormalizedError(rawError) @@ -131,7 +140,9 @@ const formatLambdaLocalError = (rawError, acceptsHTML) => { return `${error.errorType}: ${error.errorMessage}\n ${error.stackTrace.join('\n')}` } +// @ts-expect-error TS(7006) FIXME: Parameter 'err' implicitly has an 'any' type. const handleErr = async (err, request, response) => { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ err: any; }' is not assignable... Remove this comment to see the full error message detectAwsSdkError({ err }) const acceptsHtml = request.headers && request.headers.accept && request.headers.accept.includes('text/html') @@ -147,6 +158,7 @@ const handleErr = async (err, request, response) => { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'lambdaResponse' implicitly has an 'any'... Remove this comment to see the full error message const validateLambdaResponse = (lambdaResponse) => { if (lambdaResponse === undefined) { return { error: 'lambda response was undefined. check your function code again' } diff --git a/src/lib/functions/utils.mjs b/src/lib/functions/utils.mts similarity index 75% rename from src/lib/functions/utils.mjs rename to src/lib/functions/utils.mts index bc66ae149af..8830ff10dc4 100644 --- a/src/lib/functions/utils.mjs +++ b/src/lib/functions/utils.mts @@ -1,7 +1,8 @@ -// @ts-check + import { chalk, warn } from '../../utils/command-helpers.mjs' import { MISSING_AWS_SDK_WARNING } from '../log.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'error' implicitly has an 'any' ty... Remove this comment to see the full error message export const detectAwsSdkError = ({ error }) => { const isAwsSdkError = error && error.errorMessage && error.errorMessage.includes("Cannot find module 'aws-sdk'") @@ -10,6 +11,7 @@ export const detectAwsSdkError = ({ error }) => { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'err' implicitly has an 'any' type. export const formatLambdaError = (err) => chalk.red(`${err.errorType}: ${err.errorMessage}`) // should be equivalent to https://github.com/netlify/proxy/blob/main/pkg/functions/request.go#L105 @@ -27,6 +29,7 @@ const exceptionsList = new Set([ * @param {string | undefined} contentType * @returns {boolean} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'contentType' implicitly has an 'any' ty... Remove this comment to see the full error message export const shouldBase64Encode = function (contentType) { if (!contentType) { return true @@ -51,4 +54,5 @@ export const shouldBase64Encode = function (contentType) { return true } +// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. export const styleFunctionName = (name) => chalk.magenta(name) diff --git a/src/lib/geo-location.mjs b/src/lib/geo-location.mts similarity index 92% rename from src/lib/geo-location.mjs rename to src/lib/geo-location.mts index 5da6f3aeff5..2253eabeb4a 100644 --- a/src/lib/geo-location.mjs +++ b/src/lib/geo-location.mts @@ -1,4 +1,5 @@ -// @ts-check + +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message import fetch from 'node-fetch' const API_URL = 'https://netlifind.netlify.app' @@ -44,6 +45,7 @@ export const mockLocation = { * @param {import('../utils/state-config.mjs').default} params.state * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'geoCountry' implicitly has an 'an... Remove this comment to see the full error message export const getGeoLocation = async ({ geoCountry, mode, offline, state }) => { const cacheObject = state.get(STATE_GEO_PROPERTY) diff --git a/src/lib/http-agent.mjs b/src/lib/http-agent.mts similarity index 67% rename from src/lib/http-agent.mjs rename to src/lib/http-agent.mts index 6f17e8fc51f..65c8a5a355f 100644 --- a/src/lib/http-agent.mjs +++ b/src/lib/http-agent.mts @@ -1,4 +1,4 @@ -// @ts-check + import { readFile } from 'fs/promises' import HttpsProxyAgent from 'https-proxy-agent' @@ -8,15 +8,20 @@ import { NETLIFYDEVERR, NETLIFYDEVWARN, exit, log } from '../utils/command-helpe // https://github.com/TooTallNate/node-https-proxy-agent/issues/89 // Maybe replace with https://github.com/delvedor/hpagent +// @ts-expect-error TS(2507) FIXME: Type 'typeof createHttpsProxyAgent' is not a const... Remove this comment to see the full error message class HttpsProxyAgentWithCA extends HttpsProxyAgent { + // @ts-expect-error TS(7006) FIXME: Parameter 'opts' implicitly has an 'any' type. constructor(opts) { super(opts) + // @ts-expect-error TS(2339) FIXME: Property 'ca' does not exist on type 'HttpsProxyAg... Remove this comment to see the full error message this.ca = opts.ca } + // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. callback(req, opts) { return super.callback(req, { ...opts, + // @ts-expect-error TS(2339) FIXME: Property 'ca' does not exist on type 'HttpsProxyAg... Remove this comment to see the full error message ...(this.ca && { ca: this.ca }), }) } @@ -27,6 +32,7 @@ const DEFAULT_HTTPS_PORT = 443 // 50 seconds const AGENT_PORT_TIMEOUT = 50 +// @ts-expect-error TS(7031) FIXME: Binding element 'certificateFile' implicitly has a... Remove this comment to see the full error message export const tryGetAgent = async ({ certificateFile, httpProxy }) => { if (!httpProxy) { return {} @@ -54,6 +60,7 @@ export const tryGetAgent = async ({ certificateFile, httpProxy }) => { }) } catch (error) { // unknown error + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. return { error: `${httpProxy} is not available.`, message: error.message } } @@ -69,6 +76,7 @@ export const tryGetAgent = async ({ certificateFile, httpProxy }) => { try { certificate = await readFile(certificateFile) } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. response = { warning: `Could not read certificate file '${certificateFile}'.`, message: error.message } } } @@ -86,7 +94,9 @@ export const tryGetAgent = async ({ certificateFile, httpProxy }) => { return response } +// @ts-expect-error TS(7031) FIXME: Binding element 'certificateFile' implicitly has a... Remove this comment to see the full error message export const getAgent = async ({ certificateFile, httpProxy }) => { + // @ts-expect-error TS(2339) FIXME: Property 'agent' does not exist on type '{ error?:... Remove this comment to see the full error message const { agent, error, message, warning } = await tryGetAgent({ httpProxy, certificateFile }) if (error) { log(NETLIFYDEVERR, error, message || '') diff --git a/src/lib/images/proxy.mjs b/src/lib/images/proxy.mts similarity index 64% rename from src/lib/images/proxy.mjs rename to src/lib/images/proxy.mts index 4cc4725dd46..c067582c913 100644 --- a/src/lib/images/proxy.mjs +++ b/src/lib/images/proxy.mts @@ -5,6 +5,7 @@ import { log, NETLIFYDEVERR } from '../../utils/command-helpers.mjs' export const IMAGE_URL_PATTERN = '/.netlify/images' +// @ts-expect-error TS(7006) FIXME: Parameter 'config' implicitly has an 'any' type. export const parseAllDomains = function (config) { const domains = config?.images?.remote_images if (!domains) { @@ -23,6 +24,7 @@ export const parseAllDomains = function (config) { errors.push(`The URL '${patternString}' does not have a valid hostname.`) } } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. errors.push(`Invalid URL '${patternString}': ${error.message}`) } } @@ -30,10 +32,12 @@ export const parseAllDomains = function (config) { return { errors, remoteDomains } } +// @ts-expect-error TS(7031) FIXME: Binding element 'message' implicitly has an 'any' ... Remove this comment to see the full error message const getErrorMessage = function ({ message }) { return message } +// @ts-expect-error TS(7006) FIXME: Parameter 'errors' implicitly has an 'any' type. export const handleImageDomainsErrors = async function (errors) { if (errors.length === 0) { return @@ -43,6 +47,7 @@ export const handleImageDomainsErrors = async function (errors) { log(NETLIFYDEVERR, `Image domains syntax errors:\n${errorMessage}`) } +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message export const parseRemoteImageDomains = async function ({ config }) { if (!config) { return [] @@ -53,10 +58,12 @@ export const parseRemoteImageDomains = async function ({ config }) { return remoteDomains } +// @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. export const isImageRequest = function (req) { return req.url.startsWith(IMAGE_URL_PATTERN) } +// @ts-expect-error TS(7006) FIXME: Parameter 'query' implicitly has an 'any' type. export const transformImageParams = function (query) { const params = {} @@ -64,18 +71,24 @@ export const transformImageParams = function (query) { const height = query.h || query.height || null if (width && height) { + // @ts-expect-error TS(2339) FIXME: Property 's' does not exist on type '{}'. // eslint-disable-next-line id-length params.s = `${width}x${height}` } else { + // @ts-expect-error TS(2339) FIXME: Property 'w' does not exist on type '{}'. // eslint-disable-next-line id-length params.w = width + // @ts-expect-error TS(2339) FIXME: Property 'j' does not exist on type '{}'. // eslint-disable-next-line id-length params.h = height } - + // @ts-expect-error TS(2339) FIXME: Property 'quality' does not exist on type '{}'. params.quality = query.q || query.quality || null + // @ts-expect-error TS(2339) FIXME: Property 'format' does not exist on type '{}'. params.format = query.fm || null + // @ts-expect-error TS(2339) FIXME: Property 'fit' does not exist on type '{}'. params.fit = query.fit || null + // @ts-expect-error TS(2339) FIXME: Property 'position' does not exist on type '{}'. params.position = query.position || null return Object.entries(params) @@ -84,6 +97,7 @@ export const transformImageParams = function (query) { .join(',') } +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message export const initializeProxy = async function ({ config }) { const remoteDomains = await parseRemoteImageDomains({ config }) @@ -98,6 +112,7 @@ export const initializeProxy = async function ({ config }) { app.use(IMAGE_URL_PATTERN, async (req, res) => { const { url, ...query } = req.query const modifiers = await transformImageParams(query) + // @ts-expect-error TS(2345) FIXME: Argument of type 'string | string[] | ParsedQs | P... Remove this comment to see the full error message const path = `/${modifiers}/${encodeURIComponent(url)}` req.url = path handler(req, res) diff --git a/src/lib/log.mjs b/src/lib/log.mts similarity index 100% rename from src/lib/log.mjs rename to src/lib/log.mts diff --git a/src/lib/path.mjs b/src/lib/path.mjs deleted file mode 100644 index 1b18ca45995..00000000000 --- a/src/lib/path.mjs +++ /dev/null @@ -1 +0,0 @@ -export const normalizeBackslash = (path) => path.replace(/\\/g, '/') diff --git a/src/lib/path.mts b/src/lib/path.mts new file mode 100644 index 00000000000..bacfa49e84b --- /dev/null +++ b/src/lib/path.mts @@ -0,0 +1,2 @@ +// @ts-expect-error TS(7006) FIXME: Parameter 'path' implicitly has an 'any' type. +export const normalizeBackslash = (path) => path.replace(/\\/g, '/') diff --git a/src/lib/render-error-template.mjs b/src/lib/render-error-template.mts similarity index 60% rename from src/lib/render-error-template.mjs rename to src/lib/render-error-template.mts index 8d90c96d505..0edb3d0401a 100644 --- a/src/lib/render-error-template.mjs +++ b/src/lib/render-error-template.mts @@ -2,14 +2,17 @@ import { readFile } from 'fs/promises' import { dirname, join } from 'path' import { fileURLToPath } from 'url' +// @ts-expect-error TS(7034) FIXME: Variable 'errorTemplateFile' implicitly has type '... Remove this comment to see the full error message let errorTemplateFile const dir = dirname(fileURLToPath(import.meta.url)) +// @ts-expect-error TS(7006) FIXME: Parameter 'errString' implicitly has an 'any' type... Remove this comment to see the full error message const renderErrorTemplate = async (errString, templatePath, functionType) => { const errorDetailsRegex = //g const functionTypeRegex = //g try { + // @ts-expect-error TS(7005) FIXME: Variable 'errorTemplateFile' implicitly has an 'an... Remove this comment to see the full error message errorTemplateFile = errorTemplateFile || (await readFile(join(dir, templatePath), 'utf-8')) return errorTemplateFile.replace(errorDetailsRegex, errString).replace(functionTypeRegex, functionType) diff --git a/src/lib/settings.mjs b/src/lib/settings.mts similarity index 78% rename from src/lib/settings.mjs rename to src/lib/settings.mts index 56b4490749e..b27b868adaf 100644 --- a/src/lib/settings.mjs +++ b/src/lib/settings.mts @@ -12,6 +12,7 @@ const NETLIFY_HOME = '.netlify' * @param {string[]} paths * @returns {string} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'paths' implicitly has an 'any' type. export const getLegacyPathInHome = (paths) => { const pathInHome = path.join(os.homedir(), NETLIFY_HOME, ...paths) return pathInHome @@ -22,6 +23,7 @@ export const getLegacyPathInHome = (paths) => { * @param {string[]} paths * @returns {string} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'paths' implicitly has an 'any' type. export const getPathInHome = (paths) => { const pathInHome = path.join(OSBasedPaths.config, ...paths) return pathInHome @@ -32,6 +34,7 @@ export const getPathInHome = (paths) => { * @param {string[]} paths * @returns {string} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'paths' implicitly has an 'any' type. export const getPathInProject = (paths) => { const pathInProject = path.join(NETLIFY_HOME, ...paths) return pathInProject diff --git a/src/lib/spinner.mjs b/src/lib/spinner.mts similarity index 68% rename from src/lib/spinner.mjs rename to src/lib/spinner.mts index 817bc396695..a8573d47a9b 100644 --- a/src/lib/spinner.mjs +++ b/src/lib/spinner.mts @@ -1,4 +1,4 @@ -// @ts-check + import logSymbols from 'log-symbols' import ora from 'ora' @@ -8,6 +8,7 @@ import ora from 'ora' * @param {string} config.text * @returns {ora.Ora} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'text' implicitly has an 'any' typ... Remove this comment to see the full error message export const startSpinner = ({ text }) => ora({ text, @@ -21,6 +22,7 @@ export const startSpinner = ({ text }) => * @param {string} [config.text] * @returns {void} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'error' implicitly has an 'any' ty... Remove this comment to see the full error message export const stopSpinner = ({ error, spinner, text }) => { if (!spinner) { return @@ -39,6 +41,7 @@ export const stopSpinner = ({ error, spinner, text }) => { * @param {ora.Ora} config.spinner * @returns {void} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'spinner' implicitly has an 'any' ... Remove this comment to see the full error message export const clearSpinner = ({ spinner }) => { if (spinner) { spinner.stop() diff --git a/src/lib/string.mjs b/src/lib/string.mjs deleted file mode 100644 index dc13d74157c..00000000000 --- a/src/lib/string.mjs +++ /dev/null @@ -1,3 +0,0 @@ -export const capitalize = function (t) { - return t.replace(/(^\w|\s\w)/g, (string) => string.toUpperCase()) -} diff --git a/src/lib/string.mts b/src/lib/string.mts new file mode 100644 index 00000000000..9504733a69c --- /dev/null +++ b/src/lib/string.mts @@ -0,0 +1,5 @@ +// @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type. +export const capitalize = function (t) { + // @ts-expect-error TS(7006) FIXME: Parameter 'string' implicitly has an 'any' type. + return t.replace(/(^\w|\s\w)/g, (string) => string.toUpperCase()) +} diff --git a/src/recipes/vscode/index.mjs b/src/recipes/vscode/index.mts similarity index 79% rename from src/recipes/vscode/index.mjs rename to src/recipes/vscode/index.mts index 723e9995fc8..f8753a16558 100644 --- a/src/recipes/vscode/index.mjs +++ b/src/recipes/vscode/index.mts @@ -1,4 +1,4 @@ -// @ts-check + import { join } from 'path' import { DenoBridge } from '@netlify/edge-bundler' @@ -11,6 +11,7 @@ import { applySettings, getSettings, writeSettings } from './settings.mjs' export const description = 'Create VS Code settings for an optimal experience with Netlify projects' +// @ts-expect-error TS(7031) FIXME: Binding element 'fileExists' implicitly has an 'an... Remove this comment to see the full error message const getPrompt = ({ fileExists, path }) => { const formattedPath = chalk.underline(path) const message = fileExists @@ -25,17 +26,20 @@ const getPrompt = ({ fileExists, path }) => { }) } +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message const getEdgeFunctionsPath = ({ config, repositoryRoot }) => config.build.edge_functions || join(repositoryRoot, 'netlify', 'edge-functions') /** * @param {string} repositoryRoot */ +// @ts-expect-error TS(7006) FIXME: Parameter 'repositoryRoot' implicitly has an 'any'... Remove this comment to see the full error message const getSettingsPath = (repositoryRoot) => join(repositoryRoot, '.vscode', 'settings.json') /** * @param {string} repositoryRoot */ +// @ts-expect-error TS(7006) FIXME: Parameter 'repositoryRoot' implicitly has an 'any'... Remove this comment to see the full error message const hasDenoVSCodeExt = async (repositoryRoot) => { const { stdout: extensions } = await execa('code', ['--list-extensions'], { stderr: 'inherit', cwd: repositoryRoot }) return extensions.split('\n').includes('denoland.vscode-deno') @@ -44,6 +48,7 @@ const hasDenoVSCodeExt = async (repositoryRoot) => { /** * @param {string} repositoryRoot */ +// @ts-expect-error TS(7006) FIXME: Parameter 'repositoryRoot' implicitly has an 'any'... Remove this comment to see the full error message const getDenoVSCodeExt = async (repositoryRoot) => { await execa('code', ['--install-extension', 'denoland.vscode-deno'], { stdio: 'inherit', cwd: repositoryRoot }) } @@ -65,6 +70,7 @@ const getDenoExtPrompt = () => { * @param {string} params.repositoryRoot * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message export const run = async ({ config, repositoryRoot }) => { const deno = new DenoBridge({ onBeforeDownload: () => diff --git a/src/recipes/vscode/settings.mjs b/src/recipes/vscode/settings.mts similarity index 74% rename from src/recipes/vscode/settings.mjs rename to src/recipes/vscode/settings.mts index 90bd3a74fcd..5b01f88226f 100644 --- a/src/recipes/vscode/settings.mjs +++ b/src/recipes/vscode/settings.mts @@ -3,8 +3,10 @@ import { dirname, relative } from 'path' // eslint-disable-next-line import/no-namespace import * as JSONC from 'comment-json' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'unix... Remove this comment to see the full error message import unixify from 'unixify' +// @ts-expect-error TS(7006) FIXME: Parameter 'existingSettings' implicitly has an 'an... Remove this comment to see the full error message export const applySettings = (existingSettings, { denoBinary, edgeFunctionsPath, repositoryRoot }) => { const relativeEdgeFunctionsPath = unixify(relative(repositoryRoot, edgeFunctionsPath)) const settings = JSONC.assign(existingSettings, { @@ -31,6 +33,7 @@ export const applySettings = (existingSettings, { denoBinary, edgeFunctionsPath, return settings } +// @ts-expect-error TS(7006) FIXME: Parameter 'settingsPath' implicitly has an 'any' t... Remove this comment to see the full error message export const getSettings = async (settingsPath) => { try { const stats = await stat(settingsPath) @@ -46,7 +49,9 @@ export const getSettings = async (settingsPath) => { settings: JSONC.parse(file), } } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error.code !== 'ENOENT') { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. throw new Error(`Could not open VS Code settings file: ${error.message}`) } @@ -57,6 +62,7 @@ export const getSettings = async (settingsPath) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'settings' implicitly has an 'any'... Remove this comment to see the full error message export const writeSettings = async ({ settings, settingsPath }) => { const serializedSettings = JSONC.stringify(settings, null, 2) diff --git a/src/utils/addons/compare.mjs b/src/utils/addons/compare.mts similarity index 80% rename from src/utils/addons/compare.mjs rename to src/utils/addons/compare.mts index 6b2b7ab6650..ad768c7ed9e 100644 --- a/src/utils/addons/compare.mjs +++ b/src/utils/addons/compare.mts @@ -1,5 +1,6 @@ import isEqual from 'lodash/isEqual.js' +// @ts-expect-error TS(7006) FIXME: Parameter 'oldValues' implicitly has an 'any' type... Remove this comment to see the full error message export default function compare(oldValues, newValues) { const initialData = { // default everything is equal @@ -14,6 +15,7 @@ export default function compare(oldValues, newValues) { const newKeys = Object.keys(newValues) const set = new Set([...newKeys, ...oldKeys]) + // @ts-expect-error TS(2769) FIXME: No overload matches this call. return [...set].reduce((acc, current) => { // if values not deep equal. There are changes if (!isEqual(newValues[current], oldValues[current])) { diff --git a/src/utils/addons/diffs/index.mjs b/src/utils/addons/diffs/index.mts similarity index 64% rename from src/utils/addons/diffs/index.mjs rename to src/utils/addons/diffs/index.mts index 8385bfaaf23..d9032c828f8 100644 --- a/src/utils/addons/diffs/index.mjs +++ b/src/utils/addons/diffs/index.mts @@ -1,13 +1,16 @@ -// @ts-check + +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'conc... Remove this comment to see the full error message import concordance from 'concordance' import { concordanceDiffOptions, concordanceOptions } from './options.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'actualDescriptor' implicitly has an 'an... Remove this comment to see the full error message const formatDescriptorDiff = function (actualDescriptor, expectedDescriptor, options) { const diffOptions = { ...options, ...concordanceDiffOptions } return concordance.diffDescriptors(actualDescriptor, expectedDescriptor, diffOptions) } +// @ts-expect-error TS(7006) FIXME: Parameter 'actual' implicitly has an 'any' type. export default function diffValues(actual, expected) { const result = concordance.compare(actual, expected, concordanceOptions) if (result.pass) { @@ -16,5 +19,6 @@ export default function diffValues(actual, expected) { const actualDescriptor = result.actual || concordance.describe(actual, concordanceOptions) const expectedDescriptor = result.expected || concordance.describe(expected, concordanceOptions) + // @ts-expect-error TS(2554) FIXME: Expected 3 arguments, but got 2. return formatDescriptorDiff(actualDescriptor, expectedDescriptor) } diff --git a/src/utils/addons/diffs/options.mjs b/src/utils/addons/diffs/options.mts similarity index 90% rename from src/utils/addons/diffs/options.mjs rename to src/utils/addons/diffs/options.mts index 6531fa1254c..0c61fdc1be3 100644 --- a/src/utils/addons/diffs/options.mjs +++ b/src/utils/addons/diffs/options.mts @@ -1,4 +1,4 @@ -// @ts-check + import ansiStyles from 'ansi-styles' // eslint-disable-next-line no-restricted-imports import { Chalk } from 'chalk' @@ -101,8 +101,11 @@ const colorTheme = { undefined: ansiStyles.yellow, } +// @ts-expect-error TS(7034) FIXME: Variable 'plugins' implicitly has type 'any[]' in ... Remove this comment to see the full error message const plugins = [] const theme = colorTheme +// @ts-expect-error TS(7005) FIXME: Variable 'plugins' implicitly has an 'any[]' type. export const concordanceOptions = { maxDepth: 3, plugins, theme } +// @ts-expect-error TS(7005) FIXME: Variable 'plugins' implicitly has an 'any[]' type. export const concordanceDiffOptions = { maxDepth: 1, plugins, theme } diff --git a/src/utils/addons/prepare.mjs b/src/utils/addons/prepare.mts similarity index 68% rename from src/utils/addons/prepare.mjs rename to src/utils/addons/prepare.mts index e5cbc19e9b1..0d0c8f1f6e3 100644 --- a/src/utils/addons/prepare.mjs +++ b/src/utils/addons/prepare.mts @@ -1,4 +1,4 @@ -// @ts-check + import { chalk, error, exit, log, warn } from '../command-helpers.mjs' export const ADDON_VALIDATION = { @@ -6,6 +6,7 @@ export const ADDON_VALIDATION = { NOT_EXISTS: 'NOT_EXISTS', } +// @ts-expect-error TS(7031) FIXME: Binding element 'addon' implicitly has an 'any' ty... Remove this comment to see the full error message const validateExists = ({ addon, addonName, siteData }) => { if (!addon || !addon.id) { log(`Add-on ${addonName} doesn't exist for ${siteData.name}`) @@ -14,6 +15,7 @@ const validateExists = ({ addon, addonName, siteData }) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'addon' implicitly has an 'any' ty... Remove this comment to see the full error message const validateNotExists = ({ addon, addonName, siteData }) => { if (addon && addon.id) { log(`The "${addonName} add-on" already exists for ${siteData.name}`) @@ -27,8 +29,10 @@ const validateNotExists = ({ addon, addonName, siteData }) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message export const getCurrentAddon = ({ addonName, addons }) => addons.find((addon) => addon.service_slug === addonName) +// @ts-expect-error TS(7031) FIXME: Binding element 'addon' implicitly has an 'any' ty... Remove this comment to see the full error message const validateCurrentAddon = ({ addon, addonName, siteData, validation }) => { switch (validation) { case ADDON_VALIDATION.EXISTS: { @@ -46,35 +50,42 @@ const validateCurrentAddon = ({ addon, addonName, siteData, validation }) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message export const getAddonManifest = async ({ addonName, api }) => { let manifest try { manifest = await api.showServiceManifest({ addonName }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (typeof error_.message === 'string' && error_.message.includes('Not Found')) { error(`No add-on "${addonName}" found. Please double check your add-on name and try again`) } else { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(error_.message) } } return manifest } +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message export const getSiteData = async ({ api, siteId }) => { let siteData try { siteData = await api.getSite({ siteId }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(`Failed getting list of site data: ${error_.message}`) } return siteData } +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message export const getAddons = async ({ api, siteId }) => { let addons try { addons = await api.listServiceInstancesForSite({ siteId }) } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(`Failed getting list of addons: ${error_.message}`) } return addons @@ -87,6 +98,7 @@ export const getAddons = async ({ api, siteId }) => { * @param {string} [config.addonName] * @param {keyof ADDON_VALIDATION} [config.validation] */ +// @ts-expect-error TS(7031) FIXME: Binding element 'addonName' implicitly has an 'any... Remove this comment to see the full error message export const prepareAddonCommand = async ({ addonName, command, validation }) => { const { netlify } = command const { api, site } = netlify @@ -99,6 +111,7 @@ export const prepareAddonCommand = async ({ addonName, command, validation }) => const [manifest, siteData, addons] = await Promise.all([ // TODO: check as `getAddonManifest` did not accept a parameter error + // @ts-expect-error TS(2345) FIXME: Argument of type '{ api: any; addonName: any; erro... Remove this comment to see the full error message addonName ? getAddonManifest({ api, addonName, error }) : Promise.resolve(), getSiteData({ api, siteId }), getAddons({ api, siteId }), diff --git a/src/utils/addons/prompts.mjs b/src/utils/addons/prompts.mts similarity index 81% rename from src/utils/addons/prompts.mjs rename to src/utils/addons/prompts.mts index dad247ff2db..58110c53094 100644 --- a/src/utils/addons/prompts.mjs +++ b/src/utils/addons/prompts.mts @@ -1,7 +1,8 @@ -// @ts-check + import { chalk } from '../command-helpers.mjs' /* programmatically generate CLI prompts */ +// @ts-expect-error TS(7006) FIXME: Parameter 'settings' implicitly has an 'any' type. export default function generatePrompts(settings) { const { config, configValues } = settings const configItems = Object.keys(config) @@ -30,6 +31,7 @@ export default function generatePrompts(settings) { } // if current stage value set show as default if (configValues[key]) { + // @ts-expect-error TS(2339) FIXME: Property 'default' does not exist on type '{ type:... Remove this comment to see the full error message prompt.default = configValues[key] } } else if (typeof setting === 'boolean') { @@ -56,9 +58,11 @@ export default function generatePrompts(settings) { } // if value previously set show it if (configValues[key]) { + // @ts-expect-error TS(2339) FIXME: Property 'default' does not exist on type '{ type:... Remove this comment to see the full error message prompt.default = configValues[key] // else show default value if provided } else if (setting.default) { + // @ts-expect-error TS(2339) FIXME: Property 'default' does not exist on type '{ type:... Remove this comment to see the full error message prompt.default = setting.default } return prompt @@ -82,7 +86,9 @@ const noValidate = function () { // return `Please enter a value this field is required` // } +// @ts-expect-error TS(7006) FIXME: Parameter 'pattern' implicitly has an 'any' type. const validate = function (pattern) { + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. return function validateValue(value) { const regex = new RegExp(pattern) if (regex.test(value)) { diff --git a/src/utils/addons/render.mjs b/src/utils/addons/render.mts similarity index 72% rename from src/utils/addons/render.mjs rename to src/utils/addons/render.mts index b2b1acf663f..6c9f16970e6 100644 --- a/src/utils/addons/render.mjs +++ b/src/utils/addons/render.mts @@ -1,10 +1,13 @@ -// @ts-check + +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'asci... Remove this comment to see the full error message import AsciiTable from 'ascii-table' import { chalk } from '../command-helpers.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'values' implicitly has an 'any' type. export const renderMissingValues = function (values, manifest) { const display = values + // @ts-expect-error TS(7006) FIXME: Parameter 'item' implicitly has an 'any' type. .map((item) => { const itemDisplay = chalk.redBright.bold(`${item}`) const niceNameDisplay = manifest.config[item].displayName @@ -14,6 +17,7 @@ export const renderMissingValues = function (values, manifest) { console.log(display) } +// @ts-expect-error TS(7006) FIXME: Parameter 'addonName' implicitly has an 'any' type... Remove this comment to see the full error message export const renderConfigValues = function (addonName, values, currentValue) { const table = new AsciiTable(`${addonName} add-on settings`) diff --git a/src/utils/addons/validation.mjs b/src/utils/addons/validation.mjs deleted file mode 100644 index b89746f0c35..00000000000 --- a/src/utils/addons/validation.mjs +++ /dev/null @@ -1,18 +0,0 @@ -export const requiredConfigValues = function (config) { - return Object.keys(config).filter((key) => config[key].required) -} - -export const missingConfigValues = function (requiredConfig, providedConfig) { - return requiredConfig.filter((key) => !providedConfig[key]) -} - -export const updateConfigValues = function (allowedConfig, currentConfig, newConfig) { - return Object.keys(allowedConfig).reduce((acc, key) => { - if (newConfig[key]) { - acc[key] = newConfig[key] - return acc - } - acc[key] = currentConfig[key] - return acc - }, {}) -} diff --git a/src/utils/addons/validation.mts b/src/utils/addons/validation.mts new file mode 100644 index 00000000000..e023235fa30 --- /dev/null +++ b/src/utils/addons/validation.mts @@ -0,0 +1,24 @@ +// @ts-expect-error TS(7006) FIXME: Parameter 'config' implicitly has an 'any' type. +export const requiredConfigValues = function (config) { + return Object.keys(config).filter((key) => config[key].required) +} + +// @ts-expect-error TS(7006) FIXME: Parameter 'requiredConfig' implicitly has an 'any'... Remove this comment to see the full error message +export const missingConfigValues = function (requiredConfig, providedConfig) { + // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. + return requiredConfig.filter((key) => !providedConfig[key]) +} + +// @ts-expect-error TS(7006) FIXME: Parameter 'allowedConfig' implicitly has an 'any' ... Remove this comment to see the full error message +export const updateConfigValues = function (allowedConfig, currentConfig, newConfig) { + return Object.keys(allowedConfig).reduce((acc, key) => { + if (newConfig[key]) { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message + acc[key] = newConfig[key] + return acc + } + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message + acc[key] = currentConfig[key] + return acc + }, {}) +} diff --git a/src/utils/banner.mjs b/src/utils/banner.mts similarity index 70% rename from src/utils/banner.mjs rename to src/utils/banner.mts index f899d5e097a..69130685843 100644 --- a/src/utils/banner.mjs +++ b/src/utils/banner.mts @@ -1,8 +1,9 @@ -// @ts-check + import boxen from 'boxen' import { chalk, log, NETLIFYDEVLOG } from './command-helpers.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'url' implicitly has an 'any' type... Remove this comment to see the full error message export const printBanner = ({ url }) => { const banner = chalk.bold(`${NETLIFYDEVLOG} Server now ready on ${url}`) diff --git a/src/utils/build-info.mjs b/src/utils/build-info.mts similarity index 76% rename from src/utils/build-info.mjs rename to src/utils/build-info.mts index 186900ee44b..afb4a2bf059 100644 --- a/src/utils/build-info.mjs +++ b/src/utils/build-info.mts @@ -1,4 +1,4 @@ -// @ts-check + import fuzzy from 'fuzzy' import inquirer from 'inquirer' @@ -10,7 +10,9 @@ import { chalk, log } from './command-helpers.mjs' * @param {ReturnType} scriptInquirerOptions * @param {string} input */ +// @ts-expect-error TS(7006) FIXME: Parameter 'scriptInquirerOptions' implicitly has a... Remove this comment to see the full error message const filterSettings = function (scriptInquirerOptions, input) { + // @ts-expect-error TS(7006) FIXME: Parameter 'scriptInquirerOption' implicitly has an... Remove this comment to see the full error message const filterOptions = scriptInquirerOptions.map((scriptInquirerOption) => scriptInquirerOption.name) // TODO: remove once https://github.com/sindresorhus/eslint-plugin-unicorn/issues/1394 is fixed // eslint-disable-next-line unicorn/no-array-method-this-argument @@ -18,6 +20,7 @@ const filterSettings = function (scriptInquirerOptions, input) { const filteredSettingNames = new Set( filteredSettings.map((filteredSetting) => (input ? filteredSetting.string : filteredSetting)), ) + // @ts-expect-error TS(7006) FIXME: Parameter 't' implicitly has an 'any' type. return scriptInquirerOptions.filter((t) => filteredSettingNames.has(t.name)) } @@ -27,7 +30,9 @@ const filterSettings = function (scriptInquirerOptions, input) { * @param {Settings[]} settings * @param {'dev' | 'build'} type The type of command (dev or build) */ +// @ts-expect-error TS(7006) FIXME: Parameter 'settings' implicitly has an 'any' type. const formatSettingsArrForInquirer = function (settings, type = 'dev') { + // @ts-expect-error TS(7006) FIXME: Parameter 'setting' implicitly has an 'any' type. return settings.map((setting) => { const cmd = type === 'dev' ? setting.devCommand : setting.buildCommand return { @@ -45,6 +50,7 @@ const formatSettingsArrForInquirer = function (settings, type = 'dev') { * @param {'dev' | 'build'} type The type of command (dev or build) * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. export const detectFrameworkSettings = async (command, type = 'dev') => { const { relConfigFilePath } = command.netlify const settings = await detectBuildSettings(command) @@ -59,7 +65,9 @@ export const detectFrameworkSettings = async (command, type = 'dev') => { const { chosenSettings } = await inquirer.prompt({ name: 'chosenSettings', message: `Multiple possible ${type} commands found`, + // @ts-expect-error TS(2769) FIXME: No overload matches this call. type: 'autocomplete', + // @ts-expect-error TS(7006) FIXME: Parameter '_' implicitly has an 'any' type. source(/** @type {string} */ _, input = '') { if (!input) return scriptInquirerOptions // only show filtered results @@ -85,10 +93,12 @@ command = "${chosenSettings.devCommand}" * Detects and filters the build setting for a project and a command * @param {import('../commands/base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. export const detectBuildSettings = async (command) => { const { project, workspacePackage } = command const buildSettings = await project.getBuildSettings(project.workspace ? workspacePackage : '') return buildSettings + // @ts-expect-error TS(7006) FIXME: Parameter 'setting' implicitly has an 'any' type. .filter((setting) => { if (project.workspace && project.relativeBaseDirectory && setting.packagePath) { return project.relativeBaseDirectory.startsWith(setting.packagePath) @@ -96,5 +106,6 @@ export const detectBuildSettings = async (command) => { return true }) + // @ts-expect-error TS(7006) FIXME: Parameter 'setting' implicitly has an 'any' type. .filter((setting) => setting.devCommand) } diff --git a/src/utils/command-helpers.mjs b/src/utils/command-helpers.mts similarity index 78% rename from src/utils/command-helpers.mjs rename to src/utils/command-helpers.mts index 5bd68dd71e9..0c235b9eb53 100644 --- a/src/utils/command-helpers.mjs +++ b/src/utils/command-helpers.mts @@ -1,4 +1,4 @@ -// @ts-check + import { once } from 'events' import os from 'os' import process from 'process' @@ -26,6 +26,7 @@ const argv = process.argv.slice(2) * @param {boolean} noColors - disable chalk colors * @return {import('chalk').ChalkInstance} - default or custom chalk instance */ +// @ts-expect-error TS(7006) FIXME: Parameter 'noColors' implicitly has an 'any' type. const safeChalk = function (noColors) { if (noColors) { const colorlessChalk = new Chalk({ level: 0 }) @@ -43,6 +44,7 @@ export const chalk = safeChalk(argv.includes('--json')) * @param {string} [filler] * @returns {string} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'str' implicitly has an 'any' type. export const padLeft = (str, count, filler = ' ') => str.padStart(str.length + count, filler) const platform = WSL ? 'wsl' : os.platform() @@ -72,6 +74,7 @@ export const BANG = process.platform === 'win32' ? '»' : '›' * @example * options.sort(sortOptions) */ +// @ts-expect-error TS(7006) FIXME: Parameter 'optionA' implicitly has an 'any' type. export const sortOptions = (optionA, optionB) => { // base flags should be always at the bottom if (BASE_FLAGS.has(optionA.long) || BASE_FLAGS.has(optionB.long)) { @@ -90,6 +93,7 @@ const TOKEN_TIMEOUT = 3e5 * @param {object} config.ticket * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message export const pollForToken = async ({ api, ticket }) => { const spinner = startSpinner({ text: 'Waiting for authorization...' }) try { @@ -99,6 +103,7 @@ export const pollForToken = async ({ api, ticket }) => { } return accessToken } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.name === 'TimeoutError') { error( `Timed out waiting for authorization. If you do not have a ${chalk.bold.greenBright( @@ -108,6 +113,7 @@ export const pollForToken = async ({ api, ticket }) => { )}, then run ${chalk.cyanBright('netlify login')} again.`, ) } else { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) } } finally { @@ -120,6 +126,7 @@ export const pollForToken = async ({ api, ticket }) => { * @param {string} [tokenFromOptions] optional token from the provided --auth options * @returns {Promise<[null|string, 'flag' | 'env' |'config' |'not found']>} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'tokenFromOptions' implicitly has an 'an... Remove this comment to see the full error message export const getToken = async (tokenFromOptions) => { // 1. First honor command flag --auth if (tokenFromOptions) { @@ -154,6 +161,7 @@ export const logJson = (message = '') => { } } +// @ts-expect-error TS(7019) FIXME: Rest parameter 'args' implicitly has an 'any[]' ty... Remove this comment to see the full error message export const log = (message = '', ...args) => { // If --silent or --json flag passed disable logger if (argv.includes('--json') || argv.includes('--silent') || isDefaultJson()) { @@ -163,6 +171,7 @@ export const log = (message = '', ...args) => { process.stdout.write(`${format(message, ...args)}\n`) } +// @ts-expect-error TS(7019) FIXME: Rest parameter 'args' implicitly has an 'any[]' ty... Remove this comment to see the full error message export const logPadded = (message = '', ...args) => { log('') log(message, ...args) @@ -186,6 +195,7 @@ export const warn = (message = '') => { */ export const error = (message = '', options = {}) => { const err = + // @ts-expect-error TS(2358) FIXME: The left-hand side of an 'instanceof' expression m... Remove this comment to see the full error message message instanceof Error ? message : // eslint-disable-next-line unicorn/no-nested-ternary @@ -193,6 +203,7 @@ export const error = (message = '', options = {}) => { ? new Error(message) : /** @type {Error} */ ({ message, stack: undefined, name: 'Error' }) + // @ts-expect-error TS(2339) FIXME: Property 'exit' does not exist on type '{}'. if (options.exit === false) { const bang = chalk.red(BANG) if (process.env.DEBUG) { @@ -217,6 +228,7 @@ export const exit = (code = 0) => { * This removes 'publish' and 'publishOrigin' in this case. * @param {*} config */ +// @ts-expect-error TS(7006) FIXME: Parameter 'config' implicitly has an 'any' type. export const normalizeConfig = (config) => { // Unused var here is in order to omit 'publish' from build config // eslint-disable-next-line no-unused-vars @@ -239,7 +251,9 @@ const DEBOUNCE_WAIT = 100 * @param {(paths: string[]) => any} [opts.onUnlink] */ export const watchDebounced = async ( + // @ts-expect-error TS(7006) FIXME: Parameter 'target' implicitly has an 'any' type. target, + // @ts-expect-error TS(7031) FIXME: Binding element 'depth' implicitly has an 'any' ty... Remove this comment to see the full error message { depth, ignored = [], onAdd = () => {}, onChange = () => {}, onUnlink = () => {} }, ) => { const baseIgnores = [/\/(node_modules|.git)\//] @@ -247,35 +261,44 @@ export const watchDebounced = async ( await once(watcher, 'ready') + // @ts-expect-error TS(7034) FIXME: Variable 'onChangeQueue' implicitly has type 'any[... Remove this comment to see the full error message let onChangeQueue = [] + // @ts-expect-error TS(7034) FIXME: Variable 'onAddQueue' implicitly has type 'any[]' ... Remove this comment to see the full error message let onAddQueue = [] + // @ts-expect-error TS(7034) FIXME: Variable 'onUnlinkQueue' implicitly has type 'any[... Remove this comment to see the full error message let onUnlinkQueue = [] const debouncedOnChange = debounce(() => { + // @ts-expect-error TS(2554) FIXME: Expected 0 arguments, but got 1. onChange(onChangeQueue) onChangeQueue = [] }, DEBOUNCE_WAIT) const debouncedOnAdd = debounce(() => { + // @ts-expect-error TS(2554) FIXME: Expected 0 arguments, but got 1. onAdd(onAddQueue) onAddQueue = [] }, DEBOUNCE_WAIT) const debouncedOnUnlink = debounce(() => { + // @ts-expect-error TS(2554) FIXME: Expected 0 arguments, but got 1. onUnlink(onUnlinkQueue) onUnlinkQueue = [] }, DEBOUNCE_WAIT) watcher .on('change', (path) => { + // @ts-expect-error decache(path) onChangeQueue.push(path) debouncedOnChange() }) .on('unlink', (path) => { + // @ts-expect-error decache(path) onUnlinkQueue.push(path) debouncedOnUnlink() }) .on('add', (path) => { + // @ts-expect-error decache(path) onAddQueue.push(path) debouncedOnAdd() @@ -284,4 +307,5 @@ export const watchDebounced = async ( return watcher } +// @ts-expect-error TS(7006) FIXME: Parameter 'text' implicitly has an 'any' type. export const getTerminalLink = (text, url) => terminalLink(text, url, { fallback: () => `${text} (${url})` }) diff --git a/src/utils/create-deferred.mjs b/src/utils/create-deferred.mts similarity index 95% rename from src/utils/create-deferred.mjs rename to src/utils/create-deferred.mts index 376730e4da9..2cb1e22f6b2 100644 --- a/src/utils/create-deferred.mjs +++ b/src/utils/create-deferred.mts @@ -1,4 +1,4 @@ -// @ts-check + const createDeferred = () => { let resolveDeferred let rejectDeferred diff --git a/src/utils/create-stream-promise.mjs b/src/utils/create-stream-promise.mjs deleted file mode 100644 index afe1d9bca3b..00000000000 --- a/src/utils/create-stream-promise.mjs +++ /dev/null @@ -1,49 +0,0 @@ -import { Buffer } from 'buffer' - -const SEC_TO_MILLISEC = 1e3 - -// 6 MiB -const DEFAULT_BYTES_LIMIT = 6e6 - -const createStreamPromise = function (stream, timeoutSeconds, bytesLimit = DEFAULT_BYTES_LIMIT) { - return new Promise(function streamPromiseFunc(resolve, reject) { - let data = [] - let dataLength = 0 - - let timeoutId = null - if (timeoutSeconds != null && Number.isFinite(timeoutSeconds)) { - timeoutId = setTimeout(() => { - data = null - reject(new Error('Request timed out waiting for body')) - }, timeoutSeconds * SEC_TO_MILLISEC) - } - - stream.on('data', function onData(chunk) { - if (!Array.isArray(data)) { - // Stream harvesting closed - return - } - dataLength += chunk.length - if (dataLength > bytesLimit) { - data = null - reject(new Error('Stream body too big')) - } else { - data.push(chunk) - } - }) - - stream.on('error', function onError(error) { - data = null - reject(error) - clearTimeout(timeoutId) - }) - stream.on('end', function onEnd() { - clearTimeout(timeoutId) - if (data) { - resolve(Buffer.concat(data)) - } - }) - }) -} - -export default createStreamPromise diff --git a/src/utils/create-stream-promise.mts b/src/utils/create-stream-promise.mts new file mode 100644 index 00000000000..634c022d764 --- /dev/null +++ b/src/utils/create-stream-promise.mts @@ -0,0 +1,62 @@ +import { Buffer } from 'buffer' + +const SEC_TO_MILLISEC = 1e3 + +// 6 MiB +const DEFAULT_BYTES_LIMIT = 6e6 + +// @ts-expect-error TS(7006) FIXME: Parameter 'stream' implicitly has an 'any' type. +const createStreamPromise = function (stream, timeoutSeconds, bytesLimit = DEFAULT_BYTES_LIMIT) { + return new Promise(function streamPromiseFunc(resolve, reject) { + // @ts-expect-error TS(7034) FIXME: Variable 'data' implicitly has type 'any[]' in som... Remove this comment to see the full error message + let data = [] + let dataLength = 0 + + // @ts-expect-error TS(7034) FIXME: Variable 'timeoutId' implicitly has type 'any' in ... Remove this comment to see the full error message + let timeoutId = null + if (timeoutSeconds != null && Number.isFinite(timeoutSeconds)) { + timeoutId = setTimeout(() => { + // @ts-expect-error TS(2322) FIXME: Type 'null' is not assignable to type 'any[]'. + data = null + reject(new Error('Request timed out waiting for body')) + }, timeoutSeconds * SEC_TO_MILLISEC) + } + + // @ts-expect-error TS(7006) FIXME: Parameter 'chunk' implicitly has an 'any' type. + stream.on('data', function onData(chunk) { + // @ts-expect-error TS(7005) FIXME: Variable 'data' implicitly has an 'any[]' type. + if (!Array.isArray(data)) { + // Stream harvesting closed + return + } + dataLength += chunk.length + if (dataLength > bytesLimit) { + // @ts-expect-error TS(2322) FIXME: Type 'null' is not assignable to type 'any[]'. + data = null + reject(new Error('Stream body too big')) + } else { + data.push(chunk) + } + }) + + // @ts-expect-error TS(7006) FIXME: Parameter 'error' implicitly has an 'any' type. + stream.on('error', function onError(error) { + // @ts-expect-error TS(2322) FIXME: Type 'null' is not assignable to type 'any[]'. + data = null + reject(error) + // @ts-expect-error TS(7005) FIXME: Variable 'timeoutId' implicitly has an 'any' type. + clearTimeout(timeoutId) + }) + stream.on('end', function onEnd() { + // @ts-expect-error TS(7005) FIXME: Variable 'timeoutId' implicitly has an 'any' type. + clearTimeout(timeoutId) + // @ts-expect-error TS(7005) FIXME: Variable 'data' implicitly has an 'any[]' type. + if (data) { + // @ts-expect-error TS(7005) FIXME: Variable 'data' implicitly has an 'any[]' type. + resolve(Buffer.concat(data)) + } + }) + }) +} + +export default createStreamPromise diff --git a/src/utils/deploy/constants.mjs b/src/utils/deploy/constants.mts similarity index 100% rename from src/utils/deploy/constants.mjs rename to src/utils/deploy/constants.mts diff --git a/src/utils/deploy/deploy-site.mjs b/src/utils/deploy/deploy-site.mts similarity index 63% rename from src/utils/deploy/deploy-site.mjs rename to src/utils/deploy/deploy-site.mts index 44740d728b4..cef6ca6f491 100644 --- a/src/utils/deploy/deploy-site.mjs +++ b/src/utils/deploy/deploy-site.mts @@ -20,35 +20,51 @@ import uploadFiles from './upload-files.mjs' import { getUploadList, waitForDeploy, waitForDiff } from './util.mjs' export const deploySite = async ( + // @ts-expect-error TS(7006) FIXME: Parameter 'api' implicitly has an 'any' type. api, + // @ts-expect-error TS(7006) FIXME: Parameter 'siteId' implicitly has an 'any' type. siteId, + // @ts-expect-error TS(7006) FIXME: Parameter 'dir' implicitly has an 'any' type. dir, { + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message assetType, + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message branch, concurrentHash = DEFAULT_CONCURRENT_HASH, concurrentUpload = DEFAULT_CONCURRENT_UPLOAD, + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message config, + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message deployId, deployTimeout = DEFAULT_DEPLOY_TIMEOUT, draft = false, + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message filter, fnDir = [], + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message functionsConfig, + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message hashAlgorithm, + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message manifestPath, maxRetry = DEFAULT_MAX_RETRY, + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message siteEnv, + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message siteRoot, + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message skipFunctionsCache, statusCb = () => { /* default to noop */ }, syncFileLimit = DEFAULT_SYNC_LIMIT, tmpDir = temporaryDirectory(), + // @ts-expect-error TS(2525) FIXME: Initializer provides no value for this binding ele... Remove this comment to see the full error message workingDir, } = {}, ) => { + // @ts-expect-error TS(2554) FIXME: Expected 0 arguments, but got 1. statusCb({ type: 'hashing', msg: `Hashing files...`, @@ -77,6 +93,7 @@ export const deploySite = async ( hashAlgorithm, statusCb, assetType, + // @ts-expect-error TS(2345) FIXME: Argument of type '{ functionsConfig: any; tmpDir: ... Remove this comment to see the full error message workingDir, manifestPath, skipFunctionsCache, @@ -98,6 +115,7 @@ export const deploySite = async ( edgeFunctionsCount > 0 && 'edge functions', ]) + // @ts-expect-error TS(2554) FIXME: Expected 0 arguments, but got 1. statusCb({ type: 'hashing', msg: `Finished hashing ${stats}`, @@ -109,8 +127,10 @@ export const deploySite = async ( } if (functionsWithNativeModules.length !== 0) { + // @ts-expect-error TS(7031) FIXME: Binding element 'name' implicitly has an 'any' typ... Remove this comment to see the full error message + const functionsWithNativeModulesMessage = functionsWithNativeModules.map(({ name }) => `- ${name}`).join('\n') warn(`Modules with native dependencies\n -${functionsWithNativeModules.map(({ name }) => `- ${name}`).join('\n')} + ${functionsWithNativeModulesMessage} The serverless functions above use Node.js modules with native dependencies, which must be installed on a system with the same architecture as the function runtime. A @@ -121,12 +141,14 @@ instead of manual deployment. For more information, visit https://ntl.fyi/cli-native-modules.`) } + // @ts-expect-error TS(2554) FIXME: Expected 0 arguments, but got 1. statusCb({ type: 'create-deploy', msg: 'CDN diffing files...', phase: 'start', }) + // @ts-expect-error TS(2349) This expression is not callable const deployParams = cleanDeep({ siteId, deploy_id: deployId, @@ -146,6 +168,7 @@ For more information, visit https://ntl.fyi/cli-native-modules.`) const { required: requiredFiles, required_functions: requiredFns } = deploy + // @ts-expect-error TS(2554) FIXME: Expected 0 arguments, but got 1. statusCb({ type: 'create-deploy', msg: `CDN requesting ${requiredFiles.length} files${ @@ -160,6 +183,7 @@ For more information, visit https://ntl.fyi/cli-native-modules.`) await uploadFiles(api, deployId, uploadList, { concurrentUpload, statusCb, maxRetry }) + // @ts-expect-error TS(2554) FIXME: Expected 0 arguments, but got 1. statusCb({ type: 'wait-for-deploy', msg: 'Waiting for deploy to go live...', @@ -167,6 +191,7 @@ For more information, visit https://ntl.fyi/cli-native-modules.`) }) deploy = await waitForDeploy(api, deployId, siteId, deployTimeout) + // @ts-expect-error TS(2554) FIXME: Expected 0 arguments, but got 1. statusCb({ type: 'wait-for-deploy', msg: draft ? 'Draft deploy is live!' : 'Deploy is live!', @@ -183,6 +208,7 @@ For more information, visit https://ntl.fyi/cli-native-modules.`) return deployManifest } +// @ts-expect-error TS(7006) FIXME: Parameter 'possibleParts' implicitly has an 'any' ... Remove this comment to see the full error message const buildStatsString = (possibleParts) => { const parts = possibleParts.filter(Boolean) const message = parts.slice(0, -1).join(', ') diff --git a/src/utils/deploy/hash-config.mjs b/src/utils/deploy/hash-config.mts similarity index 61% rename from src/utils/deploy/hash-config.mjs rename to src/utils/deploy/hash-config.mts index f8936a27c3f..7e1b7788d88 100644 --- a/src/utils/deploy/hash-config.mjs +++ b/src/utils/deploy/hash-config.mts @@ -1,6 +1,8 @@ import hasha from 'hasha' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'toml... Remove this comment to see the full error message import tomlify from 'tomlify-j0.4' +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message export const hashConfig = ({ config }) => { if (!config) throw new Error('Missing config option') const configString = serializeToml(config) @@ -15,12 +17,14 @@ export const hashConfig = ({ config }) => { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'object' implicitly has an 'any' type. export const serializeToml = function (object) { return tomlify.toToml(object, { space: 2, replace: replaceTomlValue }) } // `tomlify-j0.4` serializes integers as floats, e.g. `200.0`. // This is a problem with `redirects[*].status`. +// @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. const replaceTomlValue = function (key, value) { return Number.isInteger(value) ? String(value) : false } diff --git a/src/utils/deploy/hash-files.mjs b/src/utils/deploy/hash-files.mts similarity index 52% rename from src/utils/deploy/hash-files.mjs rename to src/utils/deploy/hash-files.mts index 1b73d111150..0ac4afe187d 100644 --- a/src/utils/deploy/hash-files.mjs +++ b/src/utils/deploy/hash-files.mts @@ -1,6 +1,8 @@ import { promisify } from 'util' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'fold... Remove this comment to see the full error message import walker from 'folder-walker' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'pump... Remove this comment to see the full error message import pumpModule from 'pump' import { fileFilterCtor, fileNormalizerCtor, hasherCtor, manifestCollectorCtor } from './hasher-segments.mjs' @@ -9,11 +11,16 @@ const pump = promisify(pumpModule) const hashFiles = async ({ assetType = 'file', + // @ts-expect-error TS(7031) FIXME: Binding element 'concurrentHash' implicitly has an... Remove this comment to see the full error message concurrentHash, + // @ts-expect-error TS(7031) FIXME: Binding element 'directories' implicitly has an 'a... Remove this comment to see the full error message directories, + // @ts-expect-error TS(7031) FIXME: Binding element 'filter' implicitly has an 'any' t... Remove this comment to see the full error message filter, hashAlgorithm = 'sha1', + // @ts-expect-error TS(7031) FIXME: Binding element 'normalizer' implicitly has an 'an... Remove this comment to see the full error message normalizer, + // @ts-expect-error TS(7031) FIXME: Binding element 'statusCb' implicitly has an 'any'... Remove this comment to see the full error message statusCb, }) => { if (!filter) throw new Error('Missing filter function option') diff --git a/src/utils/deploy/hash-fns.mjs b/src/utils/deploy/hash-fns.mts similarity index 58% rename from src/utils/deploy/hash-fns.mjs rename to src/utils/deploy/hash-fns.mts index 7bd5d604148..4b525f012b2 100644 --- a/src/utils/deploy/hash-fns.mjs +++ b/src/utils/deploy/hash-fns.mts @@ -3,7 +3,9 @@ import path from 'path' import { promisify } from 'util' import { zipFunctions } from '@netlify/zip-it-and-ship-it' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'from... Remove this comment to see the full error message import fromArray from 'from2-array' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'pump... Remove this comment to see the full error message import pumpModule from 'pump' import { getPathInProject } from '../../lib/settings.mjs' @@ -17,12 +19,19 @@ const pump = promisify(pumpModule) const MANIFEST_FILE_TTL = 12e4 const getFunctionZips = async ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'directories' implicitly has an 'a... Remove this comment to see the full error message directories, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionsConfig' implicitly has a... Remove this comment to see the full error message functionsConfig, + // @ts-expect-error TS(7031) FIXME: Binding element 'manifestPath' implicitly has an '... Remove this comment to see the full error message manifestPath, + // @ts-expect-error TS(7031) FIXME: Binding element 'rootDir' implicitly has an 'any' ... Remove this comment to see the full error message rootDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'skipFunctionsCache' implicitly ha... Remove this comment to see the full error message skipFunctionsCache, + // @ts-expect-error TS(7031) FIXME: Binding element 'statusCb' implicitly has an 'any'... Remove this comment to see the full error message statusCb, + // @ts-expect-error TS(7031) FIXME: Binding element 'tmpDir' implicitly has an 'any' t... Remove this comment to see the full error message tmpDir, }) => { statusCb({ @@ -34,6 +43,7 @@ const getFunctionZips = async ({ if (manifestPath) { try { // read manifest.json file + // @ts-expect-error TS(2345) FIXME: Argument of type 'Buffer' is not assignable to par... Remove this comment to see the full error message const { functions, timestamp } = JSON.parse(await readFile(manifestPath)) const manifestAge = Date.now() - timestamp @@ -75,16 +85,24 @@ const getFunctionZips = async ({ } const hashFns = async ( + // @ts-expect-error TS(7006) FIXME: Parameter 'directories' implicitly has an 'any' ty... Remove this comment to see the full error message directories, { assetType = 'function', + // @ts-expect-error TS(7031) FIXME: Binding element 'concurrentHash' implicitly has an... Remove this comment to see the full error message concurrentHash, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionsConfig' implicitly has a... Remove this comment to see the full error message functionsConfig, hashAlgorithm = 'sha256', + // @ts-expect-error TS(7031) FIXME: Binding element 'manifestPath' implicitly has an '... Remove this comment to see the full error message manifestPath, + // @ts-expect-error TS(7031) FIXME: Binding element 'rootDir' implicitly has an 'any' ... Remove this comment to see the full error message rootDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'skipFunctionsCache' implicitly ha... Remove this comment to see the full error message skipFunctionsCache, + // @ts-expect-error TS(7031) FIXME: Binding element 'statusCb' implicitly has an 'any'... Remove this comment to see the full error message statusCb, + // @ts-expect-error TS(7031) FIXME: Binding element 'tmpDir' implicitly has an 'any' t... Remove this comment to see the full error message tmpDir, }, ) => { @@ -107,6 +125,7 @@ const hashFns = async ( tmpDir, }) const fileObjs = functionZips.map( + // @ts-expect-error TS(7031) FIXME: Binding element 'buildData' implicitly has an 'any... Remove this comment to see the full error message ({ buildData, displayName, generator, invocationMode, path: functionPath, runtime, runtimeVersion }) => ({ filepath: functionPath, root: tmpDir, @@ -124,8 +143,10 @@ const hashFns = async ( }), ) const fnConfig = functionZips + // @ts-expect-error TS(7006) FIXME: Parameter 'func' implicitly has an 'any' type. .filter((func) => Boolean(func.displayName || func.generator || func.routes || func.buildData)) .reduce( + // @ts-expect-error TS(7006) FIXME: Parameter 'funcs' implicitly has an 'any' type. (funcs, curr) => ({ ...funcs, [curr.name]: { @@ -138,9 +159,11 @@ const hashFns = async ( {}, ) const functionSchedules = functionZips + // @ts-expect-error TS(7031) FIXME: Binding element 'name' implicitly has an 'any' typ... Remove this comment to see the full error message .map(({ name, schedule }) => schedule && { name, cron: schedule }) .filter(Boolean) const functionsWithNativeModules = functionZips.filter( + // @ts-expect-error TS(7031) FIXME: Binding element 'nativeNodeModules' implicitly has... Remove this comment to see the full error message ({ nativeNodeModules }) => nativeNodeModules !== undefined && Object.keys(nativeNodeModules).length !== 0, ) diff --git a/src/utils/deploy/hasher-segments.mjs b/src/utils/deploy/hasher-segments.mts similarity index 64% rename from src/utils/deploy/hasher-segments.mjs rename to src/utils/deploy/hasher-segments.mts index c2c5acb6726..94b9c2db928 100644 --- a/src/utils/deploy/hasher-segments.mjs +++ b/src/utils/deploy/hasher-segments.mts @@ -1,7 +1,11 @@ +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'flus... Remove this comment to see the full error message import flushWriteStream from 'flush-write-stream' import hasha from 'hasha' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'para... Remove this comment to see the full error message import transform from 'parallel-transform' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'thro... Remove this comment to see the full error message import { objCtor as objFilterCtor } from 'through2-filter' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'thro... Remove this comment to see the full error message import { obj as map } from 'through2-map' import { normalizePath } from './util.mjs' @@ -9,9 +13,11 @@ import { normalizePath } from './util.mjs' // a parallel transform stream segment ctor that hashes fileObj's created by folder-walker // TODO: use promises instead of callbacks /* eslint-disable promise/prefer-await-to-callbacks */ +// @ts-expect-error TS(7031) FIXME: Binding element 'concurrentHash' implicitly has an... Remove this comment to see the full error message export const hasherCtor = ({ concurrentHash, hashAlgorithm }) => { const hashaOpts = { algorithm: hashAlgorithm } if (!concurrentHash) throw new Error('Missing required opts') + // @ts-expect-error TS(7006) FIXME: Parameter 'fileObj' implicitly has an 'any' type. return transform(concurrentHash, { objectMode: true }, async (fileObj, cb) => { try { const hash = await hasha.fromFile(fileObj.filepath, hashaOpts) @@ -24,7 +30,9 @@ export const hasherCtor = ({ concurrentHash, hashAlgorithm }) => { } // Inject normalized file names into normalizedPath and assetType +// @ts-expect-error TS(7031) FIXME: Binding element 'assetType' implicitly has an 'any... Remove this comment to see the full error message export const fileNormalizerCtor = ({ assetType, normalizer: normalizeFunction }) => + // @ts-expect-error TS(7006) FIXME: Parameter 'fileObj' implicitly has an 'any' type. map((fileObj) => { const normalizedFile = { ...fileObj, assetType, normalizedPath: normalizePath(fileObj.relname) } @@ -36,8 +44,10 @@ export const fileNormalizerCtor = ({ assetType, normalizer: normalizeFunction }) }) // A writable stream segment ctor that normalizes file paths, and writes shaMap's +// @ts-expect-error TS(7006) FIXME: Parameter 'filesObj' implicitly has an 'any' type. export const manifestCollectorCtor = (filesObj, shaMap, { assetType, statusCb }) => { if (!statusCb || !assetType) throw new Error('Missing required options') + // @ts-expect-error TS(7006) FIXME: Parameter 'fileObj' implicitly has an 'any' type. return flushWriteStream.obj((fileObj, _, cb) => { filesObj[fileObj.normalizedPath] = fileObj.hash @@ -60,4 +70,5 @@ export const manifestCollectorCtor = (filesObj, shaMap, { assetType, statusCb }) /* eslint-enable promise/prefer-await-to-callbacks */ // transform stream ctor that filters folder-walker results for only files +// @ts-expect-error TS(7006) FIXME: Parameter 'fileObj' implicitly has an 'any' type. export const fileFilterCtor = objFilterCtor((fileObj) => fileObj.type === 'file') diff --git a/src/utils/deploy/upload-files.mjs b/src/utils/deploy/upload-files.mts similarity index 73% rename from src/utils/deploy/upload-files.mjs rename to src/utils/deploy/upload-files.mts index aea3a6827bb..ffac113a876 100644 --- a/src/utils/deploy/upload-files.mjs +++ b/src/utils/deploy/upload-files.mts @@ -1,10 +1,12 @@ import fs from 'fs' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'back... Remove this comment to see the full error message import backoff from 'backoff' import pMap from 'p-map' import { UPLOAD_INITIAL_DELAY, UPLOAD_MAX_DELAY, UPLOAD_RANDOM_FACTOR } from './constants.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'api' implicitly has an 'any' type. const uploadFiles = async (api, deployId, uploadList, { concurrentUpload, maxRetry, statusCb }) => { if (!concurrentUpload || !statusCb || !maxRetry) throw new Error('Missing required option concurrentUpload') statusCb({ @@ -13,6 +15,7 @@ const uploadFiles = async (api, deployId, uploadList, { concurrentUpload, maxRet phase: 'start', }) + // @ts-expect-error TS(7006) FIXME: Parameter 'fileObj' implicitly has an 'any' type. const uploadFile = async (fileObj, index) => { const { assetType, body, filepath, invocationMode, normalizedPath, runtime } = fileObj @@ -38,6 +41,7 @@ const uploadFiles = async (api, deployId, uploadList, { concurrentUpload, maxRet break } case 'function': { + // @ts-expect-error TS(7006) FIXME: Parameter 'retryCount' implicitly has an 'any' typ... Remove this comment to see the full error message response = await retryUpload((retryCount) => { const params = { body: readStreamCtor, @@ -48,6 +52,7 @@ const uploadFiles = async (api, deployId, uploadList, { concurrentUpload, maxRet } if (retryCount > 0) { + // @ts-expect-error TS(2339) FIXME: Property 'xNfRetryCount' does not exist on type '{... Remove this comment to see the full error message params.xNfRetryCount = retryCount } @@ -57,6 +62,7 @@ const uploadFiles = async (api, deployId, uploadList, { concurrentUpload, maxRet } default: { const error = new Error('File Object missing assetType property') + // @ts-expect-error TS(2339) FIXME: Property 'fileObj' does not exist on type 'Error'. error.fileObj = fileObj throw error } @@ -74,8 +80,10 @@ const uploadFiles = async (api, deployId, uploadList, { concurrentUpload, maxRet return results } +// @ts-expect-error TS(7006) FIXME: Parameter 'uploadFn' implicitly has an 'any' type. const retryUpload = (uploadFn, maxRetry) => new Promise((resolve, reject) => { + // @ts-expect-error TS(7034) FIXME: Variable 'lastError' implicitly has type 'any' in ... Remove this comment to see the full error message let lastError const fibonacciBackoff = backoff.fibonacci({ @@ -93,6 +101,7 @@ const retryUpload = (uploadFn, maxRetry) => lastError = error // observed errors: 408, 401 (4** swallowed), 502 + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error.status >= 400 || error.name === 'FetchError') { fibonacciBackoff.backoff() return @@ -111,6 +120,7 @@ const retryUpload = (uploadFn, maxRetry) => fibonacciBackoff.on('ready', tryUpload) fibonacciBackoff.on('fail', () => { + // @ts-expect-error TS(7005) FIXME: Variable 'lastError' implicitly has an 'any' type. reject(lastError) }) diff --git a/src/utils/deploy/util.mjs b/src/utils/deploy/util.mts similarity index 81% rename from src/utils/deploy/util.mjs rename to src/utils/deploy/util.mts index 095f6c7020c..52f378c44cf 100644 --- a/src/utils/deploy/util.mjs +++ b/src/utils/deploy/util.mts @@ -1,4 +1,4 @@ -// @ts-check + import { sep } from 'path' import pWaitFor from 'p-wait-for' @@ -6,6 +6,7 @@ import pWaitFor from 'p-wait-for' import { DEPLOY_POLL } from './constants.mjs' // normalize windows paths to unix paths +// @ts-expect-error TS(7006) FIXME: Parameter 'relname' implicitly has an 'any' type. export const normalizePath = (relname) => { if (relname.includes('#') || relname.includes('?')) { throw new Error(`Invalid filename ${relname}. Deployed filenames cannot contain # or ? characters`) @@ -14,6 +15,7 @@ export const normalizePath = (relname) => { } // poll an async deployId until its done diffing +// @ts-expect-error TS(7006) FIXME: Parameter 'api' implicitly has an 'any' type. export const waitForDiff = async (api, deployId, siteId, timeout) => { // capture ready deploy during poll let deploy @@ -25,6 +27,7 @@ export const waitForDiff = async (api, deployId, siteId, timeout) => { // https://github.com/netlify/bitballoon/blob/master/app/models/deploy.rb#L21-L33 case 'error': { const deployError = new Error(siteDeploy.error_message || `Deploy ${deployId} had an error`) + // @ts-expect-error TS(2339) FIXME: Property 'deploy' does not exist on type 'Error'. deployError.deploy = siteDeploy throw deployError } @@ -54,6 +57,7 @@ export const waitForDiff = async (api, deployId, siteId, timeout) => { } // Poll a deployId until its ready +// @ts-expect-error TS(7006) FIXME: Parameter 'api' implicitly has an 'any' type. export const waitForDeploy = async (api, deployId, siteId, timeout) => { // capture ready deploy during poll let deploy @@ -64,6 +68,7 @@ export const waitForDeploy = async (api, deployId, siteId, timeout) => { // https://github.com/netlify/bitballoon/blob/master/app/models/deploy.rb#L21-L33 case 'error': { const deployError = new Error(siteDeploy.error_message || `Deploy ${deployId} had an error`) + // @ts-expect-error TS(2339) FIXME: Property 'deploy' does not exist on type 'Error'. deployError.deploy = siteDeploy throw deployError } @@ -93,7 +98,9 @@ export const waitForDeploy = async (api, deployId, siteId, timeout) => { } // Transform the fileShaMap and fnShaMap into a generic shaMap that file-uploader.js can use +// @ts-expect-error TS(7006) FIXME: Parameter 'required' implicitly has an 'any' type. export const getUploadList = (required, shaMap) => { if (!required || !shaMap) return [] + // @ts-expect-error TS(7006) FIXME: Parameter 'sha' implicitly has an 'any' type. return required.flatMap((sha) => shaMap[sha]) } diff --git a/src/utils/detect-server-settings.mjs b/src/utils/detect-server-settings.mts similarity index 80% rename from src/utils/detect-server-settings.mjs rename to src/utils/detect-server-settings.mts index 1d9c67521e5..36aa09b1fd4 100644 --- a/src/utils/detect-server-settings.mjs +++ b/src/utils/detect-server-settings.mts @@ -1,4 +1,4 @@ -// @ts-check + import { readFile } from 'fs/promises' import { EOL } from 'os' import { dirname, relative, resolve } from 'path' @@ -13,8 +13,10 @@ import { getInternalFunctionsDir } from './functions/functions.mjs' import { getPluginsToAutoInstall } from './init/utils.mjs' /** @param {string} str */ +// @ts-expect-error TS(7006) FIXME: Parameter 'str' implicitly has an 'any' type. const formatProperty = (str) => chalk.magenta(`'${str}'`) /** @param {string} str */ +// @ts-expect-error TS(7006) FIXME: Parameter 'str' implicitly has an 'any' type. const formatValue = (str) => chalk.green(`'${str}'`) /** @@ -23,6 +25,7 @@ const formatValue = (str) => chalk.green(`'${str}'`) * @param {string} options.certFile * @returns {Promise<{ key: string, cert: string, keyFilePath: string, certFilePath: string }>} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. const readHttpsSettings = async (options) => { if (typeof options !== 'object' || !options.keyFile || !options.certFile) { throw new TypeError( @@ -58,6 +61,7 @@ const readHttpsSettings = async (options) => { * @param {keyof import('../commands/dev/types.js').DevConfig} property The property to validate * @param {'string' | 'number'} type The type it should have */ +// @ts-expect-error TS(7006) FIXME: Parameter 'devConfig' implicitly has an 'any' type... Remove this comment to see the full error message function validateProperty(devConfig, property, type) { // eslint-disable-next-line valid-typeof if (devConfig[property] && typeof devConfig[property] !== type) { @@ -73,6 +77,7 @@ function validateProperty(devConfig, property, type) { * @param {object} config * @param {import('../commands/dev/types.js').DevConfig} config.devConfig */ +// @ts-expect-error TS(7031) FIXME: Binding element 'devConfig' implicitly has an 'any... Remove this comment to see the full error message const validateFrameworkConfig = ({ devConfig }) => { validateProperty(devConfig, 'command', 'string') validateProperty(devConfig, 'port', 'number') @@ -92,6 +97,7 @@ const validateFrameworkConfig = ({ devConfig }) => { * @param {import('../commands/dev/types.js').DevConfig} config.devConfig * @param {number=} config.detectedPort */ +// @ts-expect-error TS(7031) FIXME: Binding element 'detectedPort' implicitly has an '... Remove this comment to see the full error message const validateConfiguredPort = ({ detectedPort, devConfig }) => { if (devConfig.port && devConfig.port === detectedPort) { const formattedPort = formatProperty('port') @@ -108,6 +114,7 @@ const DEFAULT_STATIC_PORT = 3999 * Logs a message that it was unable to determine the dist directory and falls back to the workingDir * @param {string} workingDir */ +// @ts-expect-error TS(7006) FIXME: Parameter 'workingDir' implicitly has an 'any' typ... Remove this comment to see the full error message const getDefaultDist = (workingDir) => { log(`${NETLIFYDEVWARN} Unable to determine public folder to serve files from. Using current working directory`) log(`${NETLIFYDEVWARN} Setup a netlify.toml file with a [dev] section to specify your dev server settings.`) @@ -120,6 +127,7 @@ const getDefaultDist = (workingDir) => { * @param {import('../commands/dev/types.js').DevConfig} config.devConfig * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'devConfig' implicitly has an 'any... Remove this comment to see the full error message const getStaticServerPort = async ({ devConfig }) => { const port = await acquirePort({ configuredPort: devConfig.staticServerPort, @@ -138,6 +146,7 @@ const getStaticServerPort = async ({ devConfig }) => { * @param {string} config.workingDir * @returns {Promise & {command?: string}>} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'devConfig' implicitly has an 'any... Remove this comment to see the full error message const handleStaticServer = async ({ devConfig, flags, workingDir }) => { validateProperty(devConfig, 'staticServerPort', 'number') @@ -176,6 +185,7 @@ const handleStaticServer = async ({ devConfig, flags, workingDir }) => { * @param {import('@netlify/build-info').Settings} [settings] * @returns {import('./types.js').BaseServerSettings | undefined} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'settings' implicitly has an 'any' type. const getSettingsFromDetectedSettings = (settings) => { if (!settings) { return @@ -195,6 +205,7 @@ const getSettingsFromDetectedSettings = (settings) => { /** * @param {import('../commands/dev/types.js').DevConfig} devConfig */ +// @ts-expect-error TS(7006) FIXME: Parameter 'devConfig' implicitly has an 'any' type... Remove this comment to see the full error message const hasCommandAndTargetPort = (devConfig) => devConfig.command && devConfig.targetPort /** @@ -204,6 +215,7 @@ const hasCommandAndTargetPort = (devConfig) => devConfig.command && devConfig.ta * @param {string} config.workingDir * @returns {import('./types.js').BaseServerSettings} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'devConfig' implicitly has an 'any... Remove this comment to see the full error message const handleCustomFramework = ({ devConfig, workingDir }) => { if (!hasCommandAndTargetPort(devConfig)) { throw new Error( @@ -228,18 +240,26 @@ const handleCustomFramework = ({ devConfig, workingDir }) => { * @param {string} config.workingDir * @param {Partial=} config.frameworkSettings */ +// @ts-expect-error TS(7031) FIXME: Binding element 'devConfig' implicitly has an 'any... Remove this comment to see the full error message const mergeSettings = async ({ devConfig, frameworkSettings = {}, workingDir }) => { + // @ts-expect-error TS(2339) FIXME: Property 'command' does not exist on type '{}'. const command = devConfig.command || frameworkSettings.command + // @ts-expect-error TS(2339) FIXME: Property 'frameworkPort' does not exist on type '{... Remove this comment to see the full error message const frameworkPort = devConfig.targetPort || frameworkSettings.frameworkPort // if the framework doesn't start a server, we use a static one const useStaticServer = !(command && frameworkPort) return { + // @ts-expect-error TS(2339) FIXME: Property 'baseDirectory' does not exist on type '{... Remove this comment to see the full error message baseDirectory: devConfig.base || frameworkSettings.baseDirectory, command, frameworkPort: useStaticServer ? await getStaticServerPort({ devConfig }) : frameworkPort, + // @ts-expect-error TS(2339) FIXME: Property 'dist' does not exist on type '{}'. dist: devConfig.publish || frameworkSettings.dist || getDefaultDist(workingDir), + // @ts-expect-error TS(2339) FIXME: Property 'framework' does not exist on type '{}'. framework: frameworkSettings.framework, + // @ts-expect-error TS(2339) FIXME: Property 'env' does not exist on type '{}'. env: frameworkSettings.env, + // @ts-expect-error TS(2339) FIXME: Property 'pollingStrategies' does not exist on typ... Remove this comment to see the full error message pollingStrategies: frameworkSettings.pollingStrategies || [], useStaticServer, } @@ -254,6 +274,7 @@ const mergeSettings = async ({ devConfig, frameworkSettings = {}, workingDir }) * @param {string=} config.workspacePackage * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'devConfig' implicitly has an 'any... Remove this comment to see the full error message const handleForcedFramework = async ({ devConfig, project, workingDir, workspacePackage }) => { // this throws if `devConfig.framework` is not a supported framework const framework = await getFramework(devConfig.framework, project) @@ -270,6 +291,7 @@ const handleForcedFramework = async ({ devConfig, project, workingDir, workspace * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'devConfig' implicitly has an 'any' type... Remove this comment to see the full error message const detectServerSettings = async (devConfig, flags, command) => { validateProperty(devConfig, 'framework', 'string') @@ -295,6 +317,7 @@ const detectServerSettings = async (devConfig, flags, command) => { settings = await mergeSettings({ devConfig, frameworkSettings, workingDir: command.workingDir }) } + // @ts-expect-error TS(2339) FIXME: Property 'plugins' does not exist on type '{}'. settings.plugins = frameworkSettings?.plugins } else if (devConfig.framework === '#custom') { validateFrameworkConfig({ devConfig }) @@ -311,6 +334,7 @@ const detectServerSettings = async (devConfig, flags, command) => { }) } + // @ts-expect-error TS(2339) FIXME: Property 'frameworkPort' does not exist on type '{... Remove this comment to see the full error message validateConfiguredPort({ devConfig, detectedPort: settings.frameworkPort }) const acquiredPort = await acquirePort({ @@ -318,7 +342,9 @@ const detectServerSettings = async (devConfig, flags, command) => { defaultPort: DEFAULT_PORT, errorMessage: `Could not acquire required ${formatProperty('port')}`, }) + // @ts-expect-error TS(2339) FIXME: Property 'functions' does not exist on type '{}'. const functionsDir = devConfig.functions || settings.functions + // @ts-expect-error TS(2345) FIXME: Argument of type '{ base: any; }' is not assignabl... Remove this comment to see the full error message const internalFunctionsDir = await getInternalFunctionsDir({ base: command.workingDir }) const shouldStartFunctionsServer = Boolean(functionsDir || internalFunctionsDir) @@ -340,6 +366,7 @@ const detectServerSettings = async (devConfig, flags, command) => { * @param {Partial} settings * @returns {*} Modified config */ +// @ts-expect-error TS(7006) FIXME: Parameter 'config' implicitly has an 'any' type. export const getConfigWithPlugins = (config, settings) => { if (!settings.plugins) { return config @@ -350,8 +377,10 @@ export const getConfigWithPlugins = (config, settings) => { // whether the plugin has already been added by another source (like the // TOML file or the UI), as we don't want to run the same plugin twice. const { plugins: existingPlugins = [] } = config + // @ts-expect-error TS(7006) FIXME: Parameter 'plugin' implicitly has an 'any' type. const existingPluginNames = new Set(existingPlugins.map((plugin) => plugin.package)) const newPlugins = settings.plugins + // @ts-expect-error TS(7006) FIXME: Parameter 'pluginName' implicitly has an 'any' typ... Remove this comment to see the full error message .map((pluginName) => { if (existingPluginNames.has(pluginName)) { return diff --git a/src/utils/dev.mjs b/src/utils/dev.mts similarity index 72% rename from src/utils/dev.mjs rename to src/utils/dev.mts index 2aae311a64e..f9c754c92c1 100644 --- a/src/utils/dev.mjs +++ b/src/utils/dev.mts @@ -1,4 +1,4 @@ -// @ts-check + import process from 'process' import getPort from 'get-port' @@ -40,39 +40,49 @@ const ENV_VAR_SOURCES = { const ERROR_CALL_TO_ACTION = "Double-check your login status with 'netlify status' or contact support with details of your error." +// @ts-expect-error TS(7031) FIXME: Binding element 'site' implicitly has an 'any' typ... Remove this comment to see the full error message const validateSiteInfo = ({ site, siteInfo }) => { if (isEmpty(siteInfo)) { error(`Failed retrieving site information for site ${chalk.yellow(site.id)}. ${ERROR_CALL_TO_ACTION}`) } } +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const getAccounts = async ({ api }) => { try { const accounts = await api.listAccountsForUser() return accounts } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(`Failed retrieving user account: ${error_.message}. ${ERROR_CALL_TO_ACTION}`) } } +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const getAddons = async ({ api, site }) => { try { const addons = await api.listServiceInstancesForSite({ siteId: site.id }) return addons } catch (error_) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error(`Failed retrieving addons for site ${chalk.yellow(site.id)}: ${error_.message}. ${ERROR_CALL_TO_ACTION}`) } } +// @ts-expect-error TS(7031) FIXME: Binding element 'addons' implicitly has an 'any' t... Remove this comment to see the full error message const getAddonsInformation = ({ addons, siteInfo }) => { const urls = Object.fromEntries( + // @ts-expect-error TS(7006) FIXME: Parameter 'addon' implicitly has an 'any' type. addons.map((addon) => [addon.service_slug, `${siteInfo.ssl_url}${addon.service_path}`]), ) + // @ts-expect-error TS(7006) FIXME: Parameter 'addon' implicitly has an 'any' type. const env = Object.assign({}, ...addons.map((addon) => addon.env)) return { urls, env } } +// @ts-expect-error TS(7031) FIXME: Binding element 'accounts' implicitly has an 'any'... Remove this comment to see the full error message const getSiteAccount = ({ accounts, siteInfo }) => { + // @ts-expect-error TS(7006) FIXME: Parameter 'account' implicitly has an 'any' type. const siteAccount = accounts.find((account) => account.slug === siteInfo.account_slug) if (!siteAccount) { warn(`Could not find account for site '${siteInfo.name}' with account slug '${siteInfo.account_slug}'`) @@ -96,6 +106,7 @@ const BACKGROUND_FUNCTION_TIMEOUT = 900 * @param {*} config.siteInfo * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message export const getSiteInformation = async ({ api, offline, site, siteInfo }) => { if (site.id && !offline) { validateSiteInfo({ site, siteInfo }) @@ -130,7 +141,9 @@ export const getSiteInformation = async ({ api, offline, site, siteInfo }) => { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'source' implicitly has an 'any' type. const getEnvSourceName = (source) => { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message const { name = source, printFn = chalk.green } = ENV_VAR_SOURCES[source] || {} return printFn(name) @@ -140,8 +153,10 @@ const getEnvSourceName = (source) => { * @param {{devConfig: any, env: Record, site: any}} param0 * @returns {Promise>} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'devConfig' implicitly has an 'any... Remove this comment to see the full error message export const getDotEnvVariables = async ({ devConfig, env, site }) => { const dotEnvFiles = await loadDotEnvFiles({ envFiles: devConfig.envFiles, projectDir: site.root }) + // @ts-expect-error TS(2339) FIXME: Property 'env' does not exist on type '{ warning: ... Remove this comment to see the full error message dotEnvFiles.forEach(({ env: fileEnv, file }) => { const newSourceName = `${file} file` @@ -167,13 +182,17 @@ export const getDotEnvVariables = async ({ devConfig, env, site }) => { * @param {Record} env * @return {void} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'env' implicitly has an 'any' type. export const injectEnvVariables = (env) => { for (const [key, variable] of Object.entries(env)) { const existsInProcess = process.env[key] !== undefined + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. const [usedSource, ...overriddenSources] = existsInProcess ? ['process', ...variable.sources] : variable.sources const usedSourceName = getEnvSourceName(usedSource) + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. const isInternal = variable.sources.includes('internal') + // @ts-expect-error TS(7006) FIXME: Parameter 'source' implicitly has an 'any' type. overriddenSources.forEach((source) => { const sourceName = getEnvSourceName(source) @@ -192,11 +211,13 @@ export const injectEnvVariables = (env) => { log(`${NETLIFYDEVLOG} Injected ${usedSourceName} env var: ${chalk.yellow(key)}`) } + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. process.env[key] = variable.value } } } +// @ts-expect-error TS(7031) FIXME: Binding element 'configuredPort' implicitly has an... Remove this comment to see the full error message export const acquirePort = async ({ configuredPort, defaultPort, errorMessage }) => { const acquiredPort = await getPort({ port: configuredPort || defaultPort }) if (configuredPort && acquiredPort !== configuredPort) { @@ -205,6 +226,7 @@ export const acquirePort = async ({ configuredPort, defaultPort, errorMessage }) return acquiredPort } +// @ts-expect-error TS(7006) FIXME: Parameter 'fn' implicitly has an 'any' type. export const processOnExit = (fn) => { const signals = ['SIGINT', 'SIGTERM', 'SIGQUIT', 'SIGHUP', 'exit'] signals.forEach((signal) => { diff --git a/src/utils/dot-env.mjs b/src/utils/dot-env.mts similarity index 71% rename from src/utils/dot-env.mjs rename to src/utils/dot-env.mts index 3999e2c9621..5f76c80c140 100644 --- a/src/utils/dot-env.mjs +++ b/src/utils/dot-env.mts @@ -1,4 +1,4 @@ -// @ts-check + import { readFile } from 'fs/promises' import path from 'path' @@ -8,20 +8,25 @@ import { isFileAsync } from '../lib/fs.mjs' import { warn } from './command-helpers.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'envFiles' implicitly has an 'any'... Remove this comment to see the full error message export const loadDotEnvFiles = async function ({ envFiles, projectDir }) { const response = await tryLoadDotEnvFiles({ projectDir, dotenvFiles: envFiles }) + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. const filesWithWarning = response.filter((el) => el.warning) filesWithWarning.forEach((el) => { + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. warn(el.warning) }) + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. return response.filter((el) => el.file && el.env) } // in the user configuration, the order is highest to lowest const defaultEnvFiles = ['.env.development.local', '.env.local', '.env.development', '.env'] +// @ts-expect-error TS(7031) FIXME: Binding element 'projectDir' implicitly has an 'an... Remove this comment to see the full error message export const tryLoadDotEnvFiles = async ({ dotenvFiles = defaultEnvFiles, projectDir }) => { const results = await Promise.all( dotenvFiles.map(async (file) => { @@ -33,6 +38,7 @@ export const tryLoadDotEnvFiles = async ({ dotenvFiles = defaultEnvFiles, projec } } catch (error) { return { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. warning: `Failed reading env variables from file: ${filepath}: ${error.message}`, } } diff --git a/src/utils/env/index.mjs b/src/utils/env/index.mts similarity index 81% rename from src/utils/env/index.mjs rename to src/utils/env/index.mts index d0d12556454..95006f3630c 100644 --- a/src/utils/env/index.mjs +++ b/src/utils/env/index.mts @@ -7,6 +7,7 @@ export const AVAILABLE_SCOPES = ['builds', 'functions', 'runtime', 'post_process * @param {string|undefined} context - The deploy context or branch of the environment variable value * @returns {Array} The normalized context or branch name */ +// @ts-expect-error TS(7006) FIXME: Parameter 'context' implicitly has an 'any' type. export const normalizeContext = (context) => { if (!context) { return context @@ -17,6 +18,7 @@ export const normalizeContext = (context) => { } context = context.toLowerCase() if (context in CONTEXT_SYNONYMS) { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message context = CONTEXT_SYNONYMS[context] } const forbiddenContexts = AVAILABLE_CONTEXTS.map((ctx) => `branch:${ctx}`) @@ -33,7 +35,9 @@ export const normalizeContext = (context) => { * @param {string} context - The deploy context or branch of the environment variable value * @returns {object, context_parameter: , value: string>} The matching environment variable value object */ +// @ts-expect-error TS(7006) FIXME: Parameter 'values' implicitly has an 'any' type. export const findValueInValues = (values, context) => + // @ts-expect-error TS(7006) FIXME: Parameter 'val' implicitly has an 'any' type. values.find((val) => { if (!AVAILABLE_CONTEXTS.includes(context)) { // the "context" option passed in is actually the name of a branch @@ -48,7 +52,9 @@ export const findValueInValues = (values, context) => * @param {enum} source - The source of the environment variable * @returns {object} The dictionary of env vars that match the given source */ +// @ts-expect-error TS(7006) FIXME: Parameter 'env' implicitly has an 'any' type. export const filterEnvBySource = (env, source) => + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. Object.fromEntries(Object.entries(env).filter(([, variable]) => variable.sources[0] === source)) /** @@ -59,6 +65,7 @@ export const filterEnvBySource = (env, source) => * @param {string} siteId - The site id * @returns {Array} An array of environment variables from the Envelope service */ +// @ts-expect-error TS(7031) FIXME: Binding element 'accountId' implicitly has an 'any... Remove this comment to see the full error message const fetchEnvelopeItems = async function ({ accountId, api, key, siteId }) { if (accountId === undefined) { return {} @@ -102,22 +109,28 @@ const fetchEnvelopeItems = async function ({ accountId, api, key, siteId }) { * }, * } */ +// @ts-expect-error TS(7031) FIXME: Binding element 'source' implicitly has an 'any' t... Remove this comment to see the full error message export const formatEnvelopeData = ({ context = 'dev', envelopeItems = [], scope = 'any', source }) => envelopeItems // filter by context .filter(({ values }) => Boolean(findValueInValues(values, context))) // filter by scope + // @ts-expect-error TS(2339) FIXME: Property 'includes' does not exist on type 'never'... Remove this comment to see the full error message .filter(({ scopes }) => (scope === 'any' ? true : scopes.includes(scope))) // sort alphabetically, case insensitive + // @ts-expect-error TS(2339) FIXME: Property 'key' does not exist on type 'never'. .sort((left, right) => (left.key.toLowerCase() < right.key.toLowerCase() ? -1 : 1)) // format the data .reduce((acc, cur) => { + // @ts-expect-error TS(2339) FIXME: Property 'values' does not exist on type 'never'. const { context: ctx, context_parameter: branch, value } = findValueInValues(cur.values, context) return { ...acc, + // @ts-expect-error TS(2339) FIXME: Property 'key' does not exist on type 'never'. [cur.key]: { context: ctx, branch, + // @ts-expect-error TS(2339) FIXME: Property 'scopes' does not exist on type 'never'. scopes: cur.scopes, sources: [source], value, @@ -136,10 +149,12 @@ export const formatEnvelopeData = ({ context = 'dev', envelopeItems = [], scope * @param {object} siteInfo - The site object * @returns {object} An object of environment variables keys and their metadata */ +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message export const getEnvelopeEnv = async ({ api, context = 'dev', env, key = '', raw = false, scope = 'any', siteInfo }) => { const { account_slug: accountId, id: siteId } = siteInfo const [accountEnvelopeItems, siteEnvelopeItems] = await Promise.all([ + // @ts-expect-error TS(2345) FIXME: Argument of type '{ api: any; accountId: any; key:... Remove this comment to see the full error message fetchEnvelopeItems({ api, accountId, key }), fetchEnvelopeItems({ api, accountId, key, siteId }), ]) @@ -152,6 +167,7 @@ export const getEnvelopeEnv = async ({ api, context = 'dev', env, key = '', raw return entries.reduce( (obj, [envVarKey, metadata]) => ({ ...obj, + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. [envVarKey]: metadata.value, }), {}, @@ -182,6 +198,7 @@ export const getEnvelopeEnv = async ({ api, context = 'dev', env, key = '', raw * @param {Array>} scopes - An array of scopes * @returns {string} A human-readable, comma-separated list of scopes */ +// @ts-expect-error TS(7006) FIXME: Parameter 'scopes' implicitly has an 'any' type. export const getHumanReadableScopes = (scopes) => { const HUMAN_SCOPES = ['Builds', 'Functions', 'Runtime', 'Post processing'] const SCOPES_MAP = { @@ -200,6 +217,7 @@ export const getHumanReadableScopes = (scopes) => { // shorthand instead of listing every available scope return 'All' } + // @ts-expect-error TS(7006) FIXME: Parameter 'scope' implicitly has an 'any' type. return scopes.map((scope) => SCOPES_MAP[scope]).join(', ') } @@ -231,12 +249,15 @@ export const translateFromMongoToEnvelope = (env = {}) => { */ export const translateFromEnvelopeToMongo = (envVars = [], context = 'dev') => envVars + // @ts-expect-error TS(2339) FIXME: Property 'key' does not exist on type 'never'. .sort((left, right) => (left.key.toLowerCase() < right.key.toLowerCase() ? -1 : 1)) .reduce((acc, cur) => { + // @ts-expect-error TS(2339) FIXME: Property 'values' does not exist on type 'never'. const envVar = cur.values.find((val) => [context, 'all'].includes(val.context_parameter || val.context)) if (envVar && envVar.value) { return { ...acc, + // @ts-expect-error TS(2339) FIXME: Property 'key' does not exist on type 'never'. [cur.key]: envVar.value, } } diff --git a/src/utils/execa.mjs b/src/utils/execa.mts similarity index 100% rename from src/utils/execa.mjs rename to src/utils/execa.mts diff --git a/src/utils/feature-flags.mjs b/src/utils/feature-flags.mts similarity index 89% rename from src/utils/feature-flags.mjs rename to src/utils/feature-flags.mts index 827741c5dab..257208bcd86 100644 --- a/src/utils/feature-flags.mjs +++ b/src/utils/feature-flags.mts @@ -11,6 +11,7 @@ * * @returns {boolean} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'flagName' implicitly has an 'any' type. export const isFeatureFlagEnabled = (flagName, siteInfo) => { if (siteInfo.feature_flags && siteInfo.feature_flags[flagName] !== false) { return true diff --git a/src/utils/framework-server.mjs b/src/utils/framework-server.mts similarity index 78% rename from src/utils/framework-server.mjs rename to src/utils/framework-server.mts index 36b2c60a834..7b8088eec0c 100644 --- a/src/utils/framework-server.mjs +++ b/src/utils/framework-server.mts @@ -1,4 +1,4 @@ -// @ts-check + import waitPort from 'wait-port' import { startSpinner, stopSpinner } from '../lib/spinner.mjs' @@ -22,6 +22,7 @@ const FRAMEWORK_PORT_TIMEOUT = 6e5 * @param {string} config.cwd * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'cwd' implicitly has an 'any' type... Remove this comment to see the full error message export const startFrameworkServer = async function ({ cwd, settings }) { if (settings.useStaticServer) { if (settings.command) { @@ -54,11 +55,14 @@ export const startFrameworkServer = async function ({ cwd, settings }) { throw new Error(`Timed out waiting for port '${settings.frameworkPort}' to be open`) } + // @ts-expect-error TS(2345) FIXME: Argument of type '{ error: boolean; spinner: Ora; ... Remove this comment to see the full error message stopSpinner({ error: false, spinner }) } catch (error_) { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ error: boolean; spinner: Ora; ... Remove this comment to see the full error message stopSpinner({ error: true, spinner }) log(NETLIFYDEVERR, `Netlify Dev could not start or connect to localhost:${settings.frameworkPort}.`) log(NETLIFYDEVERR, `Please make sure your framework server is running on port ${settings.frameworkPort}`) + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message error(error_) exit(1) } diff --git a/src/utils/functions/constants.mjs b/src/utils/functions/constants.mts similarity index 100% rename from src/utils/functions/constants.mjs rename to src/utils/functions/constants.mts diff --git a/src/utils/functions/functions.mjs b/src/utils/functions/functions.mts similarity index 74% rename from src/utils/functions/functions.mjs rename to src/utils/functions/functions.mts index bfbf21fdf0d..f841727b12a 100644 --- a/src/utils/functions/functions.mjs +++ b/src/utils/functions/functions.mts @@ -1,4 +1,4 @@ -// @ts-check + import { promises as fs } from 'fs' import { resolve } from 'path' @@ -16,9 +16,11 @@ export const SERVE_FUNCTIONS_FOLDER = 'functions-serve' * @param {string} [defaultValue] * @returns {string} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message export const getFunctionsDir = ({ config, options }, defaultValue) => options.functions || config.dev?.functions || config.functionsDirectory || config.dev?.Functions || defaultValue +// @ts-expect-error TS(7031) FIXME: Binding element 'base' implicitly has an 'any' typ... Remove this comment to see the full error message export const getFunctionsManifestPath = async ({ base, packagePath = '' }) => { const path = resolve(base, packagePath, getPathInProject(['functions', 'manifest.json'])) const isFile = await isFileAsync(path) @@ -26,6 +28,7 @@ export const getFunctionsManifestPath = async ({ base, packagePath = '' }) => { return isFile ? path : null } +// @ts-expect-error TS(7031) FIXME: Binding element 'base' implicitly has an 'any' typ... Remove this comment to see the full error message export const getFunctionsDistPath = async ({ base, packagePath = '' }) => { const path = resolve(base, packagePath, getPathInProject(['functions'])) const isDirectory = await isDirectoryAsync(path) @@ -33,6 +36,7 @@ export const getFunctionsDistPath = async ({ base, packagePath = '' }) => { return isDirectory ? path : null } +// @ts-expect-error TS(7031) FIXME: Binding element 'base' implicitly has an 'any' typ... Remove this comment to see the full error message export const getFunctionsServePath = ({ base, packagePath = '' }) => { const path = resolve(base, packagePath, getPathInProject([SERVE_FUNCTIONS_FOLDER])) @@ -47,6 +51,7 @@ export const getFunctionsServePath = ({ base, packagePath = '' }) => { * @param {string} config.packagePath * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'base' implicitly has an 'any' typ... Remove this comment to see the full error message export const getInternalFunctionsDir = async ({ base, ensureExists, packagePath = '' }) => { const path = resolve(base, packagePath, getPathInProject([INTERNAL_FUNCTIONS_FOLDER])) diff --git a/src/utils/functions/get-functions.mjs b/src/utils/functions/get-functions.mts similarity index 56% rename from src/utils/functions/get-functions.mjs rename to src/utils/functions/get-functions.mts index 2c97e2c551c..31e3aa8feda 100644 --- a/src/utils/functions/get-functions.mjs +++ b/src/utils/functions/get-functions.mts @@ -1,13 +1,15 @@ -// @ts-check + import { listFunctions } from '@netlify/zip-it-and-ship-it' import { fileExistsAsync } from '../../lib/fs.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'functionName' implicitly has an 'any' t... Remove this comment to see the full error message const getUrlPath = (functionName) => `/.netlify/functions/${functionName}` export const BACKGROUND = '-background' const JS = 'js' +// @ts-expect-error TS(7031) FIXME: Binding element 'mainFile' implicitly has an 'any'... Remove this comment to see the full error message const addFunctionProps = ({ mainFile, name, runtime, schedule }) => { const urlPath = getUrlPath(name) const isBackground = name.endsWith(BACKGROUND) @@ -18,18 +20,23 @@ const addFunctionProps = ({ mainFile, name, runtime, schedule }) => { * @param {Record} functionConfigRecord * @returns {Record} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'functionConfigRecord' implicitly has an... Remove this comment to see the full error message const extractSchedule = (functionConfigRecord) => + // @ts-expect-error TS(2339) FIXME: Property 'schedule' does not exist on type 'unknow... Remove this comment to see the full error message Object.fromEntries(Object.entries(functionConfigRecord).map(([name, { schedule }]) => [name, { schedule }])) +// @ts-expect-error TS(7006) FIXME: Parameter 'functionsSrcDir' implicitly has an 'any... Remove this comment to see the full error message export const getFunctions = async (functionsSrcDir, config = {}) => { if (!(await fileExistsAsync(functionsSrcDir))) { return [] } const functions = await listFunctions(functionsSrcDir, { + // @ts-expect-error TS(2339) FIXME: Property 'functions' does not exist on type '{}'. config: config.functions ? extractSchedule(config.functions) : undefined, parseISC: true, }) + // @ts-expect-error TS(2345) FIXME: Argument of type 'ListedFunction' is not assignabl... Remove this comment to see the full error message const functionsWithProps = functions.filter(({ runtime }) => runtime === JS).map((func) => addFunctionProps(func)) return functionsWithProps } diff --git a/src/utils/functions/index.mjs b/src/utils/functions/index.mts similarity index 100% rename from src/utils/functions/index.mjs rename to src/utils/functions/index.mts diff --git a/src/utils/get-global-config.mjs b/src/utils/get-global-config.mts similarity index 61% rename from src/utils/get-global-config.mjs rename to src/utils/get-global-config.mts index 64ad2288382..a557740e859 100644 --- a/src/utils/get-global-config.mjs +++ b/src/utils/get-global-config.mts @@ -1,6 +1,8 @@ import { readFile } from 'fs/promises' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'conf... Remove this comment to see the full error message import Configstore from 'configstore' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'uuid... Remove this comment to see the full error message import { v4 as uuidv4 } from 'uuid' import { getLegacyPathInHome, getPathInHome } from '../lib/settings.mjs' @@ -13,12 +15,14 @@ const globalConfigDefaults = { } // Memoise config result so that we only load it once +// @ts-expect-error TS(7034) FIXME: Variable 'configStore' implicitly has type 'any' i... Remove this comment to see the full error message let configStore /** * @returns {Promise} */ const getGlobalConfig = async function () { + // @ts-expect-error TS(7005) FIXME: Variable 'configStore' implicitly has an 'any' typ... Remove this comment to see the full error message if (!configStore) { const configPath = getPathInHome(['config.json']) // Legacy config file in home ~/.netlify/config.json @@ -26,6 +30,7 @@ const getGlobalConfig = async function () { let legacyConfig // Read legacy config if exists try { + // @ts-expect-error TS(2345) FIXME: Argument of type 'Buffer' is not assignable to par... Remove this comment to see the full error message legacyConfig = JSON.parse(await readFile(legacyPath)) } catch {} // Use legacy config as default values diff --git a/src/utils/get-package-json.mjs b/src/utils/get-package-json.mjs deleted file mode 100644 index ca1d76011f5..00000000000 --- a/src/utils/get-package-json.mjs +++ /dev/null @@ -1,16 +0,0 @@ -import { readFile } from 'fs/promises' -import { dirname, join } from 'path' -import { fileURLToPath } from 'url' - -let packageJson - -const getPackageJson = async () => { - if (!packageJson) { - const packageJsonPath = join(dirname(fileURLToPath(import.meta.url)), '../../package.json') - packageJson = JSON.parse(await readFile(packageJsonPath)) - } - - return packageJson -} - -export default getPackageJson diff --git a/src/utils/get-package-json.mts b/src/utils/get-package-json.mts new file mode 100644 index 00000000000..e6508a7ce94 --- /dev/null +++ b/src/utils/get-package-json.mts @@ -0,0 +1,19 @@ +import { readFile } from 'fs/promises' +import { dirname, join } from 'path' +import { fileURLToPath } from 'url' + +// @ts-expect-error TS(7034) FIXME: Variable 'packageJson' implicitly has type 'any' i... Remove this comment to see the full error message +let packageJson + +const getPackageJson = async () => { + // @ts-expect-error TS(7005) FIXME: Variable 'packageJson' implicitly has an 'any' typ... Remove this comment to see the full error message + if (!packageJson) { + const packageJsonPath = join(dirname(fileURLToPath(import.meta.url)), '../../package.json') + // @ts-expect-error TS(2345) FIXME: Argument of type 'Buffer' is not assignable to par... Remove this comment to see the full error message + packageJson = JSON.parse(await readFile(packageJsonPath)) + } + + return packageJson +} + +export default getPackageJson diff --git a/src/utils/get-repo-data.mjs b/src/utils/get-repo-data.mts similarity index 75% rename from src/utils/get-repo-data.mjs rename to src/utils/get-repo-data.mts index 217cef1186f..5d3d30c717c 100644 --- a/src/utils/get-repo-data.mjs +++ b/src/utils/get-repo-data.mts @@ -1,10 +1,12 @@ -// @ts-check + import { dirname } from 'path' import util from 'util' import { findUp } from 'find-up' import gitRepoInfo from 'git-repo-info' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'gitc... Remove this comment to see the full error message import gitconfiglocal from 'gitconfiglocal' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'pars... Remove this comment to see the full error message import parseGitRemote from 'parse-github-url' import { log } from './command-helpers.mjs' @@ -16,6 +18,7 @@ import { log } from './command-helpers.mjs' * @param {string} config.workingDir * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'remoteName' implicitly has an 'an... Remove this comment to see the full error message const getRepoData = async function ({ remoteName, workingDir }) { try { const [gitConfig, gitDirectory] = await Promise.all([ @@ -57,11 +60,13 @@ const getRepoData = async function ({ remoteName, workingDir }) { repo, url, branch, + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message provider: PROVIDERS[host] || host, httpsUrl: `https://${host}/${repo}`, } } catch (error) { return { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error: error.message, } } diff --git a/src/utils/get-site.mjs b/src/utils/get-site.mts similarity index 65% rename from src/utils/get-site.mjs rename to src/utils/get-site.mts index 970f2db0315..8b591e89836 100644 --- a/src/utils/get-site.mjs +++ b/src/utils/get-site.mts @@ -1,8 +1,10 @@ import { error } from './command-helpers.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'api' implicitly has an 'any' type. export const getSiteByName = async (api, siteName) => { try { const sites = await api.listSites({ name: siteName, filter: 'all' }) + // @ts-expect-error TS(7006) FIXME: Parameter 'filteredSite' implicitly has an 'any' t... Remove this comment to see the full error message const siteFoundByName = sites.find((filteredSite) => filteredSite.name === siteName) if (!siteFoundByName) { diff --git a/src/utils/gh-auth.mjs b/src/utils/gh-auth.mts similarity index 85% rename from src/utils/gh-auth.mjs rename to src/utils/gh-auth.mts index d65f7129f07..87770fd569c 100644 --- a/src/utils/gh-auth.mjs +++ b/src/utils/gh-auth.mts @@ -1,4 +1,4 @@ -// @ts-check + // A simple ghauth inspired library for getting a personal access token import http from 'http' import process from 'process' @@ -49,8 +49,10 @@ export const authWithNetlify = async () => { const { promise: deferredPromise, reject: deferredReject, resolve: deferredResolve } = createDeferred() const server = http.createServer(function onRequest(req, res) { + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. const parameters = new URLSearchParams(req.url.slice(req.url.indexOf('?') + 1)) if (parameters.get('token')) { + // @ts-expect-error TS(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message deferredResolve(Object.fromEntries(parameters)) res.end( `${ @@ -63,11 +65,13 @@ export const authWithNetlify = async () => { } res.end('BAD PARAMETERS') server.close() + // @ts-expect-error TS(2722) FIXME: Cannot invoke an object which is possibly 'undefin... Remove this comment to see the full error message deferredReject(new Error('Got invalid parameters for CLI login')) }) await new Promise(function waitForListening(resolve, reject) { server.on('error', reject) + // @ts-expect-error TS(2769) FIXME: No overload matches this call. server.listen(port, resolve) }) @@ -78,6 +82,7 @@ export const authWithNetlify = async () => { }) const url = `${webUI}/cli?${urlParams.toString()}` + // @ts-expect-error TS(2345) FIXME: Argument of type '{ url: string; }' is not assigna... Remove this comment to see the full error message await openBrowser({ url }) return deferredPromise @@ -107,6 +112,7 @@ const authWithToken = async () => { } const octokit = new Octokit({ auth: `token ${token}` }) + // @ts-expect-error TS(2339) FIXME: Property 'login' does not exist on type 'OctokitRe... Remove this comment to see the full error message const { login: user } = await octokit.users.getAuthenticated() return { token, user, provider: 'github' } diff --git a/src/utils/gitignore.mjs b/src/utils/gitignore.mts similarity index 76% rename from src/utils/gitignore.mjs rename to src/utils/gitignore.mts index e9bf7e4422a..1e464b669e9 100644 --- a/src/utils/gitignore.mjs +++ b/src/utils/gitignore.mts @@ -1,19 +1,22 @@ -// @ts-check + import { readFile, writeFile } from 'fs/promises' import path from 'path' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'pars... Remove this comment to see the full error message import parseIgnore from 'parse-gitignore' import { fileExistsAsync } from '../lib/fs.mjs' import { log } from './command-helpers.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'dir' implicitly has an 'any' type. const hasGitIgnore = async function (dir) { const gitIgnorePath = path.join(dir, '.gitignore') const hasIgnore = await fileExistsAsync(gitIgnorePath) return hasIgnore } +// @ts-expect-error TS(7006) FIXME: Parameter 'dir' implicitly has an 'any' type. export const ensureNetlifyIgnore = async function (dir) { const gitIgnorePath = path.join(dir, '.gitignore') const ignoreContent = '# Local Netlify folder\n.netlify\n' @@ -33,6 +36,7 @@ export const ensureNetlifyIgnore = async function (dir) { // ignore } /* Not ignoring .netlify folder. Add to .gitignore */ + // @ts-expect-error TS(7006) FIXME: Parameter 'pattern' implicitly has an 'any' type. if (!ignorePatterns || !ignorePatterns.patterns.some((pattern) => /(^|\/|\\)\.netlify($|\/|\\)/.test(pattern))) { log() log('Adding local .netlify folder to .gitignore file...') diff --git a/src/utils/headers.mjs b/src/utils/headers.mts similarity index 64% rename from src/utils/headers.mjs rename to src/utils/headers.mts index 65165e42f1f..afba1e21e05 100644 --- a/src/utils/headers.mjs +++ b/src/utils/headers.mts @@ -13,17 +13,21 @@ import { NETLIFYDEVERR, log } from './command-helpers.mjs' * * @returns {Object} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'headers' implicitly has an 'any' type. export const headersForPath = function (headers, path) { + // @ts-expect-error TS(7031) FIXME: Binding element 'forRegExp' implicitly has an 'any... Remove this comment to see the full error message const matchingHeaders = headers.filter(({ forRegExp }) => forRegExp.test(path)).map(getHeaderValues) const headersRules = Object.assign({}, ...matchingHeaders) return headersRules } +// @ts-expect-error TS(7031) FIXME: Binding element 'values' implicitly has an 'any' t... Remove this comment to see the full error message const getHeaderValues = function ({ values }) { return values } -export const parseHeaders = async function ({ configPath, headersFiles }) { +// @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message +export const parseHeaders = async function ({ configPath, headersFiles }): Promise { const { errors, headers } = await parseAllHeaders({ headersFiles, netlifyConfigPath: configPath, @@ -33,6 +37,7 @@ export const parseHeaders = async function ({ configPath, headersFiles }) { return headers } +// @ts-expect-error TS(7006) FIXME: Parameter 'errors' implicitly has an 'any' type. const handleHeadersErrors = function (errors) { if (errors.length === 0) { return @@ -42,6 +47,7 @@ const handleHeadersErrors = function (errors) { log(NETLIFYDEVERR, `Headers syntax errors:\n${errorMessage}`) } +// @ts-expect-error TS(7031) FIXME: Binding element 'message' implicitly has an 'any' ... Remove this comment to see the full error message const getErrorMessage = function ({ message }) { return message } diff --git a/src/utils/hooks/requires-site-info.mjs b/src/utils/hooks/requires-site-info.mts similarity index 70% rename from src/utils/hooks/requires-site-info.mjs rename to src/utils/hooks/requires-site-info.mts index c1d5cfcb1c2..26b94b99da6 100644 --- a/src/utils/hooks/requires-site-info.mjs +++ b/src/utils/hooks/requires-site-info.mts @@ -3,6 +3,7 @@ import { error, warn } from '../command-helpers.mjs' * A preAction hook that errors out if siteInfo is an empty object * @param {*} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. const requiresSiteInfo = async (command) => { const { api, site } = command.netlify const siteId = site.id @@ -14,14 +15,17 @@ const requiresSiteInfo = async (command) => { await api.getSite({ siteId }) } catch (error_) { // unauthorized + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 401) { warn(`Log in with a different account or re-link to a site you have permission for`) return error(`Not authorized to view the currently linked site (${siteId})`) } // missing + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error_.status === 404) { return error(`The site this folder is linked to can't be found`) } + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message return error(error_) } } diff --git a/src/utils/init/config-github.mjs b/src/utils/init/config-github.mts similarity index 76% rename from src/utils/init/config-github.mjs rename to src/utils/init/config-github.mts index 58e9e06bc37..b6033688bef 100644 --- a/src/utils/init/config-github.mjs +++ b/src/utils/init/config-github.mts @@ -1,4 +1,4 @@ -// @ts-check + import { Octokit } from '@octokit/rest' import { chalk, error as failAndExit, log } from '../command-helpers.mjs' @@ -14,6 +14,7 @@ import { createDeployKey, formatErrorMessage, getBuildSettings, saveNetlifyToml, * @property {string} provider - The Provider where the token is associated with ('github'). */ +// @ts-expect-error TS(7031) FIXME: Binding element 'repoName' implicitly has an 'any'... Remove this comment to see the full error message const formatRepoAndOwner = ({ repoName, repoOwner }) => ({ name: chalk.magenta(repoName), owner: chalk.magenta(repoOwner), @@ -25,6 +26,7 @@ const PAGE_SIZE = 100 * Get a valid GitHub token * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'globalConfig' implicitly has an '... Remove this comment to see the full error message export const getGitHubToken = async ({ globalConfig }) => { const userId = globalConfig.get('userId') @@ -46,6 +48,7 @@ export const getGitHubToken = async ({ globalConfig }) => { const newToken = await ghauth() globalConfig.set(`users.${userId}.auth.github`, newToken) + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. return newToken.token } @@ -54,11 +57,13 @@ export const getGitHubToken = async ({ globalConfig }) => { * @param {string} token * @returns {Octokit} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'token' implicitly has an 'any' type. const getGitHubClient = (token) => new Octokit({ auth: `token ${token}`, }) +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const addDeployKey = async ({ api, octokit, repoName, repoOwner }) => { log('Adding deploy key to repository...') const key = await createDeployKey({ api }) @@ -74,6 +79,7 @@ const addDeployKey = async ({ api, octokit, repoName, repoOwner }) => { return key } catch (error) { let message = formatErrorMessage({ message: 'Failed adding GitHub deploy key', error }) + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error.status === 404) { const { name, owner } = formatRepoAndOwner({ repoName, repoOwner }) message = `${message}. Does the repository ${name} exist and do ${owner} has the correct permissions to set up deploy keys?` @@ -82,6 +88,7 @@ const addDeployKey = async ({ api, octokit, repoName, repoOwner }) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'octokit' implicitly has an 'any' ... Remove this comment to see the full error message const getGitHubRepo = async ({ octokit, repoName, repoOwner }) => { try { const { data } = await octokit.repos.get({ @@ -91,6 +98,7 @@ const getGitHubRepo = async ({ octokit, repoName, repoOwner }) => { return data } catch (error) { let message = formatErrorMessage({ message: 'Failed retrieving GitHub repository information', error }) + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error.status === 404) { const { name, owner } = formatRepoAndOwner({ repoName, repoOwner }) message = `${message}. Does the repository ${name} exist and accessible by ${owner}` @@ -99,6 +107,7 @@ const getGitHubRepo = async ({ octokit, repoName, repoOwner }) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'deployHook' implicitly has an 'an... Remove this comment to see the full error message const hookExists = async ({ deployHook, octokit, repoName, repoOwner }) => { try { const { data: hooks } = await octokit.repos.listWebhooks({ @@ -106,6 +115,7 @@ const hookExists = async ({ deployHook, octokit, repoName, repoOwner }) => { repo: repoName, per_page: PAGE_SIZE, }) + // @ts-expect-error TS(7006) FIXME: Parameter 'hook' implicitly has an 'any' type. const exists = hooks.some((hook) => hook.config.url === deployHook) return exists } catch { @@ -114,6 +124,7 @@ const hookExists = async ({ deployHook, octokit, repoName, repoOwner }) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'deployHook' implicitly has an 'an... Remove this comment to see the full error message const addDeployHook = async ({ deployHook, octokit, repoName, repoOwner }) => { const exists = await hookExists({ deployHook, octokit, repoOwner, repoName }) if (!exists) { @@ -131,8 +142,10 @@ const addDeployHook = async ({ deployHook, octokit, repoName, repoOwner }) => { }) } catch (error) { // Ignore exists error if the list doesn't return all installed hooks + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (!error.message.includes('Hook already exists on this repository')) { let message = formatErrorMessage({ message: 'Failed creating repo hook', error }) + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error.status === 404) { const { name, owner } = formatRepoAndOwner({ repoName, repoOwner }) message = `${message}. Does the repository ${name} and do ${owner} has the correct permissions to set up hooks` @@ -146,7 +159,9 @@ const addDeployHook = async ({ deployHook, octokit, repoName, repoOwner }) => { const GITHUB_HOOK_EVENTS = ['deploy_created', 'deploy_failed', 'deploy_building'] const GITHUB_HOOK_TYPE = 'github_commit_status' +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const upsertHook = async ({ api, event, ntlHooks, siteId, token }) => { + // @ts-expect-error TS(7006) FIXME: Parameter 'hook' implicitly has an 'any' type. const ntlHook = ntlHooks.find((hook) => hook.type === GITHUB_HOOK_TYPE && hook.event === event) if (!ntlHook || ntlHook.disabled) { @@ -172,9 +187,11 @@ const upsertHook = async ({ api, event, ntlHooks, siteId, token }) => { }) } +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message const addNotificationHooks = async ({ api, siteId, token }) => { log(`Creating Netlify GitHub Notification Hooks...`) + // @ts-expect-error TS(7034) FIXME: Variable 'ntlHooks' implicitly has type 'any' in s... Remove this comment to see the full error message let ntlHooks try { ntlHooks = await api.listHooksBySiteId({ siteId }) @@ -185,6 +202,7 @@ const addNotificationHooks = async ({ api, siteId, token }) => { await Promise.all( GITHUB_HOOK_EVENTS.map(async (event) => { try { + // @ts-expect-error TS(7005) FIXME: Variable 'ntlHooks' implicitly has an 'any' type. await upsertHook({ ntlHooks, event, api, siteId, token }) } catch (error) { const message = formatErrorMessage({ message: `Failed settings Netlify hook ${chalk.magenta(event)}`, error }) @@ -203,6 +221,7 @@ const addNotificationHooks = async ({ api, siteId, token }) => { * @param {string} config.repoOwner * @param {string} config.siteId */ +// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message export const configGithub = async ({ command, repoName, repoOwner, siteId }) => { const { netlify } = command const { @@ -217,6 +236,7 @@ export const configGithub = async ({ command, repoName, repoOwner, siteId }) => const token = await getGitHubToken({ globalConfig }) const { baseDir, buildCmd, buildDir, functionsDir, pluginsToInstall } = await getBuildSettings({ + // @ts-expect-error TS(2345) FIXME: Argument of type '{ repositoryRoot: any; siteRoot:... Remove this comment to see the full error message repositoryRoot, siteRoot, config, diff --git a/src/utils/init/config-manual.mjs b/src/utils/init/config-manual.mts similarity index 81% rename from src/utils/init/config-manual.mjs rename to src/utils/init/config-manual.mts index fc962de9632..472dcf4c563 100644 --- a/src/utils/init/config-manual.mjs +++ b/src/utils/init/config-manual.mts @@ -1,4 +1,4 @@ -// @ts-check + import inquirer from 'inquirer' import { exit, log } from '../command-helpers.mjs' @@ -10,6 +10,7 @@ import { createDeployKey, getBuildSettings, saveNetlifyToml, setupSite } from '. * @param {object} deployKey * @param {string} deployKey.public_key */ +// @ts-expect-error TS(7006) FIXME: Parameter 'deployKey' implicitly has an 'any' type... Remove this comment to see the full error message const addDeployKey = async (deployKey) => { log('\nGive this Netlify SSH public key access to your repository:\n') log(`\n${deployKey.public_key}\n\n`) @@ -33,6 +34,7 @@ const addDeployKey = async (deployKey) => { * @param {Awaited>} config.repoData * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'repoData' implicitly has an 'any'... Remove this comment to see the full error message const getRepoPath = async ({ repoData }) => { const { repoPath } = await inquirer.prompt([ { @@ -54,6 +56,7 @@ const getRepoPath = async ({ repoData }) => { * @param {string} deployHook * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'deployHook' implicitly has an 'any' typ... Remove this comment to see the full error message const addDeployHook = async (deployHook) => { log('\nConfigure the following webhook for your repository:\n') log(`\n${deployHook}\n\n`) @@ -75,6 +78,7 @@ const addDeployHook = async (deployHook) => { * @param {Awaited>} config.repoData * @param {string} config.siteId */ +// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message export default async function configManual({ command, repoData, siteId }) { const { netlify } = command const { @@ -86,6 +90,7 @@ export default async function configManual({ command, repoData, siteId }) { } = netlify const { baseDir, buildCmd, buildDir, functionsDir, pluginsToInstall } = await getBuildSettings({ + // @ts-expect-error TS(2345) FIXME: Argument of type '{ repositoryRoot: any; siteRoot:... Remove this comment to see the full error message repositoryRoot, siteRoot, config, diff --git a/src/utils/init/config.mjs b/src/utils/init/config.mts similarity index 84% rename from src/utils/init/config.mjs rename to src/utils/init/config.mts index 5b02fde4c8d..5706a4db35d 100644 --- a/src/utils/init/config.mjs +++ b/src/utils/init/config.mts @@ -1,9 +1,10 @@ -// @ts-check + import { chalk, log } from '../command-helpers.mjs' import { configGithub } from './config-github.mjs' import configManual from './config-manual.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'repoData' implicitly has an 'any' type. const logSuccess = (repoData) => { log() log(chalk.greenBright.bold.underline(`Success! Netlify CI/CD Configured!`)) @@ -24,6 +25,7 @@ const logSuccess = (repoData) => { * @param {*} config.repoData * @param {string} config.siteId */ +// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message export const configureRepo = async ({ command, manual, repoData, siteId }) => { if (manual) { await configManual({ command, siteId, repoData }) diff --git a/src/utils/init/node-version.mjs b/src/utils/init/node-version.mts similarity index 78% rename from src/utils/init/node-version.mjs rename to src/utils/init/node-version.mts index f14172fb1e9..cf37701fb51 100644 --- a/src/utils/init/node-version.mjs +++ b/src/utils/init/node-version.mts @@ -1,4 +1,4 @@ -// @ts-check + import { readFile } from 'fs/promises' import { locatePath } from 'locate-path' @@ -10,9 +10,11 @@ const DEFAULT_NODE_VERSION = '12.18.0' const NVM_FLAG_PREFIX = '--' // to support NODE_VERSION=--lts, etc. +// @ts-expect-error TS(7006) FIXME: Parameter 'version' implicitly has an 'any' type. const normalizeConfiguredVersion = (version) => version.startsWith(NVM_FLAG_PREFIX) ? version.slice(NVM_FLAG_PREFIX.length) : version +// @ts-expect-error TS(7031) FIXME: Binding element 'baseDirectory' implicitly has an ... Remove this comment to see the full error message export const detectNodeVersion = async ({ baseDirectory, env }) => { try { const nodeVersionFile = await locatePath(['.nvmrc', '.node-version'], { cwd: baseDirectory }) @@ -26,6 +28,7 @@ export const detectNodeVersion = async ({ baseDirectory, env }) => { return version } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. warn(`Failed detecting Node.js version: ${error.message}`) return DEFAULT_NODE_VERSION } diff --git a/src/utils/init/plugins.mjs b/src/utils/init/plugins.mjs deleted file mode 100644 index 910434689dd..00000000000 --- a/src/utils/init/plugins.mjs +++ /dev/null @@ -1,8 +0,0 @@ -const isPluginInstalled = (configPlugins, plugin) => - configPlugins.some(({ package: configPlugin }) => configPlugin === plugin) - -export const getRecommendPlugins = (frameworkPlugins, config) => - frameworkPlugins.filter((plugin) => !isPluginInstalled(config.plugins, plugin)) - -export const getUIPlugins = (configPlugins) => - configPlugins.filter(({ origin }) => origin === 'ui').map(({ package: pkg }) => ({ package: pkg })) diff --git a/src/utils/init/plugins.mts b/src/utils/init/plugins.mts new file mode 100644 index 00000000000..17b0ce4cae3 --- /dev/null +++ b/src/utils/init/plugins.mts @@ -0,0 +1,14 @@ +// @ts-expect-error TS(7006) FIXME: Parameter 'configPlugins' implicitly has an 'any' ... Remove this comment to see the full error message +const isPluginInstalled = (configPlugins, plugin) => + // @ts-expect-error TS(7031) FIXME: Binding element 'configPlugin' implicitly has an '... Remove this comment to see the full error message + configPlugins.some(({ package: configPlugin }) => configPlugin === plugin) + +// @ts-expect-error TS(7006) FIXME: Parameter 'frameworkPlugins' implicitly has an 'an... Remove this comment to see the full error message +export const getRecommendPlugins = (frameworkPlugins, config) => + // @ts-expect-error TS(7006) FIXME: Parameter 'plugin' implicitly has an 'any' type. + frameworkPlugins.filter((plugin) => !isPluginInstalled(config.plugins, plugin)) + +// @ts-expect-error TS(7006) FIXME: Parameter 'configPlugins' implicitly has an 'any' ... Remove this comment to see the full error message +export const getUIPlugins = (configPlugins) => + // @ts-expect-error TS(7031) FIXME: Binding element 'origin' implicitly has an 'any' t... Remove this comment to see the full error message + configPlugins.filter(({ origin }) => origin === 'ui').map(({ package: pkg }) => ({ package: pkg })) diff --git a/src/utils/init/utils.mjs b/src/utils/init/utils.mts similarity index 76% rename from src/utils/init/utils.mjs rename to src/utils/init/utils.mts index a003515e2ca..65613bc2ba4 100644 --- a/src/utils/init/utils.mjs +++ b/src/utils/init/utils.mts @@ -1,4 +1,4 @@ -// @ts-check + import { writeFile } from 'fs/promises' import path from 'path' @@ -40,6 +40,7 @@ export const getPluginsToAutoInstall = (pluginsInstalled = [], pluginsRecommende * @param {*} config * @param {import('../../commands/base-command.mjs').default} command */ +// @ts-expect-error TS(7006) FIXME: Parameter 'settings' implicitly has an 'any' type. const normalizeSettings = (settings, config, command) => { const plugins = getPluginsToAutoInstall(settings.plugins_from_config_file, settings.plugins_recommended) const recommendedPlugins = getRecommendPlugins(plugins, config) @@ -61,6 +62,7 @@ const normalizeSettings = (settings, config, command) => { * @param {string=} param0.defaultBuildDir * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'defaultBaseDir' implicitly has an... Remove this comment to see the full error message const getPromptInputs = ({ defaultBaseDir, defaultBuildCmd, defaultBuildDir }) => { const inputs = [ defaultBaseDir !== undefined && @@ -74,6 +76,7 @@ const getPromptInputs = ({ defaultBaseDir, defaultBuildCmd, defaultBuildDir }) = type: 'input', name: 'buildCmd', message: 'Your build command (hugo build/yarn run build/etc):', + // @ts-expect-error TS(7006) FIXME: Parameter 'val' implicitly has an 'any' type. filter: (val) => (val === '' ? '# no build command' : val), default: defaultBuildCmd, }, @@ -93,6 +96,7 @@ const getPromptInputs = ({ defaultBaseDir, defaultBuildCmd, defaultBuildDir }) = * @param {*} param0.config * @param {import('../../commands/base-command.mjs').default} param0.command */ +// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message export const getBuildSettings = async ({ command, config }) => { const settings = await detectBuildSettings(command) // TODO: add prompt for asking to choose the build command @@ -115,6 +119,7 @@ export const getBuildSettings = async ({ command, config }) => { }), ) + // @ts-expect-error TS(7006) FIXME: Parameter 'plugin' implicitly has an 'any' type. const pluginsToInstall = recommendedPlugins.map((plugin) => ({ package: plugin })) const normalizedBaseDir = baseDir ? normalizeBackslash(baseDir) : undefined @@ -149,12 +154,19 @@ const getNetlifyToml = ({ ` export const saveNetlifyToml = async ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'baseDir' implicitly has an 'any' ... Remove this comment to see the full error message baseDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'buildCmd' implicitly has an 'any'... Remove this comment to see the full error message buildCmd, + // @ts-expect-error TS(7031) FIXME: Binding element 'buildDir' implicitly has an 'any'... Remove this comment to see the full error message buildDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message config, + // @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message configPath, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionsDir' implicitly has an '... Remove this comment to see the full error message functionsDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'repositoryRoot' implicitly has an... Remove this comment to see the full error message repositoryRoot, }) => { const tomlPathParts = [repositoryRoot, baseDir, 'netlify.toml'].filter(Boolean) @@ -166,6 +178,7 @@ export const saveNetlifyToml = async ({ // We don't want to create a `netlify.toml` file that overrides existing configuration // In a monorepo the configuration can come from a repo level netlify.toml // so we make sure it doesn't by checking `configPath === undefined` + // @ts-expect-error TS(2349) if (configPath === undefined && Object.keys(cleanDeep(config)).length !== 0) { return } @@ -186,11 +199,13 @@ export const saveNetlifyToml = async ({ 'utf-8', ) } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. warn(`Failed saving Netlify toml file: ${error.message}`) } } } +// @ts-expect-error TS(7031) FIXME: Binding element 'error' implicitly has an 'any' ty... Remove this comment to see the full error message export const formatErrorMessage = ({ error, message }) => { const errorMessage = error.json ? `${error.message} - ${JSON.stringify(error.json)}` : error.message return `${message} with error: ${chalk.red(errorMessage)}` @@ -199,8 +214,10 @@ export const formatErrorMessage = ({ error, message }) => { /** * @param {string} title */ +// @ts-expect-error TS(7006) FIXME: Parameter 'title' implicitly has an 'any' type. const formatTitle = (title) => chalk.cyan(title) +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message export const createDeployKey = async ({ api }) => { try { const deployKey = await api.createDeployKey() @@ -211,6 +228,7 @@ export const createDeployKey = async ({ api }) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message export const updateSite = async ({ api, options, siteId }) => { try { const updatedSite = await api.updateSite({ siteId, body: options }) @@ -221,6 +239,7 @@ export const updateSite = async ({ api, options, siteId }) => { } } +// @ts-expect-error TS(7031) FIXME: Binding element 'api' implicitly has an 'any' type... Remove this comment to see the full error message export const setupSite = async ({ api, configPlugins, pluginsToInstall, repo, siteId }) => { const updatedSite = await updateSite({ siteId, diff --git a/src/utils/live-tunnel.mjs b/src/utils/live-tunnel.mts similarity index 72% rename from src/utils/live-tunnel.mjs rename to src/utils/live-tunnel.mts index afd50413707..a01daf91c3d 100644 --- a/src/utils/live-tunnel.mjs +++ b/src/utils/live-tunnel.mts @@ -1,14 +1,17 @@ -// @ts-check + import process from 'process' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message import fetch from 'node-fetch' import pWaitFor from 'p-wait-for' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'uuid... Remove this comment to see the full error message import { v4 as uuidv4 } from 'uuid' import { fetchLatestVersion, shouldFetchLatestVersion } from '../lib/exec-fetcher.mjs' import { getPathInHome } from '../lib/settings.mjs' import { NETLIFYDEVERR, NETLIFYDEVLOG, chalk, log } from './command-helpers.mjs' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from './execa.mjs' const PACKAGE_NAME = 'live-tunnel-client' @@ -20,6 +23,7 @@ const TUNNEL_POLL_INTERVAL = 1e3 // 5 minutes const TUNNEL_POLL_TIMEOUT = 3e5 +// @ts-expect-error TS(7031) FIXME: Binding element 'netlifyApiToken' implicitly has a... Remove this comment to see the full error message const createTunnel = async function ({ netlifyApiToken, siteId, slug }) { await installTunnelClient() @@ -51,6 +55,7 @@ const createTunnel = async function ({ netlifyApiToken, siteId, slug }) { return data } +// @ts-expect-error TS(7031) FIXME: Binding element 'localPort' implicitly has an 'any... Remove this comment to see the full error message const connectTunnel = function ({ localPort, netlifyApiToken, session }) { const execPath = getPathInHome(['tunnel', 'bin', EXEC_NAME]) const args = ['connect', '-s', session.id, '-t', netlifyApiToken, '-l', localPort] @@ -59,7 +64,9 @@ const connectTunnel = function ({ localPort, netlifyApiToken, session }) { log(execPath, args) } + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. const ps = execa(execPath, args, { stdio: 'inherit' }) + // @ts-expect-error TS(7006) FIXME: Parameter 'code' implicitly has an 'any' type. ps.on('close', (code) => process.exit(code)) ps.on('SIGINT', process.exit) ps.on('SIGTERM', process.exit) @@ -67,6 +74,7 @@ const connectTunnel = function ({ localPort, netlifyApiToken, session }) { const installTunnelClient = async function () { const binPath = getPathInHome(['tunnel', 'bin']) + // @ts-expect-error TS(2345) FIXME: Argument of type '{ binPath: string; packageName: ... Remove this comment to see the full error message const shouldFetch = await shouldFetchLatestVersion({ binPath, packageName: PACKAGE_NAME, @@ -80,6 +88,7 @@ const installTunnelClient = async function () { log(`${NETLIFYDEVLOG} Installing Live Tunnel Client`) + // @ts-expect-error TS(2345) FIXME: Argument of type '{ packageName: string; execName:... Remove this comment to see the full error message await fetchLatestVersion({ packageName: PACKAGE_NAME, execName: EXEC_NAME, @@ -88,6 +97,7 @@ const installTunnelClient = async function () { }) } +// @ts-expect-error TS(7031) FIXME: Binding element 'localPort' implicitly has an 'any... Remove this comment to see the full error message export const startLiveTunnel = async ({ localPort, netlifyApiToken, siteId, slug }) => { const session = await createTunnel({ siteId, @@ -124,6 +134,7 @@ export const startLiveTunnel = async ({ localPort, netlifyApiToken, siteId, slug return session.session_url } +// @ts-expect-error TS(7006) FIXME: Parameter 'state' implicitly has an 'any' type. export const getLiveTunnelSlug = (state, override) => { if (override !== undefined) { return override @@ -140,6 +151,7 @@ export const getLiveTunnelSlug = (state, override) => { state.set(SLUG_LOCAL_STATE_KEY, newSlug) } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. log(`${NETLIFYDEVERR} Could not read or write local state file: ${error.message}`) } diff --git a/src/utils/lm/install.mjs b/src/utils/lm/install.mts similarity index 83% rename from src/utils/lm/install.mjs rename to src/utils/lm/install.mts index 2d218bc9342..932395212ea 100644 --- a/src/utils/lm/install.mjs +++ b/src/utils/lm/install.mts @@ -1,4 +1,4 @@ -// @ts-check + import { appendFile, copyFile, readFile, rm, writeFile } from 'fs/promises' import os from 'os' import path, { dirname } from 'path' @@ -6,6 +6,7 @@ import process from 'process' import { fileURLToPath } from 'url' import execa from 'execa' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'hasb... Remove this comment to see the full error message import hasbin from 'hasbin' import { Listr } from 'listr2' import pathKey from 'path-key' @@ -31,8 +32,10 @@ const SUPPORTED_PLATFORMS = { const dirPath = dirname(fileURLToPath(import.meta.url)) +// @ts-expect-error TS(7031) FIXME: Binding element 'skipInstall' implicitly has an 'a... Remove this comment to see the full error message const getSetupStep = ({ skipInstall }) => { const platform = os.platform() + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message const platformName = SUPPORTED_PLATFORMS[platform] if (platformName === undefined) { throw new Error(`Platform not supported: ${platform}. @@ -58,11 +61,13 @@ const setupGitConfigStep = { task: () => configureGitConfig(), } +// @ts-expect-error TS(7031) FIXME: Binding element 'force' implicitly has an 'any' ty... Remove this comment to see the full error message export const installPlatform = async function ({ force }) { const skipInstall = !force && (await installedWithPackageManager()) const steps = [ checkGitVersionStep, checkGitLFSVersionStep, + // @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. checkLFSFiltersStep(async (ctx, task, installed) => { if (!installed) { await execa('git', ['lfs', 'install']) @@ -94,6 +99,7 @@ const installHelper = async function () { // remove any old versions that might still exist in `~/.netlify/helper/bin` await rm(getLegacyBinPath(), { force: true, recursive: true }) const binPath = getBinPath() + // @ts-expect-error TS(2345) FIXME: Argument of type '{ binPath: string; packageName: ... Remove this comment to see the full error message const shouldFetch = await shouldFetchLatestVersion({ binPath, packageName: PACKAGE_NAME, @@ -105,6 +111,7 @@ const installHelper = async function () { return } + // @ts-expect-error TS(2345) FIXME: Argument of type '{ packageName: string; execName:... Remove this comment to see the full error message await fetchLatestVersion({ packageName: PACKAGE_NAME, execName: EXEC_NAME, @@ -116,6 +123,7 @@ const installHelper = async function () { export const isBinInPath = () => { const envPath = process.env[pathKey()] const binPath = getBinPath() + // @ts-expect-error TS(2532) FIXME: Object is possibly 'undefined'. return envPath.replace(/"+/g, '').split(path.delimiter).includes(binPath) } @@ -136,6 +144,7 @@ const CONTENT_COMMENT = ` # The next line updates PATH for Netlify's Git Credential Helper. ` +// @ts-expect-error TS(7006) FIXME: Parameter 'incFilePath' implicitly has an 'any' ty... Remove this comment to see the full error message const getInitContent = (incFilePath) => `${CONTENT_COMMENT}test -f '${incFilePath}' && source '${incFilePath}'` const setupUnixPath = async () => { @@ -157,6 +166,7 @@ Set the helper path in your environment PATH: ${getBinPath()}` ]) } +// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. const writeConfig = async function (name, initContent) { const configPath = path.join(os.homedir(), name) if (!(await fileExistsAsync(configPath))) { @@ -178,6 +188,7 @@ const getCurrentCredentials = async () => { return currentCredentials } catch (error) { // ignore error caused by not having any credential configured + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error.stdout !== '') { throw error } @@ -186,6 +197,7 @@ const getCurrentCredentials = async () => { } // Git expects the config path to always use / even on Windows +// @ts-expect-error TS(7006) FIXME: Parameter 'gitConfigPath' implicitly has an 'any' ... Remove this comment to see the full error message const getGitConfigContent = (gitConfigPath) => ` # This next lines include Netlify's Git Credential Helper configuration in your Git configuration. [include] @@ -260,6 +272,7 @@ export const getShellInfo = function () { return { shell, incFilePath: `${getHelperPath()}/path.${shell}.inc`, + // @ts-expect-error TS(2538) FIXME: Type 'undefined' cannot be used as an index type. configFile: CONFIG_FILES[shell], } } @@ -283,6 +296,7 @@ export const uninstall = async function () { ]) } +// @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. const removeConfig = async function (name, toRemove) { const configPath = path.join(os.homedir(), name) diff --git a/src/utils/lm/requirements.mjs b/src/utils/lm/requirements.mts similarity index 77% rename from src/utils/lm/requirements.mjs rename to src/utils/lm/requirements.mts index c9c15995ac2..b9e0068ab7b 100644 --- a/src/utils/lm/requirements.mjs +++ b/src/utils/lm/requirements.mts @@ -1,10 +1,12 @@ -// @ts-check + import semver from 'semver' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../execa.mjs' export const checkLFSFilters = async function () { try { + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. const { stdout } = await execa('git', ['config', '--get-regexp', 'filter.lfs']) return stdout.length !== 0 } catch { @@ -14,6 +16,7 @@ export const checkLFSFilters = async function () { const getHelperVersion = async function () { try { + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. const { stdout } = await execa('git-credential-netlify', ['version']) return stdout } catch { @@ -34,6 +37,7 @@ export const checkHelperVersion = async function () { export const checkGitVersion = async function () { try { + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. const { stdout } = await execa('git', ['--version']) return stdout.split(' ').pop() } catch { @@ -43,6 +47,7 @@ export const checkGitVersion = async function () { const getLFSVersion = async function () { try { + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. const { stdout } = await execa('git-lfs', ['version']) return stdout } catch { @@ -61,6 +66,7 @@ export const checkLFSVersion = async function () { ) } +// @ts-expect-error TS(7006) FIXME: Parameter 'out' implicitly has an 'any' type. const matchVersion = function (out, regex, version, message) { const match = out.match(regex) if (!match || match.length !== 2 || semver.lt(match[1], version)) { diff --git a/src/utils/lm/steps.mjs b/src/utils/lm/steps.mts similarity index 67% rename from src/utils/lm/steps.mjs rename to src/utils/lm/steps.mts index 07ee9814cc5..15c9ce564a4 100644 --- a/src/utils/lm/steps.mjs +++ b/src/utils/lm/steps.mts @@ -4,6 +4,7 @@ import { checkGitVersion, checkHelperVersion, checkLFSFilters, checkLFSVersion } export const checkGitVersionStep = { title: 'Checking Git version', + // @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. task: async (ctx, task) => { const version = await checkGitVersion() task.title += chalk.dim(` [${version}]`) @@ -12,14 +13,17 @@ export const checkGitVersionStep = { export const checkGitLFSVersionStep = { title: 'Checking Git LFS version', + // @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. task: async (ctx, task) => { const version = await checkLFSVersion() task.title += chalk.dim(` [${version}]`) }, } +// @ts-expect-error TS(7006) FIXME: Parameter 'onCheckDone' implicitly has an 'any' ty... Remove this comment to see the full error message export const checkLFSFiltersStep = (onCheckDone) => ({ title: 'Checking Git LFS filters', + // @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. task: async (ctx, task) => { const installed = await checkLFSFilters() return onCheckDone(ctx, task, installed) @@ -28,6 +32,7 @@ export const checkLFSFiltersStep = (onCheckDone) => ({ export const checkHelperVersionStep = { title: `Checking Netlify's Git Credentials version`, + // @ts-expect-error TS(7006) FIXME: Parameter 'ctx' implicitly has an 'any' type. task: async (ctx, task) => { const version = await checkHelperVersion() task.title += chalk.dim(` [${version}]`) diff --git a/src/utils/lm/ui.mjs b/src/utils/lm/ui.mts similarity index 88% rename from src/utils/lm/ui.mjs rename to src/utils/lm/ui.mts index 3009d0da559..b6050c7f061 100644 --- a/src/utils/lm/ui.mjs +++ b/src/utils/lm/ui.mts @@ -9,6 +9,7 @@ import { getShellInfo, isBinInPath } from './install.mjs' /** * @param {boolean} force */ +// @ts-expect-error TS(7006) FIXME: Parameter 'force' implicitly has an 'any' type. export const printBanner = function (force) { const print = force || !isBinInPath() const platform = os.platform() diff --git a/src/utils/open-browser.mjs b/src/utils/open-browser.mts similarity index 71% rename from src/utils/open-browser.mjs rename to src/utils/open-browser.mts index f6dc20a773c..f4245e0ac99 100644 --- a/src/utils/open-browser.mjs +++ b/src/utils/open-browser.mts @@ -1,10 +1,12 @@ import process from 'process' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'bett... Remove this comment to see the full error message import open from 'better-opn' import isDockerContainer from 'is-docker' import { chalk, log } from './command-helpers.mjs' +// @ts-expect-error TS(7031) FIXME: Binding element 'message' implicitly has an 'any' ... Remove this comment to see the full error message const unableToOpenBrowserMessage = function ({ message, url }) { log('---------------------------') log(chalk.redBright(`Error: Unable to open browser automatically: ${message}`)) @@ -20,6 +22,7 @@ const unableToOpenBrowserMessage = function ({ message, url }) { * @param {boolean} [config.silentBrowserNoneError] * @returns {Promise} */ +// @ts-expect-error TS(7031) FIXME: Binding element 'silentBrowserNoneError' implicitl... Remove this comment to see the full error message const openBrowser = async function ({ silentBrowserNoneError, url }) { if (isDockerContainer()) { unableToOpenBrowserMessage({ url, message: 'Running inside a docker container' }) @@ -35,6 +38,7 @@ const openBrowser = async function ({ silentBrowserNoneError, url }) { try { await open(url) } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. unableToOpenBrowserMessage({ url, message: error.message }) } } diff --git a/src/utils/parse-raw-flags.mjs b/src/utils/parse-raw-flags.mts similarity index 80% rename from src/utils/parse-raw-flags.mjs rename to src/utils/parse-raw-flags.mts index c2d36be1019..3adf4513f69 100644 --- a/src/utils/parse-raw-flags.mjs +++ b/src/utils/parse-raw-flags.mts @@ -10,7 +10,9 @@ // // rawFlags = {stuff: yay!} // +// @ts-expect-error TS(7006) FIXME: Parameter 'raw' implicitly has an 'any' type. export const parseRawFlags = function (raw) { + // @ts-expect-error TS(7006) FIXME: Parameter 'acc' implicitly has an 'any' type. const rawFlags = raw.reduce((acc, curr, index, array) => { if (/^-{1,2}/.test(curr)) { const key = curr.replace(/^-{1,2}/, '') @@ -28,6 +30,7 @@ export const parseRawFlags = function (raw) { return rawFlags } +// @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. export const aggressiveJSONParse = function (value) { if (value === 'true') { return true diff --git a/src/utils/proxy-server.mjs b/src/utils/proxy-server.mjs deleted file mode 100644 index deeadee62d0..00000000000 --- a/src/utils/proxy-server.mjs +++ /dev/null @@ -1,107 +0,0 @@ -// @ts-check -import { exit, log, NETLIFYDEVERR } from './command-helpers.mjs' -import { startProxy } from './proxy.mjs' - -/** - * @typedef {Object} InspectSettings - * @property {boolean} enabled - Inspect enabled - * @property {boolean} pause - Pause on breakpoints - * @property {string|undefined} address - Host/port override (optional) - */ - -/** - * @param {boolean|string} edgeInspect - * @param {boolean|string} edgeInspectBrk - * @returns {InspectSettings} - */ -export const generateInspectSettings = (edgeInspect, edgeInspectBrk) => { - const enabled = Boolean(edgeInspect) || Boolean(edgeInspectBrk) - const pause = Boolean(edgeInspectBrk) - const getAddress = () => { - if (edgeInspect) { - return typeof edgeInspect === 'string' ? edgeInspect : undefined - } - if (edgeInspectBrk) { - return typeof edgeInspectBrk === 'string' ? edgeInspectBrk : undefined - } - } - - return { - enabled, - pause, - address: getAddress(), - } -} - -/** - * - * @param {object} params - * @param {string=} params.accountId - * @param {*} params.addonsUrls - * @param {import("../lib/blobs/blobs.mjs").BlobsContext} blobsContext - * @param {import('../commands/types.js').NetlifyOptions["config"]} params.config - * @param {string} [params.configPath] An override for the Netlify config path - * @param {boolean} params.debug - * @param {import('../commands/types.js').NetlifyOptions["cachedConfig"]['env']} params.env - * @param {InspectSettings} params.inspectSettings - * @param {() => Promise} params.getUpdatedConfig - * @param {string} params.geolocationMode - * @param {string} params.geoCountry - * @param {*} params.settings - * @param {boolean} params.offline - * @param {object} params.site - * @param {*} params.siteInfo - * @param {string} params.projectDir - * @param {string} params.repositoryRoot - * @param {import('./state-config.mjs').default} params.state - * @param {import('../lib/functions/registry.mjs').FunctionsRegistry=} params.functionsRegistry - * @returns - */ -export const startProxyServer = async ({ - accountId, - addonsUrls, - blobsContext, - config, - configPath, - debug, - env, - functionsRegistry, - geoCountry, - geolocationMode, - getUpdatedConfig, - inspectSettings, - offline, - projectDir, - repositoryRoot, - settings, - site, - siteInfo, - state, -}) => { - const url = await startProxy({ - addonsUrls, - blobsContext, - config, - configPath: configPath || site.configPath, - debug, - env, - functionsRegistry, - geolocationMode, - geoCountry, - getUpdatedConfig, - inspectSettings, - offline, - projectDir, - settings, - state, - siteInfo, - accountId, - repositoryRoot, - }) - if (!url) { - log(NETLIFYDEVERR, `Unable to start proxy server on port '${settings.port}'`) - exit(1) - } - - return url -} diff --git a/src/utils/proxy-server.mts b/src/utils/proxy-server.mts new file mode 100644 index 00000000000..faf3e17f307 --- /dev/null +++ b/src/utils/proxy-server.mts @@ -0,0 +1,127 @@ + +import { exit, log, NETLIFYDEVERR } from './command-helpers.mjs' +import { startProxy } from './proxy.mjs' + +/** + * @typedef {Object} InspectSettings + * @property {boolean} enabled - Inspect enabled + * @property {boolean} pause - Pause on breakpoints + * @property {string|undefined} address - Host/port override (optional) + */ + +/** + * @param {boolean|string} edgeInspect + * @param {boolean|string} edgeInspectBrk + * @returns {InspectSettings} + */ +// @ts-expect-error TS(7006) FIXME: Parameter 'edgeInspect' implicitly has an 'any' ty... Remove this comment to see the full error message +export const generateInspectSettings = (edgeInspect, edgeInspectBrk) => { + const enabled = Boolean(edgeInspect) || Boolean(edgeInspectBrk) + const pause = Boolean(edgeInspectBrk) + const getAddress = () => { + if (edgeInspect) { + return typeof edgeInspect === 'string' ? edgeInspect : undefined + } + if (edgeInspectBrk) { + return typeof edgeInspectBrk === 'string' ? edgeInspectBrk : undefined + } + } + + return { + enabled, + pause, + address: getAddress(), + } +} + +/** + * + * @param {object} params + * @param {string=} params.accountId + * @param {*} params.addonsUrls + * @param {import("../lib/blobs/blobs.mjs").BlobsContext} blobsContext + * @param {import('../commands/types.js').NetlifyOptions["config"]} params.config + * @param {string} [params.configPath] An override for the Netlify config path + * @param {boolean} params.debug + * @param {import('../commands/types.js').NetlifyOptions["cachedConfig"]['env']} params.env + * @param {InspectSettings} params.inspectSettings + * @param {() => Promise} params.getUpdatedConfig + * @param {string} params.geolocationMode + * @param {string} params.geoCountry + * @param {*} params.settings + * @param {boolean} params.offline + * @param {object} params.site + * @param {*} params.siteInfo + * @param {string} params.projectDir + * @param {string} params.repositoryRoot + * @param {import('./state-config.mjs').default} params.state + * @param {import('../lib/functions/registry.mjs').FunctionsRegistry=} params.functionsRegistry + * @returns + */ +export const startProxyServer = async ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'accountId' implicitly has an 'any... Remove this comment to see the full error message + accountId, + // @ts-expect-error TS(7031) FIXME: Binding element 'addonsUrls' implicitly has an 'an... Remove this comment to see the full error message + addonsUrls, + // @ts-expect-error TS(7031) FIXME: Binding element 'blobsContext' implicitly has an '... Remove this comment to see the full error message + blobsContext, + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message + config, + // @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message + configPath, + // @ts-expect-error TS(7031) FIXME: Binding element 'debug' implicitly has an 'any' ty... Remove this comment to see the full error message + debug, + // @ts-expect-error TS(7031) FIXME: Binding element 'env' implicitly has an 'any' type... Remove this comment to see the full error message + env, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionsRegistry' implicitly has... Remove this comment to see the full error message + functionsRegistry, + // @ts-expect-error TS(7031) FIXME: Binding element 'geoCountry' implicitly has an 'an... Remove this comment to see the full error message + geoCountry, + // @ts-expect-error TS(7031) FIXME: Binding element 'geolocationMode' implicitly has a... Remove this comment to see the full error message + geolocationMode, + // @ts-expect-error TS(7031) FIXME: Binding element 'getUpdatedConfig' implicitly has ... Remove this comment to see the full error message + getUpdatedConfig, + // @ts-expect-error TS(7031) FIXME: Binding element 'inspectSettings' implicitly has a... Remove this comment to see the full error message + inspectSettings, + // @ts-expect-error TS(7031) FIXME: Binding element 'offline' implicitly has an 'any' ... Remove this comment to see the full error message + offline, + // @ts-expect-error TS(7031) FIXME: Binding element 'projectDir' implicitly has an 'an... Remove this comment to see the full error message + projectDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'repositoryRoot' implicitly has an... Remove this comment to see the full error message + repositoryRoot, + // @ts-expect-error TS(7031) FIXME: Binding element 'settings' implicitly has an 'any'... Remove this comment to see the full error message + settings, + // @ts-expect-error TS(7031) FIXME: Binding element 'site' implicitly has an 'any' typ... Remove this comment to see the full error message + site, + // @ts-expect-error TS(7031) FIXME: Binding element 'siteInfo' implicitly has an 'any'... Remove this comment to see the full error message + siteInfo, + // @ts-expect-error TS(7031) FIXME: Binding element 'state' implicitly has an 'any' ty... Remove this comment to see the full error message + state, +}) => { + const url = await startProxy({ + addonsUrls, + blobsContext, + config, + configPath: configPath || site.configPath, + debug, + env, + functionsRegistry, + geolocationMode, + geoCountry, + getUpdatedConfig, + inspectSettings, + offline, + projectDir, + settings, + state, + siteInfo, + accountId, + repositoryRoot, + }) + if (!url) { + log(NETLIFYDEVERR, `Unable to start proxy server on port '${settings.port}'`) + exit(1) + } + + return url +} diff --git a/src/utils/proxy.mjs b/src/utils/proxy.mts similarity index 66% rename from src/utils/proxy.mjs rename to src/utils/proxy.mts index 1813a51f542..d2c15394a30 100644 --- a/src/utils/proxy.mjs +++ b/src/utils/proxy.mts @@ -1,4 +1,4 @@ -// @ts-check + import { Buffer } from 'buffer' import { once } from 'events' import { readFile } from 'fs/promises' @@ -9,9 +9,12 @@ import path from 'path' import util from 'util' import zlib from 'zlib' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'cont... Remove this comment to see the full error message import contentType from 'content-type' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'cook... Remove this comment to see the full error message import cookie from 'cookie' import { getProperty } from 'dot-prop' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'etag... Remove this comment to see the full error message import generateETag from 'etag' import getAvailablePort from 'get-port' import httpProxy from 'http-proxy' @@ -48,6 +51,7 @@ const shouldGenerateETag = Symbol('Internal: response should generate ETag') * @param {string | undefined} contentEncoding * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'body' implicitly has an 'any' type. const decompressResponseBody = async function (body, contentEncoding = '') { switch (contentEncoding) { case 'gzip': @@ -61,6 +65,7 @@ const decompressResponseBody = async function (body, contentEncoding = '') { } } +// @ts-expect-error TS(7006) FIXME: Parameter 'errorBuffer' implicitly has an 'any' ty... Remove this comment to see the full error message const formatEdgeFunctionError = (errorBuffer, acceptsHtml) => { const { error: { message, name, stack }, @@ -80,6 +85,7 @@ const formatEdgeFunctionError = (errorBuffer, acceptsHtml) => { /** * @param {string} url */ +// @ts-expect-error TS(7006) FIXME: Parameter 'url' implicitly has an 'any' type. function isInternal(url) { return url.startsWith('/.netlify/') } @@ -88,6 +94,7 @@ function isInternal(url) { * @param {boolean|number|undefined} functionsPort * @param {string} url */ +// @ts-expect-error TS(7006) FIXME: Parameter 'functionsPort' implicitly has an 'any' ... Remove this comment to see the full error message function isFunction(functionsPort, url) { return functionsPort && url.match(DEFAULT_FUNCTION_URL_EXPRESSION) } @@ -96,6 +103,7 @@ function isFunction(functionsPort, url) { * @param {Record} addonsUrls * @param {http.IncomingMessage} req */ +// @ts-expect-error TS(7006) FIXME: Parameter 'addonsUrls' implicitly has an 'any' typ... Remove this comment to see the full error message function getAddonUrl(addonsUrls, req) { const matches = req.url?.match(/^\/.netlify\/([^/]+)(\/.*)/) const addonUrl = matches && addonsUrls[matches[1]] @@ -106,6 +114,7 @@ function getAddonUrl(addonsUrls, req) { * @param {string} pathname * @param {string} publicFolder */ +// @ts-expect-error TS(7006) FIXME: Parameter 'pathname' implicitly has an 'any' type. const getStatic = async function (pathname, publicFolder) { const alternatives = [pathname, ...alternativePathsFor(pathname)].map((filePath) => path.resolve(publicFolder, filePath.slice(1)), @@ -119,14 +128,17 @@ const getStatic = async function (pathname, publicFolder) { return `/${path.relative(publicFolder, file)}` } +// @ts-expect-error TS(7006) FIXME: Parameter 'match' implicitly has an 'any' type. const isExternal = function (match) { return match.to && match.to.match(/^https?:\/\//) } +// @ts-expect-error TS(7031) FIXME: Binding element 'hash' implicitly has an 'any' typ... Remove this comment to see the full error message const stripOrigin = function ({ hash, pathname, search }) { return `${pathname}${search}${hash}` } +// @ts-expect-error TS(7031) FIXME: Binding element 'dest' implicitly has an 'any' typ... Remove this comment to see the full error message const proxyToExternalUrl = function ({ dest, destURL, req, res }) { console.log(`${NETLIFYDEVLOG} Proxying to ${dest}`) const handler = createProxyMiddleware({ @@ -138,6 +150,7 @@ const proxyToExternalUrl = function ({ dest, destURL, req, res }) { return handler(req, res, () => {}) } +// @ts-expect-error TS(7031) FIXME: Binding element 'addonUrl' implicitly has an 'any'... Remove this comment to see the full error message const handleAddonUrl = function ({ addonUrl, req, res }) { const dest = new URL(addonUrl) const destURL = stripOrigin(dest) @@ -145,16 +158,19 @@ const handleAddonUrl = function ({ addonUrl, req, res }) { return proxyToExternalUrl({ req, res, dest, destURL }) } +// @ts-expect-error TS(7006) FIXME: Parameter 'match' implicitly has an 'any' type. const isRedirect = function (match) { return match.status && match.status >= 300 && match.status <= 400 } +// @ts-expect-error TS(7006) FIXME: Parameter 'publicFolder' implicitly has an 'any' t... Remove this comment to see the full error message const render404 = async function (publicFolder) { const maybe404Page = path.resolve(publicFolder, '404.html') try { const isFile = await isFileAsync(maybe404Page) if (isFile) return await readFile(maybe404Page, 'utf-8') } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. console.warn(NETLIFYDEVWARN, 'Error while serving 404.html file', error.message) } @@ -164,6 +180,7 @@ const render404 = async function (publicFolder) { // Used as an optimization to avoid dual lookups for missing assets const assetExtensionRegExp = /\.(html?|png|jpg|js|css|svg|gif|ico|woff|woff2)$/ +// @ts-expect-error TS(7006) FIXME: Parameter 'url' implicitly has an 'any' type. const alternativePathsFor = function (url) { if (isFunction(true, url)) { return [] @@ -184,14 +201,23 @@ const alternativePathsFor = function (url) { } const serveRedirect = async function ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'env' implicitly has an 'any' type... Remove this comment to see the full error message env, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionsRegistry' implicitly has... Remove this comment to see the full error message functionsRegistry, + // @ts-expect-error TS(7031) FIXME: Binding element 'imageProxy' implicitly has an 'an... Remove this comment to see the full error message imageProxy, + // @ts-expect-error TS(7031) FIXME: Binding element 'match' implicitly has an 'any' ty... Remove this comment to see the full error message match, + // @ts-expect-error TS(7031) FIXME: Binding element 'options' implicitly has an 'any' ... Remove this comment to see the full error message options, + // @ts-expect-error TS(7031) FIXME: Binding element 'proxy' implicitly has an 'any' ty... Remove this comment to see the full error message proxy, + // @ts-expect-error TS(7031) FIXME: Binding element 'req' implicitly has an 'any' type... Remove this comment to see the full error message req, + // @ts-expect-error TS(7031) FIXME: Binding element 'res' implicitly has an 'any' type... Remove this comment to see the full error message res, + // @ts-expect-error TS(7031) FIXME: Binding element 'siteInfo' implicitly has an 'any'... Remove this comment to see the full error message siteInfo, }) { if (!match) return proxy.web(req, res, options) @@ -236,6 +262,7 @@ const serveRedirect = async function ({ if (match.exceptions && match.exceptions.JWT) { // Some values of JWT can start with :, so, make sure to normalize them const expectedRoles = new Set( + // @ts-expect-error TS(7006) FIXME: Parameter 'value' implicitly has an 'any' type. match.exceptions.JWT.split(',').map((value) => (value.startsWith(':') ? value.slice(1) : value)), ) @@ -248,14 +275,17 @@ const serveRedirect = async function ({ if (token) { let jwtValue = {} try { + // @ts-expect-error TS(2349) This expression is not callable jwtValue = jwtDecode(token) || {} } catch (error) { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. console.warn(NETLIFYDEVWARN, 'Error while decoding JWT provided in request', error.message) res.writeHead(400) res.end('Invalid JWT provided. Please see logs for more info.') return } + // @ts-expect-error TS(2339) FIXME: Property 'exp' does not exist on type '{}'. if ((jwtValue.exp || 0) < Math.round(Date.now() / MILLISEC_TO_SEC)) { console.warn(NETLIFYDEVWARN, 'Expired JWT provided in request', req.url) } else { @@ -380,6 +410,7 @@ const serveRedirect = async function ({ return proxy.web(req, res, options) } +// @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. const reqToURL = function (req, pathname) { return new URL( pathname, @@ -391,6 +422,7 @@ const reqToURL = function (req, pathname) { const MILLISEC_TO_SEC = 1e3 +// @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message const initializeProxy = async function ({ configPath, distDir, env, host, imageProxy, port, projectDir, siteInfo }) { const proxy = httpProxy.createProxyServer({ selfHandleResponse: true, @@ -413,6 +445,7 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP headers = await parseHeaders({ headersFiles, configPath }) }) + // @ts-expect-error TS(2339) FIXME: Property 'before' does not exist on type 'Server'. proxy.before('web', 'stream', (req) => { // See https://github.com/http-party/node-http-proxy/issues/1219#issuecomment-511110375 if (req.headers.expect) { @@ -422,6 +455,7 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP }) proxy.on('error', (_, req, res) => { + // @ts-expect-error TS(2339) FIXME: Property 'writeHead' does not exist on type 'Socke... Remove this comment to see the full error message res.writeHead(500, { 'Content-Type': 'text/plain', }) @@ -442,10 +476,14 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP handleProxyRequest(req, proxyReq) } + // @ts-expect-error TS(2339) FIXME: Property '__expectHeader' does not exist on type '... Remove this comment to see the full error message if (req.__expectHeader) { + // @ts-expect-error TS(2339) FIXME: Property '__expectHeader' does not exist on type '... Remove this comment to see the full error message proxyReq.setHeader('Expect', req.__expectHeader) } + // @ts-expect-error TS(2339) FIXME: Property 'originalBody' does not exist on type 'In... Remove this comment to see the full error message if (req.originalBody) { + // @ts-expect-error TS(2339) FIXME: Property 'originalBody' does not exist on type 'In... Remove this comment to see the full error message proxyReq.write(req.originalBody) } }) @@ -461,14 +499,18 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP if (proxyRes.statusCode === 404 || proxyRes.statusCode === 403) { // If a request for `/path` has failed, we'll a few variations like // `/path/index.html` to mimic the CDN behavior. + // @ts-expect-error TS(2339) FIXME: Property 'alternativePaths' does not exist on type... Remove this comment to see the full error message if (req.alternativePaths && req.alternativePaths.length !== 0) { + // @ts-expect-error TS(2339) FIXME: Property 'alternativePaths' does not exist on type... Remove this comment to see the full error message req.url = req.alternativePaths.shift() + // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message return proxy.web(req, res, req.proxyOptions) } // The request has failed but we might still have a matching redirect // rule (without `force`) that should kick in. This is how we mimic the // file shadowing behavior from the CDN. + // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message if (req.proxyOptions && req.proxyOptions.match) { return serveRedirect({ // We don't want to match functions at this point because any redirects @@ -479,7 +521,9 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP res, proxy: handlers, imageProxy, + // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message match: req.proxyOptions.match, + // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message options: req.proxyOptions, siteInfo, env, @@ -487,6 +531,7 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP } } + // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message if (req.proxyOptions.staticFile && isRedirect({ status: proxyRes.statusCode }) && proxyRes.headers.location) { req.url = proxyRes.headers.location return serveRedirect({ @@ -499,13 +544,16 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP proxy: handlers, imageProxy, match: null, + // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message options: req.proxyOptions, siteInfo, env, }) } + // @ts-expect-error TS(7034) FIXME: Variable 'responseData' implicitly has type 'any[]... Remove this comment to see the full error message const responseData = [] + // @ts-expect-error TS(2345) FIXME: Argument of type 'string | undefined' is not assig... Remove this comment to see the full error message const requestURL = new URL(req.url, `http://${req.headers.host || '127.0.0.1'}`) const headersRules = headersForPath(headers, requestURL.pathname) @@ -514,8 +562,10 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP const isStreamedResponse = proxyRes.headers['content-length'] === undefined if (isStreamedResponse) { Object.entries(headersRules).forEach(([key, val]) => { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message res.setHeader(key, val) }) + // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message res.writeHead(req.proxyOptions.status || proxyRes.statusCode, proxyRes.headers) proxyRes.on('data', function onData(data) { @@ -534,14 +584,18 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP }) proxyRes.on('end', async function onEnd() { + // @ts-expect-error TS(7005) FIXME: Variable 'responseData' implicitly has an 'any[]' ... Remove this comment to see the full error message const responseBody = Buffer.concat(responseData) + // @ts-expect-error TS(2339) FIXME: Property 'proxyOptions' does not exist on type 'In... Remove this comment to see the full error message let responseStatus = req.proxyOptions.status || proxyRes.statusCode // `req[shouldGenerateETag]` may contain a function that determines // whether the response should have an ETag header. if ( + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message typeof req[shouldGenerateETag] === 'function' && + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message req[shouldGenerateETag]({ statusCode: responseStatus }) === true ) { const etag = generateETag(responseBody, { weak: true }) @@ -554,6 +608,7 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP } Object.entries(headersRules).forEach(([key, val]) => { + // @ts-expect-error TS(2345) FIXME: Argument of type 'unknown' is not assignable to pa... Remove this comment to see the full error message res.setHeader(key, val) }) @@ -585,6 +640,7 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP }) const handlers = { + // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. web: (req, res, options) => { const requestURL = new URL(req.url, 'http://127.0.0.1') req.proxyOptions = options @@ -593,6 +649,7 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP req.headers['x-forwarded-for'] = req.connection.remoteAddress || '' return proxy.web(req, res, options) }, + // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. ws: (req, socket, head) => proxy.ws(req, socket, head), } @@ -601,18 +658,30 @@ const initializeProxy = async function ({ configPath, distDir, env, host, imageP const onRequest = async ( { + // @ts-expect-error TS(7031) FIXME: Binding element 'addonsUrls' implicitly has an 'an... Remove this comment to see the full error message addonsUrls, + // @ts-expect-error TS(7031) FIXME: Binding element 'edgeFunctionsProxy' implicitly ha... Remove this comment to see the full error message edgeFunctionsProxy, + // @ts-expect-error TS(7031) FIXME: Binding element 'env' implicitly has an 'any' type... Remove this comment to see the full error message env, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionsRegistry' implicitly has... Remove this comment to see the full error message functionsRegistry, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionsServer' implicitly has a... Remove this comment to see the full error message functionsServer, + // @ts-expect-error TS(7031) FIXME: Binding element 'imageProxy' implicitly has an 'an... Remove this comment to see the full error message imageProxy, + // @ts-expect-error TS(7031) FIXME: Binding element 'proxy' implicitly has an 'any' ty... Remove this comment to see the full error message proxy, + // @ts-expect-error TS(7031) FIXME: Binding element 'rewriter' implicitly has an 'any'... Remove this comment to see the full error message rewriter, + // @ts-expect-error TS(7031) FIXME: Binding element 'settings' implicitly has an 'any'... Remove this comment to see the full error message settings, + // @ts-expect-error TS(7031) FIXME: Binding element 'siteInfo' implicitly has an 'any'... Remove this comment to see the full error message siteInfo, }, + // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. req, + // @ts-expect-error TS(7006) FIXME: Parameter 'res' implicitly has an 'any' type. res, ) => { req.originalBody = ['GET', 'OPTIONS', 'HEAD'].includes(req.method) @@ -634,10 +703,12 @@ const onRequest = async ( const headers = {} if (functionMatch.func) { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message headers[NFFunctionName] = functionMatch.func.name } if (functionMatch.route) { + // @ts-expect-error TS(7053) FIXME: Element implicitly has an 'any' type because expre... Remove this comment to see the full error message headers[NFFunctionRoute] = functionMatch.route.pattern } @@ -665,6 +736,7 @@ const onRequest = async ( if (match) { // We don't want to generate an ETag for 3xx redirects. + // @ts-expect-error TS(7031) FIXME: Binding element 'statusCode' implicitly has an 'an... Remove this comment to see the full error message req[shouldGenerateETag] = ({ statusCode }) => statusCode < 300 || statusCode >= 400 return serveRedirect({ req, res, proxy, imageProxy, match, options, siteInfo, env, functionsRegistry }) @@ -673,6 +745,7 @@ const onRequest = async ( // The request will be served by the framework server, which means we want to // generate an ETag unless we're rendering an error page. The only way for // us to know that is by looking at the status code + // @ts-expect-error TS(7031) FIXME: Binding element 'statusCode' implicitly has an 'an... Remove this comment to see the full error message req[shouldGenerateETag] = ({ statusCode }) => statusCode >= 200 && statusCode < 300 const ct = req.headers['content-type'] ? contentType.parse(req).type : '' @@ -696,29 +769,48 @@ const onRequest = async ( * @param {Pick} settings * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'settings' implicitly has an 'any' type. export const getProxyUrl = function (settings) { const scheme = settings.https ? 'https' : 'http' return `${scheme}://localhost:${settings.port}` } export const startProxy = async function ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'accountId' implicitly has an 'any... Remove this comment to see the full error message accountId, + // @ts-expect-error TS(7031) FIXME: Binding element 'addonsUrls' implicitly has an 'an... Remove this comment to see the full error message addonsUrls, + // @ts-expect-error TS(7031) FIXME: Binding element 'blobsContext' implicitly has an '... Remove this comment to see the full error message blobsContext, + // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message config, + // @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message configPath, + // @ts-expect-error TS(7031) FIXME: Binding element 'debug' implicitly has an 'any' ty... Remove this comment to see the full error message debug, + // @ts-expect-error TS(7031) FIXME: Binding element 'env' implicitly has an 'any' type... Remove this comment to see the full error message env, + // @ts-expect-error TS(7031) FIXME: Binding element 'functionsRegistry' implicitly has... Remove this comment to see the full error message functionsRegistry, + // @ts-expect-error TS(7031) FIXME: Binding element 'geoCountry' implicitly has an 'an... Remove this comment to see the full error message geoCountry, + // @ts-expect-error TS(7031) FIXME: Binding element 'geolocationMode' implicitly has a... Remove this comment to see the full error message geolocationMode, + // @ts-expect-error TS(7031) FIXME: Binding element 'getUpdatedConfig' implicitly has ... Remove this comment to see the full error message getUpdatedConfig, + // @ts-expect-error TS(7031) FIXME: Binding element 'inspectSettings' implicitly has a... Remove this comment to see the full error message inspectSettings, + // @ts-expect-error TS(7031) FIXME: Binding element 'offline' implicitly has an 'any' ... Remove this comment to see the full error message offline, + // @ts-expect-error TS(7031) FIXME: Binding element 'projectDir' implicitly has an 'an... Remove this comment to see the full error message projectDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'repositoryRoot' implicitly has an... Remove this comment to see the full error message repositoryRoot, + // @ts-expect-error TS(7031) FIXME: Binding element 'settings' implicitly has an 'any'... Remove this comment to see the full error message settings, + // @ts-expect-error TS(7031) FIXME: Binding element 'siteInfo' implicitly has an 'any'... Remove this comment to see the full error message siteInfo, + // @ts-expect-error TS(7031) FIXME: Binding element 'state' implicitly has an 'any' ty... Remove this comment to see the full error message state, }) { const secondaryServerPort = settings.https ? await getAvailablePort() : null @@ -782,6 +874,7 @@ export const startProxy = async function ({ const primaryServer = settings.https ? https.createServer({ cert: settings.https.cert, key: settings.https.key }, onRequestWithOptions) : http.createServer(onRequestWithOptions) + // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. const onUpgrade = function onUpgrade(req, socket, head) { proxy.ws(req, socket, head) } diff --git a/src/utils/read-repo-url.mjs b/src/utils/read-repo-url.mts similarity index 81% rename from src/utils/read-repo-url.mjs rename to src/utils/read-repo-url.mts index faf8c6881f4..978b668c133 100644 --- a/src/utils/read-repo-url.mjs +++ b/src/utils/read-repo-url.mts @@ -1,6 +1,7 @@ -// @ts-check + import url from 'url' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message import fetch from 'node-fetch' // supported repo host types @@ -11,6 +12,7 @@ const GITHUB = 'GitHub' * Takes a url like https://github.com/netlify-labs/all-the-functions/tree/master/functions/9-using-middleware * and returns https://api.github.com/repos/netlify-labs/all-the-functions/contents/functions/9-using-middleware */ +// @ts-expect-error TS(7006) FIXME: Parameter '_url' implicitly has an 'any' type. export const readRepoURL = async function (_url) { // TODO: use `url.URL()` instead // eslint-disable-next-line n/no-deprecated-api @@ -22,6 +24,7 @@ export const readRepoURL = async function (_url) { return folderContents } +// @ts-expect-error TS(7006) FIXME: Parameter 'repoHost' implicitly has an 'any' type. const getRepoURLContents = async function (repoHost, ownerAndRepo, contentsPath) { // naive joining strategy for now if (repoHost === GITHUB) { @@ -40,6 +43,7 @@ const getRepoURLContents = async function (repoHost, ownerAndRepo, contentsPath) /** * @param {string} _url */ +// @ts-expect-error TS(7006) FIXME: Parameter '_url' implicitly has an 'any' type. export const validateRepoURL = function (_url) { // TODO: use `url.URL()` instead // eslint-disable-next-line n/no-deprecated-api @@ -49,6 +53,7 @@ export const validateRepoURL = function (_url) { return GITHUB } +// @ts-expect-error TS(7006) FIXME: Parameter 'repoHost' implicitly has an 'any' type. export const parseRepoURL = function (repoHost, URL) { // naive splitting strategy for now if (repoHost === GITHUB) { diff --git a/src/utils/redirects.mjs b/src/utils/redirects.mts similarity index 54% rename from src/utils/redirects.mjs rename to src/utils/redirects.mts index 789c746ef40..55bbd1a9492 100644 --- a/src/utils/redirects.mjs +++ b/src/utils/redirects.mts @@ -1,20 +1,24 @@ -// @ts-check + import { parseAllRedirects } from 'netlify-redirect-parser' import { NETLIFYDEVERR, log } from './command-helpers.mjs' // Parse, normalize and validate all redirects from `_redirects` files // and `netlify.toml` +// @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message export const parseRedirects = async function ({ configPath, redirectsFiles }) { + // @ts-expect-error TS(2345) FIXME: Argument of type '{ redirectsFiles: any; netlifyCo... Remove this comment to see the full error message const { errors, redirects } = await parseAllRedirects({ redirectsFiles, netlifyConfigPath: configPath, minimal: false, }) handleRedirectParsingErrors(errors) + // @ts-expect-error TS(2345) FIXME: Argument of type '({ conditions: { country, langua... Remove this comment to see the full error message return redirects.map(normalizeRedirect) } +// @ts-expect-error TS(7006) FIXME: Parameter 'errors' implicitly has an 'any' type. const handleRedirectParsingErrors = function (errors) { if (errors.length === 0) { return @@ -24,6 +28,7 @@ const handleRedirectParsingErrors = function (errors) { log(NETLIFYDEVERR, `Redirects syntax errors:\n${errorMessage}`) } +// @ts-expect-error TS(7031) FIXME: Binding element 'message' implicitly has an 'any' ... Remove this comment to see the full error message const getErrorMessage = function ({ message }) { return message } @@ -33,9 +38,13 @@ const getErrorMessage = function ({ message }) { // - `query` is called `params` // - `conditions.role|country|language` are capitalized const normalizeRedirect = function ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'country' implicitly has an 'any' ... Remove this comment to see the full error message conditions: { country, language, role, ...conditions }, + // @ts-expect-error TS(7031) FIXME: Binding element 'from' implicitly has an 'any' typ... Remove this comment to see the full error message from, + // @ts-expect-error TS(7031) FIXME: Binding element 'query' implicitly has an 'any' ty... Remove this comment to see the full error message query, + // @ts-expect-error TS(7031) FIXME: Binding element 'signed' implicitly has an 'any' t... Remove this comment to see the full error message signed, ...redirect }) { diff --git a/src/utils/request-id.mjs b/src/utils/request-id.mts similarity index 85% rename from src/utils/request-id.mjs rename to src/utils/request-id.mts index 16c17ad73de..012548db063 100644 --- a/src/utils/request-id.mjs +++ b/src/utils/request-id.mts @@ -1,4 +1,4 @@ -// @ts-check + import { ulid } from 'ulid' export const generateRequestID = () => ulid() diff --git a/src/utils/rules-proxy.mjs b/src/utils/rules-proxy.mts similarity index 58% rename from src/utils/rules-proxy.mjs rename to src/utils/rules-proxy.mts index 7752f6eaaf5..cad17c4cafe 100644 --- a/src/utils/rules-proxy.mjs +++ b/src/utils/rules-proxy.mts @@ -1,8 +1,10 @@ -// @ts-check + import path from 'path' import chokidar from 'chokidar' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'cook... Remove this comment to see the full error message import cookie from 'cookie' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'netl... Remove this comment to see the full error message import redirector from 'netlify-redirector' import pFilter from 'p-filter' @@ -11,9 +13,12 @@ import { fileExistsAsync } from '../lib/fs.mjs' import { NETLIFYDEVLOG } from './command-helpers.mjs' import { parseRedirects } from './redirects.mjs' +// @ts-expect-error TS(7034) FIXME: Variable 'watchers' implicitly has type 'any[]' in... Remove this comment to see the full error message const watchers = [] +// @ts-expect-error TS(7006) FIXME: Parameter 'files' implicitly has an 'any' type. export const onChanges = function (files, listener) { + // @ts-expect-error TS(7006) FIXME: Parameter 'file' implicitly has an 'any' type. files.forEach((file) => { const watcher = chokidar.watch(file) watcher.on('change', listener) @@ -23,9 +28,11 @@ export const onChanges = function (files, listener) { } export const getWatchers = function () { + // @ts-expect-error TS(7005) FIXME: Variable 'watchers' implicitly has an 'any[]' type... Remove this comment to see the full error message return watchers } +// @ts-expect-error TS(7006) FIXME: Parameter 'headers' implicitly has an 'any' type. export const getLanguage = function (headers) { if (headers['accept-language']) { return headers['accept-language'].split(',')[0].slice(0, 2) @@ -34,13 +41,20 @@ export const getLanguage = function (headers) { } export const createRewriter = async function ({ + // @ts-expect-error TS(7031) FIXME: Binding element 'configPath' implicitly has an 'an... Remove this comment to see the full error message configPath, + // @ts-expect-error TS(7031) FIXME: Binding element 'distDir' implicitly has an 'any' ... Remove this comment to see the full error message distDir, + // @ts-expect-error TS(7031) FIXME: Binding element 'geoCountry' implicitly has an 'an... Remove this comment to see the full error message geoCountry, + // @ts-expect-error TS(7031) FIXME: Binding element 'jwtRoleClaim' implicitly has an '... Remove this comment to see the full error message jwtRoleClaim, + // @ts-expect-error TS(7031) FIXME: Binding element 'jwtSecret' implicitly has an 'any... Remove this comment to see the full error message jwtSecret, + // @ts-expect-error TS(7031) FIXME: Binding element 'projectDir' implicitly has an 'an... Remove this comment to see the full error message projectDir, }) { + // @ts-expect-error TS(7034) FIXME: Variable 'matcher' implicitly has type 'any' in so... Remove this comment to see the full error message let matcher = null const redirectsFiles = [...new Set([path.resolve(distDir, '_redirects'), path.resolve(projectDir, '_redirects')])] let redirects = await parseRedirects({ redirectsFiles, configPath }) @@ -57,6 +71,7 @@ export const createRewriter = async function ({ }) const getMatcher = async () => { + // @ts-expect-error TS(7005) FIXME: Variable 'matcher' implicitly has an 'any' type. if (matcher) return matcher if (redirects.length !== 0) { @@ -72,6 +87,7 @@ export const createRewriter = async function ({ } } + // @ts-expect-error TS(7006) FIXME: Parameter 'req' implicitly has an 'any' type. return async function rewriter(req) { const matcherFunc = await getMatcher() const reqUrl = new URL( @@ -95,7 +111,9 @@ export const createRewriter = async function ({ query: reqUrl.search.slice(1), headers, cookieValues, + // @ts-expect-error TS(7006) FIXME: Parameter 'name' implicitly has an 'any' type. getHeader: (name) => headers[name.toLowerCase()] || '', + // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. getCookie: (key) => cookieValues[key] || '', } const match = matcherFunc.match(matchReq) diff --git a/src/utils/run-build.mjs b/src/utils/run-build.mts similarity index 87% rename from src/utils/run-build.mjs rename to src/utils/run-build.mts index e1f6f8ce6bd..b4222558f24 100644 --- a/src/utils/run-build.mjs +++ b/src/utils/run-build.mts @@ -1,4 +1,4 @@ -// @ts-check + import { promises as fs } from 'fs' import path, { join } from 'path' @@ -18,6 +18,7 @@ const netlifyBuildPromise = import('@netlify/build') * @param {string} configPath * @param {string} destinationFolder The folder where it should be copied to. Either the root of the repo or a package inside a monorepo */ +// @ts-expect-error TS(7006) FIXME: Parameter 'configPath' implicitly has an 'any' typ... Remove this comment to see the full error message const copyConfig = async (configPath, destinationFolder) => { const newConfigPath = path.resolve(destinationFolder, getPathInProject(['netlify.toml'])) @@ -33,6 +34,7 @@ const copyConfig = async (configPath, destinationFolder) => { /** * @param {string} basePath */ +// @ts-expect-error TS(7006) FIXME: Parameter 'basePath' implicitly has an 'any' type. const cleanInternalDirectory = async (basePath) => { const ops = [INTERNAL_FUNCTIONS_FOLDER, INTERNAL_EDGE_FUNCTIONS_FOLDER, 'netlify.toml'].map((name) => { const fullPath = path.resolve(basePath, getPathInProject([name])) @@ -53,6 +55,7 @@ const cleanInternalDirectory = async (basePath) => { * @param {'build' | 'dev'} [params.timeline] * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message export const runNetlifyBuild = async ({ command, env = {}, options, settings, timeline = 'build' }) => { const { cachedConfig, site } = command.netlify @@ -110,6 +113,7 @@ export const runNetlifyBuild = async ({ command, env = {}, options, settings, ti } // Run Netlify Build using the main entry point. + // @ts-expect-error TS(2345) FIXME: Argument of type '{ outputConfigPath: string; save... Remove this comment to see the full error message const { netlifyConfig, success } = await buildSite(buildSiteOptions) if (!success) { @@ -123,6 +127,7 @@ export const runNetlifyBuild = async ({ command, env = {}, options, settings, ti const settingsOverrides = { command: undefined, useStaticServer: true, + dist: undefined, } if (!options.dir && netlifyConfig?.build?.publish) { settingsOverrides.dist = netlifyConfig.build.publish @@ -154,9 +159,11 @@ export const runNetlifyBuild = async ({ command, env = {}, options, settings, ti /** * @param {Omit[0], 'timeline'>} options */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const runDevTimeline = (options) => runNetlifyBuild({ ...options, timeline: 'dev' }) /** * @param {Omit[0], 'timeline'>} options */ +// @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type. export const runBuildTimeline = (options) => runNetlifyBuild({ ...options, timeline: 'build' }) diff --git a/src/utils/shell.mjs b/src/utils/shell.mts similarity index 71% rename from src/utils/shell.mjs rename to src/utils/shell.mts index 63811860af3..1460a905fab 100644 --- a/src/utils/shell.mjs +++ b/src/utils/shell.mts @@ -1,7 +1,8 @@ -// @ts-check + import process from 'process' import execa from 'execa' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'stri... Remove this comment to see the full error message import stripAnsiCc from 'strip-ansi-control-characters' import { chalk, log, NETLIFYDEVERR, NETLIFYDEVWARN } from './command-helpers.mjs' @@ -10,6 +11,7 @@ import { processOnExit } from './dev.mjs' /** * @type {(() => Promise)[]} - array of functions to run before the process exits */ +// @ts-expect-error TS(7034) FIXME: Variable 'cleanupWork' implicitly has type 'any[]'... Remove this comment to see the full error message const cleanupWork = [] let cleanupStarted = false @@ -17,6 +19,7 @@ let cleanupStarted = false /** * @param {() => Promise} job */ +// @ts-expect-error TS(7006) FIXME: Parameter 'job' implicitly has an 'any' type. export const addCleanupJob = (job) => { cleanupWork.push(job) } @@ -25,11 +28,13 @@ export const addCleanupJob = (job) => { * @param {object} input * @param {number=} input.exitCode The exit code to return when exiting the process after cleanup */ +// @ts-expect-error TS(7031) FIXME: Binding element 'exitCode' implicitly has an 'any'... Remove this comment to see the full error message const cleanupBeforeExit = async ({ exitCode }) => { // If cleanup has started, then wherever started it will be responsible for exiting if (!cleanupStarted) { cleanupStarted = true try { + // @ts-expect-error TS(7005) FIXME: Variable 'cleanupWork' implicitly has an 'any[]' t... Remove this comment to see the full error message await Promise.all(cleanupWork.map((cleanup) => cleanup())) } finally { process.exit(exitCode) @@ -46,7 +51,9 @@ const cleanupBeforeExit = async ({ exitCode }) => { * @param {string} [options.cwd] * @returns {execa.ExecaChildProcess} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type. export const runCommand = (command, options = {}) => { + // @ts-expect-error TS(2339) FIXME: Property 'cwd' does not exist on type '{}'. const { cwd, env = {}, spinner = null } = options const commandProcess = execa.command(command, { preferLocal: true, @@ -64,6 +71,7 @@ export const runCommand = (command, options = {}) => { // This ensures that an active spinner stays at the bottom of the commandline // even though the actual framework command might be outputting stuff + // @ts-expect-error TS(7006) FIXME: Parameter 'writeStream' implicitly has an 'any' ty... Remove this comment to see the full error message const pipeDataWithSpinner = (writeStream, chunk) => { if (spinner && spinner.isSpinning) { spinner.clear() @@ -77,8 +85,11 @@ export const runCommand = (command, options = {}) => { }) } + // @ts-expect-error TS(2531) FIXME: Object is possibly 'null'. commandProcess.stdout.pipe(stripAnsiCc.stream()).on('data', pipeDataWithSpinner.bind(null, process.stdout)) + // @ts-expect-error TS(2531) FIXME: Object is possibly 'null'. commandProcess.stderr.pipe(stripAnsiCc.stream()).on('data', pipeDataWithSpinner.bind(null, process.stderr)) + // @ts-expect-error TS(2345) FIXME: Argument of type 'Writable | null' is not assignab... Remove this comment to see the full error message process.stdin.pipe(commandProcess.stdin) // we can't try->await->catch since we don't want to block on the framework server which @@ -97,6 +108,7 @@ export const runCommand = (command, options = {}) => { ) } else { const errorMessage = result.failed + // @ts-expect-error TS(2339) FIXME: Property 'shortMessage' does not exist on type 'Ex... Remove this comment to see the full error message ? `${NETLIFYDEVERR} ${result.shortMessage}` : `${NETLIFYDEVWARN} "${command}" exited with code ${result.exitCode}` @@ -105,6 +117,7 @@ export const runCommand = (command, options = {}) => { return await cleanupBeforeExit({ exitCode: 1 }) }) + // @ts-expect-error TS(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message processOnExit(async () => await cleanupBeforeExit({})) return commandProcess @@ -117,6 +130,7 @@ export const runCommand = (command, options = {}) => { * @param {*} config.error * @returns */ +// @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message const isNonExistingCommandError = ({ command, error: commandError }) => { // `ENOENT` is only returned for non Windows systems // See https://github.com/sindresorhus/execa/pull/447 diff --git a/src/utils/sign-redirect.mjs b/src/utils/sign-redirect.mts similarity index 60% rename from src/utils/sign-redirect.mjs rename to src/utils/sign-redirect.mts index 812ec31d000..b9101b34455 100644 --- a/src/utils/sign-redirect.mjs +++ b/src/utils/sign-redirect.mts @@ -1,6 +1,8 @@ +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'json... Remove this comment to see the full error message import jwt from 'jsonwebtoken' // https://docs.netlify.com/routing/redirects/rewrites-proxies/#signed-proxy-redirects +// @ts-expect-error TS(7031) FIXME: Binding element 'deployContext' implicitly has an ... Remove this comment to see the full error message export const signRedirect = ({ deployContext, secret, siteID, siteURL }) => { const claims = { deploy_context: deployContext, diff --git a/src/utils/sites/utils.mjs b/src/utils/sites/utils.mts similarity index 71% rename from src/utils/sites/utils.mjs rename to src/utils/sites/utils.mts index 7894a804f21..a4e7fa1b9a4 100644 --- a/src/utils/sites/utils.mjs +++ b/src/utils/sites/utils.mts @@ -1,5 +1,7 @@ +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message import fetch from 'node-fetch' +// @ts-expect-error TS(7006) FIXME: Parameter 'token' implicitly has an 'any' type. export const getTemplatesFromGitHub = async (token) => { const getPublicGitHubReposFromOrg = new URL(`https://api.github.com/orgs/netlify-templates/repos`) // GitHub returns 30 by default and we want to avoid our limit @@ -8,6 +10,7 @@ export const getTemplatesFromGitHub = async (token) => { getPublicGitHubReposFromOrg.searchParams.set('type', 'public') getPublicGitHubReposFromOrg.searchParams.set('sort', 'full_name') + // @ts-expect-error TS(2345) FIXME: Argument of type 'number' is not assignable to par... Remove this comment to see the full error message getPublicGitHubReposFromOrg.searchParams.set('per_page', REPOS_PER_PAGE) const templates = await fetch(getPublicGitHubReposFromOrg, { @@ -21,6 +24,7 @@ export const getTemplatesFromGitHub = async (token) => { return allTemplates } +// @ts-expect-error TS(7031) FIXME: Binding element 'ghToken' implicitly has an 'any' ... Remove this comment to see the full error message export const validateTemplate = async ({ ghToken, templateName }) => { const response = await fetch(`https://api.github.com/repos/${templateName}`, { headers: { @@ -41,6 +45,7 @@ export const validateTemplate = async ({ ghToken, templateName }) => { return { exists: true, isTemplate: data.is_template } } +// @ts-expect-error TS(7006) FIXME: Parameter 'templateName' implicitly has an 'any' t... Remove this comment to see the full error message export const createRepo = async (templateName, ghToken, siteName) => { const resp = await fetch(`https://api.github.com/repos/${templateName}/generate`, { method: 'POST', diff --git a/src/utils/state-config.mjs b/src/utils/state-config.mts similarity index 58% rename from src/utils/state-config.mjs rename to src/utils/state-config.mts index 5998ccd7b98..16a43edd2b9 100644 --- a/src/utils/state-config.mjs +++ b/src/utils/state-config.mts @@ -4,6 +4,7 @@ import process from 'process' import { deleteProperty, getProperty, hasProperty, setProperty } from 'dot-prop' import { findUpSync } from 'find-up' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'writ... Remove this comment to see the full error message import writeFileAtomic from 'write-file-atomic' import { getPathInProject } from '../lib/settings.mjs' @@ -16,6 +17,7 @@ const permissionError = "You don't have access to this file." * @param {string} cwd * @returns {string} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'cwd' implicitly has an 'any' type. const findStatePath = (cwd) => { const statePath = findUpSync([STATE_PATH], { cwd }) @@ -27,26 +29,34 @@ const findStatePath = (cwd) => { } export default class StateConfig { + // @ts-expect-error TS(7006) FIXME: Parameter 'cwd' implicitly has an 'any' type. constructor(cwd) { + // @ts-expect-error TS(2339) FIXME: Property 'path' does not exist on type 'StateConfi... Remove this comment to see the full error message this.path = findStatePath(cwd) } get all() { try { + // @ts-expect-error TS(2345) FIXME: Argument of type 'Buffer' is not assignable to par... Remove this comment to see the full error message return JSON.parse(fs.readFileSync(this.path)) } catch (error) { // Don't create if it doesn't exist + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error.code === 'ENOENT' || error.code === 'ENOTDIR') { return {} } // Improve the message of permission errors + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error.code === 'EACCES') { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error.message = `${error.message}\n${permissionError}\n` } // Empty the file if it encounters invalid JSON + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error.name === 'SyntaxError') { + // @ts-expect-error TS(2339) FIXME: Property 'path' does not exist on type 'StateConfi... Remove this comment to see the full error message writeFileAtomic.sync(this.path, '') return {} } @@ -58,11 +68,15 @@ export default class StateConfig { set all(val) { try { // Make sure the folder exists as it could have been deleted in the meantime + // @ts-expect-error TS(2339) FIXME: Property 'path' does not exist on type 'StateConfi... Remove this comment to see the full error message fs.mkdirSync(path.dirname(this.path), { recursive: true }) + // @ts-expect-error TS(2339) FIXME: Property 'path' does not exist on type 'StateConfi... Remove this comment to see the full error message writeFileAtomic.sync(this.path, JSON.stringify(val, null, '\t')) } catch (error) { // Improve the message of permission errors + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. if (error.code === 'EACCES') { + // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'. error.message = `${error.message}\n${permissionError}\n` } @@ -74,6 +88,7 @@ export default class StateConfig { return Object.keys(this.all || {}).length } + // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. get(key) { if (key === 'siteId' && process.env.NETLIFY_SITE_ID) { // TODO figure out cleaner way of grabbing ENV vars @@ -82,6 +97,7 @@ export default class StateConfig { return getProperty(this.all, key) } + // @ts-expect-error TS(7019) FIXME: Rest parameter 'args' implicitly has an 'any[]' ty... Remove this comment to see the full error message set(...args) { const [key, val] = args const config = this.all @@ -97,10 +113,12 @@ export default class StateConfig { this.all = config } + // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. has(key) { return hasProperty(this.all, key) } + // @ts-expect-error TS(7006) FIXME: Parameter 'key' implicitly has an 'any' type. delete(key) { const config = this.all deleteProperty(config, key) diff --git a/src/utils/static-server.mjs b/src/utils/static-server.mts similarity index 88% rename from src/utils/static-server.mjs rename to src/utils/static-server.mts index 5f6ea4224d8..9ca95d6c1b1 100644 --- a/src/utils/static-server.mjs +++ b/src/utils/static-server.mts @@ -1,4 +1,4 @@ -// @ts-check + import path from 'path' import fastifyStatic from '@fastify/static' @@ -10,6 +10,7 @@ import { log, NETLIFYDEVLOG } from './command-helpers.mjs' * @param {object} config * @param {import('./types.js').ServerSettings} config.settings */ +// @ts-expect-error TS(7031) FIXME: Binding element 'settings' implicitly has an 'any'... Remove this comment to see the full error message export const startStaticServer = async ({ settings }) => { const server = Fastify() const rootPath = path.resolve(settings.dist) diff --git a/src/utils/telemetry/index.mjs b/src/utils/telemetry/index.mts similarity index 100% rename from src/utils/telemetry/index.mjs rename to src/utils/telemetry/index.mts diff --git a/src/utils/telemetry/report-error.mjs b/src/utils/telemetry/report-error.mts similarity index 76% rename from src/utils/telemetry/report-error.mjs rename to src/utils/telemetry/report-error.mts index c934ec39f3e..c14f95e625f 100644 --- a/src/utils/telemetry/report-error.mjs +++ b/src/utils/telemetry/report-error.mts @@ -5,6 +5,7 @@ import { fileURLToPath } from 'url' import { isCI } from 'ci-info' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../execa.mjs' import getGlobalConfig from '../get-global-config.mjs' @@ -20,6 +21,7 @@ const dirPath = dirname(fileURLToPath(import.meta.url)) * @param {Record>} [config.metadata] * @returns {Promise} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'error' implicitly has an 'any' type. export const reportError = async function (error, config = {}) { if (isCI) { return @@ -38,10 +40,12 @@ export const reportError = async function (error, config = {}) { name: err.name, stack: err.stack, cause: err.cause, + // @ts-expect-error TS(2339) FIXME: Property 'severity' does not exist on type '{}'. severity: config.severity, user: { id: globalConfig.get('userId'), }, + // @ts-expect-error TS(2339) FIXME: Property 'metadata' does not exist on type '{}'. metadata: config.metadata, osName: `${os.platform()}-${os.arch()}`, cliVersion, @@ -51,6 +55,7 @@ export const reportError = async function (error, config = {}) { // spawn detached child process to handle send and wait for the http request to finish // otherwise it can get canceled + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. await execa(process.execPath, [join(dirPath, 'request.mjs'), options], { detached: true, stdio: 'ignore', diff --git a/src/utils/telemetry/request.mjs b/src/utils/telemetry/request.mts similarity index 89% rename from src/utils/telemetry/request.mjs rename to src/utils/telemetry/request.mts index bca3c0ff693..7cbb11f8bf7 100644 --- a/src/utils/telemetry/request.mjs +++ b/src/utils/telemetry/request.mts @@ -1,8 +1,9 @@ -// @ts-check + // This file is being called by `src/utils/telemetry/telemetry.js` as a child process // to run a s a detached process import process from 'process' +// @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'node... Remove this comment to see the full error message import fetch from 'node-fetch' import getPackageJson from '../get-package-json.mjs' diff --git a/src/utils/telemetry/telemetry.mjs b/src/utils/telemetry/telemetry.mts similarity index 80% rename from src/utils/telemetry/telemetry.mjs rename to src/utils/telemetry/telemetry.mts index a10f9a17f19..9b649bb652a 100644 --- a/src/utils/telemetry/telemetry.mjs +++ b/src/utils/telemetry/telemetry.mts @@ -1,10 +1,11 @@ -// @ts-check + import { dirname, join } from 'path' import process, { version as nodejsVersion } from 'process' import { fileURLToPath } from 'url' import { isCI } from 'ci-info' +// @ts-expect-error TS(7034) FIXME: Variable 'execa' implicitly has type 'any' in some... Remove this comment to see the full error message import execa from '../execa.mjs' import getGlobalConfig from '../get-global-config.mjs' @@ -17,6 +18,7 @@ const dirPath = dirname(fileURLToPath(import.meta.url)) * @param {'track' | 'identify'} type * @param {object} payload */ +// @ts-expect-error TS(7006) FIXME: Parameter 'type' implicitly has an 'any' type. function send(type, payload) { const requestFile = join(dirPath, 'request.mjs') const options = JSON.stringify({ @@ -26,12 +28,14 @@ function send(type, payload) { const args = /** @type {const} */ ([process.execPath, [requestFile, options]]) if (process.env.NETLIFY_TEST_TELEMETRY_WAIT === 'true') { + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. return execa(...args, { stdio: 'inherit', }) } // spawn detached child process to handle send + // @ts-expect-error TS(7005) FIXME: Variable 'execa' implicitly has an 'any' type. execa(...args, { detached: true, stdio: 'ignore', @@ -55,6 +59,7 @@ const eventConfig = { * @param {string} eventName * @param {{status?: string, duration?: number, [key: string]: unknown}} [payload] */ +// @ts-expect-error TS(7006) FIXME: Parameter 'eventName' implicitly has an 'any' type... Remove this comment to see the full error message export async function track(eventName, payload = {}) { if (isCI) { return @@ -79,6 +84,7 @@ export async function track(eventName, payload = {}) { return false } + // @ts-expect-error TS(2339) FIXME: Property 'duration' does not exist on type '{}'. const { duration, status, ...properties } = payload const defaultData = { event: eventName, @@ -99,6 +105,7 @@ export async function track(eventName, payload = {}) { * @param {string} payload.userId * @returns */ +// @ts-expect-error TS(7006) FIXME: Parameter 'payload' implicitly has an 'any' type. export async function identify(payload) { if (isCI) { return diff --git a/src/utils/telemetry/utils.mjs b/src/utils/telemetry/utils.mts similarity index 71% rename from src/utils/telemetry/utils.mjs rename to src/utils/telemetry/utils.mts index de9fc8f42ea..968c4186a31 100644 --- a/src/utils/telemetry/utils.mjs +++ b/src/utils/telemetry/utils.mts @@ -2,6 +2,7 @@ import getPackageJson from '../get-package-json.mjs' export const { version: cliVersion } = await getPackageJson() +// @ts-expect-error TS(7006) FIXME: Parameter 'config' implicitly has an 'any' type. export const isTelemetryDisabled = function (config) { return config.get('telemetryDisabled') } diff --git a/src/utils/telemetry/validation.mjs b/src/utils/telemetry/validation.mts similarity index 78% rename from src/utils/telemetry/validation.mjs rename to src/utils/telemetry/validation.mts index 1d70d954563..25755e92f98 100644 --- a/src/utils/telemetry/validation.mjs +++ b/src/utils/telemetry/validation.mts @@ -3,17 +3,20 @@ */ import { log } from '../command-helpers.mjs' +// @ts-expect-error TS(7006) FIXME: Parameter 'eventName' implicitly has an 'any' type... Remove this comment to see the full error message export default function isValidEventName(eventName, config) { const validProject = [config.projectName] const validObjects = config.objects || [] const matches = eventName.match(/([a-zA-Z]*):([a-zA-Z]*)_([a-zA-Z]*$)/) if (!containsSeparators(eventName) || !matches) { + // @ts-expect-error TS(2554) FIXME: Expected 2 arguments, but got 1. return formattingWarning(eventName) } const [, project, object, action] = matches let error // if missing any parts of event, exit if (!project || !object || !action) { + // @ts-expect-error TS(2554) FIXME: Expected 2 arguments, but got 1. return formattingWarning(eventName) } // validate project name @@ -29,6 +32,7 @@ export default function isValidEventName(eventName, config) { return true } +// @ts-expect-error TS(7006) FIXME: Parameter 'eventName' implicitly has an 'any' type... Remove this comment to see the full error message const containsSeparators = function (eventName) { const underscores = (eventName.match(/_/g) || []).length if (underscores !== 1) { @@ -43,6 +47,7 @@ const containsSeparators = function (eventName) { return true } +// @ts-expect-error TS(7006) FIXME: Parameter 'eventName' implicitly has an 'any' type... Remove this comment to see the full error message const formattingWarning = function (eventName, errorMsg) { log('-----------------------------') log('Tracking Error:') diff --git a/src/utils/validation.mjs b/src/utils/validation.mts similarity index 80% rename from src/utils/validation.mjs rename to src/utils/validation.mts index ad348d7eb4c..ac60ba2a42c 100644 --- a/src/utils/validation.mjs +++ b/src/utils/validation.mts @@ -1,10 +1,11 @@ -// @ts-check + import { BANG, chalk } from './command-helpers.mjs' /** * @param {string} exampleCommand * @returns {(value:string, previous: unknown) => unknown} */ +// @ts-expect-error TS(7006) FIXME: Parameter 'exampleCommand' implicitly has an 'any'... Remove this comment to see the full error message export const getGeoCountryArgParser = (exampleCommand) => (arg) => { // Validate that the arg passed is two letters only for country // See https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes diff --git a/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/brotli.mjs b/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/brotli.mjs index 9eed62900a0..7fa85b5d821 100644 --- a/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/brotli.mjs +++ b/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/brotli.mjs @@ -1,4 +1,4 @@ -import { brotliCompressSync } from "node:zlib" +import { brotliCompressSync } from 'node:zlib' export default async () => { const text = "What's 🍞🏄‍♀️? A breadboard!".repeat(100) @@ -7,7 +7,7 @@ export default async () => { return new Response(brotli, { status: 200, headers: { - "Content-Encoding": "br", - } + 'Content-Encoding': 'br', + }, }) } diff --git a/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/custom-path-root.mjs b/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/custom-path-root.mjs index b120081dae7..ae2e1e3850e 100644 --- a/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/custom-path-root.mjs +++ b/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/custom-path-root.mjs @@ -2,5 +2,5 @@ export default async (req) => new Response(`With literal path: ${req.url}`) export const config = { path: '/', - method: 'GET' + method: 'GET', } diff --git a/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/delete.mjs b/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/delete.mjs index a6a1bb76457..10ed886fab5 100644 --- a/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/delete.mjs +++ b/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/delete.mjs @@ -2,5 +2,5 @@ export default async (req, context) => new Response(`Deleted item successfully: export const config = { path: '/products/:sku', - method: "DELETE" + method: 'DELETE', } diff --git a/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/log.mjs b/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/log.mjs index e6a9ee03465..a50590dcaaa 100644 --- a/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/log.mjs +++ b/tests/integration/__fixtures__/dev-server-with-v2-functions/functions/log.mjs @@ -1,4 +1,4 @@ export default async () => { - console.log("🪵🪵🪵") - return new Response("") -} \ No newline at end of file + console.log('🪵🪵🪵') + return new Response('') +} diff --git a/tests/integration/__fixtures__/dev-server-with-v2-functions/public/v2-to-custom-without-force.html b/tests/integration/__fixtures__/dev-server-with-v2-functions/public/v2-to-custom-without-force.html index 2a18639f48a..829ae6d96ad 100644 --- a/tests/integration/__fixtures__/dev-server-with-v2-functions/public/v2-to-custom-without-force.html +++ b/tests/integration/__fixtures__/dev-server-with-v2-functions/public/v2-to-custom-without-force.html @@ -1 +1 @@ -/v2-to-custom-without-force from origin \ No newline at end of file +/v2-to-custom-without-force from origin diff --git a/tests/integration/__fixtures__/dev-server-with-v2-functions/public/v2-to-legacy-without-force.html b/tests/integration/__fixtures__/dev-server-with-v2-functions/public/v2-to-legacy-without-force.html index 3242a10f669..15a06afdc4d 100644 --- a/tests/integration/__fixtures__/dev-server-with-v2-functions/public/v2-to-legacy-without-force.html +++ b/tests/integration/__fixtures__/dev-server-with-v2-functions/public/v2-to-legacy-without-force.html @@ -1 +1 @@ -/v2-to-legacy-without-force from origin \ No newline at end of file +/v2-to-legacy-without-force from origin diff --git a/tests/integration/__fixtures__/eleventy-site/.netlify/edge-functions-import-map.json b/tests/integration/__fixtures__/eleventy-site/.netlify/edge-functions-import-map.json index ef311bf5202..0faab5973fa 100644 --- a/tests/integration/__fixtures__/eleventy-site/.netlify/edge-functions-import-map.json +++ b/tests/integration/__fixtures__/eleventy-site/.netlify/edge-functions-import-map.json @@ -1 +1 @@ -{"imports":{"netlify:edge":"https://edge.netlify.com/v1/index.ts"},"scopes":{}} \ No newline at end of file +{ "imports": { "netlify:edge": "https://edge.netlify.com/v1/index.ts" }, "scopes": {} } diff --git a/tests/integration/__fixtures__/plugin-changing-publish-dir/dist/index.html b/tests/integration/__fixtures__/plugin-changing-publish-dir/dist/index.html index c57eff55ebc..980a0d5f19a 100644 --- a/tests/integration/__fixtures__/plugin-changing-publish-dir/dist/index.html +++ b/tests/integration/__fixtures__/plugin-changing-publish-dir/dist/index.html @@ -1 +1 @@ -Hello World! \ No newline at end of file +Hello World! diff --git a/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/index.js b/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/index.js index b70100e91f5..9f3eacfd57d 100644 --- a/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/index.js +++ b/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/index.js @@ -1,5 +1,5 @@ export default { - onBuild({netlifyConfig}){ - netlifyConfig.build.publish = "dist" - } -} \ No newline at end of file + onBuild({ netlifyConfig }) { + netlifyConfig.build.publish = 'dist' + }, +} diff --git a/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/manifest.yml b/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/manifest.yml index 49a980b9bb5..c89506e3a2f 100644 --- a/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/manifest.yml +++ b/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/manifest.yml @@ -1 +1 @@ -name: change-publish-dir \ No newline at end of file +name: change-publish-dir diff --git a/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/package.json b/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/package.json index bb34440a365..3dbc1ca591c 100644 --- a/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/package.json +++ b/tests/integration/__fixtures__/plugin-changing-publish-dir/plugin/package.json @@ -1 +1,3 @@ -{ "type": "module" } \ No newline at end of file +{ + "type": "module" +} diff --git a/tests/integration/commands/dev/v2-api.test.ts b/tests/integration/commands/dev/v2-api.test.ts index 012a9dd7fdf..51fd7c1e856 100644 --- a/tests/integration/commands/dev/v2-api.test.ts +++ b/tests/integration/commands/dev/v2-api.test.ts @@ -178,7 +178,8 @@ describe.runIf(gte(version, '18.13.0'))('v2 api', () => { const url = `http://localhost:${devServer.port}/v2-to-legacy-without-force` const response = await fetch(url) expect(response.status).toBe(200) - expect(await response.text()).toBe('/v2-to-legacy-without-force from origin') + const text = await (await response.text()).trim() + expect(text).toBe('/v2-to-legacy-without-force from origin') }) test('rewrite to custom URL format with `force: true`', async ({ devServer }) => { @@ -192,7 +193,8 @@ describe.runIf(gte(version, '18.13.0'))('v2 api', () => { const url = `http://localhost:${devServer.port}/v2-to-custom-without-force` const response = await fetch(url) expect(response.status).toBe(200) - expect(await response.text()).toBe('/v2-to-custom-without-force from origin') + const text = await (await response.text()).trim() + expect(text).toBe('/v2-to-custom-without-force from origin') }) }) diff --git a/tests/integration/utils/call-cli.mjs b/tests/integration/utils/call-cli.mjs index 68601147a0d..934c4d59545 100644 --- a/tests/integration/utils/call-cli.mjs +++ b/tests/integration/utils/call-cli.mjs @@ -1,4 +1,3 @@ -// @ts-check import execa from 'execa' import { cliPath } from './cli-path.mjs' diff --git a/tests/integration/utils/site-builder.mjs b/tests/integration/utils/site-builder.mjs index 81f27fe1c55..0c4e3137b2b 100644 --- a/tests/integration/utils/site-builder.mjs +++ b/tests/integration/utils/site-builder.mjs @@ -1,4 +1,3 @@ -// @ts-check import { copyFile, mkdir, rm, unlink, writeFile } from 'fs/promises' import os from 'os' import path from 'path' diff --git a/tests/unit/lib/completion/generate-autocompletion.test.mjs b/tests/unit/lib/completion/generate-autocompletion.test.mjs index f47ef45d681..5a10066d0e7 100644 --- a/tests/unit/lib/completion/generate-autocompletion.test.mjs +++ b/tests/unit/lib/completion/generate-autocompletion.test.mjs @@ -1,4 +1,3 @@ -// @ts-check import fs from 'fs' import { Argument } from 'commander' diff --git a/tests/unit/lib/completion/get-autocompletion.test.mjs b/tests/unit/lib/completion/get-autocompletion.test.mjs index 299cd2fe299..dc835a6fe1c 100644 --- a/tests/unit/lib/completion/get-autocompletion.test.mjs +++ b/tests/unit/lib/completion/get-autocompletion.test.mjs @@ -1,4 +1,3 @@ -// @ts-check import { expect, describe, test } from 'vitest' import getAutocompletion from '../../../../src/lib/completion/get-autocompletion.mjs' diff --git a/tests/unit/lib/exec-fetcher.test.mjs b/tests/unit/lib/exec-fetcher.test.mjs index e71fa51f45e..6e27f167089 100644 --- a/tests/unit/lib/exec-fetcher.test.mjs +++ b/tests/unit/lib/exec-fetcher.test.mjs @@ -1,4 +1,3 @@ -// @ts-check import process from 'process' import { fetchLatest } from 'gh-release-fetch' diff --git a/tests/unit/utils/init/config-github.test.mjs b/tests/unit/utils/init/config-github.test.mjs index 8f1d9b965e2..dc62d2e52b6 100644 --- a/tests/unit/utils/init/config-github.test.mjs +++ b/tests/unit/utils/init/config-github.test.mjs @@ -1,4 +1,3 @@ -// @ts-check import { Octokit } from '@octokit/rest' import { beforeEach, describe, expect, test, vi } from 'vitest' diff --git a/tools/affected-test.mjs b/tools/affected-test.mjs index 9391e1b7ae9..87f06bb70c9 100755 --- a/tools/affected-test.mjs +++ b/tools/affected-test.mjs @@ -1,5 +1,5 @@ #!/usr/bin/env node -// @ts-check + import { existsSync, statSync } from 'fs' import { join } from 'path' import process from 'process' diff --git a/tools/project-graph/dependency-graph.mjs b/tools/project-graph/dependency-graph.mjs index 2117e36ab6d..89c80390941 100644 --- a/tools/project-graph/dependency-graph.mjs +++ b/tools/project-graph/dependency-graph.mjs @@ -1,4 +1,3 @@ -// @ts-check import { digraph } from 'graphviz' export class DependencyGraph { diff --git a/tools/project-graph/file-visitor.mjs b/tools/project-graph/file-visitor.mjs index dde6b4b4a62..45b26d6f411 100644 --- a/tools/project-graph/file-visitor.mjs +++ b/tools/project-graph/file-visitor.mjs @@ -1,4 +1,3 @@ -// @ts-check import { existsSync, readFileSync, statSync } from 'fs' import { dirname, join, parse } from 'path' diff --git a/tools/project-graph/visitor-plugins.mjs b/tools/project-graph/visitor-plugins.mjs index aded0b4663f..42824b269e9 100644 --- a/tools/project-graph/visitor-plugins.mjs +++ b/tools/project-graph/visitor-plugins.mjs @@ -1,4 +1,3 @@ -// @ts-check import { join } from 'path' import ts from 'typescript' diff --git a/tsconfig.json b/tsconfig.json index bf276f69e50..869ac44c5b6 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -7,17 +7,13 @@ "moduleResolution": "NodeNext", "declaration": true, "declarationMap": false, - "sourceMap": true, - "outDir": "./dist", "removeComments": false, "downlevelIteration": true, - "esModuleInterop": false, - "allowSyntheticDefaultImports": true, "forceConsistentCasingInFileNames": true, "strict": true, "skipLibCheck": true /* Skip type checking all .d.ts files. */, - "allowJs": true, - "maxNodeModuleJsDepth": 10 + "allowJs": true }, - "include": ["src"] + "include": ["src/**/*.mts"], + "exclude": ["node_modules", "src/functions-templates"] }