@netlify/build 25.0.2 → 26.0.2

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 (125) hide show
  1. package/package.json +5 -3
  2. package/src/core/bin.js +7 -8
  3. package/src/core/config.js +18 -35
  4. package/src/core/constants.js +8 -14
  5. package/src/core/dry.js +4 -8
  6. package/src/core/feature_flags.js +2 -6
  7. package/src/core/flags.js +2 -6
  8. package/src/core/lingering.js +7 -7
  9. package/src/core/main.js +25 -29
  10. package/src/core/missing_side_file.js +4 -8
  11. package/src/core/normalize_flags.js +5 -9
  12. package/src/core/severity.js +2 -6
  13. package/src/core/user_node_version.js +7 -11
  14. package/src/env/changes.js +5 -9
  15. package/src/env/main.js +4 -8
  16. package/src/env/metadata.js +3 -7
  17. package/src/error/api.js +4 -8
  18. package/src/error/build.js +4 -8
  19. package/src/error/cancel.js +1 -5
  20. package/src/error/colors.js +2 -6
  21. package/src/error/handle.js +10 -14
  22. package/src/error/info.js +6 -10
  23. package/src/error/monitor/location.js +1 -5
  24. package/src/error/monitor/normalize.js +2 -6
  25. package/src/error/monitor/print.js +2 -8
  26. package/src/error/monitor/report.js +11 -15
  27. package/src/error/monitor/start.js +9 -11
  28. package/src/error/parse/clean_stack.js +4 -8
  29. package/src/error/parse/location.js +2 -6
  30. package/src/error/parse/normalize.js +1 -5
  31. package/src/error/parse/parse.js +10 -14
  32. package/src/error/parse/plugin.js +2 -6
  33. package/src/error/parse/properties.js +3 -7
  34. package/src/error/parse/serialize_log.js +2 -6
  35. package/src/error/parse/serialize_status.js +1 -5
  36. package/src/error/parse/stack.js +2 -6
  37. package/src/error/type.js +1 -5
  38. package/src/install/functions.js +5 -9
  39. package/src/install/local.js +5 -9
  40. package/src/install/main.js +6 -10
  41. package/src/install/missing.js +9 -13
  42. package/src/log/colors.js +5 -11
  43. package/src/log/description.js +2 -6
  44. package/src/log/header.js +2 -6
  45. package/src/log/header_func.js +3 -7
  46. package/src/log/logger.js +20 -40
  47. package/src/log/messages/compatibility.js +9 -18
  48. package/src/log/messages/config.js +12 -27
  49. package/src/log/messages/core.js +20 -31
  50. package/src/log/messages/core_steps.js +7 -15
  51. package/src/log/messages/dry.js +7 -15
  52. package/src/log/messages/install.js +4 -12
  53. package/src/log/messages/ipc.js +8 -20
  54. package/src/log/messages/mutations.js +8 -17
  55. package/src/log/messages/plugins.js +5 -14
  56. package/src/log/messages/status.js +3 -9
  57. package/src/log/messages/steps.js +6 -14
  58. package/src/log/old_version.js +6 -10
  59. package/src/log/serialize.js +3 -7
  60. package/src/log/stream.js +6 -15
  61. package/src/log/theme.js +14 -29
  62. package/src/plugins/child/diff.js +5 -9
  63. package/src/plugins/child/error.js +7 -11
  64. package/src/plugins/child/lazy.js +2 -6
  65. package/src/plugins/child/load.js +6 -10
  66. package/src/plugins/child/logic.js +6 -7
  67. package/src/plugins/child/main.js +5 -7
  68. package/src/plugins/child/run.js +6 -10
  69. package/src/plugins/child/status.js +4 -8
  70. package/src/plugins/child/typescript.js +5 -9
  71. package/src/plugins/child/utils.js +21 -27
  72. package/src/plugins/child/validate.js +6 -11
  73. package/src/plugins/compatibility.js +13 -16
  74. package/src/plugins/error.js +6 -15
  75. package/src/plugins/events.js +5 -20
  76. package/src/plugins/expected_version.js +9 -13
  77. package/src/plugins/ipc.js +12 -21
  78. package/src/plugins/list.js +6 -15
  79. package/src/plugins/load.js +13 -9
  80. package/src/plugins/manifest/check.js +4 -8
  81. package/src/plugins/manifest/load.js +6 -10
  82. package/src/plugins/manifest/main.js +5 -9
  83. package/src/plugins/manifest/path.js +3 -7
  84. package/src/plugins/manifest/validate.js +3 -7
  85. package/src/plugins/node_version.js +9 -15
  86. package/src/plugins/options.js +12 -17
  87. package/src/plugins/pinned_version.js +4 -8
  88. package/src/plugins/resolve.js +7 -11
  89. package/src/plugins/spawn.js +10 -12
  90. package/src/plugins_core/add.js +2 -6
  91. package/src/plugins_core/build_command.js +7 -11
  92. package/src/plugins_core/deploy/buildbot_client.js +11 -20
  93. package/src/plugins_core/deploy/index.js +5 -9
  94. package/src/plugins_core/functions/error.js +4 -8
  95. package/src/plugins_core/functions/feature_flags.js +1 -5
  96. package/src/plugins_core/functions/index.js +20 -14
  97. package/src/plugins_core/functions/utils.js +9 -13
  98. package/src/plugins_core/functions_install/index.js +3 -7
  99. package/src/plugins_core/list.js +10 -7
  100. package/src/status/add.js +1 -5
  101. package/src/status/colors.js +2 -6
  102. package/src/status/load_error.js +4 -8
  103. package/src/status/report.js +4 -8
  104. package/src/status/success.js +2 -6
  105. package/src/steps/core_step.js +4 -8
  106. package/src/steps/error.js +7 -11
  107. package/src/steps/get.js +7 -12
  108. package/src/steps/plugin.js +8 -12
  109. package/src/steps/return.js +4 -8
  110. package/src/steps/run_step.js +8 -12
  111. package/src/steps/run_steps.js +5 -9
  112. package/src/steps/update_config.js +10 -14
  113. package/src/telemetry/main.js +8 -12
  114. package/src/time/aggregate.js +2 -6
  115. package/src/time/main.js +8 -12
  116. package/src/time/measure.js +4 -8
  117. package/src/time/report.js +5 -9
  118. package/src/utils/errors.js +1 -5
  119. package/src/utils/json.js +19 -0
  120. package/src/utils/omit.js +2 -6
  121. package/src/utils/package.js +3 -7
  122. package/src/utils/remove_falsy.js +2 -6
  123. package/src/utils/resolve.js +8 -6
  124. package/src/utils/semver.js +9 -13
  125. package/types/config/functions.d.ts +1 -1
