@netlify/build 27.20.4 → 27.20.6

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.
Files changed (133) hide show
  1. package/lib/core/bin.js +42 -59
  2. package/lib/core/build.js +333 -536
  3. package/lib/core/config.js +94 -159
  4. package/lib/core/constants.js +95 -135
  5. package/lib/core/dev.js +26 -30
  6. package/lib/core/dry.js +18 -36
  7. package/lib/core/feature_flags.js +13 -16
  8. package/lib/core/flags.js +168 -169
  9. package/lib/core/lingering.js +44 -61
  10. package/lib/core/main.js +94 -136
  11. package/lib/core/missing_side_file.js +12 -24
  12. package/lib/core/normalize_flags.js +52 -63
  13. package/lib/core/severity.js +13 -15
  14. package/lib/core/user_node_version.js +26 -35
  15. package/lib/env/changes.js +29 -37
  16. package/lib/env/main.js +10 -15
  17. package/lib/env/metadata.js +63 -76
  18. package/lib/error/api.js +31 -40
  19. package/lib/error/build.js +27 -38
  20. package/lib/error/cancel.js +5 -6
  21. package/lib/error/colors.js +7 -9
  22. package/lib/error/handle.js +38 -49
  23. package/lib/error/info.js +26 -35
  24. package/lib/error/monitor/location.js +12 -17
  25. package/lib/error/monitor/normalize.js +75 -85
  26. package/lib/error/monitor/print.js +19 -41
  27. package/lib/error/monitor/report.js +102 -121
  28. package/lib/error/monitor/start.js +43 -56
  29. package/lib/error/parse/clean_stack.js +52 -69
  30. package/lib/error/parse/location.js +40 -52
  31. package/lib/error/parse/normalize.js +18 -23
  32. package/lib/error/parse/parse.js +59 -93
  33. package/lib/error/parse/plugin.js +42 -57
  34. package/lib/error/parse/properties.js +13 -20
  35. package/lib/error/parse/serialize_log.js +29 -37
  36. package/lib/error/parse/serialize_status.js +15 -23
  37. package/lib/error/parse/stack.js +29 -38
  38. package/lib/error/type.js +132 -150
  39. package/lib/install/functions.js +16 -24
  40. package/lib/install/local.js +31 -48
  41. package/lib/install/main.js +52 -66
  42. package/lib/install/missing.js +40 -53
  43. package/lib/log/colors.js +15 -22
  44. package/lib/log/description.js +16 -21
  45. package/lib/log/header.js +11 -13
  46. package/lib/log/header_func.js +11 -15
  47. package/lib/log/logger.js +88 -119
  48. package/lib/log/messages/compatibility.js +100 -158
  49. package/lib/log/messages/config.js +76 -92
  50. package/lib/log/messages/core.js +40 -60
  51. package/lib/log/messages/core_steps.js +63 -92
  52. package/lib/log/messages/dry.js +31 -53
  53. package/lib/log/messages/install.js +21 -28
  54. package/lib/log/messages/ipc.js +21 -30
  55. package/lib/log/messages/mutations.js +51 -71
  56. package/lib/log/messages/plugins.js +18 -31
  57. package/lib/log/messages/status.js +12 -14
  58. package/lib/log/messages/steps.js +14 -18
  59. package/lib/log/old_version.js +23 -32
  60. package/lib/log/serialize.js +7 -10
  61. package/lib/log/stream.js +48 -65
  62. package/lib/log/theme.js +22 -23
  63. package/lib/plugins/child/diff.js +31 -40
  64. package/lib/plugins/child/error.js +20 -26
  65. package/lib/plugins/child/lazy.js +11 -14
  66. package/lib/plugins/child/load.js +15 -22
  67. package/lib/plugins/child/logic.js +51 -58
  68. package/lib/plugins/child/main.js +32 -46
  69. package/lib/plugins/child/run.js +18 -27
  70. package/lib/plugins/child/status.js +52 -63
  71. package/lib/plugins/child/typescript.js +19 -36
  72. package/lib/plugins/child/utils.js +36 -49
  73. package/lib/plugins/child/validate.js +25 -28
  74. package/lib/plugins/compatibility.js +64 -92
  75. package/lib/plugins/error.js +29 -35
  76. package/lib/plugins/events.js +7 -12
  77. package/lib/plugins/expected_version.js +61 -99
  78. package/lib/plugins/ipc.js +79 -102
  79. package/lib/plugins/list.js +49 -62
  80. package/lib/plugins/load.js +44 -64
  81. package/lib/plugins/manifest/check.js +64 -85
  82. package/lib/plugins/manifest/load.js +34 -37
  83. package/lib/plugins/manifest/main.js +16 -21
  84. package/lib/plugins/manifest/path.js +18 -25
  85. package/lib/plugins/manifest/validate.js +77 -94
  86. package/lib/plugins/node_version.js +22 -42
  87. package/lib/plugins/options.js +45 -78
  88. package/lib/plugins/pinned_version.js +58 -106
  89. package/lib/plugins/resolve.js +91 -133
  90. package/lib/plugins/spawn.js +43 -61
  91. package/lib/plugins_core/add.js +26 -40
  92. package/lib/plugins_core/build_command.js +47 -72
  93. package/lib/plugins_core/deploy/buildbot_client.js +61 -87
  94. package/lib/plugins_core/deploy/index.js +47 -71
  95. package/lib/plugins_core/edge_functions/index.js +73 -116
  96. package/lib/plugins_core/edge_functions/lib/error.js +13 -17
  97. package/lib/plugins_core/edge_functions/lib/internal_manifest.js +45 -55
  98. package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +65 -80
  99. package/lib/plugins_core/functions/error.js +88 -128
  100. package/lib/plugins_core/functions/feature_flags.js +5 -5
  101. package/lib/plugins_core/functions/index.js +98 -145
  102. package/lib/plugins_core/functions/utils.js +36 -57
  103. package/lib/plugins_core/functions/zisi.js +35 -52
  104. package/lib/plugins_core/functions_install/index.js +8 -11
  105. package/lib/plugins_core/list.js +15 -22
  106. package/lib/status/add.js +26 -32
  107. package/lib/status/colors.js +14 -19
  108. package/lib/status/load_error.js +8 -9
  109. package/lib/status/report.js +72 -126
  110. package/lib/status/success.js +10 -14
  111. package/lib/steps/core_step.js +54 -89
  112. package/lib/steps/error.js +50 -87
  113. package/lib/steps/get.js +33 -41
  114. package/lib/steps/plugin.js +53 -83
  115. package/lib/steps/return.js +24 -51
  116. package/lib/steps/run_core_steps.js +119 -171
  117. package/lib/steps/run_step.js +154 -270
  118. package/lib/steps/run_steps.js +91 -174
  119. package/lib/steps/update_config.js +45 -72
  120. package/lib/telemetry/main.js +89 -128
  121. package/lib/time/aggregate.js +84 -110
  122. package/lib/time/main.js +23 -34
  123. package/lib/time/measure.js +11 -15
  124. package/lib/time/report.js +32 -44
  125. package/lib/utils/errors.js +10 -9
  126. package/lib/utils/json.js +11 -15
  127. package/lib/utils/omit.js +3 -4
  128. package/lib/utils/package.js +19 -22
  129. package/lib/utils/remove_falsy.js +5 -7
  130. package/lib/utils/resolve.js +30 -34
  131. package/lib/utils/runtime.js +4 -4
  132. package/lib/utils/semver.js +19 -25
  133. package/package.json +14 -7
