@netlify/build 27.20.4 → 27.20.5

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 (133) hide show
  1. package/lib/core/bin.js +42 -59
  2. package/lib/core/build.js +333 -536
  3. package/lib/core/config.js +94 -159
  4. package/lib/core/constants.js +95 -135
  5. package/lib/core/dev.js +26 -30
  6. package/lib/core/dry.js +18 -36
  7. package/lib/core/feature_flags.js +13 -16
  8. package/lib/core/flags.js +168 -169
  9. package/lib/core/lingering.js +44 -61
  10. package/lib/core/main.js +94 -136
  11. package/lib/core/missing_side_file.js +12 -24
  12. package/lib/core/normalize_flags.js +52 -63
  13. package/lib/core/severity.js +13 -15
  14. package/lib/core/user_node_version.js +26 -35
  15. package/lib/env/changes.js +29 -37
  16. package/lib/env/main.js +10 -15
  17. package/lib/env/metadata.js +63 -76
  18. package/lib/error/api.js +31 -40
  19. package/lib/error/build.js +27 -38
  20. package/lib/error/cancel.js +5 -6
  21. package/lib/error/colors.js +7 -9
  22. package/lib/error/handle.js +38 -49
  23. package/lib/error/info.js +26 -35
  24. package/lib/error/monitor/location.js +12 -17
  25. package/lib/error/monitor/normalize.js +75 -85
  26. package/lib/error/monitor/print.js +19 -41
  27. package/lib/error/monitor/report.js +102 -121
  28. package/lib/error/monitor/start.js +43 -56
  29. package/lib/error/parse/clean_stack.js +52 -69
  30. package/lib/error/parse/location.js +40 -52
  31. package/lib/error/parse/normalize.js +18 -23
  32. package/lib/error/parse/parse.js +59 -93
  33. package/lib/error/parse/plugin.js +42 -57
  34. package/lib/error/parse/properties.js +13 -20
  35. package/lib/error/parse/serialize_log.js +29 -37
  36. package/lib/error/parse/serialize_status.js +15 -23
  37. package/lib/error/parse/stack.js +29 -38
  38. package/lib/error/type.js +132 -150
  39. package/lib/install/functions.js +16 -24
  40. package/lib/install/local.js +31 -48
  41. package/lib/install/main.js +52 -66
  42. package/lib/install/missing.js +40 -53
  43. package/lib/log/colors.js +15 -22
  44. package/lib/log/description.js +16 -21
  45. package/lib/log/header.js +11 -13
  46. package/lib/log/header_func.js +11 -15
  47. package/lib/log/logger.js +88 -119
  48. package/lib/log/messages/compatibility.js +100 -158
  49. package/lib/log/messages/config.js +76 -92
  50. package/lib/log/messages/core.js +40 -60
  51. package/lib/log/messages/core_steps.js +63 -92
  52. package/lib/log/messages/dry.js +31 -53
  53. package/lib/log/messages/install.js +21 -28
  54. package/lib/log/messages/ipc.js +21 -30
  55. package/lib/log/messages/mutations.js +51 -71
  56. package/lib/log/messages/plugins.js +18 -31
  57. package/lib/log/messages/status.js +12 -14
  58. package/lib/log/messages/steps.js +14 -18
  59. package/lib/log/old_version.js +23 -32
  60. package/lib/log/serialize.js +7 -10
  61. package/lib/log/stream.js +48 -65
  62. package/lib/log/theme.js +22 -23
  63. package/lib/plugins/child/diff.js +31 -40
  64. package/lib/plugins/child/error.js +20 -26
  65. package/lib/plugins/child/lazy.js +11 -14
  66. package/lib/plugins/child/load.js +15 -22
  67. package/lib/plugins/child/logic.js +51 -58
  68. package/lib/plugins/child/main.js +32 -46
  69. package/lib/plugins/child/run.js +18 -27
  70. package/lib/plugins/child/status.js +52 -63
  71. package/lib/plugins/child/typescript.js +19 -36
  72. package/lib/plugins/child/utils.js +36 -49
  73. package/lib/plugins/child/validate.js +25 -28
  74. package/lib/plugins/compatibility.js +64 -92
  75. package/lib/plugins/error.js +29 -35
  76. package/lib/plugins/events.js +7 -12
  77. package/lib/plugins/expected_version.js +61 -99
  78. package/lib/plugins/ipc.js +79 -102
  79. package/lib/plugins/list.js +49 -62
  80. package/lib/plugins/load.js +44 -64
  81. package/lib/plugins/manifest/check.js +64 -85
  82. package/lib/plugins/manifest/load.js +34 -37
  83. package/lib/plugins/manifest/main.js +16 -21
  84. package/lib/plugins/manifest/path.js +18 -25
  85. package/lib/plugins/manifest/validate.js +77 -94
  86. package/lib/plugins/node_version.js +22 -42
  87. package/lib/plugins/options.js +45 -78
  88. package/lib/plugins/pinned_version.js +58 -106
  89. package/lib/plugins/resolve.js +91 -133
  90. package/lib/plugins/spawn.js +43 -61
  91. package/lib/plugins_core/add.js +26 -40
  92. package/lib/plugins_core/build_command.js +47 -72
  93. package/lib/plugins_core/deploy/buildbot_client.js +61 -87
  94. package/lib/plugins_core/deploy/index.js +47 -71
  95. package/lib/plugins_core/edge_functions/index.js +73 -116
  96. package/lib/plugins_core/edge_functions/lib/error.js +13 -17
  97. package/lib/plugins_core/edge_functions/lib/internal_manifest.js +45 -55
  98. package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +65 -80
  99. package/lib/plugins_core/functions/error.js +88 -128
  100. package/lib/plugins_core/functions/feature_flags.js +5 -5
  101. package/lib/plugins_core/functions/index.js +98 -145
  102. package/lib/plugins_core/functions/utils.js +36 -57
  103. package/lib/plugins_core/functions/zisi.js +35 -52
  104. package/lib/plugins_core/functions_install/index.js +8 -11
  105. package/lib/plugins_core/list.js +15 -22
  106. package/lib/status/add.js +26 -32
  107. package/lib/status/colors.js +14 -19
  108. package/lib/status/load_error.js +8 -9
  109. package/lib/status/report.js +72 -126
  110. package/lib/status/success.js +10 -14
  111. package/lib/steps/core_step.js +54 -89
  112. package/lib/steps/error.js +50 -87
  113. package/lib/steps/get.js +33 -41
  114. package/lib/steps/plugin.js +53 -83
  115. package/lib/steps/return.js +24 -51
  116. package/lib/steps/run_core_steps.js +119 -171
  117. package/lib/steps/run_step.js +154 -270
  118. package/lib/steps/run_steps.js +91 -174
  119. package/lib/steps/update_config.js +45 -72
  120. package/lib/telemetry/main.js +89 -128
  121. package/lib/time/aggregate.js +84 -110
  122. package/lib/time/main.js +23 -34
  123. package/lib/time/measure.js +11 -15
  124. package/lib/time/report.js +32 -44
  125. package/lib/utils/errors.js +10 -9
  126. package/lib/utils/json.js +11 -15
  127. package/lib/utils/omit.js +3 -4
  128. package/lib/utils/package.js +19 -22
  129. package/lib/utils/remove_falsy.js +5 -7
  130. package/lib/utils/resolve.js +30 -34
  131. package/lib/utils/runtime.js +4 -4
  132. package/lib/utils/semver.js +19 -25
  133. package/package.json +13 -6
