@netlify/build 27.18.4 → 27.18.5-rc
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.
- package/package.json +8 -7
- package/src/core/bin.js +0 -83
- package/src/core/build.js +0 -559
- package/src/core/config.js +0 -186
- package/src/core/constants.js +0 -156
- package/src/core/dev.js +0 -31
- package/src/core/dry.js +0 -39
- package/src/core/feature_flags.js +0 -22
- package/src/core/flags.js +0 -204
- package/src/core/lingering.js +0 -85
- package/src/core/main.js +0 -165
- package/src/core/missing_side_file.js +0 -29
- package/src/core/normalize_flags.js +0 -70
- package/src/core/severity.js +0 -22
- package/src/core/user_node_version.js +0 -41
- package/src/env/changes.js +0 -52
- package/src/env/main.js +0 -19
- package/src/env/metadata.js +0 -81
- package/src/error/api.js +0 -46
- package/src/error/build.js +0 -50
- package/src/error/cancel.js +0 -8
- package/src/error/colors.js +0 -11
- package/src/error/handle.js +0 -57
- package/src/error/info.js +0 -46
- package/src/error/monitor/location.js +0 -21
- package/src/error/monitor/normalize.js +0 -96
- package/src/error/monitor/print.js +0 -42
- package/src/error/monitor/report.js +0 -138
- package/src/error/monitor/start.js +0 -69
- package/src/error/parse/clean_stack.js +0 -87
- package/src/error/parse/location.js +0 -62
- package/src/error/parse/normalize.js +0 -29
- package/src/error/parse/parse.js +0 -97
- package/src/error/parse/plugin.js +0 -70
- package/src/error/parse/properties.js +0 -23
- package/src/error/parse/serialize_log.js +0 -42
- package/src/error/parse/serialize_status.js +0 -23
- package/src/error/parse/stack.js +0 -43
- package/src/error/type.js +0 -189
- package/src/install/functions.js +0 -28
- package/src/install/local.js +0 -62
- package/src/install/main.js +0 -81
- package/src/install/missing.js +0 -67
- package/src/log/colors.js +0 -34
- package/src/log/description.js +0 -26
- package/src/log/header.js +0 -16
- package/src/log/header_func.js +0 -17
- package/src/log/logger.js +0 -161
- package/src/log/messages/compatibility.js +0 -178
- package/src/log/messages/config.js +0 -107
- package/src/log/messages/core.js +0 -70
- package/src/log/messages/core_steps.js +0 -104
- package/src/log/messages/dry.js +0 -63
- package/src/log/messages/install.js +0 -32
- package/src/log/messages/ipc.js +0 -38
- package/src/log/messages/mutations.js +0 -82
- package/src/log/messages/plugins.js +0 -39
- package/src/log/messages/status.js +0 -16
- package/src/log/messages/steps.js +0 -22
- package/src/log/old_version.js +0 -41
- package/src/log/serialize.js +0 -13
- package/src/log/stream.js +0 -85
- package/src/log/theme.js +0 -26
- package/src/plugins/child/diff.js +0 -55
- package/src/plugins/child/error.js +0 -32
- package/src/plugins/child/lazy.js +0 -18
- package/src/plugins/child/load.js +0 -29
- package/src/plugins/child/logic.js +0 -65
- package/src/plugins/child/main.js +0 -51
- package/src/plugins/child/run.js +0 -28
- package/src/plugins/child/status.js +0 -74
- package/src/plugins/child/typescript.js +0 -45
- package/src/plugins/child/utils.js +0 -56
- package/src/plugins/child/validate.js +0 -34
- package/src/plugins/compatibility.js +0 -132
- package/src/plugins/error.js +0 -50
- package/src/plugins/events.js +0 -17
- package/src/plugins/expected_version.js +0 -119
- package/src/plugins/ipc.js +0 -145
- package/src/plugins/list.js +0 -86
- package/src/plugins/load.js +0 -70
- package/src/plugins/manifest/check.js +0 -106
- package/src/plugins/manifest/load.js +0 -41
- package/src/plugins/manifest/main.js +0 -22
- package/src/plugins/manifest/path.js +0 -31
- package/src/plugins/manifest/validate.js +0 -108
- package/src/plugins/node_version.js +0 -50
- package/src/plugins/options.js +0 -88
- package/src/plugins/pinned_version.js +0 -131
- package/src/plugins/resolve.js +0 -152
- package/src/plugins/spawn.js +0 -72
- package/src/plugins_core/add.js +0 -49
- package/src/plugins_core/build_command.js +0 -75
- package/src/plugins_core/deploy/buildbot_client.js +0 -113
- package/src/plugins_core/deploy/index.js +0 -73
- package/src/plugins_core/deploy/manifest.yml +0 -1
- package/src/plugins_core/edge_functions/index.js +0 -123
- package/src/plugins_core/edge_functions/lib/error.js +0 -21
- package/src/plugins_core/edge_functions/lib/internal_manifest.js +0 -60
- package/src/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +0 -89
- package/src/plugins_core/functions/error.js +0 -163
- package/src/plugins_core/functions/feature_flags.js +0 -6
- package/src/plugins_core/functions/index.js +0 -161
- package/src/plugins_core/functions/utils.js +0 -66
- package/src/plugins_core/functions/zisi.js +0 -56
- package/src/plugins_core/functions_install/index.js +0 -13
- package/src/plugins_core/functions_install/manifest.yml +0 -1
- package/src/plugins_core/list.js +0 -27
- package/src/status/add.js +0 -36
- package/src/status/colors.js +0 -23
- package/src/status/load_error.js +0 -11
- package/src/status/report.js +0 -137
- package/src/status/success.js +0 -18
- package/src/steps/core_step.js +0 -92
- package/src/steps/error.js +0 -102
- package/src/steps/get.js +0 -51
- package/src/steps/plugin.js +0 -85
- package/src/steps/return.js +0 -52
- package/src/steps/run_core_steps.js +0 -200
- package/src/steps/run_step.js +0 -304
- package/src/steps/run_steps.js +0 -179
- package/src/steps/update_config.js +0 -93
- package/src/telemetry/main.js +0 -136
- package/src/time/aggregate.js +0 -146
- package/src/time/main.js +0 -48
- package/src/time/measure.js +0 -22
- package/src/time/report.js +0 -59
- package/src/utils/errors.js +0 -12
- package/src/utils/json.js +0 -19
- package/src/utils/omit.js +0 -6
- package/src/utils/package.js +0 -23
- package/src/utils/remove_falsy.js +0 -10
- package/src/utils/resolve.js +0 -46
- package/src/utils/runtime.js +0 -5
- package/src/utils/semver.js +0 -34
|
@@ -1,200 +0,0 @@
|
|
|
1
|
-
import { getConfigOpts, loadConfig } from '../core/config.js'
|
|
2
|
-
import { getConstants } from '../core/constants.js'
|
|
3
|
-
import { normalizeFlags } from '../core/normalize_flags.js'
|
|
4
|
-
import { getSeverity } from '../core/severity.js'
|
|
5
|
-
import { handleBuildError } from '../error/handle.js'
|
|
6
|
-
import { getErrorInfo } from '../error/info.js'
|
|
7
|
-
import { startErrorMonitor } from '../error/monitor/start.js'
|
|
8
|
-
import { getBufferLogs, getSystemLogger } from '../log/logger.js'
|
|
9
|
-
import { logBuildStart } from '../log/messages/core.js'
|
|
10
|
-
import { reportStatuses } from '../status/report.js'
|
|
11
|
-
|
|
12
|
-
import { getSteps } from './get.js'
|
|
13
|
-
import { runSteps } from './run_steps.js'
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
* Runs specific core steps for a build and returns whether it succeeded or not.
|
|
17
|
-
*
|
|
18
|
-
* @param {string[]} [buildSteps] - a string array of build steps to run
|
|
19
|
-
* @param {object} [flags] - build configuration CLI flags
|
|
20
|
-
* @param {string} [flags.config] - Path to the configuration file
|
|
21
|
-
* @param {string} [flags.cwd] - Current directory. Used to retrieve the configuration file
|
|
22
|
-
* @param {string} [flags.repositoryRoot] - Git repository root directory. Used to retrieve the configuration file.
|
|
23
|
-
* @param {string} [flags.apiHost] - Netlify API endpoint
|
|
24
|
-
* @param {string} [flags.token] - Netlify API token for authentication
|
|
25
|
-
* @param {string} [flags.siteId] - Netlify Site ID
|
|
26
|
-
* @param {string} [flags.deployId] - Netlify Deploy ID
|
|
27
|
-
* @param {string} [flags.context] - Build context
|
|
28
|
-
* @param {string} [flags.branch] - Repository branch
|
|
29
|
-
* @param {boolean} [flags.dry=false] - Run in dry mode, i.e. printing steps without executing them
|
|
30
|
-
* @param {string} [flags.nodePath] - Path to the Node.js binary to use in the build command and plugins
|
|
31
|
-
* @param {boolean} [flags.buffer=false] - Buffer output instead of printing it
|
|
32
|
-
*
|
|
33
|
-
* @returns {object} buildResult
|
|
34
|
-
* @returns {boolean} buildResult.success - Whether build succeeded or failed
|
|
35
|
-
* @returns {number} buildResult.severityCode - Build success/failure status among:
|
|
36
|
-
* 0 (success), 1 (build cancelled), 2 (user error), 3 (plugin error), 4 (system error). Can be used as exit code.
|
|
37
|
-
* @returns {string[]} buildResult.logs - When using the `buffer` option, all log messages
|
|
38
|
-
*/
|
|
39
|
-
export const runCoreSteps = async (buildSteps, flags = {}) => {
|
|
40
|
-
const { errorMonitor, mode, logs, debug, ...flagsA } = startBuild(flags)
|
|
41
|
-
const errorParams = { errorMonitor, mode, logs, debug }
|
|
42
|
-
const systemLog = getSystemLogger(logs, debug)
|
|
43
|
-
|
|
44
|
-
try {
|
|
45
|
-
const { netlifyConfig: netlifyConfigA, configMutations } = await executeBuildStep({
|
|
46
|
-
...flagsA,
|
|
47
|
-
errorMonitor,
|
|
48
|
-
mode,
|
|
49
|
-
logs,
|
|
50
|
-
debug,
|
|
51
|
-
errorParams,
|
|
52
|
-
buildSteps,
|
|
53
|
-
systemLog,
|
|
54
|
-
})
|
|
55
|
-
const { success, severityCode } = getSeverity('success')
|
|
56
|
-
|
|
57
|
-
return { success, severityCode, netlifyConfig: netlifyConfigA, configMutations, logs }
|
|
58
|
-
} catch (error) {
|
|
59
|
-
const { severity } = await handleBuildError(error, errorParams)
|
|
60
|
-
const { success, severityCode } = getSeverity(severity)
|
|
61
|
-
|
|
62
|
-
return { success, severityCode, logs }
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const startBuild = function (flags) {
|
|
67
|
-
const logs = getBufferLogs(flags)
|
|
68
|
-
|
|
69
|
-
logBuildStart(logs)
|
|
70
|
-
|
|
71
|
-
const { bugsnagKey, ...flagsA } = normalizeFlags(flags, logs)
|
|
72
|
-
const errorMonitor = startErrorMonitor({ flags: flagsA, logs, bugsnagKey })
|
|
73
|
-
|
|
74
|
-
return { ...flagsA, errorMonitor, logs }
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const getBuildSteps = function (buildSteps) {
|
|
78
|
-
const allSteps = getSteps([]).steps.filter(({ coreStepId }) => buildSteps.includes(coreStepId))
|
|
79
|
-
|
|
80
|
-
return allSteps
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const executeBuildStep = async function ({
|
|
84
|
-
config,
|
|
85
|
-
defaultConfig,
|
|
86
|
-
cachedConfig,
|
|
87
|
-
debug,
|
|
88
|
-
nodePath,
|
|
89
|
-
functionsDistDir,
|
|
90
|
-
edgeFunctionsDistDir,
|
|
91
|
-
errorMonitor,
|
|
92
|
-
mode,
|
|
93
|
-
logs,
|
|
94
|
-
errorParams,
|
|
95
|
-
featureFlags,
|
|
96
|
-
buildSteps,
|
|
97
|
-
repositoryRoot,
|
|
98
|
-
systemLog,
|
|
99
|
-
}) {
|
|
100
|
-
const configOpts = getConfigOpts({
|
|
101
|
-
config,
|
|
102
|
-
defaultConfig,
|
|
103
|
-
featureFlags,
|
|
104
|
-
mode,
|
|
105
|
-
repositoryRoot,
|
|
106
|
-
})
|
|
107
|
-
const {
|
|
108
|
-
netlifyConfig,
|
|
109
|
-
buildDir,
|
|
110
|
-
siteInfo,
|
|
111
|
-
childEnv,
|
|
112
|
-
userNodeVersion,
|
|
113
|
-
repositoryRoot: repositoryRootA,
|
|
114
|
-
} = await loadConfig({
|
|
115
|
-
configOpts,
|
|
116
|
-
cachedConfig,
|
|
117
|
-
debug,
|
|
118
|
-
logs,
|
|
119
|
-
nodePath,
|
|
120
|
-
timers: [],
|
|
121
|
-
})
|
|
122
|
-
const constants = await getConstants({
|
|
123
|
-
buildDir,
|
|
124
|
-
functionsDistDir,
|
|
125
|
-
edgeFunctionsDistDir,
|
|
126
|
-
netlifyConfig,
|
|
127
|
-
siteInfo,
|
|
128
|
-
mode,
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
// eslint-disable-next-line fp/no-mutating-assign
|
|
132
|
-
Object.assign(errorParams, { netlifyConfig, siteInfo, childEnv, userNodeVersion })
|
|
133
|
-
|
|
134
|
-
try {
|
|
135
|
-
const { netlifyConfig: netlifyConfigA, configMutations } = await runBuildStep({
|
|
136
|
-
netlifyConfig,
|
|
137
|
-
buildDir,
|
|
138
|
-
nodePath,
|
|
139
|
-
logs,
|
|
140
|
-
debug,
|
|
141
|
-
constants,
|
|
142
|
-
featureFlags,
|
|
143
|
-
childEnv,
|
|
144
|
-
buildSteps,
|
|
145
|
-
repositoryRoot: repositoryRootA,
|
|
146
|
-
systemLog,
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
return {
|
|
150
|
-
netlifyConfig: netlifyConfigA,
|
|
151
|
-
configMutations,
|
|
152
|
-
}
|
|
153
|
-
} catch (error) {
|
|
154
|
-
const [{ statuses }] = getErrorInfo(error)
|
|
155
|
-
|
|
156
|
-
await reportStatuses({
|
|
157
|
-
statuses,
|
|
158
|
-
childEnv,
|
|
159
|
-
mode,
|
|
160
|
-
netlifyConfig,
|
|
161
|
-
errorMonitor,
|
|
162
|
-
logs,
|
|
163
|
-
debug,
|
|
164
|
-
pluginsOptions: [],
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
throw error
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const runBuildStep = async function ({
|
|
172
|
-
netlifyConfig,
|
|
173
|
-
buildDir,
|
|
174
|
-
nodePath,
|
|
175
|
-
constants,
|
|
176
|
-
logs,
|
|
177
|
-
debug,
|
|
178
|
-
featureFlags,
|
|
179
|
-
childEnv,
|
|
180
|
-
buildSteps,
|
|
181
|
-
repositoryRoot,
|
|
182
|
-
systemLog,
|
|
183
|
-
}) {
|
|
184
|
-
const { netlifyConfig: netlifyConfigA, configMutations } = await runSteps({
|
|
185
|
-
steps: getBuildSteps(buildSteps),
|
|
186
|
-
buildDir,
|
|
187
|
-
nodePath,
|
|
188
|
-
constants,
|
|
189
|
-
netlifyConfig,
|
|
190
|
-
logs,
|
|
191
|
-
debug,
|
|
192
|
-
timers: [],
|
|
193
|
-
featureFlags,
|
|
194
|
-
childEnv,
|
|
195
|
-
repositoryRoot,
|
|
196
|
-
systemLog,
|
|
197
|
-
})
|
|
198
|
-
|
|
199
|
-
return { netlifyConfig: netlifyConfigA, configMutations }
|
|
200
|
-
}
|
package/src/steps/run_step.js
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
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
|
-
|
|
10
|
-
// 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
|
-
|
|
152
|
-
// A plugin fails _without making the build fail_ when either:
|
|
153
|
-
// - using `utils.build.failPlugin()`
|
|
154
|
-
// - the failure happens after deploy. This means: inside any `onError`,
|
|
155
|
-
// `onSuccess` or `onEnd` event handler.
|
|
156
|
-
//
|
|
157
|
-
// When that happens, no other events for that specific plugin is run.
|
|
158
|
-
// Not even `onError` and `onEnd`.
|
|
159
|
-
// Plugins should use `try`/`catch`/`finally` blocks to handle exceptions,
|
|
160
|
-
// not `onError` nor `onEnd`.
|
|
161
|
-
//
|
|
162
|
-
// Otherwise, most failures will make the build fail. This includes:
|
|
163
|
-
// - the build command failed
|
|
164
|
-
// - Functions or Edge Functions bundling failed
|
|
165
|
-
// - the deploy failed (deploying files to our CDN)
|
|
166
|
-
// - a plugin `onPreBuild`, `onBuild` or `onPostBuild` event handler failed.
|
|
167
|
-
// This includes uncaught exceptions and using `utils.build.failBuild()`
|
|
168
|
-
// or `utils.build.cancelBuild()`.
|
|
169
|
-
//
|
|
170
|
-
// `onError` is triggered when the build failed.
|
|
171
|
-
// It means "on build failure" not "on plugin failure".
|
|
172
|
-
// `onSuccess` is the opposite. It is triggered after the build succeeded.
|
|
173
|
-
// `onEnd` is triggered after the build either failed or succeeded.
|
|
174
|
-
// It is useful for resources cleanup.
|
|
175
|
-
//
|
|
176
|
-
// Finally, some plugins (only core plugins for the moment) might be enabled or
|
|
177
|
-
// not depending on whether a specific action is happening during the build,
|
|
178
|
-
// such as creating a file. For example, the Functions and Edge Functions core
|
|
179
|
-
// plugins are disabled if no Functions or Edge Functions directory is specified
|
|
180
|
-
// or available. However, one might be created by a build plugin, in which case,
|
|
181
|
-
// those core plugins should be triggered. We use a dynamic `condition()` to
|
|
182
|
-
// 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
|
-
|
|
208
|
-
// Wrap step function to measure its time
|
|
209
|
-
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
|
-
}
|
package/src/steps/run_steps.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
import pReduce from 'p-reduce'
|
|
2
|
-
|
|
3
|
-
import { addErrorInfo } from '../error/info.js'
|
|
4
|
-
import { addStatus } from '../status/add.js'
|
|
5
|
-
|
|
6
|
-
import { runStep } from './run_step.js'
|
|
7
|
-
|
|
8
|
-
// Run all steps.
|
|
9
|
-
// Each step can change some state: last `error`, environment variables changes,
|
|
10
|
-
// list of `failedPlugins` (that ran `utils.build.failPlugin()`).
|
|
11
|
-
// If an error arises, runs `onError` events.
|
|
12
|
-
// Runs `onEnd` events at the end, whether an error was thrown or not.
|
|
13
|
-
export const runSteps = async function ({
|
|
14
|
-
steps,
|
|
15
|
-
buildbotServerSocket,
|
|
16
|
-
events,
|
|
17
|
-
configPath,
|
|
18
|
-
headersPath,
|
|
19
|
-
redirectsPath,
|
|
20
|
-
buildDir,
|
|
21
|
-
repositoryRoot,
|
|
22
|
-
nodePath,
|
|
23
|
-
childEnv,
|
|
24
|
-
context,
|
|
25
|
-
branch,
|
|
26
|
-
constants,
|
|
27
|
-
mode,
|
|
28
|
-
api,
|
|
29
|
-
errorMonitor,
|
|
30
|
-
deployId,
|
|
31
|
-
errorParams,
|
|
32
|
-
netlifyConfig,
|
|
33
|
-
configOpts,
|
|
34
|
-
logs,
|
|
35
|
-
debug,
|
|
36
|
-
systemLog,
|
|
37
|
-
verbose,
|
|
38
|
-
saveConfig,
|
|
39
|
-
timers,
|
|
40
|
-
testOpts,
|
|
41
|
-
featureFlags,
|
|
42
|
-
}) {
|
|
43
|
-
const {
|
|
44
|
-
index: stepsCount,
|
|
45
|
-
error: errorA,
|
|
46
|
-
netlifyConfig: netlifyConfigC,
|
|
47
|
-
statuses: statusesB,
|
|
48
|
-
failedPlugins: failedPluginsA,
|
|
49
|
-
timers: timersC,
|
|
50
|
-
configMutations: configMutationsB,
|
|
51
|
-
} = await pReduce(
|
|
52
|
-
steps,
|
|
53
|
-
async (
|
|
54
|
-
{
|
|
55
|
-
index,
|
|
56
|
-
error,
|
|
57
|
-
failedPlugins,
|
|
58
|
-
envChanges,
|
|
59
|
-
netlifyConfig: netlifyConfigA,
|
|
60
|
-
configMutations,
|
|
61
|
-
headersPath: headersPathA,
|
|
62
|
-
redirectsPath: redirectsPathA,
|
|
63
|
-
statuses,
|
|
64
|
-
timers: timersA,
|
|
65
|
-
},
|
|
66
|
-
{
|
|
67
|
-
event,
|
|
68
|
-
childProcess,
|
|
69
|
-
packageName,
|
|
70
|
-
coreStep,
|
|
71
|
-
coreStepId,
|
|
72
|
-
coreStepName,
|
|
73
|
-
coreStepDescription,
|
|
74
|
-
pluginPackageJson,
|
|
75
|
-
loadedFrom,
|
|
76
|
-
origin,
|
|
77
|
-
condition,
|
|
78
|
-
},
|
|
79
|
-
) => {
|
|
80
|
-
const {
|
|
81
|
-
newIndex = index,
|
|
82
|
-
newError = error,
|
|
83
|
-
failedPlugin = [],
|
|
84
|
-
newEnvChanges = {},
|
|
85
|
-
netlifyConfig: netlifyConfigB = netlifyConfigA,
|
|
86
|
-
configMutations: configMutationsA = configMutations,
|
|
87
|
-
headersPath: headersPathB = headersPathA,
|
|
88
|
-
redirectsPath: redirectsPathB = redirectsPathA,
|
|
89
|
-
newStatus,
|
|
90
|
-
timers: timersB = timersA,
|
|
91
|
-
} = await runStep({
|
|
92
|
-
event,
|
|
93
|
-
childProcess,
|
|
94
|
-
packageName,
|
|
95
|
-
coreStep,
|
|
96
|
-
coreStepId,
|
|
97
|
-
coreStepName,
|
|
98
|
-
coreStepDescription,
|
|
99
|
-
pluginPackageJson,
|
|
100
|
-
loadedFrom,
|
|
101
|
-
origin,
|
|
102
|
-
condition,
|
|
103
|
-
configPath,
|
|
104
|
-
buildDir,
|
|
105
|
-
repositoryRoot,
|
|
106
|
-
nodePath,
|
|
107
|
-
index,
|
|
108
|
-
childEnv,
|
|
109
|
-
context,
|
|
110
|
-
branch,
|
|
111
|
-
envChanges,
|
|
112
|
-
constants,
|
|
113
|
-
steps,
|
|
114
|
-
buildbotServerSocket,
|
|
115
|
-
events,
|
|
116
|
-
mode,
|
|
117
|
-
api,
|
|
118
|
-
errorMonitor,
|
|
119
|
-
deployId,
|
|
120
|
-
errorParams,
|
|
121
|
-
error,
|
|
122
|
-
failedPlugins,
|
|
123
|
-
configOpts,
|
|
124
|
-
netlifyConfig: netlifyConfigA,
|
|
125
|
-
configMutations,
|
|
126
|
-
headersPath: headersPathA,
|
|
127
|
-
redirectsPath: redirectsPathA,
|
|
128
|
-
logs,
|
|
129
|
-
debug,
|
|
130
|
-
systemLog,
|
|
131
|
-
verbose,
|
|
132
|
-
saveConfig,
|
|
133
|
-
timers: timersA,
|
|
134
|
-
testOpts,
|
|
135
|
-
featureFlags,
|
|
136
|
-
})
|
|
137
|
-
const statusesA = addStatus({ newStatus, statuses, event, packageName, pluginPackageJson })
|
|
138
|
-
return {
|
|
139
|
-
index: newIndex,
|
|
140
|
-
error: newError,
|
|
141
|
-
failedPlugins: [...failedPlugins, ...failedPlugin],
|
|
142
|
-
envChanges: { ...envChanges, ...newEnvChanges },
|
|
143
|
-
netlifyConfig: netlifyConfigB,
|
|
144
|
-
configMutations: configMutationsA,
|
|
145
|
-
headersPath: headersPathB,
|
|
146
|
-
redirectsPath: redirectsPathB,
|
|
147
|
-
statuses: statusesA,
|
|
148
|
-
timers: timersB,
|
|
149
|
-
}
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
index: 0,
|
|
153
|
-
failedPlugins: [],
|
|
154
|
-
envChanges: {},
|
|
155
|
-
netlifyConfig,
|
|
156
|
-
configMutations: [],
|
|
157
|
-
headersPath,
|
|
158
|
-
redirectsPath,
|
|
159
|
-
statuses: [],
|
|
160
|
-
timers,
|
|
161
|
-
},
|
|
162
|
-
)
|
|
163
|
-
|
|
164
|
-
// Instead of throwing any build failure right away, we wait for `onError`,
|
|
165
|
-
// etc. to complete. This is why we are throwing only now.
|
|
166
|
-
if (errorA !== undefined) {
|
|
167
|
-
addErrorInfo(errorA, { statuses: statusesB })
|
|
168
|
-
throw errorA
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return {
|
|
172
|
-
stepsCount,
|
|
173
|
-
netlifyConfig: netlifyConfigC,
|
|
174
|
-
statuses: statusesB,
|
|
175
|
-
failedPlugins: failedPluginsA,
|
|
176
|
-
timers: timersC,
|
|
177
|
-
configMutations: configMutationsB,
|
|
178
|
-
}
|
|
179
|
-
}
|