@netlify/build 28.0.0-beta → 28.0.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 (258) hide show
  1. package/bin.js +5 -0
  2. package/lib/core/bin.js +66 -0
  3. package/lib/core/build.js +355 -0
  4. package/lib/core/config.js +121 -0
  5. package/lib/core/constants.js +116 -0
  6. package/lib/core/dev.js +27 -0
  7. package/lib/core/dry.js +21 -0
  8. package/lib/core/feature_flags.js +19 -0
  9. package/lib/core/flags.js +201 -0
  10. package/lib/core/lingering.js +68 -0
  11. package/lib/core/main.js +123 -0
  12. package/lib/core/missing_side_file.js +17 -0
  13. package/lib/core/normalize_flags.js +59 -0
  14. package/lib/core/severity.js +20 -0
  15. package/lib/core/user_node_version.js +32 -0
  16. package/lib/env/changes.js +43 -0
  17. package/lib/env/main.js +14 -0
  18. package/lib/env/metadata.js +68 -0
  19. package/lib/error/api.js +37 -0
  20. package/lib/error/build.js +36 -0
  21. package/{src → lib}/error/cancel.js +5 -6
  22. package/lib/error/colors.js +9 -0
  23. package/lib/error/handle.js +46 -0
  24. package/lib/error/info.js +37 -0
  25. package/lib/error/monitor/location.js +16 -0
  26. package/lib/error/monitor/normalize.js +86 -0
  27. package/lib/error/monitor/print.js +20 -0
  28. package/lib/error/monitor/report.js +120 -0
  29. package/lib/error/monitor/start.js +58 -0
  30. package/lib/error/parse/clean_stack.js +70 -0
  31. package/lib/error/parse/location.js +50 -0
  32. package/lib/error/parse/normalize.js +24 -0
  33. package/lib/error/parse/parse.js +67 -0
  34. package/lib/error/parse/plugin.js +55 -0
  35. package/lib/error/parse/properties.js +16 -0
  36. package/lib/error/parse/serialize_log.js +34 -0
  37. package/lib/error/parse/serialize_status.js +18 -0
  38. package/lib/error/parse/stack.js +34 -0
  39. package/lib/error/type.js +171 -0
  40. package/lib/install/functions.js +20 -0
  41. package/lib/install/local.js +45 -0
  42. package/lib/install/main.js +67 -0
  43. package/lib/install/missing.js +54 -0
  44. package/{src → lib}/log/colors.js +15 -22
  45. package/lib/log/description.js +21 -0
  46. package/lib/log/header.js +14 -0
  47. package/lib/log/header_func.js +13 -0
  48. package/lib/log/logger.js +130 -0
  49. package/lib/log/messages/compatibility.js +120 -0
  50. package/lib/log/messages/config.js +91 -0
  51. package/lib/log/messages/core.js +50 -0
  52. package/lib/log/messages/core_steps.js +75 -0
  53. package/lib/log/messages/dry.js +41 -0
  54. package/lib/log/messages/install.js +25 -0
  55. package/lib/log/messages/ipc.js +29 -0
  56. package/lib/log/messages/mutations.js +62 -0
  57. package/{src → lib}/log/messages/plugins.js +18 -32
  58. package/lib/log/messages/status.js +14 -0
  59. package/lib/log/messages/steps.js +18 -0
  60. package/lib/log/old_version.js +32 -0
  61. package/lib/log/serialize.js +10 -0
  62. package/lib/log/stream.js +68 -0
  63. package/lib/log/theme.js +25 -0
  64. package/lib/plugins/child/diff.js +46 -0
  65. package/lib/plugins/child/error.js +26 -0
  66. package/lib/plugins/child/lazy.js +15 -0
  67. package/lib/plugins/child/load.js +22 -0
  68. package/lib/plugins/child/logic.js +57 -0
  69. package/lib/plugins/child/main.js +37 -0
  70. package/lib/plugins/child/run.js +19 -0
  71. package/lib/plugins/child/status.js +63 -0
  72. package/lib/plugins/child/typescript.js +28 -0
  73. package/lib/plugins/child/utils.js +42 -0
  74. package/lib/plugins/child/validate.js +31 -0
  75. package/lib/plugins/compatibility.js +104 -0
  76. package/{src → lib}/plugins/error.js +31 -35
  77. package/{src → lib}/plugins/events.js +7 -12
  78. package/lib/plugins/expected_version.js +81 -0
  79. package/lib/plugins/ipc.js +120 -0
  80. package/lib/plugins/list.js +73 -0
  81. package/lib/plugins/load.js +50 -0
  82. package/lib/plugins/manifest/check.js +85 -0
  83. package/lib/plugins/manifest/load.js +38 -0
  84. package/lib/plugins/manifest/main.js +17 -0
  85. package/lib/plugins/manifest/path.js +24 -0
  86. package/lib/plugins/manifest/validate.js +91 -0
  87. package/lib/plugins/node_version.js +30 -0
  88. package/lib/plugins/options.js +55 -0
  89. package/lib/plugins/pinned_version.js +83 -0
  90. package/lib/plugins/resolve.js +110 -0
  91. package/lib/plugins/spawn.js +54 -0
  92. package/lib/plugins_core/add.js +35 -0
  93. package/lib/plugins_core/build_command.js +50 -0
  94. package/lib/plugins_core/deploy/buildbot_client.js +87 -0
  95. package/lib/plugins_core/deploy/index.js +49 -0
  96. package/{src → lib}/plugins_core/deploy/manifest.yml +0 -0
  97. package/lib/plugins_core/edge_functions/index.js +79 -0
  98. package/lib/plugins_core/edge_functions/lib/error.js +17 -0
  99. package/lib/plugins_core/edge_functions/lib/internal_manifest.js +50 -0
  100. package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +75 -0
  101. package/lib/plugins_core/functions/error.js +123 -0
  102. package/lib/plugins_core/functions/feature_flags.js +6 -0
  103. package/lib/plugins_core/functions/index.js +114 -0
  104. package/lib/plugins_core/functions/utils.js +45 -0
  105. package/lib/plugins_core/functions/zisi.js +39 -0
  106. package/{src → lib}/plugins_core/functions_install/index.js +8 -11
  107. package/{src → lib}/plugins_core/functions_install/manifest.yml +0 -0
  108. package/lib/plugins_core/list.js +20 -0
  109. package/lib/status/add.js +30 -0
  110. package/lib/status/colors.js +18 -0
  111. package/lib/status/load_error.js +10 -0
  112. package/lib/status/report.js +83 -0
  113. package/lib/status/success.js +14 -0
  114. package/lib/steps/core_step.js +57 -0
  115. package/lib/steps/error.js +65 -0
  116. package/lib/steps/get.js +43 -0
  117. package/lib/steps/plugin.js +55 -0
  118. package/lib/steps/return.js +25 -0
  119. package/lib/steps/run_core_steps.js +147 -0
  120. package/lib/steps/run_step.js +188 -0
  121. package/lib/steps/run_steps.js +96 -0
  122. package/lib/steps/update_config.js +66 -0
  123. package/lib/telemetry/main.js +97 -0
  124. package/lib/time/aggregate.js +120 -0
  125. package/lib/time/main.js +37 -0
  126. package/lib/time/measure.js +18 -0
  127. package/lib/time/report.js +47 -0
  128. package/lib/utils/errors.js +13 -0
  129. package/lib/utils/json.js +15 -0
  130. package/{src → lib}/utils/omit.js +3 -4
  131. package/lib/utils/package.js +22 -0
  132. package/lib/utils/remove_falsy.js +8 -0
  133. package/lib/utils/resolve.js +41 -0
  134. package/lib/utils/runtime.js +5 -0
  135. package/lib/utils/semver.js +28 -0
  136. package/package.json +39 -20
  137. package/types/config/netlify_config.d.ts +4 -4
  138. package/types/netlify_plugin_constants.d.ts +8 -8
  139. package/src/core/bin.js +0 -83
  140. package/src/core/config.js +0 -186
  141. package/src/core/constants.js +0 -156
  142. package/src/core/dry.js +0 -39
  143. package/src/core/feature_flags.js +0 -21
  144. package/src/core/flags.js +0 -194
  145. package/src/core/lingering.js +0 -85
  146. package/src/core/main.js +0 -692
  147. package/src/core/missing_side_file.js +0 -29
  148. package/src/core/normalize_flags.js +0 -69
  149. package/src/core/severity.js +0 -22
  150. package/src/core/user_node_version.js +0 -41
  151. package/src/env/changes.js +0 -52
  152. package/src/env/main.js +0 -19
  153. package/src/env/metadata.js +0 -81
  154. package/src/error/api.js +0 -46
  155. package/src/error/build.js +0 -50
  156. package/src/error/colors.js +0 -11
  157. package/src/error/handle.js +0 -57
  158. package/src/error/info.js +0 -46
  159. package/src/error/monitor/location.js +0 -21
  160. package/src/error/monitor/normalize.js +0 -77
  161. package/src/error/monitor/print.js +0 -42
  162. package/src/error/monitor/report.js +0 -133
  163. package/src/error/monitor/start.js +0 -69
  164. package/src/error/parse/clean_stack.js +0 -87
  165. package/src/error/parse/location.js +0 -58
  166. package/src/error/parse/normalize.js +0 -29
  167. package/src/error/parse/parse.js +0 -97
  168. package/src/error/parse/plugin.js +0 -70
  169. package/src/error/parse/properties.js +0 -23
  170. package/src/error/parse/serialize_log.js +0 -42
  171. package/src/error/parse/serialize_status.js +0 -23
  172. package/src/error/parse/stack.js +0 -43
  173. package/src/error/type.js +0 -182
  174. package/src/install/functions.js +0 -28
  175. package/src/install/local.js +0 -62
  176. package/src/install/main.js +0 -81
  177. package/src/install/missing.js +0 -67
  178. package/src/log/description.js +0 -26
  179. package/src/log/header.js +0 -16
  180. package/src/log/header_func.js +0 -17
  181. package/src/log/logger.js +0 -107
  182. package/src/log/messages/compatibility.js +0 -164
  183. package/src/log/messages/config.js +0 -105
  184. package/src/log/messages/core.js +0 -70
  185. package/src/log/messages/core_steps.js +0 -104
  186. package/src/log/messages/dry.js +0 -63
  187. package/src/log/messages/install.js +0 -20
  188. package/src/log/messages/ipc.js +0 -38
  189. package/src/log/messages/mutations.js +0 -82
  190. package/src/log/messages/status.js +0 -16
  191. package/src/log/messages/steps.js +0 -22
  192. package/src/log/old_version.js +0 -41
  193. package/src/log/serialize.js +0 -13
  194. package/src/log/stream.js +0 -85
  195. package/src/log/theme.js +0 -26
  196. package/src/plugins/child/diff.js +0 -55
  197. package/src/plugins/child/error.js +0 -32
  198. package/src/plugins/child/lazy.js +0 -18
  199. package/src/plugins/child/load.js +0 -29
  200. package/src/plugins/child/logic.js +0 -57
  201. package/src/plugins/child/main.js +0 -51
  202. package/src/plugins/child/run.js +0 -28
  203. package/src/plugins/child/status.js +0 -67
  204. package/src/plugins/child/typescript.js +0 -45
  205. package/src/plugins/child/utils.js +0 -56
  206. package/src/plugins/child/validate.js +0 -34
  207. package/src/plugins/compatibility.js +0 -128
  208. package/src/plugins/expected_version.js +0 -119
  209. package/src/plugins/ipc.js +0 -145
  210. package/src/plugins/list.js +0 -86
  211. package/src/plugins/load.js +0 -70
  212. package/src/plugins/manifest/check.js +0 -106
  213. package/src/plugins/manifest/load.js +0 -41
  214. package/src/plugins/manifest/main.js +0 -22
  215. package/src/plugins/manifest/path.js +0 -31
  216. package/src/plugins/manifest/validate.js +0 -108
  217. package/src/plugins/node_version.js +0 -50
  218. package/src/plugins/options.js +0 -88
  219. package/src/plugins/pinned_version.js +0 -131
  220. package/src/plugins/resolve.js +0 -152
  221. package/src/plugins/spawn.js +0 -66
  222. package/src/plugins_core/add.js +0 -49
  223. package/src/plugins_core/build_command.js +0 -75
  224. package/src/plugins_core/deploy/buildbot_client.js +0 -102
  225. package/src/plugins_core/deploy/index.js +0 -73
  226. package/src/plugins_core/edge_functions/index.js +0 -107
  227. package/src/plugins_core/edge_functions/lib/internal_manifest.js +0 -54
  228. package/src/plugins_core/functions/error.js +0 -163
  229. package/src/plugins_core/functions/feature_flags.js +0 -6
  230. package/src/plugins_core/functions/index.js +0 -160
  231. package/src/plugins_core/functions/utils.js +0 -66
  232. package/src/plugins_core/functions/zisi.js +0 -53
  233. package/src/plugins_core/list.js +0 -27
  234. package/src/status/add.js +0 -36
  235. package/src/status/colors.js +0 -23
  236. package/src/status/load_error.js +0 -11
  237. package/src/status/report.js +0 -128
  238. package/src/status/success.js +0 -18
  239. package/src/steps/core_step.js +0 -90
  240. package/src/steps/error.js +0 -102
  241. package/src/steps/get.js +0 -32
  242. package/src/steps/plugin.js +0 -85
  243. package/src/steps/return.js +0 -52
  244. package/src/steps/run_core_steps.js +0 -194
  245. package/src/steps/run_step.js +0 -300
  246. package/src/steps/run_steps.js +0 -179
  247. package/src/steps/update_config.js +0 -93
  248. package/src/telemetry/main.js +0 -136
  249. package/src/time/aggregate.js +0 -146
  250. package/src/time/main.js +0 -48
  251. package/src/time/measure.js +0 -22
  252. package/src/time/report.js +0 -59
  253. package/src/utils/errors.js +0 -12
  254. package/src/utils/json.js +0 -19
  255. package/src/utils/package.js +0 -23
  256. package/src/utils/remove_falsy.js +0 -10
  257. package/src/utils/resolve.js +0 -46
  258. package/src/utils/semver.js +0 -34
