@netlify/build 27.20.4 → 27.20.6

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 (133) hide show
  1. package/lib/core/bin.js +42 -59
  2. package/lib/core/build.js +333 -536
  3. package/lib/core/config.js +94 -159
  4. package/lib/core/constants.js +95 -135
  5. package/lib/core/dev.js +26 -30
  6. package/lib/core/dry.js +18 -36
  7. package/lib/core/feature_flags.js +13 -16
  8. package/lib/core/flags.js +168 -169
  9. package/lib/core/lingering.js +44 -61
  10. package/lib/core/main.js +94 -136
  11. package/lib/core/missing_side_file.js +12 -24
  12. package/lib/core/normalize_flags.js +52 -63
  13. package/lib/core/severity.js +13 -15
  14. package/lib/core/user_node_version.js +26 -35
  15. package/lib/env/changes.js +29 -37
  16. package/lib/env/main.js +10 -15
  17. package/lib/env/metadata.js +63 -76
  18. package/lib/error/api.js +31 -40
  19. package/lib/error/build.js +27 -38
  20. package/lib/error/cancel.js +5 -6
  21. package/lib/error/colors.js +7 -9
  22. package/lib/error/handle.js +38 -49
  23. package/lib/error/info.js +26 -35
  24. package/lib/error/monitor/location.js +12 -17
  25. package/lib/error/monitor/normalize.js +75 -85
  26. package/lib/error/monitor/print.js +19 -41
  27. package/lib/error/monitor/report.js +102 -121
  28. package/lib/error/monitor/start.js +43 -56
  29. package/lib/error/parse/clean_stack.js +52 -69
  30. package/lib/error/parse/location.js +40 -52
  31. package/lib/error/parse/normalize.js +18 -23
  32. package/lib/error/parse/parse.js +59 -93
  33. package/lib/error/parse/plugin.js +42 -57
  34. package/lib/error/parse/properties.js +13 -20
  35. package/lib/error/parse/serialize_log.js +29 -37
  36. package/lib/error/parse/serialize_status.js +15 -23
  37. package/lib/error/parse/stack.js +29 -38
  38. package/lib/error/type.js +132 -150
  39. package/lib/install/functions.js +16 -24
  40. package/lib/install/local.js +31 -48
  41. package/lib/install/main.js +52 -66
  42. package/lib/install/missing.js +40 -53
  43. package/lib/log/colors.js +15 -22
  44. package/lib/log/description.js +16 -21
  45. package/lib/log/header.js +11 -13
  46. package/lib/log/header_func.js +11 -15
  47. package/lib/log/logger.js +88 -119
  48. package/lib/log/messages/compatibility.js +100 -158
  49. package/lib/log/messages/config.js +76 -92
  50. package/lib/log/messages/core.js +40 -60
  51. package/lib/log/messages/core_steps.js +63 -92
  52. package/lib/log/messages/dry.js +31 -53
  53. package/lib/log/messages/install.js +21 -28
  54. package/lib/log/messages/ipc.js +21 -30
  55. package/lib/log/messages/mutations.js +51 -71
  56. package/lib/log/messages/plugins.js +18 -31
  57. package/lib/log/messages/status.js +12 -14
  58. package/lib/log/messages/steps.js +14 -18
  59. package/lib/log/old_version.js +23 -32
  60. package/lib/log/serialize.js +7 -10
  61. package/lib/log/stream.js +48 -65
  62. package/lib/log/theme.js +22 -23
  63. package/lib/plugins/child/diff.js +31 -40
  64. package/lib/plugins/child/error.js +20 -26
  65. package/lib/plugins/child/lazy.js +11 -14
  66. package/lib/plugins/child/load.js +15 -22
  67. package/lib/plugins/child/logic.js +51 -58
  68. package/lib/plugins/child/main.js +32 -46
  69. package/lib/plugins/child/run.js +18 -27
  70. package/lib/plugins/child/status.js +52 -63
  71. package/lib/plugins/child/typescript.js +19 -36
  72. package/lib/plugins/child/utils.js +36 -49
  73. package/lib/plugins/child/validate.js +25 -28
  74. package/lib/plugins/compatibility.js +64 -92
  75. package/lib/plugins/error.js +29 -35
  76. package/lib/plugins/events.js +7 -12
  77. package/lib/plugins/expected_version.js +61 -99
  78. package/lib/plugins/ipc.js +79 -102
  79. package/lib/plugins/list.js +49 -62
  80. package/lib/plugins/load.js +44 -64
  81. package/lib/plugins/manifest/check.js +64 -85
  82. package/lib/plugins/manifest/load.js +34 -37
  83. package/lib/plugins/manifest/main.js +16 -21
  84. package/lib/plugins/manifest/path.js +18 -25
  85. package/lib/plugins/manifest/validate.js +77 -94
  86. package/lib/plugins/node_version.js +22 -42
  87. package/lib/plugins/options.js +45 -78
  88. package/lib/plugins/pinned_version.js +58 -106
  89. package/lib/plugins/resolve.js +91 -133
  90. package/lib/plugins/spawn.js +43 -61
  91. package/lib/plugins_core/add.js +26 -40
  92. package/lib/plugins_core/build_command.js +47 -72
  93. package/lib/plugins_core/deploy/buildbot_client.js +61 -87
  94. package/lib/plugins_core/deploy/index.js +47 -71
  95. package/lib/plugins_core/edge_functions/index.js +73 -116
  96. package/lib/plugins_core/edge_functions/lib/error.js +13 -17
  97. package/lib/plugins_core/edge_functions/lib/internal_manifest.js +45 -55
  98. package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +65 -80
  99. package/lib/plugins_core/functions/error.js +88 -128
  100. package/lib/plugins_core/functions/feature_flags.js +5 -5
  101. package/lib/plugins_core/functions/index.js +98 -145
  102. package/lib/plugins_core/functions/utils.js +36 -57
  103. package/lib/plugins_core/functions/zisi.js +35 -52
  104. package/lib/plugins_core/functions_install/index.js +8 -11
  105. package/lib/plugins_core/list.js +15 -22
  106. package/lib/status/add.js +26 -32
  107. package/lib/status/colors.js +14 -19
  108. package/lib/status/load_error.js +8 -9
  109. package/lib/status/report.js +72 -126
  110. package/lib/status/success.js +10 -14
  111. package/lib/steps/core_step.js +54 -89
  112. package/lib/steps/error.js +50 -87
  113. package/lib/steps/get.js +33 -41
  114. package/lib/steps/plugin.js +53 -83
  115. package/lib/steps/return.js +24 -51
  116. package/lib/steps/run_core_steps.js +119 -171
  117. package/lib/steps/run_step.js +154 -270
  118. package/lib/steps/run_steps.js +91 -174
  119. package/lib/steps/update_config.js +45 -72
  120. package/lib/telemetry/main.js +89 -128
  121. package/lib/time/aggregate.js +84 -110
  122. package/lib/time/main.js +23 -34
  123. package/lib/time/measure.js +11 -15
  124. package/lib/time/report.js +32 -44
  125. package/lib/utils/errors.js +10 -9
  126. package/lib/utils/json.js +11 -15
  127. package/lib/utils/omit.js +3 -4
  128. package/lib/utils/package.js +19 -22
  129. package/lib/utils/remove_falsy.js +5 -7
  130. package/lib/utils/resolve.js +30 -34
  131. package/lib/utils/runtime.js +4 -4
  132. package/lib/utils/semver.js +19 -25
  133. package/package.json +14 -7
