netlify-cli 17.3.2 → 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 +2 -138
  2. package/npm-shrinkwrap.json +76 -76
  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 -99
  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,48 +1,40 @@
1
- // @ts-check
2
- import { promises as fs } from 'fs'
3
- import path, { join } from 'path'
4
-
5
- import { getBootstrapURL } from '../lib/edge-functions/bootstrap.mjs'
6
- import { INTERNAL_EDGE_FUNCTIONS_FOLDER } from '../lib/edge-functions/consts.mjs'
7
- import { getPathInProject } from '../lib/settings.mjs'
8
-
9
- import { error } from './command-helpers.mjs'
10
- import { startFrameworkServer } from './framework-server.mjs'
11
- import { INTERNAL_FUNCTIONS_FOLDER } from './functions/index.mjs'
12
-
13
- const netlifyBuildPromise = import('@netlify/build')
14
-
1
+ import { promises as fs } from 'fs';
2
+ import path, { join } from 'path';
3
+ import { getBootstrapURL } from '../lib/edge-functions/bootstrap.mjs';
4
+ import { INTERNAL_EDGE_FUNCTIONS_FOLDER } from '../lib/edge-functions/consts.mjs';
5
+ import { getPathInProject } from '../lib/settings.mjs';
6
+ import { error } from './command-helpers.mjs';
7
+ import { startFrameworkServer } from './framework-server.mjs';
8
+ import { INTERNAL_FUNCTIONS_FOLDER } from './functions/index.mjs';
9
+ const netlifyBuildPromise = import('@netlify/build');
15
10
  /**
16
11
  * Copies `netlify.toml`, if one is defined, into the `.netlify` internal
17
12
  * directory and returns the path to its new location.
18
13
  * @param {string} configPath
19
14
  * @param {string} destinationFolder The folder where it should be copied to. Either the root of the repo or a package inside a monorepo
20
15
  */
16
+ // @ts-expect-error TS(7006) FIXME: Parameter 'configPath' implicitly has an 'any' typ... Remove this comment to see the full error message
21
17
  const copyConfig = async (configPath, destinationFolder) => {
22
- const newConfigPath = path.resolve(destinationFolder, getPathInProject(['netlify.toml']))
23
-
24
- try {
25
- await fs.copyFile(configPath, newConfigPath)
26
- } catch {
27
- // no-op
28
- }
29
-
30
- return newConfigPath
31
- }
32
-
18
+ const newConfigPath = path.resolve(destinationFolder, getPathInProject(['netlify.toml']));
19
+ try {
20
+ await fs.copyFile(configPath, newConfigPath);
21
+ }
22
+ catch {
23
+ // no-op
24
+ }
25
+ return newConfigPath;
26
+ };
33
27
  /**
34
28
  * @param {string} basePath
35
29
  */
30
+ // @ts-expect-error TS(7006) FIXME: Parameter 'basePath' implicitly has an 'any' type.
36
31
  const cleanInternalDirectory = async (basePath) => {
37
- const ops = [INTERNAL_FUNCTIONS_FOLDER, INTERNAL_EDGE_FUNCTIONS_FOLDER, 'netlify.toml'].map((name) => {
38
- const fullPath = path.resolve(basePath, getPathInProject([name]))
39
-
40
- return fs.rm(fullPath, { force: true, recursive: true })
41
- })
42
-
43
- await Promise.all(ops)
44
- }
45
-
32
+ const ops = [INTERNAL_FUNCTIONS_FOLDER, INTERNAL_EDGE_FUNCTIONS_FOLDER, 'netlify.toml'].map((name) => {
33
+ const fullPath = path.resolve(basePath, getPathInProject([name]));
34
+ return fs.rm(fullPath, { force: true, recursive: true });
35
+ });
36
+ await Promise.all(ops);
37
+ };
46
38
  /**
47
39
  * @param {object} params
48
40
  * @param {import('../commands/base-command.mjs').default} params.command
@@ -53,110 +45,95 @@ const cleanInternalDirectory = async (basePath) => {
53
45
  * @param {'build' | 'dev'} [params.timeline]
54
46
  * @returns
55
47
  */