package/src/core/main.js DELETED
@@ -1,692 +0,0 @@
1
- /* eslint-disable max-lines, import/max-dependencies */
2
- import { handleBuildError } from '../error/handle.js'
3
- import { getErrorInfo } from '../error/info.js'
4
- import { startErrorMonitor } from '../error/monitor/start.js'
5
- import { getBufferLogs } from '../log/logger.js'
6
- import { logBuildStart, logTimer, logBuildSuccess } from '../log/messages/core.js'
7
- import { loadPlugins } from '../plugins/load.js'
8
- import { getPluginsOptions } from '../plugins/options.js'
9
- import { pinPlugins } from '../plugins/pinned_version.js'
10
- import { startPlugins, stopPlugins } from '../plugins/spawn.js'
11
- import { addCorePlugins } from '../plugins_core/add.js'
12
- import { reportStatuses } from '../status/report.js'
13
- import { getSteps } from '../steps/get.js'
14
- import { runSteps } from '../steps/run_steps.js'
15
- import { trackBuildComplete } from '../telemetry/main.js'
16
- import { initTimers, measureDuration } from '../time/main.js'
17
- import { reportTimers } from '../time/report.js'
18
-
19
- import { getConfigOpts, loadConfig } from './config.js'
20
- import { getConstants } from './constants.js'
21
- import { doDryRun } from './dry.js'
22
- import { warnOnLingeringProcesses } from './lingering.js'
23
- import { warnOnMissingSideFiles } from './missing_side_file.js'
24
- import { normalizeFlags } from './normalize_flags.js'
25
- import { getSeverity } from './severity.js'
26
-
27
- export { runCoreSteps } from '../steps/run_core_steps.js'
28
-
29
- /**
30
- * Main entry point of Netlify Build.
31
- * Runs a builds and returns whether it succeeded or not.
32
- *
33
- * @param {object} [flags] - build configuration CLI flags
34
- * @param {string} [flags.config] - Path to the configuration file
35
- * @param {string} [flags.cwd] - Current directory. Used to retrieve the configuration file
36
- * @param {string} [flags.repositoryRoot] - Git repository root directory. Used to retrieve the configuration file.
37
- * @param {string} [flags.apiHost] - Netlify API endpoint
38
- * @param {string} [flags.token] - Netlify API token for authentication
39
- * @param {string} [flags.siteId] - Netlify Site ID
40
- * @param {string} [flags.deployId] - Netlify Deploy ID
41
- * @param {string} [flags.context] - Build context
42
- * @param {string} [flags.branch] - Repository branch
43
- * @param {boolean} [flags.dry=false] - Run in dry mode, i.e. printing steps without executing them
44
- * @param {string} [flags.nodePath] - Path to the Node.js binary to use in the build command and plugins
45
- * @param {boolean} [flags.buffer=false] - Buffer output instead of printing it
46
- *
47
- * @returns {object} buildResult
48
- * @returns {boolean} buildResult.success - Whether build succeeded or failed
49
- * @returns {number} buildResult.severityCode - Build success/failure status among:
50
- * 0 (success), 1 (build cancelled), 2 (user error), 3 (plugin error), 4 (system error). Can be used as exit code.
51
- * @returns {string[]} buildResult.logs - When using the `buffer` option, all log messages
52
- */
53
- export default async function buildSite(flags = {}) {
54
- const {
55
- errorMonitor,
56
- framework,
57
- mode,
58
- logs,
59
- debug,
60
- testOpts,
61
- statsdOpts,
62
- dry,
63
- telemetry,
64
- buildId,
65
- deployId,
66
- ...flagsA
67
- } = startBuild(flags)
68
- const errorParams = { errorMonitor, mode, logs, debug, testOpts }
69
-
70
- try {
71
- const {
72
- pluginsOptions,
73
- netlifyConfig: netlifyConfigA,
74
- siteInfo,
75
- userNodeVersion,
76
- stepsCount,
77
- timers,
78
- durationNs,
79
- configMutations,
80
- } = await execBuild({
81
- ...flagsA,
82
- buildId,
83
- deployId,
84
- dry,
85
- errorMonitor,
86
- mode,
87
- logs,
88
- debug,
89
- testOpts,
90
- errorParams,
91
- })
92
- await handleBuildSuccess({
93
- framework,
94
- dry,
95
- logs,
96
- timers,
97
- durationNs,
98
- statsdOpts,
99
- })
100
- const { success, severityCode, status } = getSeverity('success')
101
- await telemetryReport({
102
- buildId,
103
- deployId,
104
- status,
105
- stepsCount,
106
- pluginsOptions,
107
- durationNs,
108
- siteInfo,
109
- telemetry,
110
- userNodeVersion,
111
- framework,
112
- testOpts,
113
- errorParams,
114
- })
115
- return { success, severityCode, netlifyConfig: netlifyConfigA, logs, configMutations }
116
- } catch (error) {
117
- const { severity } = await handleBuildError(error, errorParams)
118
- const { pluginsOptions, siteInfo, userNodeVersion } = errorParams
119
- const { success, severityCode, status } = getSeverity(severity)
120
- await telemetryReport({
121
- buildId,
122
- deployId,
123
- status,
124
- pluginsOptions,
125
- siteInfo,
126
- telemetry,
127
- userNodeVersion,
128
- framework,
129
- testOpts,
130
- errorParams,
131
- })
132
- return { success, severityCode, logs }
133
- }
134
- }
135
-
136
- // Performed on build start. Must be kept small and unlikely to fail since it
137
- // does not have proper error handling. Error handling relies on `errorMonitor`
138
- // being built, which relies itself on flags being normalized.
139
- const startBuild = function (flags) {
140
- const timers = initTimers()
141
-
142
- const logs = getBufferLogs(flags)
143
- logBuildStart(logs)
144
-
145
- const { bugsnagKey, ...flagsA } = normalizeFlags(flags, logs)
146
- const errorMonitor = startErrorMonitor({ flags: flagsA, logs, bugsnagKey })
147
-
148
- return { ...flagsA, errorMonitor, logs, timers }
149
- }
150
-
151
- const tExecBuild = async function ({
152
- config,
153
- defaultConfig,
154
- cachedConfig,
155
- cachedConfigPath,
156
- cwd,
157
- repositoryRoot,
158
- apiHost,
159
- token,
160
- siteId,
161
- context,
162
- branch,
163
- baseRelDir,
164
- env: envOpt,
165
- debug,
166
- verbose,
167
- nodePath,
168
- functionsDistDir,
169
- edgeFunctionsDistDir,
170
- cacheDir,
171
- dry,
172
- mode,
173
- offline,
174
- deployId,
175
- buildId,
176
- testOpts,
177
- errorMonitor,
178
- errorParams,
179
- logs,
180
- timers,
181
- buildbotServerSocket,
182
- sendStatus,
183
- saveConfig,
184
- featureFlags,
185
- }) {
186
- const configOpts = getConfigOpts({
187
- config,
188
- defaultConfig,
189
- cwd,
190
- repositoryRoot,
191
- apiHost,
192
- token,
193
- siteId,
194
- context,
195
- branch,
196
- baseRelDir,
197
- envOpt,
198
- mode,
199
- offline,
200
- deployId,
201
- buildId,
202
- testOpts,
203
- featureFlags,
204
- })
205
- const {
206
- netlifyConfig,
207
- configPath,
208
- headersPath,
209
- redirectsPath,
210
- buildDir,
211
- repositoryRoot: repositoryRootA,
212
- packageJson,
213
- userNodeVersion,
214
- childEnv,
215
- context: contextA,
216
- branch: branchA,
217
- token: tokenA,
218
- api,
219
- siteInfo,
220
- timers: timersA,
221
- } = await loadConfig({
222
- configOpts,
223
- cachedConfig,
224
- cachedConfigPath,
225
- envOpt,
226
- debug,
227
- logs,
228
- nodePath,
229
- timers,
230
- })
231
- const constants = await getConstants({
232
- configPath,
233
- buildDir,
234
- functionsDistDir,
235
- edgeFunctionsDistDir,
236
- cacheDir,
237
- netlifyConfig,
238
- siteInfo,
239
- apiHost,
240
- token: tokenA,
241
- mode,
242
- testOpts,
243
- })
244
- const pluginsOptions = addCorePlugins({ netlifyConfig, constants })
245
- // `errorParams` is purposely stateful
246
- // eslint-disable-next-line fp/no-mutating-assign
247
- Object.assign(errorParams, { netlifyConfig, pluginsOptions, siteInfo, childEnv, userNodeVersion })
248
-
249
- const {
250
- pluginsOptions: pluginsOptionsA,
251
- netlifyConfig: netlifyConfigA,
252
- stepsCount,
253
- timers: timersB,
254
- configMutations,
255
- } = await runAndReportBuild({
256
- pluginsOptions,
257
- netlifyConfig,
258
- configOpts,
259
- siteInfo,
260
- configPath,
261
- headersPath,
262
- redirectsPath,
263
- buildDir,
264
- repositoryRoot: repositoryRootA,
265
- nodePath,
266
- packageJson,
267
- userNodeVersion,
268
- childEnv,
269
- context: contextA,
270
- branch: branchA,
271
- dry,
272
- mode,
273
- api,
274
- errorMonitor,
275
- deployId,
276
- errorParams,
277
- logs,
278
- debug,
279
- verbose,
280
- timers: timersA,
281
- sendStatus,
282
- saveConfig,
283
- testOpts,
284
- buildbotServerSocket,
285
- constants,
286
- featureFlags,
287
- })
288
- return {
289
- pluginsOptions: pluginsOptionsA,
290
- netlifyConfig: netlifyConfigA,
291
- siteInfo,
292
- userNodeVersion,
293
- stepsCount,
294
- timers: timersB,
295
- configMutations,
296
- }
297
- }
298
-
299
- const execBuild = measureDuration(tExecBuild, 'total', { parentTag: 'build_site' })
300
-
301
- // Runs a build then report any plugin statuses
302
- const runAndReportBuild = async function ({
303
- pluginsOptions,
304
- netlifyConfig,
305
- configOpts,
306
- siteInfo,
307
- configPath,
308
- headersPath,
309
- redirectsPath,
310
- buildDir,
311
- repositoryRoot,
312
- nodePath,
313
- packageJson,
314
- userNodeVersion,
315
- childEnv,
316
- context,
317
- branch,
318
- buildbotServerSocket,
319
- constants,
320
- dry,
321
- mode,
322
- api,
323
- errorMonitor,
324
- deployId,
325
- errorParams,
326
- logs,
327
- debug,
328
- verbose,
329
- timers,
330
- sendStatus,
331
- saveConfig,
332
- testOpts,
333
- featureFlags,
334
- }) {
335
- try {
336
- const {
337
- stepsCount,
338
- netlifyConfig: netlifyConfigA,
339
- statuses,
340
- pluginsOptions: pluginsOptionsA,
341
- failedPlugins,
342
- timers: timersA,
343
- configMutations,
344
- } = await initAndRunBuild({
345
- pluginsOptions,
346
- netlifyConfig,
347
- configOpts,
348
- siteInfo,
349
- configPath,
350
- headersPath,
351
- redirectsPath,
352
- buildDir,
353
- repositoryRoot,
354
- nodePath,
355
- packageJson,
356
- userNodeVersion,
357
- childEnv,
358
- context,
359
- branch,
360
- dry,
361
- mode,
362
- api,
363
- errorMonitor,
364
- deployId,
365
- errorParams,
366
- logs,
367
- debug,
368
- verbose,
369
- timers,
370
- sendStatus,
371
- saveConfig,
372
- testOpts,
373
- buildbotServerSocket,
374
- constants,
375
- featureFlags,
376
- })
377
- await Promise.all([
378
- reportStatuses({
379
- statuses,
380
- childEnv,
381
- api,
382
- mode,
383
- pluginsOptions: pluginsOptionsA,
384
- netlifyConfig: netlifyConfigA,
385
- errorMonitor,
386
- deployId,
387
- logs,
388
- debug,
389
- sendStatus,
390
- testOpts,
391
- }),
392
- pinPlugins({
393
- pluginsOptions: pluginsOptionsA,
394
- failedPlugins,
395
- api,
396
- siteInfo,
397
- childEnv,
398
- mode,
399
- netlifyConfig: netlifyConfigA,
400
- errorMonitor,
401
- logs,
402
- debug,
403
- testOpts,
404
- sendStatus,
405
- }),
406
- ])
407
-
408
- return {
409
- pluginsOptions: pluginsOptionsA,
410
- netlifyConfig: netlifyConfigA,
411
- stepsCount,
412
- timers: timersA,
413
- configMutations,
414
- }
415
- } catch (error) {
416
- const [{ statuses }] = getErrorInfo(error)
417
- await reportStatuses({
418
- statuses,
419
- childEnv,
420
- api,
421
- mode,
422
- pluginsOptions,
423
- netlifyConfig,
424
- errorMonitor,
425
- deployId,
426
- logs,
427
- debug,
428
- sendStatus,
429
- testOpts,
430
- })
431
- throw error
432
- }
433
- }
434
-
435
- // Initialize plugin processes then runs a build
436
- const initAndRunBuild = async function ({
437
- pluginsOptions,
438
- netlifyConfig,
439
- configOpts,
440
- siteInfo,
441
- configPath,
442
- headersPath,
443
- redirectsPath,
444
- buildDir,
445
- repositoryRoot,
446
- nodePath,
447
- packageJson,
448
- userNodeVersion,
449
- childEnv,
450
- context,
451
- branch,
452
- dry,
453
- mode,
454
- api,
455
- errorMonitor,
456
- deployId,
457
- errorParams,
458
- logs,
459
- debug,
460
- verbose,
461
- sendStatus,
462
- saveConfig,
463
- timers,
464
- testOpts,
465
- buildbotServerSocket,
466
- constants,
467
- featureFlags,
468
- }) {
469
- const { pluginsOptions: pluginsOptionsA, timers: timersA } = await getPluginsOptions({
470
- pluginsOptions,
471
- netlifyConfig,
472
- siteInfo,
473
- buildDir,
474
- nodePath,
475
- packageJson,
476
- userNodeVersion,
477
- mode,
478
- api,
479
- logs,
480
- debug,
481
- sendStatus,
482
- timers,
483
- testOpts,
484
- featureFlags,
485
- })
486
- // eslint-disable-next-line fp/no-mutation, no-param-reassign
487
- errorParams.pluginsOptions = pluginsOptionsA
488
-
489
- const { childProcesses, timers: timersB } = await startPlugins({
490
- pluginsOptions: pluginsOptionsA,
491
- buildDir,
492
- childEnv,
493
- logs,
494
- debug,
495
- timers: timersA,
496
- })
497
-
498
- try {
499
- const {
500
- stepsCount,
501
- netlifyConfig: netlifyConfigA,
502
- statuses,
503
- failedPlugins,
504
- timers: timersC,
505
- configMutations,
506
- } = await runBuild({
507
- childProcesses,
508
- pluginsOptions: pluginsOptionsA,
509
- netlifyConfig,
510
- configOpts,
511
- packageJson,
512
- configPath,
513
- headersPath,
514
- redirectsPath,
515
- buildDir,
516
- repositoryRoot,
517
- nodePath,
518
- childEnv,
519
- context,
520
- branch,
521
- dry,
522
- buildbotServerSocket,
523
- constants,
524
- mode,
525
- api,
526
- errorMonitor,
527
- deployId,
528
- errorParams,
529
- logs,
530
- debug,
531
- verbose,
532
- saveConfig,
533
- timers: timersB,
534
- testOpts,
535
- featureFlags,
536
- })
537
-
538
- await Promise.all([
539
- warnOnMissingSideFiles({ buildDir, netlifyConfig: netlifyConfigA, logs }),
540
- warnOnLingeringProcesses({ mode, logs, testOpts }),
541
- ])
542
-
543
- return {
544
- stepsCount,
545
- netlifyConfig: netlifyConfigA,
546
- statuses,
547
- pluginsOptions: pluginsOptionsA,
548
- failedPlugins,
549
- timers: timersC,
550
- configMutations,
551
- }
552
- } finally {
553
- stopPlugins(childProcesses)
554
- }
555
- }
556
-
557
- // Load plugin main files, retrieve their event handlers then runs them,
558
- // together with the build command
559
- const runBuild = async function ({
560
- childProcesses,
561
- pluginsOptions,
562
- netlifyConfig,
563
- configOpts,
564
- packageJson,
565
- configPath,
566
- headersPath,
567
- redirectsPath,
568
- buildDir,
569
- repositoryRoot,
570
- nodePath,
571
- childEnv,
572
- context,
573
- branch,
574
- dry,
575
- buildbotServerSocket,
576
- constants,
577
- mode,
578
- api,
579
- errorMonitor,
580
- deployId,
581
- errorParams,
582
- logs,
583
- debug,
584
- verbose,
585
- saveConfig,
586
- timers,
587
- testOpts,
588
- featureFlags,
589
- }) {
590
- const { pluginsSteps, timers: timersA } = await loadPlugins({
591
- pluginsOptions,
592
- childProcesses,
593
- packageJson,
594
- timers,
595
- logs,
596
- debug,
597
- verbose,
598
- })
599
-
600
- const { steps, events } = getSteps(pluginsSteps)
601
-
602
- if (dry) {
603
- await doDryRun({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs })
604
- return { netlifyConfig }
605
- }
606
-
607
- const {
608
- stepsCount,
609
- netlifyConfig: netlifyConfigA,
610
- statuses,
611
- failedPlugins,
612
- timers: timersB,
613
- configMutations,
614
- } = await runSteps({
615
- steps,
616
- buildbotServerSocket,
617
- events,
618
- configPath,
619
- headersPath,
620
- redirectsPath,
621
- buildDir,
622
- repositoryRoot,
623
- nodePath,
624
- childEnv,
625
- context,
626
- branch,
627
- constants,
628
- mode,
629
- api,
630
- errorMonitor,
631
- deployId,
632
- errorParams,
633
- netlifyConfig,
634
- configOpts,
635
- logs,
636
- debug,
637
- verbose,
638
- saveConfig,
639
- timers: timersA,
640
- testOpts,
641
- featureFlags,
642
- })
643
-
644
- return { stepsCount, netlifyConfig: netlifyConfigA, statuses, failedPlugins, timers: timersB, configMutations }
645
- }
646
-
647
- // Logs and reports that a build successfully ended
648
- const handleBuildSuccess = async function ({ framework, dry, logs, timers, durationNs, statsdOpts }) {
649
- if (dry) {
650
- return
651
- }
652
-
653
- logBuildSuccess(logs)
654
-
655
- logTimer(logs, durationNs, 'Netlify Build')
656
- await reportTimers({ timers, statsdOpts, framework })
657
- }
658
-
659
- // Handles the calls and errors of telemetry reports
660
- const telemetryReport = async function ({
661
- deployId,
662
- buildId,
663
- status,
664
- stepsCount,
665
- pluginsOptions,
666
- durationNs,
667
- siteInfo,
668
- telemetry,
669
- userNodeVersion,
670
- framework,
671
- testOpts,
672
- errorParams,
673
- }) {
674
- try {
675
- await trackBuildComplete({
676
- deployId,
677
- buildId,
678
- status,
679
- stepsCount,
680
- pluginsOptions,
681
- durationNs,
682
- siteInfo,
683
- telemetry,
684
- userNodeVersion,
685
- framework,
686
- testOpts,
687
- })
688
- } catch (error) {
689
- await handleBuildError(error, errorParams)
690
- }
691
- }
692
- /* eslint-enable max-lines, import/max-dependencies */
@@ -1,29 +0,0 @@
1
- import { relative } from 'path'
2
-
3
- import { pathExists } from 'path-exists'
4
-
5
- import { logMissingSideFile } from '../log/messages/core.js'
6
-
7
- // Some files like `_headers` and `_redirects` must be copied to the publish
8
- // directory to be used in production. When those are present in the repository
9
- // but not in the publish directory, this most likely indicates that the build
10
- // command accidentally forgot to copy those. We then print a warning message.
11
- export const warnOnMissingSideFiles = async function ({
12
- buildDir,
13
- netlifyConfig: {
14
- build: { publish },
15
- },
16
- logs,
17
- }) {
18
- await Promise.all(SIDE_FILES.map((sideFile) => warnOnMissingSideFile({ logs, sideFile, buildDir, publish })))
19
- }
20
-
21
- const SIDE_FILES = ['_headers', '_redirects']
22
-
23
- const warnOnMissingSideFile = async function ({ logs, sideFile, buildDir, publish }) {
24
- if (!(await pathExists(`${buildDir}/${sideFile}`)) || (await pathExists(`${publish}/${sideFile}`))) {
25
- return
26
- }
27
-
28
- logMissingSideFile(logs, sideFile, relative(buildDir, publish))
29
- }