@@ -1,97 +1,69 @@
1
- import path from 'path'
2
-
3
- import { log, logArray, logErrorSubHeader, logWarningSubHeader } from '../logger.js'
4
- import { THEME } from '../theme.js'
5
-
1
+ import path from 'path';
2
+ import { log, logArray, logErrorSubHeader, logWarningSubHeader } from '../logger.js';
3
+ import { THEME } from '../theme.js';
6
4
  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
-
5
+ const functionNames = functions.map(({ path: functionPath }) => path.basename(functionPath));
6
+ if (error) {
7
+ logErrorSubHeader(logs, headerMessage);
8
+ }
9
+ else {
10
+ logWarningSubHeader(logs, headerMessage);
11
+ }
12
+ logArray(logs, functionNames);
13
+ };
18
14
  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
-
15
+ const resultsWithErrors = results.filter(({ bundlerErrors }) => bundlerErrors && bundlerErrors.length !== 0);
16
+ const resultsWithWarnings = results.filter(({ bundler, bundlerWarnings }) => bundler === 'esbuild' && bundlerWarnings && bundlerWarnings.length !== 0);
17
+ const modulesWithDynamicImports = [
18
+ ...new Set(results.flatMap((result) => result.nodeModulesWithDynamicImports || [])),
19
+ ];
20
+ if (resultsWithErrors.length !== 0) {
21
+ logBundleResultFunctions({
22
+ functions: resultsWithErrors,
23
+ headerMessage: 'Failed to bundle functions with selected bundler (fallback used):',
24
+ logs,
25
+ error: true,
26
+ });
27
+ }
28
+ if (resultsWithWarnings.length !== 0) {
29
+ logBundleResultFunctions({
30
+ functions: resultsWithWarnings,
31
+ headerMessage: 'Functions bundled with warnings:',
32
+ logs,
33
+ error: false,
34
+ });
35
+ }
36
+ if (modulesWithDynamicImports.length !== 0) {
37
+ logModulesWithDynamicImports({ logs, modulesWithDynamicImports });
38
+ }
39
+ };
50
40
  export const logFunctionsNonExistingDir = function (logs, relativeFunctionsSrc) {
51
- log(logs, `The Netlify Functions setting targets a non-existing directory: ${relativeFunctionsSrc}`)
52
- }
53
-
41
+ log(logs, `The Netlify Functions setting targets a non-existing directory: ${relativeFunctionsSrc}`);
42
+ };
54
43
  // 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