@@ -1,137 +1,83 @@
1
- import { handleBuildError } from '../error/handle.js'
2
- import { logStatuses } from '../log/messages/status.js'
3
-
4
- import { removeStatusesColors } from './colors.js'
5
-
1
+ import { handleBuildError } from '../error/handle.js';
2
+ import { logStatuses } from '../log/messages/status.js';
3
+ import { removeStatusesColors } from './colors.js';
6
4
  // Report plugin statuses to the console and API
7
- export const reportStatuses = async function ({
8
- statuses,
9
- childEnv,
10
- api,
11
- mode,
12
- pluginsOptions,
13
- netlifyConfig,
14
- errorMonitor,
15
- deployId,
16
- logs,
17
- debug,
18
- sendStatus,
19
- testOpts,
20
- }) {
21
- const finalStatuses = getFinalStatuses({ statuses, pluginsOptions })
22
- if (finalStatuses.length === 0) {
23
- return
24
- }
25
-
26
- const statusesA = removeStatusesColors(finalStatuses)
27
- printStatuses({ statuses: statusesA, mode, logs })
28
- await sendApiStatuses({
29
- statuses: statusesA,
30
- childEnv,
31
- api,
32
- mode,
33
- netlifyConfig,
34
- errorMonitor,
35
- deployId,
36
- logs,
37
- debug,
38
- sendStatus,
39
- testOpts,
40
- })
41
- }
42
-
5
+ export const reportStatuses = async function ({ statuses, childEnv, api, mode, pluginsOptions, netlifyConfig, errorMonitor, deployId, logs, debug, sendStatus, testOpts, }) {
6
+ const finalStatuses = getFinalStatuses({ statuses, pluginsOptions });
7
+ if (finalStatuses.length === 0) {
8
+ return;
9
+ }
10
+ const statusesA = removeStatusesColors(finalStatuses);
11
+ printStatuses({ statuses: statusesA, mode, logs });
12
+ await sendApiStatuses({
13
+ statuses: statusesA,
14
+ childEnv,
15
+ api,
16
+ mode,
17
+ netlifyConfig,
18
+ errorMonitor,
19
+ deployId,
20
+ logs,
21
+ debug,
22
+ sendStatus,
23
+ testOpts,
24
+ });
25
+ };
43
26
  // Some plugins might not have completed due to a build error.
