@netlify/build 27.20.4 → 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 +13 -6
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { cwd } from 'process'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
import stripAnsi from 'strip-ansi'
|
|
5
|
-
|
|
1
|
+
import { cwd } from 'process';
|
|
2
|
+
import cleanStack from 'clean-stack';
|
|
3
|
+
import stripAnsi from 'strip-ansi';
|
|
6
4
|
// Clean stack traces:
|
|
7
5
|
// - remove our internal code, e.g. the logic spawning plugins
|
|
8
6
|
// - remove node modules and Node.js internals
|
|
@@ -12,76 +10,61 @@ import stripAnsi from 'strip-ansi'
|
|
|
12
10
|
// We do not use libraries that patch `Error.prepareStackTrace()` because they
|
|
13
11
|
// tend to create issues.
|
|
14
12
|
export const cleanStacks = function ({ stack, rawStack, debug }) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return stack.split('\n').reduce(cleanStackLine, '').replace(INITIAL_NEWLINES, '')
|
|
26
|
-
}
|
|
27
|
-
|
|
13
|
+
if (stack === undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
// Internal errors / bugs keep their full stack trace
|
|
17
|
+
// Same in debug mode
|
|
18
|
+
if (rawStack || debug) {
|
|
19
|
+
return stack;
|
|
20
|
+
}
|
|
21
|
+
return stack.split('\n').reduce(cleanStackLine, '').replace(INITIAL_NEWLINES, '');
|
|
22
|
+
};
|
|
28
23
|
const cleanStackLine = function (lines, line) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
return lines
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return `${lines}\n${lineC}`
|
|
47
|
-
}
|
|
48
|
-
|
|
24
|
+
const lineA = line.replace(getCwd(), '');
|
|
25
|
+
const lineB = stripAnsi(lineA);
|
|
26
|
+
if (!STACK_LINE_REGEXP.test(lineB)) {
|
|
27
|
+
return `${lines}\n${lineA}`;
|
|
28
|
+
}
|
|
29
|
+
if (shouldRemoveStackLine(lineB)) {
|
|
30
|
+
return lines;
|
|
31
|
+
}
|
|
32
|
+
const lineC = cleanStack(lineB);
|
|
33
|
+
if (lineC === '') {
|
|
34
|
+
return lines;
|
|
35
|
+
}
|
|
36
|
+
return `${lines}\n${lineC}`;
|
|
37
|
+
};
|
|
49
38
|
// `process.cwd()` can sometimes fail: directory name too long, current
|
|
50
39
|
// directory has been removed, access denied.
|
|
51
40
|
const getCwd = function () {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
41
|
+
try {
|
|
42
|
+
return cwd();
|
|
43
|
+
}
|
|
44
|
+
catch {
|
|
45
|
+
return '';
|
|
46
|
+
}
|
|
47
|
+
};
|
|
59
48
|
// Check if a line is part of a stack trace
|
|
60
|
-
const STACK_LINE_REGEXP = /^\s+at
|
|
61
|
-
|
|
49
|
+
const STACK_LINE_REGEXP = /^\s+at /;
|
|
62
50
|
const shouldRemoveStackLine = function (line) {
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
|
|
51
|
+
const lineA = normalizePathSlashes(line);
|
|
52
|
+
return INTERNAL_STACK_STRINGS.some((stackString) => lineA.includes(stackString)) || INTERNAL_STACK_REGEXP.test(lineA);
|
|
53
|
+
};
|
|
67
54
|
const INTERNAL_STACK_STRINGS = [
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
]
|
|
77
|
-
|
|
55
|
+
// Anonymous function
|
|
56
|
+
'<anonymous>',
|
|
57
|
+
'(index 0)',
|
|
58
|
+
// nyc internal code
|
|
59
|
+
'node_modules/append-transform',
|
|
60
|
+
'node_modules/signal-exit',
|
|
61
|
+
// Node internals
|
|
62
|
+
'(node:',
|
|
63
|
+
];
|
|
78
64
|
// This is only needed for local builds and tests
|
|
79
|
-
const INTERNAL_STACK_REGEXP = /(lib\/|tests\/helpers\/|tests\/.*\/tests.js|node_modules)
|
|
80
|
-
|
|
81
|
-
const INITIAL_NEWLINES = /^\n+/
|
|
82
|
-
|
|
65
|
+
const INTERNAL_STACK_REGEXP = /(lib\/|tests\/helpers\/|tests\/.*\/tests.js|node_modules)/;
|
|
66
|
+
const INITIAL_NEWLINES = /^\n+/;
|
|
83
67
|
const normalizePathSlashes = function (line) {
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const BACKLASH_REGEXP = /\\/g
|
|
68
|
+
return line.replace(BACKLASH_REGEXP, '/');
|
|
69
|
+
};
|
|
70
|
+
const BACKLASH_REGEXP = /\\/g;
|
|
@@ -1,62 +1,50 @@
|
|
|
1
|
-
import { getBuildCommandDescription, getPluginOrigin } from '../../log/description.js'
|
|
2
|
-
|
|
1
|
+
import { getBuildCommandDescription, getPluginOrigin } from '../../log/description.js';
|
|
3
2
|
// Retrieve an error's location to print in logs.
|
|
4
3
|
// Each error type has its own logic (or none if there's no location to print).
|
|
5
4
|
export const getLocationInfo = function ({ stack, location, locationType }) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return [locationString, stack].filter(Boolean).join('\n')
|
|
18
|
-
}
|
|
19
|
-
|
|
5
|
+
// No location to print
|
|
6
|
+
if (locationType === undefined && stack === undefined) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
// The location is only the stack trace
|
|
10
|
+
if (locationType === undefined) {
|
|
11
|
+
return stack;
|
|
12
|
+
}
|
|
13
|
+
const locationString = LOCATIONS[locationType](location);
|
|
14
|
+
return [locationString, stack].filter(Boolean).join('\n');
|
|
15
|
+
};
|
|
20
16
|
const getBuildCommandLocation = function ({ buildCommand, buildCommandOrigin }) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
${buildCommand}
|
|
24
|
-
}
|
|
25
|
-
|
|
17
|
+
const description = getBuildCommandDescription(buildCommandOrigin);
|
|
18
|
+
return `In ${description}:
|
|
19
|
+
${buildCommand}`;
|
|
20
|
+
};
|
|
26
21
|
const getFunctionsBundlingLocation = function ({ functionName, functionType }) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
22
|
+
if (functionType === 'edge') {
|
|
23
|
+
return 'While bundling edge function';
|
|
24
|
+
}
|
|
25
|
+
return `While bundling function "${functionName}"`;
|
|
26
|
+
};
|
|
34
27
|
const getCoreStepLocation = function ({ coreStepName }) {
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
28
|
+
return `During ${coreStepName}`;
|
|
29
|
+
};
|
|
38
30
|
const getBuildFailLocation = function ({ event, packageName, loadedFrom, origin }) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
43
|
-
|
|
31
|
+
const eventMessage = getEventMessage(event);
|
|
32
|
+
const pluginOrigin = getPluginOrigin(loadedFrom, origin);
|
|
33
|
+
return `${eventMessage} "${packageName}" ${pluginOrigin}`;
|
|
34
|
+
};
|
|
44
35
|
const getEventMessage = function (event) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
36
|
+
if (event === 'load') {
|
|
37
|
+
return `While loading`;
|
|
38
|
+
}
|
|
39
|
+
return `In "${event}" event in`;
|
|
40
|
+
};
|
|
52
41
|
const getApiLocation = function ({ endpoint, parameters }) {
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
42
|
+
return `While calling the Netlify API endpoint '${endpoint}' with:\n${JSON.stringify(parameters, null, 2)}`;
|
|
43
|
+
};
|
|
56
44
|
const LOCATIONS = {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
45
|
+
buildCommand: getBuildCommandLocation,
|
|
46
|
+
functionsBundling: getFunctionsBundlingLocation,
|
|
47
|
+
coreStep: getCoreStepLocation,
|
|
48
|
+
buildFail: getBuildFailLocation,
|
|
49
|
+
api: getApiLocation,
|
|
50
|
+
};
|
|
@@ -2,28 +2,23 @@
|
|
|
2
2
|
// If is an `Error` instance but is missing usual `Error` properties, we make
|
|
3
3
|
// sure its static properties are preserved.
|
|
4
4
|
export const normalizeError = function (error) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
error.
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return error
|
|
22
|
-
}
|
|
23
|
-
|
|
5
|
+
if (Array.isArray(error)) {
|
|
6
|
+
return normalizeArray(error);
|
|
7
|
+
}
|
|
8
|
+
if (!(error instanceof Error)) {
|
|
9
|
+
return new Error(String(error));
|
|
10
|
+
}
|
|
11
|
+
if (typeof error.message !== 'string') {
|
|
12
|
+
error.message = String(error);
|
|
13
|
+
}
|
|
14
|
+
if (typeof error.stack !== 'string') {
|
|
15
|
+
Error.captureStackTrace(error, normalizeError);
|
|
16
|
+
}
|
|
17
|
+
return error;
|
|
18
|
+
};
|
|
24
19
|
// Some libraries throw arrays of Errors
|
|
25
20
|
const normalizeArray = function (errorArray) {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
21
|
+
const [error, ...errors] = errorArray.map(normalizeError);
|
|
22
|
+
error.errors = errors;
|
|
23
|
+
return error;
|
|
24
|
+
};
|
package/lib/error/parse/parse.js
CHANGED
|
@@ -1,101 +1,67 @@
|
|
|
1
|
-
import { serializeObject } from '../../log/serialize.js'
|
|
2
|
-
import { getErrorInfo } from '../info.js'
|
|
3
|
-
import { getTypeInfo } from '../type.js'
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { getStackInfo } from './stack.js'
|
|
10
|
-
|
|
1
|
+
import { serializeObject } from '../../log/serialize.js';
|
|
2
|
+
import { getErrorInfo } from '../info.js';
|
|
3
|
+
import { getTypeInfo } from '../type.js';
|
|
4
|
+
import { getLocationInfo } from './location.js';
|
|
5
|
+
import { normalizeError } from './normalize.js';
|
|
6
|
+
import { getPluginInfo } from './plugin.js';
|
|
7
|
+
import { getErrorProps } from './properties.js';
|
|
8
|
+
import { getStackInfo } from './stack.js';
|
|
11
9
|
// Add additional type-specific error information
|
|
12
10
|
export const getFullErrorInfo = function ({ error, colors, debug }) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
stack,
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const pluginInfo = getPluginInfo(plugin, location)
|
|
34
|
-
const tsConfigInfo = getTsConfigInfo(tsConfig)
|
|
35
|
-
const locationInfo = getLocationInfo({ stack: stackA, location, locationType })
|
|
36
|
-
const errorPropsA = getErrorProps({ errorProps, showErrorProps, colors })
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
...basicErrorInfo,
|
|
40
|
-
title: titleA,
|
|
41
|
-
message: messageA,
|
|
42
|
-
tsConfigInfo,
|
|
43
|
-
pluginInfo,
|
|
44
|
-
locationInfo,
|
|
45
|
-
errorProps: errorPropsA,
|
|
46
|
-
errorMetadata,
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
11
|
+
const basicErrorInfo = parseErrorInfo(error);
|
|
12
|
+
const { message, stack, errorProps, errorInfo, errorInfo: { location = {}, plugin = {}, tsConfig }, severity, title, stackType, locationType, showErrorProps, rawStack, errorMetadata, } = basicErrorInfo;
|
|
13
|
+
const titleA = getTitle(title, errorInfo);
|
|
14
|
+
const { message: messageA, stack: stackA } = getStackInfo({ message, stack, stackType, rawStack, severity, debug });
|
|
15
|
+
const pluginInfo = getPluginInfo(plugin, location);
|
|
16
|
+
const tsConfigInfo = getTsConfigInfo(tsConfig);
|
|
17
|
+
const locationInfo = getLocationInfo({ stack: stackA, location, locationType });
|
|
18
|
+
const errorPropsA = getErrorProps({ errorProps, showErrorProps, colors });
|
|
19
|
+
return {
|
|
20
|
+
...basicErrorInfo,
|
|
21
|
+
title: titleA,
|
|
22
|
+
message: messageA,
|
|
23
|
+
tsConfigInfo,
|
|
24
|
+
pluginInfo,
|
|
25
|
+
locationInfo,
|
|
26
|
+
errorProps: errorPropsA,
|
|
27
|
+
errorMetadata,
|
|
28
|
+
};
|
|
29
|
+
};
|
|
50
30
|
// Serialize the `tsConfig` error information
|
|
51
31
|
const getTsConfigInfo = function (tsConfig) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
32
|
+
if (tsConfig === undefined) {
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
return serializeObject(tsConfig);
|
|
36
|
+
};
|
|
59
37
|
// Parse error instance into all the basic properties containing information
|
|
60
38
|
export const parseErrorInfo = function (error) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
group,
|
|
84
|
-
stackType,
|
|
85
|
-
locationType,
|
|
86
|
-
showInBuildLog,
|
|
87
|
-
showErrorProps,
|
|
88
|
-
rawStack,
|
|
89
|
-
errorMetadata,
|
|
90
|
-
}
|
|
91
|
-
return basicErrorInfo
|
|
92
|
-
}
|
|
93
|
-
|
|
39
|
+
const { message, stack, ...errorProps } = normalizeError(error);
|
|
40
|
+
const [errorInfo, errorPropsA] = getErrorInfo(errorProps);
|
|
41
|
+
const { errorMetadata } = errorInfo;
|
|
42
|
+
const { type, severity, title, group, stackType, locationType, showErrorProps, showInBuildLog = true, rawStack, } = getTypeInfo(errorInfo);
|
|
43
|
+
const basicErrorInfo = {
|
|
44
|
+
message,
|
|
45
|
+
stack,
|
|
46
|
+
errorProps: errorPropsA,
|
|
47
|
+
errorInfo,
|
|
48
|
+
type,
|
|
49
|
+
severity,
|
|
50
|
+
title,
|
|
51
|
+
group,
|
|
52
|
+
stackType,
|
|
53
|
+
locationType,
|
|
54
|
+
showInBuildLog,
|
|
55
|
+
showErrorProps,
|
|
56
|
+
rawStack,
|
|
57
|
+
errorMetadata,
|
|
58
|
+
};
|
|
59
|
+
return basicErrorInfo;
|
|
60
|
+
};
|
|
94
61
|
// Retrieve title to print in logs
|
|
95
62
|
const getTitle = function (title, errorInfo) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
63
|
+
if (typeof title !== 'function') {
|
|
64
|
+
return title;
|
|
65
|
+
}
|
|
66
|
+
return title(errorInfo);
|
|
67
|
+
};
|
|
@@ -1,70 +1,55 @@
|
|
|
1
1
|
// Retrieve plugin's package.json details to include in error messages.
|
|
2
2
|
// Please note `pluginPackageJson` has been normalized by `normalize-package-data`.
|
|
3
3
|
export const getPluginInfo = function ({ pluginPackageJson = {} }, { packageName, loadedFrom }) {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
4
|
+
if (Object.keys(pluginPackageJson).length === 0) {
|
|
5
|
+
return;
|
|
6
|
+
}
|
|
7
|
+
return Object.entries(FIELDS)
|
|
8
|
+
.map(([name, getField]) => serializeField({ name, getField, pluginPackageJson, packageName, loadedFrom }))
|
|
9
|
+
.filter(Boolean)
|
|
10
|
+
.join('\n');
|
|
11
|
+
};
|
|
14
12
|
// Serialize a single package.json field
|
|
15
13
|
const serializeField = function ({ name, getField, pluginPackageJson, packageName, loadedFrom }) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const NAME_PADDING = 16
|
|
26
|
-
|
|
14
|
+
const field = getField(pluginPackageJson, { packageName, loadedFrom });
|
|
15
|
+
if (field === undefined) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const nameA = `${name}:`.padEnd(NAME_PADDING);
|
|
19
|
+
return `${nameA}${field}`;
|
|
20
|
+
};
|
|
21
|
+
const NAME_PADDING = 16;
|
|
27
22
|
const getPackage = function (pluginPackageJson, { packageName }) {
|
|
28
|
-
|
|
29
|
-
}
|
|
30
|
-
|
|
23
|
+
return packageName;
|
|
24
|
+
};
|
|
31
25
|
const getVersion = function ({ version }) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
26
|
+
if (version === '') {
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
return version;
|
|
30
|
+
};
|
|
39
31
|
export const getHomepage = function (pluginPackageJson = {}, { loadedFrom } = {}) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
32
|
+
return (getRepository(pluginPackageJson) ||
|
|
33
|
+
getNpmLink(pluginPackageJson, { loadedFrom }) ||
|
|
34
|
+
getIssuesLink(pluginPackageJson));
|
|
35
|
+
};
|
|
47
36
|
const getRepository = function ({ repository: { url } = {} }) {
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
|
|
37
|
+
return url;
|
|
38
|
+
};
|
|
51
39
|
const getNpmLink = function ({ name }, { loadedFrom }) {
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
40
|
+
if (!name || loadedFrom === 'local') {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
return `https://www.npmjs.com/package/${name}`;
|
|
44
|
+
};
|
|
59
45
|
const getIssuesLink = function ({ bugs: { url } = {} }) {
|
|
60
|
-
|
|
61
|
-
}
|
|
62
|
-
|
|
46
|
+
return url;
|
|
47
|
+
};
|
|
63
48
|
// List of package.json to serialize
|
|
64
49
|
const FIELDS = {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
}
|
|
50
|
+
Package: getPackage,
|
|
51
|
+
Version: getVersion,
|
|
52
|
+
Repository: getRepository,
|
|
53
|
+
'npm link': getNpmLink,
|
|
54
|
+
'Report issues': getIssuesLink,
|
|
55
|
+
};
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
import { inspect } from 'util'
|
|
2
|
-
|
|
3
|
-
import { omit } from '../../utils/omit.js'
|
|
4
|
-
|
|
1
|
+
import { inspect } from 'util';
|
|
2
|
+
import { omit } from '../../utils/omit.js';
|
|
5
3
|
// In uncaught exceptions, print error static properties
|
|
6
4
|
export const getErrorProps = function ({ errorProps, showErrorProps, colors }) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return inspect(errorPropsA, { colors, depth: INSPECT_MAX_DEPTH })
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const INSPECT_MAX_DEPTH = 5
|
|
21
|
-
|
|
5
|
+
if (!showErrorProps) {
|
|
6
|
+
return;
|
|
7
|
+
}
|
|
8
|
+
const errorPropsA = omit(errorProps, CLEANED_ERROR_PROPS);
|
|
9
|
+
if (Object.keys(errorPropsA).length === 0) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return inspect(errorPropsA, { colors, depth: INSPECT_MAX_DEPTH });
|
|
13
|
+
};
|
|
14
|
+
const INSPECT_MAX_DEPTH = 5;
|
|
22
15
|
// Remove error static properties that should not be logged
|
|
23
|
-
const CLEANED_ERROR_PROPS = ['requireStack']
|
|
16
|
+
const CLEANED_ERROR_PROPS = ['requireStack'];
|