-
44
+ export const logFunctionsToBundle = function ({ logs, userFunctions, userFunctionsSrc, userFunctionsSrcExists, internalFunctions, internalFunctionsSrc, type = 'Functions', }) {
45
+ if (internalFunctions.length !== 0) {
46
+ log(logs, `Packaging ${type} from ${THEME.highlightWords(internalFunctionsSrc)} directory:`);
47
+ logArray(logs, internalFunctions, { indent: false });
48
+ }
49
+ if (!userFunctionsSrcExists) {
50
+ return;
51
+ }
52
+ if (userFunctions.length === 0) {
53
+ log(logs, `No ${type} were found in ${THEME.highlightWords(userFunctionsSrc)} directory`);
54
+ return;
55
+ }
56
+ if (internalFunctions.length !== 0) {
57
+ log(logs, '');
58
+ }
59
+ log(logs, `Packaging ${type} from ${THEME.highlightWords(userFunctionsSrc)} directory:`);
60
+ logArray(logs, userFunctions, { indent: false });
61
+ };
87
62
  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,
63
+ const externalNodeModules = modulesWithDynamicImports.map((moduleName) => `"${moduleName}"`).join(', ');
64
+ logWarningSubHeader(logs, `The following Node.js modules use dynamic expressions to include files:`);
65
+ logArray(logs, modulesWithDynamicImports);
66
+ log(logs, `\n Because files included with dynamic expressions aren't bundled with your serverless functions by default,
95
67
  this may result in an error when invoking a function. To resolve this error, you can mark these Node.js
96
68
  modules as external in the [functions] section of your \`netlify.toml\` configuration file:
97
69
 
@@ -99,6 +71,5 @@ const logModulesWithDynamicImports = ({ logs, modulesWithDynamicImports }) => {
99
71
  external_node_modules = [${externalNodeModules}]
100
72
 
101
73
  Visit https://ntl.fyi/dynamic-imports for more information.
102
- `,
103
- )
104
- }
74
+ `);
75
+ };
@@ -1,63 +1,41 @@
1
- import figures from 'figures'
2
-
3
- import { logMessage, logSubHeader } from '../logger.js'
4
- import { THEME } from '../theme.js'
5
-
1
+ import figures from 'figures';
2
+ import { logMessage, logSubHeader } from '../logger.js';
3
+ import { THEME } from '../theme.js';
6
4
  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
5
+ const columnWidth = getDryColumnWidth(eventWidth, stepsCount);
6
+ const line = '─'.repeat(columnWidth);
7
+ const secondLine = '─'.repeat(columnWidth);
8
+ logSubHeader(logs, 'Netlify Build Commands');
9
+ logMessage(logs, `For more information on build events see the docs https://github.com/netlify/build
15
10
 