44
27
  // In that case, we add a dummy plugin run with state "skipped".
45
28
  // This allows the API to know both plugins that have completed and only started
46
29
  const getFinalStatuses = function ({ statuses = [], pluginsOptions }) {
47
- return pluginsOptions.map(({ packageName }) => getPluginStatus(packageName, statuses))
48
- }
49
-
30
+ return pluginsOptions.map(({ packageName }) => getPluginStatus(packageName, statuses));
31
+ };
50
32
  const getPluginStatus = function (packageName, statuses) {
51
- const pluginStatus = statuses.find((status) => status.packageName === packageName)
52
-
53
- if (pluginStatus !== undefined) {
54
- return pluginStatus
55
- }
56
-
57
- return { packageName, state: 'skipped' }
58
- }
59
-
33
+ const pluginStatus = statuses.find((status) => status.packageName === packageName);
34
+ if (pluginStatus !== undefined) {
35
+ return pluginStatus;
36
+ }
37
+ return { packageName, state: 'skipped' };
38
+ };
60
39
  // When not in production, print statuses to console.
61
40
  // Only print successful ones, since errors are logged afterwards.
62
41
  const printStatuses = function ({ statuses, mode, logs }) {
63
- if (mode === 'buildbot') {
64
- return
65
- }
66
-
67
- const successStatuses = statuses.filter(shouldPrintStatus)
68
-
69
- if (successStatuses.length === 0) {
70
- return
71
- }
72
-
73
- logStatuses(logs, successStatuses)
74
- }
75
-
42
+ if (mode === 'buildbot') {
43
+ return;
44
+ }
45
+ const successStatuses = statuses.filter(shouldPrintStatus);
46
+ if (successStatuses.length === 0) {
47
+ return;
48
+ }
49
+ logStatuses(logs, successStatuses);
50
+ };
76
51
  const shouldPrintStatus = function ({ state, summary }) {
77
- return state === 'success' && summary !== undefined
78
- }
79
-
52
+ return state === 'success' && summary !== undefined;
53
+ };
80
54
  // In production, send statuses to the API
