netlify-cli 17.3.1 → 17.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (210) hide show
  1. package/README.md +3 -139
  2. package/npm-shrinkwrap.json +82 -82
  3. package/package.json +16 -15
  4. package/src/commands/addons/addons-auth.mjs +27 -30
  5. package/src/commands/addons/addons-config.mjs +145 -154
  6. package/src/commands/addons/addons-create.mjs +94 -108
  7. package/src/commands/addons/addons-delete.mjs +36 -41
  8. package/src/commands/addons/addons-list.mjs +38 -42
  9. package/src/commands/addons/addons.mjs +26 -28
  10. package/src/commands/addons/index.mjs +1 -1
  11. package/src/commands/api/api.mjs +45 -53
  12. package/src/commands/api/index.mjs +1 -1
  13. package/src/commands/base-command.mjs +597 -684
  14. package/src/commands/blobs/blobs-delete.mjs +35 -0
  15. package/src/commands/blobs/blobs-get.mjs +44 -0
  16. package/src/commands/blobs/blobs-list.mjs +48 -0
  17. package/src/commands/blobs/blobs-set.mjs +54 -0
  18. package/src/commands/blobs/blobs.mjs +32 -0
  19. package/src/commands/blobs/index.mjs +1 -0
  20. package/src/commands/build/build.mjs +55 -67
  21. package/src/commands/build/index.mjs +1 -1
  22. package/src/commands/completion/completion.mjs +41 -46
  23. package/src/commands/completion/index.mjs +1 -1
  24. package/src/commands/deploy/deploy.mjs +675 -710
  25. package/src/commands/deploy/index.mjs +1 -1
  26. package/src/commands/dev/dev-exec.mjs +20 -32
  27. package/src/commands/dev/dev.mjs +217 -302
  28. package/src/commands/dev/index.mjs +1 -1
  29. package/src/commands/dev/types.d.ts +30 -0
  30. package/src/commands/env/env-clone.mjs +157 -184
  31. package/src/commands/env/env-get.mjs +49 -68
  32. package/src/commands/env/env-import.mjs +100 -119
  33. package/src/commands/env/env-list.mjs +104 -129
  34. package/src/commands/env/env-set.mjs +160 -185
  35. package/src/commands/env/env-unset.mjs +104 -122
  36. package/src/commands/env/env.mjs +28 -30
  37. package/src/commands/env/index.mjs +1 -1
  38. package/src/commands/functions/functions-build.mjs +29 -41
  39. package/src/commands/functions/functions-create.mjs +533 -601
  40. package/src/commands/functions/functions-invoke.mjs +193 -216
  41. package/src/commands/functions/functions-list.mjs +45 -55
  42. package/src/commands/functions/functions-serve.mjs +51 -61
  43. package/src/commands/functions/functions.mjs +26 -32
  44. package/src/commands/functions/index.mjs +1 -1
  45. package/src/commands/index.mjs +2 -2
  46. package/src/commands/init/index.mjs +1 -1
  47. package/src/commands/init/init.mjs +138 -167
  48. package/src/commands/integration/deploy.mjs +337 -399
  49. package/src/commands/integration/index.mjs +12 -13
  50. package/src/commands/link/index.mjs +1 -1
  51. package/src/commands/link/link.mjs +298 -317
  52. package/src/commands/lm/index.mjs +1 -1
  53. package/src/commands/lm/lm-info.mjs +23 -31
  54. package/src/commands/lm/lm-install.mjs +13 -17
  55. package/src/commands/lm/lm-setup.mjs +80 -84
  56. package/src/commands/lm/lm-uninstall.mjs +7 -12
  57. package/src/commands/lm/lm.mjs +18 -22
  58. package/src/commands/login/index.mjs +1 -1
  59. package/src/commands/login/login.mjs +35 -41
  60. package/src/commands/logout/index.mjs +1 -1
  61. package/src/commands/logout/logout.mjs +25 -31
  62. package/src/commands/main.mjs +166 -201
  63. package/src/commands/open/index.mjs +1 -1
  64. package/src/commands/open/open-admin.mjs +15 -18
  65. package/src/commands/open/open-site.mjs +16 -19
  66. package/src/commands/open/open.mjs +24 -27
  67. package/src/commands/recipes/common.mjs +23 -34
  68. package/src/commands/recipes/index.mjs +1 -1
  69. package/src/commands/recipes/recipes-list.mjs +13 -20
  70. package/src/commands/recipes/recipes.mjs +59 -72
  71. package/src/commands/serve/index.mjs +1 -1
  72. package/src/commands/serve/serve.mjs +142 -189
  73. package/src/commands/sites/index.mjs +2 -2
  74. package/src/commands/sites/sites-create-template.mjs +214 -236
  75. package/src/commands/sites/sites-create.mjs +145 -157
  76. package/src/commands/sites/sites-delete.mjs +75 -81
  77. package/src/commands/sites/sites-list.mjs +63 -66
  78. package/src/commands/sites/sites.mjs +18 -20
  79. package/src/commands/status/index.mjs +1 -1
  80. package/src/commands/status/status-hooks.mjs +32 -34
  81. package/src/commands/status/status.mjs +99 -106
  82. package/src/commands/switch/index.mjs +1 -1
  83. package/src/commands/switch/switch.mjs +32 -37
  84. package/src/commands/types.d.ts +31 -0
  85. package/src/commands/unlink/index.mjs +1 -1
  86. package/src/commands/unlink/unlink.mjs +23 -29
  87. package/src/commands/watch/index.mjs +1 -1
  88. package/src/commands/watch/watch.mjs +91 -105
  89. package/src/functions-templates/javascript/hello/{{name}}.js +2 -3
  90. package/src/lib/account.mjs +4 -5
  91. package/src/lib/api.mjs +22 -20
  92. package/src/lib/blobs/blobs.mjs +36 -45
  93. package/src/lib/build.mjs +82 -85
  94. package/src/lib/completion/constants.mjs +2 -4
  95. package/src/lib/completion/generate-autocompletion.mjs +33 -36
  96. package/src/lib/completion/get-autocompletion.mjs +31 -35
  97. package/src/lib/completion/index.mjs +1 -1
  98. package/src/lib/completion/script.mjs +12 -19
  99. package/src/lib/edge-functions/bootstrap.mjs +3 -5
  100. package/src/lib/edge-functions/consts.mjs +9 -10
  101. package/src/lib/edge-functions/deploy.mjs +28 -34
  102. package/src/lib/edge-functions/editor-helper.mjs +29 -42
  103. package/src/lib/edge-functions/headers.mjs +24 -26
  104. package/src/lib/edge-functions/internal.mjs +38 -44
  105. package/src/lib/edge-functions/proxy.mjs +229 -228
  106. package/src/lib/edge-functions/registry.mjs +473 -574
  107. package/src/lib/exec-fetcher.mjs +115 -122
  108. package/src/lib/fs.mjs +28 -27
  109. package/src/lib/functions/background.mjs +16 -20
  110. package/src/lib/functions/config.mjs +12 -9
  111. package/src/lib/functions/form-submissions-handler.mjs +143 -149
  112. package/src/lib/functions/local-proxy.mjs +40 -44
  113. package/src/lib/functions/memoized-build.mjs +19 -21
  114. package/src/lib/functions/netlify-function.mjs +269 -249
  115. package/src/lib/functions/registry.mjs +509 -568
  116. package/src/lib/functions/runtimes/go/index.mjs +62 -71
  117. package/src/lib/functions/runtimes/index.mjs +8 -15
  118. package/src/lib/functions/runtimes/js/builders/netlify-lambda.mjs +55 -64
  119. package/src/lib/functions/runtimes/js/builders/zisi.mjs +135 -154
  120. package/src/lib/functions/runtimes/js/constants.mjs +1 -1
  121. package/src/lib/functions/runtimes/js/index.mjs +92 -109
  122. package/src/lib/functions/runtimes/js/worker.mjs +43 -45
  123. package/src/lib/functions/runtimes/rust/index.mjs +64 -73
  124. package/src/lib/functions/scheduled.mjs +70 -88
  125. package/src/lib/functions/server.mjs +269 -327
  126. package/src/lib/functions/synchronous.mjs +118 -147
  127. package/src/lib/functions/utils.mjs +38 -46
  128. package/src/lib/geo-location.mjs +69 -81
  129. package/src/lib/http-agent.mjs +87 -90
  130. package/src/lib/images/proxy.mjs +97 -89
  131. package/src/lib/log.mjs +6 -9
  132. package/src/lib/path.mjs +2 -1
  133. package/src/lib/render-error-template.mjs +19 -20
  134. package/src/lib/settings.mjs +17 -19
  135. package/src/lib/spinner.mjs +21 -23
  136. package/src/lib/string.mjs +4 -2
  137. package/src/recipes/vscode/index.mjs +69 -85
  138. package/src/recipes/vscode/settings.mjs +53 -58
  139. package/src/utils/addons/compare.mjs +31 -32
  140. package/src/utils/addons/diffs/index.mjs +16 -17
  141. package/src/utils/addons/diffs/options.mjs +99 -101
  142. package/src/utils/addons/prepare.mjs +100 -97
  143. package/src/utils/addons/prompts.mjs +73 -76
  144. package/src/utils/addons/render.mjs +33 -36
  145. package/src/utils/addons/validation.mjs +19 -15
  146. package/src/utils/banner.mjs +11 -16
  147. package/src/utils/build-info.mjs +65 -66
  148. package/src/utils/command-helpers.mjs +185 -199
  149. package/src/utils/create-deferred.mjs +9 -12
  150. package/src/utils/create-stream-promise.mjs +54 -47
  151. package/src/utils/deploy/constants.mjs +9 -11
  152. package/src/utils/deploy/deploy-site.mjs +162 -182
  153. package/src/utils/deploy/hash-config.mjs +21 -21
  154. package/src/utils/deploy/hash-files.mjs +34 -38
  155. package/src/utils/deploy/hash-fns.mjs +149 -154
  156. package/src/utils/deploy/hasher-segments.mjs +58 -52
  157. package/src/utils/deploy/upload-files.mjs +99 -113
  158. package/src/utils/deploy/util.mjs +85 -91
  159. package/src/utils/detect-server-settings.mjs +236 -268
  160. package/src/utils/dev.mjs +163 -178
  161. package/src/utils/dot-env.mjs +37 -42
  162. package/src/utils/env/index.mjs +148 -148
  163. package/src/utils/execa.mjs +9 -13
  164. package/src/utils/feature-flags.mjs +6 -5
  165. package/src/utils/framework-server.mjs +43 -52
  166. package/src/utils/functions/constants.mjs +1 -1
  167. package/src/utils/functions/functions.mjs +30 -40
  168. package/src/utils/functions/get-functions.mjs +28 -29
  169. package/src/utils/functions/index.mjs +3 -3
  170. package/src/utils/get-global-config.mjs +33 -36
  171. package/src/utils/get-package-json.mjs +14 -15
  172. package/src/utils/get-repo-data.mjs +54 -64
  173. package/src/utils/get-site.mjs +14 -14
  174. package/src/utils/gh-auth.mjs +79 -100
  175. package/src/utils/gitignore.mjs +37 -40
  176. package/src/utils/headers.mjs +33 -35
  177. package/src/utils/hooks/requires-site-info.mjs +26 -22
  178. package/src/utils/init/config-github.mjs +207 -219
  179. package/src/utils/init/config-manual.mjs +83 -100
  180. package/src/utils/init/config.mjs +25 -26
  181. package/src/utils/init/node-version.mjs +23 -30
  182. package/src/utils/init/plugins.mjs +12 -8
  183. package/src/utils/init/utils.mjs +152 -172
  184. package/src/utils/live-tunnel.mjs +118 -141
  185. package/src/utils/lm/install.mjs +220 -259
  186. package/src/utils/lm/requirements.mjs +54 -63
  187. package/src/utils/lm/steps.mjs +31 -31
  188. package/src/utils/lm/ui.mjs +13 -20
  189. package/src/utils/open-browser.mjs +31 -32
  190. package/src/utils/parse-raw-flags.mjs +39 -35
  191. package/src/utils/proxy-server.mjs +84 -71
  192. package/src/utils/proxy.mjs +696 -750
  193. package/src/utils/read-repo-url.mjs +48 -47
  194. package/src/utils/redirects.mjs +49 -49
  195. package/src/utils/request-id.mjs +2 -4
  196. package/src/utils/rules-proxy.mjs +96 -100
  197. package/src/utils/run-build.mjs +109 -132
  198. package/src/utils/shell.mjs +99 -106
  199. package/src/utils/sign-redirect.mjs +14 -14
  200. package/src/utils/sites/utils.mjs +48 -55
  201. package/src/utils/state-config.mjs +101 -101
  202. package/src/utils/static-server.mjs +28 -34
  203. package/src/utils/telemetry/index.mjs +2 -2
  204. package/src/utils/telemetry/report-error.mjs +45 -49
  205. package/src/utils/telemetry/request.mjs +36 -43
  206. package/src/utils/telemetry/telemetry.mjs +90 -105
  207. package/src/utils/telemetry/utils.mjs +5 -6
  208. package/src/utils/telemetry/validation.mjs +55 -53
  209. package/src/utils/types.d.ts +46 -0
  210. package/src/utils/validation.mjs +10 -13