48
+ // @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message
56
49
  export const runNetlifyBuild = async ({ command, env = {}, options, settings, timeline = 'build' }) => {
57
- const { cachedConfig, site } = command.netlify
58
-
59
- const { default: buildSite, startDev } = await netlifyBuildPromise
60
-
61
- const sharedOptions = {
62
- cachedConfig,
63
- configPath: cachedConfig.configPath,
64
- siteId: cachedConfig.siteInfo.id,
65
- token: cachedConfig.token,
66
- dry: options.dry,
67
- debug: options.debug,
68
- context: options.context,
69
- mode: 'cli',
70
- telemetry: false,
71
- buffer: false,
72
- offline: options.offline,
73
- packagePath: command.workspacePackage,
74
- cwd: cachedConfig.buildDir,
75
- quiet: options.quiet,
76
- saveConfig: options.saveConfig,
77
- edgeFunctionsBootstrapURL: getBootstrapURL(),
78
- }
79
-
80
- const devCommand = async (settingsOverrides = {}) => {
81
- let cwd = command.workingDir
82
-
83
- if (!options.cwd && command.project.workspace?.packages.length) {
84
- cwd = join(command.project.jsWorkspaceRoot, settings.baseDirectory || '')
85
- }
86
-
87
- const { ipVersion } = await startFrameworkServer({
88
- settings: {
89
- ...settings,
90
- ...settingsOverrides,
91
- },
92
- cwd,
93
- })
94
-
95
- settings.frameworkHost = ipVersion === 6 ? '::1' : '127.0.0.1'
96
- }
97
-
98
- if (timeline === 'build') {
99
- // Start by cleaning the internal directory, as it may have artifacts left
100
- // by previous builds.
101
- await cleanInternalDirectory(site.root)
102
-
103
- // Copy `netlify.toml` into the internal directory. This will be the new
104
- // location of the config file for the duration of the command.
105
- const tempConfigPath = await copyConfig(cachedConfig.configPath, command.workingDir)
106
- const buildSiteOptions = {
107
- ...sharedOptions,
108
- outputConfigPath: tempConfigPath,
109
- saveConfig: true,
110
- }
111
-
112
- // Run Netlify Build using the main entry point.
113
- const { netlifyConfig, success } = await buildSite(buildSiteOptions)
114
-
115
- if (!success) {
116
- error('Could not start local server due to a build error')
117
-
118
- return {}
119
- }
120
-
121
- // Start the dev server, forcing the usage of a static server as opposed to
122
- // the framework server.
123
- const settingsOverrides = {
124
- command: undefined,
125
- useStaticServer: true,
50
+ const { cachedConfig, site } = command.netlify;
51
+ const { default: buildSite, startDev } = await netlifyBuildPromise;
52
+ const sharedOptions = {
53
+ cachedConfig,
54
+ configPath: cachedConfig.configPath,
55
+ siteId: cachedConfig.siteInfo.id,
56
+ token: cachedConfig.token,
57
+ dry: options.dry,
58
+ debug: options.debug,
59
+ context: options.context,
60
+ mode: 'cli',
61
+ telemetry: false,
62
+ buffer: false,
63
+ offline: options.offline,
64
+ packagePath: command.workspacePackage,
65
+ cwd: cachedConfig.buildDir,
66
+ quiet: options.quiet,
67
+ saveConfig: options.saveConfig,
68
+ edgeFunctionsBootstrapURL: getBootstrapURL(),
69
+ };
70
+ const devCommand = async (settingsOverrides = {}) => {
71
+ let cwd = command.workingDir;
72
+ if (!options.cwd && command.project.workspace?.packages.length) {
73
+ cwd = join(command.project.jsWorkspaceRoot, settings.baseDirectory || '');
74
+ }
75
+ const { ipVersion } = await startFrameworkServer({
76
+ settings: {
77
+ ...settings,
78
+ ...settingsOverrides,
79
+ },
80
+ cwd,
81
+ });
82
+ settings.frameworkHost = ipVersion === 6 ? '::1' : '127.0.0.1';
83
+ };
84
+ if (timeline === 'build') {
85
+ // Start by cleaning the internal directory, as it may have artifacts left
86
+ // by previous builds.
87
+ await cleanInternalDirectory(site.root);
88
+ // Copy `netlify.toml` into the internal directory. This will be the new
89
+ // location of the config file for the duration of the command.
90
+ const tempConfigPath = await copyConfig(cachedConfig.configPath, command.workingDir);
91
+ const buildSiteOptions = {
92
+ ...sharedOptions,
93
+ outputConfigPath: tempConfigPath,
94
+ saveConfig: true,
95
+ };
96
+ // Run Netlify Build using the main entry point.
97
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{ outputConfigPath: string; save... Remove this comment to see the full error message
98
+ const { netlifyConfig, success } = await buildSite(buildSiteOptions);
99
+ if (!success) {
100
+ error('Could not start local server due to a build error');
101
+ return {};
102
+ }
103
+ // Start the dev server, forcing the usage of a static server as opposed to
104
+ // the framework server.
105
+ const settingsOverrides = {
106
+ command: undefined,
107
+ useStaticServer: true,
108
+ dist: undefined,
109
+ };
110
+ if (!options.dir && netlifyConfig?.build?.publish) {
111
+ settingsOverrides.dist = netlifyConfig.build.publish;
112
+ }
113
+ await devCommand(settingsOverrides);
114
+ return { configPath: tempConfigPath };
126
115
  }
127
- if (!options.dir && netlifyConfig?.build?.publish) {
128
- settingsOverrides.dist = netlifyConfig.build.publish
116
+ const startDevOptions = {
117
+ ...sharedOptions,
118
+ // Set `quiet` to suppress non-essential output from Netlify Build unless
119
+ // the `debug` flag is set.
120
+ quiet: !options.debug,
121
+ env,
122
+ };
123
+ // Run Netlify Build using the `startDev` entry point.
124
+ const { error: startDevError, success } = await startDev(devCommand, startDevOptions);
125
+ if (!success && startDevError) {
126
+ error(`Could not start local development server\n\n${startDevError.message}\n\n${startDevError.stack}`);
129
127
  }
130
- await devCommand(settingsOverrides)
131
-
132
- return { configPath: tempConfigPath }
133
- }
134
-
135
- const startDevOptions = {
136
- ...sharedOptions,
137
-
138
- // Set `quiet` to suppress non-essential output from Netlify Build unless
139
- // the `debug` flag is set.
140
- quiet: !options.debug,
141
- env,
142
- }
143
-
144
- // Run Netlify Build using the `startDev` entry point.
145
- const { error: startDevError, success } = await startDev(devCommand, startDevOptions)
146
-
147
- if (!success && startDevError) {
148
- error(`Could not start local development server\n\n${startDevError.message}\n\n${startDevError.stack}`)
149
- }
150
-
151
- return {}
152
- }
153
-
128
+ return {};
129
+ };
154
130
  /**
155
131
  * @param {Omit<Parameters<typeof runNetlifyBuild>[0], 'timeline'>} options
156
132
  */
157
- export const runDevTimeline = (options) => runNetlifyBuild({ ...options, timeline: 'dev' })
158
-
133
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
134
+ export const runDevTimeline = (options) => runNetlifyBuild({ ...options, timeline: 'dev' });
159
135
  /**
160
136
  * @param {Omit<Parameters<typeof runNetlifyBuild>[0], 'timeline'>} options
161
137
  */
162
- export const runBuildTimeline = (options) => runNetlifyBuild({ ...options, timeline: 'build' })
138
+ // @ts-expect-error TS(7006) FIXME: Parameter 'options' implicitly has an 'any' type.
139
+ export const runBuildTimeline = (options) => runNetlifyBuild({ ...options, timeline: 'build' });
@@ -1,42 +1,40 @@
1
- // @ts-check
2
- import process from 'process'
3
-
4
- import execa from 'execa'
5
- import stripAnsiCc from 'strip-ansi-control-characters'
6
-
7
- import { chalk, log, NETLIFYDEVERR, NETLIFYDEVWARN } from './command-helpers.mjs'
8
- import { processOnExit } from './dev.mjs'
9
-
1
+ import process from 'process';
2
+ import execa from 'execa';
3
+ // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'stri... Remove this comment to see the full error message
4
+ import stripAnsiCc from 'strip-ansi-control-characters';
5
+ import { chalk, log, NETLIFYDEVERR, NETLIFYDEVWARN } from './command-helpers.mjs';
6
+ import { processOnExit } from './dev.mjs';
10
7
  /**
11
8
  * @type {(() => Promise<void>)[]} - array of functions to run before the process exits
12
9
  */
13
- const cleanupWork = []
14
-
15
- let cleanupStarted = false
16
-
10
+ // @ts-expect-error TS(7034) FIXME: Variable 'cleanupWork' implicitly has type 'any[]'... Remove this comment to see the full error message
11
+ const cleanupWork = [];
12
+ let cleanupStarted = false;
17
13
  /**
18
14
  * @param {() => Promise<void>} job
19
15
  */
16
+ // @ts-expect-error TS(7006) FIXME: Parameter 'job' implicitly has an 'any' type.
20
17
  export const addCleanupJob = (job) => {
21
- cleanupWork.push(job)
22
- }
23
-
18
+ cleanupWork.push(job);
19
+ };
24
20
  /**
25
21
  * @param {object} input
26
22
  * @param {number=} input.exitCode The exit code to return when exiting the process after cleanup
27
23
  */
24
+ // @ts-expect-error TS(7031) FIXME: Binding element 'exitCode' implicitly has an 'any'... Remove this comment to see the full error message
28
25
  const cleanupBeforeExit = async ({ exitCode }) => {
29
- // If cleanup has started, then wherever started it will be responsible for exiting
30
- if (!cleanupStarted) {
31
- cleanupStarted = true
32
- try {
33
- await Promise.all(cleanupWork.map((cleanup) => cleanup()))
34
- } finally {
35
- process.exit(exitCode)
26
+ // If cleanup has started, then wherever started it will be responsible for exiting
27
+ if (!cleanupStarted) {
28
+ cleanupStarted = true;
29
+ try {
30
+ // @ts-expect-error TS(7005) FIXME: Variable 'cleanupWork' implicitly has an 'any[]' t... Remove this comment to see the full error message
31
+ await Promise.all(cleanupWork.map((cleanup) => cleanup()));
32
+ }
33
+ finally {
34
+ process.exit(exitCode);
35
+ }
36
36
  }
37
- }
38
- }
39
-
37
+ };
40
38
  /**
41
39
  * Run a command and pipe stdout, stderr and stdin
42
40
  * @param {string} command
@@ -46,70 +44,68 @@ const cleanupBeforeExit = async ({ exitCode }) => {
46
44
  * @param {string} [options.cwd]
47
45
  * @returns {execa.ExecaChildProcess<string>}
48
46
  */
47
+ // @ts-expect-error TS(7006) FIXME: Parameter 'command' implicitly has an 'any' type.
49
48
  export const runCommand = (command, options = {}) => {
50
- const { cwd, env = {}, spinner = null } = options
51
- const commandProcess = execa.command(command, {
52
- preferLocal: true,
53
- // we use reject=false to avoid rejecting synchronously when the command doesn't exist
54
- reject: false,
55
- env: {
56
- // we want always colorful terminal outputs
57
- FORCE_COLOR: 'true',
58
- ...env,
59
- },
60
- // windowsHide needs to be false for child process to terminate properly on Windows
61
- windowsHide: false,
62
- cwd,
63
- })
64
-
65
- // This ensures that an active spinner stays at the bottom of the commandline
66
- // even though the actual framework command might be outputting stuff
67
- const pipeDataWithSpinner = (writeStream, chunk) => {
68
- if (spinner && spinner.isSpinning) {
69
- spinner.clear()
70
- spinner.isSilent = true
71
- }
72
- writeStream.write(chunk, () => {
73
- if (spinner && spinner.isSpinning) {
74
- spinner.isSilent = false
75
- spinner.render()
76
- }
77
- })
78
- }
79
-
80
- commandProcess.stdout.pipe(stripAnsiCc.stream()).on('data', pipeDataWithSpinner.bind(null, process.stdout))
81
- commandProcess.stderr.pipe(stripAnsiCc.stream()).on('data', pipeDataWithSpinner.bind(null, process.stderr))
82
- process.stdin.pipe(commandProcess.stdin)
83
-
84
- // we can't try->await->catch since we don't want to block on the framework server which
85
- // is a long running process
86
- // eslint-disable-next-line promise/catch-or-return
87
- commandProcess
88
- // eslint-disable-next-line promise/prefer-await-to-then
89
- .then(async () => {
90
- const result = await commandProcess
91
- const [commandWithoutArgs] = command.split(' ')
92
- if (result.failed && isNonExistingCommandError({ command: commandWithoutArgs, error: result })) {
93
- log(
94
- `${NETLIFYDEVERR} Failed running command: ${command}. Please verify ${chalk.magenta(
95
- `'${commandWithoutArgs}'`,
96
- )} exists`,
97
- )
98
- } else {
99
- const errorMessage = result.failed
100
- ? `${NETLIFYDEVERR} ${result.shortMessage}`
101
- : `${NETLIFYDEVWARN} "${command}" exited with code ${result.exitCode}`
102
-
103
- log(`${errorMessage}. Shutting down Netlify Dev server`)
104
- }
105
-
106
- return await cleanupBeforeExit({ exitCode: 1 })
107
- })
108
- processOnExit(async () => await cleanupBeforeExit({}))
109
-
110
- return commandProcess
111
- }
112
-
49
+ // @ts-expect-error TS(2339) FIXME: Property 'cwd' does not exist on type '{}'.
50
+ const { cwd, env = {}, spinner = null } = options;
51
+ const commandProcess = execa.command(command, {
52
+ preferLocal: true,
53
+ // we use reject=false to avoid rejecting synchronously when the command doesn't exist
54
+ reject: false,
55
+ env: {
56
+ // we want always colorful terminal outputs
57
+ FORCE_COLOR: 'true',
58
+ ...env,
59
+ },
60
+ // windowsHide needs to be false for child process to terminate properly on Windows
61
+ windowsHide: false,
62
+ cwd,
63
+ });
64
+ // This ensures that an active spinner stays at the bottom of the commandline
65
+ // even though the actual framework command might be outputting stuff
66
+ // @ts-expect-error TS(7006) FIXME: Parameter 'writeStream' implicitly has an 'any' ty... Remove this comment to see the full error message
67
+ const pipeDataWithSpinner = (writeStream, chunk) => {
68
+ if (spinner && spinner.isSpinning) {
69
+ spinner.clear();
70
+ spinner.isSilent = true;
71
+ }
72
+ writeStream.write(chunk, () => {
73
+ if (spinner && spinner.isSpinning) {
74
+ spinner.isSilent = false;
75
+ spinner.render();
76
+ }
77
+ });
78
+ };
79
+ // @ts-expect-error TS(2531) FIXME: Object is possibly 'null'.
80
+ commandProcess.stdout.pipe(stripAnsiCc.stream()).on('data', pipeDataWithSpinner.bind(null, process.stdout));
81
+ // @ts-expect-error TS(2531) FIXME: Object is possibly 'null'.
82
+ commandProcess.stderr.pipe(stripAnsiCc.stream()).on('data', pipeDataWithSpinner.bind(null, process.stderr));
83
+ // @ts-expect-error TS(2345) FIXME: Argument of type 'Writable | null' is not assignab... Remove this comment to see the full error message
84
+ process.stdin.pipe(commandProcess.stdin);
85
+ // we can't try->await->catch since we don't want to block on the framework server which
86
+ // is a long running process
87
+ // eslint-disable-next-line promise/catch-or-return
88
+ commandProcess
89
+ // eslint-disable-next-line promise/prefer-await-to-then
90
+ .then(async () => {
91
+ const result = await commandProcess;
92
+ const [commandWithoutArgs] = command.split(' ');
93
+ if (result.failed && isNonExistingCommandError({ command: commandWithoutArgs, error: result })) {
94
+ log(`${NETLIFYDEVERR} Failed running command: ${command}. Please verify ${chalk.magenta(`'${commandWithoutArgs}'`)} exists`);
95
+ }
96
+ else {
97
+ const errorMessage = result.failed
98
+ // @ts-expect-error TS(2339) FIXME: Property 'shortMessage' does not exist on type 'Ex... Remove this comment to see the full error message
99
+ ? `${NETLIFYDEVERR} ${result.shortMessage}`
100
+ : `${NETLIFYDEVWARN} "${command}" exited with code ${result.exitCode}`;
101
+ log(`${errorMessage}. Shutting down Netlify Dev server`);
102
+ }
103
+ return await cleanupBeforeExit({ exitCode: 1 });
104
+ });
105
+ // @ts-expect-error TS(2345) FIXME: Argument of type '{}' is not assignable to paramet... Remove this comment to see the full error message
106
+ processOnExit(async () => await cleanupBeforeExit({}));
107
+ return commandProcess;
108
+ };
113
109
  /**
114
110
  *
115
111
  * @param {object} config
@@ -117,21 +113,18 @@ export const runCommand = (command, options = {}) => {
117
113
  * @param {*} config.error
118
114
  * @returns
119
115
  */
