@netlify/build 28.0.1-beta → 28.1.0-framework-version-detection

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 (259) hide show
  1. package/bin.js +5 -0
  2. package/lib/core/bin.js +66 -0
  3. package/lib/core/build.js +355 -0
  4. package/lib/core/config.js +125 -0
  5. package/lib/core/constants.js +116 -0
  6. package/lib/core/dev.js +27 -0
  7. package/lib/core/dry.js +21 -0
  8. package/lib/core/feature_flags.js +19 -0
  9. package/lib/core/flags.js +201 -0
  10. package/lib/core/lingering.js +68 -0
  11. package/lib/core/main.js +105 -0
  12. package/lib/core/missing_side_file.js +17 -0
  13. package/lib/core/normalize_flags.js +59 -0
  14. package/lib/core/severity.js +21 -0
  15. package/lib/core/types.js +8 -0
  16. package/lib/core/user_node_version.js +32 -0
  17. package/lib/env/changes.js +43 -0
  18. package/lib/env/main.js +14 -0
  19. package/lib/env/metadata.js +68 -0
  20. package/lib/error/api.js +37 -0
  21. package/lib/error/build.js +36 -0
  22. package/{src → lib}/error/cancel.js +5 -6
  23. package/lib/error/colors.js +9 -0
  24. package/lib/error/handle.js +46 -0
  25. package/lib/error/info.js +37 -0
  26. package/lib/error/monitor/location.js +16 -0
  27. package/lib/error/monitor/normalize.js +86 -0
  28. package/lib/error/monitor/print.js +20 -0
  29. package/lib/error/monitor/report.js +120 -0
  30. package/lib/error/monitor/start.js +61 -0
  31. package/lib/error/parse/clean_stack.js +70 -0
  32. package/lib/error/parse/location.js +50 -0
  33. package/lib/error/parse/normalize.js +24 -0
  34. package/lib/error/parse/parse.js +67 -0
  35. package/lib/error/parse/plugin.js +55 -0
  36. package/lib/error/parse/properties.js +16 -0
  37. package/lib/error/parse/serialize_log.js +34 -0
  38. package/lib/error/parse/serialize_status.js +18 -0
  39. package/lib/error/parse/stack.js +34 -0
  40. package/lib/error/type.js +171 -0
  41. package/lib/install/functions.js +20 -0
  42. package/lib/install/local.js +45 -0
  43. package/lib/install/main.js +67 -0
  44. package/lib/install/missing.js +54 -0
  45. package/{src → lib}/log/colors.js +15 -22
  46. package/lib/log/description.js +21 -0
  47. package/lib/log/header.js +14 -0
  48. package/lib/log/header_func.js +13 -0
  49. package/lib/log/logger.js +140 -0
  50. package/lib/log/messages/compatibility.js +120 -0
  51. package/lib/log/messages/config.js +98 -0
  52. package/lib/log/messages/core.js +50 -0
  53. package/lib/log/messages/core_steps.js +75 -0
  54. package/lib/log/messages/dry.js +41 -0
  55. package/lib/log/messages/install.js +25 -0
  56. package/lib/log/messages/ipc.js +29 -0
  57. package/lib/log/messages/mutations.js +62 -0
  58. package/{src → lib}/log/messages/plugins.js +18 -32
  59. package/lib/log/messages/status.js +14 -0
  60. package/lib/log/messages/steps.js +18 -0
  61. package/lib/log/old_version.js +32 -0
  62. package/lib/log/serialize.js +10 -0
  63. package/lib/log/stream.js +68 -0
  64. package/lib/log/theme.js +25 -0
  65. package/lib/plugins/child/diff.js +46 -0
  66. package/lib/plugins/child/error.js +26 -0
  67. package/lib/plugins/child/lazy.js +15 -0
  68. package/lib/plugins/child/load.js +22 -0
  69. package/lib/plugins/child/logic.js +57 -0
  70. package/lib/plugins/child/main.js +37 -0
  71. package/lib/plugins/child/run.js +19 -0
  72. package/lib/plugins/child/status.js +63 -0
  73. package/lib/plugins/child/typescript.js +28 -0
  74. package/lib/plugins/child/utils.js +42 -0
  75. package/lib/plugins/child/validate.js +31 -0
  76. package/lib/plugins/compatibility.js +104 -0
  77. package/{src → lib}/plugins/error.js +31 -35
  78. package/{src → lib}/plugins/events.js +7 -12
  79. package/lib/plugins/expected_version.js +81 -0
  80. package/lib/plugins/ipc.js +120 -0
  81. package/lib/plugins/list.js +73 -0
  82. package/lib/plugins/load.js +50 -0
  83. package/lib/plugins/manifest/check.js +85 -0
  84. package/lib/plugins/manifest/load.js +38 -0
  85. package/lib/plugins/manifest/main.js +17 -0
  86. package/lib/plugins/manifest/path.js +24 -0
  87. package/lib/plugins/manifest/validate.js +91 -0
  88. package/lib/plugins/node_version.js +30 -0
  89. package/lib/plugins/options.js +55 -0
  90. package/lib/plugins/pinned_version.js +83 -0
  91. package/lib/plugins/resolve.js +110 -0
  92. package/lib/plugins/spawn.js +54 -0
  93. package/lib/plugins_core/add.js +35 -0
  94. package/lib/plugins_core/build_command.js +50 -0
  95. package/lib/plugins_core/deploy/buildbot_client.js +87 -0
  96. package/lib/plugins_core/deploy/index.js +49 -0
  97. package/{src → lib}/plugins_core/deploy/manifest.yml +0 -0
  98. package/lib/plugins_core/edge_functions/index.js +79 -0
  99. package/lib/plugins_core/edge_functions/lib/error.js +17 -0
  100. package/lib/plugins_core/edge_functions/lib/internal_manifest.js +50 -0
  101. package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +75 -0
  102. package/lib/plugins_core/functions/error.js +123 -0
  103. package/lib/plugins_core/functions/feature_flags.js +6 -0
  104. package/lib/plugins_core/functions/index.js +114 -0
  105. package/lib/plugins_core/functions/utils.js +45 -0
  106. package/lib/plugins_core/functions/zisi.js +39 -0
  107. package/{src → lib}/plugins_core/functions_install/index.js +8 -11
  108. package/{src → lib}/plugins_core/functions_install/manifest.yml +0 -0
  109. package/lib/plugins_core/list.js +20 -0
  110. package/lib/status/add.js +30 -0
  111. package/lib/status/colors.js +18 -0
  112. package/lib/status/load_error.js +10 -0
  113. package/lib/status/report.js +83 -0
  114. package/lib/status/success.js +14 -0
  115. package/lib/steps/core_step.js +57 -0
  116. package/lib/steps/error.js +65 -0
  117. package/lib/steps/get.js +43 -0
  118. package/lib/steps/plugin.js +55 -0
  119. package/lib/steps/return.js +25 -0
  120. package/lib/steps/run_core_steps.js +126 -0
  121. package/lib/steps/run_step.js +188 -0
  122. package/lib/steps/run_steps.js +96 -0
  123. package/lib/steps/update_config.js +66 -0
  124. package/lib/telemetry/main.js +97 -0
  125. package/lib/time/aggregate.js +120 -0
  126. package/lib/time/main.js +37 -0
  127. package/lib/time/measure.js +18 -0
  128. package/lib/time/report.js +47 -0
  129. package/lib/utils/errors.js +13 -0
  130. package/lib/utils/json.js +15 -0
  131. package/{src → lib}/utils/omit.js +3 -4
  132. package/lib/utils/package.js +22 -0
  133. package/lib/utils/remove_falsy.js +8 -0
  134. package/lib/utils/resolve.js +41 -0
  135. package/lib/utils/runtime.js +5 -0
  136. package/lib/utils/semver.js +28 -0
  137. package/package.json +39 -19
  138. package/types/config/netlify_config.d.ts +4 -4
  139. package/types/netlify_plugin_constants.d.ts +8 -8
  140. package/src/core/bin.js +0 -83
  141. package/src/core/config.js +0 -186
  142. package/src/core/constants.js +0 -156
  143. package/src/core/dry.js +0 -39
  144. package/src/core/feature_flags.js +0 -21
  145. package/src/core/flags.js +0 -194
  146. package/src/core/lingering.js +0 -85
  147. package/src/core/main.js +0 -692
  148. package/src/core/missing_side_file.js +0 -29
  149. package/src/core/normalize_flags.js +0 -69
  150. package/src/core/severity.js +0 -22
  151. package/src/core/user_node_version.js +0 -41
  152. package/src/env/changes.js +0 -52
  153. package/src/env/main.js +0 -19
  154. package/src/env/metadata.js +0 -81
  155. package/src/error/api.js +0 -46
  156. package/src/error/build.js +0 -50
  157. package/src/error/colors.js +0 -11
  158. package/src/error/handle.js +0 -57
  159. package/src/error/info.js +0 -46
  160. package/src/error/monitor/location.js +0 -21
  161. package/src/error/monitor/normalize.js +0 -77
  162. package/src/error/monitor/print.js +0 -42
  163. package/src/error/monitor/report.js +0 -133
  164. package/src/error/monitor/start.js +0 -69
  165. package/src/error/parse/clean_stack.js +0 -87
  166. package/src/error/parse/location.js +0 -58
  167. package/src/error/parse/normalize.js +0 -29
  168. package/src/error/parse/parse.js +0 -97
  169. package/src/error/parse/plugin.js +0 -70
  170. package/src/error/parse/properties.js +0 -23
  171. package/src/error/parse/serialize_log.js +0 -42
  172. package/src/error/parse/serialize_status.js +0 -23
  173. package/src/error/parse/stack.js +0 -43
  174. package/src/error/type.js +0 -182
  175. package/src/install/functions.js +0 -28
  176. package/src/install/local.js +0 -62
  177. package/src/install/main.js +0 -81
  178. package/src/install/missing.js +0 -67
  179. package/src/log/description.js +0 -26
  180. package/src/log/header.js +0 -16
  181. package/src/log/header_func.js +0 -17
  182. package/src/log/logger.js +0 -107
  183. package/src/log/messages/compatibility.js +0 -164
  184. package/src/log/messages/config.js +0 -105
  185. package/src/log/messages/core.js +0 -70
  186. package/src/log/messages/core_steps.js +0 -104
  187. package/src/log/messages/dry.js +0 -63
  188. package/src/log/messages/install.js +0 -20
  189. package/src/log/messages/ipc.js +0 -38
  190. package/src/log/messages/mutations.js +0 -82
  191. package/src/log/messages/status.js +0 -16
  192. package/src/log/messages/steps.js +0 -22
  193. package/src/log/old_version.js +0 -41
  194. package/src/log/serialize.js +0 -13
  195. package/src/log/stream.js +0 -85
  196. package/src/log/theme.js +0 -26
  197. package/src/plugins/child/diff.js +0 -55
  198. package/src/plugins/child/error.js +0 -32
  199. package/src/plugins/child/lazy.js +0 -18
  200. package/src/plugins/child/load.js +0 -29
  201. package/src/plugins/child/logic.js +0 -57
  202. package/src/plugins/child/main.js +0 -51
  203. package/src/plugins/child/run.js +0 -28
  204. package/src/plugins/child/status.js +0 -67
  205. package/src/plugins/child/typescript.js +0 -45
  206. package/src/plugins/child/utils.js +0 -56
  207. package/src/plugins/child/validate.js +0 -34
  208. package/src/plugins/compatibility.js +0 -128
  209. package/src/plugins/expected_version.js +0 -119
  210. package/src/plugins/ipc.js +0 -145
  211. package/src/plugins/list.js +0 -86
  212. package/src/plugins/load.js +0 -70
  213. package/src/plugins/manifest/check.js +0 -106
  214. package/src/plugins/manifest/load.js +0 -41
  215. package/src/plugins/manifest/main.js +0 -22
  216. package/src/plugins/manifest/path.js +0 -31
  217. package/src/plugins/manifest/validate.js +0 -108
  218. package/src/plugins/node_version.js +0 -50
  219. package/src/plugins/options.js +0 -88
  220. package/src/plugins/pinned_version.js +0 -131
  221. package/src/plugins/resolve.js +0 -152
  222. package/src/plugins/spawn.js +0 -66
  223. package/src/plugins_core/add.js +0 -49
  224. package/src/plugins_core/build_command.js +0 -75
  225. package/src/plugins_core/deploy/buildbot_client.js +0 -102
  226. package/src/plugins_core/deploy/index.js +0 -73
  227. package/src/plugins_core/edge_functions/index.js +0 -107
  228. package/src/plugins_core/edge_functions/lib/internal_manifest.js +0 -54
  229. package/src/plugins_core/functions/error.js +0 -163
  230. package/src/plugins_core/functions/feature_flags.js +0 -6
  231. package/src/plugins_core/functions/index.js +0 -160
  232. package/src/plugins_core/functions/utils.js +0 -66
  233. package/src/plugins_core/functions/zisi.js +0 -53
  234. package/src/plugins_core/list.js +0 -27
  235. package/src/status/add.js +0 -36
  236. package/src/status/colors.js +0 -23
  237. package/src/status/load_error.js +0 -11
  238. package/src/status/report.js +0 -128
  239. package/src/status/success.js +0 -18
  240. package/src/steps/core_step.js +0 -90
  241. package/src/steps/error.js +0 -102
  242. package/src/steps/get.js +0 -32
  243. package/src/steps/plugin.js +0 -85
  244. package/src/steps/return.js +0 -52
  245. package/src/steps/run_core_steps.js +0 -194
  246. package/src/steps/run_step.js +0 -300
  247. package/src/steps/run_steps.js +0 -179
  248. package/src/steps/update_config.js +0 -93
  249. package/src/telemetry/main.js +0 -136
  250. package/src/time/aggregate.js +0 -146
  251. package/src/time/main.js +0 -48
  252. package/src/time/measure.js +0 -22
  253. package/src/time/report.js +0 -59
  254. package/src/utils/errors.js +0 -12
  255. package/src/utils/json.js +0 -19
  256. package/src/utils/package.js +0 -23
  257. package/src/utils/remove_falsy.js +0 -10
  258. package/src/utils/resolve.js +0 -46
  259. package/src/utils/semver.js +0 -34