81
- const sendApiStatuses = async function ({
82
- statuses,
83
- childEnv,
84
- api,
85
- mode,
86
- netlifyConfig,
87
- errorMonitor,
88
- deployId,
89
- logs,
90
- debug,
91
- sendStatus,
92
- testOpts,
93
- }) {
94
- if ((mode !== 'buildbot' && !sendStatus) || api === undefined || !deployId) {
95
- return
96
- }
97
-
98
- await Promise.all(
99
- statuses.map((status) =>
100
- sendApiStatus({ api, status, childEnv, mode, netlifyConfig, errorMonitor, deployId, logs, debug, testOpts }),
101
- ),
102
- )
103
- }
104
-
105
- const sendApiStatus = async function ({
106
- api,
107
- status: { packageName, version, state, event, title, summary, text, extraData },
108
- childEnv,
109
- mode,
110
- netlifyConfig,
111
- errorMonitor,
112
- deployId,
113
- logs,
114
- debug,
115
- testOpts,
116
- }) {
117
- try {
118
- await api.createPluginRun({
119
- deploy_id: deployId,
120
- body: {
121
- package: packageName,
122
- version,
123
- state,
124
- reporting_event: event,
125
- title,
126
- summary,
127
- text,
128
- extra_data: extraData,
129
- },
130
- })
131
- // Bitballoon API randomly fails with 502.
132
- // Builds should be successful when this API call fails, but we still want
133
- // to report the error both in logs and in error monitoring.
134
- } catch (error) {
135
- await handleBuildError(error, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts })
136
- }
137
- }
55
+ const sendApiStatuses = async function ({ statuses, childEnv, api, mode, netlifyConfig, errorMonitor, deployId, logs, debug, sendStatus, testOpts, }) {
56
+ if ((mode !== 'buildbot' && !sendStatus) || api === undefined || !deployId) {
57
+ return;
58
+ }
59
+ await Promise.all(statuses.map((status) => sendApiStatus({ api, status, childEnv, mode, netlifyConfig, errorMonitor, deployId, logs, debug, testOpts })));
60
+ };
61
+ const sendApiStatus = async function ({ api, status: { packageName, version, state, event, title, summary, text, extraData }, childEnv, mode, netlifyConfig, errorMonitor, deployId, logs, debug, testOpts, }) {
62
+ try {
63
+ await api.createPluginRun({
64
+ deploy_id: deployId,
65
+ body: {
66
+ package: packageName,
67
+ version,
68
+ state,
69
+ reporting_event: event,
70
+ title,
71
+ summary,
72
+ text,
73
+ extra_data: extraData,
74
+ },
75
+ });
76
+ // Bitballoon API randomly fails with 502.
77
+ // Builds should be successful when this API call fails, but we still want
78
+ // to report the error both in logs and in error monitoring.
79
+ }
80
+ catch (error) {
81
+ await handleBuildError(error, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts });
82
+ }
83
+ };
@@ -1,18 +1,14 @@
1
- import { runsOnlyOnBuildFailure } from '../plugins/events.js'
2
-
1
+ import { runsOnlyOnBuildFailure } from '../plugins/events.js';
3
2
  // The last event handler of a plugin (except for `onError` and `onEnd`)
4
3
  // defaults to `utils.status.show({ state: 'success' })` without any `summary`.
