@netlify/build 18.13.12 → 18.15.1
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/package.json +4 -2
- package/src/core/config.js +1 -1
- package/src/core/constants.js +1 -1
- package/src/core/dry.js +10 -10
- package/src/core/feature_flags.js +1 -0
- package/src/core/flags.js +2 -2
- package/src/core/main.js +21 -21
- package/src/error/parse/location.js +3 -3
- package/src/error/type.js +4 -4
- package/src/log/messages/{core_commands.js → core_steps.js} +0 -0
- package/src/log/messages/dry.js +14 -14
- package/src/log/messages/steps.js +32 -0
- package/src/log/stream.js +2 -2
- package/src/plugins/child/load.js +5 -5
- package/src/plugins/child/run.js +2 -2
- package/src/plugins/load.js +9 -9
- package/src/plugins_core/build_command.js +7 -7
- package/src/plugins_core/deploy/buildbot_client.js +1 -3
- package/src/plugins_core/deploy/index.js +5 -5
- package/src/plugins_core/functions/index.js +8 -11
- package/src/status/success.js +5 -7
- package/src/{commands/core_command.js → steps/core_step.js} +7 -7
- package/src/{commands → steps}/error.js +5 -5
- package/src/steps/get.js +35 -0
- package/src/{commands → steps}/plugin.js +5 -5
- package/src/{commands → steps}/return.js +10 -10
- package/src/{commands/run_command.js → steps/run_step.js} +38 -38
- package/src/{commands/run_commands.js → steps/run_steps.js} +19 -19
- package/src/{commands → steps}/update_config.js +0 -0
- package/src/telemetry/main.js +4 -4
- package/types/config/build.d.ts +61 -0
- package/types/config/functions.d.ts +38 -0
- package/types/config/netlify_config.d.ts +51 -0
- package/types/index.d.ts +3 -0
- package/types/netlify_event.d.ts +5 -0
- package/types/netlify_plugin.d.ts +29 -0
- package/types/netlify_plugin_options.d.ts +56 -0
- package/types/options/index.d.ts +1 -0
- package/types/options/netlify_plugin_build_util.d.ts +7 -0
- package/types/options/netlify_plugin_cache_util.d.ts +39 -0
- package/types/options/netlify_plugin_git_util.d.ts +41 -0
- package/types/options/netlify_plugin_run_util.d.ts +24 -0
- package/types/options/netlify_plugin_status_util.d.ts +24 -0
- package/types/options/netlify_plugin_utils.d.ts +13 -0
- package/types/utils/json_value.d.ts +1 -0
- package/types/utils/many.d.ts +6 -0
- package/src/commands/get.js +0 -35
- package/src/log/messages/commands.js +0 -32
package/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.15.1",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"main": "src/core/main.js",
|
|
6
|
+
"types": "types/index.d.ts",
|
|
6
7
|
"bin": {
|
|
7
8
|
"netlify-build": "./src/core/bin.js"
|
|
8
9
|
},
|
|
9
10
|
"files": [
|
|
10
11
|
"src/**/*.js",
|
|
11
|
-
"src/**/*.yml"
|
|
12
|
+
"src/**/*.yml",
|
|
13
|
+
"types/**/*.d.ts"
|
|
12
14
|
],
|
|
13
15
|
"author": "Netlify Inc.",
|
|
14
16
|
"contributors": [
|
package/src/core/config.js
CHANGED
|
@@ -123,7 +123,7 @@ const logConfigInfo = function ({ logs, configPath, buildDir, netlifyConfig, con
|
|
|
123
123
|
// normalized.
|
|
124
124
|
// We use `debug: false` to avoid any debug logs. Otherwise every configuration
|
|
125
125
|
// change would create debug logs which would be too verbose.
|
|
126
|
-
// Errors are propagated and assigned to the specific plugin or core
|
|
126
|
+
// Errors are propagated and assigned to the specific plugin or core step
|
|
127
127
|
// which changed the configuration.
|
|
128
128
|
const resolveUpdatedConfig = async function (configOpts, configMutations) {
|
|
129
129
|
try {
|
package/src/core/constants.js
CHANGED
|
@@ -52,7 +52,7 @@ const INTERNAL_FUNCTIONS_SRC = '.netlify/functions-internal'
|
|
|
52
52
|
|
|
53
53
|
// Retrieve constants which might change during the build if a plugin modifies
|
|
54
54
|
// `netlifyConfig` or creates some default directories.
|
|
55
|
-
// Unlike readonly constants, this is called again before each
|
|
55
|
+
// Unlike readonly constants, this is called again before each build step.
|
|
56
56
|
const addMutableConstants = async function ({
|
|
57
57
|
constants,
|
|
58
58
|
buildDir,
|
package/src/core/dry.js
CHANGED
|
@@ -2,27 +2,27 @@
|
|
|
2
2
|
|
|
3
3
|
const pFilter = require('p-filter')
|
|
4
4
|
|
|
5
|
-
const { logDryRunStart,
|
|
5
|
+
const { logDryRunStart, logDryRunStep, logDryRunEnd } = require('../log/messages/dry')
|
|
6
6
|
const { runsOnlyOnBuildFailure } = require('../plugins/events')
|
|
7
7
|
|
|
8
8
|
// If the `dry` flag is specified, do a dry run
|
|
9
|
-
const doDryRun = async function ({ buildDir,
|
|
10
|
-
const
|
|
11
|
-
|
|
9
|
+
const doDryRun = async function ({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs }) {
|
|
10
|
+
const successSteps = await pFilter(steps, ({ event, condition }) =>
|
|
11
|
+
shouldIncludeStep({ buildDir, event, condition, netlifyConfig, constants, buildbotServerSocket }),
|
|
12
12
|
)
|
|
13
|
-
const eventWidth = Math.max(...
|
|
14
|
-
const
|
|
13
|
+
const eventWidth = Math.max(...successSteps.map(getEventLength))
|
|
14
|
+
const stepsCount = successSteps.length
|
|
15
15
|
|
|
16
|
-
logDryRunStart({ logs, eventWidth,
|
|
16
|
+
logDryRunStart({ logs, eventWidth, stepsCount })
|
|
17
17
|
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
successSteps.forEach((step, index) => {
|
|
19
|
+
logDryRunStep({ logs, step, index, netlifyConfig, eventWidth, stepsCount })
|
|
20
20
|
})
|
|
21
21
|
|
|
22
22
|
logDryRunEnd(logs)
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
const
|
|
25
|
+
const shouldIncludeStep = async function ({
|
|
26
26
|
buildDir,
|
|
27
27
|
event,
|
|
28
28
|
condition,
|
|
@@ -15,6 +15,7 @@ const getFeatureFlag = function (name) {
|
|
|
15
15
|
|
|
16
16
|
// Default values for feature flags
|
|
17
17
|
const DEFAULT_FEATURE_FLAGS = {
|
|
18
|
+
buildbot_build_go_functions: false,
|
|
18
19
|
buildbot_es_modules_esbuild: false,
|
|
19
20
|
buildbot_zisi_esbuild_parser: false,
|
|
20
21
|
netlify_config_toml_backslash: false,
|
package/src/core/flags.js
CHANGED
|
@@ -94,12 +94,12 @@ Default: true`,
|
|
|
94
94
|
dry: {
|
|
95
95
|
alias: 'dry-run',
|
|
96
96
|
boolean: true,
|
|
97
|
-
describe: `Run in dry mode, i.e. printing
|
|
97
|
+
describe: `Run in dry mode, i.e. printing steps without executing them.
|
|
98
98
|
Default: false`,
|
|
99
99
|
},
|
|
100
100
|
nodePath: {
|
|
101
101
|
string: true,
|
|
102
|
-
describe: `Path to the Node.js binary to use in
|
|
102
|
+
describe: `Path to the Node.js binary to use in the build command and plugins.
|
|
103
103
|
Default: Current Node.js binary`,
|
|
104
104
|
},
|
|
105
105
|
functionsDistDir: {
|
package/src/core/main.js
CHANGED
|
@@ -3,8 +3,6 @@
|
|
|
3
3
|
/* eslint-disable max-lines, import/max-dependencies */
|
|
4
4
|
require('../utils/polyfills')
|
|
5
5
|
|
|
6
|
-
const { getCommands } = require('../commands/get')
|
|
7
|
-
const { runCommands } = require('../commands/run_commands')
|
|
8
6
|
const { handleBuildError } = require('../error/handle')
|
|
9
7
|
const { getErrorInfo } = require('../error/info')
|
|
10
8
|
const { startErrorMonitor } = require('../error/monitor/start')
|
|
@@ -16,6 +14,8 @@ const { pinPlugins } = require('../plugins/pinned_version')
|
|
|
16
14
|
const { startPlugins, stopPlugins } = require('../plugins/spawn')
|
|
17
15
|
const { addCorePlugins } = require('../plugins_core/add')
|
|
18
16
|
const { reportStatuses } = require('../status/report')
|
|
17
|
+
const { getSteps } = require('../steps/get')
|
|
18
|
+
const { runSteps } = require('../steps/run_steps')
|
|
19
19
|
const { trackBuildComplete } = require('../telemetry/main')
|
|
20
20
|
const { initTimers, measureDuration } = require('../time/main')
|
|
21
21
|
const { reportTimers } = require('../time/report')
|
|
@@ -42,8 +42,8 @@ const { getSeverity } = require('./severity')
|
|
|
42
42
|
* @param {string} [flags.deployId] - Netlify Deploy ID
|
|
43
43
|
* @param {string} [flags.context] - Build context
|
|
44
44
|
* @param {string} [flags.branch] - Repository branch
|
|
45
|
-
* @param {boolean} [flags.dry=false] - Run in dry mode, i.e. printing
|
|
46
|
-
* @param {string} [flags.nodePath] - Path to the Node.js binary to use in
|
|
45
|
+
* @param {boolean} [flags.dry=false] - Run in dry mode, i.e. printing steps without executing them
|
|
46
|
+
* @param {string} [flags.nodePath] - Path to the Node.js binary to use in the build command and plugins
|
|
47
47
|
* @param {boolean} [flags.buffer=false] - Buffer output instead of printing it
|
|
48
48
|
*
|
|
49
49
|
* @returns {object} buildResult
|
|
@@ -75,7 +75,7 @@ const build = async function (flags = {}) {
|
|
|
75
75
|
netlifyConfig: netlifyConfigA,
|
|
76
76
|
siteInfo,
|
|
77
77
|
userNodeVersion,
|
|
78
|
-
|
|
78
|
+
stepsCount,
|
|
79
79
|
timers,
|
|
80
80
|
durationNs,
|
|
81
81
|
configMutations,
|
|
@@ -104,7 +104,7 @@ const build = async function (flags = {}) {
|
|
|
104
104
|
buildId,
|
|
105
105
|
deployId,
|
|
106
106
|
status,
|
|
107
|
-
|
|
107
|
+
stepsCount,
|
|
108
108
|
pluginsOptions,
|
|
109
109
|
durationNs,
|
|
110
110
|
siteInfo,
|
|
@@ -248,7 +248,7 @@ const tExecBuild = async function ({
|
|
|
248
248
|
const {
|
|
249
249
|
pluginsOptions: pluginsOptionsA,
|
|
250
250
|
netlifyConfig: netlifyConfigA,
|
|
251
|
-
|
|
251
|
+
stepsCount,
|
|
252
252
|
timers: timersB,
|
|
253
253
|
configMutations,
|
|
254
254
|
} = await runAndReportBuild({
|
|
@@ -288,7 +288,7 @@ const tExecBuild = async function ({
|
|
|
288
288
|
netlifyConfig: netlifyConfigA,
|
|
289
289
|
siteInfo,
|
|
290
290
|
userNodeVersion,
|
|
291
|
-
|
|
291
|
+
stepsCount,
|
|
292
292
|
timers: timersB,
|
|
293
293
|
configMutations,
|
|
294
294
|
}
|
|
@@ -331,7 +331,7 @@ const runAndReportBuild = async function ({
|
|
|
331
331
|
}) {
|
|
332
332
|
try {
|
|
333
333
|
const {
|
|
334
|
-
|
|
334
|
+
stepsCount,
|
|
335
335
|
netlifyConfig: netlifyConfigA,
|
|
336
336
|
statuses,
|
|
337
337
|
pluginsOptions: pluginsOptionsA,
|
|
@@ -404,7 +404,7 @@ const runAndReportBuild = async function ({
|
|
|
404
404
|
return {
|
|
405
405
|
pluginsOptions: pluginsOptionsA,
|
|
406
406
|
netlifyConfig: netlifyConfigA,
|
|
407
|
-
|
|
407
|
+
stepsCount,
|
|
408
408
|
timers: timersA,
|
|
409
409
|
configMutations,
|
|
410
410
|
}
|
|
@@ -492,7 +492,7 @@ const initAndRunBuild = async function ({
|
|
|
492
492
|
|
|
493
493
|
try {
|
|
494
494
|
const {
|
|
495
|
-
|
|
495
|
+
stepsCount,
|
|
496
496
|
netlifyConfig: netlifyConfigA,
|
|
497
497
|
statuses,
|
|
498
498
|
failedPlugins,
|
|
@@ -535,7 +535,7 @@ const initAndRunBuild = async function ({
|
|
|
535
535
|
])
|
|
536
536
|
|
|
537
537
|
return {
|
|
538
|
-
|
|
538
|
+
stepsCount,
|
|
539
539
|
netlifyConfig: netlifyConfigA,
|
|
540
540
|
statuses,
|
|
541
541
|
pluginsOptions: pluginsOptionsA,
|
|
@@ -580,7 +580,7 @@ const runBuild = async function ({
|
|
|
580
580
|
testOpts,
|
|
581
581
|
featureFlags,
|
|
582
582
|
}) {
|
|
583
|
-
const {
|
|
583
|
+
const { pluginsSteps, timers: timersA } = await loadPlugins({
|
|
584
584
|
pluginsOptions,
|
|
585
585
|
childProcesses,
|
|
586
586
|
packageJson,
|
|
@@ -588,22 +588,22 @@ const runBuild = async function ({
|
|
|
588
588
|
debug,
|
|
589
589
|
})
|
|
590
590
|
|
|
591
|
-
const {
|
|
591
|
+
const { steps, events } = getSteps(pluginsSteps)
|
|
592
592
|
|
|
593
593
|
if (dry) {
|
|
594
|
-
await doDryRun({ buildDir,
|
|
594
|
+
await doDryRun({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs })
|
|
595
595
|
return { netlifyConfig }
|
|
596
596
|
}
|
|
597
597
|
|
|
598
598
|
const {
|
|
599
|
-
|
|
599
|
+
stepsCount,
|
|
600
600
|
netlifyConfig: netlifyConfigA,
|
|
601
601
|
statuses,
|
|
602
602
|
failedPlugins,
|
|
603
603
|
timers: timersB,
|
|
604
604
|
configMutations,
|
|
605
|
-
} = await
|
|
606
|
-
|
|
605
|
+
} = await runSteps({
|
|
606
|
+
steps,
|
|
607
607
|
buildbotServerSocket,
|
|
608
608
|
events,
|
|
609
609
|
configPath,
|
|
@@ -631,7 +631,7 @@ const runBuild = async function ({
|
|
|
631
631
|
featureFlags,
|
|
632
632
|
})
|
|
633
633
|
|
|
634
|
-
return {
|
|
634
|
+
return { stepsCount, netlifyConfig: netlifyConfigA, statuses, failedPlugins, timers: timersB, configMutations }
|
|
635
635
|
}
|
|
636
636
|
|
|
637
637
|
// Logs and reports that a build successfully ended
|
|
@@ -651,7 +651,7 @@ const telemetryReport = async function ({
|
|
|
651
651
|
deployId,
|
|
652
652
|
buildId,
|
|
653
653
|
status,
|
|
654
|
-
|
|
654
|
+
stepsCount,
|
|
655
655
|
pluginsOptions,
|
|
656
656
|
durationNs,
|
|
657
657
|
siteInfo,
|
|
@@ -666,7 +666,7 @@ const telemetryReport = async function ({
|
|
|
666
666
|
deployId,
|
|
667
667
|
buildId,
|
|
668
668
|
status,
|
|
669
|
-
|
|
669
|
+
stepsCount,
|
|
670
670
|
pluginsOptions,
|
|
671
671
|
durationNs,
|
|
672
672
|
siteInfo,
|
|
@@ -29,8 +29,8 @@ const getFunctionsBundlingLocation = function ({ functionName }) {
|
|
|
29
29
|
return `While bundling Function "${functionName}"`
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
const
|
|
33
|
-
return `During ${
|
|
32
|
+
const getCoreStepLocation = function ({ coreStepName }) {
|
|
33
|
+
return `During ${coreStepName}`
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const getBuildFailLocation = function ({ event, packageName, loadedFrom, origin }) {
|
|
@@ -54,7 +54,7 @@ const getApiLocation = function ({ endpoint, parameters }) {
|
|
|
54
54
|
const LOCATIONS = {
|
|
55
55
|
buildCommand: getBuildCommandLocation,
|
|
56
56
|
functionsBundling: getFunctionsBundlingLocation,
|
|
57
|
-
|
|
57
|
+
coreStep: getCoreStepLocation,
|
|
58
58
|
buildFail: getBuildFailLocation,
|
|
59
59
|
api: getApiLocation,
|
|
60
60
|
}
|
package/src/error/type.js
CHANGED
|
@@ -141,13 +141,13 @@ const TYPES = {
|
|
|
141
141
|
severity: 'error',
|
|
142
142
|
},
|
|
143
143
|
|
|
144
|
-
// Core
|
|
145
|
-
|
|
146
|
-
title: ({ location: {
|
|
144
|
+
// Core step internal error
|
|
145
|
+
coreStep: {
|
|
146
|
+
title: ({ location: { coreStepName } }) => `Internal error during "${coreStepName}"`,
|
|
147
147
|
stackType: 'stack',
|
|
148
148
|
showErrorProps: true,
|
|
149
149
|
rawStack: true,
|
|
150
|
-
locationType: '
|
|
150
|
+
locationType: 'coreStep',
|
|
151
151
|
severity: 'error',
|
|
152
152
|
},
|
|
153
153
|
|
|
File without changes
|
package/src/log/messages/dry.js
CHANGED
|
@@ -5,8 +5,8 @@ const { arrowDown } = require('figures')
|
|
|
5
5
|
const { logMessage, logSubHeader } = require('../logger')
|
|
6
6
|
const { THEME } = require('../theme')
|
|
7
7
|
|
|
8
|
-
const logDryRunStart = function ({ logs, eventWidth,
|
|
9
|
-
const columnWidth = getDryColumnWidth(eventWidth,
|
|
8
|
+
const logDryRunStart = function ({ logs, eventWidth, stepsCount }) {
|
|
9
|
+
const columnWidth = getDryColumnWidth(eventWidth, stepsCount)
|
|
10
10
|
const line = '─'.repeat(columnWidth)
|
|
11
11
|
const secondLine = '─'.repeat(columnWidth)
|
|
12
12
|
|
|
@@ -23,19 +23,19 @@ ${THEME.header(`┌─${line}─┬─${secondLine}─┐
|
|
|
23
23
|
)
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
const
|
|
26
|
+
const logDryRunStep = function ({
|
|
27
27
|
logs,
|
|
28
|
-
|
|
28
|
+
step: { event, packageName, coreStepDescription },
|
|
29
29
|
index,
|
|
30
30
|
netlifyConfig,
|
|
31
31
|
eventWidth,
|
|
32
|
-
|
|
32
|
+
stepsCount,
|
|
33
33
|
}) {
|
|
34
|
-
const columnWidth = getDryColumnWidth(eventWidth,
|
|
35
|
-
const fullName = getFullName(
|
|
34
|
+
const columnWidth = getDryColumnWidth(eventWidth, stepsCount)
|
|
35
|
+
const fullName = getFullName(coreStepDescription, netlifyConfig, packageName)
|
|
36
36
|
const line = '─'.repeat(columnWidth)
|
|
37
37
|
const countText = `${index + 1}. `
|
|
38
|
-
const downArrow =
|
|
38
|
+
const downArrow = stepsCount === index + 1 ? ' ' : ` ${arrowDown}`
|
|
39
39
|
const eventWidthA = columnWidth - countText.length - downArrow.length
|
|
40
40
|
|
|
41
41
|
logMessage(
|
|
@@ -46,14 +46,14 @@ ${THEME.header(`└─${line}─┘ `)}`,
|
|
|
46
46
|
)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
const getFullName = function (
|
|
50
|
-
return
|
|
49
|
+
const getFullName = function (coreStepDescription, netlifyConfig, packageName) {
|
|
50
|
+
return coreStepDescription === undefined
|
|
51
51
|
? `Plugin ${THEME.highlightWords(packageName)}`
|
|
52
|
-
:
|
|
52
|
+
: coreStepDescription({ netlifyConfig })
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
const getDryColumnWidth = function (eventWidth,
|
|
56
|
-
const symbolsWidth = `${
|
|
55
|
+
const getDryColumnWidth = function (eventWidth, stepsCount) {
|
|
56
|
+
const symbolsWidth = `${stepsCount}`.length + COLUMN_EXTRA_WIDTH
|
|
57
57
|
return Math.max(eventWidth + symbolsWidth, DRY_HEADER_NAMES[1].length)
|
|
58
58
|
}
|
|
59
59
|
|
|
@@ -66,6 +66,6 @@ const logDryRunEnd = function (logs) {
|
|
|
66
66
|
|
|
67
67
|
module.exports = {
|
|
68
68
|
logDryRunStart,
|
|
69
|
-
|
|
69
|
+
logDryRunStep,
|
|
70
70
|
logDryRunEnd,
|
|
71
71
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const { getLogHeaderFunc } = require('../header_func')
|
|
4
|
+
const { log, logMessage } = require('../logger')
|
|
5
|
+
const { THEME } = require('../theme')
|
|
6
|
+
|
|
7
|
+
const logStepStart = function ({ logs, event, packageName, coreStepDescription, index, error, netlifyConfig }) {
|
|
8
|
+
const description = getDescription({ coreStepDescription, netlifyConfig, packageName, event })
|
|
9
|
+
const logHeaderFunc = getLogHeaderFunc(error)
|
|
10
|
+
logHeaderFunc(logs, `${index + 1}. ${description}`)
|
|
11
|
+
logMessage(logs, '')
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const getDescription = function ({ coreStepDescription, netlifyConfig, packageName, event }) {
|
|
15
|
+
return coreStepDescription === undefined
|
|
16
|
+
? `${event} step from ${packageName}`
|
|
17
|
+
: coreStepDescription({ netlifyConfig })
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const logBuildCommandStart = function (logs, buildCommand) {
|
|
21
|
+
log(logs, THEME.highlightWords(`$ ${buildCommand}`))
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const logStepSuccess = function (logs) {
|
|
25
|
+
logMessage(logs, '')
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
logStepStart,
|
|
30
|
+
logBuildCommandStart,
|
|
31
|
+
logStepSuccess,
|
|
32
|
+
}
|
package/src/log/stream.js
CHANGED
|
@@ -36,7 +36,7 @@ const pushBuildCommandOutput = function (output, logsArray) {
|
|
|
36
36
|
logsArray.push(output)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
// Start plugin
|
|
39
|
+
// Start plugin step output
|
|
40
40
|
const pipePluginOutput = function (childProcess, logs) {
|
|
41
41
|
if (logs === undefined) {
|
|
42
42
|
return streamOutput(childProcess)
|
|
@@ -45,7 +45,7 @@ const pipePluginOutput = function (childProcess, logs) {
|
|
|
45
45
|
return pushOutputToLogs(childProcess, logs)
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
// Stop streaming/buffering plugin
|
|
48
|
+
// Stop streaming/buffering plugin step output
|
|
49
49
|
const unpipePluginOutput = async function (childProcess, logs, listeners) {
|
|
50
50
|
// Let `childProcess` `stdout` and `stderr` flush before stopping redirecting
|
|
51
51
|
await pSetTimeout(0)
|
|
@@ -7,21 +7,21 @@ const { validatePlugin } = require('./validate')
|
|
|
7
7
|
// This also requires the plugin file and fire its top-level function.
|
|
8
8
|
// This also validates the plugin.
|
|
9
9
|
// Do it when parent requests it using the `load` event.
|
|
10
|
-
// Also figure out the list of plugin
|
|
10
|
+
// Also figure out the list of plugin steps. This is also passed to the parent.
|
|
11
11
|
const load = function ({ pluginPath, inputs, packageJson }) {
|
|
12
12
|
const logic = getLogic({ pluginPath, inputs })
|
|
13
13
|
|
|
14
14
|
validatePlugin(logic)
|
|
15
15
|
|
|
16
|
-
const
|
|
16
|
+
const pluginSteps = getPluginSteps(logic)
|
|
17
17
|
|
|
18
18
|
// Context passed to every event handler
|
|
19
|
-
const context = {
|
|
19
|
+
const context = { pluginSteps, inputs, packageJson }
|
|
20
20
|
|
|
21
|
-
return {
|
|
21
|
+
return { pluginSteps, context }
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
const
|
|
24
|
+
const getPluginSteps = function (logic) {
|
|
25
25
|
return Object.entries(logic)
|
|
26
26
|
.filter(isEventHandler)
|
|
27
27
|
.map(([event, method]) => ({ event, method }))
|
package/src/plugins/child/run.js
CHANGED
|
@@ -8,9 +8,9 @@ const { getUtils } = require('./utils')
|
|
|
8
8
|
// Run a specific plugin event handler
|
|
9
9
|
const run = async function (
|
|
10
10
|
{ event, error, constants, envChanges, netlifyConfig },
|
|
11
|
-
{
|
|
11
|
+
{ pluginSteps, inputs, packageJson },
|
|
12
12
|
) {
|
|
13
|
-
const { method } =
|
|
13
|
+
const { method } = pluginSteps.find((pluginStep) => pluginStep.event === event)
|
|
14
14
|
const runState = {}
|
|
15
15
|
const utils = getUtils({ event, constants, runState })
|
|
16
16
|
const netlifyConfigCopy = cloneNetlifyConfig(netlifyConfig)
|
package/src/plugins/load.js
CHANGED
|
@@ -6,28 +6,28 @@ const { measureDuration } = require('../time/main')
|
|
|
6
6
|
|
|
7
7
|
const { callChild } = require('./ipc')
|
|
8
8
|
|
|
9
|
-
// Retrieve all plugins
|
|
9
|
+
// Retrieve all plugins steps
|
|
10
10
|
// Can use either a module name or a file path to the plugin.
|
|
11
11
|
const loadPlugins = async function ({ pluginsOptions, childProcesses, packageJson, timers, debug }) {
|
|
12
12
|
return pluginsOptions.length === 0
|
|
13
|
-
? {
|
|
13
|
+
? { pluginsSteps: [], timers }
|
|
14
14
|
: await loadAllPlugins({ pluginsOptions, childProcesses, packageJson, timers, debug })
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
const tLoadAllPlugins = async function ({ pluginsOptions, childProcesses, packageJson, debug }) {
|
|
18
|
-
const
|
|
18
|
+
const pluginsSteps = await Promise.all(
|
|
19
19
|
pluginsOptions.map((pluginOptions, index) =>
|
|
20
20
|
loadPlugin(pluginOptions, { childProcesses, index, packageJson, debug }),
|
|
21
21
|
),
|
|
22
22
|
)
|
|
23
|
-
const
|
|
24
|
-
return {
|
|
23
|
+
const pluginsStepsA = pluginsSteps.flat()
|
|
24
|
+
return { pluginsSteps: pluginsStepsA }
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// Only performed if there are some plugins
|
|
28
28
|
const loadAllPlugins = measureDuration(tLoadAllPlugins, 'load_plugins')
|
|
29
29
|
|
|
30
|
-
// Retrieve plugin
|
|
30
|
+
// Retrieve plugin steps for one plugin.
|
|
31
31
|
// Do it by executing the plugin `load` event handler.
|
|
32
32
|
const loadPlugin = async function (
|
|
33
33
|
{ packageName, pluginPackageJson, pluginPackageJson: { version } = {}, pluginPath, inputs, loadedFrom, origin },
|
|
@@ -37,8 +37,8 @@ const loadPlugin = async function (
|
|
|
37
37
|
const loadEvent = 'load'
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
|
-
const {
|
|
41
|
-
const
|
|
40
|
+
const { pluginSteps } = await callChild(childProcess, 'load', { pluginPath, inputs, packageJson })
|
|
41
|
+
const pluginStepsA = pluginSteps.map(({ event }) => ({
|
|
42
42
|
event,
|
|
43
43
|
packageName,
|
|
44
44
|
loadedFrom,
|
|
@@ -46,7 +46,7 @@ const loadPlugin = async function (
|
|
|
46
46
|
pluginPackageJson,
|
|
47
47
|
childProcess,
|
|
48
48
|
}))
|
|
49
|
-
return
|
|
49
|
+
return pluginStepsA
|
|
50
50
|
} catch (error) {
|
|
51
51
|
addErrorInfo(error, {
|
|
52
52
|
plugin: { packageName, pluginPackageJson },
|
|
@@ -6,11 +6,11 @@ const execa = require('execa')
|
|
|
6
6
|
|
|
7
7
|
const { addErrorInfo } = require('../error/info')
|
|
8
8
|
const { getBuildCommandDescription } = require('../log/description')
|
|
9
|
-
const { logBuildCommandStart } = require('../log/messages/
|
|
9
|
+
const { logBuildCommandStart } = require('../log/messages/steps')
|
|
10
10
|
const { getBuildCommandStdio, handleBuildCommandOutput } = require('../log/stream')
|
|
11
11
|
|
|
12
12
|
// Fire `build.command`
|
|
13
|
-
const
|
|
13
|
+
const coreStep = async function ({
|
|
14
14
|
configPath,
|
|
15
15
|
buildDir,
|
|
16
16
|
nodePath,
|
|
@@ -51,7 +51,7 @@ const coreCommand = async function ({
|
|
|
51
51
|
// We use Bash on Unix and `cmd.exe` on Windows
|
|
52
52
|
const SHELL = platform === 'win32' ? true : 'bash'
|
|
53
53
|
|
|
54
|
-
const
|
|
54
|
+
const coreStepDescription = function ({
|
|
55
55
|
netlifyConfig: {
|
|
56
56
|
build: { commandOrigin: buildCommandOrigin },
|
|
57
57
|
},
|
|
@@ -69,10 +69,10 @@ const hasBuildCommand = function ({
|
|
|
69
69
|
|
|
70
70
|
const buildCommandCore = {
|
|
71
71
|
event: 'onBuild',
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
72
|
+
coreStep,
|
|
73
|
+
coreStepId: 'build_command',
|
|
74
|
+
coreStepName: 'build.command',
|
|
75
|
+
coreStepDescription,
|
|
76
76
|
condition: hasBuildCommand,
|
|
77
77
|
}
|
|
78
78
|
|
|
@@ -88,9 +88,7 @@ const getDeployDir = function ({ buildDir, repositoryRoot, constants: { PUBLISH_
|
|
|
88
88
|
const handleDeployError = function (error, errorType) {
|
|
89
89
|
const errorA = new Error(`Deploy did not succeed: ${error}`)
|
|
90
90
|
const errorInfo =
|
|
91
|
-
errorType === 'user'
|
|
92
|
-
? { type: 'resolveConfig' }
|
|
93
|
-
: { type: 'coreCommand', location: { coreCommandName: 'Deploy site' } }
|
|
91
|
+
errorType === 'user' ? { type: 'resolveConfig' } : { type: 'coreStep', location: { coreStepName: 'Deploy site' } }
|
|
94
92
|
addErrorInfo(errorA, errorInfo)
|
|
95
93
|
throw errorA
|
|
96
94
|
}
|
|
@@ -10,7 +10,7 @@ const {
|
|
|
10
10
|
deploySiteWithBuildbotClient,
|
|
11
11
|
} = require('./buildbot_client')
|
|
12
12
|
|
|
13
|
-
const
|
|
13
|
+
const coreStep = async function ({
|
|
14
14
|
buildDir,
|
|
15
15
|
configPath,
|
|
16
16
|
repositoryRoot,
|
|
@@ -67,10 +67,10 @@ const shouldDeploy = function ({ buildbotServerSocket }) {
|
|
|
67
67
|
|
|
68
68
|
const deploySite = {
|
|
69
69
|
event: 'onPostBuild',
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
70
|
+
coreStep,
|
|
71
|
+
coreStepId: 'deploy_site',
|
|
72
|
+
coreStepName: 'Deploy site',
|
|
73
|
+
coreStepDescription: () => 'Deploy site',
|
|
74
74
|
condition: shouldDeploy,
|
|
75
75
|
}
|
|
76
76
|
|
|
@@ -8,11 +8,7 @@ const mapObject = require('map-obj')
|
|
|
8
8
|
const pathExists = require('path-exists')
|
|
9
9
|
|
|
10
10
|
const { log } = require('../../log/logger')
|
|
11
|
-
const {
|
|
12
|
-
logBundleResults,
|
|
13
|
-
logFunctionsNonExistingDir,
|
|
14
|
-
logFunctionsToBundle,
|
|
15
|
-
} = require('../../log/messages/core_commands')
|
|
11
|
+
const { logBundleResults, logFunctionsNonExistingDir, logFunctionsToBundle } = require('../../log/messages/core_steps')
|
|
16
12
|
|
|
17
13
|
const { getZipError } = require('./error')
|
|
18
14
|
const { getUserAndInternalFunctions, validateFunctionsSrc } = require('./utils')
|
|
@@ -52,6 +48,7 @@ const getZisiParameters = ({ buildDir, featureFlags, functionsConfig, functionsD
|
|
|
52
48
|
normalizeFunctionConfig({ buildDir, featureFlags, functionConfig: object, isRunningLocally }),
|
|
53
49
|
])
|
|
54
50
|
const zisiFeatureFlags = {
|
|
51
|
+
buildGoSource: featureFlags.buildbot_build_go_functions,
|
|
55
52
|
defaultEsModulesToEsbuild: featureFlags.buildbot_es_modules_esbuild,
|
|
56
53
|
parseWithEsbuild: featureFlags.buildbot_zisi_esbuild_parser,
|
|
57
54
|
}
|
|
@@ -89,7 +86,7 @@ const zipFunctionsAndLogResults = async ({
|
|
|
89
86
|
|
|
90
87
|
// Plugin to package Netlify functions with @netlify/zip-it-and-ship-it
|
|
91
88
|
// eslint-disable-next-line complexity
|
|
92
|
-
const
|
|
89
|
+
const coreStep = async function ({
|
|
93
90
|
constants: {
|
|
94
91
|
INTERNAL_FUNCTIONS_SRC: relativeInternalFunctionsSrc,
|
|
95
92
|
IS_LOCAL: isRunningLocally,
|
|
@@ -152,7 +149,7 @@ const coreCommand = async function ({
|
|
|
152
149
|
}
|
|
153
150
|
}
|
|
154
151
|
|
|
155
|
-
// We run this core
|
|
152
|
+
// We run this core step if at least one of the functions directories (the
|
|
156
153
|
// one configured by the user or the internal one) exists. We use a dynamic
|
|
157
154
|
// `condition` because the directories might be created by the build command
|
|
158
155
|
// or plugins.
|
|
@@ -170,10 +167,10 @@ const hasFunctionsDirectories = async function ({ buildDir, constants: { INTERNA
|
|
|
170
167
|
|
|
171
168
|
const bundleFunctions = {
|
|
172
169
|
event: 'onBuild',
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
170
|
+
coreStep,
|
|
171
|
+
coreStepId: 'functions_bundling',
|
|
172
|
+
coreStepName: 'Functions bundling',
|
|
173
|
+
coreStepDescription: () => 'Functions bundling',
|
|
177
174
|
condition: hasFunctionsDirectories,
|
|
178
175
|
}
|
|
179
176
|
|