@netlify/build 27.18.8-rc → 27.18.9-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/lib/core/bin.js +83 -0
- package/lib/core/build.js +559 -0
- package/lib/core/config.js +186 -0
- package/lib/core/constants.js +156 -0
- package/lib/core/dev.js +31 -0
- package/lib/core/dry.js +39 -0
- package/lib/core/feature_flags.js +22 -0
- package/lib/core/flags.js +204 -0
- package/lib/core/lingering.js +85 -0
- package/lib/core/main.js +165 -0
- package/lib/core/missing_side_file.js +29 -0
- package/lib/core/normalize_flags.js +70 -0
- package/lib/core/severity.js +22 -0
- package/lib/core/user_node_version.js +41 -0
- package/lib/env/changes.js +52 -0
- package/lib/env/main.js +19 -0
- package/lib/env/metadata.js +81 -0
- package/lib/error/api.js +46 -0
- package/lib/error/build.js +50 -0
- package/lib/error/cancel.js +8 -0
- package/lib/error/colors.js +11 -0
- package/lib/error/handle.js +57 -0
- package/lib/error/info.js +46 -0
- package/lib/error/monitor/location.js +21 -0
- package/lib/error/monitor/normalize.js +96 -0
- package/lib/error/monitor/print.js +42 -0
- package/lib/error/monitor/report.js +138 -0
- package/lib/error/monitor/start.js +69 -0
- package/lib/error/parse/clean_stack.js +87 -0
- package/lib/error/parse/location.js +62 -0
- package/lib/error/parse/normalize.js +29 -0
- package/lib/error/parse/parse.js +97 -0
- package/lib/error/parse/plugin.js +70 -0
- package/lib/error/parse/properties.js +23 -0
- package/lib/error/parse/serialize_log.js +42 -0
- package/lib/error/parse/serialize_status.js +23 -0
- package/lib/error/parse/stack.js +43 -0
- package/lib/error/type.js +189 -0
- package/lib/install/functions.js +28 -0
- package/lib/install/local.js +62 -0
- package/lib/install/main.js +81 -0
- package/lib/install/missing.js +67 -0
- package/lib/log/colors.js +34 -0
- package/lib/log/description.js +26 -0
- package/lib/log/header.js +16 -0
- package/lib/log/header_func.js +17 -0
- package/lib/log/logger.js +161 -0
- package/lib/log/messages/compatibility.js +178 -0
- package/lib/log/messages/config.js +107 -0
- package/lib/log/messages/core.js +70 -0
- package/lib/log/messages/core_steps.js +104 -0
- package/lib/log/messages/dry.js +63 -0
- package/lib/log/messages/install.js +32 -0
- package/lib/log/messages/ipc.js +38 -0
- package/lib/log/messages/mutations.js +82 -0
- package/lib/log/messages/plugins.js +39 -0
- package/lib/log/messages/status.js +16 -0
- package/lib/log/messages/steps.js +22 -0
- package/lib/log/old_version.js +41 -0
- package/lib/log/serialize.js +13 -0
- package/lib/log/stream.js +85 -0
- package/lib/log/theme.js +26 -0
- package/lib/plugins/child/diff.js +55 -0
- package/lib/plugins/child/error.js +32 -0
- package/lib/plugins/child/lazy.js +18 -0
- package/lib/plugins/child/load.js +29 -0
- package/lib/plugins/child/logic.js +65 -0
- package/lib/plugins/child/main.js +51 -0
- package/lib/plugins/child/run.js +28 -0
- package/lib/plugins/child/status.js +74 -0
- package/lib/plugins/child/typescript.js +45 -0
- package/lib/plugins/child/utils.js +56 -0
- package/lib/plugins/child/validate.js +34 -0
- package/lib/plugins/compatibility.js +132 -0
- package/lib/plugins/error.js +50 -0
- package/lib/plugins/events.js +17 -0
- package/lib/plugins/expected_version.js +119 -0
- package/lib/plugins/ipc.js +145 -0
- package/lib/plugins/list.js +86 -0
- package/lib/plugins/load.js +70 -0
- package/lib/plugins/manifest/check.js +106 -0
- package/lib/plugins/manifest/load.js +41 -0
- package/lib/plugins/manifest/main.js +22 -0
- package/lib/plugins/manifest/path.js +31 -0
- package/lib/plugins/manifest/validate.js +108 -0
- package/lib/plugins/node_version.js +50 -0
- package/lib/plugins/options.js +88 -0
- package/lib/plugins/pinned_version.js +131 -0
- package/lib/plugins/resolve.js +152 -0
- package/lib/plugins/spawn.js +72 -0
- package/lib/plugins_core/add.js +49 -0
- package/lib/plugins_core/build_command.js +75 -0
- package/lib/plugins_core/deploy/buildbot_client.js +113 -0
- package/lib/plugins_core/deploy/index.js +73 -0
- package/lib/plugins_core/deploy/manifest.yml +1 -0
- package/lib/plugins_core/edge_functions/index.js +123 -0
- package/lib/plugins_core/edge_functions/lib/error.js +21 -0
- package/lib/plugins_core/edge_functions/lib/internal_manifest.js +60 -0
- package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +89 -0
- package/lib/plugins_core/functions/error.js +163 -0
- package/lib/plugins_core/functions/feature_flags.js +6 -0
- package/lib/plugins_core/functions/index.js +161 -0
- package/lib/plugins_core/functions/utils.js +66 -0
- package/lib/plugins_core/functions/zisi.js +56 -0
- package/lib/plugins_core/functions_install/index.js +13 -0
- package/lib/plugins_core/functions_install/manifest.yml +1 -0
- package/lib/plugins_core/list.js +27 -0
- package/lib/status/add.js +36 -0
- package/lib/status/colors.js +23 -0
- package/lib/status/load_error.js +11 -0
- package/lib/status/report.js +137 -0
- package/lib/status/success.js +18 -0
- package/lib/steps/core_step.js +92 -0
- package/lib/steps/error.js +102 -0
- package/lib/steps/get.js +51 -0
- package/lib/steps/plugin.js +85 -0
- package/lib/steps/return.js +52 -0
- package/lib/steps/run_core_steps.js +200 -0
- package/lib/steps/run_step.js +304 -0
- package/lib/steps/run_steps.js +179 -0
- package/lib/steps/update_config.js +93 -0
- package/lib/telemetry/main.js +136 -0
- package/lib/time/aggregate.js +146 -0
- package/lib/time/main.js +48 -0
- package/lib/time/measure.js +22 -0
- package/lib/time/report.js +59 -0
- package/lib/utils/errors.js +12 -0
- package/lib/utils/json.js +19 -0
- package/lib/utils/omit.js +6 -0
- package/lib/utils/package.js +23 -0
- package/lib/utils/remove_falsy.js +10 -0
- package/lib/utils/resolve.js +46 -0
- package/lib/utils/runtime.js +5 -0
- package/lib/utils/semver.js +34 -0
- package/package.json +6 -6
package/lib/core/bin.js
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import process from 'process'
|
|
4
|
+
|
|
5
|
+
import filterObj from 'filter-obj'
|
|
6
|
+
import yargs from 'yargs'
|
|
7
|
+
import { hideBin } from 'yargs/helpers'
|
|
8
|
+
|
|
9
|
+
import { normalizeCliFeatureFlags } from './feature_flags.js'
|
|
10
|
+
import { FLAGS } from './flags.js'
|
|
11
|
+
import build from './main.js'
|
|
12
|
+
import { FALLBACK_SEVERITY_ENTRY } from './severity.js'
|
|
13
|
+
|
|
14
|
+
// CLI entry point.
|
|
15
|
+
// Before adding logic to this file, please consider adding it to the main
|
|
16
|
+
// programmatic command instead, so that the new logic is available when run
|
|
17
|
+
// programmatically as well. This file should only contain logic that makes
|
|
18
|
+
// sense only in CLI, such as CLI flags parsing and exit code.
|
|
19
|
+
const runCli = async function () {
|
|
20
|
+
const flags = parseFlags()
|
|
21
|
+
const flagsA = filterObj(flags, isUserFlag)
|
|
22
|
+
|
|
23
|
+
const state = { done: false }
|
|
24
|
+
process.on('exit', onExit.bind(undefined, state))
|
|
25
|
+
|
|
26
|
+
const { severityCode, logs } = await build(flagsA)
|
|
27
|
+
printLogs(logs)
|
|
28
|
+
process.exitCode = severityCode
|
|
29
|
+
|
|
30
|
+
state.done = true
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const parseFlags = function () {
|
|
34
|
+
const { featureFlags: cliFeatureFlags = '', ...flags } = yargs(hideBin(process.argv))
|
|
35
|
+
.options(FLAGS)
|
|
36
|
+
.usage(USAGE)
|
|
37
|
+
.parse()
|
|
38
|
+
const featureFlags = normalizeCliFeatureFlags(cliFeatureFlags)
|
|
39
|
+
return { ...flags, featureFlags }
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const USAGE = `netlify-build [OPTIONS...]
|
|
43
|
+
|
|
44
|
+
Run Netlify Build system locally.
|
|
45
|
+
|
|
46
|
+
Options can also be specified as environment variables prefixed with
|
|
47
|
+
NETLIFY_BUILD_. For example the environment variable NETLIFY_BUILD_DRY=true can
|
|
48
|
+
be used instead of the CLI flag --dry.`
|
|
49
|
+
|
|
50
|
+
// Remove `yargs`-specific options, shortcuts, dash-cased and aliases
|
|
51
|
+
const isUserFlag = function (key, value) {
|
|
52
|
+
return value !== undefined && !INTERNAL_KEYS.has(key) && key.length !== 1 && !key.includes('-')
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
const INTERNAL_KEYS = new Set(['help', 'version', '_', '$0', 'dryRun'])
|
|
56
|
+
|
|
57
|
+
// Used mostly for testing
|
|
58
|
+
const printLogs = function (logs) {
|
|
59
|
+
if (logs === undefined) {
|
|
60
|
+
return
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const allLogs = [logs.stdout.join('\n'), logs.stderr.join('\n')].filter(Boolean).join('\n\n')
|
|
64
|
+
console.log(allLogs)
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
// In theory, the main process should not exit until the main `build()` function
|
|
68
|
+
// has completed. In practice, this might happen due to bugs.
|
|
69
|
+
// Making the exit code not 0 in that case ensures the caller knows that the
|
|
70
|
+
// build has completed when the exit code is 0. This `exit` event handlers
|
|
71
|
+
// guarantees this.
|
|
72
|
+
const onExit = function ({ done }, exitCode) {
|
|
73
|
+
if (done || exitCode !== 0) {
|
|
74
|
+
return
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const [, processName] = process.argv
|
|
78
|
+
console.log(`${processName} exited with exit code ${exitCode} without finishing the build.`)
|
|
79
|
+
|
|
80
|
+
process.exitCode = FALLBACK_SEVERITY_ENTRY.severityCode
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
runCli()
|
|
@@ -0,0 +1,559 @@
|
|
|
1
|
+
import { getErrorInfo } from '../error/info.js'
|
|
2
|
+
import { startErrorMonitor } from '../error/monitor/start.js'
|
|
3
|
+
import { getBufferLogs, getSystemLogger } from '../log/logger.js'
|
|
4
|
+
import { logBuildStart } from '../log/messages/core.js'
|
|
5
|
+
import { loadPlugins } from '../plugins/load.js'
|
|
6
|
+
import { getPluginsOptions } from '../plugins/options.js'
|
|
7
|
+
import { pinPlugins } from '../plugins/pinned_version.js'
|
|
8
|
+
import { startPlugins, stopPlugins } from '../plugins/spawn.js'
|
|
9
|
+
import { addCorePlugins } from '../plugins_core/add.js'
|
|
10
|
+
import { reportStatuses } from '../status/report.js'
|
|
11
|
+
import { getDevSteps, getSteps } from '../steps/get.js'
|
|
12
|
+
import { runSteps } from '../steps/run_steps.js'
|
|
13
|
+
import { initTimers, measureDuration } from '../time/main.js'
|
|
14
|
+
|
|
15
|
+
import { getConfigOpts, loadConfig } from './config.js'
|
|
16
|
+
import { getConstants } from './constants.js'
|
|
17
|
+
import { doDryRun } from './dry.js'
|
|
18
|
+
import { warnOnLingeringProcesses } from './lingering.js'
|
|
19
|
+
import { warnOnMissingSideFiles } from './missing_side_file.js'
|
|
20
|
+
import { normalizeFlags } from './normalize_flags.js'
|
|
21
|
+
|
|
22
|
+
// Performed on build start. Must be kept small and unlikely to fail since it
|
|
23
|
+
// does not have proper error handling. Error handling relies on `errorMonitor`
|
|
24
|
+
// being built, which relies itself on flags being normalized.
|
|
25
|
+
export const startBuild = function (flags) {
|
|
26
|
+
const timers = initTimers()
|
|
27
|
+
|
|
28
|
+
const logs = getBufferLogs(flags)
|
|
29
|
+
logBuildStart(logs)
|
|
30
|
+
|
|
31
|
+
const { bugsnagKey, ...flagsA } = normalizeFlags(flags, logs)
|
|
32
|
+
const errorMonitor = startErrorMonitor({ flags: flagsA, logs, bugsnagKey })
|
|
33
|
+
|
|
34
|
+
return { ...flagsA, errorMonitor, logs, timers }
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const tExecBuild = async function ({
|
|
38
|
+
config,
|
|
39
|
+
defaultConfig,
|
|
40
|
+
cachedConfig,
|
|
41
|
+
cachedConfigPath,
|
|
42
|
+
cwd,
|
|
43
|
+
repositoryRoot,
|
|
44
|
+
apiHost,
|
|
45
|
+
token,
|
|
46
|
+
siteId,
|
|
47
|
+
context,
|
|
48
|
+
branch,
|
|
49
|
+
baseRelDir,
|
|
50
|
+
env: envOpt,
|
|
51
|
+
debug,
|
|
52
|
+
systemLogFile,
|
|
53
|
+
verbose,
|
|
54
|
+
nodePath,
|
|
55
|
+
functionsDistDir,
|
|
56
|
+
edgeFunctionsDistDir,
|
|
57
|
+
cacheDir,
|
|
58
|
+
dry,
|
|
59
|
+
mode,
|
|
60
|
+
offline,
|
|
61
|
+
deployId,
|
|
62
|
+
buildId,
|
|
63
|
+
testOpts,
|
|
64
|
+
errorMonitor,
|
|
65
|
+
errorParams,
|
|
66
|
+
logs,
|
|
67
|
+
timers,
|
|
68
|
+
buildbotServerSocket,
|
|
69
|
+
sendStatus,
|
|
70
|
+
saveConfig,
|
|
71
|
+
featureFlags,
|
|
72
|
+
timeline,
|
|
73
|
+
devCommand,
|
|
74
|
+
}) {
|
|
75
|
+
const configOpts = getConfigOpts({
|
|
76
|
+
config,
|
|
77
|
+
defaultConfig,
|
|
78
|
+
cwd,
|
|
79
|
+
repositoryRoot,
|
|
80
|
+
apiHost,
|
|
81
|
+
token,
|
|
82
|
+
siteId,
|
|
83
|
+
context,
|
|
84
|
+
branch,
|
|
85
|
+
baseRelDir,
|
|
86
|
+
envOpt,
|
|
87
|
+
mode,
|
|
88
|
+
offline,
|
|
89
|
+
deployId,
|
|
90
|
+
buildId,
|
|
91
|
+
testOpts,
|
|
92
|
+
featureFlags,
|
|
93
|
+
})
|
|
94
|
+
const {
|
|
95
|
+
netlifyConfig,
|
|
96
|
+
configPath,
|
|
97
|
+
headersPath,
|
|
98
|
+
redirectsPath,
|
|
99
|
+
buildDir,
|
|
100
|
+
repositoryRoot: repositoryRootA,
|
|
101
|
+
packageJson,
|
|
102
|
+
userNodeVersion,
|
|
103
|
+
childEnv,
|
|
104
|
+
context: contextA,
|
|
105
|
+
branch: branchA,
|
|
106
|
+
token: tokenA,
|
|
107
|
+
api,
|
|
108
|
+
siteInfo,
|
|
109
|
+
timers: timersA,
|
|
110
|
+
} = await loadConfig({
|
|
111
|
+
configOpts,
|
|
112
|
+
cachedConfig,
|
|
113
|
+
cachedConfigPath,
|
|
114
|
+
envOpt,
|
|
115
|
+
debug,
|
|
116
|
+
logs,
|
|
117
|
+
nodePath,
|
|
118
|
+
timers,
|
|
119
|
+
})
|
|
120
|
+
const constants = await getConstants({
|
|
121
|
+
configPath,
|
|
122
|
+
buildDir,
|
|
123
|
+
functionsDistDir,
|
|
124
|
+
edgeFunctionsDistDir,
|
|
125
|
+
cacheDir,
|
|
126
|
+
netlifyConfig,
|
|
127
|
+
siteInfo,
|
|
128
|
+
apiHost,
|
|
129
|
+
token: tokenA,
|
|
130
|
+
mode,
|
|
131
|
+
testOpts,
|
|
132
|
+
})
|
|
133
|
+
const systemLog = getSystemLogger(logs, debug, systemLogFile)
|
|
134
|
+
const pluginsOptions = addCorePlugins({ netlifyConfig, constants })
|
|
135
|
+
// `errorParams` is purposely stateful
|
|
136
|
+
// eslint-disable-next-line fp/no-mutating-assign
|
|
137
|
+
Object.assign(errorParams, { netlifyConfig, pluginsOptions, siteInfo, childEnv, userNodeVersion })
|
|
138
|
+
|
|
139
|
+
const {
|
|
140
|
+
pluginsOptions: pluginsOptionsA,
|
|
141
|
+
netlifyConfig: netlifyConfigA,
|
|
142
|
+
stepsCount,
|
|
143
|
+
timers: timersB,
|
|
144
|
+
configMutations,
|
|
145
|
+
} = await runAndReportBuild({
|
|
146
|
+
pluginsOptions,
|
|
147
|
+
netlifyConfig,
|
|
148
|
+
configOpts,
|
|
149
|
+
siteInfo,
|
|
150
|
+
configPath,
|
|
151
|
+
headersPath,
|
|
152
|
+
redirectsPath,
|
|
153
|
+
buildDir,
|
|
154
|
+
repositoryRoot: repositoryRootA,
|
|
155
|
+
nodePath,
|
|
156
|
+
packageJson,
|
|
157
|
+
userNodeVersion,
|
|
158
|
+
childEnv,
|
|
159
|
+
context: contextA,
|
|
160
|
+
branch: branchA,
|
|
161
|
+
dry,
|
|
162
|
+
mode,
|
|
163
|
+
api,
|
|
164
|
+
errorMonitor,
|
|
165
|
+
deployId,
|
|
166
|
+
errorParams,
|
|
167
|
+
logs,
|
|
168
|
+
debug,
|
|
169
|
+
systemLog,
|
|
170
|
+
verbose,
|
|
171
|
+
timers: timersA,
|
|
172
|
+
sendStatus,
|
|
173
|
+
saveConfig,
|
|
174
|
+
testOpts,
|
|
175
|
+
buildbotServerSocket,
|
|
176
|
+
constants,
|
|
177
|
+
featureFlags,
|
|
178
|
+
timeline,
|
|
179
|
+
devCommand,
|
|
180
|
+
})
|
|
181
|
+
return {
|
|
182
|
+
pluginsOptions: pluginsOptionsA,
|
|
183
|
+
netlifyConfig: netlifyConfigA,
|
|
184
|
+
siteInfo,
|
|
185
|
+
userNodeVersion,
|
|
186
|
+
stepsCount,
|
|
187
|
+
timers: timersB,
|
|
188
|
+
configMutations,
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export const execBuild = measureDuration(tExecBuild, 'total', { parentTag: 'build_site' })
|
|
193
|
+
|
|
194
|
+
// Runs a build then report any plugin statuses
|
|
195
|
+
export const runAndReportBuild = async function ({
|
|
196
|
+
pluginsOptions,
|
|
197
|
+
netlifyConfig,
|
|
198
|
+
configOpts,
|
|
199
|
+
siteInfo,
|
|
200
|
+
configPath,
|
|
201
|
+
headersPath,
|
|
202
|
+
redirectsPath,
|
|
203
|
+
buildDir,
|
|
204
|
+
repositoryRoot,
|
|
205
|
+
nodePath,
|
|
206
|
+
packageJson,
|
|
207
|
+
userNodeVersion,
|
|
208
|
+
childEnv,
|
|
209
|
+
context,
|
|
210
|
+
branch,
|
|
211
|
+
buildbotServerSocket,
|
|
212
|
+
constants,
|
|
213
|
+
dry,
|
|
214
|
+
mode,
|
|
215
|
+
api,
|
|
216
|
+
errorMonitor,
|
|
217
|
+
deployId,
|
|
218
|
+
errorParams,
|
|
219
|
+
logs,
|
|
220
|
+
debug,
|
|
221
|
+
systemLog,
|
|
222
|
+
verbose,
|
|
223
|
+
timers,
|
|
224
|
+
sendStatus,
|
|
225
|
+
saveConfig,
|
|
226
|
+
testOpts,
|
|
227
|
+
featureFlags,
|
|
228
|
+
timeline,
|
|
229
|
+
devCommand,
|
|
230
|
+
}) {
|
|
231
|
+
try {
|
|
232
|
+
const {
|
|
233
|
+
stepsCount,
|
|
234
|
+
netlifyConfig: netlifyConfigA,
|
|
235
|
+
statuses,
|
|
236
|
+
pluginsOptions: pluginsOptionsA,
|
|
237
|
+
failedPlugins,
|
|
238
|
+
timers: timersA,
|
|
239
|
+
configMutations,
|
|
240
|
+
} = await initAndRunBuild({
|
|
241
|
+
pluginsOptions,
|
|
242
|
+
netlifyConfig,
|
|
243
|
+
configOpts,
|
|
244
|
+
siteInfo,
|
|
245
|
+
configPath,
|
|
246
|
+
headersPath,
|
|
247
|
+
redirectsPath,
|
|
248
|
+
buildDir,
|
|
249
|
+
repositoryRoot,
|
|
250
|
+
nodePath,
|
|
251
|
+
packageJson,
|
|
252
|
+
userNodeVersion,
|
|
253
|
+
childEnv,
|
|
254
|
+
context,
|
|
255
|
+
branch,
|
|
256
|
+
dry,
|
|
257
|
+
mode,
|
|
258
|
+
api,
|
|
259
|
+
errorMonitor,
|
|
260
|
+
deployId,
|
|
261
|
+
errorParams,
|
|
262
|
+
logs,
|
|
263
|
+
debug,
|
|
264
|
+
systemLog,
|
|
265
|
+
verbose,
|
|
266
|
+
timers,
|
|
267
|
+
sendStatus,
|
|
268
|
+
saveConfig,
|
|
269
|
+
testOpts,
|
|
270
|
+
buildbotServerSocket,
|
|
271
|
+
constants,
|
|
272
|
+
featureFlags,
|
|
273
|
+
timeline,
|
|
274
|
+
devCommand,
|
|
275
|
+
})
|
|
276
|
+
await Promise.all([
|
|
277
|
+
reportStatuses({
|
|
278
|
+
statuses,
|
|
279
|
+
childEnv,
|
|
280
|
+
api,
|
|
281
|
+
mode,
|
|
282
|
+
pluginsOptions: pluginsOptionsA,
|
|
283
|
+
netlifyConfig: netlifyConfigA,
|
|
284
|
+
errorMonitor,
|
|
285
|
+
deployId,
|
|
286
|
+
logs,
|
|
287
|
+
debug,
|
|
288
|
+
sendStatus,
|
|
289
|
+
testOpts,
|
|
290
|
+
}),
|
|
291
|
+
pinPlugins({
|
|
292
|
+
pluginsOptions: pluginsOptionsA,
|
|
293
|
+
failedPlugins,
|
|
294
|
+
api,
|
|
295
|
+
siteInfo,
|
|
296
|
+
childEnv,
|
|
297
|
+
mode,
|
|
298
|
+
netlifyConfig: netlifyConfigA,
|
|
299
|
+
errorMonitor,
|
|
300
|
+
logs,
|
|
301
|
+
debug,
|
|
302
|
+
testOpts,
|
|
303
|
+
sendStatus,
|
|
304
|
+
}),
|
|
305
|
+
])
|
|
306
|
+
|
|
307
|
+
return {
|
|
308
|
+
pluginsOptions: pluginsOptionsA,
|
|
309
|
+
netlifyConfig: netlifyConfigA,
|
|
310
|
+
stepsCount,
|
|
311
|
+
timers: timersA,
|
|
312
|
+
configMutations,
|
|
313
|
+
}
|
|
314
|
+
} catch (error) {
|
|
315
|
+
const [{ statuses }] = getErrorInfo(error)
|
|
316
|
+
await reportStatuses({
|
|
317
|
+
statuses,
|
|
318
|
+
childEnv,
|
|
319
|
+
api,
|
|
320
|
+
mode,
|
|
321
|
+
pluginsOptions,
|
|
322
|
+
netlifyConfig,
|
|
323
|
+
errorMonitor,
|
|
324
|
+
deployId,
|
|
325
|
+
logs,
|
|
326
|
+
debug,
|
|
327
|
+
sendStatus,
|
|
328
|
+
testOpts,
|
|
329
|
+
})
|
|
330
|
+
throw error
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
// Initialize plugin processes then runs a build
|
|
335
|
+
const initAndRunBuild = async function ({
|
|
336
|
+
pluginsOptions,
|
|
337
|
+
netlifyConfig,
|
|
338
|
+
configOpts,
|
|
339
|
+
siteInfo,
|
|
340
|
+
configPath,
|
|
341
|
+
headersPath,
|
|
342
|
+
redirectsPath,
|
|
343
|
+
buildDir,
|
|
344
|
+
repositoryRoot,
|
|
345
|
+
nodePath,
|
|
346
|
+
packageJson,
|
|
347
|
+
userNodeVersion,
|
|
348
|
+
childEnv,
|
|
349
|
+
context,
|
|
350
|
+
branch,
|
|
351
|
+
dry,
|
|
352
|
+
mode,
|
|
353
|
+
api,
|
|
354
|
+
errorMonitor,
|
|
355
|
+
deployId,
|
|
356
|
+
errorParams,
|
|
357
|
+
logs,
|
|
358
|
+
debug,
|
|
359
|
+
systemLog,
|
|
360
|
+
verbose,
|
|
361
|
+
sendStatus,
|
|
362
|
+
saveConfig,
|
|
363
|
+
timers,
|
|
364
|
+
testOpts,
|
|
365
|
+
buildbotServerSocket,
|
|
366
|
+
constants,
|
|
367
|
+
featureFlags,
|
|
368
|
+
timeline,
|
|
369
|
+
devCommand,
|
|
370
|
+
}) {
|
|
371
|
+
const { pluginsOptions: pluginsOptionsA, timers: timersA } = await getPluginsOptions({
|
|
372
|
+
pluginsOptions,
|
|
373
|
+
netlifyConfig,
|
|
374
|
+
siteInfo,
|
|
375
|
+
buildDir,
|
|
376
|
+
nodePath,
|
|
377
|
+
packageJson,
|
|
378
|
+
userNodeVersion,
|
|
379
|
+
mode,
|
|
380
|
+
api,
|
|
381
|
+
logs,
|
|
382
|
+
debug,
|
|
383
|
+
sendStatus,
|
|
384
|
+
timers,
|
|
385
|
+
testOpts,
|
|
386
|
+
featureFlags,
|
|
387
|
+
})
|
|
388
|
+
// eslint-disable-next-line fp/no-mutation, no-param-reassign
|
|
389
|
+
errorParams.pluginsOptions = pluginsOptionsA
|
|
390
|
+
|
|
391
|
+
const { childProcesses, timers: timersB } = await startPlugins({
|
|
392
|
+
pluginsOptions: pluginsOptionsA,
|
|
393
|
+
buildDir,
|
|
394
|
+
childEnv,
|
|
395
|
+
logs,
|
|
396
|
+
debug,
|
|
397
|
+
timers: timersA,
|
|
398
|
+
})
|
|
399
|
+
|
|
400
|
+
try {
|
|
401
|
+
const {
|
|
402
|
+
stepsCount,
|
|
403
|
+
netlifyConfig: netlifyConfigA,
|
|
404
|
+
statuses,
|
|
405
|
+
failedPlugins,
|
|
406
|
+
timers: timersC,
|
|
407
|
+
configMutations,
|
|
408
|
+
} = await runBuild({
|
|
409
|
+
childProcesses,
|
|
410
|
+
pluginsOptions: pluginsOptionsA,
|
|
411
|
+
netlifyConfig,
|
|
412
|
+
configOpts,
|
|
413
|
+
packageJson,
|
|
414
|
+
configPath,
|
|
415
|
+
headersPath,
|
|
416
|
+
redirectsPath,
|
|
417
|
+
buildDir,
|
|
418
|
+
repositoryRoot,
|
|
419
|
+
nodePath,
|
|
420
|
+
childEnv,
|
|
421
|
+
context,
|
|
422
|
+
branch,
|
|
423
|
+
dry,
|
|
424
|
+
buildbotServerSocket,
|
|
425
|
+
constants,
|
|
426
|
+
mode,
|
|
427
|
+
api,
|
|
428
|
+
errorMonitor,
|
|
429
|
+
deployId,
|
|
430
|
+
errorParams,
|
|
431
|
+
logs,
|
|
432
|
+
debug,
|
|
433
|
+
systemLog,
|
|
434
|
+
verbose,
|
|
435
|
+
saveConfig,
|
|
436
|
+
timers: timersB,
|
|
437
|
+
testOpts,
|
|
438
|
+
featureFlags,
|
|
439
|
+
timeline,
|
|
440
|
+
devCommand,
|
|
441
|
+
})
|
|
442
|
+
|
|
443
|
+
await Promise.all([
|
|
444
|
+
warnOnMissingSideFiles({ buildDir, netlifyConfig: netlifyConfigA, logs }),
|
|
445
|
+
warnOnLingeringProcesses({ mode, logs, testOpts }),
|
|
446
|
+
])
|
|
447
|
+
|
|
448
|
+
return {
|
|
449
|
+
stepsCount,
|
|
450
|
+
netlifyConfig: netlifyConfigA,
|
|
451
|
+
statuses,
|
|
452
|
+
pluginsOptions: pluginsOptionsA,
|
|
453
|
+
failedPlugins,
|
|
454
|
+
timers: timersC,
|
|
455
|
+
configMutations,
|
|
456
|
+
}
|
|
457
|
+
} finally {
|
|
458
|
+
// Terminate the child processes of plugins so that they don't linger after
|
|
459
|
+
// the build is finished. The exception is when running in the dev timeline
|
|
460
|
+
// since those are long-running events by nature.
|
|
461
|
+
if (timeline !== 'dev') {
|
|
462
|
+
stopPlugins(childProcesses)
|
|
463
|
+
}
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
// Load plugin main files, retrieve their event handlers then runs them,
|
|
468
|
+
// together with the build command
|
|
469
|
+
const runBuild = async function ({
|
|
470
|
+
childProcesses,
|
|
471
|
+
pluginsOptions,
|
|
472
|
+
netlifyConfig,
|
|
473
|
+
configOpts,
|
|
474
|
+
packageJson,
|
|
475
|
+
configPath,
|
|
476
|
+
headersPath,
|
|
477
|
+
redirectsPath,
|
|
478
|
+
buildDir,
|
|
479
|
+
repositoryRoot,
|
|
480
|
+
nodePath,
|
|
481
|
+
childEnv,
|
|
482
|
+
context,
|
|
483
|
+
branch,
|
|
484
|
+
dry,
|
|
485
|
+
buildbotServerSocket,
|
|
486
|
+
constants,
|
|
487
|
+
mode,
|
|
488
|
+
api,
|
|
489
|
+
errorMonitor,
|
|
490
|
+
deployId,
|
|
491
|
+
errorParams,
|
|
492
|
+
logs,
|
|
493
|
+
debug,
|
|
494
|
+
systemLog,
|
|
495
|
+
verbose,
|
|
496
|
+
saveConfig,
|
|
497
|
+
timers,
|
|
498
|
+
testOpts,
|
|
499
|
+
featureFlags,
|
|
500
|
+
timeline,
|
|
501
|
+
devCommand,
|
|
502
|
+
}) {
|
|
503
|
+
const { pluginsSteps, timers: timersA } = await loadPlugins({
|
|
504
|
+
pluginsOptions,
|
|
505
|
+
childProcesses,
|
|
506
|
+
packageJson,
|
|
507
|
+
timers,
|
|
508
|
+
logs,
|
|
509
|
+
debug,
|
|
510
|
+
verbose,
|
|
511
|
+
})
|
|
512
|
+
|
|
513
|
+
const { steps, events } = timeline === 'dev' ? getDevSteps(devCommand, pluginsSteps) : getSteps(pluginsSteps)
|
|
514
|
+
|
|
515
|
+
if (dry) {
|
|
516
|
+
await doDryRun({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs })
|
|
517
|
+
return { netlifyConfig }
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
const {
|
|
521
|
+
stepsCount,
|
|
522
|
+
netlifyConfig: netlifyConfigA,
|
|
523
|
+
statuses,
|
|
524
|
+
failedPlugins,
|
|
525
|
+
timers: timersB,
|
|
526
|
+
configMutations,
|
|
527
|
+
} = await runSteps({
|
|
528
|
+
steps,
|
|
529
|
+
buildbotServerSocket,
|
|
530
|
+
events,
|
|
531
|
+
configPath,
|
|
532
|
+
headersPath,
|
|
533
|
+
redirectsPath,
|
|
534
|
+
buildDir,
|
|
535
|
+
repositoryRoot,
|
|
536
|
+
nodePath,
|
|
537
|
+
childEnv,
|
|
538
|
+
context,
|
|
539
|
+
branch,
|
|
540
|
+
constants,
|
|
541
|
+
mode,
|
|
542
|
+
api,
|
|
543
|
+
errorMonitor,
|
|
544
|
+
deployId,
|
|
545
|
+
errorParams,
|
|
546
|
+
netlifyConfig,
|
|
547
|
+
configOpts,
|
|
548
|
+
logs,
|
|
549
|
+
debug,
|
|
550
|
+
systemLog,
|
|
551
|
+
verbose,
|
|
552
|
+
saveConfig,
|
|
553
|
+
timers: timersA,
|
|
554
|
+
testOpts,
|
|
555
|
+
featureFlags,
|
|
556
|
+
})
|
|
557
|
+
|
|
558
|
+
return { stepsCount, netlifyConfig: netlifyConfigA, statuses, failedPlugins, timers: timersB, configMutations }
|
|
559
|
+
}
|