@netlify/build 27.18.4 → 27.18.5-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. package/package.json +8 -7
  2. package/src/core/bin.js +0 -83
  3. package/src/core/build.js +0 -559
  4. package/src/core/config.js +0 -186
  5. package/src/core/constants.js +0 -156
  6. package/src/core/dev.js +0 -31
  7. package/src/core/dry.js +0 -39
  8. package/src/core/feature_flags.js +0 -22
  9. package/src/core/flags.js +0 -204
  10. package/src/core/lingering.js +0 -85
  11. package/src/core/main.js +0 -165
  12. package/src/core/missing_side_file.js +0 -29
  13. package/src/core/normalize_flags.js +0 -70
  14. package/src/core/severity.js +0 -22
  15. package/src/core/user_node_version.js +0 -41
  16. package/src/env/changes.js +0 -52
  17. package/src/env/main.js +0 -19
  18. package/src/env/metadata.js +0 -81
  19. package/src/error/api.js +0 -46
  20. package/src/error/build.js +0 -50
  21. package/src/error/cancel.js +0 -8
  22. package/src/error/colors.js +0 -11
  23. package/src/error/handle.js +0 -57
  24. package/src/error/info.js +0 -46
  25. package/src/error/monitor/location.js +0 -21
  26. package/src/error/monitor/normalize.js +0 -96
  27. package/src/error/monitor/print.js +0 -42
  28. package/src/error/monitor/report.js +0 -138
  29. package/src/error/monitor/start.js +0 -69
  30. package/src/error/parse/clean_stack.js +0 -87
  31. package/src/error/parse/location.js +0 -62
  32. package/src/error/parse/normalize.js +0 -29
  33. package/src/error/parse/parse.js +0 -97
  34. package/src/error/parse/plugin.js +0 -70
  35. package/src/error/parse/properties.js +0 -23
  36. package/src/error/parse/serialize_log.js +0 -42
  37. package/src/error/parse/serialize_status.js +0 -23
  38. package/src/error/parse/stack.js +0 -43
  39. package/src/error/type.js +0 -189
  40. package/src/install/functions.js +0 -28
  41. package/src/install/local.js +0 -62
  42. package/src/install/main.js +0 -81
  43. package/src/install/missing.js +0 -67
  44. package/src/log/colors.js +0 -34
  45. package/src/log/description.js +0 -26
  46. package/src/log/header.js +0 -16
  47. package/src/log/header_func.js +0 -17
  48. package/src/log/logger.js +0 -161
  49. package/src/log/messages/compatibility.js +0 -178
  50. package/src/log/messages/config.js +0 -107
  51. package/src/log/messages/core.js +0 -70
  52. package/src/log/messages/core_steps.js +0 -104
  53. package/src/log/messages/dry.js +0 -63
  54. package/src/log/messages/install.js +0 -32
  55. package/src/log/messages/ipc.js +0 -38
  56. package/src/log/messages/mutations.js +0 -82
  57. package/src/log/messages/plugins.js +0 -39
  58. package/src/log/messages/status.js +0 -16
  59. package/src/log/messages/steps.js +0 -22
  60. package/src/log/old_version.js +0 -41
  61. package/src/log/serialize.js +0 -13
  62. package/src/log/stream.js +0 -85
  63. package/src/log/theme.js +0 -26
  64. package/src/plugins/child/diff.js +0 -55
  65. package/src/plugins/child/error.js +0 -32
  66. package/src/plugins/child/lazy.js +0 -18
  67. package/src/plugins/child/load.js +0 -29
  68. package/src/plugins/child/logic.js +0 -65
  69. package/src/plugins/child/main.js +0 -51
  70. package/src/plugins/child/run.js +0 -28
  71. package/src/plugins/child/status.js +0 -74
  72. package/src/plugins/child/typescript.js +0 -45
  73. package/src/plugins/child/utils.js +0 -56
  74. package/src/plugins/child/validate.js +0 -34
  75. package/src/plugins/compatibility.js +0 -132
  76. package/src/plugins/error.js +0 -50
  77. package/src/plugins/events.js +0 -17
  78. package/src/plugins/expected_version.js +0 -119
  79. package/src/plugins/ipc.js +0 -145
  80. package/src/plugins/list.js +0 -86
  81. package/src/plugins/load.js +0 -70
  82. package/src/plugins/manifest/check.js +0 -106
  83. package/src/plugins/manifest/load.js +0 -41
  84. package/src/plugins/manifest/main.js +0 -22
  85. package/src/plugins/manifest/path.js +0 -31
  86. package/src/plugins/manifest/validate.js +0 -108
  87. package/src/plugins/node_version.js +0 -50
  88. package/src/plugins/options.js +0 -88
  89. package/src/plugins/pinned_version.js +0 -131
  90. package/src/plugins/resolve.js +0 -152
  91. package/src/plugins/spawn.js +0 -72
  92. package/src/plugins_core/add.js +0 -49
  93. package/src/plugins_core/build_command.js +0 -75
  94. package/src/plugins_core/deploy/buildbot_client.js +0 -113
  95. package/src/plugins_core/deploy/index.js +0 -73
  96. package/src/plugins_core/deploy/manifest.yml +0 -1
  97. package/src/plugins_core/edge_functions/index.js +0 -123
  98. package/src/plugins_core/edge_functions/lib/error.js +0 -21
  99. package/src/plugins_core/edge_functions/lib/internal_manifest.js +0 -60
  100. package/src/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +0 -89
  101. package/src/plugins_core/functions/error.js +0 -163
  102. package/src/plugins_core/functions/feature_flags.js +0 -6
  103. package/src/plugins_core/functions/index.js +0 -161
  104. package/src/plugins_core/functions/utils.js +0 -66
  105. package/src/plugins_core/functions/zisi.js +0 -56
  106. package/src/plugins_core/functions_install/index.js +0 -13
  107. package/src/plugins_core/functions_install/manifest.yml +0 -1
  108. package/src/plugins_core/list.js +0 -27
  109. package/src/status/add.js +0 -36
  110. package/src/status/colors.js +0 -23
  111. package/src/status/load_error.js +0 -11
  112. package/src/status/report.js +0 -137
  113. package/src/status/success.js +0 -18
  114. package/src/steps/core_step.js +0 -92
  115. package/src/steps/error.js +0 -102
  116. package/src/steps/get.js +0 -51
  117. package/src/steps/plugin.js +0 -85
  118. package/src/steps/return.js +0 -52
  119. package/src/steps/run_core_steps.js +0 -200
  120. package/src/steps/run_step.js +0 -304
  121. package/src/steps/run_steps.js +0 -179
  122. package/src/steps/update_config.js +0 -93
  123. package/src/telemetry/main.js +0 -136
  124. package/src/time/aggregate.js +0 -146
  125. package/src/time/main.js +0 -48
  126. package/src/time/measure.js +0 -22
  127. package/src/time/report.js +0 -59
  128. package/src/utils/errors.js +0 -12
  129. package/src/utils/json.js +0 -19
  130. package/src/utils/omit.js +0 -6
  131. package/src/utils/package.js +0 -23
  132. package/src/utils/remove_falsy.js +0 -10
  133. package/src/utils/resolve.js +0 -46
  134. package/src/utils/runtime.js +0 -5
  135. package/src/utils/semver.js +0 -34
