@netlify/build 18.8.0-rc → 18.9.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/package.json +4 -4
- package/src/commands/run_command.js +3 -3
- package/src/core/config.js +14 -14
- package/src/core/constants.js +0 -12
- package/src/core/feature_flags.js +1 -1
- package/src/core/flags.js +1 -7
- package/src/core/main.js +5 -1
- package/src/core/missing_side_file.js +38 -0
- package/src/core/normalize_flags.js +0 -2
- package/src/log/messages/config.js +0 -1
- package/src/log/messages/core.js +9 -0
- package/src/plugins/list.js +1 -1
- package/src/telemetry/main.js +1 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.9.1",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"main": "src/core/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -57,9 +57,9 @@
|
|
|
57
57
|
"@netlify/functions-utils": "^2.0.0",
|
|
58
58
|
"@netlify/git-utils": "^2.0.0",
|
|
59
59
|
"@netlify/plugin-edge-handlers": "^1.11.22",
|
|
60
|
-
"@netlify/plugins-list": "^3.
|
|
60
|
+
"@netlify/plugins-list": "^3.6.0",
|
|
61
61
|
"@netlify/run-utils": "^2.0.0",
|
|
62
|
-
"@netlify/zip-it-and-ship-it": "4.21.0
|
|
62
|
+
"@netlify/zip-it-and-ship-it": "^4.21.0",
|
|
63
63
|
"@sindresorhus/slugify": "^1.1.0",
|
|
64
64
|
"@ungap/from-entries": "^0.2.1",
|
|
65
65
|
"ansi-escapes": "^4.3.2",
|
|
@@ -69,7 +69,7 @@
|
|
|
69
69
|
"execa": "^5.1.1",
|
|
70
70
|
"figures": "^3.2.0",
|
|
71
71
|
"filter-obj": "^2.0.1",
|
|
72
|
-
"got": "^
|
|
72
|
+
"got": "^10.0.0",
|
|
73
73
|
"indent-string": "^4.0.0",
|
|
74
74
|
"is-plain-obj": "^3.0.0",
|
|
75
75
|
"js-yaml": "^4.0.0",
|
|
@@ -159,7 +159,7 @@ const runCommand = async function ({
|
|
|
159
159
|
//
|
|
160
160
|
// Otherwise, most failures will make the build fail. This includes:
|
|
161
161
|
// - the build command failed
|
|
162
|
-
// - Functions
|
|
162
|
+
// - Functions or Edge handlers bundling failed
|
|
163
163
|
// - the deploy failed (deploying files to our CDN)
|
|
164
164
|
// - a plugin `onPreBuild`, `onBuild` or `onPostBuild` event handler failed.
|
|
165
165
|
// This includes uncaught exceptions and using `utils.build.failBuild()`
|
|
@@ -173,8 +173,8 @@ const runCommand = async function ({
|
|
|
173
173
|
//
|
|
174
174
|
// Finally, some plugins (only core plugins for the moment) might be enabled or
|
|
175
175
|
// not depending on whether a specific action is happening during the build,
|
|
176
|
-
// such as creating a file. For example, the Functions
|
|
177
|
-
// plugins are disabled if no Functions
|
|
176
|
+
// such as creating a file. For example, the Functions and Edge handlers core
|
|
177
|
+
// plugins are disabled if no Functions or Edge handlers directory is specified
|
|
178
178
|
// or available. However, one might be created by a build plugin, in which case,
|
|
179
179
|
// those core plugins should be triggered. We use a dynamic `condition()` to
|
|
180
180
|
// model this behavior.
|
package/src/core/config.js
CHANGED
|
@@ -111,13 +111,7 @@ const resolveInitialConfig = async function (configOpts, cachedConfig, cachedCon
|
|
|
111
111
|
try {
|
|
112
112
|
return await resolveConfig({ ...configOpts, cachedConfig, cachedConfigPath })
|
|
113
113
|
} catch (error) {
|
|
114
|
-
|
|
115
|
-
// We need to mutate the `error` directly to preserve its `name`, `stack`, etc.
|
|
116
|
-
// eslint-disable-next-line fp/no-delete
|
|
117
|
-
delete error.type
|
|
118
|
-
addErrorInfo(error, { type: 'resolveConfig' })
|
|
119
|
-
}
|
|
120
|
-
throw error
|
|
114
|
+
throw getConfigError(error, 'resolveConfig')
|
|
121
115
|
}
|
|
122
116
|
}
|
|
123
117
|
|
|
@@ -139,16 +133,22 @@ const resolveUpdatedConfig = async function (configOpts, configMutations) {
|
|
|
139
133
|
try {
|
|
140
134
|
return await resolveConfig({ ...configOpts, configMutations, debug: false })
|
|
141
135
|
} catch (error) {
|
|
142
|
-
|
|
143
|
-
// We need to mutate the `error` directly to preserve its `name`, `stack`, etc.
|
|
144
|
-
// eslint-disable-next-line fp/no-delete
|
|
145
|
-
delete error.type
|
|
146
|
-
addErrorInfo(error, { type: 'pluginValidation' })
|
|
147
|
-
}
|
|
148
|
-
throw error
|
|
136
|
+
throw getConfigError(error, 'pluginValidation')
|
|
149
137
|
}
|
|
150
138
|
}
|
|
151
139
|
|
|
140
|
+
const getConfigError = function (error, type) {
|
|
141
|
+
if (error.type !== 'userError') {
|
|
142
|
+
return error
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
// We need to mutate the `error` directly to preserve its `name`, `stack`, etc.
|
|
146
|
+
// eslint-disable-next-line fp/no-delete
|
|
147
|
+
delete error.type
|
|
148
|
+
addErrorInfo(error, { type })
|
|
149
|
+
return error
|
|
150
|
+
}
|
|
151
|
+
|
|
152
152
|
// If the configuration was changed, persist it to `netlify.toml`.
|
|
153
153
|
// If `netlify.toml` does not exist, create it inside repository root.
|
|
154
154
|
// This is only done when `saveConfig` is `true`. This allows performing this
|
package/src/core/constants.js
CHANGED
|
@@ -43,16 +43,12 @@ const getConstants = async function ({
|
|
|
43
43
|
// The directory where internal functions (i.e. generated programmatically
|
|
44
44
|
// via plugins or others) live
|
|
45
45
|
INTERNAL_FUNCTIONS_SRC: `${buildDir}/${INTERNAL_FUNCTIONS_SRC}`,
|
|
46
|
-
// The directory where internal builders (i.e. generated programmatically
|
|
47
|
-
// via plugins or others) live
|
|
48
|
-
INTERNAL_BUILDERS_SRC: `${buildDir}/${INTERNAL_BUILDERS_SRC}`,
|
|
49
46
|
}
|
|
50
47
|
const constantsA = await addMutableConstants({ constants, buildDir, netlifyConfig })
|
|
51
48
|
return constantsA
|
|
52
49
|
}
|
|
53
50
|
|
|
54
51
|
const INTERNAL_FUNCTIONS_SRC = '.netlify/functions-internal'
|
|
55
|
-
const INTERNAL_BUILDERS_SRC = '.netlify/builders-internal'
|
|
56
52
|
|
|
57
53
|
// Retrieve constants which might change during the build if a plugin modifies
|
|
58
54
|
// `netlifyConfig` or creates some default directories.
|
|
@@ -63,9 +59,6 @@ const addMutableConstants = async function ({
|
|
|
63
59
|
netlifyConfig: {
|
|
64
60
|
build: { publish, edge_handlers: edgeHandlers },
|
|
65
61
|
functionsDirectory,
|
|
66
|
-
builders: {
|
|
67
|
-
'*': { directory: buildersDirectory },
|
|
68
|
-
},
|
|
69
62
|
},
|
|
70
63
|
}) {
|
|
71
64
|
const constantsA = {
|
|
@@ -74,8 +67,6 @@ const addMutableConstants = async function ({
|
|
|
74
67
|
PUBLISH_DIR: publish,
|
|
75
68
|
// The directory where function source code lives
|
|
76
69
|
FUNCTIONS_SRC: functionsDirectory,
|
|
77
|
-
// The directory where builders source code lives
|
|
78
|
-
BUILDERS_SRC: buildersDirectory,
|
|
79
70
|
// The directory where edge handlers source code lives
|
|
80
71
|
EDGE_HANDLERS_SRC: edgeHandlers,
|
|
81
72
|
}
|
|
@@ -104,7 +95,6 @@ const DEFAULT_PATHS = [
|
|
|
104
95
|
// @todo Remove once we drop support for the legacy default functions directory.
|
|
105
96
|
{ constantName: 'FUNCTIONS_SRC', defaultPath: 'netlify-automatic-functions' },
|
|
106
97
|
{ constantName: 'FUNCTIONS_SRC', defaultPath: 'netlify/functions' },
|
|
107
|
-
{ constantName: 'BUILDERS_SRC', defaultPath: 'netlify/builders' },
|
|
108
98
|
{ constantName: 'EDGE_HANDLERS_SRC', defaultPath: 'netlify/edge-handlers' },
|
|
109
99
|
]
|
|
110
100
|
|
|
@@ -154,8 +144,6 @@ const CONSTANT_PATHS = new Set([
|
|
|
154
144
|
'FUNCTIONS_SRC',
|
|
155
145
|
'FUNCTIONS_DIST',
|
|
156
146
|
'INTERNAL_FUNCTIONS_SRC',
|
|
157
|
-
'BUILDERS_SRC',
|
|
158
|
-
'INTERNAL_BUILDERS_SRC',
|
|
159
147
|
'EDGE_HANDLERS_SRC',
|
|
160
148
|
'CACHE_DIR',
|
|
161
149
|
])
|
|
@@ -18,7 +18,7 @@ const getFeatureFlag = function (name) {
|
|
|
18
18
|
// Default values for feature flags
|
|
19
19
|
const DEFAULT_FEATURE_FLAGS = {
|
|
20
20
|
zisiEsbuildDynamicImports: env.NETLIFY_EXPERIMENTAL_PROCESS_DYNAMIC_IMPORTS === 'true',
|
|
21
|
-
|
|
21
|
+
netlify_build_warning_missing_headers: false,
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
module.exports = { normalizeCliFeatureFlags, DEFAULT_FEATURE_FLAGS }
|
package/src/core/flags.js
CHANGED
|
@@ -104,13 +104,7 @@ Default: Current Node.js binary`,
|
|
|
104
104
|
},
|
|
105
105
|
functionsDistDir: {
|
|
106
106
|
string: true,
|
|
107
|
-
describe: `Path to the directory where packaged
|
|
108
|
-
Default: automatically guessed`,
|
|
109
|
-
hidden: true,
|
|
110
|
-
},
|
|
111
|
-
buildersDistDir: {
|
|
112
|
-
string: true,
|
|
113
|
-
describe: `Path to the directory where packaged builders functions are kept.
|
|
107
|
+
describe: `Path to the directory where packaged functions are kept.
|
|
114
108
|
Default: automatically guessed`,
|
|
115
109
|
hidden: true,
|
|
116
110
|
},
|
package/src/core/main.js
CHANGED
|
@@ -24,6 +24,7 @@ const { getConfigOpts, loadConfig } = require('./config')
|
|
|
24
24
|
const { getConstants } = require('./constants')
|
|
25
25
|
const { doDryRun } = require('./dry')
|
|
26
26
|
const { warnOnLingeringProcesses } = require('./lingering')
|
|
27
|
+
const { warnOnMissingSideFiles } = require('./missing_side_file')
|
|
27
28
|
const { normalizeFlags } = require('./normalize_flags')
|
|
28
29
|
const { getSeverity } = require('./severity')
|
|
29
30
|
|
|
@@ -528,7 +529,10 @@ const initAndRunBuild = async function ({
|
|
|
528
529
|
featureFlags,
|
|
529
530
|
})
|
|
530
531
|
|
|
531
|
-
await
|
|
532
|
+
await Promise.all([
|
|
533
|
+
warnOnMissingSideFiles({ buildDir, netlifyConfig: netlifyConfigA, logs, featureFlags }),
|
|
534
|
+
warnOnLingeringProcesses({ mode, logs, testOpts }),
|
|
535
|
+
])
|
|
532
536
|
|
|
533
537
|
return {
|
|
534
538
|
commandsCount,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { relative } = require('path')
|
|
4
|
+
|
|
5
|
+
const pathExists = require('path-exists')
|
|
6
|
+
|
|
7
|
+
const { logMissingSideFile } = require('../log/messages/core')
|
|
8
|
+
|
|
9
|
+
// Some files like `_headers` and `_redirects` must be copied to the publish
|
|
10
|
+
// directory to be used in production. When those are present in the repository
|
|
11
|
+
// but not in the publish directory, this most likely indicates that the build
|
|
12
|
+
// command accidentally forgot to copy those. We then print a warning message.
|
|
13
|
+
const warnOnMissingSideFiles = async function ({
|
|
14
|
+
buildDir,
|
|
15
|
+
netlifyConfig: {
|
|
16
|
+
build: { publish },
|
|
17
|
+
},
|
|
18
|
+
logs,
|
|
19
|
+
featureFlags,
|
|
20
|
+
}) {
|
|
21
|
+
if (!featureFlags.netlify_build_warning_missing_headers) {
|
|
22
|
+
return
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
await Promise.all(SIDE_FILES.map((sideFile) => warnOnMissingSideFile({ logs, sideFile, buildDir, publish })))
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const SIDE_FILES = ['_headers', '_redirects']
|
|
29
|
+
|
|
30
|
+
const warnOnMissingSideFile = async function ({ logs, sideFile, buildDir, publish }) {
|
|
31
|
+
if (!(await pathExists(`${buildDir}/${sideFile}`)) || (await pathExists(`${publish}/${sideFile}`))) {
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
logMissingSideFile(logs, sideFile, relative(buildDir, publish))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
module.exports = { warnOnMissingSideFiles }
|
|
@@ -42,7 +42,6 @@ const getDefaultFlags = function ({ env: envOpt = {} }, combinedEnv) {
|
|
|
42
42
|
offline: false,
|
|
43
43
|
telemetry: false,
|
|
44
44
|
functionsDistDir: DEFAULT_FUNCTIONS_DIST,
|
|
45
|
-
buildersDistDir: DEFAULT_BUILDERS_DIST,
|
|
46
45
|
cacheDir: DEFAULT_CACHE_DIR,
|
|
47
46
|
deployId: combinedEnv.DEPLOY_ID,
|
|
48
47
|
buildId: combinedEnv.BUILD_ID,
|
|
@@ -65,7 +64,6 @@ const computeTelemetry = function (flags, envOpts) {
|
|
|
65
64
|
|
|
66
65
|
const REQUIRE_MODE = 'require'
|
|
67
66
|
const DEFAULT_FUNCTIONS_DIST = '.netlify/functions/'
|
|
68
|
-
const DEFAULT_BUILDERS_DIST = '.netlify/builders/'
|
|
69
67
|
const DEFAULT_CACHE_DIR = '.netlify/cache/'
|
|
70
68
|
const DEFAULT_STATSD_PORT = 8125
|
|
71
69
|
|
package/src/log/messages/core.js
CHANGED
|
@@ -42,6 +42,14 @@ const logTimer = function (logs, durationNs, timerName) {
|
|
|
42
42
|
log(logs, THEME.dimWords(`(${timerName} completed in ${duration})`))
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
const logMissingSideFile = function (logs, sideFile, publish) {
|
|
46
|
+
logWarning(
|
|
47
|
+
logs,
|
|
48
|
+
`
|
|
49
|
+
A "${sideFile}" file is present in the repository but is missing in the publish directory "${publish}".`,
|
|
50
|
+
)
|
|
51
|
+
}
|
|
52
|
+
|
|
45
53
|
// @todo use `terminal-link` (https://github.com/sindresorhus/terminal-link)
|
|
46
54
|
// instead of `ansi-escapes` once
|
|
47
55
|
// https://github.com/jamestalmage/supports-hyperlinks/pull/12 is fixed
|
|
@@ -68,5 +76,6 @@ module.exports = {
|
|
|
68
76
|
logBuildError,
|
|
69
77
|
logBuildSuccess,
|
|
70
78
|
logTimer,
|
|
79
|
+
logMissingSideFile,
|
|
71
80
|
logLingeringProcesses,
|
|
72
81
|
}
|
package/src/plugins/list.js
CHANGED
|
@@ -33,7 +33,7 @@ const getPluginsList = async function ({ debug, logs, testOpts: { pluginsListUrl
|
|
|
33
33
|
|
|
34
34
|
const fetchPluginsList = async function ({ logs, pluginsListUrl }) {
|
|
35
35
|
try {
|
|
36
|
-
const { body } = await got(pluginsListUrl, {
|
|
36
|
+
const { body } = await got(pluginsListUrl, { responseType: 'json', timeout: PLUGINS_LIST_TIMEOUT })
|
|
37
37
|
|
|
38
38
|
if (!isValidPluginsList(body)) {
|
|
39
39
|
throw new Error(`Request succeeded but with an invalid response:\n${JSON.stringify(body, null, 2)}`)
|
package/src/telemetry/main.js
CHANGED
|
@@ -60,8 +60,7 @@ const trackBuildComplete = async function ({
|
|
|
60
60
|
const track = async function ({ payload, config: { origin, writeKey, timeout } }) {
|
|
61
61
|
const url = `${origin}/track`
|
|
62
62
|
await got.post(url, {
|
|
63
|
-
json:
|
|
64
|
-
body: payload,
|
|
63
|
+
json: payload,
|
|
65
64
|
timeout,
|
|
66
65
|
retry: 0,
|
|
67
66
|
headers: { Authorization: `Basic ${writeKey}` },
|