@@ -1,106 +1,90 @@
1
- // @ts-check
2
- import { join } from 'path'
3
-
4
- import { DenoBridge } from '@netlify/edge-bundler'
5
- import execa from 'execa'
6
- import inquirer from 'inquirer'
7
-
8
- import { NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log } from '../../utils/command-helpers.mjs'
9
-
10
- import { applySettings, getSettings, writeSettings } from './settings.mjs'
11
-
12
- export const description = 'Create VS Code settings for an optimal experience with Netlify projects'
13
-
1
+ import { join } from 'path';
2
+ import { DenoBridge } from '@netlify/edge-bundler';
3
+ import execa from 'execa';
4
+ import inquirer from 'inquirer';
5
+ import { NETLIFYDEVLOG, NETLIFYDEVWARN, chalk, error, log } from '../../utils/command-helpers.mjs';
6
+ import { applySettings, getSettings, writeSettings } from './settings.mjs';
7
+ export const description = 'Create VS Code settings for an optimal experience with Netlify projects';
8
+ // @ts-expect-error TS(7031) FIXME: Binding element 'fileExists' implicitly has an 'an... Remove this comment to see the full error message
14
9
  const getPrompt = ({ fileExists, path }) => {
15
- const formattedPath = chalk.underline(path)
16
- const message = fileExists
17
- ? `There is a VS Code settings file at ${formattedPath}. Can we update it?`
18
- : `A new VS Code settings file will be created at ${formattedPath}`
19
-
20
- return inquirer.prompt({
21
- type: 'confirm',
22
- name: 'confirm',
23
- message,
24
- default: true,
25
- })
26
- }
27
-
28
- const getEdgeFunctionsPath = ({ config, repositoryRoot }) =>
29
- config.build.edge_functions || join(repositoryRoot, 'netlify', 'edge-functions')
30
-
10
+ const formattedPath = chalk.underline(path);
11
+ const message = fileExists
12
+ ? `There is a VS Code settings file at ${formattedPath}. Can we update it?`
13
+ : `A new VS Code settings file will be created at ${formattedPath}`;
14
+ return inquirer.prompt({
15
+ type: 'confirm',
16
+ name: 'confirm',
17
+ message,
18
+ default: true,
19
+ });
20
+ };
21
+ // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
22
+ const getEdgeFunctionsPath = ({ config, repositoryRoot }) => config.build.edge_functions || join(repositoryRoot, 'netlify', 'edge-functions');
31
23
  /**
32
24
  * @param {string} repositoryRoot
33
25
  */
