@netlify/build 28.0.1-beta → 28.0.1
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/bin.js +5 -0
- package/lib/core/bin.js +66 -0
- package/lib/core/build.js +355 -0
- package/lib/core/config.js +121 -0
- package/lib/core/constants.js +116 -0
- package/lib/core/dev.js +27 -0
- package/lib/core/dry.js +21 -0
- package/lib/core/feature_flags.js +19 -0
- package/lib/core/flags.js +201 -0
- package/lib/core/lingering.js +68 -0
- package/lib/core/main.js +105 -0
- package/lib/core/missing_side_file.js +17 -0
- package/lib/core/normalize_flags.js +59 -0
- package/lib/core/severity.js +21 -0
- package/lib/core/types.js +8 -0
- package/lib/core/user_node_version.js +32 -0
- package/lib/env/changes.js +43 -0
- package/lib/env/main.js +14 -0
- package/lib/env/metadata.js +68 -0
- package/lib/error/api.js +37 -0
- package/lib/error/build.js +36 -0
- package/{src → lib}/error/cancel.js +5 -6
- package/lib/error/colors.js +9 -0
- package/lib/error/handle.js +46 -0
- package/lib/error/info.js +37 -0
- package/lib/error/monitor/location.js +16 -0
- package/lib/error/monitor/normalize.js +86 -0
- package/lib/error/monitor/print.js +20 -0
- package/lib/error/monitor/report.js +120 -0
- package/lib/error/monitor/start.js +61 -0
- package/lib/error/parse/clean_stack.js +70 -0
- package/lib/error/parse/location.js +50 -0
- package/lib/error/parse/normalize.js +24 -0
- package/lib/error/parse/parse.js +67 -0
- package/lib/error/parse/plugin.js +55 -0
- package/lib/error/parse/properties.js +16 -0
- package/lib/error/parse/serialize_log.js +34 -0
- package/lib/error/parse/serialize_status.js +18 -0
- package/lib/error/parse/stack.js +34 -0
- package/lib/error/type.js +171 -0
- package/lib/install/functions.js +20 -0
- package/lib/install/local.js +45 -0
- package/lib/install/main.js +67 -0
- package/lib/install/missing.js +54 -0
- package/{src → lib}/log/colors.js +15 -22
- package/lib/log/description.js +21 -0
- package/lib/log/header.js +14 -0
- package/lib/log/header_func.js +13 -0
- package/lib/log/logger.js +140 -0
- package/lib/log/messages/compatibility.js +120 -0
- package/lib/log/messages/config.js +91 -0
- package/lib/log/messages/core.js +50 -0
- package/lib/log/messages/core_steps.js +75 -0
- package/lib/log/messages/dry.js +41 -0
- package/lib/log/messages/install.js +25 -0
- package/lib/log/messages/ipc.js +29 -0
- package/lib/log/messages/mutations.js +62 -0
- package/{src → lib}/log/messages/plugins.js +18 -32
- package/lib/log/messages/status.js +14 -0
- package/lib/log/messages/steps.js +18 -0
- package/lib/log/old_version.js +32 -0
- package/lib/log/serialize.js +10 -0
- package/lib/log/stream.js +68 -0
- package/lib/log/theme.js +25 -0
- package/lib/plugins/child/diff.js +46 -0
- package/lib/plugins/child/error.js +26 -0
- package/lib/plugins/child/lazy.js +15 -0
- package/lib/plugins/child/load.js +22 -0
- package/lib/plugins/child/logic.js +57 -0
- package/lib/plugins/child/main.js +37 -0
- package/lib/plugins/child/run.js +19 -0
- package/lib/plugins/child/status.js +63 -0
- package/lib/plugins/child/typescript.js +28 -0
- package/lib/plugins/child/utils.js +42 -0
- package/lib/plugins/child/validate.js +31 -0
- package/lib/plugins/compatibility.js +104 -0
- package/{src → lib}/plugins/error.js +31 -35
- package/{src → lib}/plugins/events.js +7 -12
- package/lib/plugins/expected_version.js +81 -0
- package/lib/plugins/ipc.js +120 -0
- package/lib/plugins/list.js +73 -0
- package/lib/plugins/load.js +50 -0
- package/lib/plugins/manifest/check.js +85 -0
- package/lib/plugins/manifest/load.js +38 -0
- package/lib/plugins/manifest/main.js +17 -0
- package/lib/plugins/manifest/path.js +24 -0
- package/lib/plugins/manifest/validate.js +91 -0
- package/lib/plugins/node_version.js +30 -0
- package/lib/plugins/options.js +55 -0
- package/lib/plugins/pinned_version.js +83 -0
- package/lib/plugins/resolve.js +110 -0
- package/lib/plugins/spawn.js +54 -0
- package/lib/plugins_core/add.js +35 -0
- package/lib/plugins_core/build_command.js +50 -0
- package/lib/plugins_core/deploy/buildbot_client.js +87 -0
- package/lib/plugins_core/deploy/index.js +49 -0
- package/{src → lib}/plugins_core/deploy/manifest.yml +0 -0
- package/lib/plugins_core/edge_functions/index.js +79 -0
- package/lib/plugins_core/edge_functions/lib/error.js +17 -0
- package/lib/plugins_core/edge_functions/lib/internal_manifest.js +50 -0
- package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +75 -0
- package/lib/plugins_core/functions/error.js +123 -0
- package/lib/plugins_core/functions/feature_flags.js +6 -0
- package/lib/plugins_core/functions/index.js +114 -0
- package/lib/plugins_core/functions/utils.js +45 -0
- package/lib/plugins_core/functions/zisi.js +39 -0
- package/{src → lib}/plugins_core/functions_install/index.js +8 -11
- package/{src → lib}/plugins_core/functions_install/manifest.yml +0 -0
- package/lib/plugins_core/list.js +20 -0
- package/lib/status/add.js +30 -0
- package/lib/status/colors.js +18 -0
- package/lib/status/load_error.js +10 -0
- package/lib/status/report.js +83 -0
- package/lib/status/success.js +14 -0
- package/lib/steps/core_step.js +57 -0
- package/lib/steps/error.js +65 -0
- package/lib/steps/get.js +43 -0
- package/lib/steps/plugin.js +55 -0
- package/lib/steps/return.js +25 -0
- package/lib/steps/run_core_steps.js +126 -0
- package/lib/steps/run_step.js +188 -0
- package/lib/steps/run_steps.js +96 -0
- package/lib/steps/update_config.js +66 -0
- package/lib/telemetry/main.js +97 -0
- package/lib/time/aggregate.js +120 -0
- package/lib/time/main.js +37 -0
- package/lib/time/measure.js +18 -0
- package/lib/time/report.js +47 -0
- package/lib/utils/errors.js +13 -0
- package/lib/utils/json.js +15 -0
- package/{src → lib}/utils/omit.js +3 -4
- package/lib/utils/package.js +22 -0
- package/lib/utils/remove_falsy.js +8 -0
- package/lib/utils/resolve.js +41 -0
- package/lib/utils/runtime.js +5 -0
- package/lib/utils/semver.js +28 -0
- package/package.json +40 -20
- package/types/config/netlify_config.d.ts +4 -4
- package/types/netlify_plugin_constants.d.ts +8 -8
- package/src/core/bin.js +0 -83
- package/src/core/config.js +0 -186
- package/src/core/constants.js +0 -156
- package/src/core/dry.js +0 -39
- package/src/core/feature_flags.js +0 -21
- package/src/core/flags.js +0 -194
- package/src/core/lingering.js +0 -85
- package/src/core/main.js +0 -692
- package/src/core/missing_side_file.js +0 -29
- package/src/core/normalize_flags.js +0 -69
- 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/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 -77
- package/src/error/monitor/print.js +0 -42
- package/src/error/monitor/report.js +0 -133
- package/src/error/monitor/start.js +0 -69
- package/src/error/parse/clean_stack.js +0 -87
- package/src/error/parse/location.js +0 -58
- 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 -182
- 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/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 -107
- package/src/log/messages/compatibility.js +0 -164
- package/src/log/messages/config.js +0 -105
- 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 -20
- package/src/log/messages/ipc.js +0 -38
- package/src/log/messages/mutations.js +0 -82
- 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 -57
- package/src/plugins/child/main.js +0 -51
- package/src/plugins/child/run.js +0 -28
- package/src/plugins/child/status.js +0 -67
- 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 -128
- 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 -66
- 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 -102
- package/src/plugins_core/deploy/index.js +0 -73
- package/src/plugins_core/edge_functions/index.js +0 -107
- package/src/plugins_core/edge_functions/lib/internal_manifest.js +0 -54
- 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 -160
- package/src/plugins_core/functions/utils.js +0 -66
- package/src/plugins_core/functions/zisi.js +0 -53
- 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 -128
- package/src/status/success.js +0 -18
- package/src/steps/core_step.js +0 -90
- package/src/steps/error.js +0 -102
- package/src/steps/get.js +0 -32
- package/src/steps/plugin.js +0 -85
- package/src/steps/return.js +0 -52
- package/src/steps/run_core_steps.js +0 -194
- package/src/steps/run_step.js +0 -300
- 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/package.js +0 -23
- package/src/utils/remove_falsy.js +0 -10
- package/src/utils/resolve.js +0 -46
- package/src/utils/semver.js +0 -34
package/src/steps/run_step.js
DELETED
|
@@ -1,300 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-lines */
|
|
2
|
-
import { addMutableConstants } from '../core/constants.js'
|
|
3
|
-
import { logStepStart } from '../log/messages/steps.js'
|
|
4
|
-
import { runsAlsoOnBuildFailure, runsOnlyOnBuildFailure } from '../plugins/events.js'
|
|
5
|
-
import { measureDuration, normalizeTimerName } from '../time/main.js'
|
|
6
|
-
|
|
7
|
-
import { fireCoreStep } from './core_step.js'
|
|
8
|
-
import { firePluginStep } from './plugin.js'
|
|
9
|
-
import { getStepReturn } from './return.js'
|
|
10
|
-
|
|
11
|
-
// Run a step (core, build command or plugin)
|
|
12
|
-
export const runStep = async function ({
|
|
13
|
-
event,
|
|
14
|
-
childProcess,
|
|
15
|
-
packageName,
|
|
16
|
-
coreStep,
|
|
17
|
-
coreStepId,
|
|
18
|
-
coreStepName,
|
|
19
|
-
coreStepDescription,
|
|
20
|
-
pluginPackageJson,
|
|
21
|
-
loadedFrom,
|
|
22
|
-
origin,
|
|
23
|
-
condition,
|
|
24
|
-
configPath,
|
|
25
|
-
buildDir,
|
|
26
|
-
repositoryRoot,
|
|
27
|
-
nodePath,
|
|
28
|
-
index,
|
|
29
|
-
childEnv,
|
|
30
|
-
context,
|
|
31
|
-
branch,
|
|
32
|
-
envChanges,
|
|
33
|
-
constants,
|
|
34
|
-
steps,
|
|
35
|
-
buildbotServerSocket,
|
|
36
|
-
events,
|
|
37
|
-
mode,
|
|
38
|
-
api,
|
|
39
|
-
errorMonitor,
|
|
40
|
-
deployId,
|
|
41
|
-
errorParams,
|
|
42
|
-
error,
|
|
43
|
-
failedPlugins,
|
|
44
|
-
configOpts,
|
|
45
|
-
netlifyConfig,
|
|
46
|
-
configMutations,
|
|
47
|
-
headersPath,
|
|
48
|
-
redirectsPath,
|
|
49
|
-
logs,
|
|
50
|
-
debug,
|
|
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
|
-
verbose,
|
|
113
|
-
saveConfig,
|
|
114
|
-
timers,
|
|
115
|
-
errorParams,
|
|
116
|
-
configOpts,
|
|
117
|
-
netlifyConfig,
|
|
118
|
-
configMutations,
|
|
119
|
-
headersPath,
|
|
120
|
-
redirectsPath,
|
|
121
|
-
featureFlags,
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
const newValues = await getStepReturn({
|
|
125
|
-
event,
|
|
126
|
-
packageName,
|
|
127
|
-
newError,
|
|
128
|
-
newEnvChanges,
|
|
129
|
-
newStatus,
|
|
130
|
-
coreStep,
|
|
131
|
-
coreStepName,
|
|
132
|
-
childEnv,
|
|
133
|
-
mode,
|
|
134
|
-
api,
|
|
135
|
-
errorMonitor,
|
|
136
|
-
deployId,
|
|
137
|
-
netlifyConfig: netlifyConfigA,
|
|
138
|
-
configMutations: configMutationsA,
|
|
139
|
-
headersPath: headersPathA,
|
|
140
|
-
redirectsPath: redirectsPathA,
|
|
141
|
-
logs,
|
|
142
|
-
debug,
|
|
143
|
-
timers: timersA,
|
|
144
|
-
durationNs,
|
|
145
|
-
testOpts,
|
|
146
|
-
})
|
|
147
|
-
return { ...newValues, newIndex: index + 1 }
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// A plugin fails _without making the build fail_ when either:
|
|
151
|
-
// - using `utils.build.failPlugin()`
|
|
152
|
-
// - the failure happens after deploy. This means: inside any `onError`,
|
|
153
|
-
// `onSuccess` or `onEnd` event handler.
|
|
154
|
-
//
|
|
155
|
-
// When that happens, no other events for that specific plugin is run.
|
|
156
|
-
// Not even `onError` and `onEnd`.
|
|
157
|
-
// Plugins should use `try`/`catch`/`finally` blocks to handle exceptions,
|
|
158
|
-
// not `onError` nor `onEnd`.
|
|
159
|
-
//
|
|
160
|
-
// Otherwise, most failures will make the build fail. This includes:
|
|
161
|
-
// - the build command failed
|
|
162
|
-
// - Functions or Edge Functions bundling failed
|
|
163
|
-
// - the deploy failed (deploying files to our CDN)
|
|
164
|
-
// - a plugin `onPreBuild`, `onBuild` or `onPostBuild` event handler failed.
|
|
165
|
-
// This includes uncaught exceptions and using `utils.build.failBuild()`
|
|
166
|
-
// or `utils.build.cancelBuild()`.
|
|
167
|
-
//
|
|
168
|
-
// `onError` is triggered when the build failed.
|
|
169
|
-
// It means "on build failure" not "on plugin failure".
|
|
170
|
-
// `onSuccess` is the opposite. It is triggered after the build succeeded.
|
|
171
|
-
// `onEnd` is triggered after the build either failed or succeeded.
|
|
172
|
-
// It is useful for resources cleanup.
|
|
173
|
-
//
|
|
174
|
-
// Finally, some plugins (only core plugins for the moment) might be enabled or
|
|
175
|
-
// not depending on whether a specific action is happening during the build,
|
|
176
|
-
// such as creating a file. For example, the Functions and Edge Functions core
|
|
177
|
-
// plugins are disabled if no Functions or Edge Functions directory is specified
|
|
178
|
-
// or available. However, one might be created by a build plugin, in which case,
|
|
179
|
-
// those core plugins should be triggered. We use a dynamic `condition()` to
|
|
180
|
-
// model this behavior.
|
|
181
|
-
const shouldRunStep = async function ({
|
|
182
|
-
event,
|
|
183
|
-
packageName,
|
|
184
|
-
error,
|
|
185
|
-
failedPlugins,
|
|
186
|
-
netlifyConfig,
|
|
187
|
-
condition,
|
|
188
|
-
constants,
|
|
189
|
-
buildbotServerSocket,
|
|
190
|
-
buildDir,
|
|
191
|
-
}) {
|
|
192
|
-
if (
|
|
193
|
-
failedPlugins.includes(packageName) ||
|
|
194
|
-
(condition !== undefined && !(await condition({ buildDir, constants, buildbotServerSocket, netlifyConfig })))
|
|
195
|
-
) {
|
|
196
|
-
return false
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if (error !== undefined) {
|
|
200
|
-
return runsAlsoOnBuildFailure(event)
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return !runsOnlyOnBuildFailure(event)
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
// Wrap step function to measure its time
|
|
207
|
-
const getFireStep = function (packageName, coreStepId, event) {
|
|
208
|
-
if (coreStepId !== undefined) {
|
|
209
|
-
return measureDuration(tFireStep, coreStepId)
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
const parentTag = normalizeTimerName(packageName)
|
|
213
|
-
return measureDuration(tFireStep, event, { parentTag, category: 'pluginEvent' })
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const tFireStep = function ({
|
|
217
|
-
event,
|
|
218
|
-
childProcess,
|
|
219
|
-
packageName,
|
|
220
|
-
pluginPackageJson,
|
|
221
|
-
loadedFrom,
|
|
222
|
-
origin,
|
|
223
|
-
coreStep,
|
|
224
|
-
coreStepName,
|
|
225
|
-
configPath,
|
|
226
|
-
buildDir,
|
|
227
|
-
repositoryRoot,
|
|
228
|
-
nodePath,
|
|
229
|
-
childEnv,
|
|
230
|
-
context,
|
|
231
|
-
branch,
|
|
232
|
-
envChanges,
|
|
233
|
-
constants,
|
|
234
|
-
steps,
|
|
235
|
-
buildbotServerSocket,
|
|
236
|
-
events,
|
|
237
|
-
error,
|
|
238
|
-
logs,
|
|
239
|
-
debug,
|
|
240
|
-
verbose,
|
|
241
|
-
saveConfig,
|
|
242
|
-
errorParams,
|
|
243
|
-
configOpts,
|
|
244
|
-
netlifyConfig,
|
|
245
|
-
configMutations,
|
|
246
|
-
headersPath,
|
|
247
|
-
redirectsPath,
|
|
248
|
-
featureFlags,
|
|
249
|
-
}) {
|
|
250
|
-
if (coreStep !== undefined) {
|
|
251
|
-
return fireCoreStep({
|
|
252
|
-
coreStep,
|
|
253
|
-
coreStepName,
|
|
254
|
-
configPath,
|
|
255
|
-
buildDir,
|
|
256
|
-
repositoryRoot,
|
|
257
|
-
constants,
|
|
258
|
-
buildbotServerSocket,
|
|
259
|
-
events,
|
|
260
|
-
logs,
|
|
261
|
-
nodePath,
|
|
262
|
-
childEnv,
|
|
263
|
-
context,
|
|
264
|
-
branch,
|
|
265
|
-
envChanges,
|
|
266
|
-
errorParams,
|
|
267
|
-
configOpts,
|
|
268
|
-
netlifyConfig,
|
|
269
|
-
configMutations,
|
|
270
|
-
headersPath,
|
|
271
|
-
redirectsPath,
|
|
272
|
-
featureFlags,
|
|
273
|
-
debug,
|
|
274
|
-
saveConfig,
|
|
275
|
-
})
|
|
276
|
-
}
|
|
277
|
-
|
|
278
|
-
return firePluginStep({
|
|
279
|
-
event,
|
|
280
|
-
childProcess,
|
|
281
|
-
packageName,
|
|
282
|
-
pluginPackageJson,
|
|
283
|
-
loadedFrom,
|
|
284
|
-
origin,
|
|
285
|
-
envChanges,
|
|
286
|
-
errorParams,
|
|
287
|
-
configOpts,
|
|
288
|
-
netlifyConfig,
|
|
289
|
-
configMutations,
|
|
290
|
-
headersPath,
|
|
291
|
-
redirectsPath,
|
|
292
|
-
constants,
|
|
293
|
-
steps,
|
|
294
|
-
error,
|
|
295
|
-
logs,
|
|
296
|
-
debug,
|
|
297
|
-
verbose,
|
|
298
|
-
})
|
|
299
|
-
}
|
|
300
|
-
/* eslint-enable max-lines */
|
package/src/steps/run_steps.js
DELETED
|
@@ -1,179 +0,0 @@
|
|
|
1
|
-
/* eslint-disable max-lines */
|
|
2
|
-
import pReduce from 'p-reduce'
|
|
3
|
-
|
|
4
|
-
import { addErrorInfo } from '../error/info.js'
|
|
5
|
-
import { addStatus } from '../status/add.js'
|
|
6
|
-
|
|
7
|
-
import { runStep } from './run_step.js'
|
|
8
|
-
|
|
9
|
-
// Run all steps.
|
|
10
|
-
// Each step can change some state: last `error`, environment variables changes,
|
|
11
|
-
// list of `failedPlugins` (that ran `utils.build.failPlugin()`).
|
|
12
|
-
// If an error arises, runs `onError` events.
|
|
13
|
-
// Runs `onEnd` events at the end, whether an error was thrown or not.
|
|
14
|
-
export const runSteps = async function ({
|
|
15
|
-
steps,
|
|
16
|
-
buildbotServerSocket,
|
|
17
|
-
events,
|
|
18
|
-
configPath,
|
|
19
|
-
headersPath,
|
|
20
|
-
redirectsPath,
|
|
21
|
-
buildDir,
|
|
22
|
-
repositoryRoot,
|
|
23
|
-
nodePath,
|
|
24
|
-
childEnv,
|
|
25
|
-
context,
|
|
26
|
-
branch,
|
|
27
|
-
constants,
|
|
28
|
-
mode,
|
|
29
|
-
api,
|
|
30
|
-
errorMonitor,
|
|
31
|
-
deployId,
|
|
32
|
-
errorParams,
|
|
33
|
-
netlifyConfig,
|
|
34
|
-
configOpts,
|
|
35
|
-
logs,
|
|
36
|
-
debug,
|
|
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
|
-
verbose,
|
|
131
|
-
saveConfig,
|
|
132
|
-
timers: timersA,
|
|
133
|
-
testOpts,
|
|
134
|
-
featureFlags,
|
|
135
|
-
})
|
|
136
|
-
const statusesA = addStatus({ newStatus, statuses, event, packageName, pluginPackageJson })
|
|
137
|
-
return {
|
|
138
|
-
index: newIndex,
|
|
139
|
-
error: newError,
|
|
140
|
-
failedPlugins: [...failedPlugins, ...failedPlugin],
|
|
141
|
-
envChanges: { ...envChanges, ...newEnvChanges },
|
|
142
|
-
netlifyConfig: netlifyConfigB,
|
|
143
|
-
configMutations: configMutationsA,
|
|
144
|
-
headersPath: headersPathB,
|
|
145
|
-
redirectsPath: redirectsPathB,
|
|
146
|
-
statuses: statusesA,
|
|
147
|
-
timers: timersB,
|
|
148
|
-
}
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
index: 0,
|
|
152
|
-
failedPlugins: [],
|
|
153
|
-
envChanges: {},
|
|
154
|
-
netlifyConfig,
|
|
155
|
-
configMutations: [],
|
|
156
|
-
headersPath,
|
|
157
|
-
redirectsPath,
|
|
158
|
-
statuses: [],
|
|
159
|
-
timers,
|
|
160
|
-
},
|
|
161
|
-
)
|
|
162
|
-
|
|
163
|
-
// Instead of throwing any build failure right away, we wait for `onError`,
|
|
164
|
-
// etc. to complete. This is why we are throwing only now.
|
|
165
|
-
if (errorA !== undefined) {
|
|
166
|
-
addErrorInfo(errorA, { statuses: statusesB })
|
|
167
|
-
throw errorA
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
return {
|
|
171
|
-
stepsCount,
|
|
172
|
-
netlifyConfig: netlifyConfigC,
|
|
173
|
-
statuses: statusesB,
|
|
174
|
-
failedPlugins: failedPluginsA,
|
|
175
|
-
timers: timersC,
|
|
176
|
-
configMutations: configMutationsB,
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
/* eslint-enable max-lines */
|
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { isDeepStrictEqual } from 'util'
|
|
2
|
-
|
|
3
|
-
import pFilter from 'p-filter'
|
|
4
|
-
import { pathExists } from 'path-exists'
|
|
5
|
-
|
|
6
|
-
import { resolveUpdatedConfig } from '../core/config.js'
|
|
7
|
-
import { addErrorInfo } from '../error/info.js'
|
|
8
|
-
import { logConfigOnUpdate } from '../log/messages/config.js'
|
|
9
|
-
import { logConfigMutations } from '../log/messages/mutations.js'
|
|
10
|
-
|
|
11
|
-
// If `netlifyConfig` was updated or `_redirects` was created, the configuration
|
|
12
|
-
// is updated by calling `@netlify/config` again.
|
|
13
|
-
export const updateNetlifyConfig = async function ({
|
|
14
|
-
configOpts,
|
|
15
|
-
netlifyConfig,
|
|
16
|
-
headersPath,
|
|
17
|
-
redirectsPath,
|
|
18
|
-
configMutations,
|
|
19
|
-
newConfigMutations,
|
|
20
|
-
configSideFiles,
|
|
21
|
-
errorParams,
|
|
22
|
-
logs,
|
|
23
|
-
debug,
|
|
24
|
-
}) {
|
|
25
|
-
if (!(await shouldUpdateConfig({ newConfigMutations, configSideFiles, headersPath, redirectsPath }))) {
|
|
26
|
-
return { netlifyConfig, configMutations }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
validateConfigMutations(newConfigMutations)
|
|
30
|
-
logConfigMutations(logs, newConfigMutations, debug)
|
|
31
|
-
const configMutationsA = [...configMutations, ...newConfigMutations]
|
|
32
|
-
const {
|
|
33
|
-
config: netlifyConfigA,
|
|
34
|
-
headersPath: headersPathA,
|
|
35
|
-
redirectsPath: redirectsPathA,
|
|
36
|
-
} = await resolveUpdatedConfig(configOpts, configMutationsA)
|
|
37
|
-
logConfigOnUpdate({ logs, netlifyConfig: netlifyConfigA, debug })
|
|
38
|
-
// eslint-disable-next-line fp/no-mutation,no-param-reassign
|
|
39
|
-
errorParams.netlifyConfig = netlifyConfigA
|
|
40
|
-
return {
|
|
41
|
-
netlifyConfig: netlifyConfigA,
|
|
42
|
-
configMutations: configMutationsA,
|
|
43
|
-
headersPath: headersPathA,
|
|
44
|
-
redirectsPath: redirectsPathA,
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const shouldUpdateConfig = async function ({ newConfigMutations, configSideFiles, headersPath, redirectsPath }) {
|
|
49
|
-
return (
|
|
50
|
-
newConfigMutations.length !== 0 || (await haveConfigSideFilesChanged(configSideFiles, headersPath, redirectsPath))
|
|
51
|
-
)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// The configuration mostly depends on `netlify.toml` and UI build settings.
|
|
55
|
-
// However, it also uses some additional optional side files like `_redirects`.
|
|
56
|
-
// Those are often created by the build command. When those are created, we need
|
|
57
|
-
// to update the configuration. We detect this by checking for file existence
|
|
58
|
-
// before and after running plugins and the build command.
|
|
59
|
-
const haveConfigSideFilesChanged = async function (configSideFiles, headersPath, redirectsPath) {
|
|
60
|
-
const newSideFiles = await listConfigSideFiles([headersPath, redirectsPath])
|
|
61
|
-
return !isDeepStrictEqual(newSideFiles, configSideFiles)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
// List all the files used for configuration besides `netlify.toml`.
|
|
65
|
-
// This is useful when applying configuration mutations since those files
|
|
66
|
-
// sometimes have higher priority and should therefore be deleted in order to
|
|
67
|
-
// apply any configuration update on `netlify.toml`.
|
|
68
|
-
export const listConfigSideFiles = async function (sideFiles) {
|
|
69
|
-
const configSideFiles = await pFilter(sideFiles, pathExists)
|
|
70
|
-
// eslint-disable-next-line fp/no-mutating-methods
|
|
71
|
-
return configSideFiles.sort()
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
// Validate each new configuration change
|
|
75
|
-
const validateConfigMutations = function (newConfigMutations) {
|
|
76
|
-
try {
|
|
77
|
-
newConfigMutations.forEach(validateConfigMutation)
|
|
78
|
-
} catch (error) {
|
|
79
|
-
addErrorInfo(error, { type: 'pluginValidation' })
|
|
80
|
-
throw error
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// Triggered when calling `netlifyConfig.{key} = undefined | null`
|
|
85
|
-
// We do not allow this because the back-end only receives mutations as a
|
|
86
|
-
// `netlify.toml`, i.e. cannot apply property deletions since `undefined` is
|
|
87
|
-
// not serializable in TOML.
|
|
88
|
-
const validateConfigMutation = function ({ value, keysString }) {
|
|
89
|
-
if (value === undefined || value === null) {
|
|
90
|
-
throw new Error(`Setting "netlifyConfig.${keysString}" to ${value} is not allowed.
|
|
91
|
-
Please set this property to a specific value instead.`)
|
|
92
|
-
}
|
|
93
|
-
}
|
package/src/telemetry/main.js
DELETED
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import { platform } from 'process'
|
|
2
|
-
|
|
3
|
-
import got from 'got'
|
|
4
|
-
import osName from 'os-name'
|
|
5
|
-
|
|
6
|
-
import { addErrorInfo } from '../error/info.js'
|
|
7
|
-
import { roundTimerToMillisecs } from '../time/measure.js'
|
|
8
|
-
import { ROOT_PACKAGE_JSON } from '../utils/json.js'
|
|
9
|
-
|
|
10
|
-
const DEFAULT_TELEMETRY_TIMEOUT = 1200
|
|
11
|
-
const DEFAULT_TELEMETRY_CONFIG = {
|
|
12
|
-
origin: 'https://api.segment.io/v1',
|
|
13
|
-
writeKey: 'dWhlM1lYSlpNd1k5Uk9rcjFra2JSOEoybnRjZjl0YTI6',
|
|
14
|
-
timeout: DEFAULT_TELEMETRY_TIMEOUT,
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// Send telemetry request when build completes
|
|
18
|
-
export const trackBuildComplete = async function ({
|
|
19
|
-
deployId,
|
|
20
|
-
buildId,
|
|
21
|
-
status,
|
|
22
|
-
stepsCount,
|
|
23
|
-
pluginsOptions,
|
|
24
|
-
durationNs,
|
|
25
|
-
siteInfo,
|
|
26
|
-
telemetry,
|
|
27
|
-
userNodeVersion,
|
|
28
|
-
framework,
|
|
29
|
-
testOpts: { telemetryOrigin = DEFAULT_TELEMETRY_CONFIG.origin, telemetryTimeout = DEFAULT_TELEMETRY_CONFIG.timeout },
|
|
30
|
-
}) {
|
|
31
|
-
if (!telemetry) {
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
try {
|
|
36
|
-
const payload = getPayload({
|
|
37
|
-
deployId,
|
|
38
|
-
buildId,
|
|
39
|
-
status,
|
|
40
|
-
stepsCount,
|
|
41
|
-
pluginsOptions,
|
|
42
|
-
durationNs,
|
|
43
|
-
siteInfo,
|
|
44
|
-
userNodeVersion,
|
|
45
|
-
framework,
|
|
46
|
-
})
|
|
47
|
-
await track({
|
|
48
|
-
payload,
|
|
49
|
-
config: { ...DEFAULT_TELEMETRY_CONFIG, origin: telemetryOrigin, timeout: telemetryTimeout },
|
|
50
|
-
})
|
|
51
|
-
} catch (error) {
|
|
52
|
-
addErrorInfo(error, { type: 'telemetry' })
|
|
53
|
-
throw error
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Send track HTTP request to telemetry.
|
|
58
|
-
const track = async function ({ payload, config: { origin, writeKey, timeout } }) {
|
|
59
|
-
const url = `${origin}/track`
|
|
60
|
-
await got.post(url, {
|
|
61
|
-
json: payload,
|
|
62
|
-
timeout,
|
|
63
|
-
retry: 0,
|
|
64
|
-
headers: { Authorization: `Basic ${writeKey}` },
|
|
65
|
-
})
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Retrieve telemetry information
|
|
69
|
-
// siteInfo can be empty if the build fails during the get config step
|
|
70
|
-
const getPayload = function ({
|
|
71
|
-
deployId,
|
|
72
|
-
buildId,
|
|
73
|
-
status,
|
|
74
|
-
stepsCount,
|
|
75
|
-
pluginsOptions,
|
|
76
|
-
durationNs,
|
|
77
|
-
userNodeVersion,
|
|
78
|
-
siteInfo = {},
|
|
79
|
-
framework,
|
|
80
|
-
}) {
|
|
81
|
-
return {
|
|
82
|
-
userId: 'buildbot_user',
|
|
83
|
-
event: 'build:ci_build_process_completed',
|
|
84
|
-
timestamp: Date.now(),
|
|
85
|
-
properties: {
|
|
86
|
-
deployId,
|
|
87
|
-
buildId,
|
|
88
|
-
status,
|
|
89
|
-
steps: stepsCount,
|
|
90
|
-
buildVersion: ROOT_PACKAGE_JSON.version,
|
|
91
|
-
// We're passing the node version set by the buildbot/user which will run the `build.command` and
|
|
92
|
-
// the `package.json`/locally defined plugins
|
|
93
|
-
nodeVersion: userNodeVersion,
|
|
94
|
-
osPlatform: OS_TYPES[platform],
|
|
95
|
-
osName: osName(),
|
|
96
|
-
framework,
|
|
97
|
-
siteId: siteInfo.id,
|
|
98
|
-
...(pluginsOptions !== undefined && {
|
|
99
|
-
plugins: pluginsOptions.map(getPlugin),
|
|
100
|
-
pluginCount: pluginsOptions.length,
|
|
101
|
-
}),
|
|
102
|
-
...(durationNs !== undefined && { duration: roundTimerToMillisecs(durationNs) }),
|
|
103
|
-
},
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
const OS_TYPES = {
|
|
108
|
-
linux: 'Linux',
|
|
109
|
-
darwin: 'MacOS',
|
|
110
|
-
win32: 'Windows',
|
|
111
|
-
android: 'Android',
|
|
112
|
-
sunos: 'SunOS',
|
|
113
|
-
aix: 'AIX',
|
|
114
|
-
freebsd: 'FreeBSD',
|
|
115
|
-
openbsd: 'OpenBSD',
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const getPlugin = function ({
|
|
119
|
-
packageName,
|
|
120
|
-
origin,
|
|
121
|
-
loadedFrom,
|
|
122
|
-
nodeVersion,
|
|
123
|
-
pinnedVersion,
|
|
124
|
-
pluginPackageJson: { version } = {},
|
|
125
|
-
}) {
|
|
126
|
-
const installType = getInstallType(origin, loadedFrom)
|
|
127
|
-
return { name: packageName, installType, nodeVersion, pinnedVersion, version }
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const getInstallType = function (origin, loadedFrom) {
|
|
131
|
-
if (loadedFrom === 'auto_install') {
|
|
132
|
-
return origin === 'ui' ? 'ui' : 'netlify_toml'
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
return loadedFrom
|
|
136
|
-
}
|