@netlify/build 0.5.0 → 1.0.0-dl-test
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 +392 -0
- package/lib/core/config.js +124 -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 +17 -0
- package/lib/core/flags.js +206 -0
- package/lib/core/lingering.js +68 -0
- package/lib/core/main.js +114 -0
- package/lib/core/missing_side_file.js +17 -0
- package/lib/core/normalize_flags.js +62 -0
- package/lib/core/report_metrics.js +17 -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/lib/error/cancel.js +7 -0
- package/lib/error/colors.js +9 -0
- package/lib/error/handle.js +44 -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/report.js +29 -0
- package/lib/error/type.js +177 -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/lib/log/colors.js +28 -0
- package/lib/log/description.js +21 -0
- package/lib/log/header.js +12 -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 +49 -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/lib/log/messages/plugins.js +25 -0
- package/lib/log/messages/status.js +14 -0
- package/lib/log/messages/steps.js +18 -0
- package/lib/log/serialize.js +10 -0
- package/lib/log/stream.js +68 -0
- package/lib/log/theme.js +27 -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/lib/plugins/error.js +46 -0
- package/lib/plugins/events.js +12 -0
- package/lib/plugins/expected_version.js +81 -0
- package/lib/plugins/internal.js +10 -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 +19 -0
- package/lib/plugins/manifest/path.js +24 -0
- package/lib/plugins/manifest/validate.js +91 -0
- package/lib/plugins/node_version.js +35 -0
- package/lib/plugins/options.js +70 -0
- package/lib/plugins/pinned_version.js +83 -0
- package/lib/plugins/resolve.js +110 -0
- package/lib/plugins/spawn.js +55 -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/lib/plugins_core/deploy/manifest.yml +1 -0
- package/lib/plugins_core/edge_functions/index.js +106 -0
- package/lib/plugins_core/edge_functions/lib/error.js +17 -0
- package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +14 -0
- package/lib/plugins_core/functions/error.js +123 -0
- package/lib/plugins_core/functions/feature_flags.js +5 -0
- package/lib/plugins_core/functions/index.js +137 -0
- package/lib/plugins_core/functions/utils.js +45 -0
- package/lib/plugins_core/functions/zisi.js +64 -0
- package/lib/plugins_core/functions_install/index.js +10 -0
- package/lib/plugins_core/list.js +20 -0
- package/lib/plugins_core/save_artifacts/index.js +33 -0
- package/lib/report/statsd.js +56 -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 +62 -0
- package/lib/steps/error.js +65 -0
- package/lib/steps/get.js +44 -0
- package/lib/steps/plugin.js +55 -0
- package/lib/steps/return.js +27 -0
- package/lib/steps/run_core_steps.js +117 -0
- package/lib/steps/run_step.js +200 -0
- package/lib/steps/run_steps.js +102 -0
- package/lib/steps/update_config.js +66 -0
- package/lib/telemetry/main.js +94 -0
- package/lib/time/aggregate.js +109 -0
- package/lib/time/main.js +31 -0
- package/lib/time/measure.js +16 -0
- package/lib/time/report.js +30 -0
- package/lib/utils/errors.js +13 -0
- package/lib/utils/json.js +10 -0
- package/lib/utils/omit.js +3 -0
- package/lib/utils/package.js +24 -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 +119 -56
- package/types/config/build.d.ts +52 -0
- package/types/config/functions.d.ts +36 -0
- package/types/config/inputs.d.ts +7 -0
- package/types/config/netlify_config.d.ts +58 -0
- package/types/index.d.ts +7 -0
- package/types/netlify_event_handler.d.ts +29 -0
- package/types/netlify_plugin.d.ts +29 -0
- package/types/netlify_plugin_constants.d.ts +51 -0
- package/types/netlify_plugin_options.d.ts +23 -0
- package/types/options/index.d.ts +1 -0
- package/types/options/netlify_plugin_build_util.d.ts +7 -0
- package/types/options/netlify_plugin_cache_util.d.ts +39 -0
- package/types/options/netlify_plugin_functions_util.d.ts +32 -0
- package/types/options/netlify_plugin_git_util.d.ts +41 -0
- package/types/options/netlify_plugin_run_util.d.ts +24 -0
- package/types/options/netlify_plugin_status_util.d.ts +24 -0
- package/types/options/netlify_plugin_utils.d.ts +15 -0
- package/types/utils/json_value.d.ts +1 -0
- package/types/utils/many.d.ts +6 -0
- package/README.md +0 -3
- package/src/core/bin.js +0 -139
- package/src/core/commands.js +0 -304
- package/src/core/config.js +0 -130
- package/src/core/constants.js +0 -86
- package/src/core/dry.js +0 -23
- package/src/core/main.js +0 -196
- package/src/env/changes.js +0 -49
- package/src/env/git.js +0 -27
- package/src/env/main.js +0 -97
- package/src/env/metadata.js +0 -81
- package/src/error/api.js +0 -32
- package/src/error/build.js +0 -32
- package/src/error/cancel.js +0 -22
- package/src/error/colors.js +0 -13
- package/src/error/info.js +0 -12
- package/src/error/monitor/normalize.js +0 -50
- package/src/error/monitor/print.js +0 -43
- package/src/error/monitor/report.js +0 -140
- package/src/error/monitor/start.js +0 -50
- package/src/error/parse/clean_stack.js +0 -86
- package/src/error/parse/location.js +0 -50
- package/src/error/parse/parse.js +0 -87
- package/src/error/parse/plugin.js +0 -68
- package/src/error/parse/properties.js +0 -20
- package/src/error/parse/serialize_log.js +0 -46
- package/src/error/parse/serialize_status.js +0 -28
- package/src/error/parse/stack.js +0 -45
- package/src/error/process.js +0 -13
- package/src/error/type.js +0 -143
- package/src/install/functions.js +0 -62
- package/src/install/local.js +0 -74
- package/src/install/main.js +0 -103
- package/src/install/missing.js +0 -86
- package/src/log/colors.js +0 -59
- package/src/log/description.js +0 -38
- package/src/log/header.js +0 -19
- package/src/log/logger.js +0 -55
- package/src/log/main.js +0 -290
- package/src/log/old_version.js +0 -45
- package/src/log/serialize.js +0 -15
- package/src/log/stream.js +0 -15
- package/src/log/theme.js +0 -32
- package/src/log/timer.js +0 -28
- package/src/plugins/child/api.js +0 -59
- package/src/plugins/child/error.js +0 -39
- package/src/plugins/child/load.js +0 -37
- package/src/plugins/child/logic.js +0 -31
- package/src/plugins/child/main.js +0 -48
- package/src/plugins/child/run.js +0 -30
- package/src/plugins/child/status.js +0 -53
- package/src/plugins/child/utils.js +0 -43
- package/src/plugins/child/validate.js +0 -71
- package/src/plugins/error.js +0 -73
- package/src/plugins/events.js +0 -77
- package/src/plugins/ipc.js +0 -136
- package/src/plugins/load.js +0 -66
- package/src/plugins/manifest/check.js +0 -80
- package/src/plugins/manifest/load.js +0 -54
- package/src/plugins/manifest/main.js +0 -24
- package/src/plugins/manifest/path.js +0 -12
- package/src/plugins/manifest/validate.js +0 -136
- package/src/plugins/node_version.js +0 -74
- package/src/plugins/options.js +0 -78
- package/src/plugins/package.js +0 -17
- package/src/plugins/resolve.js +0 -159
- package/src/plugins/spawn.js +0 -82
- package/src/plugins_core/cache/manifest.yml +0 -1
- package/src/plugins_core/cache/plugin.js +0 -75
- package/src/plugins_core/functions/manifest.yml +0 -1
- package/src/plugins_core/functions/plugin.js +0 -37
- package/src/plugins_core/functions_install/plugin.js +0 -14
- package/src/plugins_core/main.js +0 -38
- package/src/status/add.js +0 -56
- package/src/status/colors.js +0 -25
- package/src/status/report.js +0 -57
- package/src/telemetry/complete.js +0 -49
- package/src/telemetry/request.js +0 -28
- package/src/telemetry/track.js +0 -33
- package/src/utils/omit.js +0 -8
- package/src/utils/polyfills.js +0 -3
- package/src/utils/remove_falsy.js +0 -12
- package/src/utils/resolve.js +0 -39
- /package/{src → lib}/plugins_core/functions_install/manifest.yml +0 -0
package/src/core/commands.js
DELETED
|
@@ -1,304 +0,0 @@
|
|
|
1
|
-
const { platform } = require('process')
|
|
2
|
-
|
|
3
|
-
const execa = require('execa')
|
|
4
|
-
const pReduce = require('p-reduce')
|
|
5
|
-
|
|
6
|
-
const { setEnvChanges } = require('../env/changes.js')
|
|
7
|
-
const { addErrorInfo, getErrorInfo } = require('../error/info')
|
|
8
|
-
const { reportBuildError } = require('../error/monitor/report')
|
|
9
|
-
const { serializeErrorStatus } = require('../error/parse/serialize_status')
|
|
10
|
-
const { logCommand, logBuildCommandStart, logCommandSuccess, logPluginError } = require('../log/main')
|
|
11
|
-
const { pipeOutput, unpipeOutput } = require('../log/stream')
|
|
12
|
-
const { startTimer, endTimer } = require('../log/timer')
|
|
13
|
-
const { EVENTS } = require('../plugins/events')
|
|
14
|
-
const { callChild } = require('../plugins/ipc')
|
|
15
|
-
const { getSuccessStatus, addStatus } = require('../status/add')
|
|
16
|
-
|
|
17
|
-
// Get commands for all events
|
|
18
|
-
const getCommands = function(pluginsCommands, netlifyConfig) {
|
|
19
|
-
const commands = addBuildCommand(pluginsCommands, netlifyConfig)
|
|
20
|
-
const commandsA = sortCommands(commands)
|
|
21
|
-
const commandsCount = commandsA.filter(isSuccessCommand).length
|
|
22
|
-
return { commands: commandsA, commandsCount }
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Merge `build.command` with plugin event handlers
|
|
26
|
-
const addBuildCommand = function(pluginsCommands, { build: { command: buildCommand } }) {
|
|
27
|
-
if (buildCommand === undefined) {
|
|
28
|
-
return pluginsCommands
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return [{ event: 'onBuild', buildCommand }, ...pluginsCommands]
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// Sort plugin commands by event order.
|
|
35
|
-
const sortCommands = function(commands) {
|
|
36
|
-
return EVENTS.flatMap(event => commands.filter(command => command.event === event))
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const isMainCommand = function({ event }) {
|
|
40
|
-
return event !== 'onEnd' && event !== 'onError'
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const isEndCommand = function({ event }) {
|
|
44
|
-
return event === 'onEnd'
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const isErrorCommand = function({ event }) {
|
|
48
|
-
return event === 'onError'
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const isSuccessCommand = function({ event }) {
|
|
52
|
-
return isMainCommand({ event }) || isEndCommand({ event })
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
// Run all commands.
|
|
56
|
-
// Each command can change some state: last `error`, environment variables changes,
|
|
57
|
-
// list of `failedPlugins` (that ran `utils.build.failPlugin()`).
|
|
58
|
-
// If an error arises, runs `onError` events.
|
|
59
|
-
// Runs `onEnd` events at the end, whether an error was thrown or not.
|
|
60
|
-
const runCommands = async function({
|
|
61
|
-
commands,
|
|
62
|
-
configPath,
|
|
63
|
-
buildDir,
|
|
64
|
-
nodePath,
|
|
65
|
-
childEnv,
|
|
66
|
-
errorMonitor,
|
|
67
|
-
netlifyConfig,
|
|
68
|
-
}) {
|
|
69
|
-
const { index: commandsCount, error: errorA, statuses: statusesB } = await pReduce(
|
|
70
|
-
commands,
|
|
71
|
-
async (
|
|
72
|
-
{ index, error, failedPlugins, envChanges, statuses },
|
|
73
|
-
{ event, childProcess, package, packageJson, loadedFrom, origin, buildCommand },
|
|
74
|
-
) => {
|
|
75
|
-
const { newIndex = index, newError = error, failedPlugin = [], newEnvChanges = {}, newStatus } = await runCommand(
|
|
76
|
-
{
|
|
77
|
-
event,
|
|
78
|
-
childProcess,
|
|
79
|
-
package,
|
|
80
|
-
packageJson,
|
|
81
|
-
loadedFrom,
|
|
82
|
-
origin,
|
|
83
|
-
buildCommand,
|
|
84
|
-
configPath,
|
|
85
|
-
buildDir,
|
|
86
|
-
nodePath,
|
|
87
|
-
index,
|
|
88
|
-
childEnv,
|
|
89
|
-
envChanges,
|
|
90
|
-
commands,
|
|
91
|
-
errorMonitor,
|
|
92
|
-
error,
|
|
93
|
-
failedPlugins,
|
|
94
|
-
netlifyConfig,
|
|
95
|
-
},
|
|
96
|
-
)
|
|
97
|
-
const statusesA = addStatus({ newStatus, statuses, event, package, packageJson })
|
|
98
|
-
return {
|
|
99
|
-
index: newIndex,
|
|
100
|
-
error: newError,
|
|
101
|
-
failedPlugins: [...failedPlugins, ...failedPlugin],
|
|
102
|
-
envChanges: { ...envChanges, ...newEnvChanges },
|
|
103
|
-
statuses: statusesA,
|
|
104
|
-
}
|
|
105
|
-
},
|
|
106
|
-
{ index: 0, failedPlugins: [], envChanges: {}, statuses: [] },
|
|
107
|
-
)
|
|
108
|
-
return { commandsCount, error: errorA, statuses: statusesB }
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Run a command (shell or plugin)
|
|
112
|
-
const runCommand = async function({
|
|
113
|
-
event,
|
|
114
|
-
childProcess,
|
|
115
|
-
package,
|
|
116
|
-
packageJson,
|
|
117
|
-
loadedFrom,
|
|
118
|
-
origin,
|
|
119
|
-
buildCommand,
|
|
120
|
-
configPath,
|
|
121
|
-
buildDir,
|
|
122
|
-
nodePath,
|
|
123
|
-
index,
|
|
124
|
-
childEnv,
|
|
125
|
-
envChanges,
|
|
126
|
-
commands,
|
|
127
|
-
errorMonitor,
|
|
128
|
-
error,
|
|
129
|
-
failedPlugins,
|
|
130
|
-
netlifyConfig,
|
|
131
|
-
}) {
|
|
132
|
-
if (shouldSkipCommand({ event, package, error, failedPlugins })) {
|
|
133
|
-
return {}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const methodTimer = startTimer()
|
|
137
|
-
|
|
138
|
-
logCommand({ event, package, index, configPath, error })
|
|
139
|
-
|
|
140
|
-
const { newEnvChanges, newError, newStatus } = await fireCommand({
|
|
141
|
-
event,
|
|
142
|
-
childProcess,
|
|
143
|
-
package,
|
|
144
|
-
packageJson,
|
|
145
|
-
loadedFrom,
|
|
146
|
-
origin,
|
|
147
|
-
buildCommand,
|
|
148
|
-
configPath,
|
|
149
|
-
buildDir,
|
|
150
|
-
nodePath,
|
|
151
|
-
childEnv,
|
|
152
|
-
envChanges,
|
|
153
|
-
commands,
|
|
154
|
-
error,
|
|
155
|
-
})
|
|
156
|
-
|
|
157
|
-
const newValues =
|
|
158
|
-
newError === undefined
|
|
159
|
-
? handleCommandSuccess({ event, package, newEnvChanges, newStatus, methodTimer })
|
|
160
|
-
: await handleCommandError({ newError, errorMonitor, buildCommand, netlifyConfig })
|
|
161
|
-
return { ...newValues, newIndex: index + 1 }
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
// If either:
|
|
165
|
-
// - an error was thrown by the current plugin or another one
|
|
166
|
-
// - the current plugin previously ran `utils.build.failPlugin()`, `failBuild()` or `cancelBuild()`
|
|
167
|
-
// Then:
|
|
168
|
-
// - run `onError` event (otherwise not run)
|
|
169
|
-
// - run `onEnd` event (always run regardless)
|
|
170
|
-
// - skip other events
|
|
171
|
-
const shouldSkipCommand = function({ event, package, error, failedPlugins }) {
|
|
172
|
-
const isError = error !== undefined || failedPlugins.includes(package)
|
|
173
|
-
return (isMainCommand({ event }) && isError) || (isErrorCommand({ event }) && !isError)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const fireCommand = function({
|
|
177
|
-
event,
|
|
178
|
-
childProcess,
|
|
179
|
-
package,
|
|
180
|
-
packageJson,
|
|
181
|
-
loadedFrom,
|
|
182
|
-
origin,
|
|
183
|
-
buildCommand,
|
|
184
|
-
configPath,
|
|
185
|
-
buildDir,
|
|
186
|
-
nodePath,
|
|
187
|
-
childEnv,
|
|
188
|
-
envChanges,
|
|
189
|
-
commands,
|
|
190
|
-
error,
|
|
191
|
-
}) {
|
|
192
|
-
if (buildCommand !== undefined) {
|
|
193
|
-
return fireBuildCommand({ buildCommand, configPath, buildDir, nodePath, childEnv, envChanges })
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return firePluginCommand({
|
|
197
|
-
event,
|
|
198
|
-
childProcess,
|
|
199
|
-
package,
|
|
200
|
-
packageJson,
|
|
201
|
-
loadedFrom,
|
|
202
|
-
origin,
|
|
203
|
-
envChanges,
|
|
204
|
-
commands,
|
|
205
|
-
error,
|
|
206
|
-
})
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
// Fire `build.command`
|
|
210
|
-
const fireBuildCommand = async function({ buildCommand, configPath, buildDir, nodePath, childEnv, envChanges }) {
|
|
211
|
-
logBuildCommandStart(buildCommand)
|
|
212
|
-
|
|
213
|
-
const env = setEnvChanges(envChanges, { ...childEnv })
|
|
214
|
-
const childProcess = execa(buildCommand, {
|
|
215
|
-
shell: SHELL,
|
|
216
|
-
cwd: buildDir,
|
|
217
|
-
preferLocal: true,
|
|
218
|
-
execPath: nodePath,
|
|
219
|
-
env,
|
|
220
|
-
extendEnv: false,
|
|
221
|
-
stdio: 'inherit',
|
|
222
|
-
})
|
|
223
|
-
|
|
224
|
-
try {
|
|
225
|
-
await childProcess
|
|
226
|
-
return {}
|
|
227
|
-
} catch (newError) {
|
|
228
|
-
addErrorInfo(newError, { type: 'buildCommand', location: { buildCommand, configPath } })
|
|
229
|
-
return { newError }
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
// We use Bash on Unix and `cmd.exe` on Windows
|
|
234
|
-
const SHELL = platform === 'win32' ? true : 'bash'
|
|
235
|
-
|
|
236
|
-
// Fire a plugin command
|
|
237
|
-
const firePluginCommand = async function({
|
|
238
|
-
event,
|
|
239
|
-
childProcess,
|
|
240
|
-
package,
|
|
241
|
-
packageJson,
|
|
242
|
-
loadedFrom,
|
|
243
|
-
origin,
|
|
244
|
-
envChanges,
|
|
245
|
-
commands,
|
|
246
|
-
error,
|
|
247
|
-
}) {
|
|
248
|
-
pipeOutput(childProcess)
|
|
249
|
-
|
|
250
|
-
try {
|
|
251
|
-
const { newEnvChanges, status } = await callChild(
|
|
252
|
-
childProcess,
|
|
253
|
-
'run',
|
|
254
|
-
{ event, error, envChanges },
|
|
255
|
-
{ plugin: { packageJson, package }, location: { event, package, loadedFrom, origin } },
|
|
256
|
-
)
|
|
257
|
-
const newStatus = getSuccessStatus(status, { commands, event, package })
|
|
258
|
-
return { newEnvChanges, newStatus }
|
|
259
|
-
} catch (newError) {
|
|
260
|
-
return { newError }
|
|
261
|
-
} finally {
|
|
262
|
-
unpipeOutput(childProcess)
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
// `build.command` or plugin event handle success
|
|
267
|
-
const handleCommandSuccess = function({ event, package, newEnvChanges, newStatus, methodTimer }) {
|
|
268
|
-
logCommandSuccess()
|
|
269
|
-
|
|
270
|
-
const timerName = package === undefined ? 'build.command' : `${package} ${event}`
|
|
271
|
-
endTimer(methodTimer, timerName)
|
|
272
|
-
|
|
273
|
-
return { newEnvChanges, newStatus }
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
// Handle shell or plugin error:
|
|
277
|
-
// - usually (`failFast`), propagate the error to make the build stop.
|
|
278
|
-
// - if onError and onEnd events (not `failFast`), wait until all event
|
|
279
|
-
// handlers of the same type have been triggered before propagating
|
|
280
|
-
// - if `utils.build.failPlugin()` was used, print an error and skip next event
|
|
281
|
-
// handlers of that plugin. But do not stop build.
|
|
282
|
-
const handleCommandError = async function({ newError, errorMonitor, buildCommand, netlifyConfig }) {
|
|
283
|
-
// `build.command` do not report error statuses
|
|
284
|
-
if (buildCommand !== undefined) {
|
|
285
|
-
return { newError }
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
const { type, location: { package } = {} } = getErrorInfo(newError)
|
|
289
|
-
const newStatus = serializeErrorStatus(newError)
|
|
290
|
-
|
|
291
|
-
if (type === 'failPlugin') {
|
|
292
|
-
return handleFailPlugin({ newStatus, package, newError, errorMonitor, netlifyConfig })
|
|
293
|
-
}
|
|
294
|
-
|
|
295
|
-
return { newError, newStatus }
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
const handleFailPlugin = async function({ newStatus, package, newError, errorMonitor, netlifyConfig }) {
|
|
299
|
-
logPluginError(newError, netlifyConfig)
|
|
300
|
-
await reportBuildError(newError, errorMonitor)
|
|
301
|
-
return { failedPlugin: [package], newStatus }
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
module.exports = { getCommands, isSuccessCommand, runCommands }
|
package/src/core/config.js
DELETED
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
env: { NETLIFY_AUTH_TOKEN },
|
|
3
|
-
execPath,
|
|
4
|
-
} = require('process')
|
|
5
|
-
|
|
6
|
-
const resolveConfig = require('@netlify/config')
|
|
7
|
-
|
|
8
|
-
const { addApiErrorHandlers } = require('../error/api')
|
|
9
|
-
const { addErrorInfo } = require('../error/info')
|
|
10
|
-
const { logFlags, logBuildDir, logConfigPath, logConfig, logContext } = require('../log/main')
|
|
11
|
-
const { removeFalsy } = require('../utils/remove_falsy')
|
|
12
|
-
|
|
13
|
-
const { getConstants } = require('./constants')
|
|
14
|
-
|
|
15
|
-
// Normalize CLI flags
|
|
16
|
-
const normalizeFlags = function(flags) {
|
|
17
|
-
const flagsA = removeFalsy(flags)
|
|
18
|
-
logFlags(flagsA)
|
|
19
|
-
|
|
20
|
-
const flagsB = { ...DEFAULT_FLAGS, ...flagsA }
|
|
21
|
-
const flagsC = removeFalsy(flagsB)
|
|
22
|
-
return flagsC
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// Default values of CLI flags
|
|
26
|
-
const DEFAULT_FLAGS = {
|
|
27
|
-
nodePath: execPath,
|
|
28
|
-
token: NETLIFY_AUTH_TOKEN,
|
|
29
|
-
mode: 'require',
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Retrieve configuration object
|
|
33
|
-
const loadConfig = async function({
|
|
34
|
-
config,
|
|
35
|
-
defaultConfig,
|
|
36
|
-
cachedConfig,
|
|
37
|
-
cwd,
|
|
38
|
-
repositoryRoot,
|
|
39
|
-
dry,
|
|
40
|
-
nodePath,
|
|
41
|
-
token,
|
|
42
|
-
siteId,
|
|
43
|
-
context,
|
|
44
|
-
branch,
|
|
45
|
-
baseRelDir,
|
|
46
|
-
mode,
|
|
47
|
-
}) {
|
|
48
|
-
const {
|
|
49
|
-
configPath,
|
|
50
|
-
buildDir,
|
|
51
|
-
config: netlifyConfig,
|
|
52
|
-
context: contextA,
|
|
53
|
-
branch: branchA,
|
|
54
|
-
api,
|
|
55
|
-
siteInfo,
|
|
56
|
-
} = await resolveFullConfig({
|
|
57
|
-
config,
|
|
58
|
-
defaultConfig,
|
|
59
|
-
cachedConfig,
|
|
60
|
-
cwd,
|
|
61
|
-
repositoryRoot,
|
|
62
|
-
context,
|
|
63
|
-
branch,
|
|
64
|
-
baseRelDir,
|
|
65
|
-
token,
|
|
66
|
-
siteId,
|
|
67
|
-
mode,
|
|
68
|
-
})
|
|
69
|
-
logBuildDir(buildDir)
|
|
70
|
-
logConfigPath(configPath)
|
|
71
|
-
logConfig(netlifyConfig)
|
|
72
|
-
logContext(contextA)
|
|
73
|
-
|
|
74
|
-
const apiA = addApiErrorHandlers(api)
|
|
75
|
-
const constants = await getConstants({ configPath, buildDir, netlifyConfig, siteInfo, mode })
|
|
76
|
-
return {
|
|
77
|
-
netlifyConfig,
|
|
78
|
-
configPath,
|
|
79
|
-
buildDir,
|
|
80
|
-
nodePath,
|
|
81
|
-
api: apiA,
|
|
82
|
-
token,
|
|
83
|
-
dry,
|
|
84
|
-
siteInfo,
|
|
85
|
-
constants,
|
|
86
|
-
context: contextA,
|
|
87
|
-
branch: branchA,
|
|
88
|
-
mode,
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// Retrieve configuration file and related information
|
|
93
|
-
// (path, build directory, etc.)
|
|
94
|
-
const resolveFullConfig = async function({
|
|
95
|
-
config,
|
|
96
|
-
defaultConfig,
|
|
97
|
-
cachedConfig,
|
|
98
|
-
cwd,
|
|
99
|
-
repositoryRoot,
|
|
100
|
-
context,
|
|
101
|
-
branch,
|
|
102
|
-
baseRelDir,
|
|
103
|
-
token,
|
|
104
|
-
siteId,
|
|
105
|
-
mode,
|
|
106
|
-
}) {
|
|
107
|
-
try {
|
|
108
|
-
return await resolveConfig({
|
|
109
|
-
config,
|
|
110
|
-
defaultConfig,
|
|
111
|
-
cachedConfig,
|
|
112
|
-
cwd,
|
|
113
|
-
repositoryRoot,
|
|
114
|
-
context,
|
|
115
|
-
branch,
|
|
116
|
-
baseRelDir,
|
|
117
|
-
token,
|
|
118
|
-
siteId,
|
|
119
|
-
mode,
|
|
120
|
-
})
|
|
121
|
-
} catch (error) {
|
|
122
|
-
if (error.type === 'userError') {
|
|
123
|
-
delete error.type
|
|
124
|
-
addErrorInfo(error, { type: 'resolveConfig' })
|
|
125
|
-
}
|
|
126
|
-
throw error
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
module.exports = { normalizeFlags, loadConfig }
|
package/src/core/constants.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const { tmpdir } = require('os')
|
|
2
|
-
const { relative, normalize } = require('path')
|
|
3
|
-
const {
|
|
4
|
-
env: { DEPLOY_ID },
|
|
5
|
-
} = require('process')
|
|
6
|
-
|
|
7
|
-
const { getCacheDir } = require('@netlify/cache-utils')
|
|
8
|
-
const mapObj = require('map-obj')
|
|
9
|
-
|
|
10
|
-
// Retrieve constants passed to plugins
|
|
11
|
-
const getConstants = async function({
|
|
12
|
-
configPath,
|
|
13
|
-
buildDir,
|
|
14
|
-
netlifyConfig: {
|
|
15
|
-
build: { publish = buildDir, functions },
|
|
16
|
-
},
|
|
17
|
-
siteInfo: { id: siteId },
|
|
18
|
-
mode,
|
|
19
|
-
}) {
|
|
20
|
-
const isLocal = mode !== 'buildbot'
|
|
21
|
-
const functionsDist = getFunctionsDist(isLocal)
|
|
22
|
-
const cacheDir = await getCacheDir({ mode })
|
|
23
|
-
|
|
24
|
-
const constants = {
|
|
25
|
-
/**
|
|
26
|
-
* Path to the Netlify configuration file
|
|
27
|
-
*/
|
|
28
|
-
CONFIG_PATH: configPath,
|
|
29
|
-
/**
|
|
30
|
-
* Directory that contains the deploy-ready HTML files and assets generated by the build
|
|
31
|
-
*/
|
|
32
|
-
PUBLISH_DIR: publish,
|
|
33
|
-
/**
|
|
34
|
-
* The directory where function source code lives
|
|
35
|
-
*/
|
|
36
|
-
FUNCTIONS_SRC: functions,
|
|
37
|
-
/**
|
|
38
|
-
* The directory where built serverless functions are placed before deployment
|
|
39
|
-
*/
|
|
40
|
-
FUNCTIONS_DIST: functionsDist,
|
|
41
|
-
/**
|
|
42
|
-
* Path to the Netlify build cache folder
|
|
43
|
-
*/
|
|
44
|
-
CACHE_DIR: cacheDir,
|
|
45
|
-
/**
|
|
46
|
-
* Boolean indicating whether the build was run locally (Netlify CLI) or in the production CI
|
|
47
|
-
*/
|
|
48
|
-
IS_LOCAL: isLocal,
|
|
49
|
-
/**
|
|
50
|
-
* The Netlify Site ID
|
|
51
|
-
*/
|
|
52
|
-
SITE_ID: siteId,
|
|
53
|
-
}
|
|
54
|
-
const constantsA = mapObj(constants, (key, path) => [key, normalizePath(path, buildDir, key)])
|
|
55
|
-
return constantsA
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const LOCAL_FUNCTIONS_DIST = '.netlify/functions/'
|
|
59
|
-
const getFunctionsDist = function(isLocal) {
|
|
60
|
-
if (isLocal) {
|
|
61
|
-
return LOCAL_FUNCTIONS_DIST
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return `${tmpdir()}/zisi-${DEPLOY_ID}`
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// The current directory is `buildDir`. Most constants are inside this `buildDir`.
|
|
68
|
-
// Instead of passing absolute paths, we pass paths relative to `buildDir`, so
|
|
69
|
-
// that logs are less verbose.
|
|
70
|
-
const normalizePath = function(path, buildDir, key) {
|
|
71
|
-
if (path === undefined || NOT_PATHS.includes(key)) {
|
|
72
|
-
return path
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const pathA = normalize(path)
|
|
76
|
-
|
|
77
|
-
if (pathA.startsWith(buildDir) && pathA !== buildDir) {
|
|
78
|
-
return relative(buildDir, pathA)
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return pathA
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const NOT_PATHS = ['IS_LOCAL', 'SITE_ID']
|
|
85
|
-
|
|
86
|
-
module.exports = { getConstants }
|
package/src/core/dry.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
const { logDryRunStart, logDryRunCommand, logDryRunEnd } = require('../log/main')
|
|
2
|
-
|
|
3
|
-
const { isSuccessCommand } = require('./commands')
|
|
4
|
-
|
|
5
|
-
// If the `dry` flag is specified, do a dry run
|
|
6
|
-
const doDryRun = function({ commands, commandsCount, configPath }) {
|
|
7
|
-
const successCommands = commands.filter(isSuccessCommand)
|
|
8
|
-
const eventWidth = Math.max(...successCommands.map(getEventLength))
|
|
9
|
-
|
|
10
|
-
logDryRunStart(eventWidth, commandsCount)
|
|
11
|
-
|
|
12
|
-
successCommands.forEach((command, index) => {
|
|
13
|
-
logDryRunCommand({ command, index, configPath, eventWidth, commandsCount })
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
logDryRunEnd()
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const getEventLength = function({ event }) {
|
|
20
|
-
return event.length
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
module.exports = { doDryRun }
|