5
4
  export const getSuccessStatus = function (newStatus, { steps, event, packageName }) {
6
- if (newStatus === undefined && isLastNonErrorStep({ steps, event, packageName })) {
7
- return IMPLICIT_STATUS
8
- }
9
-
10
- return newStatus
11
- }
12
-
5
+ if (newStatus === undefined && isLastNonErrorStep({ steps, event, packageName })) {
6
+ return IMPLICIT_STATUS;
7
+ }
8
+ return newStatus;
9
+ };
13
10
  const isLastNonErrorStep = function ({ steps, event, packageName }) {
14
- const nonErrorSteps = steps.filter((step) => step.packageName === packageName && !runsOnlyOnBuildFailure(step.event))
15
- return nonErrorSteps.length === 0 || nonErrorSteps[nonErrorSteps.length - 1].event === event
16
- }
17
-
18
- const IMPLICIT_STATUS = { state: 'success', implicit: true }
11
+ const nonErrorSteps = steps.filter((step) => step.packageName === packageName && !runsOnlyOnBuildFailure(step.event));
12
+ return nonErrorSteps.length === 0 || nonErrorSteps[nonErrorSteps.length - 1].event === event;
13
+ };
14
+ const IMPLICIT_STATUS = { state: 'success', implicit: true };
@@ -1,92 +1,57 @@
1
- import { setEnvChanges } from '../env/changes.js'
2
- import { addErrorInfo, isBuildError } from '../error/info.js'
3
-
4
- import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js'
5
-
1
+ import { setEnvChanges } from '../env/changes.js';
2
+ import { addErrorInfo, isBuildError } from '../error/info.js';
3
+ import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js';
6
4
  // Fire a core step
