@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
|
@@ -1,42 +1,34 @@
|
|
|
1
|
-
import { THEME } from '../../log/theme.js'
|
|
2
|
-
|
|
1
|
+
import { THEME } from '../../log/theme.js';
|
|
3
2
|
// Serialize an error object into a title|body string to print in logs
|
|
4
|
-
export const serializeLogError = function ({
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
return { title, body }
|
|
9
|
-
}
|
|
10
|
-
|
|
3
|
+
export const serializeLogError = function ({ fullErrorInfo: { title, severity, message, pluginInfo, locationInfo, tsConfigInfo, errorProps }, }) {
|
|
4
|
+
const body = getBody({ message, pluginInfo, locationInfo, tsConfigInfo, errorProps, severity });
|
|
5
|
+
return { title, body };
|
|
6
|
+
};
|
|
11
7
|
const getBody = function ({ message, pluginInfo, locationInfo, tsConfigInfo, errorProps, severity }) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
8
|
+
if (severity === 'none') {
|
|
9
|
+
return message;
|
|
10
|
+
}
|
|
11
|
+
return Object.entries({
|
|
12
|
+
message,
|
|
13
|
+
tsConfigInfo,
|
|
14
|
+
pluginInfo,
|
|
15
|
+
locationInfo,
|
|
16
|
+
errorProps,
|
|
17
|
+
})
|
|
18
|
+
.filter(blockHasValue)
|
|
19
|
+
.map(serializeBlock)
|
|
20
|
+
.join('\n\n');
|
|
21
|
+
};
|
|
28
22
|
const blockHasValue = function ([, value]) {
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
23
|
+
return value !== undefined;
|
|
24
|
+
};
|
|
32
25
|
const serializeBlock = function ([key, value]) {
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
26
|
+
return `${THEME.errorSubHeader(LOG_BLOCK_NAMES[key])}\n${value}`;
|
|
27
|
+
};
|
|
36
28
|
const LOG_BLOCK_NAMES = {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
29
|
+
message: 'Error message',
|
|
30
|
+
pluginInfo: 'Plugin details',
|
|
31
|
+
locationInfo: 'Error location',
|
|
32
|
+
tsConfigInfo: 'TypeScript configuration',
|
|
33
|
+
errorProps: 'Error properties',
|
|
34
|
+
};
|
|
@@ -1,26 +1,18 @@
|
|
|
1
1
|
// Serialize an error object to `statuses` properties
|
|
2
|
-
export const serializeErrorStatus = function ({
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
const text = getText({ locationInfo, errorProps })
|
|
7
|
-
return { state, title, summary: message, text, extraData: errorMetadata }
|
|
8
|
-
}
|
|
9
|
-
|
|
2
|
+
export const serializeErrorStatus = function ({ fullErrorInfo: { title, message, locationInfo, errorProps, errorMetadata }, state, }) {
|
|
3
|
+
const text = getText({ locationInfo, errorProps });
|
|
4
|
+
return { state, title, summary: message, text, extraData: errorMetadata };
|
|
5
|
+
};
|
|
10
6
|
const getText = function ({ locationInfo, errorProps }) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return parts.join('\n\n')
|
|
18
|
-
}
|
|
19
|
-
|
|
7
|
+
const parts = [locationInfo, getErrorProps(errorProps)].filter(Boolean);
|
|
8
|
+
if (parts.length === 0) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
return parts.join('\n\n');
|
|
12
|
+
};
|
|
20
13
|
const getErrorProps = function (errorProps) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
14
|
+
if (errorProps === undefined) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
return `Error properties:\n${errorProps}`;
|
|
18
|
+
};
|
package/lib/error/parse/stack.js
CHANGED
|
@@ -1,43 +1,34 @@
|
|
|
1
|
-
import { cleanStacks } from './clean_stack.js'
|
|
2
|
-
|
|
1
|
+
import { cleanStacks } from './clean_stack.js';
|
|
3
2
|
// Retrieve the stack trace
|
|
4
3
|
export const getStackInfo = function ({ message, stack, stackType, rawStack, severity, debug }) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
4
|
+
const { message: messageA, stack: stackA } = splitStackInfo({ message, stack, stackType });
|
|
5
|
+
const messageB = severity === 'none' ? messageA.replace(SUCCESS_ERROR_NAME, '') : messageA;
|
|
6
|
+
const stackB = cleanStacks({ stack: stackA, rawStack, debug });
|
|
7
|
+
return { message: messageB, stack: stackB };
|
|
8
|
+
};
|
|
11
9
|
const splitStackInfo = function ({ message, stack, stackType }) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
return splitStack(stack)
|
|
24
|
-
}
|
|
25
|
-
|
|
10
|
+
// Some errors should not show any stack trace
|
|
11
|
+
if (stackType === 'none') {
|
|
12
|
+
return { message };
|
|
13
|
+
}
|
|
14
|
+
// Some errors have their stack trace inside `error.message` instead of
|
|
15
|
+
// `error.stack` due to IPC
|
|
16
|
+
if (stackType === 'message') {
|
|
17
|
+
return splitStack(message);
|
|
18
|
+
}
|
|
19
|
+
return splitStack(stack);
|
|
20
|
+
};
|
|
26
21
|
const splitStack = function (string) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
return { message: messageA, stack: stackA }
|
|
37
|
-
}
|
|
38
|
-
|
|
22
|
+
const lines = string.split('\n');
|
|
23
|
+
const stackIndex = lines.findIndex(isStackTrace);
|
|
24
|
+
if (stackIndex === -1) {
|
|
25
|
+
return { message: string };
|
|
26
|
+
}
|
|
27
|
+
const messageA = lines.slice(0, stackIndex).join('\n');
|
|
28
|
+
const stackA = lines.slice(stackIndex).join('\n');
|
|
29
|
+
return { message: messageA, stack: stackA };
|
|
30
|
+
};
|
|
39
31
|
const isStackTrace = function (line) {
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const SUCCESS_ERROR_NAME = 'Error: '
|
|
32
|
+
return line.trim().startsWith('at ');
|
|
33
|
+
};
|
|
34
|
+
const SUCCESS_ERROR_NAME = 'Error: ';
|
package/lib/error/type.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
// Retrieve error-type specific information
|
|
2
2
|
export const getTypeInfo = function ({ type }) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
3
|
+
const typeA = TYPES[type] === undefined ? DEFAULT_TYPE : type;
|
|
4
|
+
return { type: typeA, ...TYPES[typeA] };
|
|
5
|
+
};
|
|
7
6
|
// List of error types, and their related properties
|
|
8
7
|
// Related to build error logs:
|
|
9
8
|
// - `showInBuildLog`: `true` when we want this error to show in build logs (defaults to true)
|
|
@@ -40,150 +39,133 @@ export const getTypeInfo = function ({ type }) {
|
|
|
40
39
|
// for new errors of that type. You must use the bookmark menu action "Update
|
|
41
40
|
// with current filters"
|
|
42
41
|
const TYPES = {
|
|
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
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
stackType: 'stack',
|
|
172
|
-
showErrorProps: true,
|
|
173
|
-
rawStack: true,
|
|
174
|
-
severity: 'error',
|
|
175
|
-
},
|
|
176
|
-
|
|
177
|
-
// Errors related with the telemetry output
|
|
178
|
-
telemetry: {
|
|
179
|
-
showInBuildLog: false,
|
|
180
|
-
title: 'Telemetry error',
|
|
181
|
-
stackType: 'stack',
|
|
182
|
-
showErrorProps: true,
|
|
183
|
-
rawStack: true,
|
|
184
|
-
severity: 'error',
|
|
185
|
-
},
|
|
186
|
-
}
|
|
187
|
-
|
|
42
|
+
// Plugin called `utils.build.cancelBuild()`
|
|
43
|
+
cancelBuild: {
|
|
44
|
+
title: ({ location: { packageName } }) => `Build canceled by ${packageName}`,
|
|
45
|
+
stackType: 'stack',
|
|
46
|
+
locationType: 'buildFail',
|
|
47
|
+
severity: 'none',
|
|
48
|
+
},
|
|
49
|
+
// User configuration error (`@netlify/config`, wrong Node.js version)
|
|
50
|
+
resolveConfig: {
|
|
51
|
+
title: 'Configuration error',
|
|
52
|
+
stackType: 'none',
|
|
53
|
+
severity: 'info',
|
|
54
|
+
},
|
|
55
|
+
// Error while installing user packages (missing plugins, local plugins or functions dependencies)
|
|
56
|
+
dependencies: {
|
|
57
|
+
title: 'Dependencies installation error',
|
|
58
|
+
stackType: 'none',
|
|
59
|
+
severity: 'info',
|
|
60
|
+
},
|
|
61
|
+
// User misconfigured a plugin
|
|
62
|
+
pluginInput: {
|
|
63
|
+
title: ({ location: { packageName, input } }) => `Plugin "${packageName}" invalid input "${input}"`,
|
|
64
|
+
stackType: 'none',
|
|
65
|
+
locationType: 'buildFail',
|
|
66
|
+
severity: 'info',
|
|
67
|
+
},
|
|
68
|
+
// `build.command` non-0 exit code
|
|
69
|
+
buildCommand: {
|
|
70
|
+
title: '"build.command" failed',
|
|
71
|
+
group: ({ location: { buildCommand } }) => buildCommand,
|
|
72
|
+
stackType: 'message',
|
|
73
|
+
locationType: 'buildCommand',
|
|
74
|
+
severity: 'info',
|
|
75
|
+
},
|
|
76
|
+
// User error during Functions bundling
|
|
77
|
+
functionsBundling: {
|
|
78
|
+
title: ({ location: { functionName, functionType } }) => {
|
|
79
|
+
if (functionType === 'edge') {
|
|
80
|
+
return 'Bundling of edge function failed';
|
|
81
|
+
}
|
|
82
|
+
return `Bundling of function "${functionName}" failed`;
|
|
83
|
+
},
|
|
84
|
+
group: ({ location: { functionType = 'serverless' } }) => `Bundling of ${functionType} function failed`,
|
|
85
|
+
stackType: 'none',
|
|
86
|
+
locationType: 'functionsBundling',
|
|
87
|
+
severity: 'info',
|
|
88
|
+
},
|
|
89
|
+
// Plugin called `utils.build.failBuild()`
|
|
90
|
+
failBuild: {
|
|
91
|
+
title: ({ location: { packageName } }) => `Plugin "${packageName}" failed`,
|
|
92
|
+
stackType: 'stack',
|
|
93
|
+
locationType: 'buildFail',
|
|
94
|
+
severity: 'info',
|
|
95
|
+
},
|
|
96
|
+
// Plugin called `utils.build.failPlugin()`
|
|
97
|
+
failPlugin: {
|
|
98
|
+
title: ({ location: { packageName } }) => `Plugin "${packageName}" failed`,
|
|
99
|
+
stackType: 'stack',
|
|
100
|
+
locationType: 'buildFail',
|
|
101
|
+
severity: 'info',
|
|
102
|
+
},
|
|
103
|
+
// Plugin has an invalid shape
|
|
104
|
+
pluginValidation: {
|
|
105
|
+
title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
|
|
106
|
+
stackType: 'stack',
|
|
107
|
+
locationType: 'buildFail',
|
|
108
|
+
severity: 'warning',
|
|
109
|
+
},
|
|
110
|
+
// Plugin threw an uncaught exception
|
|
111
|
+
pluginInternal: {
|
|
112
|
+
title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
|
|
113
|
+
stackType: 'stack',
|
|
114
|
+
showErrorProps: true,
|
|
115
|
+
rawStack: true,
|
|
116
|
+
locationType: 'buildFail',
|
|
117
|
+
severity: 'warning',
|
|
118
|
+
},
|
|
119
|
+
// Bug while orchestrating child processes
|
|
120
|
+
ipc: {
|
|
121
|
+
title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
|
|
122
|
+
stackType: 'none',
|
|
123
|
+
locationType: 'buildFail',
|
|
124
|
+
severity: 'warning',
|
|
125
|
+
},
|
|
126
|
+
// Core plugin internal error
|
|
127
|
+
corePlugin: {
|
|
128
|
+
title: ({ location: { packageName } }) => `Plugin "${packageName}" internal error`,
|
|
129
|
+
stackType: 'stack',
|
|
130
|
+
showErrorProps: true,
|
|
131
|
+
rawStack: true,
|
|
132
|
+
locationType: 'buildFail',
|
|
133
|
+
severity: 'error',
|
|
134
|
+
},
|
|
135
|
+
// Core step internal error
|
|
136
|
+
coreStep: {
|
|
137
|
+
title: ({ location: { coreStepName } }) => `Internal error during "${coreStepName}"`,
|
|
138
|
+
stackType: 'stack',
|
|
139
|
+
showErrorProps: true,
|
|
140
|
+
rawStack: true,
|
|
141
|
+
locationType: 'coreStep',
|
|
142
|
+
severity: 'error',
|
|
143
|
+
},
|
|
144
|
+
// Request error when `@netlify/build` was calling Netlify API
|
|
145
|
+
api: {
|
|
146
|
+
title: ({ location: { endpoint } }) => `API error on "${endpoint}"`,
|
|
147
|
+
stackType: 'message',
|
|
148
|
+
showErrorProps: true,
|
|
149
|
+
locationType: 'api',
|
|
150
|
+
severity: 'error',
|
|
151
|
+
},
|
|
152
|
+
// `@netlify/build` threw an uncaught exception
|
|
153
|
+
exception: {
|
|
154
|
+
title: 'Core internal error',
|
|
155
|
+
stackType: 'stack',
|
|
156
|
+
showErrorProps: true,
|
|
157
|
+
rawStack: true,
|
|
158
|
+
severity: 'error',
|
|
159
|
+
},
|
|
160
|
+
// Errors related with the telemetry output
|
|
161
|
+
telemetry: {
|
|
162
|
+
showInBuildLog: false,
|
|
163
|
+
title: 'Telemetry error',
|
|
164
|
+
stackType: 'stack',
|
|
165
|
+
showErrorProps: true,
|
|
166
|
+
rawStack: true,
|
|
167
|
+
severity: 'error',
|
|
168
|
+
},
|
|
169
|
+
};
|
|
188
170
|
// When no error type matches, it's an uncaught exception, i.e. a bug
|
|
189
|
-
const DEFAULT_TYPE = 'exception'
|
|
171
|
+
const DEFAULT_TYPE = 'exception';
|
package/lib/install/functions.js
CHANGED
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
import { dirname } from 'path'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import { logInstallFunctionDependencies } from '../log/messages/install.js'
|
|
6
|
-
|
|
7
|
-
import { installDependencies } from './main.js'
|
|
8
|
-
|
|
1
|
+
import { dirname } from 'path';
|
|
2
|
+
import readdirp from 'readdirp';
|
|
3
|
+
import { logInstallFunctionDependencies } from '../log/messages/install.js';
|
|
4
|
+
import { installDependencies } from './main.js';
|
|
9
5
|
// Install dependencies of Netlify Functions
|
|
10
6
|
export const installFunctionDependencies = async function (functionsSrc, isLocal) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
await Promise.all(packageRoots.map((packageRoot) => installDependencies({ packageRoot, isLocal })))
|
|
20
|
-
}
|
|
21
|
-
|
|
7
|
+
const packagePaths = await getPackagePaths(functionsSrc);
|
|
8
|
+
if (packagePaths.length === 0) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
logInstallFunctionDependencies();
|
|
12
|
+
const packageRoots = packagePaths.map(getPackageRoot);
|
|
13
|
+
await Promise.all(packageRoots.map((packageRoot) => installDependencies({ packageRoot, isLocal })));
|
|
14
|
+
};
|
|
22
15
|
const getPackagePaths = function (functionsSrc) {
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
16
|
+
return readdirp.promise(functionsSrc, { depth: 1, fileFilter: 'package.json' });
|
|
17
|
+
};
|
|
26
18
|
const getPackageRoot = function ({ fullPath }) {
|
|
27
|
-
|
|
28
|
-
}
|
|
19
|
+
return dirname(fullPath);
|
|
20
|
+
};
|
package/lib/install/local.js
CHANGED
|
@@ -1,62 +1,45 @@
|
|
|
1
|
-
import { packageDirectory } from 'pkg-dir'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { installDependencies } from './main.js'
|
|
6
|
-
|
|
1
|
+
import { packageDirectory } from 'pkg-dir';
|
|
2
|
+
import { logInstallLocalPluginsDeps } from '../log/messages/install.js';
|
|
3
|
+
import { installDependencies } from './main.js';
|
|
7
4
|
// Install dependencies of local plugins.
|
|
8
5
|
// Users must add this plugin to their `netlify.toml` `plugins` to use this
|
|
9
6
|
// feature. We don't want to provide it by default because this makes build
|
|
10
7
|
// slow and buggy.
|
|
11
8
|
export const installLocalPluginsDependencies = async function ({ plugins, pluginsOptions, buildDir, mode, logs }) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
logInstallLocalPluginsDeps(logs, localPluginsOptionsA)
|
|
27
|
-
await Promise.all(
|
|
28
|
-
localPluginsOptionsA.map(({ packageDir }) =>
|
|
29
|
-
installDependencies({ packageRoot: packageDir, isLocal: mode !== 'buildbot' }),
|
|
30
|
-
),
|
|
31
|
-
)
|
|
32
|
-
}
|
|
33
|
-
|
|
9
|
+
if (!plugins.some(isLocalInstallOptIn)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const localPluginsOptions = getLocalPluginsOptions(pluginsOptions);
|
|
13
|
+
if (localPluginsOptions.length === 0) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
const localPluginsOptionsA = await removeMainRoot(localPluginsOptions, buildDir);
|
|
17
|
+
if (localPluginsOptionsA.length === 0) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
logInstallLocalPluginsDeps(logs, localPluginsOptionsA);
|
|
21
|
+
await Promise.all(localPluginsOptionsA.map(({ packageDir }) => installDependencies({ packageRoot: packageDir, isLocal: mode !== 'buildbot' })));
|
|
22
|
+
};
|
|
34
23
|
const isLocalInstallOptIn = function (plugin) {
|
|
35
|
-
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const LOCAL_INSTALL_PLUGIN_NAME = '@netlify/plugin-local-install-core'
|
|
39
|
-
|
|
24
|
+
return plugin.package === LOCAL_INSTALL_PLUGIN_NAME;
|
|
25
|
+
};
|
|
26
|
+
export const LOCAL_INSTALL_PLUGIN_NAME = '@netlify/plugin-local-install-core';
|
|
40
27
|
// Core plugins and non-local plugins already have their dependencies installed
|
|
41
28
|
const getLocalPluginsOptions = function (pluginsOptions) {
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
29
|
+
return pluginsOptions.filter(isLocalPlugin).filter(isUnique).filter(hasPackageDir);
|
|
30
|
+
};
|
|
45
31
|
const isLocalPlugin = function ({ loadedFrom }) {
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
32
|
+
return loadedFrom === 'local';
|
|
33
|
+
};
|
|
49
34
|
// Remove duplicates
|
|
50
35
|
const isUnique = function ({ packageDir }, index, pluginsOptions) {
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
36
|
+
return pluginsOptions.slice(index + 1).every((pluginOption) => pluginOption.packageDir !== packageDir);
|
|
37
|
+
};
|
|
54
38
|
const hasPackageDir = function ({ packageDir }) {
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
39
|
+
return packageDir !== undefined;
|
|
40
|
+
};
|
|
58
41
|
// We only install dependencies of local plugins that have their own `package.json`
|
|
59
42
|
const removeMainRoot = async function (localPluginsOptions, buildDir) {
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
43
|
+
const mainPackageDir = await packageDirectory({ cwd: buildDir });
|
|
44
|
+
return localPluginsOptions.filter(({ packageDir }) => packageDir !== mainPackageDir);
|
|
45
|
+
};
|