@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.
Files changed (133) hide show
  1. package/lib/core/bin.js +42 -59
  2. package/lib/core/build.js +333 -536
  3. package/lib/core/config.js +94 -159
  4. package/lib/core/constants.js +95 -135
  5. package/lib/core/dev.js +26 -30
  6. package/lib/core/dry.js +18 -36
  7. package/lib/core/feature_flags.js +13 -16
  8. package/lib/core/flags.js +168 -169
  9. package/lib/core/lingering.js +44 -61
  10. package/lib/core/main.js +94 -136
  11. package/lib/core/missing_side_file.js +12 -24
  12. package/lib/core/normalize_flags.js +52 -63
  13. package/lib/core/severity.js +13 -15
  14. package/lib/core/user_node_version.js +26 -35
  15. package/lib/env/changes.js +29 -37
  16. package/lib/env/main.js +10 -15
  17. package/lib/env/metadata.js +63 -76
  18. package/lib/error/api.js +31 -40
  19. package/lib/error/build.js +27 -38
  20. package/lib/error/cancel.js +5 -6
  21. package/lib/error/colors.js +7 -9
  22. package/lib/error/handle.js +38 -49
  23. package/lib/error/info.js +26 -35
  24. package/lib/error/monitor/location.js +12 -17
  25. package/lib/error/monitor/normalize.js +75 -85
  26. package/lib/error/monitor/print.js +19 -41
  27. package/lib/error/monitor/report.js +102 -121
  28. package/lib/error/monitor/start.js +43 -56
  29. package/lib/error/parse/clean_stack.js +52 -69
  30. package/lib/error/parse/location.js +40 -52
  31. package/lib/error/parse/normalize.js +18 -23
  32. package/lib/error/parse/parse.js +59 -93
  33. package/lib/error/parse/plugin.js +42 -57
  34. package/lib/error/parse/properties.js +13 -20
  35. package/lib/error/parse/serialize_log.js +29 -37
  36. package/lib/error/parse/serialize_status.js +15 -23
  37. package/lib/error/parse/stack.js +29 -38
  38. package/lib/error/type.js +132 -150
  39. package/lib/install/functions.js +16 -24
  40. package/lib/install/local.js +31 -48
  41. package/lib/install/main.js +52 -66
  42. package/lib/install/missing.js +40 -53
  43. package/lib/log/colors.js +15 -22
  44. package/lib/log/description.js +16 -21
  45. package/lib/log/header.js +11 -13
  46. package/lib/log/header_func.js +11 -15
  47. package/lib/log/logger.js +88 -119
  48. package/lib/log/messages/compatibility.js +100 -158
  49. package/lib/log/messages/config.js +76 -92
  50. package/lib/log/messages/core.js +40 -60
  51. package/lib/log/messages/core_steps.js +63 -92
  52. package/lib/log/messages/dry.js +31 -53
  53. package/lib/log/messages/install.js +21 -28
  54. package/lib/log/messages/ipc.js +21 -30
  55. package/lib/log/messages/mutations.js +51 -71
  56. package/lib/log/messages/plugins.js +18 -31
  57. package/lib/log/messages/status.js +12 -14
  58. package/lib/log/messages/steps.js +14 -18
  59. package/lib/log/old_version.js +23 -32
  60. package/lib/log/serialize.js +7 -10
  61. package/lib/log/stream.js +48 -65
  62. package/lib/log/theme.js +22 -23
  63. package/lib/plugins/child/diff.js +31 -40
  64. package/lib/plugins/child/error.js +20 -26
  65. package/lib/plugins/child/lazy.js +11 -14
  66. package/lib/plugins/child/load.js +15 -22
  67. package/lib/plugins/child/logic.js +51 -58
  68. package/lib/plugins/child/main.js +32 -46
  69. package/lib/plugins/child/run.js +18 -27
  70. package/lib/plugins/child/status.js +52 -63
  71. package/lib/plugins/child/typescript.js +19 -36
  72. package/lib/plugins/child/utils.js +36 -49
  73. package/lib/plugins/child/validate.js +25 -28
  74. package/lib/plugins/compatibility.js +64 -92
  75. package/lib/plugins/error.js +29 -35
  76. package/lib/plugins/events.js +7 -12
  77. package/lib/plugins/expected_version.js +61 -99
  78. package/lib/plugins/ipc.js +79 -102
  79. package/lib/plugins/list.js +49 -62
  80. package/lib/plugins/load.js +44 -64
  81. package/lib/plugins/manifest/check.js +64 -85
  82. package/lib/plugins/manifest/load.js +34 -37
  83. package/lib/plugins/manifest/main.js +16 -21
  84. package/lib/plugins/manifest/path.js +18 -25
  85. package/lib/plugins/manifest/validate.js +77 -94
  86. package/lib/plugins/node_version.js +22 -42
  87. package/lib/plugins/options.js +45 -78
  88. package/lib/plugins/pinned_version.js +58 -106
  89. package/lib/plugins/resolve.js +91 -133
  90. package/lib/plugins/spawn.js +43 -61
  91. package/lib/plugins_core/add.js +26 -40
  92. package/lib/plugins_core/build_command.js +47 -72
  93. package/lib/plugins_core/deploy/buildbot_client.js +61 -87
  94. package/lib/plugins_core/deploy/index.js +47 -71
  95. package/lib/plugins_core/edge_functions/index.js +73 -116
  96. package/lib/plugins_core/edge_functions/lib/error.js +13 -17
  97. package/lib/plugins_core/edge_functions/lib/internal_manifest.js +45 -55
  98. package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +65 -80
  99. package/lib/plugins_core/functions/error.js +88 -128
  100. package/lib/plugins_core/functions/feature_flags.js +5 -5
  101. package/lib/plugins_core/functions/index.js +98 -145
  102. package/lib/plugins_core/functions/utils.js +36 -57
  103. package/lib/plugins_core/functions/zisi.js +35 -52
  104. package/lib/plugins_core/functions_install/index.js +8 -11
  105. package/lib/plugins_core/list.js +15 -22
  106. package/lib/status/add.js +26 -32
  107. package/lib/status/colors.js +14 -19
  108. package/lib/status/load_error.js +8 -9
  109. package/lib/status/report.js +72 -126
  110. package/lib/status/success.js +10 -14
  111. package/lib/steps/core_step.js +54 -89
  112. package/lib/steps/error.js +50 -87
  113. package/lib/steps/get.js +33 -41
  114. package/lib/steps/plugin.js +53 -83
  115. package/lib/steps/return.js +24 -51
  116. package/lib/steps/run_core_steps.js +119 -171
  117. package/lib/steps/run_step.js +154 -270
  118. package/lib/steps/run_steps.js +91 -174
  119. package/lib/steps/update_config.js +45 -72
  120. package/lib/telemetry/main.js +89 -128
  121. package/lib/time/aggregate.js +84 -110
  122. package/lib/time/main.js +23 -34
  123. package/lib/time/measure.js +11 -15
  124. package/lib/time/report.js +32 -44
  125. package/lib/utils/errors.js +10 -9
  126. package/lib/utils/json.js +11 -15
  127. package/lib/utils/omit.js +3 -4
  128. package/lib/utils/package.js +19 -22
  129. package/lib/utils/remove_falsy.js +5 -7
  130. package/lib/utils/resolve.js +30 -34
  131. package/lib/utils/runtime.js +4 -4
  132. package/lib/utils/semver.js +19 -25
  133. package/package.json +15 -8
