@netlify/build 25.0.0 → 26.0.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 +6 -4
- package/src/core/bin.js +7 -8
- package/src/core/config.js +18 -35
- package/src/core/constants.js +8 -14
- package/src/core/dry.js +4 -8
- package/src/core/feature_flags.js +2 -6
- 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 +9 -11
- 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 +20 -31
- 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 +6 -10
- 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 +13 -16
- package/src/plugins/error.js +6 -15
- package/src/plugins/events.js +5 -20
- package/src/plugins/expected_version.js +9 -13
- 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 -15
- package/src/plugins/options.js +12 -17
- 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 +20 -14
- 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 +8 -12
- 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 +19 -0
- 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
package/src/install/missing.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { writeFile, unlink } from 'fs'
|
|
2
|
+
import { normalize } from 'path'
|
|
3
|
+
import { promisify } from 'util'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
import makeDir from 'make-dir'
|
|
6
|
+
import pathExists from 'path-exists'
|
|
7
|
+
import { isFile } from 'path-type'
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
const pathExists = require('path-exists')
|
|
9
|
-
const { isFile } = require('path-type')
|
|
9
|
+
import { logInstallMissingPlugins } from '../log/messages/install.js'
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
const { addExactDependencies } = require('./main')
|
|
11
|
+
import { addExactDependencies } from './main.js'
|
|
14
12
|
|
|
15
13
|
const pWriteFile = promisify(writeFile)
|
|
16
14
|
const pUnlink = promisify(unlink)
|
|
@@ -20,7 +18,7 @@ const pUnlink = promisify(unlink)
|
|
|
20
18
|
// options. We do not allow configure the package manager nor its options.
|
|
21
19
|
// Users requiring `yarn` or custom npm/yarn flags should install the plugin in
|
|
22
20
|
// their `package.json`.
|
|
23
|
-
const installMissingPlugins = async function ({ missingPlugins, autoPluginsDir, mode, logs }) {
|
|
21
|
+
export const installMissingPlugins = async function ({ missingPlugins, autoPluginsDir, mode, logs }) {
|
|
24
22
|
const packages = missingPlugins.map(getPackage)
|
|
25
23
|
logInstallMissingPlugins(logs, packages)
|
|
26
24
|
|
|
@@ -72,5 +70,3 @@ const AUTO_PLUGINS_PACKAGE_JSON = {
|
|
|
72
70
|
author: 'Netlify',
|
|
73
71
|
license: 'MIT',
|
|
74
72
|
}
|
|
75
|
-
|
|
76
|
-
module.exports = { installMissingPlugins }
|
package/src/log/colors.js
CHANGED
|
@@ -1,16 +1,12 @@
|
|
|
1
|
-
|
|
1
|
+
import { inspect } from 'util'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
inspect: { defaultOptions },
|
|
5
|
-
} = require('util')
|
|
6
|
-
|
|
7
|
-
const supportsColor = require('supports-color')
|
|
3
|
+
import supportsColor from 'supports-color'
|
|
8
4
|
|
|
9
5
|
// Plugin child processes use `stdio: 'pipe'` so they are always
|
|
10
6
|
// non-interactive even if the parent is an interactive TTY. This means they
|
|
11
7
|
// would normally lose colors. If the parent has colors, we pass an environment
|
|
12
8
|
// variable to the child process to force colors.
|
|
13
|
-
const getParentColorEnv = function () {
|
|
9
|
+
export const getParentColorEnv = function () {
|
|
14
10
|
if (!hasColors()) {
|
|
15
11
|
return {}
|
|
16
12
|
}
|
|
@@ -23,18 +19,16 @@ const getParentColorEnv = function () {
|
|
|
23
19
|
// `process.stdout.hasColors` which is always `undefined` when the TTY is
|
|
24
20
|
// non-interactive. So we need to set `util.inspect.defaultOptions.colors`
|
|
25
21
|
// manually both in plugin processes.
|
|
26
|
-
const setInspectColors = function () {
|
|
22
|
+
export const setInspectColors = function () {
|
|
27
23
|
if (!hasColors()) {
|
|
28
24
|
return
|
|
29
25
|
}
|
|
30
26
|
|
|
31
27
|
// `inspect.defaultOptions` requires direct mutation
|
|
32
28
|
// eslint-disable-next-line fp/no-mutation
|
|
33
|
-
defaultOptions.colors = true
|
|
29
|
+
inspect.defaultOptions.colors = true
|
|
34
30
|
}
|
|
35
31
|
|
|
36
32
|
const hasColors = function () {
|
|
37
33
|
return supportsColor.stdout !== false
|
|
38
34
|
}
|
|
39
|
-
|
|
40
|
-
module.exports = { getParentColorEnv, setInspectColors }
|
package/src/log/description.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const getBuildCommandDescription = function (buildCommandOrigin) {
|
|
1
|
+
export const getBuildCommandDescription = function (buildCommandOrigin) {
|
|
4
2
|
return BUILD_COMMAND_DESCRIPTIONS[buildCommandOrigin]
|
|
5
3
|
}
|
|
6
4
|
|
|
@@ -11,7 +9,7 @@ const BUILD_COMMAND_DESCRIPTIONS = {
|
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
// Retrieve human-friendly plugin origin
|
|
14
|
-
const getPluginOrigin = function (loadedFrom, origin) {
|
|
12
|
+
export const getPluginOrigin = function (loadedFrom, origin) {
|
|
15
13
|
const originName = PLUGIN_ORIGINS[origin]
|
|
16
14
|
|
|
17
15
|
if (loadedFrom === 'package.json') {
|
|
@@ -26,5 +24,3 @@ const PLUGIN_ORIGINS = {
|
|
|
26
24
|
ui: 'Netlify app',
|
|
27
25
|
config: 'netlify.toml',
|
|
28
26
|
}
|
|
29
|
-
|
|
30
|
-
module.exports = { getBuildCommandDescription, getPluginOrigin }
|
package/src/log/header.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const stringWidth = require('string-width')
|
|
1
|
+
import stringWidth from 'string-width'
|
|
4
2
|
|
|
5
3
|
// Print a rectangular header
|
|
6
|
-
const getHeader = function (message) {
|
|
4
|
+
export const getHeader = function (message) {
|
|
7
5
|
const messageWidth = stringWidth(message)
|
|
8
6
|
const headerWidth = Math.max(HEADER_MIN_WIDTH, messageWidth)
|
|
9
7
|
const line = '─'.repeat(headerWidth + PADDING_WIDTH * 2)
|
|
@@ -16,5 +14,3 @@ ${line}`
|
|
|
16
14
|
|
|
17
15
|
const HEADER_MIN_WIDTH = 60
|
|
18
16
|
const PADDING_WIDTH = 2
|
|
19
|
-
|
|
20
|
-
module.exports = { getHeader }
|
package/src/log/header_func.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { parseErrorInfo } from '../error/parse/parse.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { logHeader, logErrorHeader } = require('./logger')
|
|
3
|
+
import { logHeader, logErrorHeader } from './logger.js'
|
|
6
4
|
|
|
7
5
|
// Retrieve successful or error header depending on whether `error` exists
|
|
8
|
-
const getLogHeaderFunc = function (error) {
|
|
6
|
+
export const getLogHeaderFunc = function (error) {
|
|
9
7
|
if (error === undefined) {
|
|
10
8
|
return logHeader
|
|
11
9
|
}
|
|
@@ -17,5 +15,3 @@ const getLogHeaderFunc = function (error) {
|
|
|
17
15
|
|
|
18
16
|
return logErrorHeader
|
|
19
17
|
}
|
|
20
|
-
|
|
21
|
-
module.exports = { getLogHeaderFunc }
|
package/src/log/logger.js
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
import figures from 'figures'
|
|
2
|
+
import indentString from 'indent-string'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { getHeader } = require('./header')
|
|
7
|
-
const { serializeObject, serializeArray } = require('./serialize')
|
|
8
|
-
const { THEME } = require('./theme')
|
|
4
|
+
import { getHeader } from './header.js'
|
|
5
|
+
import { serializeObject, serializeArray } from './serialize.js'
|
|
6
|
+
import { THEME } from './theme.js'
|
|
9
7
|
|
|
10
8
|
// When the `buffer` option is true, we return logs instead of printing them
|
|
11
9
|
// on the console. The logs are accumulated in a `logs` array variable.
|
|
12
|
-
const getBufferLogs = function ({ buffer = false }) {
|
|
10
|
+
export const getBufferLogs = function ({ buffer = false }) {
|
|
13
11
|
if (!buffer) {
|
|
14
12
|
return
|
|
15
13
|
}
|
|
@@ -20,7 +18,7 @@ const getBufferLogs = function ({ buffer = false }) {
|
|
|
20
18
|
// Core logging utility, used by the other methods.
|
|
21
19
|
// This should be used instead of `console.log()` as it allows us to instrument
|
|
22
20
|
// how any build logs is being printed.
|
|
23
|
-
const log = function (logs, string, { indent = false, color } = {}) {
|
|
21
|
+
export const log = function (logs, string, { indent = false, color } = {}) {
|
|
24
22
|
const stringA = indent ? indentString(string, INDENT_SIZE) : string
|
|
25
23
|
const stringB = String(stringA).replace(EMPTY_LINES_REGEXP, EMPTY_LINE)
|
|
26
24
|
const stringC = color === undefined ? stringB : color(stringB)
|
|
@@ -50,78 +48,60 @@ const serializeIndentedItem = function (item) {
|
|
|
50
48
|
return indentString(item, INDENT_SIZE + 1).trimLeft()
|
|
51
49
|
}
|
|
52
50
|
|
|
53
|
-
const logError = function (logs, string, opts) {
|
|
51
|
+
export const logError = function (logs, string, opts) {
|
|
54
52
|
log(logs, string, { color: THEME.errorLine, ...opts })
|
|
55
53
|
}
|
|
56
54
|
|
|
57
|
-
const logWarning = function (logs, string, opts) {
|
|
55
|
+
export const logWarning = function (logs, string, opts) {
|
|
58
56
|
log(logs, string, { color: THEME.warningLine, ...opts })
|
|
59
57
|
}
|
|
60
58
|
|
|
61
59
|
// Print a message that is under a header/subheader, i.e. indented
|
|
62
|
-
const logMessage = function (logs, string, opts) {
|
|
60
|
+
export const logMessage = function (logs, string, opts) {
|
|
63
61
|
log(logs, string, { indent: true, ...opts })
|
|
64
62
|
}
|
|
65
63
|
|
|
66
64
|
// Print an object
|
|
67
|
-
const logObject = function (logs, object, opts) {
|
|
65
|
+
export const logObject = function (logs, object, opts) {
|
|
68
66
|
logMessage(logs, serializeObject(object), opts)
|
|
69
67
|
}
|
|
70
68
|
|
|
71
69
|
// Print an array
|
|
72
|
-
const logArray = function (logs, array, opts) {
|
|
70
|
+
export const logArray = function (logs, array, opts) {
|
|
73
71
|
logMessage(logs, serializeIndentedArray(array), { color: THEME.none, ...opts })
|
|
74
72
|
}
|
|
75
73
|
|
|
76
74
|
// Print an array of errors
|
|
77
|
-
const logErrorArray = function (logs, array, opts) {
|
|
75
|
+
export const logErrorArray = function (logs, array, opts) {
|
|
78
76
|
logMessage(logs, serializeIndentedArray(array), { color: THEME.errorLine, ...opts })
|
|
79
77
|
}
|
|
80
78
|
|
|
81
79
|
// Print an array of warnings
|
|
82
|
-
const logWarningArray = function (logs, array, opts) {
|
|
80
|
+
export const logWarningArray = function (logs, array, opts) {
|
|
83
81
|
logMessage(logs, serializeIndentedArray(array), { color: THEME.warningLine, ...opts })
|
|
84
82
|
}
|
|
85
83
|
|
|
86
84
|
// Print a main section header
|
|
87
|
-
const logHeader = function (logs, string, opts) {
|
|
85
|
+
export const logHeader = function (logs, string, opts) {
|
|
88
86
|
log(logs, `\n${getHeader(string)}`, { color: THEME.header, ...opts })
|
|
89
87
|
}
|
|
90
88
|
|
|
91
89
|
// Print a main section header, when an error happened
|
|
92
|
-
const logErrorHeader = function (logs, string, opts) {
|
|
90
|
+
export const logErrorHeader = function (logs, string, opts) {
|
|
93
91
|
logHeader(logs, string, { color: THEME.errorHeader, ...opts })
|
|
94
92
|
}
|
|
95
93
|
|
|
96
94
|
// Print a sub-section header
|
|
97
|
-
const logSubHeader = function (logs, string, opts) {
|
|
98
|
-
log(logs, `\n${pointer} ${string}`, { color: THEME.subHeader, ...opts })
|
|
95
|
+
export const logSubHeader = function (logs, string, opts) {
|
|
96
|
+
log(logs, `\n${figures.pointer} ${string}`, { color: THEME.subHeader, ...opts })
|
|
99
97
|
}
|
|
100
98
|
|
|
101
99
|
// Print a sub-section header, when an error happened
|
|
102
|
-
const logErrorSubHeader = function (logs, string, opts) {
|
|
100
|
+
export const logErrorSubHeader = function (logs, string, opts) {
|
|
103
101
|
logSubHeader(logs, string, { color: THEME.errorSubHeader, ...opts })
|
|
104
102
|
}
|
|
105
103
|
|
|
106
104
|
// Print a sub-section header, when a warning happened
|
|
107
|
-
const logWarningSubHeader = function (logs, string, opts) {
|
|
105
|
+
export const logWarningSubHeader = function (logs, string, opts) {
|
|
108
106
|
logSubHeader(logs, string, { color: THEME.warningSubHeader, ...opts })
|
|
109
107
|
}
|
|
110
|
-
|
|
111
|
-
module.exports = {
|
|
112
|
-
getBufferLogs,
|
|
113
|
-
log,
|
|
114
|
-
logError,
|
|
115
|
-
logWarning,
|
|
116
|
-
logMessage,
|
|
117
|
-
logObject,
|
|
118
|
-
logArray,
|
|
119
|
-
logErrorArray,
|
|
120
|
-
logWarningArray,
|
|
121
|
-
logHeader,
|
|
122
|
-
logErrorHeader,
|
|
123
|
-
logSubHeader,
|
|
124
|
-
logErrorSubHeader,
|
|
125
|
-
logWarningSubHeader,
|
|
126
|
-
pointer,
|
|
127
|
-
}
|
|
@@ -1,14 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import semver from 'semver'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { isPreviousMajor } from '../../utils/semver.js'
|
|
4
|
+
import { getPluginOrigin } from '../description.js'
|
|
5
|
+
import { logArray, logSubHeader, logWarningArray, logWarningSubHeader } from '../logger.js'
|
|
6
|
+
import { THEME } from '../theme.js'
|
|
4
7
|
|
|
5
|
-
const
|
|
6
|
-
const { getPluginOrigin } = require('../description')
|
|
7
|
-
const { logArray, logSubHeader } = require('../logger')
|
|
8
|
-
const { logWarningArray, logWarningSubHeader } = require('../logger')
|
|
9
|
-
const { THEME } = require('../theme')
|
|
10
|
-
|
|
11
|
-
const logLoadingPlugins = function (logs, pluginsOptions, debug) {
|
|
8
|
+
export const logLoadingPlugins = function (logs, pluginsOptions, debug) {
|
|
12
9
|
const loadingPlugins = pluginsOptions
|
|
13
10
|
.filter(isNotCorePlugin)
|
|
14
11
|
.map((pluginOptions) => getPluginDescription(pluginOptions, debug))
|
|
@@ -72,7 +69,7 @@ const getVersionField = function ([versionFieldName, version]) {
|
|
|
72
69
|
|
|
73
70
|
// Print a warning message when old versions plugins are used.
|
|
74
71
|
// This can only happen when they are installed to `package.json`.
|
|
75
|
-
const logOutdatedPlugins = function (logs, pluginsOptions) {
|
|
72
|
+
export const logOutdatedPlugins = function (logs, pluginsOptions) {
|
|
76
73
|
const outdatedPlugins = pluginsOptions.filter(hasOutdatedVersion).map(getOutdatedPlugin)
|
|
77
74
|
|
|
78
75
|
if (outdatedPlugins.length === 0) {
|
|
@@ -84,7 +81,7 @@ const logOutdatedPlugins = function (logs, pluginsOptions) {
|
|
|
84
81
|
}
|
|
85
82
|
|
|
86
83
|
const hasOutdatedVersion = function ({ pluginPackageJson: { version }, latestVersion }) {
|
|
87
|
-
return version !== undefined && latestVersion !== undefined &&
|
|
84
|
+
return version !== undefined && latestVersion !== undefined && semver.lt(version, latestVersion)
|
|
88
85
|
}
|
|
89
86
|
|
|
90
87
|
const getOutdatedPlugin = function ({
|
|
@@ -124,7 +121,7 @@ const getUpgradeInstruction = function (loadedFrom, origin) {
|
|
|
124
121
|
// Print a warning message when plugins are using a version that is too recent
|
|
125
122
|
// and does not meet some `compatibility` expectations.
|
|
126
123
|
// This can only happen when they are installed to `package.json`.
|
|
127
|
-
const logIncompatiblePlugins = function (logs, pluginsOptions) {
|
|
124
|
+
export const logIncompatiblePlugins = function (logs, pluginsOptions) {
|
|
128
125
|
const incompatiblePlugins = pluginsOptions.filter(hasIncompatibleVersion).map(getIncompatiblePlugin)
|
|
129
126
|
|
|
130
127
|
if (incompatiblePlugins.length === 0) {
|
|
@@ -165,9 +162,3 @@ const getIncompatiblePlugin = function ({
|
|
|
165
162
|
const getVersionedPackage = function (packageName, version = '') {
|
|
166
163
|
return version === '' ? '' : `@${version}`
|
|
167
164
|
}
|
|
168
|
-
|
|
169
|
-
module.exports = {
|
|
170
|
-
logLoadingPlugins,
|
|
171
|
-
logOutdatedPlugins,
|
|
172
|
-
logIncompatiblePlugins,
|
|
173
|
-
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { cleanupConfig } from '@netlify/config'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
import { DEFAULT_FEATURE_FLAGS } from '../../core/feature_flags.js'
|
|
4
|
+
import { omit } from '../../utils/omit.js'
|
|
5
|
+
import { logMessage, logObject, logSubHeader } from '../logger.js'
|
|
6
|
+
import { THEME } from '../theme.js'
|
|
7
7
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
const logFlags = function (logs, flags, { debug }) {
|
|
8
|
+
export const logFlags = function (logs, flags, { debug }) {
|
|
11
9
|
const flagsA = cleanFeatureFlags(flags)
|
|
12
10
|
const hiddenFlags = debug ? HIDDEN_DEBUG_FLAGS : HIDDEN_FLAGS
|
|
13
11
|
const flagsB = omit(flagsA, hiddenFlags)
|
|
@@ -57,49 +55,46 @@ const INTERNAL_FLAGS = [
|
|
|
57
55
|
const HIDDEN_FLAGS = [...SECURE_FLAGS, ...TEST_FLAGS, ...INTERNAL_FLAGS]
|
|
58
56
|
const HIDDEN_DEBUG_FLAGS = [...SECURE_FLAGS, ...TEST_FLAGS]
|
|
59
57
|
|
|
60
|
-
const logBuildDir = function (logs, buildDir) {
|
|
58
|
+
export const logBuildDir = function (logs, buildDir) {
|
|
61
59
|
logSubHeader(logs, 'Current directory')
|
|
62
60
|
logMessage(logs, buildDir)
|
|
63
61
|
}
|
|
64
62
|
|
|
65
|
-
const logConfigPath = function (logs, configPath = NO_CONFIG_MESSAGE) {
|
|
63
|
+
export const logConfigPath = function (logs, configPath = NO_CONFIG_MESSAGE) {
|
|
66
64
|
logSubHeader(logs, 'Config file')
|
|
67
65
|
logMessage(logs, configPath)
|
|
68
66
|
}
|
|
69
67
|
|
|
70
68
|
const NO_CONFIG_MESSAGE = 'No config file was defined: using default values.'
|
|
71
69
|
|
|
72
|
-
const logConfig =
|
|
70
|
+
export const logConfig = function ({ logs, netlifyConfig, debug }) {
|
|
73
71
|
if (!debug) {
|
|
74
72
|
return
|
|
75
73
|
}
|
|
76
74
|
|
|
77
|
-
const { cleanupConfig } = await netlifyConfigPromise
|
|
78
75
|
logSubHeader(logs, 'Resolved config')
|
|
79
76
|
logObject(logs, cleanupConfig(netlifyConfig))
|
|
80
77
|
}
|
|
81
78
|
|
|
82
|
-
const logConfigOnUpdate =
|
|
79
|
+
export const logConfigOnUpdate = function ({ logs, netlifyConfig, debug }) {
|
|
83
80
|
if (!debug) {
|
|
84
81
|
return
|
|
85
82
|
}
|
|
86
83
|
|
|
87
|
-
const { cleanupConfig } = await netlifyConfigPromise
|
|
88
84
|
logSubHeader(logs, 'Updated config')
|
|
89
85
|
logObject(logs, cleanupConfig(netlifyConfig))
|
|
90
86
|
}
|
|
91
87
|
|
|
92
|
-
const logConfigOnError =
|
|
88
|
+
export const logConfigOnError = function ({ logs, netlifyConfig, severity }) {
|
|
93
89
|
if (netlifyConfig === undefined || severity === 'none') {
|
|
94
90
|
return
|
|
95
91
|
}
|
|
96
92
|
|
|
97
|
-
const { cleanupConfig } = await netlifyConfigPromise
|
|
98
93
|
logMessage(logs, THEME.errorSubHeader('Resolved config'))
|
|
99
94
|
logObject(logs, cleanupConfig(netlifyConfig))
|
|
100
95
|
}
|
|
101
96
|
|
|
102
|
-
const logContext = function (logs, context) {
|
|
97
|
+
export const logContext = function (logs, context) {
|
|
103
98
|
if (context === undefined) {
|
|
104
99
|
return
|
|
105
100
|
}
|
|
@@ -107,13 +102,3 @@ const logContext = function (logs, context) {
|
|
|
107
102
|
logSubHeader(logs, 'Context')
|
|
108
103
|
logMessage(logs, context)
|
|
109
104
|
}
|
|
110
|
-
|
|
111
|
-
module.exports = {
|
|
112
|
-
logFlags,
|
|
113
|
-
logBuildDir,
|
|
114
|
-
logConfigPath,
|
|
115
|
-
logConfig,
|
|
116
|
-
logConfigOnUpdate,
|
|
117
|
-
logConfigOnError,
|
|
118
|
-
logContext,
|
|
119
|
-
}
|
package/src/log/messages/core.js
CHANGED
|
@@ -1,48 +1,46 @@
|
|
|
1
|
-
|
|
1
|
+
import ansiEscapes from 'ansi-escapes'
|
|
2
|
+
import prettyMs from 'pretty-ms'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import { getFullErrorInfo } from '../../error/parse/parse.js'
|
|
5
|
+
import { serializeLogError } from '../../error/parse/serialize_log.js'
|
|
6
|
+
import { roundTimerToMillisecs } from '../../time/measure.js'
|
|
7
|
+
import { ROOT_PACKAGE_JSON } from '../../utils/json.js'
|
|
8
|
+
import { getLogHeaderFunc } from '../header_func.js'
|
|
9
|
+
import { log, logMessage, logWarning, logHeader, logSubHeader, logWarningArray } from '../logger.js'
|
|
10
|
+
import { logOldCliVersionError } from '../old_version.js'
|
|
11
|
+
import { THEME } from '../theme.js'
|
|
5
12
|
|
|
6
|
-
|
|
7
|
-
const { getFullErrorInfo } = require('../../error/parse/parse')
|
|
8
|
-
const { serializeLogError } = require('../../error/parse/serialize_log')
|
|
9
|
-
const { roundTimerToMillisecs } = require('../../time/measure')
|
|
10
|
-
const { getLogHeaderFunc } = require('../header_func')
|
|
11
|
-
const { log, logMessage, logWarning, logHeader, logSubHeader, logWarningArray } = require('../logger')
|
|
12
|
-
const { logOldCliVersionError } = require('../old_version')
|
|
13
|
-
const { THEME } = require('../theme')
|
|
13
|
+
import { logConfigOnError } from './config.js'
|
|
14
14
|
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
const logBuildStart = function (logs) {
|
|
15
|
+
export const logBuildStart = function (logs) {
|
|
18
16
|
logHeader(logs, 'Netlify Build')
|
|
19
17
|
logSubHeader(logs, 'Version')
|
|
20
|
-
logMessage(logs, `${name} ${version}`)
|
|
18
|
+
logMessage(logs, `${ROOT_PACKAGE_JSON.name} ${ROOT_PACKAGE_JSON.version}`)
|
|
21
19
|
}
|
|
22
20
|
|
|
23
|
-
const logBuildError =
|
|
21
|
+
export const logBuildError = function ({ error, netlifyConfig, mode, logs, debug, testOpts }) {
|
|
24
22
|
const fullErrorInfo = getFullErrorInfo({ error, colors: true, debug })
|
|
25
23
|
const { severity } = fullErrorInfo
|
|
26
24
|
const { title, body } = serializeLogError({ fullErrorInfo })
|
|
27
25
|
const logHeaderFunc = getLogHeaderFunc(error)
|
|
28
26
|
logHeaderFunc(logs, title)
|
|
29
27
|
logMessage(logs, `\n${body}\n`)
|
|
30
|
-
|
|
28
|
+
logConfigOnError({ logs, netlifyConfig, severity })
|
|
31
29
|
logOldCliVersionError({ mode, testOpts })
|
|
32
30
|
}
|
|
33
31
|
|
|
34
|
-
const logBuildSuccess = function (logs) {
|
|
32
|
+
export const logBuildSuccess = function (logs) {
|
|
35
33
|
logHeader(logs, 'Netlify Build Complete')
|
|
36
34
|
logMessage(logs, '')
|
|
37
35
|
}
|
|
38
36
|
|
|
39
|
-
const logTimer = function (logs, durationNs, timerName) {
|
|
37
|
+
export const logTimer = function (logs, durationNs, timerName) {
|
|
40
38
|
const durationMs = roundTimerToMillisecs(durationNs)
|
|
41
39
|
const duration = prettyMs(durationMs)
|
|
42
40
|
log(logs, THEME.dimWords(`(${timerName} completed in ${duration})`))
|
|
43
41
|
}
|
|
44
42
|
|
|
45
|
-
const logMissingSideFile = function (logs, sideFile, publish) {
|
|
43
|
+
export const logMissingSideFile = function (logs, sideFile, publish) {
|
|
46
44
|
logWarning(
|
|
47
45
|
logs,
|
|
48
46
|
`
|
|
@@ -53,7 +51,7 @@ A "${sideFile}" file is present in the repository but is missing in the publish
|
|
|
53
51
|
// @todo use `terminal-link` (https://github.com/sindresorhus/terminal-link)
|
|
54
52
|
// instead of `ansi-escapes` once
|
|
55
53
|
// https://github.com/jamestalmage/supports-hyperlinks/pull/12 is fixed
|
|
56
|
-
const logLingeringProcesses = function (logs, commands) {
|
|
54
|
+
export const logLingeringProcesses = function (logs, commands) {
|
|
57
55
|
logWarning(
|
|
58
56
|
logs,
|
|
59
57
|
`
|
|
@@ -64,18 +62,9 @@ The build completed successfully, but the following processes were still running
|
|
|
64
62
|
logWarning(
|
|
65
63
|
logs,
|
|
66
64
|
`
|
|
67
|
-
These processes have been terminated. In case this creates a problem for your build, refer to this ${link(
|
|
65
|
+
These processes have been terminated. In case this creates a problem for your build, refer to this ${ansiEscapes.link(
|
|
68
66
|
'article',
|
|
69
67
|
'https://answers.netlify.com/t/support-guide-how-to-address-the-warning-message-related-to-terminating-processes-in-builds/35277',
|
|
70
68
|
)} for details about why this process termination happens and how to fix it.`,
|
|
71
69
|
)
|
|
72
70
|
}
|
|
73
|
-
|
|
74
|
-
module.exports = {
|
|
75
|
-
logBuildStart,
|
|
76
|
-
logBuildError,
|
|
77
|
-
logBuildSuccess,
|
|
78
|
-
logTimer,
|
|
79
|
-
logMissingSideFile,
|
|
80
|
-
logLingeringProcesses,
|
|
81
|
-
}
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import path from 'path'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { log, logArray, logErrorSubHeader, logWarningSubHeader } = require('../logger')
|
|
6
|
-
const { THEME } = require('../theme')
|
|
3
|
+
import { log, logArray, logErrorSubHeader, logWarningSubHeader } from '../logger.js'
|
|
4
|
+
import { THEME } from '../theme.js'
|
|
7
5
|
|
|
8
6
|
const logBundleResultFunctions = ({ functions, headerMessage, logs, error }) => {
|
|
9
7
|
const functionNames = functions.map(({ path: functionPath }) => path.basename(functionPath))
|
|
@@ -17,7 +15,7 @@ const logBundleResultFunctions = ({ functions, headerMessage, logs, error }) =>
|
|
|
17
15
|
logArray(logs, functionNames)
|
|
18
16
|
}
|
|
19
17
|
|
|
20
|
-
const logBundleResults = ({ logs, results = [] }) => {
|
|
18
|
+
export const logBundleResults = ({ logs, results = [] }) => {
|
|
21
19
|
const resultsWithErrors = results.filter(({ bundlerErrors }) => bundlerErrors && bundlerErrors.length !== 0)
|
|
22
20
|
const resultsWithWarnings = results.filter(
|
|
23
21
|
({ bundler, bundlerWarnings }) => bundler === 'esbuild' && bundlerWarnings && bundlerWarnings.length !== 0,
|
|
@@ -49,12 +47,12 @@ const logBundleResults = ({ logs, results = [] }) => {
|
|
|
49
47
|
}
|
|
50
48
|
}
|
|
51
49
|
|
|
52
|
-
const logFunctionsNonExistingDir = function (logs, relativeFunctionsSrc) {
|
|
50
|
+
export const logFunctionsNonExistingDir = function (logs, relativeFunctionsSrc) {
|
|
53
51
|
log(logs, `The Netlify Functions setting targets a non-existing directory: ${relativeFunctionsSrc}`)
|
|
54
52
|
}
|
|
55
53
|
|
|
56
54
|
// Print the list of Netlify Functions about to be bundled
|
|
57
|
-
const logFunctionsToBundle = function ({
|
|
55
|
+
export const logFunctionsToBundle = function ({
|
|
58
56
|
logs,
|
|
59
57
|
userFunctions,
|
|
60
58
|
userFunctionsSrc,
|
|
@@ -95,7 +93,7 @@ const logModulesWithDynamicImports = ({ logs, modulesWithDynamicImports }) => {
|
|
|
95
93
|
`\n Because files included with dynamic expressions aren't bundled with your serverless functions by default,
|
|
96
94
|
this may result in an error when invoking a function. To resolve this error, you can mark these Node.js
|
|
97
95
|
modules as external in the [functions] section of your \`netlify.toml\` configuration file:
|
|
98
|
-
|
|
96
|
+
|
|
99
97
|
[functions]
|
|
100
98
|
external_node_modules = [${externalNodeModules}]
|
|
101
99
|
|
|
@@ -103,9 +101,3 @@ const logModulesWithDynamicImports = ({ logs, modulesWithDynamicImports }) => {
|
|
|
103
101
|
`,
|
|
104
102
|
)
|
|
105
103
|
}
|
|
106
|
-
|
|
107
|
-
module.exports = {
|
|
108
|
-
logBundleResults,
|
|
109
|
-
logFunctionsToBundle,
|
|
110
|
-
logFunctionsNonExistingDir,
|
|
111
|
-
}
|
package/src/log/messages/dry.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import figures from 'figures'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { logMessage, logSubHeader } from '../logger.js'
|
|
4
|
+
import { THEME } from '../theme.js'
|
|
4
5
|
|
|
5
|
-
const {
|
|
6
|
-
const { THEME } = require('../theme')
|
|
7
|
-
|
|
8
|
-
const logDryRunStart = function ({ logs, eventWidth, stepsCount }) {
|
|
6
|
+
export const logDryRunStart = function ({ logs, eventWidth, stepsCount }) {
|
|
9
7
|
const columnWidth = getDryColumnWidth(eventWidth, stepsCount)
|
|
10
8
|
const line = '─'.repeat(columnWidth)
|
|
11
9
|
const secondLine = '─'.repeat(columnWidth)
|
|
@@ -23,7 +21,7 @@ ${THEME.header(`┌─${line}─┬─${secondLine}─┐
|
|
|
23
21
|
)
|
|
24
22
|
}
|
|
25
23
|
|
|
26
|
-
const logDryRunStep = function ({
|
|
24
|
+
export const logDryRunStep = function ({
|
|
27
25
|
logs,
|
|
28
26
|
step: { event, packageName, coreStepDescription },
|
|
29
27
|
index,
|
|
@@ -35,7 +33,7 @@ const logDryRunStep = function ({
|
|
|
35
33
|
const fullName = getFullName(coreStepDescription, netlifyConfig, packageName)
|
|
36
34
|
const line = '─'.repeat(columnWidth)
|
|
37
35
|
const countText = `${index + 1}. `
|
|
38
|
-
const downArrow = stepsCount === index + 1 ? ' ' : ` ${arrowDown}`
|
|
36
|
+
const downArrow = stepsCount === index + 1 ? ' ' : ` ${figures.arrowDown}`
|
|
39
37
|
const eventWidthA = columnWidth - countText.length - downArrow.length
|
|
40
38
|
|
|
41
39
|
logMessage(
|
|
@@ -60,12 +58,6 @@ const getDryColumnWidth = function (eventWidth, stepsCount) {
|
|
|
60
58
|
const COLUMN_EXTRA_WIDTH = 4
|
|
61
59
|
const DRY_HEADER_NAMES = ['Event', 'Location']
|
|
62
60
|
|
|
63
|
-
const logDryRunEnd = function (logs) {
|
|
61
|
+
export const logDryRunEnd = function (logs) {
|
|
64
62
|
logMessage(logs, `\nIf this looks good to you, run \`netlify build\` to execute the build\n`)
|
|
65
63
|
}
|
|
66
|
-
|
|
67
|
-
module.exports = {
|
|
68
|
-
logDryRunStart,
|
|
69
|
-
logDryRunStep,
|
|
70
|
-
logDryRunEnd,
|
|
71
|
-
}
|
|
@@ -1,28 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { log, logArray, logSubHeader } from '../logger.js'
|
|
2
2
|
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
const logInstallMissingPlugins = function (logs, packages) {
|
|
3
|
+
export const logInstallMissingPlugins = function (logs, packages) {
|
|
6
4
|
logSubHeader(logs, 'Installing plugins')
|
|
7
5
|
logArray(logs, packages)
|
|
8
6
|
}
|
|
9
7
|
|
|
10
|
-
const logInstallLocalPluginsDeps = function (logs, localPluginsOptions) {
|
|
8
|
+
export const logInstallLocalPluginsDeps = function (logs, localPluginsOptions) {
|
|
11
9
|
const packages = localPluginsOptions.map(getPackageName)
|
|
12
10
|
logSubHeader(logs, 'Installing local plugins dependencies')
|
|
13
11
|
logArray(logs, packages)
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
const logInstallFunctionDependencies = function () {
|
|
14
|
+
export const logInstallFunctionDependencies = function () {
|
|
17
15
|
log(undefined, 'Installing functions dependencies')
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
const getPackageName = function ({ packageName }) {
|
|
21
19
|
return packageName
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
module.exports = {
|
|
25
|
-
logInstallMissingPlugins,
|
|
26
|
-
logInstallLocalPluginsDeps,
|
|
27
|
-
logInstallFunctionDependencies,
|
|
28
|
-
}
|