@netlify/build 27.18.4 → 27.18.6-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.
- package/package.json +8 -7
- package/src/core/bin.js +0 -83
- package/src/core/build.js +0 -559
- package/src/core/config.js +0 -186
- package/src/core/constants.js +0 -156
- package/src/core/dev.js +0 -31
- package/src/core/dry.js +0 -39
- package/src/core/feature_flags.js +0 -22
- package/src/core/flags.js +0 -204
- package/src/core/lingering.js +0 -85
- package/src/core/main.js +0 -165
- package/src/core/missing_side_file.js +0 -29
- package/src/core/normalize_flags.js +0 -70
- package/src/core/severity.js +0 -22
- package/src/core/user_node_version.js +0 -41
- package/src/env/changes.js +0 -52
- package/src/env/main.js +0 -19
- package/src/env/metadata.js +0 -81
- package/src/error/api.js +0 -46
- package/src/error/build.js +0 -50
- package/src/error/cancel.js +0 -8
- package/src/error/colors.js +0 -11
- package/src/error/handle.js +0 -57
- package/src/error/info.js +0 -46
- package/src/error/monitor/location.js +0 -21
- package/src/error/monitor/normalize.js +0 -96
- package/src/error/monitor/print.js +0 -42
- package/src/error/monitor/report.js +0 -138
- package/src/error/monitor/start.js +0 -69
- package/src/error/parse/clean_stack.js +0 -87
- package/src/error/parse/location.js +0 -62
- package/src/error/parse/normalize.js +0 -29
- package/src/error/parse/parse.js +0 -97
- package/src/error/parse/plugin.js +0 -70
- package/src/error/parse/properties.js +0 -23
- package/src/error/parse/serialize_log.js +0 -42
- package/src/error/parse/serialize_status.js +0 -23
- package/src/error/parse/stack.js +0 -43
- package/src/error/type.js +0 -189
- package/src/install/functions.js +0 -28
- package/src/install/local.js +0 -62
- package/src/install/main.js +0 -81
- package/src/install/missing.js +0 -67
- package/src/log/colors.js +0 -34
- package/src/log/description.js +0 -26
- package/src/log/header.js +0 -16
- package/src/log/header_func.js +0 -17
- package/src/log/logger.js +0 -161
- package/src/log/messages/compatibility.js +0 -178
- package/src/log/messages/config.js +0 -107
- package/src/log/messages/core.js +0 -70
- package/src/log/messages/core_steps.js +0 -104
- package/src/log/messages/dry.js +0 -63
- package/src/log/messages/install.js +0 -32
- package/src/log/messages/ipc.js +0 -38
- package/src/log/messages/mutations.js +0 -82
- package/src/log/messages/plugins.js +0 -39
- package/src/log/messages/status.js +0 -16
- package/src/log/messages/steps.js +0 -22
- package/src/log/old_version.js +0 -41
- package/src/log/serialize.js +0 -13
- package/src/log/stream.js +0 -85
- package/src/log/theme.js +0 -26
- package/src/plugins/child/diff.js +0 -55
- package/src/plugins/child/error.js +0 -32
- package/src/plugins/child/lazy.js +0 -18
- package/src/plugins/child/load.js +0 -29
- package/src/plugins/child/logic.js +0 -65
- package/src/plugins/child/main.js +0 -51
- package/src/plugins/child/run.js +0 -28
- package/src/plugins/child/status.js +0 -74
- package/src/plugins/child/typescript.js +0 -45
- package/src/plugins/child/utils.js +0 -56
- package/src/plugins/child/validate.js +0 -34
- package/src/plugins/compatibility.js +0 -132
- package/src/plugins/error.js +0 -50
- package/src/plugins/events.js +0 -17
- package/src/plugins/expected_version.js +0 -119
- package/src/plugins/ipc.js +0 -145
- package/src/plugins/list.js +0 -86
- package/src/plugins/load.js +0 -70
- package/src/plugins/manifest/check.js +0 -106
- package/src/plugins/manifest/load.js +0 -41
- package/src/plugins/manifest/main.js +0 -22
- package/src/plugins/manifest/path.js +0 -31
- package/src/plugins/manifest/validate.js +0 -108
- package/src/plugins/node_version.js +0 -50
- package/src/plugins/options.js +0 -88
- package/src/plugins/pinned_version.js +0 -131
- package/src/plugins/resolve.js +0 -152
- package/src/plugins/spawn.js +0 -72
- package/src/plugins_core/add.js +0 -49
- package/src/plugins_core/build_command.js +0 -75
- package/src/plugins_core/deploy/buildbot_client.js +0 -113
- package/src/plugins_core/deploy/index.js +0 -73
- package/src/plugins_core/deploy/manifest.yml +0 -1
- package/src/plugins_core/edge_functions/index.js +0 -123
- package/src/plugins_core/edge_functions/lib/error.js +0 -21
- package/src/plugins_core/edge_functions/lib/internal_manifest.js +0 -60
- package/src/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +0 -89
- package/src/plugins_core/functions/error.js +0 -163
- package/src/plugins_core/functions/feature_flags.js +0 -6
- package/src/plugins_core/functions/index.js +0 -161
- package/src/plugins_core/functions/utils.js +0 -66
- package/src/plugins_core/functions/zisi.js +0 -56
- package/src/plugins_core/functions_install/index.js +0 -13
- package/src/plugins_core/functions_install/manifest.yml +0 -1
- package/src/plugins_core/list.js +0 -27
- package/src/status/add.js +0 -36
- package/src/status/colors.js +0 -23
- package/src/status/load_error.js +0 -11
- package/src/status/report.js +0 -137
- package/src/status/success.js +0 -18
- package/src/steps/core_step.js +0 -92
- package/src/steps/error.js +0 -102
- package/src/steps/get.js +0 -51
- package/src/steps/plugin.js +0 -85
- package/src/steps/return.js +0 -52
- package/src/steps/run_core_steps.js +0 -200
- package/src/steps/run_step.js +0 -304
- package/src/steps/run_steps.js +0 -179
- package/src/steps/update_config.js +0 -93
- package/src/telemetry/main.js +0 -136
- package/src/time/aggregate.js +0 -146
- package/src/time/main.js +0 -48
- package/src/time/measure.js +0 -22
- package/src/time/report.js +0 -59
- package/src/utils/errors.js +0 -12
- package/src/utils/json.js +0 -19
- package/src/utils/omit.js +0 -6
- package/src/utils/package.js +0 -23
- package/src/utils/remove_falsy.js +0 -10
- package/src/utils/resolve.js +0 -46
- package/src/utils/runtime.js +0 -5
- package/src/utils/semver.js +0 -34
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
|
|
3
|
-
import { log, logArray, logErrorSubHeader, logWarningSubHeader } from '../logger.js'
|
|
4
|
-
import { THEME } from '../theme.js'
|
|
5
|
-
|
|
6
|
-
const logBundleResultFunctions = ({ functions, headerMessage, logs, error }) => {
|
|
7
|
-
const functionNames = functions.map(({ path: functionPath }) => path.basename(functionPath))
|
|
8
|
-
|
|
9
|
-
if (error) {
|
|
10
|
-
logErrorSubHeader(logs, headerMessage)
|
|
11
|
-
} else {
|
|
12
|
-
logWarningSubHeader(logs, headerMessage)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
logArray(logs, functionNames)
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export const logBundleResults = ({ logs, results = [] }) => {
|
|
19
|
-
const resultsWithErrors = results.filter(({ bundlerErrors }) => bundlerErrors && bundlerErrors.length !== 0)
|
|
20
|
-
const resultsWithWarnings = results.filter(
|
|
21
|
-
({ bundler, bundlerWarnings }) => bundler === 'esbuild' && bundlerWarnings && bundlerWarnings.length !== 0,
|
|
22
|
-
)
|
|
23
|
-
const modulesWithDynamicImports = [
|
|
24
|
-
...new Set(results.flatMap((result) => result.nodeModulesWithDynamicImports || [])),
|
|
25
|
-
]
|
|
26
|
-
|
|
27
|
-
if (resultsWithErrors.length !== 0) {
|
|
28
|
-
logBundleResultFunctions({
|
|
29
|
-
functions: resultsWithErrors,
|
|
30
|
-
headerMessage: 'Failed to bundle functions with selected bundler (fallback used):',
|
|
31
|
-
logs,
|
|
32
|
-
error: true,
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (resultsWithWarnings.length !== 0) {
|
|
37
|
-
logBundleResultFunctions({
|
|
38
|
-
functions: resultsWithWarnings,
|
|
39
|
-
headerMessage: 'Functions bundled with warnings:',
|
|
40
|
-
logs,
|
|
41
|
-
error: false,
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
if (modulesWithDynamicImports.length !== 0) {
|
|
46
|
-
logModulesWithDynamicImports({ logs, modulesWithDynamicImports })
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export const logFunctionsNonExistingDir = function (logs, relativeFunctionsSrc) {
|
|
51
|
-
log(logs, `The Netlify Functions setting targets a non-existing directory: ${relativeFunctionsSrc}`)
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Print the list of Netlify Functions about to be bundled
|
|
55
|
-
export const logFunctionsToBundle = function ({
|
|
56
|
-
logs,
|
|
57
|
-
userFunctions,
|
|
58
|
-
userFunctionsSrc,
|
|
59
|
-
userFunctionsSrcExists,
|
|
60
|
-
internalFunctions,
|
|
61
|
-
internalFunctionsSrc,
|
|
62
|
-
type = 'Functions',
|
|
63
|
-
}) {
|
|
64
|
-
if (internalFunctions.length !== 0) {
|
|
65
|
-
log(logs, `Packaging ${type} from ${THEME.highlightWords(internalFunctionsSrc)} directory:`)
|
|
66
|
-
logArray(logs, internalFunctions, { indent: false })
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
if (!userFunctionsSrcExists) {
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
if (userFunctions.length === 0) {
|
|
74
|
-
log(logs, `No ${type} were found in ${THEME.highlightWords(userFunctionsSrc)} directory`)
|
|
75
|
-
|
|
76
|
-
return
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
if (internalFunctions.length !== 0) {
|
|
80
|
-
log(logs, '')
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
log(logs, `Packaging ${type} from ${THEME.highlightWords(userFunctionsSrc)} directory:`)
|
|
84
|
-
logArray(logs, userFunctions, { indent: false })
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const logModulesWithDynamicImports = ({ logs, modulesWithDynamicImports }) => {
|
|
88
|
-
const externalNodeModules = modulesWithDynamicImports.map((moduleName) => `"${moduleName}"`).join(', ')
|
|
89
|
-
|
|
90
|
-
logWarningSubHeader(logs, `The following Node.js modules use dynamic expressions to include files:`)
|
|
91
|
-
logArray(logs, modulesWithDynamicImports)
|
|
92
|
-
log(
|
|
93
|
-
logs,
|
|
94
|
-
`\n Because files included with dynamic expressions aren't bundled with your serverless functions by default,
|
|
95
|
-
this may result in an error when invoking a function. To resolve this error, you can mark these Node.js
|
|
96
|
-
modules as external in the [functions] section of your \`netlify.toml\` configuration file:
|
|
97
|
-
|
|
98
|
-
[functions]
|
|
99
|
-
external_node_modules = [${externalNodeModules}]
|
|
100
|
-
|
|
101
|
-
Visit https://ntl.fyi/dynamic-imports for more information.
|
|
102
|
-
`,
|
|
103
|
-
)
|
|
104
|
-
}
|
package/src/log/messages/dry.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import figures from 'figures'
|
|
2
|
-
|
|
3
|
-
import { logMessage, logSubHeader } from '../logger.js'
|
|
4
|
-
import { THEME } from '../theme.js'
|
|
5
|
-
|
|
6
|
-
export const logDryRunStart = function ({ logs, eventWidth, stepsCount }) {
|
|
7
|
-
const columnWidth = getDryColumnWidth(eventWidth, stepsCount)
|
|
8
|
-
const line = '─'.repeat(columnWidth)
|
|
9
|
-
const secondLine = '─'.repeat(columnWidth)
|
|
10
|
-
|
|
11
|
-
logSubHeader(logs, 'Netlify Build Commands')
|
|
12
|
-
logMessage(
|
|
13
|
-
logs,
|
|
14
|
-
`For more information on build events see the docs https://github.com/netlify/build
|
|
15
|
-
|
|
16
|
-
Running \`netlify build\` will execute this build flow
|
|
17
|
-
|
|
18
|
-
${THEME.header(`┌─${line}─┬─${secondLine}─┐
|
|
19
|
-
│ ${DRY_HEADER_NAMES[0].padEnd(columnWidth)} │ ${DRY_HEADER_NAMES[1].padEnd(columnWidth)} │
|
|
20
|
-
└─${line}─┴─${secondLine}─┘`)}`,
|
|
21
|
-
)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export const logDryRunStep = function ({
|
|
25
|
-
logs,
|
|
26
|
-
step: { event, packageName, coreStepDescription },
|
|
27
|
-
index,
|
|
28
|
-
netlifyConfig,
|
|
29
|
-
eventWidth,
|
|
30
|
-
stepsCount,
|
|
31
|
-
}) {
|
|
32
|
-
const columnWidth = getDryColumnWidth(eventWidth, stepsCount)
|
|
33
|
-
const fullName = getFullName(coreStepDescription, netlifyConfig, packageName)
|
|
34
|
-
const line = '─'.repeat(columnWidth)
|
|
35
|
-
const countText = `${index + 1}. `
|
|
36
|
-
const downArrow = stepsCount === index + 1 ? ' ' : ` ${figures.arrowDown}`
|
|
37
|
-
const eventWidthA = columnWidth - countText.length - downArrow.length
|
|
38
|
-
|
|
39
|
-
logMessage(
|
|
40
|
-
logs,
|
|
41
|
-
`${THEME.header(`┌─${line}─┐`)}
|
|
42
|
-
${THEME.header(`│ ${countText}${event.padEnd(eventWidthA)}${downArrow} │`)} ${fullName}
|
|
43
|
-
${THEME.header(`└─${line}─┘ `)}`,
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const getFullName = function (coreStepDescription, netlifyConfig, packageName) {
|
|
48
|
-
return coreStepDescription === undefined
|
|
49
|
-
? `Plugin ${THEME.highlightWords(packageName)}`
|
|
50
|
-
: coreStepDescription({ netlifyConfig })
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const getDryColumnWidth = function (eventWidth, stepsCount) {
|
|
54
|
-
const symbolsWidth = `${stepsCount}`.length + COLUMN_EXTRA_WIDTH
|
|
55
|
-
return Math.max(eventWidth + symbolsWidth, DRY_HEADER_NAMES[1].length)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const COLUMN_EXTRA_WIDTH = 4
|
|
59
|
-
const DRY_HEADER_NAMES = ['Event', 'Location']
|
|
60
|
-
|
|
61
|
-
export const logDryRunEnd = function (logs) {
|
|
62
|
-
logMessage(logs, `\nIf this looks good to you, run \`netlify build\` to execute the build\n`)
|
|
63
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { isRuntime } from '../../utils/runtime.js'
|
|
2
|
-
import { log, logArray, logSubHeader } from '../logger.js'
|
|
3
|
-
|
|
4
|
-
export const logInstallMissingPlugins = function (logs, packages) {
|
|
5
|
-
const runtimes = packages.filter((pkg) => isRuntime(pkg))
|
|
6
|
-
const plugins = packages.filter((pkg) => !isRuntime(pkg))
|
|
7
|
-
|
|
8
|
-
if (plugins.length !== 0) {
|
|
9
|
-
logSubHeader(logs, 'Installing plugins')
|
|
10
|
-
logArray(logs, packages)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (runtimes.length !== 0) {
|
|
14
|
-
const [nextRuntime] = runtimes
|
|
15
|
-
|
|
16
|
-
logSubHeader(logs, `Using Next.js Runtime - v${nextRuntime.pluginPackageJson.version}`)
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const logInstallLocalPluginsDeps = function (logs, localPluginsOptions) {
|
|
21
|
-
const packages = localPluginsOptions.map(getPackageName)
|
|
22
|
-
logSubHeader(logs, 'Installing local plugins dependencies')
|
|
23
|
-
logArray(logs, packages)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export const logInstallFunctionDependencies = function () {
|
|
27
|
-
log(undefined, 'Installing functions dependencies')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const getPackageName = function ({ packageName }) {
|
|
31
|
-
return packageName
|
|
32
|
-
}
|
package/src/log/messages/ipc.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { log } from '../logger.js'
|
|
2
|
-
|
|
3
|
-
const logVerbose = function (logs, verbose, message) {
|
|
4
|
-
if (!verbose) {
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
log(logs, message)
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export const logSendingEventToChild = function (logs, verbose) {
|
|
12
|
-
logVerbose(logs, verbose, 'Step starting.')
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export const logSentEventToChild = function (logs, verbose) {
|
|
16
|
-
logVerbose(logs, verbose, 'Step started.')
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export const logPluginMethodStart = function (verbose) {
|
|
20
|
-
logVerbose(undefined, verbose, 'Plugin logic started.')
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export const logPluginMethodEnd = function (verbose) {
|
|
24
|
-
logVerbose(undefined, verbose, 'Plugin logic ended.')
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export const logSendingEventToParent = function (verbose, error) {
|
|
28
|
-
const message = error instanceof Error ? `Step erroring.\n${error.stack}` : 'Stop closing.'
|
|
29
|
-
logVerbose(undefined, verbose, message)
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export const logReceivedEventFromChild = function (logs, verbose) {
|
|
33
|
-
logVerbose(logs, verbose, 'Step ended.')
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
export const logStepCompleted = function (logs, verbose) {
|
|
37
|
-
logVerbose(logs, verbose, 'Step completed.')
|
|
38
|
-
}
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { promises as fs } from 'fs'
|
|
2
|
-
import { inspect } from 'util'
|
|
3
|
-
|
|
4
|
-
import { pathExists } from 'path-exists'
|
|
5
|
-
|
|
6
|
-
import { log, logMessage, logSubHeader } from '../logger.js'
|
|
7
|
-
|
|
8
|
-
export const logConfigMutations = function (logs, newConfigMutations, debug) {
|
|
9
|
-
const configMutationsToLog = debug ? newConfigMutations : newConfigMutations.filter(shouldLogConfigMutation)
|
|
10
|
-
configMutationsToLog.forEach(({ keysString, value }) => {
|
|
11
|
-
logConfigMutation(logs, keysString, value)
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// Some configuration mutations are only logged in debug mode
|
|
16
|
-
const shouldLogConfigMutation = function ({ keysString }) {
|
|
17
|
-
return !HIDDEN_PROPS.some((hiddenProp) => keysString.startsWith(hiddenProp))
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// `functions` is an object which can have thousands of properties, one per
|
|
21
|
-
// function file. This can be very verbose, especially for plugins which create
|
|
22
|
-
// many function files like Essential Next.js
|
|
23
|
-
const HIDDEN_PROPS = ['functions']
|
|
24
|
-
|
|
25
|
-
const logConfigMutation = function (logs, keysString, value) {
|
|
26
|
-
const newValue = shouldHideConfigValue(keysString) ? '' : ` to ${inspect(value, { colors: false })}`
|
|
27
|
-
log(logs, `Netlify configuration property "${keysString}" value changed${newValue}.`)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const shouldHideConfigValue = function (keysString) {
|
|
31
|
-
return SECRET_PROPS.some((secretProp) => keysString.startsWith(secretProp))
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const SECRET_PROPS = ['build.environment']
|
|
35
|
-
|
|
36
|
-
export const logConfigOnUpload = async function ({ logs, configPath, debug }) {
|
|
37
|
-
if (!debug) {
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
logSubHeader(logs, 'Uploaded config')
|
|
42
|
-
|
|
43
|
-
if (!(await pathExists(configPath))) {
|
|
44
|
-
logMessage(logs, 'No netlify.toml')
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const configContents = await fs.readFile(configPath, 'utf8')
|
|
49
|
-
logMessage(logs, configContents.trim())
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const logHeadersOnUpload = async function ({ logs, headersPath, debug }) {
|
|
53
|
-
if (!debug) {
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
logSubHeader(logs, 'Uploaded headers')
|
|
58
|
-
|
|
59
|
-
if (!(await pathExists(headersPath))) {
|
|
60
|
-
logMessage(logs, 'No headers')
|
|
61
|
-
return
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const headersContents = await fs.readFile(headersPath, 'utf8')
|
|
65
|
-
logMessage(logs, headersContents.trim())
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export const logRedirectsOnUpload = async function ({ logs, redirectsPath, debug }) {
|
|
69
|
-
if (!debug) {
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
logSubHeader(logs, 'Uploaded redirects')
|
|
74
|
-
|
|
75
|
-
if (!(await pathExists(redirectsPath))) {
|
|
76
|
-
logMessage(logs, 'No redirects\n')
|
|
77
|
-
return
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
const redirectsContents = await fs.readFile(redirectsPath, 'utf8')
|
|
81
|
-
logMessage(logs, `${redirectsContents.trim()}\n`)
|
|
82
|
-
}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { log, logArray, logWarning, logSubHeader } from '../logger.js'
|
|
2
|
-
|
|
3
|
-
export const logPluginsFetchError = function (logs, message) {
|
|
4
|
-
logWarning(
|
|
5
|
-
logs,
|
|
6
|
-
`
|
|
7
|
-
Warning: could not fetch latest plugins list. Plugins versions might not be the latest.
|
|
8
|
-
${message}`,
|
|
9
|
-
)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const logPluginsList = function ({ pluginsList, debug, logs }) {
|
|
13
|
-
if (!debug) {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// eslint-disable-next-line fp/no-mutating-methods
|
|
18
|
-
const pluginsListArray = Object.entries(pluginsList).map(getPluginsListItem).sort()
|
|
19
|
-
|
|
20
|
-
logSubHeader(logs, 'Available plugins')
|
|
21
|
-
logArray(logs, pluginsListArray)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const getPluginsListItem = function ([packageName, versions]) {
|
|
25
|
-
return `${packageName}@${versions[0].version}`
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export const logFailPluginWarning = function (methodName, event) {
|
|
29
|
-
logWarning(
|
|
30
|
-
undefined,
|
|
31
|
-
`Plugin error: since "${event}" happens after deploy, the build has already succeeded and cannot fail anymore. This plugin should either:
|
|
32
|
-
- use utils.build.failPlugin() instead of utils.build.${methodName}() to clarify that the plugin failed, but not the build.
|
|
33
|
-
- use "onPostBuild" instead of "${event}" if the plugin failure should make the build fail too. Please note that "onPostBuild" (unlike "${event}") happens before deploy.`,
|
|
34
|
-
)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export const logDeploySuccess = function (logs) {
|
|
38
|
-
log(logs, 'Site deploy was successfully initiated')
|
|
39
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { logMessage, logHeader, logSubHeader } from '../logger.js'
|
|
2
|
-
import { THEME } from '../theme.js'
|
|
3
|
-
|
|
4
|
-
export const logStatuses = function (logs, statuses) {
|
|
5
|
-
logHeader(logs, 'Summary')
|
|
6
|
-
statuses.forEach((status) => {
|
|
7
|
-
logStatus(logs, status)
|
|
8
|
-
})
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const logStatus = function (logs, { packageName, title = `Plugin ${packageName} ran successfully`, summary, text }) {
|
|
12
|
-
const titleA = title.includes(packageName) ? title : `${packageName}: ${title}`
|
|
13
|
-
const body = text === undefined ? summary : `${summary}\n${THEME.dimWords(text)}`
|
|
14
|
-
logSubHeader(logs, titleA)
|
|
15
|
-
logMessage(logs, body)
|
|
16
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { getLogHeaderFunc } from '../header_func.js'
|
|
2
|
-
import { log, logMessage } from '../logger.js'
|
|
3
|
-
import { THEME } from '../theme.js'
|
|
4
|
-
|
|
5
|
-
export const logStepStart = function ({ logs, event, packageName, coreStepDescription, index, error, netlifyConfig }) {
|
|
6
|
-
const description = getDescription({ coreStepDescription, netlifyConfig, packageName, event })
|
|
7
|
-
const logHeaderFunc = getLogHeaderFunc(error)
|
|
8
|
-
logHeaderFunc(logs, `${index + 1}. ${description}`)
|
|
9
|
-
logMessage(logs, '')
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const getDescription = function ({ coreStepDescription, netlifyConfig, packageName, event }) {
|
|
13
|
-
return coreStepDescription === undefined ? `${packageName} (${event} event)` : coreStepDescription({ netlifyConfig })
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export const logBuildCommandStart = function (logs, buildCommand) {
|
|
17
|
-
log(logs, THEME.highlightWords(`$ ${buildCommand}`))
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const logStepSuccess = function (logs) {
|
|
21
|
-
logMessage(logs, '')
|
|
22
|
-
}
|
package/src/log/old_version.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { stdout } from 'process'
|
|
2
|
-
|
|
3
|
-
import UpdateNotifier from 'update-notifier'
|
|
4
|
-
|
|
5
|
-
import { ROOT_PACKAGE_JSON } from '../utils/json.js'
|
|
6
|
-
|
|
7
|
-
// Many build errors happen in local builds that do not use the latest version
|
|
8
|
-
// of `@netlify/build`. We print a warning message on those.
|
|
9
|
-
// We only print this when Netlify CLI has been used. Programmatic usage might
|
|
10
|
-
// come from a deep dependency calling `@netlify/build` and user might not be
|
|
11
|
-
// able to take any upgrade action, making the message noisy.
|
|
12
|
-
export const logOldCliVersionError = function ({ mode, testOpts }) {
|
|
13
|
-
if (mode !== 'cli') {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const corePackageJson = getCorePackageJson(testOpts)
|
|
18
|
-
UpdateNotifier({ pkg: corePackageJson, updateCheckInterval: 1 }).notify({
|
|
19
|
-
message: OLD_VERSION_MESSAGE,
|
|
20
|
-
shouldNotifyInNpmScript: true,
|
|
21
|
-
})
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const getCorePackageJson = function (testOpts) {
|
|
25
|
-
// TODO: Find a way to test this without injecting code in the `src/`
|
|
26
|
-
if (testOpts.oldCliLogs) {
|
|
27
|
-
// `update-notifier` does not do anything if not in a TTY.
|
|
28
|
-
// In tests, we need to monkey patch this
|
|
29
|
-
// Mutation is required due to how `stdout.isTTY` works
|
|
30
|
-
// eslint-disable-next-line fp/no-mutation
|
|
31
|
-
stdout.isTTY = true
|
|
32
|
-
|
|
33
|
-
return { ...ROOT_PACKAGE_JSON, version: '0.0.1' }
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return ROOT_PACKAGE_JSON
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const OLD_VERSION_MESSAGE = `Please update netlify-cli to its latest version.
|
|
40
|
-
If netlify-cli is already the latest version,
|
|
41
|
-
please update your dependencies lock file instead.`
|
package/src/log/serialize.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { dump } from 'js-yaml'
|
|
2
|
-
|
|
3
|
-
export const serializeObject = function (object) {
|
|
4
|
-
return dump(object, { noRefs: true, sortKeys: true, lineWidth: Number.POSITIVE_INFINITY }).trimEnd()
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export const serializeArray = function (array) {
|
|
8
|
-
return array.map(addDash).join('\n')
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const addDash = function (string) {
|
|
12
|
-
return ` - ${string}`
|
|
13
|
-
}
|
package/src/log/stream.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { stdout, stderr } from 'process'
|
|
2
|
-
import { promisify } from 'util'
|
|
3
|
-
|
|
4
|
-
// TODO: replace with `timers/promises` after dropping Node < 15.0.0
|
|
5
|
-
const pSetTimeout = promisify(setTimeout)
|
|
6
|
-
|
|
7
|
-
// We try to use `stdio: inherit` because it keeps `stdout/stderr` as `TTY`,
|
|
8
|
-
// which solves many problems. However we can only do it in build.command.
|
|
9
|
-
// Plugins have several events, so need to be switch on and off instead.
|
|
10
|
-
// In buffer mode (`logs` not `undefined`), `pipe` is necessary.
|
|
11
|
-
export const getBuildCommandStdio = function (logs) {
|
|
12
|
-
if (logs !== undefined) {
|
|
13
|
-
return 'pipe'
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return 'inherit'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Add build command output
|
|
20
|
-
export const handleBuildCommandOutput = function ({ stdout: commandStdout, stderr: commandStderr }, logs) {
|
|
21
|
-
if (logs === undefined) {
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
pushBuildCommandOutput(commandStdout, logs.stdout)
|
|
26
|
-
pushBuildCommandOutput(commandStderr, logs.stderr)
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const pushBuildCommandOutput = function (output, logsArray) {
|
|
30
|
-
if (output === '') {
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
logsArray.push(output)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Start plugin step output
|
|
38
|
-
export const pipePluginOutput = function (childProcess, logs) {
|
|
39
|
-
if (logs === undefined) {
|
|
40
|
-
return streamOutput(childProcess)
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return pushOutputToLogs(childProcess, logs)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Stop streaming/buffering plugin step output
|
|
47
|
-
export const unpipePluginOutput = async function (childProcess, logs, listeners) {
|
|
48
|
-
// Let `childProcess` `stdout` and `stderr` flush before stopping redirecting
|
|
49
|
-
await pSetTimeout(0)
|
|
50
|
-
|
|
51
|
-
if (logs === undefined) {
|
|
52
|
-
return unstreamOutput(childProcess)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
unpushOutputToLogs(childProcess, logs, listeners)
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
// Usually, we stream stdout/stderr because it is more efficient
|
|
59
|
-
const streamOutput = function (childProcess) {
|
|
60
|
-
childProcess.stdout.pipe(stdout)
|
|
61
|
-
childProcess.stderr.pipe(stderr)
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const unstreamOutput = function (childProcess) {
|
|
65
|
-
childProcess.stdout.unpipe(stdout)
|
|
66
|
-
childProcess.stderr.unpipe(stderr)
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
// In tests, we push to the `logs` array instead
|
|
70
|
-
const pushOutputToLogs = function (childProcess, logs) {
|
|
71
|
-
const stdoutListener = logsListener.bind(null, logs.stdout)
|
|
72
|
-
const stderrListener = logsListener.bind(null, logs.stderr)
|
|
73
|
-
childProcess.stdout.on('data', stdoutListener)
|
|
74
|
-
childProcess.stderr.on('data', stderrListener)
|
|
75
|
-
return { stdoutListener, stderrListener }
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const logsListener = function (logs, chunk) {
|
|
79
|
-
logs.push(chunk.toString().trimEnd())
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const unpushOutputToLogs = function (childProcess, logs, { stdoutListener, stderrListener }) {
|
|
83
|
-
childProcess.stdout.removeListener('data', stdoutListener)
|
|
84
|
-
childProcess.stderr.removeListener('data', stderrListener)
|
|
85
|
-
}
|
package/src/log/theme.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import chalk from 'chalk'
|
|
2
|
-
|
|
3
|
-
// Color theme. Please use this instead of requiring chalk directly, to ensure
|
|
4
|
-
// consistent colors.
|
|
5
|
-
export const THEME = {
|
|
6
|
-
// Main headers
|
|
7
|
-
header: chalk.cyanBright.bold,
|
|
8
|
-
// Single lines used as subheaders
|
|
9
|
-
subHeader: chalk.cyan.bold,
|
|
10
|
-
// One of several words that should be highlighted inside a line
|
|
11
|
-
highlightWords: chalk.cyan,
|
|
12
|
-
// Same for errors
|
|
13
|
-
errorHeader: chalk.redBright.bold,
|
|
14
|
-
errorSubHeader: chalk.red.bold,
|
|
15
|
-
errorLine: chalk.redBright,
|
|
16
|
-
errorHighlightWords: chalk.redBright.bold,
|
|
17
|
-
// Same for warnings
|
|
18
|
-
warningHeader: chalk.yellowBright.bold,
|
|
19
|
-
warningSubHeader: chalk.yellow.bold,
|
|
20
|
-
warningLine: chalk.yellowBright,
|
|
21
|
-
warningHighlightWords: chalk.yellowBright.bold,
|
|
22
|
-
// One of several words that should be dimmed inside a line
|
|
23
|
-
dimWords: chalk.gray,
|
|
24
|
-
// No colors
|
|
25
|
-
none: (string) => string,
|
|
26
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { isDeepStrictEqual } from 'util'
|
|
2
|
-
|
|
3
|
-
import isPlainObj from 'is-plain-obj'
|
|
4
|
-
import rfdc from 'rfdc'
|
|
5
|
-
|
|
6
|
-
const clone = rfdc()
|
|
7
|
-
|
|
8
|
-
// Copy `netlifyConfig` so we can compare before/after mutating it
|
|
9
|
-
export const cloneNetlifyConfig = function (netlifyConfig) {
|
|
10
|
-
return clone(netlifyConfig)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Diff `netlifyConfig` before and after mutating it to retrieve an array of
|
|
14
|
-
// `configMutations` objects.
|
|
15
|
-
// We need to keep track of the changes on `netlifyConfig` so they can be
|
|
16
|
-
// processed later to:
|
|
17
|
-
// - Warn plugin authors when mutating read-only properties
|
|
18
|
-
// - Apply the change to `netlifyConfig` in the parent process so it can
|
|
19
|
-
// run `@netlify/config` to normalize and validate the new values
|
|
20
|
-
// `configMutations` is passed to parent process as JSON
|
|
21
|
-
export const getConfigMutations = function (netlifyConfig, netlifyConfigCopy, event) {
|
|
22
|
-
const configMutations = diffObjects(netlifyConfig, netlifyConfigCopy, [])
|
|
23
|
-
return configMutations.map((configMutation) => getConfigMutation(configMutation, event))
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// We only recurse over plain objects, not arrays. Which means array properties
|
|
27
|
-
// can only be modified all at once.
|
|
28
|
-
const diffObjects = function (objA, objB, parentKeys) {
|
|
29
|
-
const allKeys = [...new Set([...Object.keys(objA), ...Object.keys(objB)])]
|
|
30
|
-
return allKeys.flatMap((key) => {
|
|
31
|
-
const valueA = objA[key]
|
|
32
|
-
const valueB = objB[key]
|
|
33
|
-
const keys = [...parentKeys, key]
|
|
34
|
-
|
|
35
|
-
if (isPlainObj(valueA) && isPlainObj(valueB)) {
|
|
36
|
-
return diffObjects(valueA, valueB, keys)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (isDeepStrictEqual(valueA, valueB)) {
|
|
40
|
-
return []
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return [{ keys, value: valueB }]
|
|
44
|
-
})
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const getConfigMutation = function ({ keys, value }, event) {
|
|
48
|
-
const serializedKeys = keys.map(String)
|
|
49
|
-
return {
|
|
50
|
-
keys: serializedKeys,
|
|
51
|
-
keysString: serializedKeys.join('.'),
|
|
52
|
-
value,
|
|
53
|
-
event,
|
|
54
|
-
}
|
|
55
|
-
}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import logProcessErrors from 'log-process-errors'
|
|
2
|
-
|
|
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'
|
|
7
|
-
|
|
8
|
-
// Handle any top-level error and communicate it back to parent
|
|
9
|
-
export const handleError = async function (error, verbose) {
|
|
10
|
-
const errorA = normalizeError(error)
|
|
11
|
-
addDefaultErrorInfo(errorA, { type: 'pluginInternal' })
|
|
12
|
-
const errorPayload = errorToJson(errorA)
|
|
13
|
-
await sendEventToParent('error', errorPayload, verbose, errorA)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// On uncaught exceptions and unhandled rejections, print the stack trace.
|
|
17
|
-
// Also, prevent child processes from crashing on uncaught exceptions.
|
|
18
|
-
export const handleProcessErrors = function () {
|
|
19
|
-
logProcessErrors({ log: handleProcessError, exitOn: [] })
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const handleProcessError = async function (error, level, originalError) {
|
|
23
|
-
if (level !== 'error') {
|
|
24
|
-
console[level](error)
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Do not use log-process-errors prettification with errors thrown by `utils.build.*`
|
|
29
|
-
const errorA = isBuildError(originalError) ? originalError : error
|
|
30
|
-
|
|
31
|
-
await handleError(errorA)
|
|
32
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import memoizeOne from 'memoize-one'
|
|
2
|
-
|
|
3
|
-
// Add a `object[propName]` whose value is the return value of `getFunc()`, but
|
|
4
|
-
// is only retrieved when accessed.
|
|
5
|
-
export const addLazyProp = function (object, propName, getFunc) {
|
|
6
|
-
const mGetFunc = memoizeOne(getFunc, returnTrue)
|
|
7
|
-
// Mutation is required due to the usage of `Object.defineProperty()`
|
|
8
|
-
// eslint-disable-next-line fp/no-mutating-methods
|
|
9
|
-
Object.defineProperty(object, propName, {
|
|
10
|
-
get: mGetFunc,
|
|
11
|
-
enumerable: true,
|
|
12
|
-
configurable: true,
|
|
13
|
-
})
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const returnTrue = function () {
|
|
17
|
-
return true
|
|
18
|
-
}
|