@@ -1,164 +0,0 @@
1
- import semver from 'semver'
2
-
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'
7
-
8
- export const logLoadingPlugins = function (logs, pluginsOptions, debug) {
9
- const loadingPlugins = pluginsOptions
10
- .filter(isNotCorePlugin)
11
- .map((pluginOptions) => getPluginDescription(pluginOptions, debug))
12
-
13
- if (loadingPlugins.length === 0) {
14
- return
15
- }
16
-
17
- logSubHeader(logs, 'Loading plugins')
18
- logArray(logs, loadingPlugins)
19
- }
20
-
21
- // We only logs plugins explicitly enabled by users
22
- const isNotCorePlugin = function ({ origin }) {
23
- return origin !== 'core'
24
- }
25
-
26
- const getPluginDescription = function (
27
- {
28
- packageName,
29
- pluginPackageJson: { version },
30
- loadedFrom,
31
- origin,
32
- pinnedVersion,
33
- latestVersion,
34
- expectedVersion,
35
- compatibleVersion,
36
- },
37
- debug,
38
- ) {
39
- const versionedPackage = getVersionedPackage(packageName, version)
40
- const pluginOrigin = getPluginOrigin(loadedFrom, origin)
41
- const description = `${THEME.highlightWords(packageName)}${versionedPackage} ${pluginOrigin}`
42
- if (!debug) {
43
- return description
44
- }
45
-
46
- const versions = Object.entries({
47
- pinned: pinnedVersion,
48
- latest: latestVersion,
49
- expected: expectedVersion,
50
- compatible: compatibleVersion,
51
- })
52
- .filter(hasVersion)
53
- .map(getVersionField)
54
-
55
- if (versions.length === 0) {
56
- return description
57
- }
58
-
59
- return `${description} (${versions.join(', ')})`
60
- }
61
-
62
- const hasVersion = function ([, version]) {
63
- return version !== undefined
64
- }
65
-
66
- const getVersionField = function ([versionFieldName, version]) {
67
- return `${versionFieldName} ${version}`
68
- }
69
-
70
- // Print a warning message when old versions plugins are used.
71
- // This can only happen when they are installed to `package.json`.
72
- export const logOutdatedPlugins = function (logs, pluginsOptions) {
73
- const outdatedPlugins = pluginsOptions.filter(hasOutdatedVersion).map(getOutdatedPlugin)
74
-
75
- if (outdatedPlugins.length === 0) {
76
- return
77
- }
78
-
79
- logWarningSubHeader(logs, 'Outdated plugins')
80
- logWarningArray(logs, outdatedPlugins)
81
- }
82
-
83
- const hasOutdatedVersion = function ({ pluginPackageJson: { version }, latestVersion }) {
84
- return version !== undefined && latestVersion !== undefined && semver.lt(version, latestVersion)
85
- }
86
-
87
- const getOutdatedPlugin = function ({
88
- packageName,
89
- pluginPackageJson: { version },
90
- latestVersion,
91
- migrationGuide,
92
- loadedFrom,
93
- origin,
94
- }) {
95
- const versionedPackage = getVersionedPackage(packageName, version)
96
- const outdatedDescription = getOutdatedDescription({ latestVersion, migrationGuide, loadedFrom, origin })
97
- return `${THEME.warningHighlightWords(packageName)}${versionedPackage}: ${outdatedDescription}`
98
- }
99
-
100
- const getOutdatedDescription = function ({ latestVersion, migrationGuide, loadedFrom, origin }) {
101
- const upgradeInstruction = getUpgradeInstruction(loadedFrom, origin)
102
- if (migrationGuide === undefined) {
103
- return `latest version is ${latestVersion}\n${upgradeInstruction}`
104
- }
105
-
106
- return `latest version is ${latestVersion}\nMigration guide: ${migrationGuide}\n${upgradeInstruction}`
107
- }
108
-
109
- const getUpgradeInstruction = function (loadedFrom, origin) {
110
- if (loadedFrom === 'package.json') {
111
- return 'To upgrade this plugin, please update its version in "package.json"'
112
- }
113
-
114
- if (origin === 'ui') {
115
- return 'To upgrade this plugin, please uninstall and re-install it from the Netlify plugins directory (https://app.netlify.com/plugins)'
116
- }
117
-
118
- 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)'
119
- }
120
-
121
- // Print a warning message when plugins are using a version that is too recent
122
- // and does not meet some `compatibility` expectations.
123
- // This can only happen when they are installed to `package.json`.
124
- export const logIncompatiblePlugins = function (logs, pluginsOptions) {
125
- const incompatiblePlugins = pluginsOptions.filter(hasIncompatibleVersion).map(getIncompatiblePlugin)
126
-
127
- if (incompatiblePlugins.length === 0) {
128
- return
129
- }
130
-
131
- logWarningSubHeader(logs, 'Incompatible plugins')
132
- logWarningArray(logs, incompatiblePlugins)
133
- }
134
-
135
- const hasIncompatibleVersion = function ({ pluginPackageJson: { version }, compatibleVersion, compatWarning }) {
136
- return (
137
- compatWarning !== '' &&
138
- version !== undefined &&
139
- compatibleVersion !== undefined &&
140
- // Using only the major version prevents printing this warning message when
141
- // a site is using the right `compatibility` version, but is using the most
142
- // recent version due to the time gap between `npm publish` and the
143
- // `plugins.json` update
144
- isPreviousMajor(compatibleVersion, version)
145
- )
146
- }
147
-
148
- const getIncompatiblePlugin = function ({
149
- packageName,
150
- pluginPackageJson: { version },
151
- compatibleVersion,
152
- compatWarning,
153
- }) {
154
- const versionedPackage = getVersionedPackage(packageName, version)
155
- return `${THEME.warningHighlightWords(
156
- packageName,
157
- )}${versionedPackage}: version ${compatibleVersion} is the most recent version compatible with ${compatWarning}`
158
- }
159
-
160
- // Make sure we handle `package.json` with `version` being either `undefined`
161
- // or an empty string
162
- const getVersionedPackage = function (packageName, version = '') {
163
- return version === '' ? '' : `@${version}`
164
- }
@@ -1,105 +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
- ]
56
- const HIDDEN_FLAGS = [...SECURE_FLAGS, ...TEST_FLAGS, ...INTERNAL_FLAGS]
57
- const HIDDEN_DEBUG_FLAGS = [...SECURE_FLAGS, ...TEST_FLAGS]
58
-
59
- export const logBuildDir = function (logs, buildDir) {
60
- logSubHeader(logs, 'Current directory')
61
- logMessage(logs, buildDir)
62
- }
63
-
64
- export const logConfigPath = function (logs, configPath = NO_CONFIG_MESSAGE) {
65
- logSubHeader(logs, 'Config file')
66
- logMessage(logs, configPath)
67
- }
68
-
69
- const NO_CONFIG_MESSAGE = 'No config file was defined: using default values.'
70
-
71
- export const logConfig = function ({ logs, netlifyConfig, debug }) {
72
- if (!debug) {
73
- return
74
- }
75
-
76
- logSubHeader(logs, 'Resolved config')
77
- logObject(logs, cleanupConfig(netlifyConfig))
78
- }
79
-
80
- export const logConfigOnUpdate = function ({ logs, netlifyConfig, debug }) {
81
- if (!debug) {
82
- return
83
- }
84
-
85
- logSubHeader(logs, 'Updated config')
86
- logObject(logs, cleanupConfig(netlifyConfig))
87
- }
88
-
89
- export const logConfigOnError = function ({ logs, netlifyConfig, severity }) {
90
- if (netlifyConfig === undefined || severity === 'none') {
91
- return
92
- }
93
-
94
- logMessage(logs, THEME.errorSubHeader('Resolved config'))
95
- logObject(logs, cleanupConfig(netlifyConfig))
96
- }
97
-
98
- export const logContext = function (logs, context) {
99
- if (context === undefined) {
100
- return
101
- }
102
-
103
- logSubHeader(logs, 'Context')
104
- logMessage(logs, context)
105
- }
@@ -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
- }
@@ -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
- }
@@ -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,20 +0,0 @@
1
- import { log, logArray, logSubHeader } from '../logger.js'
2
-
3
- export const logInstallMissingPlugins = function (logs, packages) {
4
- logSubHeader(logs, 'Installing plugins')
5
- logArray(logs, packages)
6
- }
7
-
8
- export const logInstallLocalPluginsDeps = function (logs, localPluginsOptions) {
9
- const packages = localPluginsOptions.map(getPackageName)
10
- logSubHeader(logs, 'Installing local plugins dependencies')
11
- logArray(logs, packages)
12
- }
13
-
14
- export const logInstallFunctionDependencies = function () {
15
- log(undefined, 'Installing functions dependencies')
16
- }
17
-
18
- const getPackageName = function ({ packageName }) {
19
- return packageName
20
- }
@@ -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,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
- }