16
11
  Running \`netlify build\` will execute this build flow
17
12
 
18
13
  ${THEME.header(`┌─${line}─┬─${secondLine}─┐
19
14
  │ ${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}─┐`)}
15
+ └─${line}─┴─${secondLine}─┘`)}`);
16
+ };
17
+ export const logDryRunStep = function ({ logs, step: { event, packageName, coreStepDescription }, index, netlifyConfig, eventWidth, stepsCount, }) {
18
+ const columnWidth = getDryColumnWidth(eventWidth, stepsCount);
19
+ const fullName = getFullName(coreStepDescription, netlifyConfig, packageName);
20
+ const line = '─'.repeat(columnWidth);
21
+ const countText = `${index + 1}. `;
22
+ const downArrow = stepsCount === index + 1 ? ' ' : ` ${figures.arrowDown}`;
23
+ const eventWidthA = columnWidth - countText.length - downArrow.length;
24
+ logMessage(logs, `${THEME.header(`┌─${line}─┐`)}
42
25
  ${THEME.header(`│ ${countText}${event.padEnd(eventWidthA)}${downArrow} │`)} ${fullName}
43
- ${THEME.header(`└─${line}─┘ `)}`,
44
- )
45
- }
46
-
26
+ ${THEME.header(`└─${line}─┘ `)}`);
27
+ };
47
28
  const getFullName = function (coreStepDescription, netlifyConfig, packageName) {
48
- return coreStepDescription === undefined
49
- ? `Plugin ${THEME.highlightWords(packageName)}`
50
- : coreStepDescription({ netlifyConfig })
51
- }
52
-
29
+ return coreStepDescription === undefined
30
+ ? `Plugin ${THEME.highlightWords(packageName)}`
31
+ : coreStepDescription({ netlifyConfig });
32
+ };
53
33
  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
