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