@netlify/build 27.20.3 → 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 +15 -8
|
@@ -1,41 +1,38 @@
|
|
|
1
|
-
import { promises as fs } from 'fs'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { addErrorInfo } from '../../error/info.js'
|
|
6
|
-
|
|
7
|
-
import { validateManifest } from './validate.js'
|
|
8
|
-
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import { load as loadYaml, JSON_SCHEMA } from 'js-yaml';
|
|
3
|
+
import { addErrorInfo } from '../../error/info.js';
|
|
4
|
+
import { validateManifest } from './validate.js';
|
|
9
5
|
// Load "manifest.yml" using its file path
|
|
10
6
|
export const loadManifest = async function ({ manifestPath, packageName, pluginPackageJson, loadedFrom, origin }) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
7
|
+
try {
|
|
8
|
+
const rawManifest = await loadRawManifest(manifestPath);
|
|
9
|
+
const manifest = await parseManifest(rawManifest);
|
|
10
|
+
validateManifest(manifest, rawManifest);
|
|
11
|
+
return manifest;
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
addErrorInfo(error, {
|
|
15
|
+
type: 'pluginValidation',
|
|
16
|
+
plugin: { packageName, pluginPackageJson },
|
|
17
|
+
location: { event: 'load', packageName, loadedFrom, origin },
|
|
18
|
+
});
|
|
19
|
+
throw error;
|
|
20
|
+
}
|
|
21
|
+
};
|
|
26
22
|
const loadRawManifest = async function (manifestPath) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
error
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}
|
|
34
|
-
|
|
23
|
+
try {
|
|
24
|
+
return await fs.readFile(manifestPath, 'utf8');
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
error.message = `Could not load plugin's "manifest.yml"\n${error.message}`;
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
};
|
|
35
31
|
const parseManifest = async function (rawManifest) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
32
|
+
try {
|
|
33
|
+
return await loadYaml(rawManifest, { schema: JSON_SCHEMA, json: true });
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
throw new Error(`Could not parse plugin's "manifest.yml"\n${error.message}`);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
import { addPluginLoadErrorStatus } from '../../status/load_error.js'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { getManifestPath } from './path.js'
|
|
6
|
-
|
|
1
|
+
import { addPluginLoadErrorStatus } from '../../status/load_error.js';
|
|
2
|
+
import { checkInputs } from './check.js';
|
|
3
|
+
import { loadManifest } from './load.js';
|
|
4
|
+
import { getManifestPath } from './path.js';
|
|
7
5
|
// Load plugin's `manifest.yml`
|
|
8
|
-
export const useManifest = async function (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
throw error
|
|
21
|
-
}
|
|
22
|
-
}
|
|
6
|
+
export const useManifest = async function ({ packageName, loadedFrom, origin, inputs }, { pluginDir, packageDir, pluginPackageJson, pluginPackageJson: { version }, debug }) {
|
|
7
|
+
const manifestPath = await getManifestPath({ pluginDir, packageDir, packageName });
|
|
8
|
+
try {
|
|
9
|
+
const manifest = await loadManifest({ manifestPath, packageName, pluginPackageJson, loadedFrom, origin });
|
|
10
|
+
const inputsA = checkInputs({ inputs, manifest, packageName, pluginPackageJson, loadedFrom, origin });
|
|
11
|
+
return { manifest, inputs: inputsA };
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
addPluginLoadErrorStatus({ error, packageName, version, debug });
|
|
15
|
+
throw error;
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -1,31 +1,24 @@
|
|
|
1
|
-
import { locatePath } from 'locate-path'
|
|
2
|
-
|
|
3
|
-
import { addErrorInfo } from '../../error/info.js'
|
|
4
|
-
|
|
1
|
+
import { locatePath } from 'locate-path';
|
|
2
|
+
import { addErrorInfo } from '../../error/info.js';
|
|
5
3
|
// Retrieve "manifest.yml" path for a specific plugin
|
|
6
4
|
export const getManifestPath = async function ({ pluginDir, packageDir, packageName }) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
5
|
+
const dirs = [pluginDir, packageDir]
|
|
6
|
+
.filter(Boolean)
|
|
7
|
+
.flatMap((dir) => MANIFEST_FILENAMES.map((filename) => `${dir}/${filename}`));
|
|
8
|
+
const manifestPath = await locatePath(dirs);
|
|
9
|
+
validateManifestExists(manifestPath, packageName);
|
|
10
|
+
return manifestPath;
|
|
11
|
+
};
|
|
15
12
|
const validateManifestExists = function (manifestPath, packageName) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const error = new Error(
|
|
21
|
-
`The plugin "${packageName}" is missing a "manifest.yml".
|
|
13
|
+
if (manifestPath !== undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const error = new Error(`The plugin "${packageName}" is missing a "manifest.yml".
|
|
22
17
|
This might mean:
|
|
23
18
|
- The plugin "package" name is misspelled
|
|
24
19
|
- The plugin "package" points to a Node module that is not a Netlify Build plugin
|
|
25
|
-
- If you're developing a plugin, please see the documentation at https://docs.netlify.com/configure-builds/build-plugins/create-plugins/#anatomy-of-a-plugin
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const MANIFEST_FILENAMES = ['manifest.yml', 'manifest.yaml']
|
|
20
|
+
- If you're developing a plugin, please see the documentation at https://docs.netlify.com/configure-builds/build-plugins/create-plugins/#anatomy-of-a-plugin`);
|
|
21
|
+
addErrorInfo(error, { type: 'resolveConfig' });
|
|
22
|
+
throw error;
|
|
23
|
+
};
|
|
24
|
+
const MANIFEST_FILENAMES = ['manifest.yml', 'manifest.yaml'];
|
|
@@ -1,108 +1,91 @@
|
|
|
1
|
-
import isPlainObj from 'is-plain-obj'
|
|
2
|
-
|
|
3
|
-
import { THEME } from '../../log/theme.js'
|
|
4
|
-
|
|
1
|
+
import isPlainObj from 'is-plain-obj';
|
|
2
|
+
import { THEME } from '../../log/theme.js';
|
|
5
3
|
// Validate `manifest.yml` syntax
|
|
6
4
|
export const validateManifest = function (manifest, rawManifest) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
error
|
|
5
|
+
try {
|
|
6
|
+
validateBasic(manifest);
|
|
7
|
+
validateUnknownProps(manifest);
|
|
8
|
+
validateName(manifest);
|
|
9
|
+
validateInputs(manifest);
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
error.message = `Plugin's "manifest.yml" ${error.message}
|
|
14
13
|
|
|
15
14
|
${THEME.errorSubHeader('manifest.yml')}
|
|
16
|
-
${rawManifest.trim()}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
15
|
+
${rawManifest.trim()}`;
|
|
16
|
+
throw error;
|
|
17
|
+
}
|
|
18
|
+
};
|
|
21
19
|
const validateBasic = function (manifest) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
|
|
20
|
+
if (!isPlainObj(manifest)) {
|
|
21
|
+
throw new Error('must be a plain object');
|
|
22
|
+
}
|
|
23
|
+
};
|
|
27
24
|
const validateUnknownProps = function (manifest) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const VALID_PROPS = new Set(['name', 'inputs'])
|
|
35
|
-
|
|
25
|
+
const unknownProp = Object.keys(manifest).find((key) => !VALID_PROPS.has(key));
|
|
26
|
+
if (unknownProp !== undefined) {
|
|
27
|
+
throw new Error(`unknown property "${unknownProp}"`);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const VALID_PROPS = new Set(['name', 'inputs']);
|
|
36
31
|
const validateName = function ({ name }) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
32
|
+
if (name === undefined) {
|
|
33
|
+
throw new Error('must contain a "name" property');
|
|
34
|
+
}
|
|
35
|
+
if (typeof name !== 'string') {
|
|
36
|
+
throw new TypeError('"name" property must be a string');
|
|
37
|
+
}
|
|
38
|
+
};
|
|
46
39
|
const validateInputs = function ({ inputs }) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
inputs.forEach(validateInput)
|
|
56
|
-
}
|
|
57
|
-
|
|
40
|
+
if (inputs === undefined) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
if (!isArrayOfObjects(inputs)) {
|
|
44
|
+
throw new Error('"inputs" property must be an array of objects');
|
|
45
|
+
}
|
|
46
|
+
inputs.forEach(validateInput);
|
|
47
|
+
};
|
|
58
48
|
const isArrayOfObjects = function (objects) {
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
49
|
+
return Array.isArray(objects) && objects.every(isPlainObj);
|
|
50
|
+
};
|
|
62
51
|
const validateInput = function (input, index) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
error
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
|
|
52
|
+
try {
|
|
53
|
+
validateUnknownInputProps(input);
|
|
54
|
+
validateInputName(input);
|
|
55
|
+
validateInputDescription(input);
|
|
56
|
+
validateInputRequired(input);
|
|
57
|
+
}
|
|
58
|
+
catch (error) {
|
|
59
|
+
error.message = `"inputs" property is invalid.
|
|
60
|
+
Input at position ${index} ${error.message}.`;
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
75
64
|
const validateUnknownInputProps = function (input) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const VALID_INPUT_PROPS = new Set(['name', 'description', 'required', 'default'])
|
|
83
|
-
|
|
65
|
+
const unknownProp = Object.keys(input).find((key) => !VALID_INPUT_PROPS.has(key));
|
|
66
|
+
if (unknownProp !== undefined) {
|
|
67
|
+
throw new Error(`has an unknown property "${unknownProp}"`);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const VALID_INPUT_PROPS = new Set(['name', 'description', 'required', 'default']);
|
|
84
71
|
const validateInputName = function ({ name }) {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
|
|
72
|
+
if (name === undefined) {
|
|
73
|
+
throw new Error('must contain a "name" property');
|
|
74
|
+
}
|
|
75
|
+
if (typeof name !== 'string') {
|
|
76
|
+
throw new TypeError('"name" property must be a string');
|
|
77
|
+
}
|
|
78
|
+
};
|
|
94
79
|
const validateInputDescription = function ({ description }) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
80
|
+
if (description === undefined) {
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
if (typeof description !== 'string') {
|
|
84
|
+
throw new TypeError('"description" property must be a string');
|
|
85
|
+
}
|
|
86
|
+
};
|
|
104
87
|
const validateInputRequired = function ({ required }) {
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
88
|
+
if (required !== undefined && typeof required !== 'boolean') {
|
|
89
|
+
throw new Error('"required" property must be a boolean');
|
|
90
|
+
}
|
|
91
|
+
};
|
|
@@ -1,50 +1,30 @@
|
|
|
1
|
-
import { version as currentVersion, execPath } from 'process'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { addErrorInfo } from '../error/info.js'
|
|
6
|
-
import { ROOT_PACKAGE_JSON } from '../utils/json.js'
|
|
7
|
-
|
|
1
|
+
import { version as currentVersion, execPath } from 'process';
|
|
2
|
+
import semver from 'semver';
|
|
3
|
+
import { addErrorInfo } from '../error/info.js';
|
|
4
|
+
import { ROOT_PACKAGE_JSON } from '../utils/json.js';
|
|
8
5
|
// Local plugins and `package.json`-installed plugins use user's preferred Node.js version if higher than our minimum
|
|
9
6
|
// supported version. Else default to the system Node version.
|
|
10
7
|
// Local and programmatic builds use `@netlify/build` Node.js version, which is
|
|
11
8
|
// usually the system's Node.js version.
|
|
12
9
|
// If the user Node version does not satisfy our supported engine range use our own system Node version
|
|
13
10
|
export const addPluginsNodeVersion = function ({ pluginsOptions, nodePath, userNodeVersion }) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
currentNodeVersion,
|
|
24
|
-
userNodeVersion,
|
|
25
|
-
nodePath,
|
|
26
|
-
}) {
|
|
27
|
-
return (loadedFrom === 'local' || loadedFrom === 'package.json') &&
|
|
28
|
-
semver.satisfies(userNodeVersion, ROOT_PACKAGE_JSON.engines.node)
|
|
29
|
-
? { ...pluginOptions, nodePath, nodeVersion: userNodeVersion }
|
|
30
|
-
: { ...pluginOptions, nodePath: execPath, nodeVersion: currentNodeVersion }
|
|
31
|
-
}
|
|
32
|
-
|
|
11
|
+
const currentNodeVersion = semver.clean(currentVersion);
|
|
12
|
+
return pluginsOptions.map((pluginOptions) => addPluginNodeVersion({ pluginOptions, currentNodeVersion, userNodeVersion, nodePath }));
|
|
13
|
+
};
|
|
14
|
+
const addPluginNodeVersion = function ({ pluginOptions, pluginOptions: { loadedFrom }, currentNodeVersion, userNodeVersion, nodePath, }) {
|
|
15
|
+
return (loadedFrom === 'local' || loadedFrom === 'package.json') &&
|
|
16
|
+
semver.satisfies(userNodeVersion, ROOT_PACKAGE_JSON.engines.node)
|
|
17
|
+
? { ...pluginOptions, nodePath, nodeVersion: userNodeVersion }
|
|
18
|
+
: { ...pluginOptions, nodePath: execPath, nodeVersion: currentNodeVersion };
|
|
19
|
+
};
|
|
33
20
|
// Ensure Node.js version is compatible with plugin's `engines.node`
|
|
34
|
-
export const checkNodeVersion = function ({
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (pluginNodeVersionRange && !semver.satisfies(nodeVersion, pluginNodeVersionRange)) {
|
|
40
|
-
throwUserError(
|
|
41
|
-
`The Node.js version is ${nodeVersion} but the plugin "${packageName}" requires ${pluginNodeVersionRange}`,
|
|
42
|
-
)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
21
|
+
export const checkNodeVersion = function ({ nodeVersion, packageName, pluginPackageJson: { engines: { node: pluginNodeVersionRange } = {} } = {}, }) {
|
|
22
|
+
if (pluginNodeVersionRange && !semver.satisfies(nodeVersion, pluginNodeVersionRange)) {
|
|
23
|
+
throwUserError(`The Node.js version is ${nodeVersion} but the plugin "${packageName}" requires ${pluginNodeVersionRange}`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
46
26
|
const throwUserError = function (message) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
27
|
+
const error = new Error(message);
|
|
28
|
+
addErrorInfo(error, { type: 'resolveConfig' });
|
|
29
|
+
throw error;
|
|
30
|
+
};
|
package/lib/plugins/options.js
CHANGED
|
@@ -1,88 +1,55 @@
|
|
|
1
|
-
import { dirname } from 'path'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import { checkNodeVersion } from './node_version.js'
|
|
10
|
-
import { resolvePluginsPath } from './resolve.js'
|
|
11
|
-
|
|
1
|
+
import { dirname } from 'path';
|
|
2
|
+
import { installLocalPluginsDependencies } from '../install/local.js';
|
|
3
|
+
import { measureDuration } from '../time/main.js';
|
|
4
|
+
import { ROOT_PACKAGE_JSON } from '../utils/json.js';
|
|
5
|
+
import { getPackageJson } from '../utils/package.js';
|
|
6
|
+
import { useManifest } from './manifest/main.js';
|
|
7
|
+
import { checkNodeVersion } from './node_version.js';
|
|
8
|
+
import { resolvePluginsPath } from './resolve.js';
|
|
12
9
|
// Load core plugins and user plugins
|
|
13
|
-
const tGetPluginsOptions = async function ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
userNodeVersion,
|
|
36
|
-
mode,
|
|
37
|
-
api,
|
|
38
|
-
logs,
|
|
39
|
-
debug,
|
|
40
|
-
sendStatus,
|
|
41
|
-
testOpts,
|
|
42
|
-
featureFlags,
|
|
43
|
-
})
|
|
44
|
-
const pluginsOptionsB = await Promise.all(
|
|
45
|
-
pluginsOptionsA.map((pluginOptions) => loadPluginFiles({ pluginOptions, debug })),
|
|
46
|
-
)
|
|
47
|
-
const pluginsOptionsC = pluginsOptionsB.filter(isNotRedundantCorePlugin)
|
|
48
|
-
await installLocalPluginsDependencies({ plugins, pluginsOptions: pluginsOptionsC, buildDir, mode, logs })
|
|
49
|
-
return { pluginsOptions: pluginsOptionsC }
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const getPluginsOptions = measureDuration(tGetPluginsOptions, 'get_plugins_options')
|
|
53
|
-
|
|
10
|
+
const tGetPluginsOptions = async function ({ pluginsOptions, netlifyConfig: { plugins }, siteInfo, buildDir, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, }) {
|
|
11
|
+
const pluginsOptionsA = await resolvePluginsPath({
|
|
12
|
+
pluginsOptions,
|
|
13
|
+
siteInfo,
|
|
14
|
+
buildDir,
|
|
15
|
+
nodePath,
|
|
16
|
+
packageJson,
|
|
17
|
+
userNodeVersion,
|
|
18
|
+
mode,
|
|
19
|
+
api,
|
|
20
|
+
logs,
|
|
21
|
+
debug,
|
|
22
|
+
sendStatus,
|
|
23
|
+
testOpts,
|
|
24
|
+
featureFlags,
|
|
25
|
+
});
|
|
26
|
+
const pluginsOptionsB = await Promise.all(pluginsOptionsA.map((pluginOptions) => loadPluginFiles({ pluginOptions, debug })));
|
|
27
|
+
const pluginsOptionsC = pluginsOptionsB.filter(isNotRedundantCorePlugin);
|
|
28
|
+
await installLocalPluginsDependencies({ plugins, pluginsOptions: pluginsOptionsC, buildDir, mode, logs });
|
|
29
|
+
return { pluginsOptions: pluginsOptionsC };
|
|
30
|
+
};
|
|
31
|
+
export const getPluginsOptions = measureDuration(tGetPluginsOptions, 'get_plugins_options');
|
|
54
32
|
// Retrieve plugin's main file path.
|
|
55
33
|
// Then load plugin's `package.json` and `manifest.yml`.
|
|
56
|
-
const loadPluginFiles = async function ({
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
checkNodeVersion({ nodeVersion, packageName, pluginPackageJson })
|
|
64
|
-
const { manifest, inputs } = await useManifest(pluginOptions, { pluginDir, packageDir, pluginPackageJson, debug })
|
|
65
|
-
return { ...pluginOptions, pluginDir, packageDir, pluginPackageJson, manifest, inputs }
|
|
66
|
-
}
|
|
67
|
-
|
|
34
|
+
const loadPluginFiles = async function ({ pluginOptions, pluginOptions: { pluginPath, nodeVersion, packageName }, debug, }) {
|
|
35
|
+
const pluginDir = dirname(pluginPath);
|
|
36
|
+
const { packageDir, packageJson: pluginPackageJson } = await getPackageJson(pluginDir);
|
|
37
|
+
checkNodeVersion({ nodeVersion, packageName, pluginPackageJson });
|
|
38
|
+
const { manifest, inputs } = await useManifest(pluginOptions, { pluginDir, packageDir, pluginPackageJson, debug });
|
|
39
|
+
return { ...pluginOptions, pluginDir, packageDir, pluginPackageJson, manifest, inputs };
|
|
40
|
+
};
|
|
68
41
|
// Core plugins can only be included once.
|
|
69
42
|
// For example, when testing core plugins, they might be included as local plugins,
|
|
70
43
|
// in which case they should not be included twice.
|
|
71
44
|
const isNotRedundantCorePlugin = function (pluginOptionsA, index, pluginsOptions) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
(pluginOptionsB) =>
|
|
76
|
-
pluginOptionsA.manifest.name !== pluginOptionsB.manifest.name || pluginOptionsA === pluginOptionsB,
|
|
77
|
-
)
|
|
78
|
-
)
|
|
79
|
-
}
|
|
80
|
-
|
|
45
|
+
return (pluginOptionsA.loadedFrom !== 'core' ||
|
|
46
|
+
pluginsOptions.every((pluginOptionsB) => pluginOptionsA.manifest.name !== pluginOptionsB.manifest.name || pluginOptionsA === pluginOptionsB));
|
|
47
|
+
};
|
|
81
48
|
// Retrieve information about @netlify/build when an error happens there and not
|
|
82
49
|
// in a plugin
|
|
83
50
|
export const getSpawnInfo = function () {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
51
|
+
return {
|
|
52
|
+
plugin: { packageName: ROOT_PACKAGE_JSON.name, pluginPackageJson: ROOT_PACKAGE_JSON },
|
|
53
|
+
location: { event: 'load', packageName: ROOT_PACKAGE_JSON.name, loadedFrom: 'core', origin: 'core' },
|
|
54
|
+
};
|
|
55
|
+
};
|