34
- const getSettingsPath = (repositoryRoot) => join(repositoryRoot, '.vscode', 'settings.json')
35
-
26
+ // @ts-expect-error TS(7006) FIXME: Parameter 'repositoryRoot' implicitly has an 'any'... Remove this comment to see the full error message
27
+ const getSettingsPath = (repositoryRoot) => join(repositoryRoot, '.vscode', 'settings.json');
36
28
  /**
37
29
  * @param {string} repositoryRoot
38
30
  */
31
+ // @ts-expect-error TS(7006) FIXME: Parameter 'repositoryRoot' implicitly has an 'any'... Remove this comment to see the full error message
39
32
  const hasDenoVSCodeExt = async (repositoryRoot) => {
40
- const { stdout: extensions } = await execa('code', ['--list-extensions'], { stderr: 'inherit', cwd: repositoryRoot })
41
- return extensions.split('\n').includes('denoland.vscode-deno')
42
- }
43
-
33
+ const { stdout: extensions } = await execa('code', ['--list-extensions'], { stderr: 'inherit', cwd: repositoryRoot });
34
+ return extensions.split('\n').includes('denoland.vscode-deno');
35
+ };
44
36
  /**
45
37
  * @param {string} repositoryRoot
46
38
  */
39
+ // @ts-expect-error TS(7006) FIXME: Parameter 'repositoryRoot' implicitly has an 'any'... Remove this comment to see the full error message
47
40
  const getDenoVSCodeExt = async (repositoryRoot) => {
48
- await execa('code', ['--install-extension', 'denoland.vscode-deno'], { stdio: 'inherit', cwd: repositoryRoot })
49
- }
50
-
41
+ await execa('code', ['--install-extension', 'denoland.vscode-deno'], { stdio: 'inherit', cwd: repositoryRoot });
42
+ };
51
43
  const getDenoExtPrompt = () => {
52
- const message = 'The Deno VS Code extension is recommended. Would you like to install it now?'
53
-
54
- return inquirer.prompt({
55
- type: 'confirm',
56
- name: 'confirm',
57
- message,
58
- default: true,
59
- })
60
- }
61
-
44
+ const message = 'The Deno VS Code extension is recommended. Would you like to install it now?';
45
+ return inquirer.prompt({
46
+ type: 'confirm',
47
+ name: 'confirm',
48
+ message,
49
+ default: true,
50
+ });
51
+ };
62
52
  /**
63
53
  * @param {object} params
64
54
  * @param {*} params.config
65
55
  * @param {string} params.repositoryRoot
66
56
  * @returns
67
57
  */