@@ -1,154 +1,90 @@
1
- import { addMutableConstants } from '../core/constants.js'
2
- import { logStepStart } from '../log/messages/steps.js'
3
- import { runsAlsoOnBuildFailure, runsOnlyOnBuildFailure } from '../plugins/events.js'
4
- import { measureDuration, normalizeTimerName } from '../time/main.js'
5
-
6
- import { fireCoreStep } from './core_step.js'
7
- import { firePluginStep } from './plugin.js'
8
- import { getStepReturn } from './return.js'
9
-
1
+ import { addMutableConstants } from '../core/constants.js';
2
+ import { logStepStart } from '../log/messages/steps.js';
3
+ import { runsAlsoOnBuildFailure, runsOnlyOnBuildFailure } from '../plugins/events.js';
4
+ import { measureDuration, normalizeTimerName } from '../time/main.js';
5
+ import { fireCoreStep } from './core_step.js';
6
+ import { firePluginStep } from './plugin.js';
7
+ import { getStepReturn } from './return.js';
10
8
  // Run a step (core, build command or plugin)
11
- export const runStep = async function ({
12
- event,
13
- childProcess,
14
- packageName,
15
- coreStep,
16
- coreStepId,
17
- coreStepName,
18
- coreStepDescription,
19
- pluginPackageJson,
20
- loadedFrom,
21
- origin,
22
- condition,
23
- configPath,
24
- buildDir,
25
- repositoryRoot,
26
- nodePath,
27
- index,
28
- childEnv,
29
- context,
30
- branch,
31
- envChanges,
32
- constants,
33
- steps,
34
- buildbotServerSocket,
35
- events,
36
- mode,
37
- api,
38
- errorMonitor,
39
- deployId,
40
- errorParams,
41
- error,
42
- failedPlugins,
43
- configOpts,
44
- netlifyConfig,
45
- configMutations,
46
- headersPath,
47
- redirectsPath,
48
- logs,
49
- debug,
50
- systemLog,
51
- verbose,
52
- saveConfig,
53
- timers,
54
- testOpts,
55
- featureFlags,
56
- }) {
57
- const constantsA = await addMutableConstants({ constants, buildDir, netlifyConfig })
58
-
59
- if (
60
- !(await shouldRunStep({
61
- event,
62
- packageName,
63
- error,
64
- failedPlugins,
65
- netlifyConfig,
66
- condition,
67
- constants: constantsA,
68
- buildbotServerSocket,
69
- buildDir,
70
- }))
71
- ) {
72
- return {}
73
- }
74
-
75
- logStepStart({ logs, event, packageName, coreStepDescription, index, error, netlifyConfig })
76
-
77
- const fireStep = getFireStep(packageName, coreStepId, event)
78
- const {
79
- newEnvChanges,
80
- netlifyConfig: netlifyConfigA = netlifyConfig,
81
- configMutations: configMutationsA = configMutations,
82
- headersPath: headersPathA = headersPath,
83
- redirectsPath: redirectsPathA = redirectsPath,
84
- newError,
85
- newStatus,
86
- timers: timersA,
87
- durationNs,
88
- } = await fireStep({
89
- event,
90
- childProcess,
91
- packageName,
92
- pluginPackageJson,
93
- loadedFrom,
94
- origin,
95
- coreStep,
96
- coreStepName,
97
- configPath,
98
- buildDir,
99
- repositoryRoot,
100
- nodePath,
101
- childEnv,
102
- context,
103
- branch,
104
- envChanges,
105
- constants: constantsA,
106
- steps,
107
- buildbotServerSocket,
108
- events,
109
- error,
110
- logs,
111
- debug,
112
- systemLog,
113
- verbose,
114
- saveConfig,
115
- timers,
116
- errorParams,
117
- configOpts,
118
- netlifyConfig,
119
- configMutations,
120
- headersPath,
121
- redirectsPath,
122
- featureFlags,
123
- })
124
-
125
- const newValues = await getStepReturn({
126
- event,
127
- packageName,
128
- newError,
129
- newEnvChanges,
130
- newStatus,
131
- coreStep,
132
- coreStepName,
133
- childEnv,
134
- mode,
135
- api,
136
- errorMonitor,
137
- deployId,
138
- netlifyConfig: netlifyConfigA,
139
- configMutations: configMutationsA,
140
- headersPath: headersPathA,
141
- redirectsPath: redirectsPathA,
142
- logs,
143
- debug,
144
- systemLog,
145
- timers: timersA,
146
- durationNs,
147
- testOpts,
148
- })
149
- return { ...newValues, newIndex: index + 1 }
150
- }
151
-
9
+ export const runStep = async function ({ event, childProcess, packageName, coreStep, coreStepId, coreStepName, coreStepDescription, pluginPackageJson, loadedFrom, origin, condition, configPath, buildDir, repositoryRoot, nodePath, index, childEnv, context, branch, envChanges, constants, steps, buildbotServerSocket, events, mode, api, errorMonitor, deployId, errorParams, error, failedPlugins, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, logs, debug, systemLog, verbose, saveConfig, timers, testOpts, featureFlags, }) {
10
+ const constantsA = await addMutableConstants({ constants, buildDir, netlifyConfig });
11
+ if (!(await shouldRunStep({
12
+ event,
13
+ packageName,
14
+ error,
15
+ failedPlugins,
16
+ netlifyConfig,
17
+ condition,
18
+ constants: constantsA,
19
+ buildbotServerSocket,
20
+ buildDir,
21
+ }))) {
22
+ return {};
23
+ }
24
+ logStepStart({ logs, event, packageName, coreStepDescription, index, error, netlifyConfig });
25
+ const fireStep = getFireStep(packageName, coreStepId, event);
26
+ const { newEnvChanges, netlifyConfig: netlifyConfigA = netlifyConfig, configMutations: configMutationsA = configMutations, headersPath: headersPathA = headersPath, redirectsPath: redirectsPathA = redirectsPath, newError, newStatus, timers: timersA, durationNs, } = await fireStep({
27
+ event,
28
+ childProcess,
29
+ packageName,
30
+ pluginPackageJson,
31
+ loadedFrom,
32
+ origin,
33
+ coreStep,
34
+ coreStepName,
35
+ configPath,
36
+ buildDir,
37
+ repositoryRoot,
38
+ nodePath,
39
+ childEnv,
40
+ context,
41
+ branch,
42
+ envChanges,
43
+ constants: constantsA,
44
+ steps,
45
+ buildbotServerSocket,
46
+ events,
47
+ error,
48
+ logs,
49
+ debug,
50
+ systemLog,
51
+ verbose,
52
+ saveConfig,
53
+ timers,
54
+ errorParams,
55
+ configOpts,
56
+ netlifyConfig,
57
+ configMutations,
58
+ headersPath,
59
+ redirectsPath,
60
+ featureFlags,
61
+ });
62
+ const newValues = await getStepReturn({
63
+ event,
64
+ packageName,
65
+ newError,
66
+ newEnvChanges,
67
+ newStatus,
68
+ coreStep,
69
+ coreStepName,
70
+ childEnv,
71
+ mode,
72
+ api,
73
+ errorMonitor,
74
+ deployId,
75
+ netlifyConfig: netlifyConfigA,
76
+ configMutations: configMutationsA,
77
+ headersPath: headersPathA,
78
+ redirectsPath: redirectsPathA,
79
+ logs,
80
+ debug,
81
+ systemLog,
82
+ timers: timersA,
83
+ durationNs,
84
+ testOpts,
85
+ });
86
+ return { ...newValues, newIndex: index + 1 };
87
+ };
152
88
  // A plugin fails _without making the build fail_ when either:
