@netlify/build 28.0.1-beta → 28.1.0-framework-version-detection
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/bin.js +5 -0
- package/lib/core/bin.js +66 -0
- package/lib/core/build.js +355 -0
- package/lib/core/config.js +125 -0
- package/lib/core/constants.js +116 -0
- package/lib/core/dev.js +27 -0
- package/lib/core/dry.js +21 -0
- package/lib/core/feature_flags.js +19 -0
- package/lib/core/flags.js +201 -0
- package/lib/core/lingering.js +68 -0
- package/lib/core/main.js +105 -0
- package/lib/core/missing_side_file.js +17 -0
- package/lib/core/normalize_flags.js +59 -0
- package/lib/core/severity.js +21 -0
- package/lib/core/types.js +8 -0
- package/lib/core/user_node_version.js +32 -0
- package/lib/env/changes.js +43 -0
- package/lib/env/main.js +14 -0
- package/lib/env/metadata.js +68 -0
- package/lib/error/api.js +37 -0
- package/lib/error/build.js +36 -0
- package/{src → lib}/error/cancel.js +5 -6
- package/lib/error/colors.js +9 -0
- package/lib/error/handle.js +46 -0
- package/lib/error/info.js +37 -0
- package/lib/error/monitor/location.js +16 -0
- package/lib/error/monitor/normalize.js +86 -0
- package/lib/error/monitor/print.js +20 -0
- package/lib/error/monitor/report.js +120 -0
- package/lib/error/monitor/start.js +61 -0
- package/lib/error/parse/clean_stack.js +70 -0
- package/lib/error/parse/location.js +50 -0
- package/lib/error/parse/normalize.js +24 -0
- package/lib/error/parse/parse.js +67 -0
- package/lib/error/parse/plugin.js +55 -0
- package/lib/error/parse/properties.js +16 -0
- package/lib/error/parse/serialize_log.js +34 -0
- package/lib/error/parse/serialize_status.js +18 -0
- package/lib/error/parse/stack.js +34 -0
- package/lib/error/type.js +171 -0
- package/lib/install/functions.js +20 -0
- package/lib/install/local.js +45 -0
- package/lib/install/main.js +67 -0
- package/lib/install/missing.js +54 -0
- package/{src → lib}/log/colors.js +15 -22
- package/lib/log/description.js +21 -0
- package/lib/log/header.js +14 -0
- package/lib/log/header_func.js +13 -0
- package/lib/log/logger.js +140 -0
- package/lib/log/messages/compatibility.js +120 -0
- package/lib/log/messages/config.js +98 -0
- package/lib/log/messages/core.js +50 -0
- package/lib/log/messages/core_steps.js +75 -0
- package/lib/log/messages/dry.js +41 -0
- package/lib/log/messages/install.js +25 -0
- package/lib/log/messages/ipc.js +29 -0
- package/lib/log/messages/mutations.js +62 -0
- package/{src → lib}/log/messages/plugins.js +18 -32
- package/lib/log/messages/status.js +14 -0
- package/lib/log/messages/steps.js +18 -0
- package/lib/log/old_version.js +32 -0
- package/lib/log/serialize.js +10 -0
- package/lib/log/stream.js +68 -0
- package/lib/log/theme.js +25 -0
- package/lib/plugins/child/diff.js +46 -0
- package/lib/plugins/child/error.js +26 -0
- package/lib/plugins/child/lazy.js +15 -0
- package/lib/plugins/child/load.js +22 -0
- package/lib/plugins/child/logic.js +57 -0
- package/lib/plugins/child/main.js +37 -0
- package/lib/plugins/child/run.js +19 -0
- package/lib/plugins/child/status.js +63 -0
- package/lib/plugins/child/typescript.js +28 -0
- package/lib/plugins/child/utils.js +42 -0
- package/lib/plugins/child/validate.js +31 -0
- package/lib/plugins/compatibility.js +104 -0
- package/{src → lib}/plugins/error.js +31 -35
- package/{src → lib}/plugins/events.js +7 -12
- package/lib/plugins/expected_version.js +81 -0
- package/lib/plugins/ipc.js +120 -0
- package/lib/plugins/list.js +73 -0
- package/lib/plugins/load.js +50 -0
- package/lib/plugins/manifest/check.js +85 -0
- package/lib/plugins/manifest/load.js +38 -0
- package/lib/plugins/manifest/main.js +17 -0
- package/lib/plugins/manifest/path.js +24 -0
- package/lib/plugins/manifest/validate.js +91 -0
- package/lib/plugins/node_version.js +30 -0
- package/lib/plugins/options.js +55 -0
- package/lib/plugins/pinned_version.js +83 -0
- package/lib/plugins/resolve.js +110 -0
- package/lib/plugins/spawn.js +54 -0
- package/lib/plugins_core/add.js +35 -0
- package/lib/plugins_core/build_command.js +50 -0
- package/lib/plugins_core/deploy/buildbot_client.js +87 -0
- package/lib/plugins_core/deploy/index.js +49 -0
- package/{src → lib}/plugins_core/deploy/manifest.yml +0 -0
- package/lib/plugins_core/edge_functions/index.js +79 -0
- package/lib/plugins_core/edge_functions/lib/error.js +17 -0
- package/lib/plugins_core/edge_functions/lib/internal_manifest.js +50 -0
- package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +75 -0
- package/lib/plugins_core/functions/error.js +123 -0
- package/lib/plugins_core/functions/feature_flags.js +6 -0
- package/lib/plugins_core/functions/index.js +114 -0
- package/lib/plugins_core/functions/utils.js +45 -0
- package/lib/plugins_core/functions/zisi.js +39 -0
- package/{src → lib}/plugins_core/functions_install/index.js +8 -11
- package/{src → lib}/plugins_core/functions_install/manifest.yml +0 -0
- package/lib/plugins_core/list.js +20 -0
- package/lib/status/add.js +30 -0
- package/lib/status/colors.js +18 -0
- package/lib/status/load_error.js +10 -0
- package/lib/status/report.js +83 -0
- package/lib/status/success.js +14 -0
- package/lib/steps/core_step.js +57 -0
- package/lib/steps/error.js +65 -0
- package/lib/steps/get.js +43 -0
- package/lib/steps/plugin.js +55 -0
- package/lib/steps/return.js +25 -0
- package/lib/steps/run_core_steps.js +126 -0
- package/lib/steps/run_step.js +188 -0
- package/lib/steps/run_steps.js +96 -0
- package/lib/steps/update_config.js +66 -0
- package/lib/telemetry/main.js +97 -0
- package/lib/time/aggregate.js +120 -0
- package/lib/time/main.js +37 -0
- package/lib/time/measure.js +18 -0
- package/lib/time/report.js +47 -0
- package/lib/utils/errors.js +13 -0
- package/lib/utils/json.js +15 -0
- package/{src → lib}/utils/omit.js +3 -4
- package/lib/utils/package.js +22 -0
- package/lib/utils/remove_falsy.js +8 -0
- package/lib/utils/resolve.js +41 -0
- package/lib/utils/runtime.js +5 -0
- package/lib/utils/semver.js +28 -0
- package/package.json +39 -19
- package/types/config/netlify_config.d.ts +4 -4
- package/types/netlify_plugin_constants.d.ts +8 -8
- package/src/core/bin.js +0 -83
- package/src/core/config.js +0 -186
- package/src/core/constants.js +0 -156
- package/src/core/dry.js +0 -39
- package/src/core/feature_flags.js +0 -21
- package/src/core/flags.js +0 -194
- package/src/core/lingering.js +0 -85
- package/src/core/main.js +0 -692
- package/src/core/missing_side_file.js +0 -29
- package/src/core/normalize_flags.js +0 -69
- package/src/core/severity.js +0 -22
- package/src/core/user_node_version.js +0 -41
- package/src/env/changes.js +0 -52
- package/src/env/main.js +0 -19
- package/src/env/metadata.js +0 -81
- package/src/error/api.js +0 -46
- package/src/error/build.js +0 -50
- package/src/error/colors.js +0 -11
- package/src/error/handle.js +0 -57
- package/src/error/info.js +0 -46
- package/src/error/monitor/location.js +0 -21
- package/src/error/monitor/normalize.js +0 -77
- package/src/error/monitor/print.js +0 -42
- package/src/error/monitor/report.js +0 -133
- package/src/error/monitor/start.js +0 -69
- package/src/error/parse/clean_stack.js +0 -87
- package/src/error/parse/location.js +0 -58
- package/src/error/parse/normalize.js +0 -29
- package/src/error/parse/parse.js +0 -97
- package/src/error/parse/plugin.js +0 -70
- package/src/error/parse/properties.js +0 -23
- package/src/error/parse/serialize_log.js +0 -42
- package/src/error/parse/serialize_status.js +0 -23
- package/src/error/parse/stack.js +0 -43
- package/src/error/type.js +0 -182
- package/src/install/functions.js +0 -28
- package/src/install/local.js +0 -62
- package/src/install/main.js +0 -81
- package/src/install/missing.js +0 -67
- package/src/log/description.js +0 -26
- package/src/log/header.js +0 -16
- package/src/log/header_func.js +0 -17
- package/src/log/logger.js +0 -107
- package/src/log/messages/compatibility.js +0 -164
- package/src/log/messages/config.js +0 -105
- package/src/log/messages/core.js +0 -70
- package/src/log/messages/core_steps.js +0 -104
- package/src/log/messages/dry.js +0 -63
- package/src/log/messages/install.js +0 -20
- package/src/log/messages/ipc.js +0 -38
- package/src/log/messages/mutations.js +0 -82
- package/src/log/messages/status.js +0 -16
- package/src/log/messages/steps.js +0 -22
- package/src/log/old_version.js +0 -41
- package/src/log/serialize.js +0 -13
- package/src/log/stream.js +0 -85
- package/src/log/theme.js +0 -26
- package/src/plugins/child/diff.js +0 -55
- package/src/plugins/child/error.js +0 -32
- package/src/plugins/child/lazy.js +0 -18
- package/src/plugins/child/load.js +0 -29
- package/src/plugins/child/logic.js +0 -57
- package/src/plugins/child/main.js +0 -51
- package/src/plugins/child/run.js +0 -28
- package/src/plugins/child/status.js +0 -67
- package/src/plugins/child/typescript.js +0 -45
- package/src/plugins/child/utils.js +0 -56
- package/src/plugins/child/validate.js +0 -34
- package/src/plugins/compatibility.js +0 -128
- package/src/plugins/expected_version.js +0 -119
- package/src/plugins/ipc.js +0 -145
- package/src/plugins/list.js +0 -86
- package/src/plugins/load.js +0 -70
- package/src/plugins/manifest/check.js +0 -106
- package/src/plugins/manifest/load.js +0 -41
- package/src/plugins/manifest/main.js +0 -22
- package/src/plugins/manifest/path.js +0 -31
- package/src/plugins/manifest/validate.js +0 -108
- package/src/plugins/node_version.js +0 -50
- package/src/plugins/options.js +0 -88
- package/src/plugins/pinned_version.js +0 -131
- package/src/plugins/resolve.js +0 -152
- package/src/plugins/spawn.js +0 -66
- package/src/plugins_core/add.js +0 -49
- package/src/plugins_core/build_command.js +0 -75
- package/src/plugins_core/deploy/buildbot_client.js +0 -102
- package/src/plugins_core/deploy/index.js +0 -73
- package/src/plugins_core/edge_functions/index.js +0 -107
- package/src/plugins_core/edge_functions/lib/internal_manifest.js +0 -54
- package/src/plugins_core/functions/error.js +0 -163
- package/src/plugins_core/functions/feature_flags.js +0 -6
- package/src/plugins_core/functions/index.js +0 -160
- package/src/plugins_core/functions/utils.js +0 -66
- package/src/plugins_core/functions/zisi.js +0 -53
- package/src/plugins_core/list.js +0 -27
- package/src/status/add.js +0 -36
- package/src/status/colors.js +0 -23
- package/src/status/load_error.js +0 -11
- package/src/status/report.js +0 -128
- package/src/status/success.js +0 -18
- package/src/steps/core_step.js +0 -90
- package/src/steps/error.js +0 -102
- package/src/steps/get.js +0 -32
- package/src/steps/plugin.js +0 -85
- package/src/steps/return.js +0 -52
- package/src/steps/run_core_steps.js +0 -194
- package/src/steps/run_step.js +0 -300
- package/src/steps/run_steps.js +0 -179
- package/src/steps/update_config.js +0 -93
- package/src/telemetry/main.js +0 -136
- package/src/time/aggregate.js +0 -146
- package/src/time/main.js +0 -48
- package/src/time/measure.js +0 -22
- package/src/time/report.js +0 -59
- package/src/utils/errors.js +0 -12
- package/src/utils/json.js +0 -19
- package/src/utils/package.js +0 -23
- package/src/utils/remove_falsy.js +0 -10
- package/src/utils/resolve.js +0 -46
- package/src/utils/semver.js +0 -34
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// Wrap an async function so it prepends an error message on exceptions.
|
|
2
|
+
// This helps locate errors.
|
|
3
|
+
export const addAsyncErrorMessage = function (asyncFunc, message) {
|
|
4
|
+
return async (...args) => {
|
|
5
|
+
try {
|
|
6
|
+
return await asyncFunc(...args);
|
|
7
|
+
}
|
|
8
|
+
catch (error) {
|
|
9
|
+
error.stack = `${message}: ${error.stack}`;
|
|
10
|
+
throw error;
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { promises as fs, readFileSync } from 'fs';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
const ROOT_PACKAGE_JSON_PATH = fileURLToPath(new URL('../../package.json', import.meta.url));
|
|
4
|
+
// TODO: Replace with dynamic `import()` once it is supported without
|
|
5
|
+
// experimental flags
|
|
6
|
+
export const importJsonFile = async function (filePath) {
|
|
7
|
+
const fileContents = await fs.readFile(filePath);
|
|
8
|
+
return JSON.parse(fileContents);
|
|
9
|
+
};
|
|
10
|
+
const importJsonFileSync = function (filePath) {
|
|
11
|
+
// Use sync I/O so it is easier to migrate to `import()` later on
|
|
12
|
+
const fileContents = readFileSync(filePath, 'utf8');
|
|
13
|
+
return JSON.parse(fileContents);
|
|
14
|
+
};
|
|
15
|
+
export const ROOT_PACKAGE_JSON = importJsonFileSync(ROOT_PACKAGE_JSON_PATH);
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import filterObj from 'filter-obj'
|
|
2
|
-
|
|
1
|
+
import filterObj from 'filter-obj';
|
|
3
2
|
// lodash.omit is 1400 lines of codes. filter-obj is much smaller and simpler.
|
|
4
3
|
export const omit = function (obj, keys) {
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
return filterObj(obj, (key) => !keys.includes(key));
|
|
5
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { dirname } from 'path';
|
|
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 }) {
|
|
14
|
+
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.
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
// continue regardless error
|
|
21
|
+
}
|
|
22
|
+
};
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { async as resolveLib } from 'resolve';
|
|
3
|
+
// TODO: use `import.resolve()` once it is available without any experimental
|
|
4
|
+
// flags
|
|
5
|
+
const require = createRequire(import.meta.url);
|
|
6
|
+
// Like `resolvePath()` but does not throw
|
|
7
|
+
export const tryResolvePath = async function (path, basedir) {
|
|
8
|
+
try {
|
|
9
|
+
const resolvedPath = await resolvePath(path, basedir);
|
|
10
|
+
return { path: resolvedPath };
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
return { error };
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
// This throws if the package cannot be found
|
|
17
|
+
export const resolvePath = async function (path, basedir) {
|
|
18
|
+
try {
|
|
19
|
+
return await resolvePathWithBasedir(path, basedir);
|
|
20
|
+
// Fallback.
|
|
21
|
+
// `resolve` sometimes gives unhelpful error messages.
|
|
22
|
+
// https://github.com/browserify/resolve/issues/223
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return require.resolve(path, { paths: [basedir] });
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
// Like `require.resolve()` but as an external library.
|
|
29
|
+
// We need to use `new Promise()` due to a bug with `utils.promisify()` on
|
|
30
|
+
// `resolve`:
|
|
31
|
+
// https://github.com/browserify/resolve/issues/151#issuecomment-368210310
|
|
32
|
+
const resolvePathWithBasedir = function (path, basedir) {
|
|
33
|
+
return new Promise((resolve, reject) => {
|
|
34
|
+
resolveLib(path, { basedir }, (error, resolvedPath) => {
|
|
35
|
+
if (error) {
|
|
36
|
+
return reject(error);
|
|
37
|
+
}
|
|
38
|
+
resolve(resolvedPath);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import semver from 'semver';
|
|
2
|
+
// Compare two versions by their major versions.
|
|
3
|
+
// Takes into account the special rules for `0.*.*` and `0.0.*` versions.
|
|
4
|
+
export const isPreviousMajor = function (versionA, versionB) {
|
|
5
|
+
return semver.lt(getMajor(versionA), getMajor(versionB));
|
|
6
|
+
};
|
|
7
|
+
// Remove minor/patch numbers
|
|
8
|
+
const getMajor = function (version) {
|
|
9
|
+
return semver.minVersion(getMajorVersion(version)).version;
|
|
10
|
+
};
|
|
11
|
+
// According to semver, the second number is the major release number for
|
|
12
|
+
// `0.*.*` versions and the third for `0.0.*`. This is how `^` behaves with the
|
|
13
|
+
// `semver` module which is used by `npm`.
|
|
14
|
+
export const getMajorVersion = function (version) {
|
|
15
|
+
if (!version || semver.clean(version) === null) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const majorVersion = semver.major(version);
|
|
19
|
+
if (majorVersion !== 0) {
|
|
20
|
+
return `${majorVersion}`;
|
|
21
|
+
}
|
|
22
|
+
const minorVersion = semver.minor(version);
|
|
23
|
+
if (minorVersion !== 0) {
|
|
24
|
+
return `${majorVersion}.${minorVersion}`;
|
|
25
|
+
}
|
|
26
|
+
const patchVersion = semver.patch(version);
|
|
27
|
+
return `${majorVersion}.${minorVersion}.${patchVersion}`;
|
|
28
|
+
};
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "28.0
|
|
3
|
+
"version": "28.1.0-framework-version-detection",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"exports": "./
|
|
7
|
-
"main": "./
|
|
8
|
-
"types": "types/index.d.ts",
|
|
6
|
+
"exports": "./lib/core/main.js",
|
|
7
|
+
"main": "./lib/core/main.js",
|
|
8
|
+
"types": "./types/index.d.ts",
|
|
9
9
|
"bin": {
|
|
10
|
-
"netlify-build": "./
|
|
10
|
+
"netlify-build": "./bin.js"
|
|
11
11
|
},
|
|
12
12
|
"files": [
|
|
13
|
-
"
|
|
14
|
-
"
|
|
13
|
+
"bin.js",
|
|
14
|
+
"lib/**/*.js",
|
|
15
|
+
"lib/**/*.yml",
|
|
15
16
|
"types/**/*.d.ts"
|
|
16
17
|
],
|
|
17
18
|
"author": "Netlify Inc.",
|
|
@@ -20,7 +21,14 @@
|
|
|
20
21
|
"Swyx <swyx@netlify.com> (https://www.swyx.io)"
|
|
21
22
|
],
|
|
22
23
|
"scripts": {
|
|
23
|
-
"
|
|
24
|
+
"prebuild": "rm -rf lib",
|
|
25
|
+
"postbuild": "npx copyfiles \"src/**/*.yml\" lib/ -u 1",
|
|
26
|
+
"build": "tsc",
|
|
27
|
+
"pretest": "tsd .",
|
|
28
|
+
"test": "ava",
|
|
29
|
+
"test:dev": "ava -w",
|
|
30
|
+
"test:ci": "c8 -r lcovonly -r text -r json ava",
|
|
31
|
+
"test:measure": "../../tools/tests-duration.js"
|
|
24
32
|
},
|
|
25
33
|
"keywords": [
|
|
26
34
|
"nodejs",
|
|
@@ -56,16 +64,18 @@
|
|
|
56
64
|
"license": "MIT",
|
|
57
65
|
"dependencies": {
|
|
58
66
|
"@bugsnag/js": "^7.0.0",
|
|
59
|
-
"@netlify/
|
|
60
|
-
"@netlify/cache-utils": "^
|
|
61
|
-
"@netlify/config": "^
|
|
62
|
-
"@netlify/
|
|
63
|
-
"@netlify/
|
|
64
|
-
"@netlify/
|
|
65
|
-
"@netlify/
|
|
66
|
-
"@netlify/
|
|
67
|
+
"@netlify/build-info": "5.2.0-framework-version-detection",
|
|
68
|
+
"@netlify/cache-utils": "^5.0.1",
|
|
69
|
+
"@netlify/config": "^19.0.1",
|
|
70
|
+
"@netlify/edge-bundler": "^2.8.0",
|
|
71
|
+
"@netlify/functions-utils": "^5.0.1",
|
|
72
|
+
"@netlify/git-utils": "^5.0.1",
|
|
73
|
+
"@netlify/plugins-list": "^6.50.0",
|
|
74
|
+
"@netlify/run-utils": "^5.0.1",
|
|
75
|
+
"@netlify/zip-it-and-ship-it": "^7.1.2",
|
|
67
76
|
"@sindresorhus/slugify": "^2.0.0",
|
|
68
|
-
"
|
|
77
|
+
"ajv": "^8.11.0",
|
|
78
|
+
"ajv-errors": "^3.0.0",
|
|
69
79
|
"ansi-escapes": "^5.0.0",
|
|
70
80
|
"chalk": "^5.0.0",
|
|
71
81
|
"clean-stack": "^4.0.0",
|
|
@@ -110,9 +120,12 @@
|
|
|
110
120
|
"yargs": "^17.3.1"
|
|
111
121
|
},
|
|
112
122
|
"devDependencies": {
|
|
113
|
-
"@netlify/nock-udp": "^
|
|
123
|
+
"@netlify/nock-udp": "^3.0.0",
|
|
124
|
+
"@types/node": "^14.18.31",
|
|
114
125
|
"atob": "^2.1.2",
|
|
115
126
|
"ava": "^4.0.0",
|
|
127
|
+
"c8": "^7.12.0",
|
|
128
|
+
"copyfiles": "^2.4.1",
|
|
116
129
|
"cpy": "^8.1.0",
|
|
117
130
|
"del": "^6.0.0",
|
|
118
131
|
"fast-safe-stringify": "^2.0.7",
|
|
@@ -126,9 +139,16 @@
|
|
|
126
139
|
"path-key": "^4.0.0",
|
|
127
140
|
"process-exists": "^5.0.0",
|
|
128
141
|
"sinon": "^13.0.0",
|
|
142
|
+
"tsd": "^0.24.1",
|
|
143
|
+
"typescript": "^4.8.4",
|
|
129
144
|
"yarn": "^1.22.4"
|
|
130
145
|
},
|
|
131
146
|
"engines": {
|
|
132
|
-
"node": "^
|
|
147
|
+
"node": "^14.16.0 || >=16.0.0"
|
|
148
|
+
},
|
|
149
|
+
"tsd": {
|
|
150
|
+
"compilerOptions": {
|
|
151
|
+
"module": "commonjs"
|
|
152
|
+
}
|
|
133
153
|
}
|
|
134
154
|
}
|
|
@@ -22,9 +22,9 @@ interface Header {
|
|
|
22
22
|
values: Partial<Record<string, Many<string, 'mutable'>>>
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
interface
|
|
25
|
+
interface EdgeFunction {
|
|
26
26
|
path?: `/${string}`
|
|
27
|
-
|
|
27
|
+
function: string
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
interface NetlifyPlugin {
|
|
@@ -44,9 +44,9 @@ interface NetlifyConfig {
|
|
|
44
44
|
*/
|
|
45
45
|
headers: Header[]
|
|
46
46
|
/**
|
|
47
|
-
* array of Edge
|
|
47
|
+
* array of Edge Functions with their modifiable options
|
|
48
48
|
*/
|
|
49
|
-
|
|
49
|
+
edge_functions: EdgeFunction[]
|
|
50
50
|
/**
|
|
51
51
|
* object with options for modifying [functions](https://docs.netlify.com/configure-builds/file-based-configuration/#functions)
|
|
52
52
|
*/
|
|
@@ -14,10 +14,10 @@ export interface NetlifyPluginConstants {
|
|
|
14
14
|
*/
|
|
15
15
|
FUNCTIONS_SRC?: string
|
|
16
16
|
/**
|
|
17
|
-
* the directory where internal Edge
|
|
18
|
-
* `undefined` if the version of @netlify/build does not support internal Edge
|
|
17
|
+
* the directory where internal Edge Functions source code lives. This is where build plugins should place auto-generated functions.
|
|
18
|
+
* `undefined` if the version of @netlify/build does not support internal Edge Functions
|
|
19
19
|
*/
|
|
20
|
-
|
|
20
|
+
INTERNAL_EDGE_FUNCTIONS_SRC?: string
|
|
21
21
|
/**
|
|
22
22
|
* the directory where internal function source code lives. This is where build plugins should place auto-generated functions.
|
|
23
23
|
* `undefined` if the version of @netlify/build does not support internal functions
|
|
@@ -28,14 +28,14 @@ export interface NetlifyPluginConstants {
|
|
|
28
28
|
*/
|
|
29
29
|
FUNCTIONS_DIST: string
|
|
30
30
|
/**
|
|
31
|
-
* the directory where built Edge
|
|
31
|
+
* the directory where built Edge Functions are placed before deployment. Its value is always defined, but the target might not have been created yet.
|
|
32
32
|
*/
|
|
33
|
-
|
|
33
|
+
EDGE_FUNCTIONS_DIST: string
|
|
34
34
|
/**
|
|
35
|
-
* the directory where Edge
|
|
36
|
-
* `undefined` if no `netlify/edge-
|
|
35
|
+
* the directory where Edge Functions source code lives.
|
|
36
|
+
* `undefined` if no `netlify/edge-functions` directory exists.
|
|
37
37
|
*/
|
|
38
|
-
|
|
38
|
+
EDGE_FUNCTIONS_SRC?: string
|
|
39
39
|
/**
|
|
40
40
|
* boolean indicating whether the build was [run locally](https://docs.netlify.com/cli/get-started/#run-builds-locally) or on Netlify
|
|
41
41
|
*/
|
package/src/core/bin.js
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
import process from 'process'
|
|
4
|
-
|
|
5
|
-
import filterObj from 'filter-obj'
|
|
6
|
-
import yargs from 'yargs'
|
|
7
|
-
import { hideBin } from 'yargs/helpers'
|
|
8
|
-
|
|
9
|
-
import { normalizeCliFeatureFlags } from './feature_flags.js'
|
|
10
|
-
import { FLAGS } from './flags.js'
|
|
11
|
-
import build from './main.js'
|
|
12
|
-
import { FALLBACK_SEVERITY_ENTRY } from './severity.js'
|
|
13
|
-
|
|
14
|
-
// CLI entry point.
|
|
15
|
-
// Before adding logic to this file, please consider adding it to the main
|
|
16
|
-
// programmatic command instead, so that the new logic is available when run
|
|
17
|
-
// programmatically as well. This file should only contain logic that makes
|
|
18
|
-
// sense only in CLI, such as CLI flags parsing and exit code.
|
|
19
|
-
const runCli = async function () {
|
|
20
|
-
const flags = parseFlags()
|
|
21
|
-
const flagsA = filterObj(flags, isUserFlag)
|
|
22
|
-
|
|
23
|
-
const state = { done: false }
|
|
24
|
-
process.on('exit', onExit.bind(undefined, state))
|
|
25
|
-
|
|
26
|
-
const { severityCode, logs } = await build(flagsA)
|
|
27
|
-
printLogs(logs)
|
|
28
|
-
process.exitCode = severityCode
|
|
29
|
-
|
|
30
|
-
state.done = true
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
const parseFlags = function () {
|
|
34
|
-
const { featureFlags: cliFeatureFlags = '', ...flags } = yargs(hideBin(process.argv))
|
|
35
|
-
.options(FLAGS)
|
|
36
|
-
.usage(USAGE)
|
|
37
|
-
.parse()
|
|
38
|
-
const featureFlags = normalizeCliFeatureFlags(cliFeatureFlags)
|
|
39
|
-
return { ...flags, featureFlags }
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const USAGE = `netlify-build [OPTIONS...]
|
|
43
|
-
|
|
44
|
-
Run Netlify Build system locally.
|
|
45
|
-
|
|
46
|
-
Options can also be specified as environment variables prefixed with
|
|
47
|
-
NETLIFY_BUILD_. For example the environment variable NETLIFY_BUILD_DRY=true can
|
|
48
|
-
be used instead of the CLI flag --dry.`
|
|
49
|
-
|
|
50
|
-
// Remove `yargs`-specific options, shortcuts, dash-cased and aliases
|
|
51
|
-
const isUserFlag = function (key, value) {
|
|
52
|
-
return value !== undefined && !INTERNAL_KEYS.has(key) && key.length !== 1 && !key.includes('-')
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const INTERNAL_KEYS = new Set(['help', 'version', '_', '$0', 'dryRun'])
|
|
56
|
-
|
|
57
|
-
// Used mostly for testing
|
|
58
|
-
const printLogs = function (logs) {
|
|
59
|
-
if (logs === undefined) {
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
const allLogs = [logs.stdout.join('\n'), logs.stderr.join('\n')].filter(Boolean).join('\n\n')
|
|
64
|
-
console.log(allLogs)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// In theory, the main process should not exit until the main `build()` function
|
|
68
|
-
// has completed. In practice, this might happen due to bugs.
|
|
69
|
-
// Making the exit code not 0 in that case ensures the caller knows that the
|
|
70
|
-
// build has completed when the exit code is 0. This `exit` event handlers
|
|
71
|
-
// guarantees this.
|
|
72
|
-
const onExit = function ({ done }, exitCode) {
|
|
73
|
-
if (done || exitCode !== 0) {
|
|
74
|
-
return
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const [, processName] = process.argv
|
|
78
|
-
console.log(`${processName} exited with exit code ${exitCode} without finishing the build.`)
|
|
79
|
-
|
|
80
|
-
process.exitCode = FALLBACK_SEVERITY_ENTRY.severityCode
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
runCli()
|
package/src/core/config.js
DELETED
|
@@ -1,186 +0,0 @@
|
|
|
1
|
-
import { resolveConfig, updateConfig, restoreConfig } from '@netlify/config'
|
|
2
|
-
import mapObj from 'map-obj'
|
|
3
|
-
|
|
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'
|
|
11
|
-
|
|
12
|
-
import { getUserNodeVersion } from './user_node_version.js'
|
|
13
|
-
|
|
14
|
-
// Retrieve immutable options passed to `@netlify/config`.
|
|
15
|
-
// This does not include options which might change during the course of the
|
|
16
|
-
// build:
|
|
17
|
-
// - `cachedConfig` and `cachedConfigPath` are only used at the beginning of
|
|
18
|
-
// the build
|
|
19
|
-
// - If plugins change the configuration, `configMutations` is used instead
|
|
20
|
-
// In both cases, almost all options should remain the same.
|
|
21
|
-
export const getConfigOpts = function ({
|
|
22
|
-
config,
|
|
23
|
-
defaultConfig,
|
|
24
|
-
cwd,
|
|
25
|
-
repositoryRoot,
|
|
26
|
-
apiHost,
|
|
27
|
-
token,
|
|
28
|
-
siteId,
|
|
29
|
-
context,
|
|
30
|
-
branch,
|
|
31
|
-
baseRelDir,
|
|
32
|
-
envOpt,
|
|
33
|
-
mode,
|
|
34
|
-
offline,
|
|
35
|
-
deployId,
|
|
36
|
-
buildId,
|
|
37
|
-
testOpts,
|
|
38
|
-
featureFlags,
|
|
39
|
-
}) {
|
|
40
|
-
return {
|
|
41
|
-
config,
|
|
42
|
-
defaultConfig,
|
|
43
|
-
cwd,
|
|
44
|
-
repositoryRoot,
|
|
45
|
-
context,
|
|
46
|
-
branch,
|
|
47
|
-
baseRelDir,
|
|
48
|
-
host: apiHost,
|
|
49
|
-
token,
|
|
50
|
-
siteId,
|
|
51
|
-
deployId,
|
|
52
|
-
buildId,
|
|
53
|
-
mode,
|
|
54
|
-
offline,
|
|
55
|
-
env: envOpt,
|
|
56
|
-
testOpts,
|
|
57
|
-
featureFlags,
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Retrieve configuration object
|
|
62
|
-
const tLoadConfig = async function ({ configOpts, cachedConfig, cachedConfigPath, envOpt, debug, logs, nodePath }) {
|
|
63
|
-
const {
|
|
64
|
-
configPath,
|
|
65
|
-
headersPath,
|
|
66
|
-
redirectsPath,
|
|
67
|
-
buildDir,
|
|
68
|
-
repositoryRoot,
|
|
69
|
-
config: netlifyConfig,
|
|
70
|
-
context: contextA,
|
|
71
|
-
branch: branchA,
|
|
72
|
-
token: tokenA,
|
|
73
|
-
api,
|
|
74
|
-
siteInfo,
|
|
75
|
-
env,
|
|
76
|
-
} = await resolveInitialConfig(configOpts, cachedConfig, cachedConfigPath)
|
|
77
|
-
logConfigInfo({ logs, configPath, buildDir, netlifyConfig, context: contextA, debug })
|
|
78
|
-
|
|
79
|
-
const apiA = addApiErrorHandlers(api)
|
|
80
|
-
const envValues = mapObj(env, (key, { value }) => [key, value])
|
|
81
|
-
const childEnv = getChildEnv({ envOpt, env: envValues })
|
|
82
|
-
const [{ packageJson }, userNodeVersion] = await Promise.all([getPackageJson(buildDir), getUserNodeVersion(nodePath)])
|
|
83
|
-
return {
|
|
84
|
-
netlifyConfig,
|
|
85
|
-
configPath,
|
|
86
|
-
headersPath,
|
|
87
|
-
redirectsPath,
|
|
88
|
-
buildDir,
|
|
89
|
-
repositoryRoot,
|
|
90
|
-
packageJson,
|
|
91
|
-
userNodeVersion,
|
|
92
|
-
childEnv,
|
|
93
|
-
context: contextA,
|
|
94
|
-
branch: branchA,
|
|
95
|
-
token: tokenA,
|
|
96
|
-
api: apiA,
|
|
97
|
-
siteInfo,
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
export const loadConfig = measureDuration(tLoadConfig, 'resolve_config')
|
|
102
|
-
|
|
103
|
-
// Retrieve initial configuration.
|
|
104
|
-
// In the buildbot and CLI, we re-use the already parsed `@netlify/config`
|
|
105
|
-
// return value which is passed as `cachedConfig`/`cachedConfigPath`.
|
|
106
|
-
const resolveInitialConfig = async function (configOpts, cachedConfig, cachedConfigPath) {
|
|
107
|
-
return await resolveConfig({ ...configOpts, cachedConfig, cachedConfigPath })
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const logConfigInfo = function ({ logs, configPath, buildDir, netlifyConfig, context, debug }) {
|
|
111
|
-
logBuildDir(logs, buildDir)
|
|
112
|
-
logConfigPath(logs, configPath)
|
|
113
|
-
logConfig({ logs, netlifyConfig, debug })
|
|
114
|
-
logContext(logs, context)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
// Retrieve the configuration after it's been changed.
|
|
118
|
-
// This ensures any configuration changes done by plugins is validated and
|
|
119
|
-
// normalized.
|
|
120
|
-
// We use `debug: false` to avoid any debug logs. Otherwise every configuration
|
|
121
|
-
// change would create debug logs which would be too verbose.
|
|
122
|
-
// Errors are propagated and assigned to the specific plugin or core step
|
|
123
|
-
// which changed the configuration.
|
|
124
|
-
export const resolveUpdatedConfig = async function (configOpts, configMutations) {
|
|
125
|
-
try {
|
|
126
|
-
return await resolveConfig({ ...configOpts, configMutations, debug: false })
|
|
127
|
-
} catch (error) {
|
|
128
|
-
changeErrorType(error, 'resolveConfig', 'pluginValidation')
|
|
129
|
-
throw error
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
// If the configuration was changed, persist it to `netlify.toml`.
|
|
134
|
-
// If `netlify.toml` does not exist, create it inside repository root.
|
|
135
|
-
// This is only done when `saveConfig` is `true`. This allows performing this
|
|
136
|
-
// in the buildbot but not in local builds, since only the latter run in a
|
|
137
|
-
// container and we want to avoid saving files on local machines.
|
|
138
|
-
export const saveUpdatedConfig = async function ({
|
|
139
|
-
configMutations,
|
|
140
|
-
buildDir,
|
|
141
|
-
repositoryRoot,
|
|
142
|
-
configPath = `${repositoryRoot}/netlify.toml`,
|
|
143
|
-
headersPath,
|
|
144
|
-
redirectsPath,
|
|
145
|
-
logs,
|
|
146
|
-
featureFlags,
|
|
147
|
-
context,
|
|
148
|
-
branch,
|
|
149
|
-
debug,
|
|
150
|
-
saveConfig,
|
|
151
|
-
}) {
|
|
152
|
-
if (!saveConfig) {
|
|
153
|
-
return
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
await updateConfig(configMutations, {
|
|
157
|
-
buildDir,
|
|
158
|
-
configPath,
|
|
159
|
-
headersPath,
|
|
160
|
-
redirectsPath,
|
|
161
|
-
context,
|
|
162
|
-
branch,
|
|
163
|
-
logs,
|
|
164
|
-
featureFlags,
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
await logConfigOnUpload({ logs, configPath, debug })
|
|
168
|
-
await logHeadersOnUpload({ logs, headersPath, debug })
|
|
169
|
-
await logRedirectsOnUpload({ logs, redirectsPath, debug })
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
export const restoreUpdatedConfig = async function ({
|
|
173
|
-
configMutations,
|
|
174
|
-
buildDir,
|
|
175
|
-
repositoryRoot,
|
|
176
|
-
configPath = `${repositoryRoot}/netlify.toml`,
|
|
177
|
-
headersPath,
|
|
178
|
-
redirectsPath,
|
|
179
|
-
saveConfig,
|
|
180
|
-
}) {
|
|
181
|
-
if (!saveConfig) {
|
|
182
|
-
return
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
await restoreConfig(configMutations, { buildDir, configPath, headersPath, redirectsPath })
|
|
186
|
-
}
|