-
34
+ const symbolsWidth = `${stepsCount}`.length + COLUMN_EXTRA_WIDTH;
35
+ return Math.max(eventWidth + symbolsWidth, DRY_HEADER_NAMES[1].length);
36
+ };
37
+ const COLUMN_EXTRA_WIDTH = 4;
38
+ const DRY_HEADER_NAMES = ['Event', 'Location'];
61
39
  export const logDryRunEnd = function (logs) {
62
- logMessage(logs, `\nIf this looks good to you, run \`netlify build\` to execute the build\n`)
63
- }
40
+ logMessage(logs, `\nIf this looks good to you, run \`netlify build\` to execute the build\n`);
41
+ };
@@ -1,32 +1,25 @@
1
- import { isRuntime } from '../../utils/runtime.js'
2
- import { log, logArray, logSubHeader } from '../logger.js'
3
-
1
+ import { isRuntime } from '../../utils/runtime.js';
2
+ import { log, logArray, logSubHeader } from '../logger.js';
4
3
  export const logInstallMissingPlugins = function (logs, packages) {
5
- const runtimes = packages.filter((pkg) => isRuntime(pkg))
6
- const plugins = packages.filter((pkg) => !isRuntime(pkg))
7
-
8
- if (plugins.length !== 0) {
9
- logSubHeader(logs, 'Installing plugins')
10
- logArray(logs, packages)
11
- }
12
-
13
- if (runtimes.length !== 0) {
14
- const [nextRuntime] = runtimes
15
-
16
- logSubHeader(logs, `Using Next.js Runtime - v${nextRuntime.pluginPackageJson.version}`)
17
- }
18
- }
19
-
4
+ const runtimes = packages.filter((pkg) => isRuntime(pkg));
5
+ const plugins = packages.filter((pkg) => !isRuntime(pkg));
6
+ if (plugins.length !== 0) {
7
+ logSubHeader(logs, 'Installing plugins');
8
+ logArray(logs, packages);
9
+ }
10
+ if (runtimes.length !== 0) {
11
+ const [nextRuntime] = runtimes;
12
+ logSubHeader(logs, `Using Next.js Runtime - v${nextRuntime.pluginPackageJson.version}`);
13
+ }
14
+ };
20
15
  export const logInstallLocalPluginsDeps = function (logs, localPluginsOptions) {
21
- const packages = localPluginsOptions.map(getPackageName)
22
- logSubHeader(logs, 'Installing local plugins dependencies')
23
- logArray(logs, packages)
24
- }
25
-
16
+ const packages = localPluginsOptions.map(getPackageName);
17
+ logSubHeader(logs, 'Installing local plugins dependencies');
18
+ logArray(logs, packages);
19
+ };
26
20
  export const logInstallFunctionDependencies = function () {
27
- log(undefined, 'Installing functions dependencies')
28
- }
29
-
21
+ log(undefined, 'Installing functions dependencies');
22
+ };
30
23
  const getPackageName = function ({ packageName }) {
31
- return packageName
32
- }
24
+ return packageName;
25
+ };
@@ -1,38 +1,29 @@
1
- import { log } from '../logger.js'
2
-
1
+ import { log } from '../logger.js';
3
2
  const logVerbose = function (logs, verbose, message) {
4
- if (!verbose) {
5
- return
6
- }
7
-
8
- log(logs, message)
9
- }
10
-
3
+ if (!verbose) {
4
+ return;
5
+ }
6
+ log(logs, message);
7
+ };
11
8
  export const logSendingEventToChild = function (logs, verbose) {
12
- logVerbose(logs, verbose, 'Step starting.')
13
- }
14
-
9
+ logVerbose(logs, verbose, 'Step starting.');
10
+ };
15
11
  export const logSentEventToChild = function (logs, verbose) {
16
- logVerbose(logs, verbose, 'Step started.')
17
- }
18
-
12
+ logVerbose(logs, verbose, 'Step started.');
13
+ };
19
14
  export const logPluginMethodStart = function (verbose) {
20
- logVerbose(undefined, verbose, 'Plugin logic started.')
21
- }
22
-
15
+ logVerbose(undefined, verbose, 'Plugin logic started.');
16
+ };
23
17
  export const logPluginMethodEnd = function (verbose) {
24
- logVerbose(undefined, verbose, 'Plugin logic ended.')
25
- }
26
-
18
+ logVerbose(undefined, verbose, 'Plugin logic ended.');
19
+ };
27
20
  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
-
21
+ const message = error instanceof Error ? `Step erroring.\n${error.stack}` : 'Stop closing.';
22
+ logVerbose(undefined, verbose, message);
23
+ };
32
24
  export const logReceivedEventFromChild = function (logs, verbose) {
33
- logVerbose(logs, verbose, 'Step ended.')
34
- }
35
-
25
+ logVerbose(logs, verbose, 'Step ended.');
26
+ };
36
27
  export const logStepCompleted = function (logs, verbose) {
37
- logVerbose(logs, verbose, 'Step completed.')
38
- }
28
+ logVerbose(logs, verbose, 'Step completed.');
29
+ };
@@ -1,82 +1,62 @@
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
-
1
+ import { promises as fs } from 'fs';
2
+ import { inspect } from 'util';
3
+ import { pathExists } from 'path-exists';
4
+ import { log, logMessage, logSubHeader } from '../logger.js';
8
5
  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