@@ -1,41 +1,38 @@
1
- import { promises as fs } from 'fs'
2
-
3
- import { load as loadYaml, JSON_SCHEMA } from 'js-yaml'
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
- try {
12
- const rawManifest = await loadRawManifest(manifestPath)
13
- const manifest = await parseManifest(rawManifest)
14
- validateManifest(manifest, rawManifest)
15
- return manifest
16
- } catch (error) {
17
- addErrorInfo(error, {
18
- type: 'pluginValidation',
19
- plugin: { packageName, pluginPackageJson },
20
- location: { event: 'load', packageName, loadedFrom, origin },
21
- })
22
- throw error
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
- try {
28
- return await fs.readFile(manifestPath, 'utf8')
29
- } catch (error) {
30
- error.message = `Could not load plugin's "manifest.yml"\n${error.message}`
31
- throw error
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
- try {
37
- return await loadYaml(rawManifest, { schema: JSON_SCHEMA, json: true })
38
- } catch (error) {
39
- throw new Error(`Could not parse plugin's "manifest.yml"\n${error.message}`)
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 { checkInputs } from './check.js'
4
- import { loadManifest } from './load.js'
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
- { packageName, loadedFrom, origin, inputs },
10
- { pluginDir, packageDir, pluginPackageJson, pluginPackageJson: { version }, debug },
11
- ) {
12
- const manifestPath = await getManifestPath({ pluginDir, packageDir, packageName })
13
-
14
- try {
15
- const manifest = await loadManifest({ manifestPath, packageName, pluginPackageJson, loadedFrom, origin })
16
- const inputsA = checkInputs({ inputs, manifest, packageName, pluginPackageJson, loadedFrom, origin })
17
- return { manifest, inputs: inputsA }
18
- } catch (error) {
19
- addPluginLoadErrorStatus({ error, packageName, version, debug })
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
- const dirs = [pluginDir, packageDir]
8
- .filter(Boolean)
9
- .flatMap((dir) => MANIFEST_FILENAMES.map((filename) => `${dir}/${filename}`))
10
- const manifestPath = await locatePath(dirs)
11
- validateManifestExists(manifestPath, packageName)
12
- return manifestPath
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
- if (manifestPath !== undefined) {
17
- return
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
- addErrorInfo(error, { type: 'resolveConfig' })
28
- throw error
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
- try {
8
- validateBasic(manifest)
9
- validateUnknownProps(manifest)
10
- validateName(manifest)
11
- validateInputs(manifest)
12
- } catch (error) {
13
- error.message = `Plugin's "manifest.yml" ${error.message}
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
- throw error
18
- }
19
- }
20
-
15
+ ${rawManifest.trim()}`;
16
+ throw error;
17
+ }
18
+ };
21
19
  const validateBasic = function (manifest) {
22
- if (!isPlainObj(manifest)) {
23
- throw new Error('must be a plain object')
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
- const unknownProp = Object.keys(manifest).find((key) => !VALID_PROPS.has(key))
29
- if (unknownProp !== undefined) {
30
- throw new Error(`unknown property "${unknownProp}"`)
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
- if (name === undefined) {
38
- throw new Error('must contain a "name" property')
39
- }
40
-
41
- if (typeof name !== 'string') {
42
- throw new TypeError('"name" property must be a string')
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
- if (inputs === undefined) {
48
- return
49
- }
50
-
51
- if (!isArrayOfObjects(inputs)) {
52
- throw new Error('"inputs" property must be an array of objects')
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
- return Array.isArray(objects) && objects.every(isPlainObj)
60
- }
61
-
49
+ return Array.isArray(objects) && objects.every(isPlainObj);
50
+ };
62
51
  const validateInput = function (input, index) {
63
- try {
64
- validateUnknownInputProps(input)
65
- validateInputName(input)
66
- validateInputDescription(input)
67
- validateInputRequired(input)
68
- } catch (error) {
69
- error.message = `"inputs" property is invalid.
70
- Input at position ${index} ${error.message}.`
71
- throw error
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
- const unknownProp = Object.keys(input).find((key) => !VALID_INPUT_PROPS.has(key))
77
- if (unknownProp !== undefined) {
78
- throw new Error(`has an unknown property "${unknownProp}"`)
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
- if (name === undefined) {
86
- throw new Error('must contain a "name" property')
87
- }
88
-
89
- if (typeof name !== 'string') {
90
- throw new TypeError('"name" property must be a string')
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
- if (description === undefined) {
96
- return
97
- }
98
-
99
- if (typeof description !== 'string') {
100
- throw new TypeError('"description" property must be a string')
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
- if (required !== undefined && typeof required !== 'boolean') {
106
- throw new Error('"required" property must be a boolean')
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 semver from 'semver'
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
- const currentNodeVersion = semver.clean(currentVersion)
15
- return pluginsOptions.map((pluginOptions) =>
16
- addPluginNodeVersion({ pluginOptions, currentNodeVersion, userNodeVersion, nodePath }),
17
- )
18
- }
19
-
20
- const addPluginNodeVersion = function ({
21
- pluginOptions,
22
- pluginOptions: { loadedFrom },
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
- nodeVersion,
36
- packageName,
37
- pluginPackageJson: { engines: { node: pluginNodeVersionRange } = {} } = {},
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
- const error = new Error(message)
48
- addErrorInfo(error, { type: 'resolveConfig' })
49
- throw error
50
- }
27
+ const error = new Error(message);
28
+ addErrorInfo(error, { type: 'resolveConfig' });
29
+ throw error;
30
+ };
@@ -1,88 +1,55 @@
1
- import { dirname } from 'path'
2
-
3
- import { installLocalPluginsDependencies } from '../install/local.js'
4
- import { measureDuration } from '../time/main.js'
5
- import { ROOT_PACKAGE_JSON } from '../utils/json.js'
6
- import { getPackageJson } from '../utils/package.js'
7
-
8
- import { useManifest } from './manifest/main.js'
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
- pluginsOptions,
15
- netlifyConfig: { plugins },
16
- siteInfo,
17
- buildDir,
18
- nodePath,
19
- packageJson,
20
- userNodeVersion,
21
- mode,
22
- api,
23
- logs,
24
- debug,
25
- sendStatus,
26
- testOpts,
27
- featureFlags,
28
- }) {
29
- const pluginsOptionsA = await resolvePluginsPath({
30
- pluginsOptions,
31
- siteInfo,
32
- buildDir,
33
- nodePath,
34
- packageJson,
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
- pluginOptions,
58
- pluginOptions: { pluginPath, nodeVersion, packageName },
59
- debug,
60
- }) {
61
- const pluginDir = dirname(pluginPath)
62
- const { packageDir, packageJson: pluginPackageJson } = await getPackageJson(pluginDir)
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
- return (
73
- pluginOptionsA.loadedFrom !== 'core' ||
74
- pluginsOptions.every(
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
- return {
85
- plugin: { packageName: ROOT_PACKAGE_JSON.name, pluginPackageJson: ROOT_PACKAGE_JSON },
86
- location: { event: 'load', packageName: ROOT_PACKAGE_JSON.name, loadedFrom: 'core', origin: 'core' },
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
+ };