@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
package/lib/env/metadata.js
CHANGED
|
@@ -1,81 +1,68 @@
|
|
|
1
|
-
import { env } from 'process'
|
|
2
|
-
|
|
3
|
-
import filterObj from 'filter-obj'
|
|
4
|
-
|
|
1
|
+
import { env } from 'process';
|
|
2
|
+
import filterObj from 'filter-obj';
|
|
5
3
|
// Retrieve enviroment variables used in error monitoring
|
|
6
4
|
export const getEnvMetadata = function (childEnv = env) {
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
5
|
+
return filterObj(childEnv, isEnvMetadata);
|
|
6
|
+
};
|
|
10
7
|
const isEnvMetadata = function (name) {
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
8
|
+
return ENVIRONMENT_VARIABLES.has(name);
|
|
9
|
+
};
|
|
14
10
|
// This is sorted by most useful in debugging to least
|
|
15
11
|
const ENVIRONMENT_VARIABLES = new Set([
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// Python
|
|
74
|
-
'PIPENV_DEFAULT_PYTHON_VERSION',
|
|
75
|
-
'PIPENV_RUNTIME',
|
|
76
|
-
'PIPENV_VENV_IN_PROJECT',
|
|
77
|
-
|
|
78
|
-
// Git LFS
|
|
79
|
-
'GIT_LFS_ENABLED',
|
|
80
|
-
'GIT_LFS_FETCH_INCLUDE',
|
|
81
|
-
])
|
|
12
|
+
// URL and IDs
|
|
13
|
+
'BUILD_ID',
|
|
14
|
+
'DEPLOY_ID',
|
|
15
|
+
'SITE_NAME',
|
|
16
|
+
'SITE_ID',
|
|
17
|
+
'REPOSITORY_URL',
|
|
18
|
+
'URL',
|
|
19
|
+
'DEPLOY_URL',
|
|
20
|
+
'DEPLOY_PRIME_URL',
|
|
21
|
+
// Git
|
|
22
|
+
'HEAD',
|
|
23
|
+
'COMMIT_REF',
|
|
24
|
+
'CACHED_COMMIT_REF',
|
|
25
|
+
'BRANCH',
|
|
26
|
+
'CONTEXT',
|
|
27
|
+
'PULL_REQUEST',
|
|
28
|
+
'REVIEW_ID',
|
|
29
|
+
// Node
|
|
30
|
+
'NODE_VERSION',
|
|
31
|
+
'AWS_LAMBDA_JS_RUNTIME',
|
|
32
|
+
'NPM_VERSION',
|
|
33
|
+
'YARN_VERSION',
|
|
34
|
+
'NPM_FLAGS',
|
|
35
|
+
'YARN_FLAGS',
|
|
36
|
+
'NVM_FLAGS',
|
|
37
|
+
'NODE_ENV',
|
|
38
|
+
// Go
|
|
39
|
+
'GO_VERSION',
|
|
40
|
+
'GO_IMPORT_PATH',
|
|
41
|
+
'GOCACHE',
|
|
42
|
+
'GOPATH',
|
|
43
|
+
'GOROOT',
|
|
44
|
+
// Ruby
|
|
45
|
+
'RUBY_VERSION',
|
|
46
|
+
'GEM_HOME',
|
|
47
|
+
'GEM_PATH',
|
|
48
|
+
'GIMME_GCO_ENABLED',
|
|
49
|
+
'GIMME_ENV_PREFIX',
|
|
50
|
+
'GIMME_GO_PREFIX',
|
|
51
|
+
'GIMME_NO_ENV_ALIAS',
|
|
52
|
+
'GIMME_TYPE',
|
|
53
|
+
'IRBRC',
|
|
54
|
+
'MY_RUBY_HOME',
|
|
55
|
+
// Hugo
|
|
56
|
+
'HUGO_VERSION',
|
|
57
|
+
// Java
|
|
58
|
+
'JAVA_VERSION',
|
|
59
|
+
// PHP
|
|
60
|
+
'PHP_VERSION',
|
|
61
|
+
// Python
|
|
62
|
+
'PIPENV_DEFAULT_PYTHON_VERSION',
|
|
63
|
+
'PIPENV_RUNTIME',
|
|
64
|
+
'PIPENV_VENV_IN_PROJECT',
|
|
65
|
+
// Git LFS
|
|
66
|
+
'GIT_LFS_ENABLED',
|
|
67
|
+
'GIT_LFS_FETCH_INCLUDE',
|
|
68
|
+
]);
|
package/lib/error/api.js
CHANGED
|
@@ -1,46 +1,37 @@
|
|
|
1
|
-
import isPlainObj from 'is-plain-obj'
|
|
2
|
-
import mapObj from 'map-obj'
|
|
3
|
-
|
|
4
|
-
import { addErrorInfo } from './info.js'
|
|
5
|
-
|
|
1
|
+
import isPlainObj from 'is-plain-obj';
|
|
2
|
+
import mapObj from 'map-obj';
|
|
3
|
+
import { addErrorInfo } from './info.js';
|
|
6
4
|
// Wrap `api.*` methods so that they add more error information
|
|
7
5
|
export const addApiErrorHandlers = function (api) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
6
|
+
if (api === undefined) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
return mapObj(api, addErrorHandler);
|
|
10
|
+
};
|
|
15
11
|
const addErrorHandler = function (key, value) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
|
|
12
|
+
if (typeof value !== 'function') {
|
|
13
|
+
return [key, value];
|
|
14
|
+
}
|
|
15
|
+
const valueA = apiMethodHandler.bind(null, key, value);
|
|
16
|
+
return [key, valueA];
|
|
17
|
+
};
|
|
24
18
|
const apiMethodHandler = async function (endpoint, method, parameters, ...args) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
19
|
+
try {
|
|
20
|
+
return await method(parameters, ...args);
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
redactError(error);
|
|
24
|
+
addErrorInfo(error, { type: 'api', location: { endpoint, parameters } });
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
34
28
|
// Redact API token from the build logs
|
|
35
29
|
const redactError = function (error) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const HEX_REGEXP = /[\da-f]{6,}/g
|
|
30
|
+
if (error instanceof Error &&
|
|
31
|
+
isPlainObj(error.data) &&
|
|
32
|
+
isPlainObj(error.data.headers) &&
|
|
33
|
+
typeof error.data.headers.Authorization === 'string') {
|
|
34
|
+
error.data.headers.Authorization = error.data.headers.Authorization.replace(HEX_REGEXP, 'HEX');
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
const HEX_REGEXP = /[\da-f]{6,}/g;
|
package/lib/error/build.js
CHANGED
|
@@ -1,47 +1,36 @@
|
|
|
1
|
-
import safeJsonStringify from 'safe-json-stringify'
|
|
2
|
-
|
|
3
|
-
import { CUSTOM_ERROR_KEY } from './info.js'
|
|
4
|
-
|
|
1
|
+
import safeJsonStringify from 'safe-json-stringify';
|
|
2
|
+
import { CUSTOM_ERROR_KEY } from './info.js';
|
|
5
3
|
// Retrieve error information from child process and re-build it in current
|
|
6
4
|
// process. We need this since errors static properties are not kept by
|
|
7
5
|
// `v8.serialize()`.
|
|
8
6
|
export const jsonToError = function ({ name, message, stack, ...errorProps }) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
return error
|
|
17
|
-
}
|
|
18
|
-
|
|
7
|
+
const error = new Error('');
|
|
8
|
+
assignErrorProps(error, { name, message, stack });
|
|
9
|
+
// Assign static error properties (if any)
|
|
10
|
+
// We need to mutate the `error` directly to preserve its `name`, `stack`, etc.
|
|
11
|
+
Object.assign(error, errorProps);
|
|
12
|
+
return error;
|
|
13
|
+
};
|
|
19
14
|
// Make sure `name`, `message` and `stack` are not enumerable
|
|
20
15
|
const assignErrorProps = function (error, values) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const ERROR_PROPS = ['name', 'message', 'stack']
|
|
27
|
-
|
|
16
|
+
ERROR_PROPS.forEach((name) => {
|
|
17
|
+
assignErrorProp(error, name, values[name]);
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
const ERROR_PROPS = ['name', 'message', 'stack'];
|
|
28
21
|
const assignErrorProp = function (error, name, value) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
22
|
+
// `Object.defineProperty()` requires direct mutation
|
|
23
|
+
Object.defineProperty(error, name, { value, enumerable: false, writable: true, configurable: true });
|
|
24
|
+
};
|
|
34
25
|
// Inverse of `jsonToError()`.
|
|
35
26
|
export const errorToJson = function (error) {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
}
|
|
27
|
+
const { name, message, stack, [CUSTOM_ERROR_KEY]: customError, ...errorProps } = error;
|
|
28
|
+
// diagnosticText is not enumerable in TSError so we need to grab it manually. destructuring won't work.
|
|
29
|
+
if (error.diagnosticText) {
|
|
30
|
+
errorProps.diagnosticText = error.diagnosticText;
|
|
31
|
+
}
|
|
32
|
+
return {
|
|
33
|
+
...safeJsonStringify.ensureProperties(errorProps),
|
|
34
|
+
...safeJsonStringify.ensureProperties({ name, message, stack, [CUSTOM_ERROR_KEY]: customError }),
|
|
35
|
+
};
|
|
36
|
+
};
|
package/lib/error/cancel.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Cancel builds, for example when a plugin uses `utils.build.cancelBuild()`
|
|
2
2
|
export const cancelBuild = async function ({ api, deployId }) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
3
|
+
if (api === undefined || !deployId) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
await api.cancelSiteDeploy({ deploy_id: deployId });
|
|
7
|
+
};
|
package/lib/error/colors.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import stripAnsi from 'strip-ansi'
|
|
2
|
-
|
|
1
|
+
import stripAnsi from 'strip-ansi';
|
|
3
2
|
// Remove ANSI sequences from `error.message`
|
|
4
3
|
export const removeErrorColors = function (error) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
4
|
+
if (!(error instanceof Error)) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
error.message = stripAnsi(error.message);
|
|
8
|
+
error.stack = stripAnsi(error.stack);
|
|
9
|
+
};
|
package/lib/error/handle.js
CHANGED
|
@@ -1,37 +1,26 @@
|
|
|
1
|
-
import { cwd as getCwd } from 'process'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
import { getErrorInfo } from './info.js'
|
|
10
|
-
import { reportBuildError } from './monitor/report.js'
|
|
11
|
-
import { parseErrorInfo } from './parse/parse.js'
|
|
12
|
-
|
|
1
|
+
import { cwd as getCwd } from 'process';
|
|
2
|
+
import { pathExists } from 'path-exists';
|
|
3
|
+
import { logBuildError } from '../log/messages/core.js';
|
|
4
|
+
import { logOldCliVersionError } from '../log/old_version.js';
|
|
5
|
+
import { removeErrorColors } from './colors.js';
|
|
6
|
+
import { getErrorInfo } from './info.js';
|
|
7
|
+
import { reportBuildError } from './monitor/report.js';
|
|
8
|
+
import { parseErrorInfo } from './parse/parse.js';
|
|
13
9
|
// Logs and reports a build failure
|
|
14
|
-
export const handleBuildError = async function (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
logOldCliVersionError({ mode, testOpts })
|
|
30
|
-
await reportBuildError({ error, errorMonitor, childEnv, logs, testOpts })
|
|
31
|
-
|
|
32
|
-
return basicErrorInfo
|
|
33
|
-
}
|
|
34
|
-
|
|
10
|
+
export const handleBuildError = async function (error, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts }) {
|
|
11
|
+
const basicErrorInfo = parseErrorInfo(error);
|
|
12
|
+
if (await isCancelCrash(error)) {
|
|
13
|
+
return basicErrorInfo;
|
|
14
|
+
}
|
|
15
|
+
removeErrorColors(error);
|
|
16
|
+
// Some errors, such as telemetry ones, should not be logged
|
|
17
|
+
if (basicErrorInfo.showInBuildLog) {
|
|
18
|
+
logBuildError({ error, netlifyConfig, mode, logs, debug, testOpts });
|
|
19
|
+
}
|
|
20
|
+
logOldCliVersionError({ mode, testOpts });
|
|
21
|
+
await reportBuildError({ error, errorMonitor, childEnv, logs, testOpts });
|
|
22
|
+
return basicErrorInfo;
|
|
23
|
+
};
|
|
35
24
|
// When builds are canceled, the whole filesystem is being deleted.
|
|
36
25
|
// However, the process (and build) keeps going. Because no files exist anymore,
|
|
37
26
|
// the build eventually crashes with a randomly odd error. Those should not be
|
|
@@ -39,19 +28,19 @@ export const handleBuildError = async function (
|
|
|
39
28
|
// However builds canceled with `utils.build.cancelBuild()` should still show
|
|
40
29
|
// "Build canceled by ..."
|
|
41
30
|
const isCancelCrash = async function (error) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
31
|
+
const [{ type }] = getErrorInfo(error);
|
|
32
|
+
if (type === 'cancelBuild') {
|
|
33
|
+
return false;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
// TODO: find a better way to detect that the build is being cancelled.
|
|
37
|
+
// Otherwise bugs due to (for example) the build command removing
|
|
38
|
+
// `process.cwd` are currently not logged/reported.
|
|
39
|
+
const cwd = getCwd();
|
|
40
|
+
return !(await pathExists(cwd));
|
|
41
|
+
// `process.cwd()` fails when the current directory does not exist
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
};
|
package/lib/error/info.js
CHANGED
|
@@ -1,46 +1,37 @@
|
|
|
1
1
|
// Add information related to an error without colliding with existing properties
|
|
2
2
|
export const addDefaultErrorInfo = function (error, info) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
3
|
+
if (!canHaveErrorInfo(error)) {
|
|
4
|
+
return;
|
|
5
|
+
}
|
|
6
|
+
error[CUSTOM_ERROR_KEY] = { ...info, ...error[CUSTOM_ERROR_KEY] };
|
|
7
|
+
};
|
|
10
8
|
// Retrieve error information added by our system
|
|
11
9
|
export const addErrorInfo = function (error, info) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
10
|
+
if (!canHaveErrorInfo(error)) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
error[CUSTOM_ERROR_KEY] = { ...error[CUSTOM_ERROR_KEY], ...info };
|
|
14
|
+
};
|
|
19
15
|
export const getErrorInfo = function (error) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
16
|
+
if (!isBuildError(error)) {
|
|
17
|
+
return [{}, error];
|
|
18
|
+
}
|
|
19
|
+
const { [CUSTOM_ERROR_KEY]: errorInfo, ...errorA } = error;
|
|
20
|
+
return [errorInfo, errorA];
|
|
21
|
+
};
|
|
28
22
|
// Change error type from one to another
|
|
29
23
|
export const changeErrorType = function (error, oldType, newType) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
24
|
+
const [{ type }] = getErrorInfo(error);
|
|
25
|
+
if (type === oldType) {
|
|
26
|
+
addErrorInfo(error, { type: newType });
|
|
27
|
+
}
|
|
28
|
+
};
|
|
36
29
|
export const isBuildError = function (error) {
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
30
|
+
return canHaveErrorInfo(error) && error[CUSTOM_ERROR_KEY] !== undefined;
|
|
31
|
+
};
|
|
40
32
|
// Exceptions that are not objects (including `Error` instances) cannot have an
|
|
41
33
|
// `CUSTOM_ERROR_KEY` property
|
|
42
34
|
const canHaveErrorInfo = function (error) {
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export const CUSTOM_ERROR_KEY = 'customErrorInfo'
|
|
35
|
+
return error != null;
|
|
36
|
+
};
|
|
37
|
+
export const CUSTOM_ERROR_KEY = 'customErrorInfo';
|
|
@@ -1,21 +1,16 @@
|
|
|
1
1
|
// Retrieve plugin's location and build logs
|
|
2
2
|
export const getLocationMetadata = function (location, envMetadata) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
return { buildLogs, ...location }
|
|
10
|
-
}
|
|
11
|
-
|
|
3
|
+
const buildLogs = getBuildLogs(envMetadata);
|
|
4
|
+
if (buildLogs === undefined && location === undefined) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
return { buildLogs, ...location };
|
|
8
|
+
};
|
|
12
9
|
// Retrieve the URL to the build logs
|
|
13
10
|
const getBuildLogs = function ({ SITE_NAME, DEPLOY_ID }) {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const NETLIFY_ORIGIN = 'https://app.netlify.com'
|
|
11
|
+
if (SITE_NAME === undefined || DEPLOY_ID === undefined) {
|
|
12
|
+
return;
|
|
13
|
+
}
|
|
14
|
+
return `${NETLIFY_ORIGIN}/sites/${SITE_NAME}/deploys/${DEPLOY_ID}`;
|
|
15
|
+
};
|
|
16
|
+
const NETLIFY_ORIGIN = 'https://app.netlify.com';
|