-
6
+ const configMutationsToLog = debug ? newConfigMutations : newConfigMutations.filter(shouldLogConfigMutation);
7
+ configMutationsToLog.forEach(({ keysString, value }) => {
8
+ logConfigMutation(logs, keysString, value);
9
+ });
10
+ };
15
11
  // Some configuration mutations are only logged in debug mode
16
12
  const shouldLogConfigMutation = function ({ keysString }) {
17
- return !HIDDEN_PROPS.some((hiddenProp) => keysString.startsWith(hiddenProp))
18
- }
19
-
13
+ return !HIDDEN_PROPS.some((hiddenProp) => keysString.startsWith(hiddenProp));
14
+ };
20
15
  // `functions` is an object which can have thousands of properties, one per
21
16
  // function file. This can be very verbose, especially for plugins which create
22
17
  // many function files like Essential Next.js
23
- const HIDDEN_PROPS = ['functions']
24
-
18
+ const HIDDEN_PROPS = ['functions'];
25
19
  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
-
20
+ const newValue = shouldHideConfigValue(keysString) ? '' : ` to ${inspect(value, { colors: false })}`;
21
+ log(logs, `Netlify configuration property "${keysString}" value changed${newValue}.`);
22
+ };
30
23
  const shouldHideConfigValue = function (keysString) {
31
- return SECRET_PROPS.some((secretProp) => keysString.startsWith(secretProp))
32
- }
33
-
34
- const SECRET_PROPS = ['build.environment']
35
-
24
+ return SECRET_PROPS.some((secretProp) => keysString.startsWith(secretProp));
25
+ };
26
+ const SECRET_PROPS = ['build.environment'];
36
27
  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
-
28
+ if (!debug) {
29
+ return;
30
+ }
31
+ logSubHeader(logs, 'Uploaded config');
32
+ if (!(await pathExists(configPath))) {
33
+ logMessage(logs, 'No netlify.toml');
34
+ return;
35
+ }
36
+ const configContents = await fs.readFile(configPath, 'utf8');
37
+ logMessage(logs, configContents.trim());
38
+ };
52
39
  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
-
40
+ if (!debug) {
41
+ return;
42
+ }
43
+ logSubHeader(logs, 'Uploaded headers');
44
+ if (!(await pathExists(headersPath))) {
45
+ logMessage(logs, 'No headers');
46
+ return;
47
+ }
48
+ const headersContents = await fs.readFile(headersPath, 'utf8');
49
+ logMessage(logs, headersContents.trim());
50
+ };
68
51
  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