7
- export const fireCoreStep = async function ({
8
- coreStep,
9
- coreStepName,
10
- configPath,
11
- buildDir,
12
- repositoryRoot,
13
- constants,
14
- buildbotServerSocket,
15
- events,
16
- logs,
17
- nodePath,
18
- childEnv,
19
- context,
20
- branch,
21
- envChanges,
22
- errorParams,
23
- configOpts,
24
- netlifyConfig,
25
- configMutations,
26
- headersPath,
27
- redirectsPath,
28
- featureFlags,
29
- debug,
30
- systemLog,
31
- saveConfig,
32
- }) {
33
- try {
34
- const configSideFiles = await listConfigSideFiles([headersPath, redirectsPath])
35
- const childEnvA = setEnvChanges(envChanges, { ...childEnv })
36
- const {
37
- newEnvChanges = {},
38
- configMutations: newConfigMutations = [],
39
- tags,
40
- } = await coreStep({
41
- configPath,
42
- buildDir,
43
- repositoryRoot,
44
- constants,
45
- buildbotServerSocket,
46
- events,
47
- logs,
48
- context,
49
- branch,
50
- childEnv: childEnvA,
51
- netlifyConfig,
52
- nodePath,
53
- configMutations,
54
- headersPath,
55
- redirectsPath,
56
- featureFlags,
57
- debug,
58
- systemLog,
59
- saveConfig,
60
- })
61
- const {
62
- netlifyConfig: netlifyConfigA,
63
- configMutations: configMutationsA,
64
- headersPath: headersPathA,
65
- redirectsPath: redirectsPathA,
66
- } = await updateNetlifyConfig({
67
- configOpts,
68
- netlifyConfig,
69
- headersPath,
70
- redirectsPath,
71
- configMutations,
72
- newConfigMutations,
73
- configSideFiles,
74
- errorParams,
75
- logs,
76
- debug,
77
- })
78
- return {
79
- newEnvChanges,
80
- netlifyConfig: netlifyConfigA,
81
- configMutations: configMutationsA,
82
- headersPath: headersPathA,
83
- redirectsPath: redirectsPathA,
84
- tags,
5
+ export const fireCoreStep = async function ({ coreStep, coreStepName, configPath, buildDir, repositoryRoot, constants, buildbotServerSocket, events, logs, nodePath, childEnv, context, branch, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, featureFlags, debug, systemLog, saveConfig, }) {
6
+ try {
7
+ const configSideFiles = await listConfigSideFiles([headersPath, redirectsPath]);
8
+ const childEnvA = setEnvChanges(envChanges, { ...childEnv });
9
+ const { newEnvChanges = {}, configMutations: newConfigMutations = [], tags, } = await coreStep({
10
+ configPath,
11
+ buildDir,
12
+ repositoryRoot,
13
+ constants,
14
+ buildbotServerSocket,
15
+ events,
16
+ logs,
17
+ context,
18
+ branch,
19
+ childEnv: childEnvA,
20
+ netlifyConfig,
21
+ nodePath,
22
+ configMutations,
23
+ headersPath,
24
+ redirectsPath,
25
+ featureFlags,
26
+ debug,
27
+ systemLog,
28
+ saveConfig,
29
+ });
30
+ const { netlifyConfig: netlifyConfigA, configMutations: configMutationsA, headersPath: headersPathA, redirectsPath: redirectsPathA, } = await updateNetlifyConfig({
31
+ configOpts,
32
+ netlifyConfig,
33
+ headersPath,
34
+ redirectsPath,
35
+ configMutations,
36
+ newConfigMutations,
37
+ configSideFiles,
38
+ errorParams,
39
+ logs,
40
+ debug,
41
+ });
42
+ return {
43
+ newEnvChanges,
44
+ netlifyConfig: netlifyConfigA,
45
+ configMutations: configMutationsA,
46
+ headersPath: headersPathA,
47
+ redirectsPath: redirectsPathA,
48
+ tags,
49
+ };
85
50
  }
86
- } catch (newError) {
87
- if (!isBuildError(newError)) {
88
- addErrorInfo(newError, { type: 'coreStep', location: { coreStepName } })
51
+ catch (newError) {
52
+ if (!isBuildError(newError)) {
53
+ addErrorInfo(newError, { type: 'coreStep', location: { coreStepName } });
54
+ }
55
+ return { newError };
89
56
  }
90
- return { newError }
91
- }
92
- }
57
+ };
@@ -1,9 +1,8 @@
1
- import { cancelBuild } from '../error/cancel.js'
2
- import { handleBuildError } from '../error/handle.js'
3
- import { getFullErrorInfo, parseErrorInfo } from '../error/parse/parse.js'
4
- import { serializeErrorStatus } from '../error/parse/serialize_status.js'
5
- import { isSoftFailEvent } from '../plugins/events.js'
6
-
1
+ import { cancelBuild } from '../error/cancel.js';
2
+ import { handleBuildError } from '../error/handle.js';
3
+ import { getFullErrorInfo, parseErrorInfo } from '../error/parse/parse.js';
4
+ import { serializeErrorStatus } from '../error/parse/serialize_status.js';
5
+ import { isSoftFailEvent } from '../plugins/events.js';
7
6
  // Handle build command errors and plugin errors:
8
7
  // - usually, propagate the error to make the build stop.
9
8
  // - `utils.build.cancelBuild()` also cancels the build by calling the API
@@ -11,92 +10,56 @@ import { isSoftFailEvent } from '../plugins/events.js'
11
10
  // stop, but are still reported, and prevent future events from the same
12
11
  // plugin.
13
12
  // This also computes error statuses that are sent to the API.
14
- export const handleStepError = function ({
15
- event,
16
- newError,
17
- childEnv,
18
- mode,
19
- api,
20
- errorMonitor,
21
- deployId,
22
- coreStep,
23
- netlifyConfig,
24
- logs,
25
- debug,
26
- testOpts,
27
- }) {
28
- // Core steps do not report error statuses
29
- if (coreStep !== undefined) {
30
- return { newError }
31
- }
32
-
33
- const fullErrorInfo = getFullErrorInfo({ error: newError, colors: false, debug })
34
- const { type } = fullErrorInfo
35
-
36
- if (type === 'failPlugin' || isSoftFailEvent(event)) {
37
- return handleFailPlugin({
38
- fullErrorInfo,
39
- newError,
40
- childEnv,
41
- mode,
42
- errorMonitor,
43
- netlifyConfig,
44
- logs,
45
- debug,
46
- testOpts,
47
- })
48
- }
49
-
50
- if (type === 'cancelBuild') {
51
- return handleCancelBuild({ fullErrorInfo, newError, api, deployId })
52
- }
53
-
54
- return handleFailBuild({ fullErrorInfo, newError })
55
- }
56
-
13
+ export const handleStepError = function ({ event, newError, childEnv, mode, api, errorMonitor, deployId, coreStep, netlifyConfig, logs, debug, testOpts, }) {
14
+ // Core steps do not report error statuses
15
+ if (coreStep !== undefined) {
16
+ return { newError };
17
+ }
18
+ const fullErrorInfo = getFullErrorInfo({ error: newError, colors: false, debug });
19
+ const { type } = fullErrorInfo;
20
+ if (type === 'failPlugin' || isSoftFailEvent(event)) {
21
+ return handleFailPlugin({
22
+ fullErrorInfo,
23
+ newError,
24
+ childEnv,
25
+ mode,
26
+ errorMonitor,
27
+ netlifyConfig,
28
+ logs,
29
+ debug,
30
+ testOpts,
31
+ });
32
+ }
33
+ if (type === 'cancelBuild') {
34
+ return handleCancelBuild({ fullErrorInfo, newError, api, deployId });
35
+ }
36
+ return handleFailBuild({ fullErrorInfo, newError });
37
+ };
57
38
  // On `utils.build.failPlugin()` or during `onSuccess` or `onEnd`
58
- const handleFailPlugin = async function ({
59
- fullErrorInfo,
60
- fullErrorInfo: {
61
- errorInfo: { location: { packageName } = {} },
62
- },
63
- newError,
64
- childEnv,
65
- mode,
66
- errorMonitor,
67
- netlifyConfig,
68
- logs,
69
- debug,
70
- testOpts,
71
- }) {
72
- const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_plugin' })
73
- await handleBuildError(newError, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts })
74
- return { failedPlugin: [packageName], newStatus }
75
- }
76
-
39
+ const handleFailPlugin = async function ({ fullErrorInfo, fullErrorInfo: { errorInfo: { location: { packageName } = {} }, }, newError, childEnv, mode, errorMonitor, netlifyConfig, logs, debug, testOpts, }) {
40
+ const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_plugin' });
41
+ await handleBuildError(newError, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts });
42
+ return { failedPlugin: [packageName], newStatus };
43
+ };
77
44
  // On `utils.build.cancelBuild()`
