@netlify/build 27.18.3 → 27.18.5-rc

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 (135) hide show
  1. package/package.json +10 -9
  2. package/src/core/bin.js +0 -83
  3. package/src/core/build.js +0 -559
  4. package/src/core/config.js +0 -186
  5. package/src/core/constants.js +0 -156
  6. package/src/core/dev.js +0 -31
  7. package/src/core/dry.js +0 -39
  8. package/src/core/feature_flags.js +0 -22
  9. package/src/core/flags.js +0 -204
  10. package/src/core/lingering.js +0 -85
  11. package/src/core/main.js +0 -165
  12. package/src/core/missing_side_file.js +0 -29
  13. package/src/core/normalize_flags.js +0 -70
  14. package/src/core/severity.js +0 -22
  15. package/src/core/user_node_version.js +0 -41
  16. package/src/env/changes.js +0 -52
  17. package/src/env/main.js +0 -19
  18. package/src/env/metadata.js +0 -81
  19. package/src/error/api.js +0 -46
  20. package/src/error/build.js +0 -50
  21. package/src/error/cancel.js +0 -8
  22. package/src/error/colors.js +0 -11
  23. package/src/error/handle.js +0 -57
  24. package/src/error/info.js +0 -46
  25. package/src/error/monitor/location.js +0 -21
  26. package/src/error/monitor/normalize.js +0 -96
  27. package/src/error/monitor/print.js +0 -42
  28. package/src/error/monitor/report.js +0 -138
  29. package/src/error/monitor/start.js +0 -69
  30. package/src/error/parse/clean_stack.js +0 -87
  31. package/src/error/parse/location.js +0 -62
  32. package/src/error/parse/normalize.js +0 -29
  33. package/src/error/parse/parse.js +0 -97
  34. package/src/error/parse/plugin.js +0 -70
  35. package/src/error/parse/properties.js +0 -23
  36. package/src/error/parse/serialize_log.js +0 -42
  37. package/src/error/parse/serialize_status.js +0 -23
  38. package/src/error/parse/stack.js +0 -43
  39. package/src/error/type.js +0 -189
  40. package/src/install/functions.js +0 -28
  41. package/src/install/local.js +0 -62
  42. package/src/install/main.js +0 -81
  43. package/src/install/missing.js +0 -67
  44. package/src/log/colors.js +0 -34
  45. package/src/log/description.js +0 -26
  46. package/src/log/header.js +0 -16
  47. package/src/log/header_func.js +0 -17
  48. package/src/log/logger.js +0 -161
  49. package/src/log/messages/compatibility.js +0 -178
  50. package/src/log/messages/config.js +0 -107
  51. package/src/log/messages/core.js +0 -70
  52. package/src/log/messages/core_steps.js +0 -104
  53. package/src/log/messages/dry.js +0 -63
  54. package/src/log/messages/install.js +0 -32
  55. package/src/log/messages/ipc.js +0 -38
  56. package/src/log/messages/mutations.js +0 -82
  57. package/src/log/messages/plugins.js +0 -39
  58. package/src/log/messages/status.js +0 -16
  59. package/src/log/messages/steps.js +0 -22
  60. package/src/log/old_version.js +0 -41
  61. package/src/log/serialize.js +0 -13
  62. package/src/log/stream.js +0 -85
  63. package/src/log/theme.js +0 -26
  64. package/src/plugins/child/diff.js +0 -55
  65. package/src/plugins/child/error.js +0 -32
  66. package/src/plugins/child/lazy.js +0 -18
  67. package/src/plugins/child/load.js +0 -29
  68. package/src/plugins/child/logic.js +0 -65
  69. package/src/plugins/child/main.js +0 -51
  70. package/src/plugins/child/run.js +0 -28
  71. package/src/plugins/child/status.js +0 -74
  72. package/src/plugins/child/typescript.js +0 -45
  73. package/src/plugins/child/utils.js +0 -56
  74. package/src/plugins/child/validate.js +0 -34
  75. package/src/plugins/compatibility.js +0 -132
  76. package/src/plugins/error.js +0 -50
  77. package/src/plugins/events.js +0 -17
  78. package/src/plugins/expected_version.js +0 -119
  79. package/src/plugins/ipc.js +0 -145
  80. package/src/plugins/list.js +0 -86
  81. package/src/plugins/load.js +0 -70
  82. package/src/plugins/manifest/check.js +0 -106
  83. package/src/plugins/manifest/load.js +0 -41
  84. package/src/plugins/manifest/main.js +0 -22
  85. package/src/plugins/manifest/path.js +0 -31
  86. package/src/plugins/manifest/validate.js +0 -108
  87. package/src/plugins/node_version.js +0 -50
  88. package/src/plugins/options.js +0 -88
  89. package/src/plugins/pinned_version.js +0 -131
  90. package/src/plugins/resolve.js +0 -152
  91. package/src/plugins/spawn.js +0 -72
  92. package/src/plugins_core/add.js +0 -49
  93. package/src/plugins_core/build_command.js +0 -75
  94. package/src/plugins_core/deploy/buildbot_client.js +0 -113
  95. package/src/plugins_core/deploy/index.js +0 -73
  96. package/src/plugins_core/deploy/manifest.yml +0 -1
  97. package/src/plugins_core/edge_functions/index.js +0 -123
  98. package/src/plugins_core/edge_functions/lib/error.js +0 -21
  99. package/src/plugins_core/edge_functions/lib/internal_manifest.js +0 -60
  100. package/src/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +0 -89
  101. package/src/plugins_core/functions/error.js +0 -163
  102. package/src/plugins_core/functions/feature_flags.js +0 -6
  103. package/src/plugins_core/functions/index.js +0 -161
  104. package/src/plugins_core/functions/utils.js +0 -66
  105. package/src/plugins_core/functions/zisi.js +0 -56
  106. package/src/plugins_core/functions_install/index.js +0 -13
  107. package/src/plugins_core/functions_install/manifest.yml +0 -1
  108. package/src/plugins_core/list.js +0 -27
  109. package/src/status/add.js +0 -36
  110. package/src/status/colors.js +0 -23
  111. package/src/status/load_error.js +0 -11
  112. package/src/status/report.js +0 -137
  113. package/src/status/success.js +0 -18
  114. package/src/steps/core_step.js +0 -92
  115. package/src/steps/error.js +0 -102
  116. package/src/steps/get.js +0 -51
  117. package/src/steps/plugin.js +0 -85
  118. package/src/steps/return.js +0 -52
  119. package/src/steps/run_core_steps.js +0 -200
  120. package/src/steps/run_step.js +0 -304
  121. package/src/steps/run_steps.js +0 -179
  122. package/src/steps/update_config.js +0 -93
  123. package/src/telemetry/main.js +0 -136
  124. package/src/time/aggregate.js +0 -146
  125. package/src/time/main.js +0 -48
  126. package/src/time/measure.js +0 -22
  127. package/src/time/report.js +0 -59
  128. package/src/utils/errors.js +0 -12
  129. package/src/utils/json.js +0 -19
  130. package/src/utils/omit.js +0 -6
  131. package/src/utils/package.js +0 -23
  132. package/src/utils/remove_falsy.js +0 -10
  133. package/src/utils/resolve.js +0 -46
  134. package/src/utils/runtime.js +0 -5
  135. package/src/utils/semver.js +0 -34
