@netlify/build 25.0.2 → 26.0.2
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 +5 -3
- package/src/core/bin.js +7 -8
- package/src/core/config.js +18 -35
- package/src/core/constants.js +8 -14
- package/src/core/dry.js +4 -8
- package/src/core/feature_flags.js +2 -6
- package/src/core/flags.js +2 -6
- package/src/core/lingering.js +7 -7
- package/src/core/main.js +25 -29
- package/src/core/missing_side_file.js +4 -8
- package/src/core/normalize_flags.js +5 -9
- package/src/core/severity.js +2 -6
- package/src/core/user_node_version.js +7 -11
- package/src/env/changes.js +5 -9
- package/src/env/main.js +4 -8
- package/src/env/metadata.js +3 -7
- package/src/error/api.js +4 -8
- package/src/error/build.js +4 -8
- package/src/error/cancel.js +1 -5
- package/src/error/colors.js +2 -6
- package/src/error/handle.js +10 -14
- package/src/error/info.js +6 -10
- package/src/error/monitor/location.js +1 -5
- package/src/error/monitor/normalize.js +2 -6
- package/src/error/monitor/print.js +2 -8
- package/src/error/monitor/report.js +11 -15
- package/src/error/monitor/start.js +9 -11
- package/src/error/parse/clean_stack.js +4 -8
- package/src/error/parse/location.js +2 -6
- package/src/error/parse/normalize.js +1 -5
- package/src/error/parse/parse.js +10 -14
- package/src/error/parse/plugin.js +2 -6
- package/src/error/parse/properties.js +3 -7
- package/src/error/parse/serialize_log.js +2 -6
- package/src/error/parse/serialize_status.js +1 -5
- package/src/error/parse/stack.js +2 -6
- package/src/error/type.js +1 -5
- package/src/install/functions.js +5 -9
- package/src/install/local.js +5 -9
- package/src/install/main.js +6 -10
- package/src/install/missing.js +9 -13
- package/src/log/colors.js +5 -11
- package/src/log/description.js +2 -6
- package/src/log/header.js +2 -6
- package/src/log/header_func.js +3 -7
- package/src/log/logger.js +20 -40
- package/src/log/messages/compatibility.js +9 -18
- package/src/log/messages/config.js +12 -27
- package/src/log/messages/core.js +20 -31
- package/src/log/messages/core_steps.js +7 -15
- package/src/log/messages/dry.js +7 -15
- package/src/log/messages/install.js +4 -12
- package/src/log/messages/ipc.js +8 -20
- package/src/log/messages/mutations.js +8 -17
- package/src/log/messages/plugins.js +5 -14
- package/src/log/messages/status.js +3 -9
- package/src/log/messages/steps.js +6 -14
- package/src/log/old_version.js +6 -10
- package/src/log/serialize.js +3 -7
- package/src/log/stream.js +6 -15
- package/src/log/theme.js +14 -29
- package/src/plugins/child/diff.js +5 -9
- package/src/plugins/child/error.js +7 -11
- package/src/plugins/child/lazy.js +2 -6
- package/src/plugins/child/load.js +6 -10
- package/src/plugins/child/logic.js +6 -7
- package/src/plugins/child/main.js +5 -7
- package/src/plugins/child/run.js +6 -10
- package/src/plugins/child/status.js +4 -8
- package/src/plugins/child/typescript.js +5 -9
- package/src/plugins/child/utils.js +21 -27
- package/src/plugins/child/validate.js +6 -11
- package/src/plugins/compatibility.js +13 -16
- package/src/plugins/error.js +6 -15
- package/src/plugins/events.js +5 -20
- package/src/plugins/expected_version.js +9 -13
- package/src/plugins/ipc.js +12 -21
- package/src/plugins/list.js +6 -15
- package/src/plugins/load.js +13 -9
- package/src/plugins/manifest/check.js +4 -8
- package/src/plugins/manifest/load.js +6 -10
- package/src/plugins/manifest/main.js +5 -9
- package/src/plugins/manifest/path.js +3 -7
- package/src/plugins/manifest/validate.js +3 -7
- package/src/plugins/node_version.js +9 -15
- package/src/plugins/options.js +12 -17
- package/src/plugins/pinned_version.js +4 -8
- package/src/plugins/resolve.js +7 -11
- package/src/plugins/spawn.js +10 -12
- package/src/plugins_core/add.js +2 -6
- package/src/plugins_core/build_command.js +7 -11
- package/src/plugins_core/deploy/buildbot_client.js +11 -20
- package/src/plugins_core/deploy/index.js +5 -9
- package/src/plugins_core/functions/error.js +4 -8
- package/src/plugins_core/functions/feature_flags.js +1 -5
- package/src/plugins_core/functions/index.js +20 -14
- package/src/plugins_core/functions/utils.js +9 -13
- package/src/plugins_core/functions_install/index.js +3 -7
- package/src/plugins_core/list.js +10 -7
- package/src/status/add.js +1 -5
- package/src/status/colors.js +2 -6
- package/src/status/load_error.js +4 -8
- package/src/status/report.js +4 -8
- package/src/status/success.js +2 -6
- package/src/steps/core_step.js +4 -8
- package/src/steps/error.js +7 -11
- package/src/steps/get.js +7 -12
- package/src/steps/plugin.js +8 -12
- package/src/steps/return.js +4 -8
- package/src/steps/run_step.js +8 -12
- package/src/steps/run_steps.js +5 -9
- package/src/steps/update_config.js +10 -14
- package/src/telemetry/main.js +8 -12
- package/src/time/aggregate.js +2 -6
- package/src/time/main.js +8 -12
- package/src/time/measure.js +4 -8
- package/src/time/report.js +5 -9
- package/src/utils/errors.js +1 -5
- package/src/utils/json.js +19 -0
- package/src/utils/omit.js +2 -6
- package/src/utils/package.js +3 -7
- package/src/utils/remove_falsy.js +2 -6
- package/src/utils/resolve.js +8 -6
- package/src/utils/semver.js +9 -13
- package/types/config/functions.d.ts +1 -1
package/package.json
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "26.0.2",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
|
-
"
|
|
5
|
+
"type": "module",
|
|
6
|
+
"exports": "./src/core/main.js",
|
|
7
|
+
"main": "./src/core/main.js",
|
|
6
8
|
"types": "types/index.d.ts",
|
|
7
9
|
"bin": {
|
|
8
10
|
"netlify-build": "./src/core/bin.js"
|
|
@@ -61,7 +63,7 @@
|
|
|
61
63
|
"@netlify/plugin-edge-handlers": "^3.0.0",
|
|
62
64
|
"@netlify/plugins-list": "^6.2.0",
|
|
63
65
|
"@netlify/run-utils": "^4.0.0",
|
|
64
|
-
"@netlify/zip-it-and-ship-it": "^5.
|
|
66
|
+
"@netlify/zip-it-and-ship-it": "^5.4.0",
|
|
65
67
|
"@sindresorhus/slugify": "^1.1.0",
|
|
66
68
|
"ansi-escapes": "^4.3.2",
|
|
67
69
|
"chalk": "^4.1.2",
|
package/src/core/bin.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
'use strict'
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
import process from 'process'
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
import filterObj from 'filter-obj'
|
|
6
|
+
import yargs from 'yargs'
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
import { normalizeCliFeatureFlags } from './feature_flags.js'
|
|
9
|
+
import { FLAGS } from './flags.js'
|
|
10
|
+
import build from './main.js'
|
|
11
|
+
import { FALLBACK_SEVERITY_ENTRY } from './severity.js'
|
|
13
12
|
|
|
14
13
|
// CLI entry point.
|
|
15
14
|
// Before adding logic to this file, please consider adding it to the main
|
package/src/core/config.js
CHANGED
|
@@ -1,19 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { resolveConfig, updateConfig, restoreConfig } from '@netlify/config'
|
|
2
|
+
import mapObj from 'map-obj'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { getChildEnv } from '../env/main.js'
|
|
5
|
+
import { addApiErrorHandlers } from '../error/api.js'
|
|
6
|
+
import { changeErrorType } from '../error/info.js'
|
|
7
|
+
import { logBuildDir, logConfigPath, logConfig, logContext } from '../log/messages/config.js'
|
|
8
|
+
import { logConfigOnUpload, logHeadersOnUpload, logRedirectsOnUpload } from '../log/messages/mutations.js'
|
|
9
|
+
import { measureDuration } from '../time/main.js'
|
|
10
|
+
import { getPackageJson } from '../utils/package.js'
|
|
5
11
|
|
|
6
|
-
|
|
7
|
-
const { addApiErrorHandlers } = require('../error/api')
|
|
8
|
-
const { changeErrorType } = require('../error/info')
|
|
9
|
-
const { logBuildDir, logConfigPath, logConfig, logContext } = require('../log/messages/config')
|
|
10
|
-
const { logConfigOnUpload, logHeadersOnUpload, logRedirectsOnUpload } = require('../log/messages/mutations')
|
|
11
|
-
const { measureDuration } = require('../time/main')
|
|
12
|
-
const { getPackageJson } = require('../utils/package')
|
|
13
|
-
|
|
14
|
-
const { getUserNodeVersion } = require('./user_node_version')
|
|
15
|
-
|
|
16
|
-
const netlifyConfigPromise = import('@netlify/config')
|
|
12
|
+
import { getUserNodeVersion } from './user_node_version.js'
|
|
17
13
|
|
|
18
14
|
// Retrieve immutable options passed to `@netlify/config`.
|
|
19
15
|
// This does not include options which might change during the course of the
|
|
@@ -22,7 +18,7 @@ const netlifyConfigPromise = import('@netlify/config')
|
|
|
22
18
|
// the build
|
|
23
19
|
// - If plugins change the configuration, `configMutations` is used instead
|
|
24
20
|
// In both cases, almost all options should remain the same.
|
|
25
|
-
const getConfigOpts = function ({
|
|
21
|
+
export const getConfigOpts = function ({
|
|
26
22
|
config,
|
|
27
23
|
defaultConfig,
|
|
28
24
|
cwd,
|
|
@@ -78,7 +74,7 @@ const tLoadConfig = async function ({ configOpts, cachedConfig, cachedConfigPath
|
|
|
78
74
|
siteInfo,
|
|
79
75
|
env,
|
|
80
76
|
} = await resolveInitialConfig(configOpts, cachedConfig, cachedConfigPath)
|
|
81
|
-
|
|
77
|
+
logConfigInfo({ logs, configPath, buildDir, netlifyConfig, context: contextA, debug })
|
|
82
78
|
|
|
83
79
|
const apiA = addApiErrorHandlers(api)
|
|
84
80
|
const envValues = mapObj(env, (key, { value }) => [key, value])
|
|
@@ -102,20 +98,19 @@ const tLoadConfig = async function ({ configOpts, cachedConfig, cachedConfigPath
|
|
|
102
98
|
}
|
|
103
99
|
}
|
|
104
100
|
|
|
105
|
-
const loadConfig = measureDuration(tLoadConfig, 'resolve_config')
|
|
101
|
+
export const loadConfig = measureDuration(tLoadConfig, 'resolve_config')
|
|
106
102
|
|
|
107
103
|
// Retrieve initial configuration.
|
|
108
104
|
// In the buildbot and CLI, we re-use the already parsed `@netlify/config`
|
|
109
105
|
// return value which is passed as `cachedConfig`/`cachedConfigPath`.
|
|
110
106
|
const resolveInitialConfig = async function (configOpts, cachedConfig, cachedConfigPath) {
|
|
111
|
-
const { resolveConfig } = await netlifyConfigPromise
|
|
112
107
|
return await resolveConfig({ ...configOpts, cachedConfig, cachedConfigPath })
|
|
113
108
|
}
|
|
114
109
|
|
|
115
|
-
const logConfigInfo =
|
|
110
|
+
const logConfigInfo = function ({ logs, configPath, buildDir, netlifyConfig, context, debug }) {
|
|
116
111
|
logBuildDir(logs, buildDir)
|
|
117
112
|
logConfigPath(logs, configPath)
|
|
118
|
-
|
|
113
|
+
logConfig({ logs, netlifyConfig, debug })
|
|
119
114
|
logContext(logs, context)
|
|
120
115
|
}
|
|
121
116
|
|
|
@@ -126,8 +121,7 @@ const logConfigInfo = async function ({ logs, configPath, buildDir, netlifyConfi
|
|
|
126
121
|
// change would create debug logs which would be too verbose.
|
|
127
122
|
// Errors are propagated and assigned to the specific plugin or core step
|
|
128
123
|
// which changed the configuration.
|
|
129
|
-
const resolveUpdatedConfig = async function (configOpts, configMutations) {
|
|
130
|
-
const { resolveConfig } = await netlifyConfigPromise
|
|
124
|
+
export const resolveUpdatedConfig = async function (configOpts, configMutations) {
|
|
131
125
|
try {
|
|
132
126
|
return await resolveConfig({ ...configOpts, configMutations, debug: false })
|
|
133
127
|
} catch (error) {
|
|
@@ -141,7 +135,7 @@ const resolveUpdatedConfig = async function (configOpts, configMutations) {
|
|
|
141
135
|
// This is only done when `saveConfig` is `true`. This allows performing this
|
|
142
136
|
// in the buildbot but not in local builds, since only the latter run in a
|
|
143
137
|
// container and we want to avoid saving files on local machines.
|
|
144
|
-
const saveUpdatedConfig = async function ({
|
|
138
|
+
export const saveUpdatedConfig = async function ({
|
|
145
139
|
configMutations,
|
|
146
140
|
buildDir,
|
|
147
141
|
repositoryRoot,
|
|
@@ -158,7 +152,6 @@ const saveUpdatedConfig = async function ({
|
|
|
158
152
|
return
|
|
159
153
|
}
|
|
160
154
|
|
|
161
|
-
const { updateConfig } = await netlifyConfigPromise
|
|
162
155
|
await updateConfig(configMutations, {
|
|
163
156
|
buildDir,
|
|
164
157
|
configPath,
|
|
@@ -174,7 +167,7 @@ const saveUpdatedConfig = async function ({
|
|
|
174
167
|
await logRedirectsOnUpload({ logs, redirectsPath, debug })
|
|
175
168
|
}
|
|
176
169
|
|
|
177
|
-
const restoreUpdatedConfig = async function ({
|
|
170
|
+
export const restoreUpdatedConfig = async function ({
|
|
178
171
|
configMutations,
|
|
179
172
|
buildDir,
|
|
180
173
|
repositoryRoot,
|
|
@@ -187,15 +180,5 @@ const restoreUpdatedConfig = async function ({
|
|
|
187
180
|
return
|
|
188
181
|
}
|
|
189
182
|
|
|
190
|
-
const { restoreConfig } = await netlifyConfigPromise
|
|
191
183
|
await restoreConfig(configMutations, { buildDir, configPath, headersPath, redirectsPath })
|
|
192
184
|
}
|
|
193
|
-
|
|
194
|
-
module.exports = {
|
|
195
|
-
getConfigOpts,
|
|
196
|
-
loadConfig,
|
|
197
|
-
resolveUpdatedConfig,
|
|
198
|
-
saveUpdatedConfig,
|
|
199
|
-
restoreUpdatedConfig,
|
|
200
|
-
}
|
|
201
|
-
/* eslint-enable max-lines */
|
package/src/core/constants.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { relative, normalize } from 'path'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { getCacheDir } from '@netlify/cache-utils'
|
|
4
|
+
import mapObj from 'map-obj'
|
|
5
|
+
import pathExists from 'path-exists'
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
const pathExists = require('path-exists')
|
|
7
|
-
|
|
8
|
-
const { version } = require('../../package.json')
|
|
9
|
-
|
|
10
|
-
const cacheUtilsPromise = import('@netlify/cache-utils')
|
|
7
|
+
import { ROOT_PACKAGE_JSON } from '../utils/json.js'
|
|
11
8
|
|
|
12
9
|
// Retrieve constants passed to plugins
|
|
13
|
-
const getConstants = async function ({
|
|
10
|
+
export const getConstants = async function ({
|
|
14
11
|
configPath,
|
|
15
12
|
buildDir,
|
|
16
13
|
functionsDistDir,
|
|
@@ -22,7 +19,6 @@ const getConstants = async function ({
|
|
|
22
19
|
mode,
|
|
23
20
|
}) {
|
|
24
21
|
const isLocal = mode !== 'buildbot'
|
|
25
|
-
const { getCacheDir } = await cacheUtilsPromise
|
|
26
22
|
const normalizedCacheDir = getCacheDir({ cacheDir, cwd: buildDir })
|
|
27
23
|
|
|
28
24
|
const constants = {
|
|
@@ -35,7 +31,7 @@ const getConstants = async function ({
|
|
|
35
31
|
// Boolean indicating whether the build was run locally (Netlify CLI) or in the production CI
|
|
36
32
|
IS_LOCAL: isLocal,
|
|
37
33
|
// The version of Netlify Build
|
|
38
|
-
NETLIFY_BUILD_VERSION: version,
|
|
34
|
+
NETLIFY_BUILD_VERSION: ROOT_PACKAGE_JSON.version,
|
|
39
35
|
// The Netlify Site ID
|
|
40
36
|
SITE_ID: siteId,
|
|
41
37
|
// The Netlify API access token
|
|
@@ -55,7 +51,7 @@ const INTERNAL_FUNCTIONS_SRC = '.netlify/functions-internal'
|
|
|
55
51
|
// Retrieve constants which might change during the build if a plugin modifies
|
|
56
52
|
// `netlifyConfig` or creates some default directories.
|
|
57
53
|
// Unlike readonly constants, this is called again before each build step.
|
|
58
|
-
const addMutableConstants = async function ({
|
|
54
|
+
export const addMutableConstants = async function ({
|
|
59
55
|
constants,
|
|
60
56
|
buildDir,
|
|
61
57
|
netlifyConfig: {
|
|
@@ -149,5 +145,3 @@ const CONSTANT_PATHS = new Set([
|
|
|
149
145
|
'EDGE_HANDLERS_SRC',
|
|
150
146
|
'CACHE_DIR',
|
|
151
147
|
])
|
|
152
|
-
|
|
153
|
-
module.exports = { getConstants, addMutableConstants }
|
package/src/core/dry.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import pFilter from 'p-filter'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { logDryRunStart, logDryRunStep, logDryRunEnd } = require('../log/messages/dry')
|
|
6
|
-
const { runsOnlyOnBuildFailure } = require('../plugins/events')
|
|
3
|
+
import { logDryRunStart, logDryRunStep, logDryRunEnd } from '../log/messages/dry.js'
|
|
4
|
+
import { runsOnlyOnBuildFailure } from '../plugins/events.js'
|
|
7
5
|
|
|
8
6
|
// If the `dry` flag is specified, do a dry run
|
|
9
|
-
const doDryRun = async function ({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs }) {
|
|
7
|
+
export const doDryRun = async function ({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs }) {
|
|
10
8
|
const successSteps = await pFilter(steps, ({ event, condition }) =>
|
|
11
9
|
shouldIncludeStep({ buildDir, event, condition, netlifyConfig, constants, buildbotServerSocket }),
|
|
12
10
|
)
|
|
@@ -39,5 +37,3 @@ const shouldIncludeStep = async function ({
|
|
|
39
37
|
const getEventLength = function ({ event }) {
|
|
40
38
|
return event.length
|
|
41
39
|
}
|
|
42
|
-
|
|
43
|
-
module.exports = { doDryRun }
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
// From CLI `--featureFlags=a,b,c` to programmatic `{ a: true, b: true, c: true }`
|
|
4
|
-
const normalizeCliFeatureFlags = function (cliFeatureFlags) {
|
|
2
|
+
export const normalizeCliFeatureFlags = function (cliFeatureFlags) {
|
|
5
3
|
return Object.assign({}, ...cliFeatureFlags.split(',').filter(isNotEmpty).map(getFeatureFlag))
|
|
6
4
|
}
|
|
7
5
|
|
|
@@ -14,7 +12,7 @@ const getFeatureFlag = function (name) {
|
|
|
14
12
|
}
|
|
15
13
|
|
|
16
14
|
// Default values for feature flags
|
|
17
|
-
const DEFAULT_FEATURE_FLAGS = {
|
|
15
|
+
export const DEFAULT_FEATURE_FLAGS = {
|
|
18
16
|
buildbot_build_go_functions: false,
|
|
19
17
|
buildbot_create_functions_manifest: false,
|
|
20
18
|
buildbot_es_modules_esbuild: false,
|
|
@@ -23,5 +21,3 @@ const DEFAULT_FEATURE_FLAGS = {
|
|
|
23
21
|
buildbot_scheduled_functions: false,
|
|
24
22
|
zisi_parse_isc: false,
|
|
25
23
|
}
|
|
26
|
-
|
|
27
|
-
module.exports = { normalizeCliFeatureFlags, DEFAULT_FEATURE_FLAGS }
|
package/src/core/flags.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
/* eslint eslint-comments/no-use: off, max-lines: off */
|
|
4
2
|
|
|
5
3
|
// All CLI flags
|
|
6
|
-
const FLAGS = {
|
|
4
|
+
export const FLAGS = {
|
|
7
5
|
config: {
|
|
8
6
|
string: true,
|
|
9
7
|
describe: `Path to the configuration file.
|
|
@@ -129,7 +127,7 @@ Default: false`,
|
|
|
129
127
|
describe: `Environment in which this is loaded. Can be:
|
|
130
128
|
- 'buildbot': within Netlify Buildbot
|
|
131
129
|
- 'cli': within Netlify CLI
|
|
132
|
-
- 'require': through
|
|
130
|
+
- 'require': through import('@netlify/build')`,
|
|
133
131
|
hidden: true,
|
|
134
132
|
},
|
|
135
133
|
debug: {
|
|
@@ -184,5 +182,3 @@ Default: false`,
|
|
|
184
182
|
describe: 'Buffer output instead of printing it',
|
|
185
183
|
},
|
|
186
184
|
}
|
|
187
|
-
|
|
188
|
-
module.exports = { FLAGS }
|
package/src/core/lingering.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import psList from 'ps-list'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { logLingeringProcesses } = require('../log/messages/core')
|
|
3
|
+
import { logLingeringProcesses } from '../log/messages/core.js'
|
|
6
4
|
|
|
7
5
|
// Print a warning when some build processes are still running.
|
|
8
6
|
// We cannot rely on using the process tree:
|
|
@@ -20,7 +18,11 @@ const { logLingeringProcesses } = require('../log/messages/core')
|
|
|
20
18
|
// Therefore, we run this in a controlled environment only (the buildbot) and
|
|
21
19
|
// exclude specific processes manually. This is a lesser evil, although still
|
|
22
20
|
// quite hacky.
|
|
23
|
-
const warnOnLingeringProcesses = async function ({
|
|
21
|
+
export const warnOnLingeringProcesses = async function ({
|
|
22
|
+
mode,
|
|
23
|
+
logs,
|
|
24
|
+
testOpts: { silentLingeringProcesses = false },
|
|
25
|
+
}) {
|
|
24
26
|
if (mode !== 'buildbot' || silentLingeringProcesses) {
|
|
25
27
|
return
|
|
26
28
|
}
|
|
@@ -81,5 +83,3 @@ const IGNORED_COMMANDS = [
|
|
|
81
83
|
'jest-worker',
|
|
82
84
|
'broccoli-babel-transpiler',
|
|
83
85
|
]
|
|
84
|
-
|
|
85
|
-
module.exports = { warnOnLingeringProcesses }
|
package/src/core/main.js
CHANGED
|
@@ -1,30 +1,28 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
/* eslint-disable max-lines, import/max-dependencies */
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
2
|
+
import { handleBuildError } from '../error/handle.js'
|
|
3
|
+
import { getErrorInfo } from '../error/info.js'
|
|
4
|
+
import { startErrorMonitor } from '../error/monitor/start.js'
|
|
5
|
+
import { getBufferLogs } from '../log/logger.js'
|
|
6
|
+
import { logBuildStart, logTimer, logBuildSuccess } from '../log/messages/core.js'
|
|
7
|
+
import { loadPlugins } from '../plugins/load.js'
|
|
8
|
+
import { getPluginsOptions } from '../plugins/options.js'
|
|
9
|
+
import { pinPlugins } from '../plugins/pinned_version.js'
|
|
10
|
+
import { startPlugins, stopPlugins } from '../plugins/spawn.js'
|
|
11
|
+
import { addCorePlugins } from '../plugins_core/add.js'
|
|
12
|
+
import { reportStatuses } from '../status/report.js'
|
|
13
|
+
import { getSteps } from '../steps/get.js'
|
|
14
|
+
import { runSteps } from '../steps/run_steps.js'
|
|
15
|
+
import { trackBuildComplete } from '../telemetry/main.js'
|
|
16
|
+
import { initTimers, measureDuration } from '../time/main.js'
|
|
17
|
+
import { reportTimers } from '../time/report.js'
|
|
20
18
|
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
19
|
+
import { getConfigOpts, loadConfig } from './config.js'
|
|
20
|
+
import { getConstants } from './constants.js'
|
|
21
|
+
import { doDryRun } from './dry.js'
|
|
22
|
+
import { warnOnLingeringProcesses } from './lingering.js'
|
|
23
|
+
import { warnOnMissingSideFiles } from './missing_side_file.js'
|
|
24
|
+
import { normalizeFlags } from './normalize_flags.js'
|
|
25
|
+
import { getSeverity } from './severity.js'
|
|
28
26
|
|
|
29
27
|
/**
|
|
30
28
|
* Main entry point of Netlify Build.
|
|
@@ -50,7 +48,7 @@ const { getSeverity } = require('./severity')
|
|
|
50
48
|
* 0 (success), 1 (build cancelled), 2 (user error), 3 (plugin error), 4 (system error). Can be used as exit code.
|
|
51
49
|
* @returns {string[]} buildResult.logs - When using the `buffer` option, all log messages
|
|
52
50
|
*/
|
|
53
|
-
|
|
51
|
+
export default async function buildSite(flags = {}) {
|
|
54
52
|
const {
|
|
55
53
|
errorMonitor,
|
|
56
54
|
framework,
|
|
@@ -595,7 +593,7 @@ const runBuild = async function ({
|
|
|
595
593
|
verbose,
|
|
596
594
|
})
|
|
597
595
|
|
|
598
|
-
const { steps, events } =
|
|
596
|
+
const { steps, events } = getSteps(pluginsSteps)
|
|
599
597
|
|
|
600
598
|
if (dry) {
|
|
601
599
|
await doDryRun({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs })
|
|
@@ -687,6 +685,4 @@ const telemetryReport = async function ({
|
|
|
687
685
|
await handleBuildError(error, errorParams)
|
|
688
686
|
}
|
|
689
687
|
}
|
|
690
|
-
|
|
691
|
-
module.exports = build
|
|
692
688
|
/* eslint-enable max-lines, import/max-dependencies */
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { relative } from 'path'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import pathExists from 'path-exists'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { logMissingSideFile } = require('../log/messages/core')
|
|
5
|
+
import { logMissingSideFile } from '../log/messages/core.js'
|
|
8
6
|
|
|
9
7
|
// Some files like `_headers` and `_redirects` must be copied to the publish
|
|
10
8
|
// directory to be used in production. When those are present in the repository
|
|
11
9
|
// but not in the publish directory, this most likely indicates that the build
|
|
12
10
|
// command accidentally forgot to copy those. We then print a warning message.
|
|
13
|
-
const warnOnMissingSideFiles = async function ({
|
|
11
|
+
export const warnOnMissingSideFiles = async function ({
|
|
14
12
|
buildDir,
|
|
15
13
|
netlifyConfig: {
|
|
16
14
|
build: { publish },
|
|
@@ -29,5 +27,3 @@ const warnOnMissingSideFile = async function ({ logs, sideFile, buildDir, publis
|
|
|
29
27
|
|
|
30
28
|
logMissingSideFile(logs, sideFile, relative(buildDir, publish))
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
module.exports = { warnOnMissingSideFiles }
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { env, execPath } from 'process'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { logFlags } from '../log/messages/config.js'
|
|
4
|
+
import { removeFalsy } from '../utils/remove_falsy.js'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
const { removeFalsy } = require('../utils/remove_falsy')
|
|
7
|
-
|
|
8
|
-
const { DEFAULT_FEATURE_FLAGS } = require('./feature_flags')
|
|
6
|
+
import { DEFAULT_FEATURE_FLAGS } from './feature_flags.js'
|
|
9
7
|
|
|
10
8
|
// Normalize CLI flags
|
|
11
|
-
const normalizeFlags = function (flags, logs) {
|
|
9
|
+
export const normalizeFlags = function (flags, logs) {
|
|
12
10
|
const rawFlags = removeFalsy(flags)
|
|
13
11
|
|
|
14
12
|
// Combine the flags object env with the process.env
|
|
@@ -67,5 +65,3 @@ const REQUIRE_MODE = 'require'
|
|
|
67
65
|
const DEFAULT_FUNCTIONS_DIST = '.netlify/functions/'
|
|
68
66
|
const DEFAULT_CACHE_DIR = '.netlify/cache/'
|
|
69
67
|
const DEFAULT_STATSD_PORT = 8125
|
|
70
|
-
|
|
71
|
-
module.exports = { normalizeFlags }
|
package/src/core/severity.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
|
|
3
1
|
// Used to extract exit codes and respective status strings
|
|
4
2
|
// 1|2|3 indicate whether this was a user|plugin|system error.
|
|
5
|
-
const getSeverity = function (severity = FALLBACK_SEVERITY) {
|
|
3
|
+
export const getSeverity = function (severity = FALLBACK_SEVERITY) {
|
|
6
4
|
const severityEntry = severity in SEVERITY_MAP ? SEVERITY_MAP[severity] : FALLBACK_SEVERITY_ENTRY
|
|
7
5
|
const success = severity === SUCCESS_SEVERITY
|
|
8
6
|
return { success, ...severityEntry }
|
|
@@ -21,6 +19,4 @@ const SEVERITY_MAP = {
|
|
|
21
19
|
const SUCCESS_SEVERITY = 'success'
|
|
22
20
|
// Indicates a bug in our codebase
|
|
23
21
|
const FALLBACK_SEVERITY = 'error'
|
|
24
|
-
const FALLBACK_SEVERITY_ENTRY = SEVERITY_MAP[FALLBACK_SEVERITY]
|
|
25
|
-
|
|
26
|
-
module.exports = { getSeverity, FALLBACK_SEVERITY_ENTRY }
|
|
22
|
+
export const FALLBACK_SEVERITY_ENTRY = SEVERITY_MAP[FALLBACK_SEVERITY]
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { version as currentVersion, execPath } from 'process'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import execa from 'execa'
|
|
4
|
+
import semver from 'semver'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
const { clean: cleanVersion } = require('semver')
|
|
7
|
-
|
|
8
|
-
const { addErrorInfo } = require('../error/info')
|
|
6
|
+
import { addErrorInfo } from '../error/info.js'
|
|
9
7
|
|
|
10
8
|
// Retrieve Node.js version if the Node.js path is using nvm.
|
|
11
9
|
// `node.exe` on Windows, `bin/node` on Unix.
|
|
@@ -13,11 +11,11 @@ const NVM_NODE_VERSION_REGEXP = /[/\\]v(\d+\.\d+\.\d+)[/\\](bin[/\\]node|node.ex
|
|
|
13
11
|
|
|
14
12
|
// Retrieve Node.js version from current process
|
|
15
13
|
const getCurrentNodeVersion = function () {
|
|
16
|
-
return
|
|
14
|
+
return semver.clean(currentVersion)
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
// Retrieve Node.js version from `--node-path` or fallback to extracting the current Node.js process version
|
|
20
|
-
const getUserNodeVersion = async function (nodePath) {
|
|
18
|
+
export const getUserNodeVersion = async function (nodePath) {
|
|
21
19
|
// No `--node-path` CLI flag, use the current node process version
|
|
22
20
|
if (nodePath === execPath) {
|
|
23
21
|
return getCurrentNodeVersion()
|
|
@@ -31,7 +29,7 @@ const getUserNodeVersion = async function (nodePath) {
|
|
|
31
29
|
|
|
32
30
|
// Fallback to actually running `node --version` with the given nodePath
|
|
33
31
|
const { stdout } = await execa(nodePath, ['--version'], { reject: false })
|
|
34
|
-
const version =
|
|
32
|
+
const version = semver.clean(stdout)
|
|
35
33
|
|
|
36
34
|
if (version === null) {
|
|
37
35
|
const error = new Error(`Invalid --node-path CLI flag: ${nodePath}`)
|
|
@@ -41,5 +39,3 @@ const getUserNodeVersion = async function (nodePath) {
|
|
|
41
39
|
|
|
42
40
|
return version
|
|
43
41
|
}
|
|
44
|
-
|
|
45
|
-
module.exports = { getUserNodeVersion }
|
package/src/env/changes.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { env } from 'process'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const filterObj = require('filter-obj')
|
|
6
|
-
const mapObj = require('map-obj')
|
|
3
|
+
import filterObj from 'filter-obj'
|
|
4
|
+
import mapObj from 'map-obj'
|
|
7
5
|
|
|
8
6
|
// If plugins modify `process.env`, this is propagated in other plugins and in
|
|
9
7
|
// `build.command`. Since those are different processes, we figure out when they
|
|
10
8
|
// do this and communicate the new `process.env` to other processes.
|
|
11
|
-
const getNewEnvChanges = function (envBefore, netlifyConfig, netlifyConfigCopy) {
|
|
9
|
+
export const getNewEnvChanges = function (envBefore, netlifyConfig, netlifyConfigCopy) {
|
|
12
10
|
const processEnvChanges = diffEnv(envBefore, env)
|
|
13
11
|
const netlifyConfigEnvChanges = diffEnv(netlifyConfig.build.environment, netlifyConfigCopy.build.environment)
|
|
14
12
|
return { ...processEnvChanges, ...netlifyConfigEnvChanges }
|
|
@@ -31,7 +29,7 @@ const setToNull = function (name) {
|
|
|
31
29
|
|
|
32
30
|
// Set `process.env` changes from a previous different plugin.
|
|
33
31
|
// Can also merge with a `currentEnv` plain object instead of `process.env`.
|
|
34
|
-
const setEnvChanges = function (envChanges, currentEnv = env) {
|
|
32
|
+
export const setEnvChanges = function (envChanges, currentEnv = env) {
|
|
35
33
|
Object.entries(envChanges).forEach(([name, value]) => {
|
|
36
34
|
setEnvChange(name, value, currentEnv)
|
|
37
35
|
})
|
|
@@ -52,5 +50,3 @@ const setEnvChange = function (name, value, currentEnv) {
|
|
|
52
50
|
|
|
53
51
|
currentEnv[name] = value
|
|
54
52
|
}
|
|
55
|
-
|
|
56
|
-
module.exports = { getNewEnvChanges, setEnvChanges }
|
package/src/env/main.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { env } from 'process'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import filterObj from 'filter-obj'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { getParentColorEnv } = require('../log/colors')
|
|
5
|
+
import { getParentColorEnv } from '../log/colors.js'
|
|
8
6
|
|
|
9
7
|
// Retrieve the environment variables passed to plugins and `build.command`
|
|
10
8
|
// When run locally, this tries to emulate the production environment.
|
|
11
|
-
const getChildEnv = function ({ envOpt, env: allConfigEnv }) {
|
|
9
|
+
export const getChildEnv = function ({ envOpt, env: allConfigEnv }) {
|
|
12
10
|
const parentColorEnv = getParentColorEnv()
|
|
13
11
|
const parentEnv = { ...env, ...allConfigEnv, ...envOpt, ...parentColorEnv }
|
|
14
12
|
return filterObj(parentEnv, shouldKeepEnv)
|
|
@@ -19,5 +17,3 @@ const shouldKeepEnv = function (key) {
|
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
const REMOVED_PARENT_ENV = new Set(['bugsnag_key'])
|
|
22
|
-
|
|
23
|
-
module.exports = { getChildEnv }
|
package/src/env/metadata.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { env } from 'process'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const filterObj = require('filter-obj')
|
|
3
|
+
import filterObj from 'filter-obj'
|
|
6
4
|
|
|
7
5
|
// Retrieve enviroment variables used in error monitoring
|
|
8
|
-
const getEnvMetadata = function (childEnv = env) {
|
|
6
|
+
export const getEnvMetadata = function (childEnv = env) {
|
|
9
7
|
return filterObj(childEnv, isEnvMetadata)
|
|
10
8
|
}
|
|
11
9
|
|
|
@@ -81,5 +79,3 @@ const ENVIRONMENT_VARIABLES = new Set([
|
|
|
81
79
|
'GIT_LFS_ENABLED',
|
|
82
80
|
'GIT_LFS_FETCH_INCLUDE',
|
|
83
81
|
])
|
|
84
|
-
|
|
85
|
-
module.exports = { getEnvMetadata }
|
package/src/error/api.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import isPlainObj from 'is-plain-obj'
|
|
2
|
+
import mapObj from 'map-obj'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const mapObj = require('map-obj')
|
|
5
|
-
|
|
6
|
-
const { addErrorInfo } = require('./info')
|
|
4
|
+
import { addErrorInfo } from './info.js'
|
|
7
5
|
|
|
8
6
|
// Wrap `api.*` methods so that they add more error information
|
|
9
|
-
const addApiErrorHandlers = function (api) {
|
|
7
|
+
export const addApiErrorHandlers = function (api) {
|
|
10
8
|
if (api === undefined) {
|
|
11
9
|
return
|
|
12
10
|
}
|
|
@@ -46,5 +44,3 @@ const redactError = function (error) {
|
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
const HEX_REGEXP = /[\da-f]{6,}/g
|
|
49
|
-
|
|
50
|
-
module.exports = { addApiErrorHandlers }
|