@netlify/build 27.20.4 → 27.20.5
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/lib/core/bin.js +42 -59
- package/lib/core/build.js +333 -536
- package/lib/core/config.js +94 -159
- package/lib/core/constants.js +95 -135
- package/lib/core/dev.js +26 -30
- package/lib/core/dry.js +18 -36
- package/lib/core/feature_flags.js +13 -16
- package/lib/core/flags.js +168 -169
- package/lib/core/lingering.js +44 -61
- package/lib/core/main.js +94 -136
- package/lib/core/missing_side_file.js +12 -24
- package/lib/core/normalize_flags.js +52 -63
- package/lib/core/severity.js +13 -15
- package/lib/core/user_node_version.js +26 -35
- package/lib/env/changes.js +29 -37
- package/lib/env/main.js +10 -15
- package/lib/env/metadata.js +63 -76
- package/lib/error/api.js +31 -40
- package/lib/error/build.js +27 -38
- package/lib/error/cancel.js +5 -6
- package/lib/error/colors.js +7 -9
- package/lib/error/handle.js +38 -49
- package/lib/error/info.js +26 -35
- package/lib/error/monitor/location.js +12 -17
- package/lib/error/monitor/normalize.js +75 -85
- package/lib/error/monitor/print.js +19 -41
- package/lib/error/monitor/report.js +102 -121
- package/lib/error/monitor/start.js +43 -56
- package/lib/error/parse/clean_stack.js +52 -69
- package/lib/error/parse/location.js +40 -52
- package/lib/error/parse/normalize.js +18 -23
- package/lib/error/parse/parse.js +59 -93
- package/lib/error/parse/plugin.js +42 -57
- package/lib/error/parse/properties.js +13 -20
- package/lib/error/parse/serialize_log.js +29 -37
- package/lib/error/parse/serialize_status.js +15 -23
- package/lib/error/parse/stack.js +29 -38
- package/lib/error/type.js +132 -150
- package/lib/install/functions.js +16 -24
- package/lib/install/local.js +31 -48
- package/lib/install/main.js +52 -66
- package/lib/install/missing.js +40 -53
- package/lib/log/colors.js +15 -22
- package/lib/log/description.js +16 -21
- package/lib/log/header.js +11 -13
- package/lib/log/header_func.js +11 -15
- package/lib/log/logger.js +88 -119
- package/lib/log/messages/compatibility.js +100 -158
- package/lib/log/messages/config.js +76 -92
- package/lib/log/messages/core.js +40 -60
- package/lib/log/messages/core_steps.js +63 -92
- package/lib/log/messages/dry.js +31 -53
- package/lib/log/messages/install.js +21 -28
- package/lib/log/messages/ipc.js +21 -30
- package/lib/log/messages/mutations.js +51 -71
- package/lib/log/messages/plugins.js +18 -31
- package/lib/log/messages/status.js +12 -14
- package/lib/log/messages/steps.js +14 -18
- package/lib/log/old_version.js +23 -32
- package/lib/log/serialize.js +7 -10
- package/lib/log/stream.js +48 -65
- package/lib/log/theme.js +22 -23
- package/lib/plugins/child/diff.js +31 -40
- package/lib/plugins/child/error.js +20 -26
- package/lib/plugins/child/lazy.js +11 -14
- package/lib/plugins/child/load.js +15 -22
- package/lib/plugins/child/logic.js +51 -58
- package/lib/plugins/child/main.js +32 -46
- package/lib/plugins/child/run.js +18 -27
- package/lib/plugins/child/status.js +52 -63
- package/lib/plugins/child/typescript.js +19 -36
- package/lib/plugins/child/utils.js +36 -49
- package/lib/plugins/child/validate.js +25 -28
- package/lib/plugins/compatibility.js +64 -92
- package/lib/plugins/error.js +29 -35
- package/lib/plugins/events.js +7 -12
- package/lib/plugins/expected_version.js +61 -99
- package/lib/plugins/ipc.js +79 -102
- package/lib/plugins/list.js +49 -62
- package/lib/plugins/load.js +44 -64
- package/lib/plugins/manifest/check.js +64 -85
- package/lib/plugins/manifest/load.js +34 -37
- package/lib/plugins/manifest/main.js +16 -21
- package/lib/plugins/manifest/path.js +18 -25
- package/lib/plugins/manifest/validate.js +77 -94
- package/lib/plugins/node_version.js +22 -42
- package/lib/plugins/options.js +45 -78
- package/lib/plugins/pinned_version.js +58 -106
- package/lib/plugins/resolve.js +91 -133
- package/lib/plugins/spawn.js +43 -61
- package/lib/plugins_core/add.js +26 -40
- package/lib/plugins_core/build_command.js +47 -72
- package/lib/plugins_core/deploy/buildbot_client.js +61 -87
- package/lib/plugins_core/deploy/index.js +47 -71
- package/lib/plugins_core/edge_functions/index.js +73 -116
- package/lib/plugins_core/edge_functions/lib/error.js +13 -17
- package/lib/plugins_core/edge_functions/lib/internal_manifest.js +45 -55
- package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +65 -80
- package/lib/plugins_core/functions/error.js +88 -128
- package/lib/plugins_core/functions/feature_flags.js +5 -5
- package/lib/plugins_core/functions/index.js +98 -145
- package/lib/plugins_core/functions/utils.js +36 -57
- package/lib/plugins_core/functions/zisi.js +35 -52
- package/lib/plugins_core/functions_install/index.js +8 -11
- package/lib/plugins_core/list.js +15 -22
- package/lib/status/add.js +26 -32
- package/lib/status/colors.js +14 -19
- package/lib/status/load_error.js +8 -9
- package/lib/status/report.js +72 -126
- package/lib/status/success.js +10 -14
- package/lib/steps/core_step.js +54 -89
- package/lib/steps/error.js +50 -87
- package/lib/steps/get.js +33 -41
- package/lib/steps/plugin.js +53 -83
- package/lib/steps/return.js +24 -51
- package/lib/steps/run_core_steps.js +119 -171
- package/lib/steps/run_step.js +154 -270
- package/lib/steps/run_steps.js +91 -174
- package/lib/steps/update_config.js +45 -72
- package/lib/telemetry/main.js +89 -128
- package/lib/time/aggregate.js +84 -110
- package/lib/time/main.js +23 -34
- package/lib/time/measure.js +11 -15
- package/lib/time/report.js +32 -44
- package/lib/utils/errors.js +10 -9
- package/lib/utils/json.js +11 -15
- package/lib/utils/omit.js +3 -4
- package/lib/utils/package.js +19 -22
- package/lib/utils/remove_falsy.js +5 -7
- package/lib/utils/resolve.js +30 -34
- package/lib/utils/runtime.js +4 -4
- package/lib/utils/semver.js +19 -25
- package/package.json +13 -6
package/lib/core/main.js
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
import { handleBuildError } from '../error/handle.js'
|
|
2
|
-
import { logTimer, logBuildSuccess } from '../log/messages/core.js'
|
|
3
|
-
import { trackBuildComplete } from '../telemetry/main.js'
|
|
4
|
-
import { reportTimers } from '../time/report.js'
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export { startDev } from './dev.js'
|
|
10
|
-
export { runCoreSteps } from '../steps/run_core_steps.js'
|
|
11
|
-
|
|
1
|
+
import { handleBuildError } from '../error/handle.js';
|
|
2
|
+
import { logTimer, logBuildSuccess } from '../log/messages/core.js';
|
|
3
|
+
import { trackBuildComplete } from '../telemetry/main.js';
|
|
4
|
+
import { reportTimers } from '../time/report.js';
|
|
5
|
+
import { execBuild, startBuild } from './build.js';
|
|
6
|
+
import { getSeverity } from './severity.js';
|
|
7
|
+
export { startDev } from './dev.js';
|
|
8
|
+
export { runCoreSteps } from '../steps/run_core_steps.js';
|
|
12
9
|
/**
|
|
13
10
|
* Main entry point of Netlify Build.
|
|
14
11
|
* Runs a builds and returns whether it succeeded or not.
|
|
@@ -34,132 +31,93 @@ export { runCoreSteps } from '../steps/run_core_steps.js'
|
|
|
34
31
|
* @returns {string[]} buildResult.logs - When using the `buffer` option, all log messages
|
|
35
32
|
*/
|
|
36
33
|
export default async function buildSite(flags = {}) {
|
|
37
|
-
|
|
38
|
-
errorMonitor,
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
framework,
|
|
97
|
-
testOpts,
|
|
98
|
-
errorParams,
|
|
99
|
-
})
|
|
100
|
-
return { success, severityCode, netlifyConfig: netlifyConfigA, logs, configMutations }
|
|
101
|
-
} catch (error) {
|
|
102
|
-
const { severity } = await handleBuildError(error, errorParams)
|
|
103
|
-
const { pluginsOptions, siteInfo, userNodeVersion } = errorParams
|
|
104
|
-
const { success, severityCode, status } = getSeverity(severity)
|
|
105
|
-
await telemetryReport({
|
|
106
|
-
buildId,
|
|
107
|
-
deployId,
|
|
108
|
-
status,
|
|
109
|
-
pluginsOptions,
|
|
110
|
-
siteInfo,
|
|
111
|
-
telemetry,
|
|
112
|
-
userNodeVersion,
|
|
113
|
-
framework,
|
|
114
|
-
testOpts,
|
|
115
|
-
errorParams,
|
|
116
|
-
})
|
|
117
|
-
return { success, severityCode, logs }
|
|
118
|
-
}
|
|
34
|
+
const { errorMonitor, framework, mode, logs, debug, systemLogFile, testOpts, statsdOpts, dry, telemetry, buildId, deployId, ...flagsA } = startBuild(flags);
|
|
35
|
+
const errorParams = { errorMonitor, mode, logs, debug, testOpts };
|
|
36
|
+
try {
|
|
37
|
+
const { pluginsOptions, netlifyConfig: netlifyConfigA, siteInfo, userNodeVersion, stepsCount, timers, durationNs, configMutations, } = await execBuild({
|
|
38
|
+
...flagsA,
|
|
39
|
+
buildId,
|
|
40
|
+
systemLogFile,
|
|
41
|
+
deployId,
|
|
42
|
+
dry,
|
|
43
|
+
errorMonitor,
|
|
44
|
+
mode,
|
|
45
|
+
logs,
|
|
46
|
+
debug,
|
|
47
|
+
testOpts,
|
|
48
|
+
errorParams,
|
|
49
|
+
});
|
|
50
|
+
await handleBuildSuccess({
|
|
51
|
+
framework,
|
|
52
|
+
dry,
|
|
53
|
+
logs,
|
|
54
|
+
timers,
|
|
55
|
+
durationNs,
|
|
56
|
+
statsdOpts,
|
|
57
|
+
});
|
|
58
|
+
const { success, severityCode, status } = getSeverity('success');
|
|
59
|
+
await telemetryReport({
|
|
60
|
+
buildId,
|
|
61
|
+
deployId,
|
|
62
|
+
status,
|
|
63
|
+
stepsCount,
|
|
64
|
+
pluginsOptions,
|
|
65
|
+
durationNs,
|
|
66
|
+
siteInfo,
|
|
67
|
+
telemetry,
|
|
68
|
+
userNodeVersion,
|
|
69
|
+
framework,
|
|
70
|
+
testOpts,
|
|
71
|
+
errorParams,
|
|
72
|
+
});
|
|
73
|
+
return { success, severityCode, netlifyConfig: netlifyConfigA, logs, configMutations };
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
const { severity } = await handleBuildError(error, errorParams);
|
|
77
|
+
const { pluginsOptions, siteInfo, userNodeVersion } = errorParams;
|
|
78
|
+
const { success, severityCode, status } = getSeverity(severity);
|
|
79
|
+
await telemetryReport({
|
|
80
|
+
buildId,
|
|
81
|
+
deployId,
|
|
82
|
+
status,
|
|
83
|
+
pluginsOptions,
|
|
84
|
+
siteInfo,
|
|
85
|
+
telemetry,
|
|
86
|
+
userNodeVersion,
|
|
87
|
+
framework,
|
|
88
|
+
testOpts,
|
|
89
|
+
errorParams,
|
|
90
|
+
});
|
|
91
|
+
return { success, severityCode, logs };
|
|
92
|
+
}
|
|
119
93
|
}
|
|
120
|
-
|
|
121
94
|
// Logs and reports that a build successfully ended
|
|
122
95
|
const handleBuildSuccess = async function ({ framework, dry, logs, timers, durationNs, statsdOpts }) {
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
await reportTimers({ timers, statsdOpts, framework })
|
|
131
|
-
}
|
|
132
|
-
|
|
96
|
+
if (dry) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
logBuildSuccess(logs);
|
|
100
|
+
logTimer(logs, durationNs, 'Netlify Build');
|
|
101
|
+
await reportTimers({ timers, statsdOpts, framework });
|
|
102
|
+
};
|
|
133
103
|
// Handles the calls and errors of telemetry reports
|
|
134
|
-
const telemetryReport = async function ({
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
pluginsOptions,
|
|
155
|
-
durationNs,
|
|
156
|
-
siteInfo,
|
|
157
|
-
telemetry,
|
|
158
|
-
userNodeVersion,
|
|
159
|
-
framework,
|
|
160
|
-
testOpts,
|
|
161
|
-
})
|
|
162
|
-
} catch (error) {
|
|
163
|
-
await handleBuildError(error, errorParams)
|
|
164
|
-
}
|
|
165
|
-
}
|
|
104
|
+
const telemetryReport = async function ({ deployId, buildId, status, stepsCount, pluginsOptions, durationNs, siteInfo, telemetry, userNodeVersion, framework, testOpts, errorParams, }) {
|
|
105
|
+
try {
|
|
106
|
+
await trackBuildComplete({
|
|
107
|
+
deployId,
|
|
108
|
+
buildId,
|
|
109
|
+
status,
|
|
110
|
+
stepsCount,
|
|
111
|
+
pluginsOptions,
|
|
112
|
+
durationNs,
|
|
113
|
+
siteInfo,
|
|
114
|
+
telemetry,
|
|
115
|
+
userNodeVersion,
|
|
116
|
+
framework,
|
|
117
|
+
testOpts,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
await handleBuildError(error, errorParams);
|
|
122
|
+
}
|
|
123
|
+
};
|
|
@@ -1,29 +1,17 @@
|
|
|
1
|
-
import { relative } from 'path'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { logMissingSideFile } from '../log/messages/core.js'
|
|
6
|
-
|
|
1
|
+
import { relative } from 'path';
|
|
2
|
+
import { pathExists } from 'path-exists';
|
|
3
|
+
import { logMissingSideFile } from '../log/messages/core.js';
|
|
7
4
|
// Some files like `_headers` and `_redirects` must be copied to the publish
|
|
8
5
|
// directory to be used in production. When those are present in the repository
|
|
9
6
|
// but not in the publish directory, this most likely indicates that the build
|
|
10
7
|
// command accidentally forgot to copy those. We then print a warning message.
|
|
11
|
-
export const warnOnMissingSideFiles = async function ({
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
logs,
|
|
17
|
-
}) {
|
|
18
|
-
await Promise.all(SIDE_FILES.map((sideFile) => warnOnMissingSideFile({ logs, sideFile, buildDir, publish })))
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const SIDE_FILES = ['_headers', '_redirects']
|
|
22
|
-
|
|
8
|
+
export const warnOnMissingSideFiles = async function ({ buildDir, netlifyConfig: { build: { publish }, }, logs, }) {
|
|
9
|
+
await Promise.all(SIDE_FILES.map((sideFile) => warnOnMissingSideFile({ logs, sideFile, buildDir, publish })));
|
|
10
|
+
};
|
|
11
|
+
const SIDE_FILES = ['_headers', '_redirects'];
|
|
23
12
|
const warnOnMissingSideFile = async function ({ logs, sideFile, buildDir, publish }) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
13
|
+
if (!(await pathExists(`${buildDir}/${sideFile}`)) || (await pathExists(`${publish}/${sideFile}`))) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
logMissingSideFile(logs, sideFile, relative(buildDir, publish));
|
|
17
|
+
};
|
|
@@ -1,70 +1,59 @@
|
|
|
1
|
-
import { env, execPath } from 'process'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { DEFAULT_FEATURE_FLAGS } from './feature_flags.js'
|
|
7
|
-
|
|
1
|
+
import { env, execPath } from 'process';
|
|
2
|
+
import { logFlags } from '../log/messages/config.js';
|
|
3
|
+
import { removeFalsy } from '../utils/remove_falsy.js';
|
|
4
|
+
import { DEFAULT_FEATURE_FLAGS } from './feature_flags.js';
|
|
8
5
|
// Normalize CLI flags
|
|
9
6
|
export const normalizeFlags = function (flags, logs) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
logFlags(logs, rawFlags, normalizedFlags)
|
|
29
|
-
|
|
30
|
-
return normalizedFlags
|
|
31
|
-
}
|
|
32
|
-
|
|
7
|
+
const rawFlags = removeFalsy(flags);
|
|
8
|
+
// Combine the flags object env with the process.env
|
|
9
|
+
const combinedEnv = { ...env, ...rawFlags.env };
|
|
10
|
+
const defaultFlags = getDefaultFlags(rawFlags, combinedEnv);
|
|
11
|
+
// The telemetry flag requires specific logic to compute
|
|
12
|
+
const telemetryFlag = computeTelemetry(rawFlags, combinedEnv);
|
|
13
|
+
const mergedFlags = {
|
|
14
|
+
...defaultFlags,
|
|
15
|
+
...rawFlags,
|
|
16
|
+
...telemetryFlag,
|
|
17
|
+
statsdOpts: { ...defaultFlags.statsd, ...rawFlags.statsd },
|
|
18
|
+
featureFlags: { ...defaultFlags.featureFlags, ...rawFlags.featureFlags },
|
|
19
|
+
};
|
|
20
|
+
const normalizedFlags = removeFalsy(mergedFlags);
|
|
21
|
+
logFlags(logs, rawFlags, normalizedFlags);
|
|
22
|
+
return normalizedFlags;
|
|
23
|
+
};
|
|
33
24
|
// Default values of CLI flags
|
|
34
25
|
const getDefaultFlags = function ({ env: envOpt = {} }, combinedEnv) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
|
|
26
|
+
return {
|
|
27
|
+
env: envOpt,
|
|
28
|
+
nodePath: execPath,
|
|
29
|
+
token: combinedEnv.NETLIFY_AUTH_TOKEN,
|
|
30
|
+
mode: REQUIRE_MODE,
|
|
31
|
+
offline: false,
|
|
32
|
+
telemetry: false,
|
|
33
|
+
verbose: Boolean(combinedEnv.NETLIFY_BUILD_DEBUG),
|
|
34
|
+
functionsDistDir: DEFAULT_FUNCTIONS_DIST,
|
|
35
|
+
edgeFunctionsDistDir: DEFAULT_EDGE_FUNCTIONS_DIST,
|
|
36
|
+
cacheDir: DEFAULT_CACHE_DIR,
|
|
37
|
+
deployId: combinedEnv.DEPLOY_ID,
|
|
38
|
+
buildId: combinedEnv.BUILD_ID,
|
|
39
|
+
debug: Boolean(combinedEnv.NETLIFY_BUILD_DEBUG),
|
|
40
|
+
bugsnagKey: combinedEnv.BUGSNAG_KEY,
|
|
41
|
+
sendStatus: false,
|
|
42
|
+
saveConfig: false,
|
|
43
|
+
apiHost: 'api.netlify.com',
|
|
44
|
+
testOpts: {},
|
|
45
|
+
featureFlags: DEFAULT_FEATURE_FLAGS,
|
|
46
|
+
statsd: { port: DEFAULT_STATSD_PORT },
|
|
47
|
+
timeline: 'build',
|
|
48
|
+
};
|
|
49
|
+
};
|
|
60
50
|
// Compute the telemetry flag, it's disabled by default and we want to always disable it
|
|
61
51
|
// if BUILD_TELEMETRY_DISABLED is passed.
|
|
62
52
|
const computeTelemetry = function (flags, envOpts) {
|
|
63
|
-
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const
|
|
67
|
-
const
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const DEFAULT_STATSD_PORT = 8125
|
|
53
|
+
return envOpts.BUILD_TELEMETRY_DISABLED ? { telemetry: false } : { telemetry: flags.telemetry };
|
|
54
|
+
};
|
|
55
|
+
const REQUIRE_MODE = 'require';
|
|
56
|
+
const DEFAULT_EDGE_FUNCTIONS_DIST = '.netlify/edge-functions-dist/';
|
|
57
|
+
const DEFAULT_FUNCTIONS_DIST = '.netlify/functions/';
|
|
58
|
+
const DEFAULT_CACHE_DIR = '.netlify/cache/';
|
|
59
|
+
const DEFAULT_STATSD_PORT = 8125;
|
package/lib/core/severity.js
CHANGED
|
@@ -1,22 +1,20 @@
|
|
|
1
1
|
// Used to extract exit codes and respective status strings
|
|
2
2
|
// 1|2|3 indicate whether this was a user|plugin|system error.
|
|
3
3
|
export const getSeverity = function (severity = FALLBACK_SEVERITY) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
4
|
+
const severityEntry = severity in SEVERITY_MAP ? SEVERITY_MAP[severity] : FALLBACK_SEVERITY_ENTRY;
|
|
5
|
+
const success = severity === SUCCESS_SEVERITY;
|
|
6
|
+
return { success, ...severityEntry };
|
|
7
|
+
};
|
|
9
8
|
// Map error severities to exit codes and status (used for telemetry purposes)
|
|
10
|
-
|
|
11
9
|
const SEVERITY_MAP = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
10
|
+
success: { severityCode: 0, status: 'success' },
|
|
11
|
+
none: { severityCode: 1, status: 'cancelled' },
|
|
12
|
+
info: { severityCode: 2, status: 'user-error' },
|
|
13
|
+
warning: { severityCode: 3, status: 'plugin-error' },
|
|
14
|
+
error: { severityCode: 4, status: 'system-error' },
|
|
15
|
+
};
|
|
18
16
|
/* eslint-enable no-magic-numbers */
|
|
19
|
-
const SUCCESS_SEVERITY = 'success'
|
|
17
|
+
const SUCCESS_SEVERITY = 'success';
|
|
20
18
|
// Indicates a bug in our codebase
|
|
21
|
-
const FALLBACK_SEVERITY = 'error'
|
|
22
|
-
export const FALLBACK_SEVERITY_ENTRY = SEVERITY_MAP[FALLBACK_SEVERITY]
|
|
19
|
+
const FALLBACK_SEVERITY = 'error';
|
|
20
|
+
export const FALLBACK_SEVERITY_ENTRY = SEVERITY_MAP[FALLBACK_SEVERITY];
|
|
@@ -1,41 +1,32 @@
|
|
|
1
|
-
import { version as currentVersion, execPath } from 'process'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
import { addErrorInfo } from '../error/info.js'
|
|
7
|
-
|
|
1
|
+
import { version as currentVersion, execPath } from 'process';
|
|
2
|
+
import { execa } from 'execa';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import { addErrorInfo } from '../error/info.js';
|
|
8
5
|
// Retrieve Node.js version if the Node.js path is using nvm.
|
|
9
6
|
// `node.exe` on Windows, `bin/node` on Unix.
|
|
10
|
-
const NVM_NODE_VERSION_REGEXP = /[/\\]v(\d+\.\d+\.\d+)[/\\](bin[/\\]node|node.exe)
|
|
11
|
-
|
|
7
|
+
const NVM_NODE_VERSION_REGEXP = /[/\\]v(\d+\.\d+\.\d+)[/\\](bin[/\\]node|node.exe)$/;
|
|
12
8
|
// Retrieve Node.js version from current process
|
|
13
9
|
const getCurrentNodeVersion = function () {
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
10
|
+
return semver.clean(currentVersion);
|
|
11
|
+
};
|
|
17
12
|
// Retrieve Node.js version from `--node-path` or fallback to extracting the current Node.js process version
|
|
18
13
|
export const getUserNodeVersion = async function (nodePath) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return version
|
|
41
|
-
}
|
|
14
|
+
// No `--node-path` CLI flag, use the current node process version
|
|
15
|
+
if (nodePath === execPath) {
|
|
16
|
+
return getCurrentNodeVersion();
|
|
17
|
+
}
|
|
18
|
+
// Extract version from path
|
|
19
|
+
const result = NVM_NODE_VERSION_REGEXP.exec(nodePath);
|
|
20
|
+
if (result !== null) {
|
|
21
|
+
return result[1];
|
|
22
|
+
}
|
|
23
|
+
// Fallback to actually running `node --version` with the given nodePath
|
|
24
|
+
const { stdout } = await execa(nodePath, ['--version'], { reject: false });
|
|
25
|
+
const version = semver.clean(stdout);
|
|
26
|
+
if (version === null) {
|
|
27
|
+
const error = new Error(`Invalid --node-path CLI flag: ${nodePath}`);
|
|
28
|
+
addErrorInfo(error, { type: 'resolveConfig' });
|
|
29
|
+
throw error;
|
|
30
|
+
}
|
|
31
|
+
return version;
|
|
32
|
+
};
|
package/lib/env/changes.js
CHANGED
|
@@ -1,51 +1,43 @@
|
|
|
1
|
-
import { env } from 'process'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import mapObj from 'map-obj'
|
|
5
|
-
|
|
1
|
+
import { env } from 'process';
|
|
2
|
+
import filterObj from 'filter-obj';
|
|
3
|
+
import mapObj from 'map-obj';
|
|
6
4
|
// If plugins modify `process.env`, this is propagated in other plugins and in
|
|
7
5
|
// `build.command`. Since those are different processes, we figure out when they
|
|
8
6
|
// do this and communicate the new `process.env` to other processes.
|
|
9
7
|
export const getNewEnvChanges = function (envBefore, netlifyConfig, netlifyConfigCopy) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
8
|
+
const processEnvChanges = diffEnv(envBefore, env);
|
|
9
|
+
const netlifyConfigEnvChanges = diffEnv(netlifyConfig.build.environment, netlifyConfigCopy.build.environment);
|
|
10
|
+
return { ...processEnvChanges, ...netlifyConfigEnvChanges };
|
|
11
|
+
};
|
|
15
12
|
const diffEnv = function (envBefore, envAfter) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
13
|
+
const envChanges = filterObj(envAfter, (name, value) => value !== envBefore[name]);
|
|
14
|
+
const deletedEnv = filterObj(envBefore, (name) => envAfter[name] === undefined);
|
|
15
|
+
const deletedEnvA = mapObj(deletedEnv, setToNull);
|
|
16
|
+
return { ...envChanges, ...deletedEnvA };
|
|
17
|
+
};
|
|
22
18
|
// `undefined` is not JSON-serializable (which is used in process IPC), so we
|
|
23
19
|
// convert it to `null`
|
|
24
20
|
// Note: `process.env[name] = undefined` actually does
|
|
25
21
|
// `process.env[name] = 'undefined'` in Node.js.
|
|
26
22
|
const setToNull = function (name) {
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
23
|
+
return [name, null];
|
|
24
|
+
};
|
|
30
25
|
// Set `process.env` changes from a previous different plugin.
|
|
31
26
|
// Can also merge with a `currentEnv` plain object instead of `process.env`.
|
|
32
27
|
export const setEnvChanges = function (envChanges, currentEnv = env) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
28
|
+
Object.entries(envChanges).forEach(([name, value]) => {
|
|
29
|
+
setEnvChange(name, value, currentEnv);
|
|
30
|
+
});
|
|
31
|
+
return { ...currentEnv };
|
|
32
|
+
};
|
|
39
33
|
const setEnvChange = function (name, value, currentEnv) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
currentEnv[name] = value
|
|
51
|
-
}
|
|
34
|
+
if (currentEnv[name] === value) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
if (value === null) {
|
|
38
|
+
// `currentEnv` is a mutable variable
|
|
39
|
+
delete currentEnv[name];
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
currentEnv[name] = value;
|
|
43
|
+
};
|
package/lib/env/main.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
|
-
import { env } from 'process'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { getParentColorEnv } from '../log/colors.js'
|
|
6
|
-
|
|
1
|
+
import { env } from 'process';
|
|
2
|
+
import filterObj from 'filter-obj';
|
|
3
|
+
import { getParentColorEnv } from '../log/colors.js';
|
|
7
4
|
// Retrieve the environment variables passed to plugins and `build.command`
|
|
8
5
|
// When run locally, this tries to emulate the production environment.
|
|
9
6
|
export const getChildEnv = function ({ envOpt, env: allConfigEnv }) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
7
|
+
const parentColorEnv = getParentColorEnv();
|
|
8
|
+
const parentEnv = { ...env, ...allConfigEnv, ...envOpt, ...parentColorEnv };
|
|
9
|
+
return filterObj(parentEnv, shouldKeepEnv);
|
|
10
|
+
};
|
|
15
11
|
const shouldKeepEnv = function (key) {
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const REMOVED_PARENT_ENV = new Set(['bugsnag_key'])
|
|
12
|
+
return !REMOVED_PARENT_ENV.has(key.toLowerCase());
|
|
13
|
+
};
|
|
14
|
+
const REMOVED_PARENT_ENV = new Set(['bugsnag_key']);
|