78
45
  const handleCancelBuild = async function ({ fullErrorInfo, newError, api, deployId }) {
79
- const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'canceled_build' })
80
- await cancelBuild({ api, deployId })
81
- return { newError, newStatus }
82
- }
83
-
46
+ const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'canceled_build' });
47
+ await cancelBuild({ api, deployId });
48
+ return { newError, newStatus };
49
+ };
84
50
  // On `utils.build.failBuild()` or uncaught exception
85
51
  const handleFailBuild = function ({ fullErrorInfo, newError }) {
86
- const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_build' })
87
- return { newError, newStatus }
88
- }
89
-
52
+ const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_build' });
53
+ return { newError, newStatus };
54
+ };
90
55
  // Unlike community plugins, core plugin bugs should be handled as system errors
91
56
  export const getPluginErrorType = function (error, loadedFrom) {
92
- if (!isCorePluginBug(error, loadedFrom)) {
93
- return {}
94
- }
95
-
96
- return { type: 'corePlugin' }
97
- }
98
-
57
+ if (!isCorePluginBug(error, loadedFrom)) {
58
+ return {};
59
+ }
60
+ return { type: 'corePlugin' };
61
+ };
99
62
  const isCorePluginBug = function (error, loadedFrom) {
100
- const { severity } = parseErrorInfo(error)
101
- return severity === 'warning' && loadedFrom === 'core'
102
- }
63
+ const { severity } = parseErrorInfo(error);
64
+ return severity === 'warning' && loadedFrom === 'core';
65
+ };
package/lib/steps/get.js CHANGED
@@ -1,51 +1,43 @@
1
- import { DEV_EVENTS, EVENTS } from '../plugins/events.js'
2
- import { buildCommandCore } from '../plugins_core/build_command.js'
3
- import { deploySite } from '../plugins_core/deploy/index.js'
4
- import { bundleEdgeFunctions } from '../plugins_core/edge_functions/index.js'
5
- import { bundleFunctions } from '../plugins_core/functions/index.js'
6
-
1
+ import { DEV_EVENTS, EVENTS } from '../plugins/events.js';
2
+ import { buildCommandCore } from '../plugins_core/build_command.js';
3
+ import { deploySite } from '../plugins_core/deploy/index.js';
4
+ import { bundleEdgeFunctions } from '../plugins_core/edge_functions/index.js';
5
+ import { bundleFunctions } from '../plugins_core/functions/index.js';
7
6
  // Get all build steps