@@ -1,67 +0,0 @@
1
- import { promises as fs } from 'fs'
2
- import { normalize } from 'path'
3
-
4
- import { pathExists } from 'path-exists'
5
- import { isFile } from 'path-type'
6
-
7
- import { logInstallMissingPlugins } from '../log/messages/install.js'
8
-
9
- import { addExactDependencies } from './main.js'
10
-
11
- // Automatically install plugins if not already installed.
12
- // Since this is done under the hood, we always use `npm` with specific `npm`
13
- // options. We do not allow configure the package manager nor its options.
14
- // Users requiring `yarn` or custom npm/yarn flags should install the plugin in
15
- // their `package.json`.
16
- export const installMissingPlugins = async function ({ missingPlugins, autoPluginsDir, mode, logs }) {
17
- const packages = missingPlugins.map(getPackage)
18
- logInstallMissingPlugins(logs, packages)
19
-
20
- await createAutoPluginsDir(logs, autoPluginsDir)
21
- await addExactDependencies({ packageRoot: autoPluginsDir, isLocal: mode !== 'buildbot', packages })
22
- }
23
-
24
- // We pin the version without using semver ranges ^ nor ~
25
- const getPackage = function ({ packageName, expectedVersion }) {
26
- return `${packageName}@${expectedVersion}`
27
- }
28
-
29
- const createAutoPluginsDir = async function (logs, autoPluginsDir) {
30
- await ensureDir(logs, autoPluginsDir)
31
- await createPackageJson(autoPluginsDir)
32
- }
33
-
34
- // Create the directory if it does not exist
35
- const ensureDir = async function (logs, autoPluginsDir) {
36
- if (await pathExists(autoPluginsDir)) {
37
- return
38
- }
39
-
40
- // If `.netlify` exists but is not a directory, we remove it first
41
- const autoPluginsParent = normalize(`${autoPluginsDir}/..`)
42
- if (await isFile(autoPluginsParent)) {
43
- await fs.unlink(autoPluginsParent)
44
- }
45
-
46
- await fs.mkdir(autoPluginsDir, { recursive: true })
47
- }
48
-
49
- // Create a dummy `package.json` so we can run `npm install` and get a lock file
50
- const createPackageJson = async function (autoPluginsDir) {
51
- const packageJsonPath = `${autoPluginsDir}/package.json`
52
- if (await pathExists(packageJsonPath)) {
53
- return
54
- }
55
-
56
- const packageJsonContent = JSON.stringify(AUTO_PLUGINS_PACKAGE_JSON, null, 2)
57
- await fs.writeFile(packageJsonPath, packageJsonContent)
58
- }
59
-
60
- const AUTO_PLUGINS_PACKAGE_JSON = {
61
- name: 'netlify-local-plugins',
62
- description: 'This directory contains Build plugins that have been automatically installed by Netlify.',
63
- version: '1.0.0',
64
- private: true,
65
- author: 'Netlify',
66
- license: 'MIT',
67
- }
package/src/log/colors.js DELETED
@@ -1,34 +0,0 @@
1
- import { inspect } from 'util'
2
-
3
- import supportsColor from 'supports-color'
4
-
5
- // Plugin child processes use `stdio: 'pipe'` so they are always
6
- // non-interactive even if the parent is an interactive TTY. This means they
7
- // would normally lose colors. If the parent has colors, we pass an environment
8
- // variable to the child process to force colors.
9
- export const getParentColorEnv = function () {
10
- if (!hasColors()) {
11
- return {}
12
- }
13
-
14
- return { FORCE_COLOR: '1' }
15
- }
16
-
17
- // Child processes and the buildbot relies on `FORCE_COLOR=1` to set colors.
18
- // However `utils.inspect()` (used by `console.log()`) uses
19
- // `process.stdout.hasColors` which is always `undefined` when the TTY is
20
- // non-interactive. So we need to set `util.inspect.defaultOptions.colors`
21
- // manually both in plugin processes.
22
- export const setInspectColors = function () {
23
- if (!hasColors()) {
24
- return
25
- }
26
-
27
- // `inspect.defaultOptions` requires direct mutation
28
- // eslint-disable-next-line fp/no-mutation
29
- inspect.defaultOptions.colors = true
30
- }
31
-
32
- const hasColors = function () {
33
- return supportsColor.stdout !== false
34
- }
@@ -1,26 +0,0 @@
1
- export const getBuildCommandDescription = function (buildCommandOrigin) {
2
- return BUILD_COMMAND_DESCRIPTIONS[buildCommandOrigin]
3
- }
4
-
5
- const BUILD_COMMAND_DESCRIPTIONS = {
6
- ui: 'Build command from Netlify app',
7
- config: 'build.command from netlify.toml',
8
- inline: 'build.command from a plugin',
9
- }
10
-
11
- // Retrieve human-friendly plugin origin
12
- export const getPluginOrigin = function (loadedFrom, origin) {
13
- const originName = PLUGIN_ORIGINS[origin]
14
-
15
- if (loadedFrom === 'package.json') {
16
- return `from ${originName} and package.json`
17
- }
18
-
19
- return `from ${originName}`
20
- }
21
-
22
- const PLUGIN_ORIGINS = {
23
- core: 'core',
24
- ui: 'Netlify app',
25
- config: 'netlify.toml',
26
- }
package/src/log/header.js DELETED
@@ -1,16 +0,0 @@
1
- import stringWidth from 'string-width'
2
-
3
- // Print a rectangular header
4
- export const getHeader = function (message) {
5
- const messageWidth = stringWidth(message)
6
- const headerWidth = Math.max(HEADER_MIN_WIDTH, messageWidth)
7
- const line = '─'.repeat(headerWidth + PADDING_WIDTH * 2)
8
- const paddingLeft = ' '.repeat(PADDING_WIDTH)
9
- const paddingRight = ' '.repeat(PADDING_WIDTH + headerWidth - messageWidth)
10
- return `${line}
11
- ${paddingLeft}${message}${paddingRight}
12
- ${line}`
13
- }
14
-
15
- const HEADER_MIN_WIDTH = 60
16
- const PADDING_WIDTH = 2
@@ -1,17 +0,0 @@
1
- import { parseErrorInfo } from '../error/parse/parse.js'
2
-
3
- import { logHeader, logErrorHeader } from './logger.js'
4
-
5
- // Retrieve successful or error header depending on whether `error` exists
6
- export const getLogHeaderFunc = function (error) {
7
- if (error === undefined) {
8
- return logHeader
9
- }
10
-
11
- const { severity } = parseErrorInfo(error)
12
- if (severity === 'none') {
13
- return logHeader
14
- }
15
-
16
- return logErrorHeader
17
- }
package/src/log/logger.js DELETED
@@ -1,161 +0,0 @@
1
- import { createWriteStream } from 'fs'
2
-
3
- import figures from 'figures'
4
- import indentString from 'indent-string'
5
-
6
- import { getHeader } from './header.js'
7
- import { serializeObject, serializeArray } from './serialize.js'
8
- import { THEME } from './theme.js'
9
-
10
- // When the `buffer` option is true, we return logs instead of printing them
11
- // on the console. The logs are accumulated in a `logs` array variable.
12
- export const getBufferLogs = function ({ buffer = false }) {
13
- if (!buffer) {
14
- return
15
- }
16
-
17
- return { stdout: [], stderr: [] }
18
- }
19
-
20
- // Core logging utility, used by the other methods.
21
- // This should be used instead of `console.log()` as it allows us to instrument
22
- // how any build logs is being printed.
23
- export const log = function (logs, string, { indent = false, color } = {}) {
24
- const stringA = indent ? indentString(string, INDENT_SIZE) : string
25
- const stringB = String(stringA).replace(EMPTY_LINES_REGEXP, EMPTY_LINE)
26
- const stringC = color === undefined ? stringB : color(stringB)
27
-
28
- if (logs !== undefined) {
29
- // `logs` is a stateful variable
30
- // eslint-disable-next-line fp/no-mutating-methods
31
- logs.stdout.push(stringC)
32
- return
33
- }
34
-
35
- console.log(stringC)
36
- }
37
-
38
- const INDENT_SIZE = 2
39
-
40
- // We need to add a zero width space character in empty lines. Otherwise the
41
- // buildbot removes those due to a bug: https://github.com/netlify/buildbot/issues/595
42
- const EMPTY_LINES_REGEXP = /^\s*$/gm
43
- const EMPTY_LINE = '\u{200B}'
44
-
45
- const serializeIndentedArray = function (array) {
46
- return serializeArray(array.map(serializeIndentedItem))
47
- }
48
-
49
- const serializeIndentedItem = function (item) {
50
- return indentString(item, INDENT_SIZE + 1).trimStart()
51
- }
52
-
53
- export const logError = function (logs, string, opts) {
54
- log(logs, string, { color: THEME.errorLine, ...opts })
55
- }
56
-
57
- export const logWarning = function (logs, string, opts) {
58
- log(logs, string, { color: THEME.warningLine, ...opts })
59
- }
60
-
61
- // Print a message that is under a header/subheader, i.e. indented
62
- export const logMessage = function (logs, string, opts) {
63
- log(logs, string, { indent: true, ...opts })
64
- }
65
-
66
- // Print an object
67
- export const logObject = function (logs, object, opts) {
68
- logMessage(logs, serializeObject(object), opts)
69
- }
70
-
71
- // Print an array
72
- export const logArray = function (logs, array, opts) {
73
- logMessage(logs, serializeIndentedArray(array), { color: THEME.none, ...opts })
74
- }
75
-
76
- // Print an array of errors
77
- export const logErrorArray = function (logs, array, opts) {
78
- logMessage(logs, serializeIndentedArray(array), { color: THEME.errorLine, ...opts })
79
- }
80
-
81
- // Print an array of warnings
82
- export const logWarningArray = function (logs, array, opts) {
83
- logMessage(logs, serializeIndentedArray(array), { color: THEME.warningLine, ...opts })
84
- }
85
-
86
- // Print a main section header
87
- export const logHeader = function (logs, string, opts) {
88
- log(logs, `\n${getHeader(string)}`, { color: THEME.header, ...opts })
89
- }
90
-
91
- // Print a main section header, when an error happened
92
- export const logErrorHeader = function (logs, string, opts) {
93
- logHeader(logs, string, { color: THEME.errorHeader, ...opts })
94
- }
95
-
96
- // Print a sub-section header
97
- export const logSubHeader = function (logs, string, opts) {
98
- log(logs, `\n${figures.pointer} ${string}`, { color: THEME.subHeader, ...opts })
99
- }
100
-
101
- // Print a sub-section header, when an error happened
102
- export const logErrorSubHeader = function (logs, string, opts) {
103
- logSubHeader(logs, string, { color: THEME.errorSubHeader, ...opts })
104
- }
105
-
106
- // Print a sub-section header, when a warning happened
107
- export const logWarningSubHeader = function (logs, string, opts) {
108
- logSubHeader(logs, string, { color: THEME.warningSubHeader, ...opts })
109
- }
110
-
111
- // Combines an array of elements into a single string, separated by a space,
112
- // and with basic serialization of non-string types
113
- const reduceLogLines = function (lines) {
114
- return lines
115
- .map((input) => {
116
- if (input instanceof Error) {
117
- return `${input.message} ${input.stack}`
118
- }
119
-
120
- if (typeof input === 'object') {
121
- try {
122
- return JSON.stringify(input)
123
- } catch {
124
- // Value could not be serialized to JSON, so we return the string
125
- // representation.
126
- return String(input)
127
- }
128
- }
129
-
130
- return String(input)
131
- })
132
- .join(' ')
133
- }
134
-
135
- // Builds a function for logging data to the system logger (i.e. hidden from
136
- // the user-facing build logs)
137
- export const getSystemLogger = function (logs, debug, systemLogFile) {
138
- // If the `debug` flag is used, we return a function that pipes system logs
139
- // to the regular logger, as the intention is for them to end up in stdout.
140
- if (debug) {
141
- return (...args) => log(logs, reduceLogLines(args))
142
- }
143
-
144
- // If there's not a file descriptor configured for system logs and `debug`
145
- // is not set, we return a no-op function that will swallow the errors.
146
- if (!systemLogFile) {
147
- return () => {
148
- // no-op
149
- }
150
- }
151
-
152
- // Return a function that writes to the file descriptor configured for system
153
- // logs.
154
- const fileDescriptor = createWriteStream(null, { fd: systemLogFile })
155
-
156
- fileDescriptor.on('error', () => {
157
- logError(logs, 'Could not write to system log file')
158
- })
159
-
160
- return (...args) => fileDescriptor.write(`${reduceLogLines(args)}\n`)
161
- }
@@ -1,178 +0,0 @@
1
- import semver from 'semver'
2
-
3
- import { isRuntime } from '../../utils/runtime.js'
4
- import { isPreviousMajor } from '../../utils/semver.js'
5
- import { getPluginOrigin } from '../description.js'
6
- import { logArray, logSubHeader, logWarningArray, logWarningSubHeader } from '../logger.js'
7
- import { THEME } from '../theme.js'
8
-
9
- export const logRuntime = (logs, pluginOptions) => {
10
- const runtimes = pluginOptions.filter(isRuntime)
11
-
12
- // Once we have more runtimes, this hardcoded check should be removed
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 logLoadingPlugins = function (logs, pluginsOptions, debug) {
21
- const loadingPlugins = pluginsOptions
22
- .filter(isNotCorePlugin)
23
- // We don't want to show runtimes as plugins
24
- .filter((plugin) => !isRuntime(plugin))
25
- .map((pluginOptions) => getPluginDescription(pluginOptions, debug))
26
-
27
- if (loadingPlugins.length === 0) {
28
- return
29
- }
30
-
31
- logSubHeader(logs, 'Loading plugins')
32
- logArray(logs, loadingPlugins)
33
- }
34
-
35
- // We only logs plugins explicitly enabled by users
36
- const isNotCorePlugin = function ({ origin }) {
37
- return origin !== 'core'
38
- }
39
-
40
- const getPluginDescription = function (
41
- {
42
- packageName,
43
- pluginPackageJson: { version },
44
- loadedFrom,
45
- origin,
46
- pinnedVersion,
47
- latestVersion,
48
- expectedVersion,
49
- compatibleVersion,
50
- },
51
- debug,
52
- ) {
53
- const versionedPackage = getVersionedPackage(packageName, version)
54
- const pluginOrigin = getPluginOrigin(loadedFrom, origin)
55
- const description = `${THEME.highlightWords(packageName)}${versionedPackage} ${pluginOrigin}`
56
- if (!debug) {
57
- return description
58
- }
59
-
60
- const versions = Object.entries({
61
- pinned: pinnedVersion,
62
- latest: latestVersion,
63
- expected: expectedVersion,
64
- compatible: compatibleVersion,
65
- })
66
- .filter(hasVersion)
67
- .map(getVersionField)
68
-
69
- if (versions.length === 0) {
70
- return description
71
- }
72
-
73
- return `${description} (${versions.join(', ')})`
74
- }
75
-
76
- const hasVersion = function ([, version]) {
77
- return version !== undefined
78
- }
79
-
80
- const getVersionField = function ([versionFieldName, version]) {
81
- return `${versionFieldName} ${version}`
82
- }
83
-
84
- // Print a warning message when old versions plugins are used.
85
- // This can only happen when they are installed to `package.json`.
86
- export const logOutdatedPlugins = function (logs, pluginsOptions) {
87
- const outdatedPlugins = pluginsOptions.filter(hasOutdatedVersion).map(getOutdatedPlugin)
88
-
89
- if (outdatedPlugins.length === 0) {
90
- return
91
- }
92
-
93
- logWarningSubHeader(logs, 'Outdated plugins')
94
- logWarningArray(logs, outdatedPlugins)
95
- }
96
-
97
- const hasOutdatedVersion = function ({ pluginPackageJson: { version }, latestVersion }) {
98
- return version !== undefined && latestVersion !== undefined && semver.lt(version, latestVersion)
99
- }
100
-
101
- const getOutdatedPlugin = function ({
102
- packageName,
103
- pluginPackageJson: { version },
104
- latestVersion,
105
- migrationGuide,
106
- loadedFrom,
107
- origin,
108
- }) {
109
- const versionedPackage = getVersionedPackage(packageName, version)
110
- const outdatedDescription = getOutdatedDescription({ latestVersion, migrationGuide, loadedFrom, origin })
111
- return `${THEME.warningHighlightWords(packageName)}${versionedPackage}: ${outdatedDescription}`
112
- }
113
-
114
- const getOutdatedDescription = function ({ latestVersion, migrationGuide, loadedFrom, origin }) {
115
- const upgradeInstruction = getUpgradeInstruction(loadedFrom, origin)
116
- if (migrationGuide === undefined) {
117
- return `latest version is ${latestVersion}\n${upgradeInstruction}`
118
- }
119
-
120
- return `latest version is ${latestVersion}\nMigration guide: ${migrationGuide}\n${upgradeInstruction}`
121
- }
122
-
123
- const getUpgradeInstruction = function (loadedFrom, origin) {
124
- if (loadedFrom === 'package.json') {
125
- return 'To upgrade this plugin, please update its version in "package.json"'
126
- }
127
-
128
- if (origin === 'ui') {
129
- return 'To upgrade this plugin, please uninstall and re-install it from the Netlify plugins directory (https://app.netlify.com/plugins)'
130
- }
131
-
132
- return 'To upgrade this plugin, please remove it from "netlify.toml" and install it from the Netlify plugins directory instead (https://app.netlify.com/plugins)'
133
- }
134
-
135
- // Print a warning message when plugins are using a version that is too recent
136
- // and does not meet some `compatibility` expectations.
137
- // This can only happen when they are installed to `package.json`.
138
- export const logIncompatiblePlugins = function (logs, pluginsOptions) {
139
- const incompatiblePlugins = pluginsOptions.filter(hasIncompatibleVersion).map(getIncompatiblePlugin)
140
-
141
- if (incompatiblePlugins.length === 0) {
142
- return
143
- }
144
-
145
- logWarningSubHeader(logs, 'Incompatible plugins')
146
- logWarningArray(logs, incompatiblePlugins)
147
- }
148
-
149
- const hasIncompatibleVersion = function ({ pluginPackageJson: { version }, compatibleVersion, compatWarning }) {
150
- return (
151
- compatWarning !== '' &&
152
- version !== undefined &&
153
- compatibleVersion !== undefined &&
154
- // Using only the major version prevents printing this warning message when
155
- // a site is using the right `compatibility` version, but is using the most
156
- // recent version due to the time gap between `npm publish` and the
157
- // `plugins.json` update
158
- isPreviousMajor(compatibleVersion, version)
159
- )
160
- }
161
-
162
- const getIncompatiblePlugin = function ({
163
- packageName,
164
- pluginPackageJson: { version },
165
- compatibleVersion,
166
- compatWarning,
167
- }) {
168
- const versionedPackage = getVersionedPackage(packageName, version)
169
- return `${THEME.warningHighlightWords(
170
- packageName,
171
- )}${versionedPackage}: version ${compatibleVersion} is the most recent version compatible with ${compatWarning}`
172
- }
173
-
174
- // Make sure we handle `package.json` with `version` being either `undefined`
175
- // or an empty string
176
- const getVersionedPackage = function (packageName, version = '') {
177
- return version === '' ? '' : `@${version}`
178
- }
@@ -1,107 +0,0 @@
1
- import { cleanupConfig } from '@netlify/config'
2
-
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
-
8
- export const logFlags = function (logs, flags, { debug }) {
9
- const flagsA = cleanFeatureFlags(flags)
10
- const hiddenFlags = debug ? HIDDEN_DEBUG_FLAGS : HIDDEN_FLAGS
11
- const flagsB = omit(flagsA, hiddenFlags)
12
- logSubHeader(logs, 'Flags')
13
- logObject(logs, flagsB)
14
- }
15
-
16
- // We only show feature flags related to `@netlify/build`.
17
- // Also, we only print enabled feature flags.
18
- const cleanFeatureFlags = function ({ featureFlags = {}, ...flags }) {
19
- const cleanedFeatureFlags = Object.entries(featureFlags)
20
- .filter(shouldPrintFeatureFlag)
21
- .map(([featureFlagName]) => featureFlagName)
22
- return cleanedFeatureFlags.length === 0 ? flags : { ...flags, featureFlags: cleanedFeatureFlags }
23
- }
24
-
25
- const shouldPrintFeatureFlag = function ([featureFlagName, enabled]) {
26
- return enabled && featureFlagName in DEFAULT_FEATURE_FLAGS
27
- }
28
-
29
- // Hidden because the value is security-sensitive
30
- const SECURE_FLAGS = ['token', 'bugsnagKey', 'env', 'cachedConfig', 'defaultConfig']
31
- // Hidden because those are used in tests
32
- const TEST_FLAGS = ['buffer', 'telemetry']
33
- // Hidden because those are only used internally
34
- const INTERNAL_FLAGS = [
35
- 'nodePath',
36
- 'functionsDistDir',
37
- 'edgeFunctionsDistDir',
38
- 'defaultConfig',
39
- 'cachedConfigPath',
40
- 'sendStatus',
41
- 'saveConfig',
42
- 'statsd',
43
- 'framework',
44
- 'featureFlags',
45
- 'buildbotServerSocket',
46
- 'testOpts',
47
- 'siteId',
48
- 'context',
49
- 'branch',
50
- 'cwd',
51
- 'repositoryRoot',
52
- 'mode',
53
- 'apiHost',
54
- 'cacheDir',
55
- 'systemLogFile',
56
- 'timeline',
57
- ]
58
- const HIDDEN_FLAGS = [...SECURE_FLAGS, ...TEST_FLAGS, ...INTERNAL_FLAGS]
59
- const HIDDEN_DEBUG_FLAGS = [...SECURE_FLAGS, ...TEST_FLAGS]
60
-
61
- export const logBuildDir = function (logs, buildDir) {
62
- logSubHeader(logs, 'Current directory')
63
- logMessage(logs, buildDir)
64
- }
65
-
66
- export const logConfigPath = function (logs, configPath = NO_CONFIG_MESSAGE) {
67
- logSubHeader(logs, 'Config file')
68
- logMessage(logs, configPath)
69
- }
70
-
71
- const NO_CONFIG_MESSAGE = 'No config file was defined: using default values.'
72
-
73
- export const logConfig = function ({ logs, netlifyConfig, debug }) {
74
- if (!debug) {
75
- return
76
- }
77
-
78
- logSubHeader(logs, 'Resolved config')
79
- logObject(logs, cleanupConfig(netlifyConfig))
80
- }
81
-
82
- export const logConfigOnUpdate = function ({ logs, netlifyConfig, debug }) {
83
- if (!debug) {
84
- return
85
- }
86
-
87
- logSubHeader(logs, 'Updated config')
88
- logObject(logs, cleanupConfig(netlifyConfig))
89
- }
90
-
91
- export const logConfigOnError = function ({ logs, netlifyConfig, severity }) {
92
- if (netlifyConfig === undefined || severity === 'none') {
93
- return
94
- }
95
-
96
- logMessage(logs, THEME.errorSubHeader('Resolved config'))
97
- logObject(logs, cleanupConfig(netlifyConfig))
98
- }
99
-
100
- export const logContext = function (logs, context) {
101
- if (context === undefined) {
102
- return
103
- }
104
-
105
- logSubHeader(logs, 'Context')
106
- logMessage(logs, context)
107
- }
@@ -1,70 +0,0 @@
1
- import ansiEscapes from 'ansi-escapes'
2
- import prettyMs from 'pretty-ms'
3
-
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'
12
-
13
- import { logConfigOnError } from './config.js'
14
-
15
- export const logBuildStart = function (logs) {
16
- logHeader(logs, 'Netlify Build')
17
- logSubHeader(logs, 'Version')
18
- logMessage(logs, `${ROOT_PACKAGE_JSON.name} ${ROOT_PACKAGE_JSON.version}`)
19
- }
20
-
21
- export const logBuildError = function ({ error, netlifyConfig, mode, logs, debug, testOpts }) {
22
- const fullErrorInfo = getFullErrorInfo({ error, colors: true, debug })
23
- const { severity } = fullErrorInfo
24
- const { title, body } = serializeLogError({ fullErrorInfo })
25
- const logHeaderFunc = getLogHeaderFunc(error)
26
- logHeaderFunc(logs, title)
27
- logMessage(logs, `\n${body}\n`)
28
- logConfigOnError({ logs, netlifyConfig, severity })
29
- logOldCliVersionError({ mode, testOpts })
30
- }
31
-
32
- export const logBuildSuccess = function (logs) {
33
- logHeader(logs, 'Netlify Build Complete')
34
- logMessage(logs, '')
35
- }
36
-
37
- export const logTimer = function (logs, durationNs, timerName) {
38
- const durationMs = roundTimerToMillisecs(durationNs)
39
- const duration = prettyMs(durationMs)
40
- log(logs, THEME.dimWords(`(${timerName} completed in ${duration})`))
41
- }
42
-
43
- export const logMissingSideFile = function (logs, sideFile, publish) {
44
- logWarning(
45
- logs,
46
- `
47
- A "${sideFile}" file is present in the repository but is missing in the publish directory "${publish}".`,
48
- )
49
- }
50
-
51
- // @todo use `terminal-link` (https://github.com/sindresorhus/terminal-link)
52
- // instead of `ansi-escapes` once
53
- // https://github.com/jamestalmage/supports-hyperlinks/pull/12 is fixed
54
- export const logLingeringProcesses = function (logs, commands) {
55
- logWarning(
56
- logs,
57
- `
58
- The build completed successfully, but the following processes were still running:
59
- `,
60
- )
61
- logWarningArray(logs, commands)
62
- logWarning(
63
- logs,
64
- `
65
- These processes have been terminated. In case this creates a problem for your build, refer to this ${ansiEscapes.link(
66
- 'article',
67
- 'https://answers.netlify.com/t/support-guide-how-to-address-the-warning-message-related-to-terminating-processes-in-builds/35277',
68
- )} for details about why this process termination happens and how to fix it.`,
69
- )
70
- }