@netlify/build 25.0.3 → 26.1.0
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 +5 -3
- package/src/core/bin.js +7 -8
- package/src/core/config.js +18 -35
- package/src/core/constants.js +7 -13
- package/src/core/dry.js +4 -8
- package/src/core/feature_flags.js +2 -7
- package/src/core/flags.js +2 -6
- package/src/core/lingering.js +7 -7
- package/src/core/main.js +25 -29
- package/src/core/missing_side_file.js +4 -8
- package/src/core/normalize_flags.js +5 -9
- package/src/core/severity.js +2 -6
- package/src/core/user_node_version.js +7 -11
- package/src/env/changes.js +5 -9
- package/src/env/main.js +4 -8
- package/src/env/metadata.js +3 -7
- package/src/error/api.js +4 -8
- package/src/error/build.js +4 -8
- package/src/error/cancel.js +1 -5
- package/src/error/colors.js +2 -6
- package/src/error/handle.js +10 -14
- package/src/error/info.js +6 -10
- package/src/error/monitor/location.js +1 -5
- package/src/error/monitor/normalize.js +2 -6
- package/src/error/monitor/print.js +2 -8
- package/src/error/monitor/report.js +11 -15
- package/src/error/monitor/start.js +7 -9
- package/src/error/parse/clean_stack.js +4 -8
- package/src/error/parse/location.js +2 -6
- package/src/error/parse/normalize.js +1 -5
- package/src/error/parse/parse.js +10 -14
- package/src/error/parse/plugin.js +2 -6
- package/src/error/parse/properties.js +3 -7
- package/src/error/parse/serialize_log.js +2 -6
- package/src/error/parse/serialize_status.js +1 -5
- package/src/error/parse/stack.js +2 -6
- package/src/error/type.js +1 -5
- package/src/install/functions.js +5 -9
- package/src/install/local.js +5 -9
- package/src/install/main.js +6 -10
- package/src/install/missing.js +9 -13
- package/src/log/colors.js +5 -11
- package/src/log/description.js +2 -6
- package/src/log/header.js +2 -6
- package/src/log/header_func.js +3 -7
- package/src/log/logger.js +20 -40
- package/src/log/messages/compatibility.js +9 -18
- package/src/log/messages/config.js +12 -27
- package/src/log/messages/core.js +19 -30
- package/src/log/messages/core_steps.js +7 -15
- package/src/log/messages/dry.js +7 -15
- package/src/log/messages/install.js +4 -12
- package/src/log/messages/ipc.js +8 -20
- package/src/log/messages/mutations.js +8 -17
- package/src/log/messages/plugins.js +5 -14
- package/src/log/messages/status.js +3 -9
- package/src/log/messages/steps.js +6 -14
- package/src/log/old_version.js +4 -8
- package/src/log/serialize.js +3 -7
- package/src/log/stream.js +6 -15
- package/src/log/theme.js +14 -29
- package/src/plugins/child/diff.js +5 -9
- package/src/plugins/child/error.js +7 -11
- package/src/plugins/child/lazy.js +2 -6
- package/src/plugins/child/load.js +6 -10
- package/src/plugins/child/logic.js +6 -7
- package/src/plugins/child/main.js +5 -7
- package/src/plugins/child/run.js +6 -10
- package/src/plugins/child/status.js +4 -8
- package/src/plugins/child/typescript.js +5 -9
- package/src/plugins/child/utils.js +21 -27
- package/src/plugins/child/validate.js +6 -11
- package/src/plugins/compatibility.js +12 -15
- package/src/plugins/error.js +6 -15
- package/src/plugins/events.js +5 -20
- package/src/plugins/expected_version.js +8 -12
- package/src/plugins/ipc.js +12 -21
- package/src/plugins/list.js +6 -15
- package/src/plugins/load.js +13 -9
- package/src/plugins/manifest/check.js +4 -8
- package/src/plugins/manifest/load.js +6 -10
- package/src/plugins/manifest/main.js +5 -9
- package/src/plugins/manifest/path.js +3 -7
- package/src/plugins/manifest/validate.js +3 -7
- package/src/plugins/node_version.js +9 -13
- package/src/plugins/options.js +10 -14
- package/src/plugins/pinned_version.js +4 -8
- package/src/plugins/resolve.js +7 -11
- package/src/plugins/spawn.js +10 -12
- package/src/plugins_core/add.js +2 -6
- package/src/plugins_core/build_command.js +7 -11
- package/src/plugins_core/deploy/buildbot_client.js +11 -20
- package/src/plugins_core/deploy/index.js +5 -9
- package/src/plugins_core/functions/error.js +4 -8
- package/src/plugins_core/functions/feature_flags.js +1 -5
- package/src/plugins_core/functions/index.js +22 -16
- package/src/plugins_core/functions/utils.js +9 -13
- package/src/plugins_core/functions_install/index.js +3 -7
- package/src/plugins_core/list.js +10 -7
- package/src/status/add.js +1 -5
- package/src/status/colors.js +2 -6
- package/src/status/load_error.js +4 -8
- package/src/status/report.js +4 -8
- package/src/status/success.js +2 -6
- package/src/steps/core_step.js +4 -8
- package/src/steps/error.js +7 -11
- package/src/steps/get.js +7 -12
- package/src/steps/plugin.js +8 -12
- package/src/steps/return.js +4 -8
- package/src/steps/run_step.js +8 -12
- package/src/steps/run_steps.js +5 -9
- package/src/steps/update_config.js +10 -14
- package/src/telemetry/main.js +7 -11
- package/src/time/aggregate.js +2 -6
- package/src/time/main.js +8 -12
- package/src/time/measure.js +4 -8
- package/src/time/report.js +5 -9
- package/src/utils/errors.js +1 -5
- package/src/utils/json.js +5 -8
- package/src/utils/omit.js +2 -6
- package/src/utils/package.js +3 -7
- package/src/utils/remove_falsy.js +2 -6
- package/src/utils/resolve.js +8 -6
- package/src/utils/semver.js +9 -13
- package/types/config/functions.d.ts +1 -1
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { readFile } from 'fs'
|
|
2
|
+
import { inspect, promisify } from 'util'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const { inspect, promisify } = require('util')
|
|
4
|
+
import pathExists from 'path-exists'
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { log, logMessage, logSubHeader } = require('../logger')
|
|
6
|
+
import { log, logMessage, logSubHeader } from '../logger.js'
|
|
9
7
|
|
|
10
8
|
const pReadFile = promisify(readFile)
|
|
11
9
|
|
|
12
|
-
const logConfigMutations = function (logs, newConfigMutations, debug) {
|
|
10
|
+
export const logConfigMutations = function (logs, newConfigMutations, debug) {
|
|
13
11
|
const configMutationsToLog = debug ? newConfigMutations : newConfigMutations.filter(shouldLogConfigMutation)
|
|
14
12
|
configMutationsToLog.forEach(({ keysString, value }) => {
|
|
15
13
|
logConfigMutation(logs, keysString, value)
|
|
@@ -37,7 +35,7 @@ const shouldHideConfigValue = function (keysString) {
|
|
|
37
35
|
|
|
38
36
|
const SECRET_PROPS = ['build.environment']
|
|
39
37
|
|
|
40
|
-
const logConfigOnUpload = async function ({ logs, configPath, debug }) {
|
|
38
|
+
export const logConfigOnUpload = async function ({ logs, configPath, debug }) {
|
|
41
39
|
if (!debug) {
|
|
42
40
|
return
|
|
43
41
|
}
|
|
@@ -53,7 +51,7 @@ const logConfigOnUpload = async function ({ logs, configPath, debug }) {
|
|
|
53
51
|
logMessage(logs, configContents.trim())
|
|
54
52
|
}
|
|
55
53
|
|
|
56
|
-
const logHeadersOnUpload = async function ({ logs, headersPath, debug }) {
|
|
54
|
+
export const logHeadersOnUpload = async function ({ logs, headersPath, debug }) {
|
|
57
55
|
if (!debug) {
|
|
58
56
|
return
|
|
59
57
|
}
|
|
@@ -69,7 +67,7 @@ const logHeadersOnUpload = async function ({ logs, headersPath, debug }) {
|
|
|
69
67
|
logMessage(logs, headersContents.trim())
|
|
70
68
|
}
|
|
71
69
|
|
|
72
|
-
const logRedirectsOnUpload = async function ({ logs, redirectsPath, debug }) {
|
|
70
|
+
export const logRedirectsOnUpload = async function ({ logs, redirectsPath, debug }) {
|
|
73
71
|
if (!debug) {
|
|
74
72
|
return
|
|
75
73
|
}
|
|
@@ -84,10 +82,3 @@ const logRedirectsOnUpload = async function ({ logs, redirectsPath, debug }) {
|
|
|
84
82
|
const redirectsContents = await pReadFile(redirectsPath, 'utf8')
|
|
85
83
|
logMessage(logs, `${redirectsContents.trim()}\n`)
|
|
86
84
|
}
|
|
87
|
-
|
|
88
|
-
module.exports = {
|
|
89
|
-
logConfigMutations,
|
|
90
|
-
logConfigOnUpload,
|
|
91
|
-
logHeadersOnUpload,
|
|
92
|
-
logRedirectsOnUpload,
|
|
93
|
-
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import { log, logArray, logWarning, logSubHeader } from '../logger.js'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const logPluginsFetchError = function (logs, message) {
|
|
3
|
+
export const logPluginsFetchError = function (logs, message) {
|
|
6
4
|
logWarning(
|
|
7
5
|
logs,
|
|
8
6
|
`
|
|
@@ -11,7 +9,7 @@ ${message}`,
|
|
|
11
9
|
)
|
|
12
10
|
}
|
|
13
11
|
|
|
14
|
-
const logPluginsList = function ({ pluginsList, debug, logs }) {
|
|
12
|
+
export const logPluginsList = function ({ pluginsList, debug, logs }) {
|
|
15
13
|
if (!debug) {
|
|
16
14
|
return
|
|
17
15
|
}
|
|
@@ -27,7 +25,7 @@ const getPluginsListItem = function ([packageName, versions]) {
|
|
|
27
25
|
return `${packageName}@${versions[0].version}`
|
|
28
26
|
}
|
|
29
27
|
|
|
30
|
-
const logFailPluginWarning = function (methodName, event) {
|
|
28
|
+
export const logFailPluginWarning = function (methodName, event) {
|
|
31
29
|
logWarning(
|
|
32
30
|
undefined,
|
|
33
31
|
`Plugin error: since "${event}" happens after deploy, the build has already succeeded and cannot fail anymore. This plugin should either:
|
|
@@ -36,13 +34,6 @@ const logFailPluginWarning = function (methodName, event) {
|
|
|
36
34
|
)
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
const logDeploySuccess = function (logs) {
|
|
37
|
+
export const logDeploySuccess = function (logs) {
|
|
40
38
|
log(logs, 'Site deploy was successfully initiated')
|
|
41
39
|
}
|
|
42
|
-
|
|
43
|
-
module.exports = {
|
|
44
|
-
logPluginsFetchError,
|
|
45
|
-
logPluginsList,
|
|
46
|
-
logFailPluginWarning,
|
|
47
|
-
logDeploySuccess,
|
|
48
|
-
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { logMessage, logHeader, logSubHeader } from '../logger.js'
|
|
2
|
+
import { THEME } from '../theme.js'
|
|
2
3
|
|
|
3
|
-
const
|
|
4
|
-
const { THEME } = require('../theme')
|
|
5
|
-
|
|
6
|
-
const logStatuses = function (logs, statuses) {
|
|
4
|
+
export const logStatuses = function (logs, statuses) {
|
|
7
5
|
logHeader(logs, 'Summary')
|
|
8
6
|
statuses.forEach((status) => {
|
|
9
7
|
logStatus(logs, status)
|
|
@@ -16,7 +14,3 @@ const logStatus = function (logs, { packageName, title = `Plugin ${packageName}
|
|
|
16
14
|
logSubHeader(logs, titleA)
|
|
17
15
|
logMessage(logs, body)
|
|
18
16
|
}
|
|
19
|
-
|
|
20
|
-
module.exports = {
|
|
21
|
-
logStatuses,
|
|
22
|
-
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import { getLogHeaderFunc } from '../header_func.js'
|
|
2
|
+
import { log, logMessage } from '../logger.js'
|
|
3
|
+
import { THEME } from '../theme.js'
|
|
2
4
|
|
|
3
|
-
const {
|
|
4
|
-
const { log, logMessage } = require('../logger')
|
|
5
|
-
const { THEME } = require('../theme')
|
|
6
|
-
|
|
7
|
-
const logStepStart = function ({ logs, event, packageName, coreStepDescription, index, error, netlifyConfig }) {
|
|
5
|
+
export const logStepStart = function ({ logs, event, packageName, coreStepDescription, index, error, netlifyConfig }) {
|
|
8
6
|
const description = getDescription({ coreStepDescription, netlifyConfig, packageName, event })
|
|
9
7
|
const logHeaderFunc = getLogHeaderFunc(error)
|
|
10
8
|
logHeaderFunc(logs, `${index + 1}. ${description}`)
|
|
@@ -15,16 +13,10 @@ const getDescription = function ({ coreStepDescription, netlifyConfig, packageNa
|
|
|
15
13
|
return coreStepDescription === undefined ? `${packageName} (${event} event)` : coreStepDescription({ netlifyConfig })
|
|
16
14
|
}
|
|
17
15
|
|
|
18
|
-
const logBuildCommandStart = function (logs, buildCommand) {
|
|
16
|
+
export const logBuildCommandStart = function (logs, buildCommand) {
|
|
19
17
|
log(logs, THEME.highlightWords(`$ ${buildCommand}`))
|
|
20
18
|
}
|
|
21
19
|
|
|
22
|
-
const logStepSuccess = function (logs) {
|
|
20
|
+
export const logStepSuccess = function (logs) {
|
|
23
21
|
logMessage(logs, '')
|
|
24
22
|
}
|
|
25
|
-
|
|
26
|
-
module.exports = {
|
|
27
|
-
logStepStart,
|
|
28
|
-
logBuildCommandStart,
|
|
29
|
-
logStepSuccess,
|
|
30
|
-
}
|
package/src/log/old_version.js
CHANGED
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
import { stdout } from 'process'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import UpdateNotifier from 'update-notifier'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { ROOT_PACKAGE_JSON } = require('../utils/json')
|
|
5
|
+
import { ROOT_PACKAGE_JSON } from '../utils/json.js'
|
|
8
6
|
|
|
9
7
|
// Many build errors happen in local builds that do not use the latest version
|
|
10
8
|
// of `@netlify/build`. We print a warning message on those.
|
|
11
9
|
// We only print this when Netlify CLI has been used. Programmatic usage might
|
|
12
10
|
// come from a deep dependency calling `@netlify/build` and user might not be
|
|
13
11
|
// able to take any upgrade action, making the message noisy.
|
|
14
|
-
const logOldCliVersionError = function ({ mode, testOpts }) {
|
|
12
|
+
export const logOldCliVersionError = function ({ mode, testOpts }) {
|
|
15
13
|
if (mode !== 'cli') {
|
|
16
14
|
return
|
|
17
15
|
}
|
|
@@ -41,5 +39,3 @@ const getCorePackageJson = function (testOpts) {
|
|
|
41
39
|
const OLD_VERSION_MESSAGE = `Please update netlify-cli to its latest version.
|
|
42
40
|
If netlify-cli is already the latest version,
|
|
43
41
|
please update your dependencies lock file instead.`
|
|
44
|
-
|
|
45
|
-
module.exports = { logOldCliVersionError }
|
package/src/log/serialize.js
CHANGED
|
@@ -1,17 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { dump } from 'js-yaml'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const serializeObject = function (object) {
|
|
3
|
+
export const serializeObject = function (object) {
|
|
6
4
|
return dump(object, { noRefs: true, sortKeys: true, lineWidth: Number.POSITIVE_INFINITY }).trimRight()
|
|
7
5
|
}
|
|
8
6
|
|
|
9
|
-
const serializeArray = function (array) {
|
|
7
|
+
export const serializeArray = function (array) {
|
|
10
8
|
return array.map(addDash).join('\n')
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
const addDash = function (string) {
|
|
14
12
|
return ` - ${string}`
|
|
15
13
|
}
|
|
16
|
-
|
|
17
|
-
module.exports = { serializeObject, serializeArray }
|
package/src/log/stream.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { stdout, stderr } = require('process')
|
|
4
|
-
const { promisify } = require('util')
|
|
1
|
+
import { stdout, stderr } from 'process'
|
|
2
|
+
import { promisify } from 'util'
|
|
5
3
|
|
|
6
4
|
// TODO: replace with `timers/promises` after dropping Node < 15.0.0
|
|
7
5
|
const pSetTimeout = promisify(setTimeout)
|
|
@@ -10,7 +8,7 @@ const pSetTimeout = promisify(setTimeout)
|
|
|
10
8
|
// which solves many problems. However we can only do it in build.command.
|
|
11
9
|
// Plugins have several events, so need to be switch on and off instead.
|
|
12
10
|
// In buffer mode (`logs` not `undefined`), `pipe` is necessary.
|
|
13
|
-
const getBuildCommandStdio = function (logs) {
|
|
11
|
+
export const getBuildCommandStdio = function (logs) {
|
|
14
12
|
if (logs !== undefined) {
|
|
15
13
|
return 'pipe'
|
|
16
14
|
}
|
|
@@ -19,7 +17,7 @@ const getBuildCommandStdio = function (logs) {
|
|
|
19
17
|
}
|
|
20
18
|
|
|
21
19
|
// Add build command output
|
|
22
|
-
const handleBuildCommandOutput = function ({ stdout: commandStdout, stderr: commandStderr }, logs) {
|
|
20
|
+
export const handleBuildCommandOutput = function ({ stdout: commandStdout, stderr: commandStderr }, logs) {
|
|
23
21
|
if (logs === undefined) {
|
|
24
22
|
return
|
|
25
23
|
}
|
|
@@ -37,7 +35,7 @@ const pushBuildCommandOutput = function (output, logsArray) {
|
|
|
37
35
|
}
|
|
38
36
|
|
|
39
37
|
// Start plugin step output
|
|
40
|
-
const pipePluginOutput = function (childProcess, logs) {
|
|
38
|
+
export const pipePluginOutput = function (childProcess, logs) {
|
|
41
39
|
if (logs === undefined) {
|
|
42
40
|
return streamOutput(childProcess)
|
|
43
41
|
}
|
|
@@ -46,7 +44,7 @@ const pipePluginOutput = function (childProcess, logs) {
|
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
// Stop streaming/buffering plugin step output
|
|
49
|
-
const unpipePluginOutput = async function (childProcess, logs, listeners) {
|
|
47
|
+
export const unpipePluginOutput = async function (childProcess, logs, listeners) {
|
|
50
48
|
// Let `childProcess` `stdout` and `stderr` flush before stopping redirecting
|
|
51
49
|
await pSetTimeout(0)
|
|
52
50
|
|
|
@@ -85,10 +83,3 @@ const unpushOutputToLogs = function (childProcess, logs, { stdoutListener, stder
|
|
|
85
83
|
childProcess.stdout.removeListener('data', stdoutListener)
|
|
86
84
|
childProcess.stderr.removeListener('data', stderrListener)
|
|
87
85
|
}
|
|
88
|
-
|
|
89
|
-
module.exports = {
|
|
90
|
-
getBuildCommandStdio,
|
|
91
|
-
handleBuildCommandOutput,
|
|
92
|
-
pipePluginOutput,
|
|
93
|
-
unpipePluginOutput,
|
|
94
|
-
}
|
package/src/log/theme.js
CHANGED
|
@@ -1,41 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const {
|
|
4
|
-
cyanBright: { bold: cyanBrightBold },
|
|
5
|
-
cyan: { bold: cyanBold },
|
|
6
|
-
cyan,
|
|
7
|
-
redBright: { bold: redBrightBold },
|
|
8
|
-
redBright,
|
|
9
|
-
red: { bold: redBold },
|
|
10
|
-
yellowBright: { bold: yellowBrightBold },
|
|
11
|
-
yellowBright,
|
|
12
|
-
yellow: { bold: yellowBold },
|
|
13
|
-
gray,
|
|
14
|
-
} = require('chalk')
|
|
1
|
+
import chalk from 'chalk'
|
|
15
2
|
|
|
16
3
|
// Color theme. Please use this instead of requiring chalk directly, to ensure
|
|
17
4
|
// consistent colors.
|
|
18
|
-
const THEME = {
|
|
5
|
+
export const THEME = {
|
|
19
6
|
// Main headers
|
|
20
|
-
header:
|
|
7
|
+
header: chalk.cyanBright.bold,
|
|
21
8
|
// Single lines used as subheaders
|
|
22
|
-
subHeader:
|
|
9
|
+
subHeader: chalk.cyan.bold,
|
|
23
10
|
// One of several words that should be highlighted inside a line
|
|
24
|
-
highlightWords: cyan,
|
|
11
|
+
highlightWords: chalk.cyan,
|
|
25
12
|
// Same for errors
|
|
26
|
-
errorHeader:
|
|
27
|
-
errorSubHeader:
|
|
28
|
-
errorLine: redBright,
|
|
29
|
-
errorHighlightWords:
|
|
13
|
+
errorHeader: chalk.redBright.bold,
|
|
14
|
+
errorSubHeader: chalk.red.bold,
|
|
15
|
+
errorLine: chalk.redBright,
|
|
16
|
+
errorHighlightWords: chalk.redBright.bold,
|
|
30
17
|
// Same for warnings
|
|
31
|
-
warningHeader:
|
|
32
|
-
warningSubHeader:
|
|
33
|
-
warningLine: yellowBright,
|
|
34
|
-
warningHighlightWords:
|
|
18
|
+
warningHeader: chalk.yellowBright.bold,
|
|
19
|
+
warningSubHeader: chalk.yellow.bold,
|
|
20
|
+
warningLine: chalk.yellowBright,
|
|
21
|
+
warningHighlightWords: chalk.yellowBright.bold,
|
|
35
22
|
// One of several words that should be dimmed inside a line
|
|
36
|
-
dimWords: gray,
|
|
23
|
+
dimWords: chalk.gray,
|
|
37
24
|
// No colors
|
|
38
25
|
none: (string) => string,
|
|
39
26
|
}
|
|
40
|
-
|
|
41
|
-
module.exports = { THEME }
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { isDeepStrictEqual } from 'util'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const isPlainObj = require('is-plain-obj')
|
|
6
|
-
const rfdc = require('rfdc')
|
|
3
|
+
import isPlainObj from 'is-plain-obj'
|
|
4
|
+
import rfdc from 'rfdc'
|
|
7
5
|
|
|
8
6
|
const clone = rfdc()
|
|
9
7
|
|
|
10
8
|
// Copy `netlifyConfig` so we can compare before/after mutating it
|
|
11
|
-
const cloneNetlifyConfig = function (netlifyConfig) {
|
|
9
|
+
export const cloneNetlifyConfig = function (netlifyConfig) {
|
|
12
10
|
return clone(netlifyConfig)
|
|
13
11
|
}
|
|
14
12
|
|
|
@@ -20,7 +18,7 @@ const cloneNetlifyConfig = function (netlifyConfig) {
|
|
|
20
18
|
// - Apply the change to `netlifyConfig` in the parent process so it can
|
|
21
19
|
// run `@netlify/config` to normalize and validate the new values
|
|
22
20
|
// `configMutations` is passed to parent process as JSON
|
|
23
|
-
const getConfigMutations = function (netlifyConfig, netlifyConfigCopy, event) {
|
|
21
|
+
export const getConfigMutations = function (netlifyConfig, netlifyConfigCopy, event) {
|
|
24
22
|
const configMutations = diffObjects(netlifyConfig, netlifyConfigCopy, [])
|
|
25
23
|
return configMutations.map((configMutation) => getConfigMutation(configMutation, event))
|
|
26
24
|
}
|
|
@@ -55,5 +53,3 @@ const getConfigMutation = function ({ keys, value }, event) {
|
|
|
55
53
|
event,
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
|
-
|
|
59
|
-
module.exports = { cloneNetlifyConfig, getConfigMutations }
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import logProcessErrors from 'log-process-errors'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { normalizeError } = require('../../error/parse/normalize')
|
|
8
|
-
const { sendEventToParent } = require('../ipc')
|
|
3
|
+
import { errorToJson } from '../../error/build.js'
|
|
4
|
+
import { addDefaultErrorInfo, isBuildError } from '../../error/info.js'
|
|
5
|
+
import { normalizeError } from '../../error/parse/normalize.js'
|
|
6
|
+
import { sendEventToParent } from '../ipc.js'
|
|
9
7
|
|
|
10
8
|
// Handle any top-level error and communicate it back to parent
|
|
11
|
-
const handleError = async function (error, verbose) {
|
|
9
|
+
export const handleError = async function (error, verbose) {
|
|
12
10
|
const errorA = normalizeError(error)
|
|
13
11
|
addDefaultErrorInfo(errorA, { type: 'pluginInternal' })
|
|
14
12
|
const errorPayload = errorToJson(errorA)
|
|
@@ -17,7 +15,7 @@ const handleError = async function (error, verbose) {
|
|
|
17
15
|
|
|
18
16
|
// On uncaught exceptions and unhandled rejections, print the stack trace.
|
|
19
17
|
// Also, prevent child processes from crashing on uncaught exceptions.
|
|
20
|
-
const handleProcessErrors = function () {
|
|
18
|
+
export const handleProcessErrors = function () {
|
|
21
19
|
logProcessErrors({ log: handleProcessError, exitOn: [], level: { multipleResolves: 'silent' } })
|
|
22
20
|
}
|
|
23
21
|
|
|
@@ -32,5 +30,3 @@ const handleProcessError = async function (error, level, originalError) {
|
|
|
32
30
|
|
|
33
31
|
await handleError(errorA)
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
module.exports = { handleError, handleProcessErrors }
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const memoizeOne = require('memoize-one')
|
|
1
|
+
import memoizeOne from 'memoize-one'
|
|
4
2
|
|
|
5
3
|
// Add a `object[propName]` whose value is the return value of `getFunc()`, but
|
|
6
4
|
// is only retrieved when accessed.
|
|
7
|
-
const addLazyProp = function (object, propName, getFunc) {
|
|
5
|
+
export const addLazyProp = function (object, propName, getFunc) {
|
|
8
6
|
const mGetFunc = memoizeOne(getFunc, returnTrue)
|
|
9
7
|
// Mutation is required due to the usage of `Object.defineProperty()`
|
|
10
8
|
// eslint-disable-next-line fp/no-mutating-methods
|
|
@@ -18,5 +16,3 @@ const addLazyProp = function (object, propName, getFunc) {
|
|
|
18
16
|
const returnTrue = function () {
|
|
19
17
|
return true
|
|
20
18
|
}
|
|
21
|
-
|
|
22
|
-
module.exports = { addLazyProp }
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
|
|
1
|
+
import filterObj from 'filter-obj'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { registerTypeScript } = require('./typescript')
|
|
7
|
-
const { validatePlugin } = require('./validate')
|
|
3
|
+
import { getLogic } from './logic.js'
|
|
4
|
+
import { registerTypeScript } from './typescript.js'
|
|
5
|
+
import { validatePlugin } from './validate.js'
|
|
8
6
|
|
|
9
7
|
// Load context passed to every plugin method.
|
|
10
8
|
// This also requires the plugin file and fire its top-level function.
|
|
11
9
|
// This also validates the plugin.
|
|
12
10
|
// Do it when parent requests it using the `load` event.
|
|
13
11
|
// Also figure out the list of plugin steps. This is also passed to the parent.
|
|
14
|
-
const load = async function ({ pluginPath, inputs, packageJson, verbose }) {
|
|
12
|
+
export const load = async function ({ pluginPath, inputs, packageJson, verbose }) {
|
|
15
13
|
const tsNodeService = registerTypeScript(pluginPath)
|
|
16
14
|
const logic = await getLogic({ pluginPath, inputs, tsNodeService })
|
|
17
15
|
|
|
18
|
-
|
|
16
|
+
validatePlugin(logic)
|
|
19
17
|
|
|
20
18
|
const methods = filterObj(logic, isEventHandler)
|
|
21
19
|
const events = Object.keys(methods)
|
|
@@ -29,5 +27,3 @@ const load = async function ({ pluginPath, inputs, packageJson, verbose }) {
|
|
|
29
27
|
const isEventHandler = function (event, value) {
|
|
30
28
|
return typeof value === 'function'
|
|
31
29
|
}
|
|
32
|
-
|
|
33
|
-
module.exports = { load }
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import { createRequire } from 'module'
|
|
2
|
+
import { pathToFileURL } from 'url'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
+
import { addTsErrorInfo } from './typescript.js'
|
|
4
5
|
|
|
5
|
-
const
|
|
6
|
+
const require = createRequire(import.meta.url)
|
|
6
7
|
|
|
7
8
|
// Require the plugin file and fire its top-level function.
|
|
8
9
|
// The returned object is the `logic` which includes all event handlers.
|
|
9
|
-
const getLogic = async function ({ pluginPath, inputs, tsNodeService }) {
|
|
10
|
+
export const getLogic = async function ({ pluginPath, inputs, tsNodeService }) {
|
|
10
11
|
const logic = await importLogic(pluginPath, tsNodeService)
|
|
11
12
|
const logicA = loadLogic({ logic, inputs })
|
|
12
13
|
return logicA
|
|
@@ -18,7 +19,7 @@ const importLogic = async function (pluginPath, tsNodeService) {
|
|
|
18
19
|
// which is currently making it impossible for local plugins to use both
|
|
19
20
|
// pure ES modules and TypeScript.
|
|
20
21
|
if (tsNodeService !== undefined) {
|
|
21
|
-
// eslint-disable-next-line
|
|
22
|
+
// eslint-disable-next-line import/no-dynamic-require
|
|
22
23
|
return require(pluginPath)
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -54,5 +55,3 @@ const loadLogic = function ({ logic, inputs }) {
|
|
|
54
55
|
throw error
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
|
-
|
|
58
|
-
module.exports = { getLogic }
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { setInspectColors } from '../../log/colors.js'
|
|
2
|
+
import { sendEventToParent, getEventsFromParent } from '../ipc.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { handleProcessErrors, handleError } = require('./error')
|
|
7
|
-
const { load } = require('./load')
|
|
8
|
-
const { run } = require('./run')
|
|
4
|
+
import { handleProcessErrors, handleError } from './error.js'
|
|
5
|
+
import { load } from './load.js'
|
|
6
|
+
import { run } from './run.js'
|
|
9
7
|
|
|
10
8
|
// Boot plugin child process.
|
|
11
9
|
const bootPlugin = async function () {
|
package/src/plugins/child/run.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { getNewEnvChanges, setEnvChanges } from '../../env/changes.js'
|
|
2
|
+
import { logPluginMethodStart, logPluginMethodEnd } from '../../log/messages/ipc.js'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { cloneNetlifyConfig, getConfigMutations } = require('./diff')
|
|
7
|
-
const { getUtils } = require('./utils')
|
|
4
|
+
import { cloneNetlifyConfig, getConfigMutations } from './diff.js'
|
|
5
|
+
import { getUtils } from './utils.js'
|
|
8
6
|
|
|
9
7
|
// Run a specific plugin event handler
|
|
10
|
-
const run = async function (
|
|
8
|
+
export const run = async function (
|
|
11
9
|
{ event, error, constants, envChanges, netlifyConfig },
|
|
12
10
|
{ methods, inputs, packageJson, verbose },
|
|
13
11
|
) {
|
|
14
12
|
const method = methods[event]
|
|
15
13
|
const runState = {}
|
|
16
|
-
const utils =
|
|
14
|
+
const utils = getUtils({ event, constants, runState })
|
|
17
15
|
const netlifyConfigCopy = cloneNetlifyConfig(netlifyConfig)
|
|
18
16
|
const runOptions = { utils, constants, inputs, netlifyConfig: netlifyConfigCopy, packageJson, error }
|
|
19
17
|
|
|
@@ -28,5 +26,3 @@ const run = async function (
|
|
|
28
26
|
const configMutations = getConfigMutations(netlifyConfig, netlifyConfigCopy, event)
|
|
29
27
|
return { ...runState, newEnvChanges, configMutations }
|
|
30
28
|
}
|
|
31
|
-
|
|
32
|
-
module.exports = { run }
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import isPlainObj from 'is-plain-obj'
|
|
2
|
+
import mapObj from 'map-obj'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const mapObj = require('map-obj')
|
|
5
|
-
|
|
6
|
-
const { addErrorInfo } = require('../../error/info')
|
|
4
|
+
import { addErrorInfo } from '../../error/info.js'
|
|
7
5
|
|
|
8
6
|
// Report status information to the UI
|
|
9
|
-
const show = function (runState, showArgs) {
|
|
7
|
+
export const show = function (runState, showArgs) {
|
|
10
8
|
validateShowArgs(showArgs)
|
|
11
9
|
const { title, summary, text } = removeEmptyStrings(showArgs)
|
|
12
10
|
runState.status = { state: 'success', title, summary, text }
|
|
@@ -67,5 +65,3 @@ const removeEmptyString = function (key, value) {
|
|
|
67
65
|
|
|
68
66
|
return [key, value]
|
|
69
67
|
}
|
|
70
|
-
|
|
71
|
-
module.exports = { show }
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { extname } from 'path'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { register } from 'ts-node'
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { addErrorInfo } = require('../../error/info')
|
|
5
|
+
import { addErrorInfo } from '../../error/info.js'
|
|
8
6
|
|
|
9
7
|
// Allow local plugins to be written with TypeScript.
|
|
10
8
|
// Local plugins cannot be transpiled by the build command since they can be run
|
|
11
9
|
// before it. Therefore, we type-check and transpile them automatically using
|
|
12
10
|
// `ts-node`.
|
|
13
|
-
const registerTypeScript = function (pluginPath) {
|
|
11
|
+
export const registerTypeScript = function (pluginPath) {
|
|
14
12
|
if (!isTypeScriptPlugin(pluginPath)) {
|
|
15
13
|
return
|
|
16
14
|
}
|
|
@@ -20,7 +18,7 @@ const registerTypeScript = function (pluginPath) {
|
|
|
20
18
|
|
|
21
19
|
// On TypeScript errors, adds information about the `ts-node` configuration,
|
|
22
20
|
// which includes the resolved `tsconfig.json`.
|
|
23
|
-
const addTsErrorInfo = function (error, tsNodeService) {
|
|
21
|
+
export const addTsErrorInfo = function (error, tsNodeService) {
|
|
24
22
|
if (tsNodeService === undefined) {
|
|
25
23
|
return
|
|
26
24
|
}
|
|
@@ -39,5 +37,3 @@ const isTypeScriptPlugin = function (pluginPath) {
|
|
|
39
37
|
}
|
|
40
38
|
|
|
41
39
|
const TYPESCRIPT_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.cts'])
|
|
42
|
-
|
|
43
|
-
module.exports = { registerTypeScript, addTsErrorInfo }
|