8
7
  export const getSteps = function (steps) {
9
- const stepsA = addCoreSteps(steps)
10
- const stepsB = sortSteps(stepsA, EVENTS)
11
- const events = getEvents(stepsB)
12
- return { steps: stepsB, events }
13
- }
14
-
8
+ const stepsA = addCoreSteps(steps);
9
+ const stepsB = sortSteps(stepsA, EVENTS);
10
+ const events = getEvents(stepsB);
11
+ return { steps: stepsB, events };
12
+ };
15
13
  // Get all dev steps
16
14
  export const getDevSteps = function (command, steps) {
17
- const devCommandStep = {
18
- event: 'onDev',
19
- coreStep: async () => {
20
- await command()
21
-
22
- return {}
23
- },
24
- coreStepId: 'dev_command',
25
- coreStepName: 'dev.command',
26
- coreStepDescription: () => 'Run command for local development',
27
- }
28
- const sortedSteps = sortSteps([...steps, devCommandStep], DEV_EVENTS)
29
- const events = getEvents(sortedSteps)
30
-
31
- return { steps: sortedSteps, events }
32
- }
33
-
15
+ const devCommandStep = {
16
+ event: 'onDev',
17
+ coreStep: async () => {
18
+ await command();
19
+ return {};
20
+ },
21
+ coreStepId: 'dev_command',
22
+ coreStepName: 'dev.command',
23
+ coreStepDescription: () => 'Run command for local development',
24
+ };
25
+ const sortedSteps = sortSteps([...steps, devCommandStep], DEV_EVENTS);
26
+ const events = getEvents(sortedSteps);
27
+ return { steps: sortedSteps, events };
28
+ };
34
29
  const addCoreSteps = function (steps) {
35
- return [buildCommandCore, ...steps, bundleFunctions, bundleEdgeFunctions, deploySite]
36
- }
37
-
30
+ return [buildCommandCore, ...steps, bundleFunctions, bundleEdgeFunctions, deploySite];
31
+ };
38
32
  // Sort plugin steps by event order.
39
33
  const sortSteps = function (steps, events) {
40
- return events.flatMap((event) => steps.filter((step) => step.event === event))
41
- }
42
-
34
+ return events.flatMap((event) => steps.filter((step) => step.event === event));
35
+ };
43
36
  // Retrieve list of unique events
44
37
  const getEvents = function (steps) {
45
- const events = steps.map(getEvent)
46
- return [...new Set(events)]
47
- }
48
-
38
+ const events = steps.map(getEvent);
39
+ return [...new Set(events)];
40
+ };
49
41
  const getEvent = function ({ event }) {
50
- return event
51
- }
42
+ return event;
43
+ };