@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/error.js
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { cancelBuild } from '../error/cancel.js'
|
|
2
|
-
import { handleBuildError } from '../error/handle.js'
|
|
3
|
-
import { getFullErrorInfo, parseErrorInfo } from '../error/parse/parse.js'
|
|
4
|
-
import { serializeErrorStatus } from '../error/parse/serialize_status.js'
|
|
5
|
-
import { isSoftFailEvent } from '../plugins/events.js'
|
|
6
|
-
|
|
7
|
-
// Handle build command errors and plugin errors:
|
|
8
|
-
// - usually, propagate the error to make the build stop.
|
|
9
|
-
// - `utils.build.cancelBuild()` also cancels the build by calling the API
|
|
10
|
-
// - `utils.build.failPlugin()` or post-deploy errors do not make the build
|
|
11
|
-
// stop, but are still reported, and prevent future events from the same
|
|
12
|
-
// plugin.
|
|
13
|
-
// This also computes error statuses that are sent to the API.
|
|
14
|
-
export const handleStepError = function ({
|
|
15
|
-
event,
|
|
16
|
-
newError,
|
|
17
|
-
childEnv,
|
|
18
|
-
mode,
|
|
19
|
-
api,
|
|
20
|
-
errorMonitor,
|
|
21
|
-
deployId,
|
|
22
|
-
coreStep,
|
|
23
|
-
netlifyConfig,
|
|
24
|
-
logs,
|
|
25
|
-
debug,
|
|
26
|
-
testOpts,
|
|
27
|
-
}) {
|
|
28
|
-
// Core steps do not report error statuses
|
|
29
|
-
if (coreStep !== undefined) {
|
|
30
|
-
return { newError }
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const fullErrorInfo = getFullErrorInfo({ error: newError, colors: false, debug })
|
|
34
|
-
const { type } = fullErrorInfo
|
|
35
|
-
|
|
36
|
-
if (type === 'failPlugin' || isSoftFailEvent(event)) {
|
|
37
|
-
return handleFailPlugin({
|
|
38
|
-
fullErrorInfo,
|
|
39
|
-
newError,
|
|
40
|
-
childEnv,
|
|
41
|
-
mode,
|
|
42
|
-
errorMonitor,
|
|
43
|
-
netlifyConfig,
|
|
44
|
-
logs,
|
|
45
|
-
debug,
|
|
46
|
-
testOpts,
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (type === 'cancelBuild') {
|
|
51
|
-
return handleCancelBuild({ fullErrorInfo, newError, api, deployId })
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return handleFailBuild({ fullErrorInfo, newError })
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// On `utils.build.failPlugin()` or during `onSuccess` or `onEnd`
|
|
58
|
-
const handleFailPlugin = async function ({
|
|
59
|
-
fullErrorInfo,
|
|
60
|
-
fullErrorInfo: {
|
|
61
|
-
errorInfo: { location: { packageName } = {} },
|
|
62
|
-
},
|
|
63
|
-
newError,
|
|
64
|
-
childEnv,
|
|
65
|
-
mode,
|
|
66
|
-
errorMonitor,
|
|
67
|
-
netlifyConfig,
|
|
68
|
-
logs,
|
|
69
|
-
debug,
|
|
70
|
-
testOpts,
|
|
71
|
-
}) {
|
|
72
|
-
const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_plugin' })
|
|
73
|
-
await handleBuildError(newError, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts })
|
|
74
|
-
return { failedPlugin: [packageName], newStatus }
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// On `utils.build.cancelBuild()`
|
|
78
|
-
const handleCancelBuild = async function ({ fullErrorInfo, newError, api, deployId }) {
|
|
79
|
-
const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'canceled_build' })
|
|
80
|
-
await cancelBuild({ api, deployId })
|
|
81
|
-
return { newError, newStatus }
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
// On `utils.build.failBuild()` or uncaught exception
|
|
85
|
-
const handleFailBuild = function ({ fullErrorInfo, newError }) {
|
|
86
|
-
const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_build' })
|
|
87
|
-
return { newError, newStatus }
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Unlike community plugins, core plugin bugs should be handled as system errors
|
|
91
|
-
export const getPluginErrorType = function (error, loadedFrom) {
|
|
92
|
-
if (!isCorePluginBug(error, loadedFrom)) {
|
|
93
|
-
return {}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return { type: 'corePlugin' }
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
const isCorePluginBug = function (error, loadedFrom) {
|
|
100
|
-
const { severity } = parseErrorInfo(error)
|
|
101
|
-
return severity === 'warning' && loadedFrom === 'core'
|
|
102
|
-
}
|
package/src/steps/get.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { EVENTS } from '../plugins/events.js'
|
|
2
|
-
import { buildCommandCore } from '../plugins_core/build_command.js'
|
|
3
|
-
import { deploySite } from '../plugins_core/deploy/index.js'
|
|
4
|
-
import { bundleEdgeFunctions } from '../plugins_core/edge_functions/index.js'
|
|
5
|
-
import { bundleFunctions } from '../plugins_core/functions/index.js'
|
|
6
|
-
|
|
7
|
-
// Get all build steps
|
|
8
|
-
export const getSteps = function (steps) {
|
|
9
|
-
const stepsA = addCoreSteps(steps)
|
|
10
|
-
const stepsB = sortSteps(stepsA)
|
|
11
|
-
const events = getEvents(stepsB)
|
|
12
|
-
return { steps: stepsB, events }
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const addCoreSteps = function (steps) {
|
|
16
|
-
return [buildCommandCore, ...steps, bundleFunctions, bundleEdgeFunctions, deploySite]
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Sort plugin steps by event order.
|
|
20
|
-
const sortSteps = function (steps) {
|
|
21
|
-
return EVENTS.flatMap((event) => steps.filter((step) => step.event === event))
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Retrieve list of unique events
|
|
25
|
-
const getEvents = function (steps) {
|
|
26
|
-
const events = steps.map(getEvent)
|
|
27
|
-
return [...new Set(events)]
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const getEvent = function ({ event }) {
|
|
31
|
-
return event
|
|
32
|
-
}
|
package/src/steps/plugin.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { addErrorInfo } from '../error/info.js'
|
|
2
|
-
import { logStepCompleted } from '../log/messages/ipc.js'
|
|
3
|
-
import { pipePluginOutput, unpipePluginOutput } from '../log/stream.js'
|
|
4
|
-
import { callChild } from '../plugins/ipc.js'
|
|
5
|
-
import { getSuccessStatus } from '../status/success.js'
|
|
6
|
-
|
|
7
|
-
import { getPluginErrorType } from './error.js'
|
|
8
|
-
import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js'
|
|
9
|
-
|
|
10
|
-
// Fire a plugin step
|
|
11
|
-
export const firePluginStep = async function ({
|
|
12
|
-
event,
|
|
13
|
-
childProcess,
|
|
14
|
-
packageName,
|
|
15
|
-
pluginPackageJson,
|
|
16
|
-
loadedFrom,
|
|
17
|
-
origin,
|
|
18
|
-
envChanges,
|
|
19
|
-
errorParams,
|
|
20
|
-
configOpts,
|
|
21
|
-
netlifyConfig,
|
|
22
|
-
configMutations,
|
|
23
|
-
headersPath,
|
|
24
|
-
redirectsPath,
|
|
25
|
-
constants,
|
|
26
|
-
steps,
|
|
27
|
-
error,
|
|
28
|
-
logs,
|
|
29
|
-
debug,
|
|
30
|
-
verbose,
|
|
31
|
-
}) {
|
|
32
|
-
const listeners = pipePluginOutput(childProcess, logs)
|
|
33
|
-
|
|
34
|
-
try {
|
|
35
|
-
const configSideFiles = await listConfigSideFiles([headersPath, redirectsPath])
|
|
36
|
-
const {
|
|
37
|
-
newEnvChanges,
|
|
38
|
-
configMutations: newConfigMutations,
|
|
39
|
-
status,
|
|
40
|
-
} = await callChild({
|
|
41
|
-
childProcess,
|
|
42
|
-
eventName: 'run',
|
|
43
|
-
payload: { event, error, envChanges, netlifyConfig, constants },
|
|
44
|
-
logs,
|
|
45
|
-
verbose,
|
|
46
|
-
})
|
|
47
|
-
const {
|
|
48
|
-
netlifyConfig: netlifyConfigA,
|
|
49
|
-
configMutations: configMutationsA,
|
|
50
|
-
headersPath: headersPathA,
|
|
51
|
-
redirectsPath: redirectsPathA,
|
|
52
|
-
} = await updateNetlifyConfig({
|
|
53
|
-
configOpts,
|
|
54
|
-
netlifyConfig,
|
|
55
|
-
headersPath,
|
|
56
|
-
redirectsPath,
|
|
57
|
-
configMutations,
|
|
58
|
-
newConfigMutations,
|
|
59
|
-
configSideFiles,
|
|
60
|
-
errorParams,
|
|
61
|
-
logs,
|
|
62
|
-
debug,
|
|
63
|
-
})
|
|
64
|
-
const newStatus = getSuccessStatus(status, { steps, event, packageName })
|
|
65
|
-
return {
|
|
66
|
-
newEnvChanges,
|
|
67
|
-
netlifyConfig: netlifyConfigA,
|
|
68
|
-
configMutations: configMutationsA,
|
|
69
|
-
headersPath: headersPathA,
|
|
70
|
-
redirectsPath: redirectsPathA,
|
|
71
|
-
newStatus,
|
|
72
|
-
}
|
|
73
|
-
} catch (newError) {
|
|
74
|
-
const errorType = getPluginErrorType(newError, loadedFrom)
|
|
75
|
-
addErrorInfo(newError, {
|
|
76
|
-
...errorType,
|
|
77
|
-
plugin: { pluginPackageJson, packageName },
|
|
78
|
-
location: { event, packageName, loadedFrom, origin },
|
|
79
|
-
})
|
|
80
|
-
return { newError }
|
|
81
|
-
} finally {
|
|
82
|
-
await unpipePluginOutput(childProcess, logs, listeners)
|
|
83
|
-
logStepCompleted(logs, verbose)
|
|
84
|
-
}
|
|
85
|
-
}
|
package/src/steps/return.js
DELETED
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { logTimer } from '../log/messages/core.js'
|
|
2
|
-
import { logStepSuccess } from '../log/messages/steps.js'
|
|
3
|
-
|
|
4
|
-
import { handleStepError } from './error.js'
|
|
5
|
-
|
|
6
|
-
// Retrieve the return value of a step
|
|
7
|
-
export const getStepReturn = function ({
|
|
8
|
-
event,
|
|
9
|
-
packageName,
|
|
10
|
-
newError,
|
|
11
|
-
newEnvChanges,
|
|
12
|
-
newStatus,
|
|
13
|
-
coreStep,
|
|
14
|
-
coreStepName: timerName = `${packageName} ${event}`,
|
|
15
|
-
childEnv,
|
|
16
|
-
mode,
|
|
17
|
-
api,
|
|
18
|
-
errorMonitor,
|
|
19
|
-
deployId,
|
|
20
|
-
netlifyConfig,
|
|
21
|
-
configMutations,
|
|
22
|
-
headersPath,
|
|
23
|
-
redirectsPath,
|
|
24
|
-
logs,
|
|
25
|
-
debug,
|
|
26
|
-
timers,
|
|
27
|
-
durationNs,
|
|
28
|
-
testOpts,
|
|
29
|
-
}) {
|
|
30
|
-
if (newError !== undefined) {
|
|
31
|
-
return handleStepError({
|
|
32
|
-
event,
|
|
33
|
-
newError,
|
|
34
|
-
childEnv,
|
|
35
|
-
mode,
|
|
36
|
-
api,
|
|
37
|
-
errorMonitor,
|
|
38
|
-
deployId,
|
|
39
|
-
coreStep,
|
|
40
|
-
netlifyConfig,
|
|
41
|
-
logs,
|
|
42
|
-
debug,
|
|
43
|
-
testOpts,
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
logStepSuccess(logs)
|
|
48
|
-
|
|
49
|
-
logTimer(logs, durationNs, timerName)
|
|
50
|
-
|
|
51
|
-
return { newEnvChanges, netlifyConfig, configMutations, headersPath, redirectsPath, newStatus, timers }
|
|
52
|
-
}
|
|
@@ -1,194 +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 } 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
|
-
|
|
43
|
-
try {
|
|
44
|
-
const { netlifyConfig: netlifyConfigA, configMutations } = await executeBuildStep({
|
|
45
|
-
...flagsA,
|
|
46
|
-
errorMonitor,
|
|
47
|
-
mode,
|
|
48
|
-
logs,
|
|
49
|
-
debug,
|
|
50
|
-
errorParams,
|
|
51
|
-
buildSteps,
|
|
52
|
-
})
|
|
53
|
-
const { success, severityCode } = getSeverity('success')
|
|
54
|
-
|
|
55
|
-
return { success, severityCode, netlifyConfig: netlifyConfigA, configMutations, logs }
|
|
56
|
-
} catch (error) {
|
|
57
|
-
const { severity } = await handleBuildError(error, errorParams)
|
|
58
|
-
const { success, severityCode } = getSeverity(severity)
|
|
59
|
-
|
|
60
|
-
return { success, severityCode, logs }
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const startBuild = function (flags) {
|
|
65
|
-
const logs = getBufferLogs(flags)
|
|
66
|
-
|
|
67
|
-
logBuildStart(logs)
|
|
68
|
-
|
|
69
|
-
const { bugsnagKey, ...flagsA } = normalizeFlags(flags, logs)
|
|
70
|
-
const errorMonitor = startErrorMonitor({ flags: flagsA, logs, bugsnagKey })
|
|
71
|
-
|
|
72
|
-
return { ...flagsA, errorMonitor, logs }
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
const getBuildSteps = function (buildSteps) {
|
|
76
|
-
const allSteps = getSteps([]).steps.filter(({ coreStepId }) => buildSteps.includes(coreStepId))
|
|
77
|
-
|
|
78
|
-
return allSteps
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
const executeBuildStep = async function ({
|
|
82
|
-
config,
|
|
83
|
-
defaultConfig,
|
|
84
|
-
cachedConfig,
|
|
85
|
-
debug,
|
|
86
|
-
nodePath,
|
|
87
|
-
functionsDistDir,
|
|
88
|
-
edgeFunctionsDistDir,
|
|
89
|
-
errorMonitor,
|
|
90
|
-
mode,
|
|
91
|
-
logs,
|
|
92
|
-
errorParams,
|
|
93
|
-
featureFlags,
|
|
94
|
-
buildSteps,
|
|
95
|
-
repositoryRoot,
|
|
96
|
-
}) {
|
|
97
|
-
const configOpts = getConfigOpts({
|
|
98
|
-
config,
|
|
99
|
-
defaultConfig,
|
|
100
|
-
featureFlags,
|
|
101
|
-
mode,
|
|
102
|
-
repositoryRoot,
|
|
103
|
-
})
|
|
104
|
-
const {
|
|
105
|
-
netlifyConfig,
|
|
106
|
-
buildDir,
|
|
107
|
-
siteInfo,
|
|
108
|
-
childEnv,
|
|
109
|
-
userNodeVersion,
|
|
110
|
-
repositoryRoot: repositoryRootA,
|
|
111
|
-
} = await loadConfig({
|
|
112
|
-
configOpts,
|
|
113
|
-
cachedConfig,
|
|
114
|
-
debug,
|
|
115
|
-
logs,
|
|
116
|
-
nodePath,
|
|
117
|
-
timers: [],
|
|
118
|
-
})
|
|
119
|
-
const constants = await getConstants({
|
|
120
|
-
buildDir,
|
|
121
|
-
functionsDistDir,
|
|
122
|
-
edgeFunctionsDistDir,
|
|
123
|
-
netlifyConfig,
|
|
124
|
-
siteInfo,
|
|
125
|
-
mode,
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
// eslint-disable-next-line fp/no-mutating-assign
|
|
129
|
-
Object.assign(errorParams, { netlifyConfig, siteInfo, childEnv, userNodeVersion })
|
|
130
|
-
|
|
131
|
-
try {
|
|
132
|
-
const { netlifyConfig: netlifyConfigA, configMutations } = await runBuildStep({
|
|
133
|
-
netlifyConfig,
|
|
134
|
-
buildDir,
|
|
135
|
-
nodePath,
|
|
136
|
-
logs,
|
|
137
|
-
debug,
|
|
138
|
-
constants,
|
|
139
|
-
featureFlags,
|
|
140
|
-
childEnv,
|
|
141
|
-
buildSteps,
|
|
142
|
-
repositoryRoot: repositoryRootA,
|
|
143
|
-
})
|
|
144
|
-
|
|
145
|
-
return {
|
|
146
|
-
netlifyConfig: netlifyConfigA,
|
|
147
|
-
configMutations,
|
|
148
|
-
}
|
|
149
|
-
} catch (error) {
|
|
150
|
-
const [{ statuses }] = getErrorInfo(error)
|
|
151
|
-
|
|
152
|
-
await reportStatuses({
|
|
153
|
-
statuses,
|
|
154
|
-
childEnv,
|
|
155
|
-
mode,
|
|
156
|
-
netlifyConfig,
|
|
157
|
-
errorMonitor,
|
|
158
|
-
logs,
|
|
159
|
-
debug,
|
|
160
|
-
pluginsOptions: [],
|
|
161
|
-
})
|
|
162
|
-
|
|
163
|
-
throw error
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
const runBuildStep = async function ({
|
|
168
|
-
netlifyConfig,
|
|
169
|
-
buildDir,
|
|
170
|
-
nodePath,
|
|
171
|
-
constants,
|
|
172
|
-
logs,
|
|
173
|
-
debug,
|
|
174
|
-
featureFlags,
|
|
175
|
-
childEnv,
|
|
176
|
-
buildSteps,
|
|
177
|
-
repositoryRoot,
|
|
178
|
-
}) {
|
|
179
|
-
const { netlifyConfig: netlifyConfigA, configMutations } = await runSteps({
|
|
180
|
-
steps: getBuildSteps(buildSteps),
|
|
181
|
-
buildDir,
|
|
182
|
-
nodePath,
|
|
183
|
-
constants,
|
|
184
|
-
netlifyConfig,
|
|
185
|
-
logs,
|
|
186
|
-
debug,
|
|
187
|
-
timers: [],
|
|
188
|
-
featureFlags,
|
|
189
|
-
childEnv,
|
|
190
|
-
repositoryRoot,
|
|
191
|
-
})
|
|
192
|
-
|
|
193
|
-
return { netlifyConfig: netlifyConfigA, configMutations }
|
|
194
|
-
}
|