58
+ // @ts-expect-error TS(7031) FIXME: Binding element 'config' implicitly has an 'any' t... Remove this comment to see the full error message
68
59
  export const run = async ({ config, repositoryRoot }) => {
69
- const deno = new DenoBridge({
70
- onBeforeDownload: () =>
71
- log(`${NETLIFYDEVWARN} Setting up the Edge Functions environment. This may take a couple of minutes.`),
72
- })
73
- const denoBinary = await deno.getBinaryPath()
74
- const settingsPath = getSettingsPath(repositoryRoot)
75
- const edgeFunctionsPath = getEdgeFunctionsPath({ config, repositoryRoot })
76
- const { fileExists, settings: existingSettings } = await getSettings(settingsPath)
77
- const settings = applySettings(existingSettings, { denoBinary, edgeFunctionsPath, repositoryRoot })
78
- const { confirm } = await getPrompt({ fileExists, path: settingsPath })
79
-
80
- if (!confirm) {
81
- return
82
- }
83
-
84
- try {
85
- if (!(await hasDenoVSCodeExt(repositoryRoot))) {
86
- const { confirm: denoExtConfirm } = await getDenoExtPrompt()
87
- if (denoExtConfirm) {
88
- getDenoVSCodeExt(repositoryRoot)
89
- }
60
+ const deno = new DenoBridge({
61
+ onBeforeDownload: () => log(`${NETLIFYDEVWARN} Setting up the Edge Functions environment. This may take a couple of minutes.`),
62
+ });
63
+ const denoBinary = await deno.getBinaryPath();
64
+ const settingsPath = getSettingsPath(repositoryRoot);
65
+ const edgeFunctionsPath = getEdgeFunctionsPath({ config, repositoryRoot });
66
+ const { fileExists, settings: existingSettings } = await getSettings(settingsPath);
67
+ const settings = applySettings(existingSettings, { denoBinary, edgeFunctionsPath, repositoryRoot });
68
+ const { confirm } = await getPrompt({ fileExists, path: settingsPath });
69
+ if (!confirm) {
70
+ return;
90
71
  }
91
- } catch {
92
- log(
93
- `${NETLIFYDEVWARN} Unable to install Deno VS Code extension. To install it manually, visit ${chalk.blue(
94
- 'https://ntl.fyi/deno-vscode',
95
- )}.`,
96
- )
97
- }
98
-
99
- try {
100
- await writeSettings({ settings, settingsPath })
101
-
102
- log(`${NETLIFYDEVLOG} VS Code settings file ${fileExists ? 'updated' : 'created'}.`)
103
- } catch {
104
- error('Could not write VS Code settings file.')
105
- }
106
- }
72
+ try {
73
+ if (!(await hasDenoVSCodeExt(repositoryRoot))) {
74
+ const { confirm: denoExtConfirm } = await getDenoExtPrompt();
75
+ if (denoExtConfirm) {
76
+ getDenoVSCodeExt(repositoryRoot);
77
+ }
78
+ }
79
+ }
80
+ catch {
81
+ log(`${NETLIFYDEVWARN} Unable to install Deno VS Code extension. To install it manually, visit ${chalk.blue('https://ntl.fyi/deno-vscode')}.`);
82
+ }
83
+ try {
84
+ await writeSettings({ settings, settingsPath });
85
+ log(`${NETLIFYDEVLOG} VS Code settings file ${fileExists ? 'updated' : 'created'}.`);
86
+ }
87
+ catch {
88
+ error('Could not write VS Code settings file.');
89
+ }
90
+ };
@@ -1,65 +1,60 @@
1
- import { mkdir, readFile, stat, writeFile } from 'fs/promises'
2
- import { dirname, relative } from 'path'
3
-
1
+ import { mkdir, readFile, stat, writeFile } from 'fs/promises';
2
+ import { dirname, relative } from 'path';
4
3
  // eslint-disable-next-line import/no-namespace