@@ -1,137 +0,0 @@
1
- import { handleBuildError } from '../error/handle.js'
2
- import { logStatuses } from '../log/messages/status.js'
3
-
4
- import { removeStatusesColors } from './colors.js'
5
-
6
- // 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
-
43
- // Some plugins might not have completed due to a build error.
44
- // In that case, we add a dummy plugin run with state "skipped".
45
- // This allows the API to know both plugins that have completed and only started
46
- const getFinalStatuses = function ({ statuses = [], pluginsOptions }) {
47
- return pluginsOptions.map(({ packageName }) => getPluginStatus(packageName, statuses))
48
- }
49
-
50
- 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
-
60
- // When not in production, print statuses to console.
61
- // Only print successful ones, since errors are logged afterwards.
62
- 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
-
76
- const shouldPrintStatus = function ({ state, summary }) {
77
- return state === 'success' && summary !== undefined
78
- }
79
-
80
- // 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
- }
@@ -1,18 +0,0 @@
1
- import { runsOnlyOnBuildFailure } from '../plugins/events.js'
2
-
3
- // The last event handler of a plugin (except for `onError` and `onEnd`)
4
- // defaults to `utils.status.show({ state: 'success' })` without any `summary`.
5
- 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
-
13
- 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 }
@@ -1,92 +0,0 @@
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
-
6
- // 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,
85
- }
86
- } catch (newError) {
87
- if (!isBuildError(newError)) {
88
- addErrorInfo(newError, { type: 'coreStep', location: { coreStepName } })
89
- }
90
- return { newError }
91
- }
92
- }
@@ -1,102 +0,0 @@
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
-
7
- // Handle build command errors and plugin errors:
8
- // - usually, propagate the error to make the build stop.
9
- // - `utils.build.cancelBuild()` also cancels the build by calling the API
10
- // - `utils.build.failPlugin()` or post-deploy errors do not make the build
11
- // stop, but are still reported, and prevent future events from the same
12
- // plugin.
13
- // 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
-
57
- // 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
-
77
- // On `utils.build.cancelBuild()`
78
- 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
-
84
- // On `utils.build.failBuild()` or uncaught exception
85
- const handleFailBuild = function ({ fullErrorInfo, newError }) {
86
- const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_build' })
87
- return { newError, newStatus }
88
- }
89
-
90
- // Unlike community plugins, core plugin bugs should be handled as system errors
91
- export const getPluginErrorType = function (error, loadedFrom) {
92
- if (!isCorePluginBug(error, loadedFrom)) {
93
- return {}
94
- }
95
-
96
- return { type: 'corePlugin' }
97
- }
98
-
99
- const isCorePluginBug = function (error, loadedFrom) {
100
- const { severity } = parseErrorInfo(error)
101
- return severity === 'warning' && loadedFrom === 'core'
102
- }
package/src/steps/get.js DELETED
@@ -1,51 +0,0 @@
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
-
7
- // Get all build steps
8
- 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
-
15
- // Get all dev steps
16
- 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
-
34
- const addCoreSteps = function (steps) {
35
- return [buildCommandCore, ...steps, bundleFunctions, bundleEdgeFunctions, deploySite]
36
- }
37
-
38
- // Sort plugin steps by event order.
39
- const sortSteps = function (steps, events) {
40
- return events.flatMap((event) => steps.filter((step) => step.event === event))
41
- }
42
-
43
- // Retrieve list of unique events
44
- const getEvents = function (steps) {
45
- const events = steps.map(getEvent)
46
- return [...new Set(events)]
47
- }
48
-
49
- const getEvent = function ({ event }) {
50
- return event
51
- }
@@ -1,85 +0,0 @@
1
- import { addErrorInfo } from '../error/info.js'
2
- import { logStepCompleted } from '../log/messages/ipc.js'
3
- import { pipePluginOutput, unpipePluginOutput } from '../log/stream.js'
4
- import { callChild } from '../plugins/ipc.js'
5
- import { getSuccessStatus } from '../status/success.js'
6
-
7
- import { getPluginErrorType } from './error.js'
8
- import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js'
9
-
10
- // Fire a plugin step
11
- export const firePluginStep = async function ({
12
- event,
13
- childProcess,
14
- packageName,
15
- pluginPackageJson,
16
- loadedFrom,
17
- origin,
18
- envChanges,
19
- errorParams,
20
- configOpts,
21
- netlifyConfig,
22
- configMutations,
23
- headersPath,
24
- redirectsPath,
25
- constants,
26
- steps,
27
- error,
28
- logs,
29
- debug,
30
- verbose,
31
- }) {
32
- const listeners = pipePluginOutput(childProcess, logs)
33
-
34
- try {
35
- const configSideFiles = await listConfigSideFiles([headersPath, redirectsPath])
36
- const {
37
- newEnvChanges,
38
- configMutations: newConfigMutations,
39
- status,
40
- } = await callChild({
41
- childProcess,
42
- eventName: 'run',
43
- payload: { event, error, envChanges, netlifyConfig, constants },
44
- logs,
45
- verbose,
46
- })
47
- const {
48
- netlifyConfig: netlifyConfigA,
49
- configMutations: configMutationsA,
50
- headersPath: headersPathA,
51
- redirectsPath: redirectsPathA,
52
- } = await updateNetlifyConfig({
53
- configOpts,
54
- netlifyConfig,
55
- headersPath,
56
- redirectsPath,
57
- configMutations,
58
- newConfigMutations,
59
- configSideFiles,
60
- errorParams,
61
- logs,
62
- debug,
63
- })
64
- const newStatus = getSuccessStatus(status, { steps, event, packageName })
65
- return {
66
- newEnvChanges,
67
- netlifyConfig: netlifyConfigA,
68
- configMutations: configMutationsA,
69
- headersPath: headersPathA,
70
- redirectsPath: redirectsPathA,
71
- newStatus,
72
- }
73
- } catch (newError) {
74
- const errorType = getPluginErrorType(newError, loadedFrom)
75
- addErrorInfo(newError, {
76
- ...errorType,
77
- plugin: { pluginPackageJson, packageName },
78
- location: { event, packageName, loadedFrom, origin },
79
- })
80
- return { newError }
81
- } finally {
82
- await unpipePluginOutput(childProcess, logs, listeners)
83
- logStepCompleted(logs, verbose)
84
- }
85
- }
@@ -1,52 +0,0 @@
1
- import { logTimer } from '../log/messages/core.js'
2
- import { logStepSuccess } from '../log/messages/steps.js'
3
-
4
- import { handleStepError } from './error.js'
5
-
6
- // Retrieve the return value of a step
7
- export const getStepReturn = function ({
8
- event,
9
- packageName,
10
- newError,
11
- newEnvChanges,
12
- newStatus,
13
- coreStep,
14
- coreStepName: timerName = `${packageName} ${event}`,
15
- childEnv,
16
- mode,
17
- api,
18
- errorMonitor,
19
- deployId,
20
- netlifyConfig,
21
- configMutations,
22
- headersPath,
23
- redirectsPath,
24
- logs,
25
- debug,
26
- timers,
27
- durationNs,
28
- testOpts,
29
- }) {
30
- if (newError !== undefined) {
31
- return handleStepError({
32
- event,
33
- newError,
34
- childEnv,
35
- mode,
36
- api,
37
- errorMonitor,
38
- deployId,
39
- coreStep,
40
- netlifyConfig,
41
- logs,
42
- debug,
43
- testOpts,
44
- })
45
- }
46
-
47
- logStepSuccess(logs)
48
-
49
- logTimer(logs, durationNs, timerName)
50
-
51
- return { newEnvChanges, netlifyConfig, configMutations, headersPath, redirectsPath, newStatus, timers }
52
- }