@netlify/build 24.0.1 → 25.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -1
- package/src/core/config.js +9 -5
- package/src/core/main.js +1 -1
- package/src/error/handle.js +1 -1
- package/src/log/messages/config.js +8 -5
- package/src/log/messages/core.js +2 -2
- package/src/plugins/child/load.js +1 -1
- package/src/plugins/child/validate.js +5 -4
- package/src/plugins/events.js +7 -2
- package/src/steps/get.js +5 -4
- package/src/steps/update_config.js +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "25.0.0",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"main": "src/core/main.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -112,6 +112,7 @@
|
|
|
112
112
|
"ava": "^3.15.0",
|
|
113
113
|
"cpy": "^8.1.0",
|
|
114
114
|
"del": "^6.0.0",
|
|
115
|
+
"fast-safe-stringify": "^2.0.7",
|
|
115
116
|
"get-bin-path": "^5.1.0",
|
|
116
117
|
"get-node": "^11.0.2",
|
|
117
118
|
"get-port": "^5.1.1",
|
package/src/core/config.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
2
|
'use strict'
|
|
3
3
|
|
|
4
|
-
const resolveConfig = require('@netlify/config')
|
|
5
|
-
const { updateConfig, restoreConfig } = require('@netlify/config')
|
|
6
4
|
const mapObj = require('map-obj')
|
|
7
5
|
|
|
8
6
|
const { getChildEnv } = require('../env/main')
|
|
@@ -15,6 +13,8 @@ const { getPackageJson } = require('../utils/package')
|
|
|
15
13
|
|
|
16
14
|
const { getUserNodeVersion } = require('./user_node_version')
|
|
17
15
|
|
|
16
|
+
const netlifyConfigPromise = import('@netlify/config')
|
|
17
|
+
|
|
18
18
|
// Retrieve immutable options passed to `@netlify/config`.
|
|
19
19
|
// This does not include options which might change during the course of the
|
|
20
20
|
// build:
|
|
@@ -78,7 +78,7 @@ const tLoadConfig = async function ({ configOpts, cachedConfig, cachedConfigPath
|
|
|
78
78
|
siteInfo,
|
|
79
79
|
env,
|
|
80
80
|
} = await resolveInitialConfig(configOpts, cachedConfig, cachedConfigPath)
|
|
81
|
-
logConfigInfo({ logs, configPath, buildDir, netlifyConfig, context: contextA, debug })
|
|
81
|
+
await logConfigInfo({ logs, configPath, buildDir, netlifyConfig, context: contextA, debug })
|
|
82
82
|
|
|
83
83
|
const apiA = addApiErrorHandlers(api)
|
|
84
84
|
const envValues = mapObj(env, (key, { value }) => [key, value])
|
|
@@ -108,13 +108,14 @@ const loadConfig = measureDuration(tLoadConfig, 'resolve_config')
|
|
|
108
108
|
// In the buildbot and CLI, we re-use the already parsed `@netlify/config`
|
|
109
109
|
// return value which is passed as `cachedConfig`/`cachedConfigPath`.
|
|
110
110
|
const resolveInitialConfig = async function (configOpts, cachedConfig, cachedConfigPath) {
|
|
111
|
+
const { resolveConfig } = await netlifyConfigPromise
|
|
111
112
|
return await resolveConfig({ ...configOpts, cachedConfig, cachedConfigPath })
|
|
112
113
|
}
|
|
113
114
|
|
|
114
|
-
const logConfigInfo = function ({ logs, configPath, buildDir, netlifyConfig, context, debug }) {
|
|
115
|
+
const logConfigInfo = async function ({ logs, configPath, buildDir, netlifyConfig, context, debug }) {
|
|
115
116
|
logBuildDir(logs, buildDir)
|
|
116
117
|
logConfigPath(logs, configPath)
|
|
117
|
-
logConfig({ logs, netlifyConfig, debug })
|
|
118
|
+
await logConfig({ logs, netlifyConfig, debug })
|
|
118
119
|
logContext(logs, context)
|
|
119
120
|
}
|
|
120
121
|
|
|
@@ -126,6 +127,7 @@ const logConfigInfo = function ({ logs, configPath, buildDir, netlifyConfig, con
|
|
|
126
127
|
// Errors are propagated and assigned to the specific plugin or core step
|
|
127
128
|
// which changed the configuration.
|
|
128
129
|
const resolveUpdatedConfig = async function (configOpts, configMutations) {
|
|
130
|
+
const { resolveConfig } = await netlifyConfigPromise
|
|
129
131
|
try {
|
|
130
132
|
return await resolveConfig({ ...configOpts, configMutations, debug: false })
|
|
131
133
|
} catch (error) {
|
|
@@ -156,6 +158,7 @@ const saveUpdatedConfig = async function ({
|
|
|
156
158
|
return
|
|
157
159
|
}
|
|
158
160
|
|
|
161
|
+
const { updateConfig } = await netlifyConfigPromise
|
|
159
162
|
await updateConfig(configMutations, {
|
|
160
163
|
buildDir,
|
|
161
164
|
configPath,
|
|
@@ -184,6 +187,7 @@ const restoreUpdatedConfig = async function ({
|
|
|
184
187
|
return
|
|
185
188
|
}
|
|
186
189
|
|
|
190
|
+
const { restoreConfig } = await netlifyConfigPromise
|
|
187
191
|
await restoreConfig(configMutations, { buildDir, configPath, headersPath, redirectsPath })
|
|
188
192
|
}
|
|
189
193
|
|
package/src/core/main.js
CHANGED
|
@@ -595,7 +595,7 @@ const runBuild = async function ({
|
|
|
595
595
|
verbose,
|
|
596
596
|
})
|
|
597
597
|
|
|
598
|
-
const { steps, events } = getSteps(pluginsSteps)
|
|
598
|
+
const { steps, events } = await getSteps(pluginsSteps)
|
|
599
599
|
|
|
600
600
|
if (dry) {
|
|
601
601
|
await doDryRun({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs })
|
package/src/error/handle.js
CHANGED
|
@@ -26,7 +26,7 @@ const handleBuildError = async function (
|
|
|
26
26
|
removeErrorColors(error)
|
|
27
27
|
// Some errors, such as telemetry ones, should not be logged
|
|
28
28
|
if (basicErrorInfo.showInBuildLog) {
|
|
29
|
-
logBuildError({ error, netlifyConfig, mode, logs, debug, testOpts })
|
|
29
|
+
await logBuildError({ error, netlifyConfig, mode, logs, debug, testOpts })
|
|
30
30
|
}
|
|
31
31
|
logOldCliVersionError({ mode, testOpts })
|
|
32
32
|
await reportBuildError({ error, errorMonitor, childEnv, logs, testOpts })
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const { cleanupConfig } = require('@netlify/config')
|
|
4
|
-
|
|
5
3
|
const { DEFAULT_FEATURE_FLAGS } = require('../../core/feature_flags')
|
|
6
4
|
const { omit } = require('../../utils/omit')
|
|
7
5
|
const { logMessage, logObject, logSubHeader } = require('../logger')
|
|
8
6
|
const { THEME } = require('../theme')
|
|
9
7
|
|
|
8
|
+
const netlifyConfigPromise = import('@netlify/config')
|
|
9
|
+
|
|
10
10
|
const logFlags = function (logs, flags, { debug }) {
|
|
11
11
|
const flagsA = cleanFeatureFlags(flags)
|
|
12
12
|
const hiddenFlags = debug ? HIDDEN_DEBUG_FLAGS : HIDDEN_FLAGS
|
|
@@ -69,29 +69,32 @@ const logConfigPath = function (logs, configPath = NO_CONFIG_MESSAGE) {
|
|
|
69
69
|
|
|
70
70
|
const NO_CONFIG_MESSAGE = 'No config file was defined: using default values.'
|
|
71
71
|
|
|
72
|
-
const logConfig = function ({ logs, netlifyConfig, debug }) {
|
|
72
|
+
const logConfig = async function ({ logs, netlifyConfig, debug }) {
|
|
73
73
|
if (!debug) {
|
|
74
74
|
return
|
|
75
75
|
}
|
|
76
76
|
|
|
77
|
+
const { cleanupConfig } = await netlifyConfigPromise
|
|
77
78
|
logSubHeader(logs, 'Resolved config')
|
|
78
79
|
logObject(logs, cleanupConfig(netlifyConfig))
|
|
79
80
|
}
|
|
80
81
|
|
|
81
|
-
const logConfigOnUpdate = function ({ logs, netlifyConfig, debug }) {
|
|
82
|
+
const logConfigOnUpdate = async function ({ logs, netlifyConfig, debug }) {
|
|
82
83
|
if (!debug) {
|
|
83
84
|
return
|
|
84
85
|
}
|
|
85
86
|
|
|
87
|
+
const { cleanupConfig } = await netlifyConfigPromise
|
|
86
88
|
logSubHeader(logs, 'Updated config')
|
|
87
89
|
logObject(logs, cleanupConfig(netlifyConfig))
|
|
88
90
|
}
|
|
89
91
|
|
|
90
|
-
const logConfigOnError = function ({ logs, netlifyConfig, severity }) {
|
|
92
|
+
const logConfigOnError = async function ({ logs, netlifyConfig, severity }) {
|
|
91
93
|
if (netlifyConfig === undefined || severity === 'none') {
|
|
92
94
|
return
|
|
93
95
|
}
|
|
94
96
|
|
|
97
|
+
const { cleanupConfig } = await netlifyConfigPromise
|
|
95
98
|
logMessage(logs, THEME.errorSubHeader('Resolved config'))
|
|
96
99
|
logObject(logs, cleanupConfig(netlifyConfig))
|
|
97
100
|
}
|
package/src/log/messages/core.js
CHANGED
|
@@ -20,14 +20,14 @@ const logBuildStart = function (logs) {
|
|
|
20
20
|
logMessage(logs, `${name} ${version}`)
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
const logBuildError = function ({ error, netlifyConfig, mode, logs, debug, testOpts }) {
|
|
23
|
+
const logBuildError = async function ({ error, netlifyConfig, mode, logs, debug, testOpts }) {
|
|
24
24
|
const fullErrorInfo = getFullErrorInfo({ error, colors: true, debug })
|
|
25
25
|
const { severity } = fullErrorInfo
|
|
26
26
|
const { title, body } = serializeLogError({ fullErrorInfo })
|
|
27
27
|
const logHeaderFunc = getLogHeaderFunc(error)
|
|
28
28
|
logHeaderFunc(logs, title)
|
|
29
29
|
logMessage(logs, `\n${body}\n`)
|
|
30
|
-
logConfigOnError({ logs, netlifyConfig, severity })
|
|
30
|
+
await logConfigOnError({ logs, netlifyConfig, severity })
|
|
31
31
|
logOldCliVersionError({ mode, testOpts })
|
|
32
32
|
}
|
|
33
33
|
|
|
@@ -15,7 +15,7 @@ const load = async function ({ pluginPath, inputs, packageJson, verbose }) {
|
|
|
15
15
|
const tsNodeService = registerTypeScript(pluginPath)
|
|
16
16
|
const logic = await getLogic({ pluginPath, inputs, tsNodeService })
|
|
17
17
|
|
|
18
|
-
validatePlugin(logic)
|
|
18
|
+
await validatePlugin(logic)
|
|
19
19
|
|
|
20
20
|
const methods = filterObj(logic, isEventHandler)
|
|
21
21
|
const events = Object.keys(methods)
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
const { addErrorInfo } = require('../../error/info')
|
|
4
4
|
const { serializeArray } = require('../../log/serialize')
|
|
5
|
-
const {
|
|
5
|
+
const { listEvents } = require('../events')
|
|
6
6
|
|
|
7
7
|
// Validate the shape of a plugin return value
|
|
8
|
-
const validatePlugin = function (logic) {
|
|
8
|
+
const validatePlugin = async function (logic) {
|
|
9
9
|
try {
|
|
10
10
|
// This validation must work with the return value of `import()` which has
|
|
11
11
|
// a `Module` prototype, not `Object`
|
|
@@ -13,8 +13,9 @@ const validatePlugin = function (logic) {
|
|
|
13
13
|
throw new Error('Plugin must be an object or a function')
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
const EVENTS = await listEvents()
|
|
16
17
|
Object.entries(logic).forEach(([propName, value]) => {
|
|
17
|
-
validateEventHandler(value, propName)
|
|
18
|
+
validateEventHandler(value, propName, EVENTS)
|
|
18
19
|
})
|
|
19
20
|
} catch (error) {
|
|
20
21
|
addErrorInfo(error, { type: 'pluginValidation' })
|
|
@@ -23,7 +24,7 @@ const validatePlugin = function (logic) {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
// All other properties are event handlers
|
|
26
|
-
const validateEventHandler = function (value, propName) {
|
|
27
|
+
const validateEventHandler = function (value, propName, EVENTS) {
|
|
27
28
|
if (!EVENTS.includes(propName)) {
|
|
28
29
|
throw new Error(`Invalid event '${propName}'.
|
|
29
30
|
Please use a valid event name. One of:
|
package/src/plugins/events.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const netlifyConfigPromise = import('@netlify/config')
|
|
4
|
+
|
|
5
|
+
const listEvents = async function () {
|
|
6
|
+
const { EVENTS } = await netlifyConfigPromise
|
|
7
|
+
return EVENTS
|
|
8
|
+
}
|
|
4
9
|
|
|
5
10
|
const isAmongEvents = function (events, event) {
|
|
6
11
|
return events.includes(event)
|
|
@@ -19,7 +24,7 @@ const runsOnlyOnBuildFailure = isAmongEvents.bind(null, ['onError'])
|
|
|
19
24
|
const runsAfterDeploy = isAmongEvents.bind(null, ['onSuccess', 'onEnd'])
|
|
20
25
|
|
|
21
26
|
module.exports = {
|
|
22
|
-
|
|
27
|
+
listEvents,
|
|
23
28
|
isSoftFailEvent,
|
|
24
29
|
runsAlsoOnBuildFailure,
|
|
25
30
|
runsOnlyOnBuildFailure,
|
package/src/steps/get.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
const {
|
|
3
|
+
const { listEvents } = require('../plugins/events')
|
|
4
4
|
const { buildCommandCore } = require('../plugins_core/build_command')
|
|
5
5
|
const { deploySite } = require('../plugins_core/deploy')
|
|
6
6
|
const { bundleFunctions } = require('../plugins_core/functions')
|
|
7
7
|
|
|
8
8
|
// Get all build steps
|
|
9
|
-
const getSteps = function (steps) {
|
|
9
|
+
const getSteps = async function (steps) {
|
|
10
10
|
const stepsA = addCoreSteps(steps)
|
|
11
|
-
const stepsB = sortSteps(stepsA)
|
|
11
|
+
const stepsB = await sortSteps(stepsA)
|
|
12
12
|
const events = getEvents(stepsB)
|
|
13
13
|
return { steps: stepsB, events }
|
|
14
14
|
}
|
|
@@ -18,7 +18,8 @@ const addCoreSteps = function (steps) {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
// Sort plugin steps by event order.
|
|
21
|
-
const sortSteps = function (steps) {
|
|
21
|
+
const sortSteps = async function (steps) {
|
|
22
|
+
const EVENTS = await listEvents()
|
|
22
23
|
return EVENTS.flatMap((event) => steps.filter((step) => step.event === event))
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -36,7 +36,7 @@ const updateNetlifyConfig = async function ({
|
|
|
36
36
|
headersPath: headersPathA,
|
|
37
37
|
redirectsPath: redirectsPathA,
|
|
38
38
|
} = await resolveUpdatedConfig(configOpts, configMutationsA)
|
|
39
|
-
logConfigOnUpdate({ logs, netlifyConfig: netlifyConfigA, debug })
|
|
39
|
+
await logConfigOnUpdate({ logs, netlifyConfig: netlifyConfigA, debug })
|
|
40
40
|
// eslint-disable-next-line fp/no-mutation,no-param-reassign
|
|
41
41
|
errorParams.netlifyConfig = netlifyConfigA
|
|
42
42
|
return {
|