- }
52
+ if (!debug) {
53
+ return;
54
+ }
55
+ logSubHeader(logs, 'Uploaded redirects');
56
+ if (!(await pathExists(redirectsPath))) {
57
+ logMessage(logs, 'No redirects\n');
58
+ return;
59
+ }
60
+ const redirectsContents = await fs.readFile(redirectsPath, 'utf8');
61
+ logMessage(logs, `${redirectsContents.trim()}\n`);
62
+ };
@@ -1,38 +1,25 @@
1
- import { log, logArray, logWarning, logSubHeader } from '../logger.js'
2
-
1
+ import { log, logArray, logWarning, logSubHeader } from '../logger.js';
3
2
  export const logPluginsFetchError = function (logs, message) {
4
- logWarning(
5
- logs,
6
- `
3
+ logWarning(logs, `
7
4
  Warning: could not fetch latest plugins list. Plugins versions might not be the latest.
8
- ${message}`,
9
- )
10
- }
11
-
5
+ ${message}`);
6
+ };
12
7
  export const logPluginsList = function ({ pluginsList, debug, logs }) {
13
- if (!debug) {
14
- return
15
- }
16
-
17
- const pluginsListArray = Object.entries(pluginsList).map(getPluginsListItem).sort()
18
-
19
- logSubHeader(logs, 'Available plugins')
20
- logArray(logs, pluginsListArray)
21
- }
22
-
8
+ if (!debug) {
9
+ return;
10
+ }
11
+ const pluginsListArray = Object.entries(pluginsList).map(getPluginsListItem).sort();
12
+ logSubHeader(logs, 'Available plugins');
13
+ logArray(logs, pluginsListArray);
14
+ };
23
15
  const getPluginsListItem = function ([packageName, versions]) {
24
- return `${packageName}@${versions[0].version}`
25
- }
26
-
16
+ return `${packageName}@${versions[0].version}`;
17
+ };
27
18
  export const logFailPluginWarning = function (methodName, event) {
28
- logWarning(
29
- undefined,
30
- `Plugin error: since "${event}" happens after deploy, the build has already succeeded and cannot fail anymore. This plugin should either:
19
+ logWarning(undefined, `Plugin error: since "${event}" happens after deploy, the build has already succeeded and cannot fail anymore. This plugin should either:
31
20
  - use utils.build.failPlugin() instead of utils.build.${methodName}() to clarify that the plugin failed, but not the build.
32
- - use "onPostBuild" instead of "${event}" if the plugin failure should make the build fail too. Please note that "onPostBuild" (unlike "${event}") happens before deploy.`,
33
- )
34
- }
35
-
21
+ - use "onPostBuild" instead of "${event}" if the plugin failure should make the build fail too. Please note that "onPostBuild" (unlike "${event}") happens before deploy.`);
22
+ };
36
23
  export const logDeploySuccess = function (logs) {
37
- log(logs, 'Site deploy was successfully initiated')
38
- }
24
+ log(logs, 'Site deploy was successfully initiated');
25
+ };
@@ -1,16 +1,14 @@
1
- import { logMessage, logHeader, logSubHeader } from '../logger.js'
2
- import { THEME } from '../theme.js'
3
-
1
+ import { logMessage, logHeader, logSubHeader } from '../logger.js';
2
+ import { THEME } from '../theme.js';
4
3
  export const logStatuses = function (logs, statuses) {
5
- logHeader(logs, 'Summary')
6
- statuses.forEach((status) => {
7
- logStatus(logs, status)
8
- })
9
- }
10
-
4
+ logHeader(logs, 'Summary');
5
+ statuses.forEach((status) => {
6
+ logStatus(logs, status);
7
+ });
8
+ };
11
9
  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
- }
10
+ const titleA = title.includes(packageName) ? title : `${packageName}: ${title}`;
11
+ const body = text === undefined ? summary : `${summary}\n${THEME.dimWords(text)}`;
12
+ logSubHeader(logs, titleA);
13
+ logMessage(logs, body);
14
+ };
@@ -1,22 +1,18 @@
1
- import { getLogHeaderFunc } from '../header_func.js'
2
- import { log, logMessage } from '../logger.js'
3
- import { THEME } from '../theme.js'
4
-
1
+ import { getLogHeaderFunc } from '../header_func.js';
2
+ import { log, logMessage } from '../logger.js';
3
+ import { THEME } from '../theme.js';
5
4
  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
-
5
+ const description = getDescription({ coreStepDescription, netlifyConfig, packageName, event });
6
+ const logHeaderFunc = getLogHeaderFunc(error);
7
+ logHeaderFunc(logs, `${index + 1}. ${description}`);
8
+ logMessage(logs, '');
9
+ };
12
10
  const getDescription = function ({ coreStepDescription, netlifyConfig, packageName, event }) {
13
- return coreStepDescription === undefined ? `${packageName} (${event} event)` : coreStepDescription({ netlifyConfig })
14
- }
15
-
11
+ return coreStepDescription === undefined ? `${packageName} (${event} event)` : coreStepDescription({ netlifyConfig });
12
+ };
16
13
  export const logBuildCommandStart = function (logs, buildCommand) {
17
- log(logs, THEME.highlightWords(`$ ${buildCommand}`))
18
- }
19
-
14
+ log(logs, THEME.highlightWords(`$ ${buildCommand}`));
15
+ };
20
16
  export const logStepSuccess = function (logs) {
21
- logMessage(logs, '')
22
- }
17
+ logMessage(logs, '');
18
+ };