@netlify/build 28.1.5 → 28.1.7

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.
@@ -2,8 +2,10 @@ import { addPluginLoadErrorStatus } from '../../status/load_error.js';
2
2
  import { checkInputs } from './check.js';
3
3
  import { loadManifest } from './load.js';
4
4
  import { getManifestPath } from './path.js';
5
- // Load plugin's `manifest.yml`
6
- export const useManifest = async function ({ packageName, loadedFrom, origin, inputs }, { pluginDir, packageDir, pluginPackageJson, pluginPackageJson: { version }, debug }) {
5
+ /**
6
+ * Load plugin's `manifest.yml`
7
+ */
8
+ export const useManifest = async function ({ packageName, loadedFrom, origin, inputs, }, { pluginDir, packageDir, pluginPackageJson, pluginPackageJson: { version }, debug, }) {
7
9
  const manifestPath = await getManifestPath({ pluginDir, packageDir, packageName });
8
10
  try {
9
11
  const manifest = await loadManifest({ manifestPath, packageName, pluginPackageJson, loadedFrom, origin });
@@ -1,7 +1,8 @@
1
- import { version as currentVersion, execPath } from 'process';
1
+ import { execPath, version as currentVersion } from 'process';
2
2
  import semver from 'semver';
3
- import { addErrorInfo } from '../error/info.js';
4
- import { ROOT_PACKAGE_JSON } from '../utils/json.js';
3
+ // This node version is minimum required to use ESModules so if the user's preferred Node.js version is below that
4
+ // we have to fall back to the system node version
5
+ const MINIMUM_REQUIRED_NODE_VERSION = '^12.20.0 || ^14.14.0 || >=16.0.0';
5
6
  // Local plugins and `package.json`-installed plugins use user's preferred Node.js version if higher than our minimum
6
7
  // supported version. Else default to the system Node version.
7
8
  // Local and programmatic builds use `@netlify/build` Node.js version, which is
@@ -13,18 +14,7 @@ export const addPluginsNodeVersion = function ({ pluginsOptions, nodePath, userN
13
14
  };
14
15
  const addPluginNodeVersion = function ({ pluginOptions, pluginOptions: { loadedFrom }, currentNodeVersion, userNodeVersion, nodePath, }) {
15
16
  return (loadedFrom === 'local' || loadedFrom === 'package.json') &&
16
- semver.satisfies(userNodeVersion, ROOT_PACKAGE_JSON.engines.node)
17
+ semver.satisfies(userNodeVersion, MINIMUM_REQUIRED_NODE_VERSION)
17
18
  ? { ...pluginOptions, nodePath, nodeVersion: userNodeVersion }
18
19
  : { ...pluginOptions, nodePath: execPath, nodeVersion: currentNodeVersion };
19
20
  };
20
- // Ensure Node.js version is compatible with plugin's `engines.node`
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
- };
26
- const throwUserError = function (message) {
27
- const error = new Error(message);
28
- addErrorInfo(error, { type: 'resolveConfig' });
29
- throw error;
30
- };
@@ -1,10 +1,11 @@
1
1
  import { dirname } from 'path';
2
+ import semver from 'semver';
3
+ import { addErrorInfo } from '../error/info.js';
2
4
  import { installLocalPluginsDependencies } from '../install/local.js';
3
5
  import { measureDuration } from '../time/main.js';
4
6
  import { ROOT_PACKAGE_JSON } from '../utils/json.js';
5
7
  import { getPackageJson } from '../utils/package.js';
6
8
  import { useManifest } from './manifest/main.js';
7
- import { checkNodeVersion } from './node_version.js';
8
9
  import { resolvePluginsPath } from './resolve.js';
9
10
  // Load core plugins and user plugins
10
11
  const tGetPluginsOptions = async function ({ pluginsOptions, netlifyConfig: { plugins }, siteInfo, buildDir, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, }) {
@@ -34,7 +35,11 @@ export const getPluginsOptions = measureDuration(tGetPluginsOptions, 'get_plugin
34
35
  const loadPluginFiles = async function ({ pluginOptions, pluginOptions: { pluginPath, nodeVersion, packageName }, debug, }) {
35
36
  const pluginDir = dirname(pluginPath);
36
37
  const { packageDir, packageJson: pluginPackageJson } = await getPackageJson(pluginDir);
37
- checkNodeVersion({ nodeVersion, packageName, pluginPackageJson });
38
+ // Ensure Node.js version is compatible with plugin's `engines.node`
39
+ const pluginNodeVersionRange = pluginPackageJson?.engines?.node;
40
+ if (pluginNodeVersionRange && !semver.satisfies(nodeVersion, pluginNodeVersionRange)) {
41
+ throwUserError(`The Node.js version is ${nodeVersion} but the plugin "${packageName}" requires ${pluginNodeVersionRange}`);
42
+ }
38
43
  const { manifest, inputs } = await useManifest(pluginOptions, { pluginDir, packageDir, pluginPackageJson, debug });
39
44
  return { ...pluginOptions, pluginDir, packageDir, pluginPackageJson, manifest, inputs };
40
45
  };
@@ -45,11 +50,16 @@ const isNotRedundantCorePlugin = function (pluginOptionsA, index, pluginsOptions
45
50
  return (pluginOptionsA.loadedFrom !== 'core' ||
46
51
  pluginsOptions.every((pluginOptionsB) => pluginOptionsA.manifest.name !== pluginOptionsB.manifest.name || pluginOptionsA === pluginOptionsB));
47
52
  };
48
- // Retrieve information about @netlify/build when an error happens there and not
49
- // in a plugin
50
- export const getSpawnInfo = function () {
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
- };
53
+ /**
54
+ * Retrieve information about @netlify/build when an error happens there and not
55
+ * in a plugin
56
+ */
57
+ export const getSpawnInfo = () => ({
58
+ plugin: { packageName: ROOT_PACKAGE_JSON.name, pluginPackageJson: ROOT_PACKAGE_JSON },
59
+ location: { event: 'load', packageName: ROOT_PACKAGE_JSON.name, loadedFrom: 'core', origin: 'core' },
60
+ });
61
+ const throwUserError = function (message) {
62
+ const error = new Error(message);
63
+ addErrorInfo(error, { type: 'resolveConfig' });
64
+ throw error;
55
65
  };
package/lib/utils/json.js CHANGED
@@ -4,12 +4,12 @@ const ROOT_PACKAGE_JSON_PATH = fileURLToPath(new URL('../../package.json', impor
4
4
  // TODO: Replace with dynamic `import()` once it is supported without
5
5
  // experimental flags
6
6
  export const importJsonFile = async function (filePath) {
7
- const fileContents = await fs.readFile(filePath);
7
+ const fileContents = await fs.readFile(filePath, 'utf-8');
8
8
  return JSON.parse(fileContents);
9
9
  };
10
10
  const importJsonFileSync = function (filePath) {
11
11
  // Use sync I/O so it is easier to migrate to `import()` later on
12
- const fileContents = readFileSync(filePath, 'utf8');
12
+ const fileContents = readFileSync(filePath, 'utf-8');
13
13
  return JSON.parse(fileContents);
14
14
  };
15
15
  export const ROOT_PACKAGE_JSON = importJsonFileSync(ROOT_PACKAGE_JSON_PATH);
package/lib/utils/omit.js CHANGED
@@ -1,5 +1,3 @@
1
1
  import filterObj from 'filter-obj';
2
2
  // lodash.omit is 1400 lines of codes. filter-obj is much smaller and simpler.
3
- export const omit = function (obj, keys) {
4
- return filterObj(obj, (key) => !keys.includes(key));
5
- };
3
+ export const omit = (obj, keys) => filterObj(obj, (key) => !keys.includes(key));
@@ -1,22 +1,22 @@
1
1
  import { dirname } from 'path';
2
2
  import { readPackageUp } from 'read-pkg-up';
3
- // Retrieve `package.json` from a specific directory
4
- export const getPackageJson = async function (cwd, { normalize } = {}) {
5
- const packageObj = await getPackageObj({ cwd, normalize });
6
- if (packageObj === undefined) {
7
- return { packageJson: {} };
8
- }
9
- const { path, packageJson } = packageObj;
10
- const packageDir = dirname(path);
11
- return { packageDir, packageJson };
12
- };
13
- const getPackageObj = async function ({ cwd, normalize = true }) {
3
+ /**
4
+ * Retrieve `package.json` from a specific directory
5
+ */
6
+ export const getPackageJson = async function (cwd, options = {}) {
7
+ const result = {
8
+ packageJson: {},
9
+ };
14
10
  try {
15
- return await readPackageUp({ cwd, normalize });
16
- // If the `package.json` is invalid and `normalize` is `true`, an error is
17
- // thrown. We return `undefined` then.
11
+ const { path, packageJson } = await readPackageUp({
12
+ cwd,
13
+ ...Object.assign({ normalize: true }, options),
14
+ });
15
+ result.packageJson = packageJson;
16
+ result.packageDir = dirname(path);
18
17
  }
19
18
  catch {
20
19
  // continue regardless error
21
20
  }
21
+ return result;
22
22
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "28.1.5",
3
+ "version": "28.1.7",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./lib/core/main.js",
@@ -65,7 +65,7 @@
65
65
  "dependencies": {
66
66
  "@bugsnag/js": "^7.0.0",
67
67
  "@netlify/cache-utils": "^5.0.1",
68
- "@netlify/config": "^19.1.1",
68
+ "@netlify/config": "^19.1.2",
69
69
  "@netlify/edge-bundler": "^3.0.1",
70
70
  "@netlify/functions-utils": "^5.0.1",
71
71
  "@netlify/git-utils": "^5.0.1",
@@ -113,7 +113,7 @@
113
113
  "supports-color": "^9.0.0",
114
114
  "tmp-promise": "^3.0.2",
115
115
  "ts-node": "^10.6.0",
116
- "typescript": "^4.5.4",
116
+ "typescript": "^4.8.4",
117
117
  "update-notifier": "^5.0.0",
118
118
  "uuid": "^8.0.0",
119
119
  "yargs": "^17.6.0"
@@ -140,7 +140,6 @@
140
140
  "process-exists": "^5.0.0",
141
141
  "sinon": "^13.0.0",
142
142
  "tsd": "^0.24.1",
143
- "typescript": "^4.8.4",
144
143
  "yarn": "^1.22.4"
145
144
  },
146
145
  "engines": {
@@ -151,5 +150,5 @@
151
150
  "module": "commonjs"
152
151
  }
153
152
  },
154
- "gitHead": "a17c26b151dd163548b4c8f9d6836ff290305a4a"
153
+ "gitHead": "452f62c69334ac40ef33156baea0d6bd64f20394"
155
154
  }