153
89
  // - using `utils.build.failPlugin()`
154
90
  // - the failure happens after deploy. This means: inside any `onError`,
@@ -180,125 +116,73 @@ export const runStep = async function ({
180
116
  // or available. However, one might be created by a build plugin, in which case,
181
117
  // those core plugins should be triggered. We use a dynamic `condition()` to
182
118
  // model this behavior.
183
- const shouldRunStep = async function ({
184
- event,
185
- packageName,
186
- error,
187
- failedPlugins,
188
- netlifyConfig,
189
- condition,
190
- constants,
191
- buildbotServerSocket,
192
- buildDir,
193
- }) {
194
- if (
195
- failedPlugins.includes(packageName) ||
196
- (condition !== undefined && !(await condition({ buildDir, constants, buildbotServerSocket, netlifyConfig })))
197
- ) {
198
- return false
199
- }
200
-
201
- if (error !== undefined) {
202
- return runsAlsoOnBuildFailure(event)
203
- }
204
-
205
- return !runsOnlyOnBuildFailure(event)
206
- }
207
-
119
+ const shouldRunStep = async function ({ event, packageName, error, failedPlugins, netlifyConfig, condition, constants, buildbotServerSocket, buildDir, }) {
120
+ if (failedPlugins.includes(packageName) ||
121
+ (condition !== undefined && !(await condition({ buildDir, constants, buildbotServerSocket, netlifyConfig })))) {
122
+ return false;
123
+ }
124
+ if (error !== undefined) {
125
+ return runsAlsoOnBuildFailure(event);
126
+ }
127
+ return !runsOnlyOnBuildFailure(event);
128
+ };
208
129
  // Wrap step function to measure its time
209
130
  const getFireStep = function (packageName, coreStepId, event) {
210
- if (coreStepId !== undefined) {
211
- return measureDuration(tFireStep, coreStepId)
212
- }
213
-
214
- const parentTag = normalizeTimerName(packageName)
215
- return measureDuration(tFireStep, event, { parentTag, category: 'pluginEvent' })
216
- }
217
-
218
- const tFireStep = function ({
219
- event,
220
- childProcess,
221
- packageName,
222
- pluginPackageJson,
223
- loadedFrom,
224
- origin,
225
- coreStep,
226
- coreStepName,
227
- configPath,
228
- buildDir,
229
- repositoryRoot,
230
- nodePath,
231
- childEnv,
232
- context,
233
- branch,
234
- envChanges,
235
- constants,
236
- steps,
237
- buildbotServerSocket,
238
- events,
239
- error,
240
- logs,
241
- debug,
242
- systemLog,
243
- verbose,
244
- saveConfig,
245
- errorParams,
246
- configOpts,
247
- netlifyConfig,
248
- configMutations,
249
- headersPath,
250
- redirectsPath,
251
- featureFlags,
252
- }) {
253
- if (coreStep !== undefined) {
254
- return fireCoreStep({
255
- coreStep,
256
- coreStepName,
257
- configPath,
258
- buildDir,
259
- repositoryRoot,
260
- constants,
261
- buildbotServerSocket,
262
- events,
263
- logs,
264
- nodePath,
265
- childEnv,
266
- context,
267
- branch,
268
- envChanges,
269
- errorParams,
270
- configOpts,
271
- netlifyConfig,
272
- configMutations,
273
- headersPath,
274
- redirectsPath,
275
- featureFlags,
276
- debug,
277
- systemLog,
278
- saveConfig,
279
- })
280
- }
281
-
282
- return firePluginStep({
283
- event,
284
- childProcess,
285
- packageName,
286
- pluginPackageJson,
287
- loadedFrom,
288
- origin,
289
- envChanges,
290
- errorParams,
291
- configOpts,
292
- netlifyConfig,
293
- configMutations,
294
- headersPath,
295
- redirectsPath,
296
- constants,
297
- steps,
298
- error,
299
- logs,
300
- debug,
301
- systemLog,
302
- verbose,
303
- })
304
- }
131
+ if (coreStepId !== undefined) {
132
+ return measureDuration(tFireStep, coreStepId);
133
+ }
134
+ const parentTag = normalizeTimerName(packageName);
135
+ return measureDuration(tFireStep, event, { parentTag, category: 'pluginEvent' });
136
+ };
137
+ const tFireStep = function ({ event, childProcess, packageName, pluginPackageJson, loadedFrom, origin, coreStep, coreStepName, configPath, buildDir, repositoryRoot, nodePath, childEnv, context, branch, envChanges, constants, steps, buildbotServerSocket, events, error, logs, debug, systemLog, verbose, saveConfig, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, featureFlags, }) {
138
+ if (coreStep !== undefined) {
139
+ return fireCoreStep({
140
+ coreStep,
141
+ coreStepName,
142
+ configPath,
143
+ buildDir,
144
+ repositoryRoot,
145
+ constants,
146
+ buildbotServerSocket,
147
+ events,
148
+ logs,
149
+ nodePath,
150
+ childEnv,
151
+ context,
152
+ branch,
153
+ envChanges,
154
+ errorParams,
155
+ configOpts,
156
+ netlifyConfig,
157
+ configMutations,
158
+ headersPath,
159
+ redirectsPath,
160
+ featureFlags,
161
+ debug,
162
+ systemLog,
163
+ saveConfig,
164
+ });
165
+ }
166
+ return firePluginStep({
167
+ event,
168
+ childProcess,
169
+ packageName,
170
+ pluginPackageJson,
171
+ loadedFrom,
172
+ origin,
173
+ envChanges,
174
+ errorParams,
175
+ configOpts,
176
+ netlifyConfig,
177
+ configMutations,
178
+ headersPath,
179
+ redirectsPath,
180
+ constants,
181
+ steps,
182
+ error,
183
+ logs,
184
+ debug,
185
+ systemLog,
186
+ verbose,
187
+ });
188
+ };