5
- import * as JSONC from 'comment-json'
6
- import unixify from 'unixify'
7
-
4
+ import * as JSONC from 'comment-json';
5
+ // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'unix... Remove this comment to see the full error message
6
+ import unixify from 'unixify';
7
+ // @ts-expect-error TS(7006) FIXME: Parameter 'existingSettings' implicitly has an 'an... Remove this comment to see the full error message
8
8
  export const applySettings = (existingSettings, { denoBinary, edgeFunctionsPath, repositoryRoot }) => {
9
- const relativeEdgeFunctionsPath = unixify(relative(repositoryRoot, edgeFunctionsPath))
10
- const settings = JSONC.assign(existingSettings, {
11
- 'deno.enable': true,
12
- 'deno.enablePaths': existingSettings['deno.enablePaths'] || [],
13
- 'deno.unstable': true,
14
- 'deno.importMap': '.netlify/edge-functions-import-map.json',
15
- })
16
-
17
- // If the Edge Functions path isn't already in `deno.enabledPaths`, let's add
18
- // it.
19
- if (!settings['deno.enablePaths'].includes(relativeEdgeFunctionsPath)) {
20
- settings['deno.enablePaths'].push(relativeEdgeFunctionsPath)
21
- }
22
-
23
- // If the Deno CLI binary isn't globally installed, we need to set the path
24
- // to it in the settings file or the extension won't know where to find it.
25
- // The only exception is when `deno.path` has already been defined, because
26
- // we don't want to override that.
27
- if (!denoBinary.global && settings['deno.path'] === undefined) {
28
- settings['deno.path'] = denoBinary.path
29
- }
30
-
31
- return settings
32
- }
33
-
34
- export const getSettings = async (settingsPath) => {
35
- try {
36
- const stats = await stat(settingsPath)
37
-
38
- if (!stats.isFile()) {
39
- throw new Error(`${settingsPath} is not a valid file.`)
9
+ const relativeEdgeFunctionsPath = unixify(relative(repositoryRoot, edgeFunctionsPath));
10
+ const settings = JSONC.assign(existingSettings, {
11
+ 'deno.enable': true,
12
+ 'deno.enablePaths': existingSettings['deno.enablePaths'] || [],
13
+ 'deno.unstable': true,
14
+ 'deno.importMap': '.netlify/edge-functions-import-map.json',
15
+ });
16
+ // If the Edge Functions path isn't already in `deno.enabledPaths`, let's add
17
+ // it.
18
+ if (!settings['deno.enablePaths'].includes(relativeEdgeFunctionsPath)) {
19
+ settings['deno.enablePaths'].push(relativeEdgeFunctionsPath);
40
20
  }
41
-
42
- const file = await readFile(settingsPath, 'utf8')
43
-
44
- return {
45
- fileExists: true,
46
- settings: JSONC.parse(file),
21
+ // If the Deno CLI binary isn't globally installed, we need to set the path
22
+ // to it in the settings file or the extension won't know where to find it.
23
+ // The only exception is when `deno.path` has already been defined, because
24
+ // we don't want to override that.
25
+ if (!denoBinary.global && settings['deno.path'] === undefined) {
26
+ settings['deno.path'] = denoBinary.path;
47
27
  }
48
- } catch (error) {
49
- if (error.code !== 'ENOENT') {
50
- throw new Error(`Could not open VS Code settings file: ${error.message}`)
28
+ return settings;
29
+ };
30
+ // @ts-expect-error TS(7006) FIXME: Parameter 'settingsPath' implicitly has an 'any' t... Remove this comment to see the full error message
31
+ export const getSettings = async (settingsPath) => {
32
+ try {
33
+ const stats = await stat(settingsPath);
34
+ if (!stats.isFile()) {
35
+ throw new Error(`${settingsPath} is not a valid file.`);
36
+ }
37
+ const file = await readFile(settingsPath, 'utf8');
38
+ return {
39
+ fileExists: true,
40
+ settings: JSONC.parse(file),
41
+ };
51
42
  }
52
-
53
- return {
54
- fileExists: false,
55
- settings: {},
43
+ catch (error) {
44
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
45
+ if (error.code !== 'ENOENT') {
46
+ // @ts-expect-error TS(2571) FIXME: Object is of type 'unknown'.
47
+ throw new Error(`Could not open VS Code settings file: ${error.message}`);
48
+ }
49
+ return {
50
+ fileExists: false,
51
+ settings: {},
52
+ };
56
53
  }
57
- }
58
- }
59
-
54
+ };
55
+ // @ts-expect-error TS(7031) FIXME: Binding element 'settings' implicitly has an 'any'... Remove this comment to see the full error message
60
56
  export const writeSettings = async ({ settings, settingsPath }) => {
61
- const serializedSettings = JSONC.stringify(settings, null, 2)
62
-
63
- await mkdir(dirname(settingsPath), { recursive: true })
64
- await writeFile(settingsPath, serializedSettings)
65
- }
57
+ const serializedSettings = JSONC.stringify(settings, null, 2);
58
+ await mkdir(dirname(settingsPath), { recursive: true });
59
+ await writeFile(settingsPath, serializedSettings);
60
+ };
@@ -1,34 +1,33 @@
1
- import isEqual from 'lodash/isEqual.js'
2
-
1
+ import isEqual from 'lodash/isEqual.js';
2
+ // @ts-expect-error TS(7006) FIXME: Parameter 'oldValues' implicitly has an 'any' type... Remove this comment to see the full error message
3
3
  export default function compare(oldValues, newValues) {
4
- const initialData = {
5
- // default everything is equal
6
- isEqual: true,
7
- // Keys that are different
8
- keys: [],
9
- // Values of the keys that are different
10
- diffs: {},
11
- }
12
-
13
- const oldKeys = Object.keys(oldValues)
14
- const newKeys = Object.keys(newValues)
15
- const set = new Set([...newKeys, ...oldKeys])
16
-
17
- return [...set].reduce((acc, current) => {
18
- // if values not deep equal. There are changes
19
- if (!isEqual(newValues[current], oldValues[current])) {
20
- return {
21
- isEqual: false,
22
- keys: [...acc.keys, current],
23
- diffs: {
24
- ...acc.diffs,
25
- [`${current}`]: {
26
- newValue: newValues[current],
27
- oldValue: oldValues[current],
28
- },
29
- },
30
- }
31
- }
32
- return acc
33
- }, initialData)
4
+ const initialData = {
5
+ // default everything is equal
6
+ isEqual: true,
7
+ // Keys that are different
8
+ keys: [],
9
+ // Values of the keys that are different
10
+ diffs: {},
11
+ };
12
+ const oldKeys = Object.keys(oldValues);
13
+ const newKeys = Object.keys(newValues);
14
+ const set = new Set([...newKeys, ...oldKeys]);
15
+ // @ts-expect-error TS(2769) FIXME: No overload matches this call.
16
+ return [...set].reduce((acc, current) => {
17
+ // if values not deep equal. There are changes
18
+ if (!isEqual(newValues[current], oldValues[current])) {
19
+ return {
20
+ isEqual: false,
21
+ keys: [...acc.keys, current],
22
+ diffs: {
23
+ ...acc.diffs,
24
+ [`${current}`]: {
25
+ newValue: newValues[current],
26
+ oldValue: oldValues[current],
27
+ },
28
+ },
29
+ };
30
+ }
31
+ return acc;
32
+ }, initialData);
34
33
  }
@@ -1,20 +1,19 @@
1
- // @ts-check
2
- import concordance from 'concordance'
3
-
4
- import { concordanceDiffOptions, concordanceOptions } from './options.mjs'
5
-
1
+ // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'conc... Remove this comment to see the full error message
2
+ import concordance from 'concordance';
3
+ import { concordanceDiffOptions, concordanceOptions } from './options.mjs';
4
+ // @ts-expect-error TS(7006) FIXME: Parameter 'actualDescriptor' implicitly has an 'an... Remove this comment to see the full error message
6
5
  const formatDescriptorDiff = function (actualDescriptor, expectedDescriptor, options) {
7
- const diffOptions = { ...options, ...concordanceDiffOptions }
8
- return concordance.diffDescriptors(actualDescriptor, expectedDescriptor, diffOptions)
9
- }
10
-
6
+ const diffOptions = { ...options, ...concordanceDiffOptions };
7
+ return concordance.diffDescriptors(actualDescriptor, expectedDescriptor, diffOptions);
8
+ };
9
+ // @ts-expect-error TS(7006) FIXME: Parameter 'actual' implicitly has an 'any' type.
11
10
  export default function diffValues(actual, expected) {
12
- const result = concordance.compare(actual, expected, concordanceOptions)
13
- if (result.pass) {
14
- return null
15
- }
16
- const actualDescriptor = result.actual || concordance.describe(actual, concordanceOptions)
17
- const expectedDescriptor = result.expected || concordance.describe(expected, concordanceOptions)
18
-
19
- return formatDescriptorDiff(actualDescriptor, expectedDescriptor)
11
+ const result = concordance.compare(actual, expected, concordanceOptions);
12
+ if (result.pass) {
13
+ return null;
14
+ }
15
+ const actualDescriptor = result.actual || concordance.describe(actual, concordanceOptions);
16
+ const expectedDescriptor = result.expected || concordance.describe(expected, concordanceOptions);
17
+ // @ts-expect-error TS(2554) FIXME: Expected 3 arguments, but got 2.
18
+ return formatDescriptorDiff(actualDescriptor, expectedDescriptor);
20
19
  }
@@ -1,108 +1,106 @@
1
- // @ts-check
2
- import ansiStyles from 'ansi-styles'
1
+ import ansiStyles from 'ansi-styles';
3
2
  // eslint-disable-next-line no-restricted-imports
4
- import { Chalk } from 'chalk'
5
-
6
- const forceColor = new Chalk({ level: 1 })
7
-
3
+ import { Chalk } from 'chalk';
4
+ const forceColor = new Chalk({ level: 1 });
8
5
  const colorTheme = {
9
- boolean: ansiStyles.yellow,
10
- circular: forceColor.grey('[Circular]'),
11
- date: {
12
- invalid: forceColor.red('invalid'),
13
- value: ansiStyles.blue,
14
- },
15
- diffGutters: {
16
- actual: `${forceColor.red('-')} `,
17
- expected: `${forceColor.green('+')} `,
18
- padding: ' ',
19
- },
20
- error: {
21
- ctor: {
22
- open: `${ansiStyles.grey.open}(`,
23
- close: `)${ansiStyles.grey.close}`,
6
+ boolean: ansiStyles.yellow,
7
+ circular: forceColor.grey('[Circular]'),
8
+ date: {
9
+ invalid: forceColor.red('invalid'),
10
+ value: ansiStyles.blue,
24
11
  },
25
- name: ansiStyles.magenta,
26
- },
27
- function: {
28
- name: ansiStyles.blue,
29
- stringTag: ansiStyles.magenta,
30
- },
31
- global: ansiStyles.magenta,
32
- item: {
33
- after: forceColor.grey(','),
34
- },
35
- list: {
36
- openBracket: forceColor.grey('['),
37
- closeBracket: forceColor.grey(']'),
38
- },
39
- mapEntry: {
40
- after: forceColor.grey(','),
41
- },
42
- maxDepth: forceColor.grey('…'),
43
- null: ansiStyles.yellow,
44
- number: ansiStyles.yellow,
45
- object: {
46
- openBracket: forceColor.grey('{'),
47
- closeBracket: forceColor.grey('}'),
48
- ctor: ansiStyles.magenta,
49
- stringTag: {
50
- open: `${ansiStyles.magenta.open}@`,
51
- close: ansiStyles.magenta.close,
12
+ diffGutters: {
13
+ actual: `${forceColor.red('-')} `,
14
+ expected: `${forceColor.green('+')} `,
15
+ padding: ' ',
52
16
  },
53
- secondaryStringTag: {
54
- open: `${ansiStyles.grey.open}@`,
55
- close: ansiStyles.grey.close,
17
+ error: {
18
+ ctor: {
19
+ open: `${ansiStyles.grey.open}(`,
20
+ close: `)${ansiStyles.grey.close}`,
21
+ },
22
+ name: ansiStyles.magenta,
56
23
  },
57
- },
58
- property: {
59
- after: forceColor.grey(','),
60
- keyBracket: { open: forceColor.grey('['), close: forceColor.grey(']') },
61
- valueFallback: forceColor.grey('…'),
62
- },
63
- regexp: {
64
- source: {
65
- open: `${ansiStyles.blue.open}/`,
66
- close: `/${ansiStyles.blue.close}`,
24
+ function: {
25
+ name: ansiStyles.blue,
26
+ stringTag: ansiStyles.magenta,
67
27
  },
68
- flags: ansiStyles.yellow,
69
- },
70
- stats: { separator: forceColor.grey('---') },
71
- string: {
72
- open: ansiStyles.white.open,
73
- close: ansiStyles.white.close,
74
- line: { open: forceColor.white("'"), close: forceColor.white("'") },
75
- multiline: { start: forceColor.white('`'), end: forceColor.white('`') },
76
- controlPicture: ansiStyles.grey,
77
- diff: {
78
- insert: {
79
- open: ansiStyles.bgGreen.open + ansiStyles.black.open,
80
- close: ansiStyles.black.close + ansiStyles.bgGreen.close,
81
- },
82
- delete: {
83
- open: ansiStyles.bgRed.open + ansiStyles.black.open,
84
- close: ansiStyles.black.close + ansiStyles.bgRed.close,
85
- },
86
- equal: ansiStyles.white,
87
- insertLine: {
88
- open: ansiStyles.green.open,
89
- close: ansiStyles.green.close,
90
- },
91
- deleteLine: {
92
- open: ansiStyles.red.open,
93
- close: ansiStyles.red.close,
94
- },
28
+ global: ansiStyles.magenta,
29
+ item: {
30
+ after: forceColor.grey(','),
95
31
  },
96
- },
97
- symbol: ansiStyles.yellow,
98
- typedArray: {
99
- bytes: ansiStyles.yellow,
100
- },
101
- undefined: ansiStyles.yellow,
102
- }
103
-
104
- const plugins = []
105
- const theme = colorTheme
106
-
107
- export const concordanceOptions = { maxDepth: 3, plugins, theme }
108
- export const concordanceDiffOptions = { maxDepth: 1, plugins, theme }
32
+ list: {
33
+ openBracket: forceColor.grey('['),
34
+ closeBracket: forceColor.grey(']'),
35
+ },
36
+ mapEntry: {
37
+ after: forceColor.grey(','),
38
+ },
39
+ maxDepth: forceColor.grey('…'),
40
+ null: ansiStyles.yellow,
41
+ number: ansiStyles.yellow,
42
+ object: {
43
+ openBracket: forceColor.grey('{'),
44
+ closeBracket: forceColor.grey('}'),
45
+ ctor: ansiStyles.magenta,
46
+ stringTag: {
47
+ open: `${ansiStyles.magenta.open}@`,
48
+ close: ansiStyles.magenta.close,
49
+ },
50
+ secondaryStringTag: {
51
+ open: `${ansiStyles.grey.open}@`,
52
+ close: ansiStyles.grey.close,
53
+ },
54
+ },
55
+ property: {
56
+ after: forceColor.grey(','),
57
+ keyBracket: { open: forceColor.grey('['), close: forceColor.grey(']') },
58
+ valueFallback: forceColor.grey('…'),
59
+ },
60
+ regexp: {
61
+ source: {
62
+ open: `${ansiStyles.blue.open}/`,
63
+ close: `/${ansiStyles.blue.close}`,
64
+ },
65
+ flags: ansiStyles.yellow,
66
+ },
67
+ stats: { separator: forceColor.grey('---') },
68
+ string: {
69
+ open: ansiStyles.white.open,
70
+ close: ansiStyles.white.close,
71
+ line: { open: forceColor.white("'"), close: forceColor.white("'") },
72
+ multiline: { start: forceColor.white('`'), end: forceColor.white('`') },
73
+ controlPicture: ansiStyles.grey,
74
+ diff: {
75
+ insert: {
76
+ open: ansiStyles.bgGreen.open + ansiStyles.black.open,
77
+ close: ansiStyles.black.close + ansiStyles.bgGreen.close,
78
+ },
79
+ delete: {
80
+ open: ansiStyles.bgRed.open + ansiStyles.black.open,
81
+ close: ansiStyles.black.close + ansiStyles.bgRed.close,
82
+ },
83
+ equal: ansiStyles.white,
84
+ insertLine: {
85
+ open: ansiStyles.green.open,
86
+ close: ansiStyles.green.close,
87
+ },
88
+ deleteLine: {
89
+ open: ansiStyles.red.open,
90
+ close: ansiStyles.red.close,
91
+ },
92
+ },
93
+ },
94
+ symbol: ansiStyles.yellow,
95
+ typedArray: {
96
+ bytes: ansiStyles.yellow,
97
+ },
98
+ undefined: ansiStyles.yellow,
99
+ };
100
+ // @ts-expect-error TS(7034) FIXME: Variable 'plugins' implicitly has type 'any[]' in ... Remove this comment to see the full error message
101
+ const plugins = [];
102
+ const theme = colorTheme;
103
+ // @ts-expect-error TS(7005) FIXME: Variable 'plugins' implicitly has an 'any[]' type.
104
+ export const concordanceOptions = { maxDepth: 3, plugins, theme };
105
+ // @ts-expect-error TS(7005) FIXME: Variable 'plugins' implicitly has an 'any[]' type.
106
+ export const concordanceDiffOptions = { maxDepth: 1, plugins, theme };