@@ -1,13 +1,11 @@
1
- 'use strict'
1
+ import safeJsonStringify from 'safe-json-stringify'
2
2
 
3
- const safeJsonStringify = require('safe-json-stringify')
4
-
5
- const { CUSTOM_ERROR_KEY } = require('./info')
3
+ import { CUSTOM_ERROR_KEY } from './info.js'
6
4
 
7
5
  // Retrieve error information from child process and re-build it in current
8
6
  // process. We need this since errors static properties are not kept by
9
7
  // `v8.serialize()`.
10
- const jsonToError = function ({ name, message, stack, ...errorProps }) {
8
+ export const jsonToError = function ({ name, message, stack, ...errorProps }) {
11
9
  // eslint-disable-next-line unicorn/error-message
12
10
  const error = new Error('')
13
11
 
@@ -36,11 +34,9 @@ const assignErrorProp = function (error, name, value) {
36
34
  }
37
35
 
38
36
  // Inverse of `jsonToError()`.
39
- const errorToJson = function ({ name, message, stack, [CUSTOM_ERROR_KEY]: customError, ...errorProps }) {
37
+ export const errorToJson = function ({ name, message, stack, [CUSTOM_ERROR_KEY]: customError, ...errorProps }) {
40
38
  return {
41
39
  ...safeJsonStringify.ensureProperties(errorProps),
42
40
  ...safeJsonStringify.ensureProperties({ name, message, stack, [CUSTOM_ERROR_KEY]: customError }),
43
41
  }
44
42
  }
45
-
46
- module.exports = { jsonToError, errorToJson }
@@ -1,12 +1,8 @@
1
- 'use strict'
2
-
3
1
  // Cancel builds, for example when a plugin uses `utils.build.cancelBuild()`
4
- const cancelBuild = async function ({ api, deployId }) {
2
+ export const cancelBuild = async function ({ api, deployId }) {
5
3
  if (api === undefined || !deployId) {
6
4
  return
7
5
  }
8
6
 
9
7
  await api.cancelSiteDeploy({ deploy_id: deployId })
10
8
  }
11
-
12
- module.exports = { cancelBuild }
@@ -1,9 +1,7 @@
1
- 'use strict'
2
-
3
- const stripAnsi = require('strip-ansi')
1
+ import stripAnsi from 'strip-ansi'
4
2
 
5
3
  // Remove ANSI sequences from `error.message`
6
- const removeErrorColors = function (error) {
4
+ export const removeErrorColors = function (error) {
7
5
  if (!(error instanceof Error)) {
8
6
  return
9
7
  }
@@ -11,5 +9,3 @@ const removeErrorColors = function (error) {
11
9
  error.message = stripAnsi(error.message)
12
10
  error.stack = stripAnsi(error.stack)
13
11
  }
14
-
15
- module.exports = { removeErrorColors }
@@ -1,19 +1,17 @@
1
- 'use strict'
1
+ import { cwd as getCwd } from 'process'
2
2
 
3
- const { cwd: getCwd } = require('process')
3
+ import pathExists from 'path-exists'
4
4
 
5
- const pathExists = require('path-exists')
5
+ import { logBuildError } from '../log/messages/core.js'
6
+ import { logOldCliVersionError } from '../log/old_version.js'
6
7
 
7
- const { logBuildError } = require('../log/messages/core')
8
- const { logOldCliVersionError } = require('../log/old_version')
9
-
10
- const { removeErrorColors } = require('./colors')
11
- const { getErrorInfo } = require('./info')
12
- const { reportBuildError } = require('./monitor/report')
13
- const { parseErrorInfo } = require('./parse/parse')
8
+ import { removeErrorColors } from './colors.js'
9
+ import { getErrorInfo } from './info.js'
10
+ import { reportBuildError } from './monitor/report.js'
11
+ import { parseErrorInfo } from './parse/parse.js'
14
12
 
15
13
  // Logs and reports a build failure
16
- const handleBuildError = async function (
14
+ export const handleBuildError = async function (
17
15
  error,
18
16
  { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts },
19
17
  ) {
@@ -26,7 +24,7 @@ const handleBuildError = async function (
26
24
  removeErrorColors(error)
27
25
  // Some errors, such as telemetry ones, should not be logged
28
26
  if (basicErrorInfo.showInBuildLog) {
29
- await logBuildError({ error, netlifyConfig, mode, logs, debug, testOpts })
27
+ logBuildError({ error, netlifyConfig, mode, logs, debug, testOpts })
30
28
  }
31
29
  logOldCliVersionError({ mode, testOpts })
32
30
  await reportBuildError({ error, errorMonitor, childEnv, logs, testOpts })
@@ -57,5 +55,3 @@ const isCancelCrash = async function (error) {
57
55
  return true
58
56
  }
59
57
  }
60
-
61
- module.exports = { handleBuildError }
package/src/error/info.js CHANGED
@@ -1,7 +1,5 @@
1
- 'use strict'
2
-
3
1
  // Add information related to an error without colliding with existing properties
4
- const addDefaultErrorInfo = function (error, info) {
2
+ export const addDefaultErrorInfo = function (error, info) {
5
3
  if (!canHaveErrorInfo(error)) {
6
4
  return
7
5
  }
@@ -10,7 +8,7 @@ const addDefaultErrorInfo = function (error, info) {
10
8
  }
11
9
 
12
10
  // Retrieve error information added by our system
13
- const addErrorInfo = function (error, info) {
11
+ export const addErrorInfo = function (error, info) {
14
12
  if (!canHaveErrorInfo(error)) {
15
13
  return
16
14
  }
@@ -18,7 +16,7 @@ const addErrorInfo = function (error, info) {
18
16
  error[CUSTOM_ERROR_KEY] = { ...error[CUSTOM_ERROR_KEY], ...info }
19
17
  }
20
18
 
21
- const getErrorInfo = function (error) {
19
+ export const getErrorInfo = function (error) {
22
20
  if (!isBuildError(error)) {
23
21
  return [{}, error]
24
22
  }
@@ -28,14 +26,14 @@ const getErrorInfo = function (error) {
28
26
  }
29
27
 
30
28
  // Change error type from one to another
31
- const changeErrorType = function (error, oldType, newType) {
29
+ export const changeErrorType = function (error, oldType, newType) {
32
30
  const [{ type }] = getErrorInfo(error)
33
31
  if (type === oldType) {
34
32
  addErrorInfo(error, { type: newType })
35
33
  }
36
34
  }
37
35
 
38
- const isBuildError = function (error) {
36
+ export const isBuildError = function (error) {
39
37
  return canHaveErrorInfo(error) && error[CUSTOM_ERROR_KEY] !== undefined
40
38
  }
41
39
 
@@ -45,6 +43,4 @@ const canHaveErrorInfo = function (error) {
45
43
  return error != null
46
44
  }
47
45
 
48
- const CUSTOM_ERROR_KEY = 'customErrorInfo'
49
-
50
- module.exports = { addDefaultErrorInfo, addErrorInfo, getErrorInfo, changeErrorType, isBuildError, CUSTOM_ERROR_KEY }
46
+ export const CUSTOM_ERROR_KEY = 'customErrorInfo'
@@ -1,7 +1,5 @@
1
- 'use strict'
2
-
3
1
  // Retrieve plugin's location and build logs
4
- const getLocationMetadata = function (location, envMetadata) {
2
+ export const getLocationMetadata = function (location, envMetadata) {
5
3
  const buildLogs = getBuildLogs(envMetadata)
6
4
 
7
5
  if (buildLogs === undefined && location === undefined) {
@@ -21,5 +19,3 @@ const getBuildLogs = function ({ SITE_NAME, DEPLOY_ID }) {
21
19
  }
22
20
 
23
21
  const NETLIFY_ORIGIN = 'https://app.netlify.com'
24
-
25
- module.exports = { getLocationMetadata }
@@ -1,9 +1,7 @@
1
- 'use strict'
2
-
3
1
  // We group errors by `error.message`. However some `error.message` contain
4
2
  // unique IDs, etc. which defeats that grouping. So we normalize those to make
5
3
  // them consistent
6
- const normalizeGroupingMessage = function (message, type) {
4
+ export const normalizeGroupingMessage = function (message, type) {
7
5
  const messageA = removeDependenciesLogs(message, type)
8
6
  return NORMALIZE_REGEXPS.reduce(normalizeMessage, messageA)
9
7
  }
@@ -57,7 +55,7 @@ const NORMALIZE_REGEXPS = [
57
55
  [/(Required inputs for plugin).*/gm, '$1'],
58
56
  // Netlify Functions validation check
59
57
  [/(should target a directory, not a regular file):.*/, '$1'],
60
- // zip-it-and-ship-it error when there is a `require()` but dependencies
58
+ // zip-it-and-ship-it error when there is an `import()` but dependencies
61
59
  // were not installed
62
60
  [/(Cannot find module) '([^']+)'/g, "$1 'moduleName'"],
63
61
  [/(A Netlify Function is using) "[^"]+"/g, '$1 "moduleName"'],
@@ -77,5 +75,3 @@ const NORMALIZE_REGEXPS = [
77
75
  // Multiple empty lines
78
76
  [/^\s*$/gm, ''],
79
77
  ]
80
-
81
- module.exports = { normalizeGroupingMessage }
@@ -1,9 +1,7 @@
1
- 'use strict'
2
-
3
- const { log } = require('../../log/logger')
1
+ import { log } from '../../log/logger.js'
4
2
 
5
3
  // Print event payload instead of sending actual request during tests
6
- const printEventForTest = function (
4
+ export const printEventForTest = function (
7
5
  { name: errorClass, message: errorMessage },
8
6
  {
9
7
  context,
@@ -42,7 +40,3 @@ const printEventForTest = function (
42
40
  )
43
41
  log(logs, `\nError monitoring payload:\n${eventString}`)
44
42
  }
45
-
46
- module.exports = {
47
- printEventForTest,
48
- }
@@ -1,21 +1,19 @@
1
- 'use strict'
1
+ import { type as osType, freemem, totalmem } from 'os'
2
+ import { promisify } from 'util'
2
3
 
3
- const { type: osType, freemem, totalmem } = require('os')
4
- const { promisify } = require('util')
4
+ import osName from 'os-name'
5
5
 
6
- const osName = require('os-name')
6
+ import { getEnvMetadata } from '../../env/metadata.js'
7
+ import { log } from '../../log/logger.js'
8
+ import { parseErrorInfo } from '../parse/parse.js'
9
+ import { getHomepage } from '../parse/plugin.js'
7
10
 
8
- const { getEnvMetadata } = require('../../env/metadata')
9
- const { log } = require('../../log/logger')
10
- const { parseErrorInfo } = require('../parse/parse')
11
- const { getHomepage } = require('../parse/plugin')
12
-
13
- const { getLocationMetadata } = require('./location')
14
- const { normalizeGroupingMessage } = require('./normalize')
15
- const { printEventForTest } = require('./print')
11
+ import { getLocationMetadata } from './location.js'
12
+ import { normalizeGroupingMessage } from './normalize.js'
13
+ import { printEventForTest } from './print.js'
16
14
 
17
15
  // Report a build failure for monitoring purpose
18
- const reportBuildError = async function ({ error, errorMonitor, childEnv, logs, testOpts }) {
16
+ export const reportBuildError = async function ({ error, errorMonitor, childEnv, logs, testOpts }) {
19
17
  if (errorMonitor === undefined) {
20
18
  return
21
19
  }
@@ -130,5 +128,3 @@ const onError = function (event, eventProps) {
130
128
  })
131
129
  return true
132
130
  }
133
-
134
- module.exports = { reportBuildError }
@@ -1,15 +1,15 @@
1
- 'use strict'
1
+ import { fileURLToPath } from 'url'
2
2
 
3
- const Bugsnag = require('@bugsnag/js')
4
- const memoizeOne = require('memoize-one')
3
+ import Bugsnag from '@bugsnag/js'
4
+ import memoizeOne from 'memoize-one'
5
5
 
6
- const { name, version } = require('../../../package.json')
7
- const { log } = require('../../log/logger')
6
+ import { log } from '../../log/logger.js'
7
+ import { ROOT_PACKAGE_JSON } from '../../utils/json.js'
8
8
 
9
- const projectRoot = `${__dirname}/../../..`
9
+ const projectRoot = fileURLToPath(new URL('../../..', import.meta.url))
10
10
 
11
11
  // Start a client to monitor errors
12
- const startErrorMonitor = function ({ flags: { mode }, logs, bugsnagKey }) {
12
+ export const startErrorMonitor = function ({ flags: { mode }, logs, bugsnagKey }) {
13
13
  if (!bugsnagKey) {
14
14
  return
15
15
  }
@@ -20,8 +20,8 @@ const startErrorMonitor = function ({ flags: { mode }, logs, bugsnagKey }) {
20
20
  try {
21
21
  const errorMonitor = startBugsnag({
22
22
  apiKey: bugsnagKey,
23
- appVersion: `${name} ${version}`,
24
- appType: name,
23
+ appVersion: `${ROOT_PACKAGE_JSON.name} ${ROOT_PACKAGE_JSON.version}`,
24
+ appType: ROOT_PACKAGE_JSON.name,
25
25
  releaseStage,
26
26
  logger,
27
27
  projectRoot,
@@ -67,5 +67,3 @@ const getLogger = function (logs, isTest) {
67
67
  }
68
68
 
69
69
  const noop = function () {}
70
-
71
- module.exports = { startErrorMonitor }
@@ -1,9 +1,7 @@
1
- 'use strict'
1
+ import { cwd } from 'process'
2
2
 
3
- const { cwd } = require('process')
4
-
5
- const cleanStack = require('clean-stack')
6
- const stripAnsi = require('strip-ansi')
3
+ import cleanStack from 'clean-stack'
4
+ import stripAnsi from 'strip-ansi'
7
5
 
8
6
  // Clean stack traces:
9
7
  // - remove our internal code, e.g. the logic spawning plugins
@@ -13,7 +11,7 @@ const stripAnsi = require('strip-ansi')
13
11
  // Keep non stack trace lines as is.
14
12
  // We do not use libraries that patch `Error.prepareStackTrace()` because they
15
13
  // tend to create issues.
16
- const cleanStacks = function ({ stack, rawStack, debug }) {
14
+ export const cleanStacks = function ({ stack, rawStack, debug }) {
17
15
  if (stack === undefined) {
18
16
  return
19
17
  }
@@ -87,5 +85,3 @@ const normalizePathSlashes = function (line) {
87
85
  }
88
86
 
89
87
  const BACKLASH_REGEXP = /\\/g
90
-
91
- module.exports = { cleanStacks }
@@ -1,10 +1,8 @@
1
- 'use strict'
2
-
3
- const { getBuildCommandDescription, getPluginOrigin } = require('../../log/description')
1
+ import { getBuildCommandDescription, getPluginOrigin } from '../../log/description.js'
4
2
 
5
3
  // Retrieve an error's location to print in logs.
6
4
  // Each error type has its own logic (or none if there's no location to print).
7
- const getLocationInfo = function ({ stack, location, locationType }) {
5
+ export const getLocationInfo = function ({ stack, location, locationType }) {
8
6
  // No location to print
9
7
  if (locationType === undefined && stack === undefined) {
10
8
  return
@@ -58,5 +56,3 @@ const LOCATIONS = {
58
56
  buildFail: getBuildFailLocation,
59
57
  api: getApiLocation,
60
58
  }
61
-
62
- module.exports = { getLocationInfo }
@@ -1,9 +1,7 @@
1
- 'use strict'
2
-
3
1
  // Ensure error is an `Error` instance.
4
2
  // If is an `Error` instance but is missing usual `Error` properties, we make
5
3
  // sure its static properties are preserved.
6
- const normalizeError = function (error) {
4
+ export const normalizeError = function (error) {
7
5
  if (Array.isArray(error)) {
8
6
  return normalizeArray(error)
9
7
  }
@@ -29,5 +27,3 @@ const normalizeArray = function (errorArray) {
29
27
  error.errors = errors
30
28
  return error
31
29
  }
32
-
33
- module.exports = { normalizeError }
@@ -1,17 +1,15 @@
1
- 'use strict'
1
+ import { serializeObject } from '../../log/serialize.js'
2
+ import { getErrorInfo } from '../info.js'
3
+ import { getTypeInfo } from '../type.js'
2
4
 
3
- const { serializeObject } = require('../../log/serialize')
4
- const { getErrorInfo } = require('../info')
5
- const { getTypeInfo } = require('../type')
6
-
7
- const { getLocationInfo } = require('./location')
8
- const { normalizeError } = require('./normalize')
9
- const { getPluginInfo } = require('./plugin')
10
- const { getErrorProps } = require('./properties')
11
- const { getStackInfo } = require('./stack')
5
+ import { getLocationInfo } from './location.js'
6
+ import { normalizeError } from './normalize.js'
7
+ import { getPluginInfo } from './plugin.js'
8
+ import { getErrorProps } from './properties.js'
9
+ import { getStackInfo } from './stack.js'
12
10
 
13
11
  // Add additional type-specific error information
14
- const getFullErrorInfo = function ({ error, colors, debug }) {
12
+ export const getFullErrorInfo = function ({ error, colors, debug }) {
15
13
  const basicErrorInfo = parseErrorInfo(error)
16
14
  const {
17
15
  message,
@@ -57,7 +55,7 @@ const getTsConfigInfo = function (tsConfig) {
57
55
  }
58
56
 
59
57
  // Parse error instance into all the basic properties containing information
60
- const parseErrorInfo = function (error) {
58
+ export const parseErrorInfo = function (error) {
61
59
  const { message, stack, ...errorProps } = normalizeError(error)
62
60
  const [errorInfo, errorPropsA] = getErrorInfo(errorProps)
63
61
  const {
@@ -97,5 +95,3 @@ const getTitle = function (title, errorInfo) {
97
95
 
98
96
  return title(errorInfo)
99
97
  }
100
-
101
- module.exports = { getFullErrorInfo, parseErrorInfo }
@@ -1,8 +1,6 @@
1
- 'use strict'
2
-
3
1
  // Retrieve plugin's package.json details to include in error messages.
4
2
  // Please note `pluginPackageJson` has been normalized by `normalize-package-data`.
5
- const getPluginInfo = function ({ pluginPackageJson = {} }, { packageName, loadedFrom }) {
3
+ export const getPluginInfo = function ({ pluginPackageJson = {} }, { packageName, loadedFrom }) {
6
4
  if (Object.keys(pluginPackageJson).length === 0) {
7
5
  return
8
6
  }
@@ -38,7 +36,7 @@ const getVersion = function ({ version }) {
38
36
  return version
39
37
  }
40
38
 
41
- const getHomepage = function (pluginPackageJson = {}, { loadedFrom } = {}) {
39
+ export const getHomepage = function (pluginPackageJson = {}, { loadedFrom } = {}) {
42
40
  return (
43
41
  getRepository(pluginPackageJson) ||
44
42
  getNpmLink(pluginPackageJson, { loadedFrom }) ||
@@ -70,5 +68,3 @@ const FIELDS = {
70
68
  'npm link': getNpmLink,
71
69
  'Report issues': getIssuesLink,
72
70
  }
73
-
74
- module.exports = { getPluginInfo, getHomepage }
@@ -1,11 +1,9 @@
1
- 'use strict'
1
+ import { inspect } from 'util'
2
2
 
3
- const { inspect } = require('util')
4
-
5
- const { omit } = require('../../utils/omit')
3
+ import { omit } from '../../utils/omit.js'
6
4
 
7
5
  // In uncaught exceptions, print error static properties
8
- const getErrorProps = function ({ errorProps, showErrorProps, colors }) {
6
+ export const getErrorProps = function ({ errorProps, showErrorProps, colors }) {
9
7
  if (!showErrorProps) {
10
8
  return
11
9
  }
@@ -23,5 +21,3 @@ const INSPECT_MAX_DEPTH = 5
23
21
 
24
22
  // Remove error static properties that should not be logged
25
23
  const CLEANED_ERROR_PROPS = ['requireStack']
26
-
27
- module.exports = { getErrorProps }
@@ -1,9 +1,7 @@
1
- 'use strict'
2
-
3
- const { THEME } = require('../../log/theme')
1
+ import { THEME } from '../../log/theme.js'
4
2
 
5
3
  // Serialize an error object into a title|body string to print in logs
6
- const serializeLogError = function ({
4
+ export const serializeLogError = function ({
7
5
  fullErrorInfo: { title, severity, message, pluginInfo, locationInfo, tsConfigInfo, errorProps },
8
6
  }) {
9
7
  const body = getBody({ message, pluginInfo, locationInfo, tsConfigInfo, errorProps, severity })
@@ -42,5 +40,3 @@ const LOG_BLOCK_NAMES = {
42
40
  tsConfigInfo: 'TypeScript configuration',
43
41
  errorProps: 'Error properties',
44
42
  }
45
-
46
- module.exports = { serializeLogError }
@@ -1,7 +1,5 @@
1
- 'use strict'
2
-
3
1
  // Serialize an error object to `statuses` properties
4
- const serializeErrorStatus = function ({ fullErrorInfo: { title, message, locationInfo, errorProps }, state }) {
2
+ export const serializeErrorStatus = function ({ fullErrorInfo: { title, message, locationInfo, errorProps }, state }) {
5
3
  const text = getText({ locationInfo, errorProps })
6
4
  return { state, title, summary: message, text }
7
5
  }
@@ -23,5 +21,3 @@ const getErrorProps = function (errorProps) {
23
21
 
24
22
  return `Error properties:\n${errorProps}`
25
23
  }
26
-
27
- module.exports = { serializeErrorStatus }
@@ -1,9 +1,7 @@
1
- 'use strict'
2
-
3
- const { cleanStacks } = require('./clean_stack')
1
+ import { cleanStacks } from './clean_stack.js'
4
2
 
5
3
  // Retrieve the stack trace
6
- const getStackInfo = function ({ message, stack, stackType, rawStack, severity, debug }) {
4
+ export const getStackInfo = function ({ message, stack, stackType, rawStack, severity, debug }) {
7
5
  const { message: messageA, stack: stackA } = splitStackInfo({ message, stack, stackType })
8
6
  const messageB = severity === 'none' ? messageA.replace(SUCCESS_ERROR_NAME, '') : messageA
9
7
  const stackB = cleanStacks({ stack: stackA, rawStack, debug })
@@ -43,5 +41,3 @@ const isStackTrace = function (line) {
43
41
  }
44
42
 
45
43
  const SUCCESS_ERROR_NAME = 'Error: '
46
-
47
- module.exports = { getStackInfo }
package/src/error/type.js CHANGED
@@ -1,7 +1,5 @@
1
- 'use strict'
2
-
3
1
  // Retrieve error-type specific information
4
- const getTypeInfo = function ({ type }) {
2
+ export const getTypeInfo = function ({ type }) {
5
3
  const typeA = TYPES[type] === undefined ? DEFAULT_TYPE : type
6
4
  return { type: typeA, ...TYPES[typeA] }
7
5
  }
@@ -182,5 +180,3 @@ const TYPES = {
182
180
 
183
181
  // When no error type matches, it's an uncaught exception, i.e. a bug
184
182
  const DEFAULT_TYPE = 'exception'
185
-
186
- module.exports = { getTypeInfo }
@@ -1,15 +1,13 @@
1
- 'use strict'
1
+ import { dirname } from 'path'
2
2
 
3
- const { dirname } = require('path')
3
+ import readdirp from 'readdirp'
4
4
 
5
- const readdirp = require('readdirp')
5
+ import { logInstallFunctionDependencies } from '../log/messages/install.js'
6
6
 
7
- const { logInstallFunctionDependencies } = require('../log/messages/install')
8
-
9
- const { installDependencies } = require('./main')
7
+ import { installDependencies } from './main.js'
10
8
 
11
9
  // Install dependencies of Netlify Functions
12
- const installFunctionDependencies = async function (functionsSrc, isLocal) {
10
+ export const installFunctionDependencies = async function (functionsSrc, isLocal) {
13
11
  const packagePaths = await getPackagePaths(functionsSrc)
14
12
  if (packagePaths.length === 0) {
15
13
  return
@@ -28,5 +26,3 @@ const getPackagePaths = function (functionsSrc) {
28
26
  const getPackageRoot = function ({ fullPath }) {
29
27
  return dirname(fullPath)
30
28
  }
31
-
32
- module.exports = { installFunctionDependencies }
@@ -1,16 +1,14 @@
1
- 'use strict'
1
+ import pkgDir from 'pkg-dir'
2
2
 
3
- const pkgDir = require('pkg-dir')
3
+ import { logInstallLocalPluginsDeps } from '../log/messages/install.js'
4
4
 
5
- const { logInstallLocalPluginsDeps } = require('../log/messages/install')
6
-
7
- const { installDependencies } = require('./main')
5
+ import { installDependencies } from './main.js'
8
6
 
9
7
  // Install dependencies of local plugins.
10
8
  // Users must add this plugin to their `netlify.toml` `plugins` to use this
11
9
  // feature. We don't want to provide it by default because this makes build
12
10
  // slow and buggy.
13
- const installLocalPluginsDependencies = async function ({ plugins, pluginsOptions, buildDir, mode, logs }) {
11
+ export const installLocalPluginsDependencies = async function ({ plugins, pluginsOptions, buildDir, mode, logs }) {
14
12
  if (!plugins.some(isLocalInstallOptIn)) {
15
13
  return
16
14
  }
@@ -37,7 +35,7 @@ const isLocalInstallOptIn = function (plugin) {
37
35
  return plugin.package === LOCAL_INSTALL_PLUGIN_NAME
38
36
  }
39
37
 
40
- const LOCAL_INSTALL_PLUGIN_NAME = '@netlify/plugin-local-install-core'
38
+ export const LOCAL_INSTALL_PLUGIN_NAME = '@netlify/plugin-local-install-core'
41
39
 
42
40
  // Core plugins and non-local plugins already have their dependencies installed
43
41
  const getLocalPluginsOptions = function (pluginsOptions) {
@@ -62,5 +60,3 @@ const removeMainRoot = async function (localPluginsOptions, buildDir) {
62
60
  const mainPackageDir = await pkgDir(buildDir)
63
61
  return localPluginsOptions.filter(({ packageDir }) => packageDir !== mainPackageDir)
64
62
  }
65
-
66
- module.exports = { installLocalPluginsDependencies, LOCAL_INSTALL_PLUGIN_NAME }
@@ -1,19 +1,17 @@
1
- 'use strict'
1
+ import { homedir } from 'os'
2
2
 
3
- const { homedir } = require('os')
3
+ import execa from 'execa'
4
+ import pathExists from 'path-exists'
4
5
 
5
- const execa = require('execa')
6
- const pathExists = require('path-exists')
7
-
8
- const { addErrorInfo } = require('../error/info')
6
+ import { addErrorInfo } from '../error/info.js'
9
7
 
10
8
  // Install Node.js dependencies in a specific directory
11
- const installDependencies = function ({ packageRoot, isLocal }) {
9
+ export const installDependencies = function ({ packageRoot, isLocal }) {
12
10
  return runCommand({ packageRoot, isLocal, type: 'install' })
13
11
  }
14
12
 
15
13
  // Add new Node.js dependencies, with exact semver ranges
16
- const addExactDependencies = function ({ packageRoot, isLocal, packages }) {
14
+ export const addExactDependencies = function ({ packageRoot, isLocal, packages }) {
17
15
  return runCommand({ packageRoot, packages, isLocal, type: 'addExact' })
18
16
  }
19
17
 
@@ -81,5 +79,3 @@ const isNotNpmLogMessage = function (line) {
81
79
  return NPM_LOG_MESSAGES.every((message) => !line.includes(message))
82
80
  }
83
81
  const NPM_LOG_MESSAGES = ['complete log of this run', '-debug.log']
84
-
85
- module.exports = { installDependencies, addExactDependencies }