116
+ // @ts-expect-error TS(7031) FIXME: Binding element 'command' implicitly has an 'any' ... Remove this comment to see the full error message
120
117
  const isNonExistingCommandError = ({ command, error: commandError }) => {
121
- // `ENOENT` is only returned for non Windows systems
122
- // See https://github.com/sindresorhus/execa/pull/447
123
- if (commandError.code === 'ENOENT') {
124
- return true
125
- }
126
-
127
- // if the command is a package manager we let it report the error
128
- if (['yarn', 'npm', 'pnpm'].includes(command)) {
129
- return false
130
- }
131
-
132
- // this only works on English versions of Windows
133
- return (
134
- typeof commandError.message === 'string' &&
135
- commandError.message.includes('is not recognized as an internal or external command')
136
- )
137
- }
118
+ // `ENOENT` is only returned for non Windows systems
119
+ // See https://github.com/sindresorhus/execa/pull/447
120
+ if (commandError.code === 'ENOENT') {
121
+ return true;
122
+ }
123
+ // if the command is a package manager we let it report the error
124
+ if (['yarn', 'npm', 'pnpm'].includes(command)) {
125
+ return false;
126
+ }
127
+ // this only works on English versions of Windows
128
+ return (typeof commandError.message === 'string' &&
129
+ commandError.message.includes('is not recognized as an internal or external command'));
130
+ };
@@ -1,16 +1,16 @@
1
- import jwt from 'jsonwebtoken'
2
-
1
+ // @ts-expect-error TS(7016) FIXME: Could not find a declaration file for module 'json... Remove this comment to see the full error message
2
+ import jwt from 'jsonwebtoken';
3
3
  // https://docs.netlify.com/routing/redirects/rewrites-proxies/#signed-proxy-redirects
4
+ // @ts-expect-error TS(7031) FIXME: Binding element 'deployContext' implicitly has an ... Remove this comment to see the full error message
4
5
  export const signRedirect = ({ deployContext, secret, siteID, siteURL }) => {
5
- const claims = {
6
- deploy_context: deployContext,
7
- netlify_id: siteID,
8
- site_url: siteURL,
9
- }
10
- const options = {
11
- expiresIn: '5 minutes',
12
- issuer: 'netlify',
13
- }
14
-
15
- return jwt.sign(claims, secret, options)
16
- }
6
+ const claims = {
7
+ deploy_context: deployContext,
8
+ netlify_id: siteID,
9
+ site_url: siteURL,
10
+ };
11
+ const options = {
12
+ expiresIn: '5 minutes',
13
+ issuer: 'netlify',
14
+ };
15
+ return jwt.sign(claims, secret, options);
16
+ };