@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,81 +1,68 @@
1
- import { env } from 'process'
2
-
3
- import filterObj from 'filter-obj'
4
-
1
+ import { env } from 'process';
2
+ import filterObj from 'filter-obj';
5
3
  // Retrieve enviroment variables used in error monitoring
6
4
  export const getEnvMetadata = function (childEnv = env) {
7
- return filterObj(childEnv, isEnvMetadata)
8
- }
9
-
5
+ return filterObj(childEnv, isEnvMetadata);
6
+ };
10
7
  const isEnvMetadata = function (name) {
11
- return ENVIRONMENT_VARIABLES.has(name)
12
- }
13
-
8
+ return ENVIRONMENT_VARIABLES.has(name);
9
+ };
14
10
  // This is sorted by most useful in debugging to least
15
11
  const ENVIRONMENT_VARIABLES = new Set([
16
- // URL and IDs
17
- 'BUILD_ID',
18
- 'DEPLOY_ID',
19
- 'SITE_NAME',
20
- 'SITE_ID',
21
- 'REPOSITORY_URL',
22
- 'URL',
23
- 'DEPLOY_URL',
24
- 'DEPLOY_PRIME_URL',
25
-
26
- // Git
27
- 'HEAD',
28
- 'COMMIT_REF',
29
- 'CACHED_COMMIT_REF',
30
- 'BRANCH',
31
- 'CONTEXT',
32
- 'PULL_REQUEST',
33
- 'REVIEW_ID',
34
-
35
- // Node
36
- 'NODE_VERSION',
37
- 'AWS_LAMBDA_JS_RUNTIME',
38
- 'NPM_VERSION',
39
- 'YARN_VERSION',
40
- 'NPM_FLAGS',
41
- 'YARN_FLAGS',
42
- 'NVM_FLAGS',
43
- 'NODE_ENV',
44
-
45
- // Go
46
- 'GO_VERSION',
47
- 'GO_IMPORT_PATH',
48
- 'GOCACHE',
49
- 'GOPATH',
50
- 'GOROOT',
51
-
52
- // Ruby
53
- 'RUBY_VERSION',
54
- 'GEM_HOME',
55
- 'GEM_PATH',
56
- 'GIMME_GCO_ENABLED',
57
- 'GIMME_ENV_PREFIX',
58
- 'GIMME_GO_PREFIX',
59
- 'GIMME_NO_ENV_ALIAS',
60
- 'GIMME_TYPE',
61
- 'IRBRC',
62
- 'MY_RUBY_HOME',
63
-
64
- // Hugo
65
- 'HUGO_VERSION',
66
-
67
- // Java
68
- 'JAVA_VERSION',
69
-
70
- // PHP
71
- 'PHP_VERSION',
72
-
73
- // Python
74
- 'PIPENV_DEFAULT_PYTHON_VERSION',
75
- 'PIPENV_RUNTIME',
76
- 'PIPENV_VENV_IN_PROJECT',
77
-
78
- // Git LFS
79
- 'GIT_LFS_ENABLED',
80
- 'GIT_LFS_FETCH_INCLUDE',
81
- ])
12
+ // URL and IDs
13
+ 'BUILD_ID',
14
+ 'DEPLOY_ID',
15
+ 'SITE_NAME',
16
+ 'SITE_ID',
17
+ 'REPOSITORY_URL',
18
+ 'URL',
19
+ 'DEPLOY_URL',
20
+ 'DEPLOY_PRIME_URL',
21
+ // Git
22
+ 'HEAD',
23
+ 'COMMIT_REF',
24
+ 'CACHED_COMMIT_REF',
25
+ 'BRANCH',
26
+ 'CONTEXT',
27
+ 'PULL_REQUEST',
28
+ 'REVIEW_ID',
29
+ // Node
30
+ 'NODE_VERSION',
31
+ 'AWS_LAMBDA_JS_RUNTIME',
32
+ 'NPM_VERSION',
33
+ 'YARN_VERSION',
34
+ 'NPM_FLAGS',
35
+ 'YARN_FLAGS',
36
+ 'NVM_FLAGS',
37
+ 'NODE_ENV',
38
+ // Go
39
+ 'GO_VERSION',
40
+ 'GO_IMPORT_PATH',
41
+ 'GOCACHE',
42
+ 'GOPATH',
43
+ 'GOROOT',
44
+ // Ruby
45
+ 'RUBY_VERSION',
46
+ 'GEM_HOME',
47
+ 'GEM_PATH',
48
+ 'GIMME_GCO_ENABLED',
49
+ 'GIMME_ENV_PREFIX',
50
+ 'GIMME_GO_PREFIX',
51
+ 'GIMME_NO_ENV_ALIAS',
52
+ 'GIMME_TYPE',
53
+ 'IRBRC',
54
+ 'MY_RUBY_HOME',
55
+ // Hugo
56
+ 'HUGO_VERSION',
57
+ // Java
58
+ 'JAVA_VERSION',
59
+ // PHP
60
+ 'PHP_VERSION',
61
+ // Python
62
+ 'PIPENV_DEFAULT_PYTHON_VERSION',
63
+ 'PIPENV_RUNTIME',
64
+ 'PIPENV_VENV_IN_PROJECT',
65
+ // Git LFS
66
+ 'GIT_LFS_ENABLED',
67
+ 'GIT_LFS_FETCH_INCLUDE',
68
+ ]);
package/lib/error/api.js CHANGED
@@ -1,46 +1,37 @@
1
- import isPlainObj from 'is-plain-obj'
2
- import mapObj from 'map-obj'
3
-
4
- import { addErrorInfo } from './info.js'
5
-
1
+ import isPlainObj from 'is-plain-obj';
2
+ import mapObj from 'map-obj';
3
+ import { addErrorInfo } from './info.js';
6
4
  // Wrap `api.*` methods so that they add more error information
7
5
  export const addApiErrorHandlers = function (api) {
8
- if (api === undefined) {
9
- return
10
- }
11
-
12
- return mapObj(api, addErrorHandler)
13
- }
14
-
6
+ if (api === undefined) {
7
+ return;
8
+ }
9
+ return mapObj(api, addErrorHandler);
10
+ };
15
11
  const addErrorHandler = function (key, value) {
16
- if (typeof value !== 'function') {
17
- return [key, value]
18
- }
19
-
20
- const valueA = apiMethodHandler.bind(null, key, value)
21
- return [key, valueA]
22
- }
23
-
12
+ if (typeof value !== 'function') {
13
+ return [key, value];
14
+ }
15
+ const valueA = apiMethodHandler.bind(null, key, value);
16
+ return [key, valueA];
17
+ };
24
18
  const apiMethodHandler = async function (endpoint, method, parameters, ...args) {
25
- try {
26
- return await method(parameters, ...args)
27
- } catch (error) {
28
- redactError(error)
29
- addErrorInfo(error, { type: 'api', location: { endpoint, parameters } })
30
- throw error
31
- }
32
- }
33
-
19
+ try {
20
+ return await method(parameters, ...args);
21
+ }
22
+ catch (error) {
23
+ redactError(error);
24
+ addErrorInfo(error, { type: 'api', location: { endpoint, parameters } });
25
+ throw error;
26
+ }
27
+ };
34
28
  // Redact API token from the build logs
35
29
  const redactError = function (error) {
36
- if (
37
- error instanceof Error &&
38
- isPlainObj(error.data) &&
39
- isPlainObj(error.data.headers) &&
40
- typeof error.data.headers.Authorization === 'string'
41
- ) {
42
- error.data.headers.Authorization = error.data.headers.Authorization.replace(HEX_REGEXP, 'HEX')
43
- }
44
- }
45
-
46
- const HEX_REGEXP = /[\da-f]{6,}/g
30
+ if (error instanceof Error &&
31
+ isPlainObj(error.data) &&
32
+ isPlainObj(error.data.headers) &&
33
+ typeof error.data.headers.Authorization === 'string') {
34
+ error.data.headers.Authorization = error.data.headers.Authorization.replace(HEX_REGEXP, 'HEX');
35
+ }
36
+ };
37
+ const HEX_REGEXP = /[\da-f]{6,}/g;
@@ -1,47 +1,36 @@
1
- import safeJsonStringify from 'safe-json-stringify'
2
-
3
- import { CUSTOM_ERROR_KEY } from './info.js'
4
-
1
+ import safeJsonStringify from 'safe-json-stringify';
2
+ import { CUSTOM_ERROR_KEY } from './info.js';
5
3
  // Retrieve error information from child process and re-build it in current
6
4
  // process. We need this since errors static properties are not kept by
7
5
  // `v8.serialize()`.
8
6
  export const jsonToError = function ({ name, message, stack, ...errorProps }) {
9
- const error = new Error('')
10
-
11
- assignErrorProps(error, { name, message, stack })
12
- // Assign static error properties (if any)
13
- // We need to mutate the `error` directly to preserve its `name`, `stack`, etc.
14
- Object.assign(error, errorProps)
15
-
16
- return error
17
- }
18
-
7
+ const error = new Error('');
8
+ assignErrorProps(error, { name, message, stack });
9
+ // Assign static error properties (if any)
10
+ // We need to mutate the `error` directly to preserve its `name`, `stack`, etc.
11
+ Object.assign(error, errorProps);
12
+ return error;
13
+ };
19
14
  // Make sure `name`, `message` and `stack` are not enumerable
20
15
  const assignErrorProps = function (error, values) {
21
- ERROR_PROPS.forEach((name) => {
22
- assignErrorProp(error, name, values[name])
23
- })
24
- }
25
-
26
- const ERROR_PROPS = ['name', 'message', 'stack']
27
-
16
+ ERROR_PROPS.forEach((name) => {
17
+ assignErrorProp(error, name, values[name]);
18
+ });
19
+ };
20
+ const ERROR_PROPS = ['name', 'message', 'stack'];
28
21
  const assignErrorProp = function (error, name, value) {
29
- // `Object.defineProperty()` requires direct mutation
30
-
31
- Object.defineProperty(error, name, { value, enumerable: false, writable: true, configurable: true })
32
- }
33
-
22
+ // `Object.defineProperty()` requires direct mutation
23
+ Object.defineProperty(error, name, { value, enumerable: false, writable: true, configurable: true });
24
+ };
34
25
  // Inverse of `jsonToError()`.
35
26
  export const errorToJson = function (error) {
36
- const { name, message, stack, [CUSTOM_ERROR_KEY]: customError, ...errorProps } = error
37
-
38
- // diagnosticText is not enumerable in TSError so we need to grab it manually. destructuring won't work.
39
- if (error.diagnosticText) {
40
- errorProps.diagnosticText = error.diagnosticText
41
- }
42
-
43
- return {
44
- ...safeJsonStringify.ensureProperties(errorProps),
45
- ...safeJsonStringify.ensureProperties({ name, message, stack, [CUSTOM_ERROR_KEY]: customError }),
46
- }
47
- }
27
+ const { name, message, stack, [CUSTOM_ERROR_KEY]: customError, ...errorProps } = error;
28
+ // diagnosticText is not enumerable in TSError so we need to grab it manually. destructuring won't work.
29
+ if (error.diagnosticText) {
30
+ errorProps.diagnosticText = error.diagnosticText;
31
+ }
32
+ return {
33
+ ...safeJsonStringify.ensureProperties(errorProps),
34
+ ...safeJsonStringify.ensureProperties({ name, message, stack, [CUSTOM_ERROR_KEY]: customError }),
35
+ };
36
+ };
@@ -1,8 +1,7 @@
1
1
  // Cancel builds, for example when a plugin uses `utils.build.cancelBuild()`
2
2
  export const cancelBuild = async function ({ api, deployId }) {
3
- if (api === undefined || !deployId) {
4
- return
5
- }
6
-
7
- await api.cancelSiteDeploy({ deploy_id: deployId })
8
- }
3
+ if (api === undefined || !deployId) {
4
+ return;
5
+ }
6
+ await api.cancelSiteDeploy({ deploy_id: deployId });
7
+ };
@@ -1,11 +1,9 @@
1
- import stripAnsi from 'strip-ansi'
2
-
1
+ import stripAnsi from 'strip-ansi';
3
2
  // Remove ANSI sequences from `error.message`
4
3
  export const removeErrorColors = function (error) {
5
- if (!(error instanceof Error)) {
6
- return
7
- }
8
-
9
- error.message = stripAnsi(error.message)
10
- error.stack = stripAnsi(error.stack)
11
- }
4
+ if (!(error instanceof Error)) {
5
+ return;
6
+ }
7
+ error.message = stripAnsi(error.message);
8
+ error.stack = stripAnsi(error.stack);
9
+ };
@@ -1,37 +1,26 @@
1
- import { cwd as getCwd } from 'process'
2
-
3
- import { pathExists } from 'path-exists'
4
-
5
- import { logBuildError } from '../log/messages/core.js'
6
- import { logOldCliVersionError } from '../log/old_version.js'
7
-
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'
12
-
1
+ import { cwd as getCwd } from 'process';
2
+ import { pathExists } from 'path-exists';
3
+ import { logBuildError } from '../log/messages/core.js';
4
+ import { logOldCliVersionError } from '../log/old_version.js';
5
+ import { removeErrorColors } from './colors.js';
6
+ import { getErrorInfo } from './info.js';
7
+ import { reportBuildError } from './monitor/report.js';
8
+ import { parseErrorInfo } from './parse/parse.js';
13
9
  // Logs and reports a build failure
14
- export const handleBuildError = async function (
15
- error,
16
- { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts },
17
- ) {
18
- const basicErrorInfo = parseErrorInfo(error)
19
-
20
- if (await isCancelCrash(error)) {
21
- return basicErrorInfo
22
- }
23
-
24
- removeErrorColors(error)
25
- // Some errors, such as telemetry ones, should not be logged
26
- if (basicErrorInfo.showInBuildLog) {
27
- logBuildError({ error, netlifyConfig, mode, logs, debug, testOpts })
28
- }
29
- logOldCliVersionError({ mode, testOpts })
30
- await reportBuildError({ error, errorMonitor, childEnv, logs, testOpts })
31
-
32
- return basicErrorInfo
33
- }
34
-
10
+ export const handleBuildError = async function (error, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts }) {
11
+ const basicErrorInfo = parseErrorInfo(error);
12
+ if (await isCancelCrash(error)) {
13
+ return basicErrorInfo;
14
+ }
15
+ removeErrorColors(error);
16
+ // Some errors, such as telemetry ones, should not be logged
17
+ if (basicErrorInfo.showInBuildLog) {
18
+ logBuildError({ error, netlifyConfig, mode, logs, debug, testOpts });
19
+ }
20
+ logOldCliVersionError({ mode, testOpts });
21
+ await reportBuildError({ error, errorMonitor, childEnv, logs, testOpts });
22
+ return basicErrorInfo;
23
+ };
35
24
  // When builds are canceled, the whole filesystem is being deleted.
36
25
  // However, the process (and build) keeps going. Because no files exist anymore,
37
26
  // the build eventually crashes with a randomly odd error. Those should not be
@@ -39,19 +28,19 @@ export const handleBuildError = async function (
39
28
  // However builds canceled with `utils.build.cancelBuild()` should still show
40
29
  // "Build canceled by ..."
41
30
  const isCancelCrash = async function (error) {
42
- const [{ type }] = getErrorInfo(error)
43
- if (type === 'cancelBuild') {
44
- return false
45
- }
46
-
47
- try {
48
- // TODO: find a better way to detect that the build is being cancelled.
49
- // Otherwise bugs due to (for example) the build command removing
50
- // `process.cwd` are currently not logged/reported.
51
- const cwd = getCwd()
52
- return !(await pathExists(cwd))
53
- // `process.cwd()` fails when the current directory does not exist
54
- } catch {
55
- return true
56
- }
57
- }
31
+ const [{ type }] = getErrorInfo(error);
32
+ if (type === 'cancelBuild') {
33
+ return false;
34
+ }
35
+ try {
36
+ // TODO: find a better way to detect that the build is being cancelled.
37
+ // Otherwise bugs due to (for example) the build command removing
38
+ // `process.cwd` are currently not logged/reported.
39
+ const cwd = getCwd();
40
+ return !(await pathExists(cwd));
41
+ // `process.cwd()` fails when the current directory does not exist
42
+ }
43
+ catch {
44
+ return true;
45
+ }
46
+ };
package/lib/error/info.js CHANGED
@@ -1,46 +1,37 @@
1
1
  // Add information related to an error without colliding with existing properties
2
2
  export const addDefaultErrorInfo = function (error, info) {
3
- if (!canHaveErrorInfo(error)) {
4
- return
5
- }
6
-
7
- error[CUSTOM_ERROR_KEY] = { ...info, ...error[CUSTOM_ERROR_KEY] }
8
- }
9
-
3
+ if (!canHaveErrorInfo(error)) {
4
+ return;
5
+ }
6
+ error[CUSTOM_ERROR_KEY] = { ...info, ...error[CUSTOM_ERROR_KEY] };
7
+ };
10
8
  // Retrieve error information added by our system
11
9
  export const addErrorInfo = function (error, info) {
12
- if (!canHaveErrorInfo(error)) {
13
- return
14
- }
15
-
16
- error[CUSTOM_ERROR_KEY] = { ...error[CUSTOM_ERROR_KEY], ...info }
17
- }
18
-
10
+ if (!canHaveErrorInfo(error)) {
11
+ return;
12
+ }
13
+ error[CUSTOM_ERROR_KEY] = { ...error[CUSTOM_ERROR_KEY], ...info };
14
+ };
19
15
  export const getErrorInfo = function (error) {
20
- if (!isBuildError(error)) {
21
- return [{}, error]
22
- }
23
-
24
- const { [CUSTOM_ERROR_KEY]: errorInfo, ...errorA } = error
25
- return [errorInfo, errorA]
26
- }
27
-
16
+ if (!isBuildError(error)) {
17
+ return [{}, error];
18
+ }
19
+ const { [CUSTOM_ERROR_KEY]: errorInfo, ...errorA } = error;
20
+ return [errorInfo, errorA];
21
+ };
28
22
  // Change error type from one to another
29
23
  export const changeErrorType = function (error, oldType, newType) {
30
- const [{ type }] = getErrorInfo(error)
31
- if (type === oldType) {
32
- addErrorInfo(error, { type: newType })
33
- }
34
- }
35
-
24
+ const [{ type }] = getErrorInfo(error);
25
+ if (type === oldType) {
26
+ addErrorInfo(error, { type: newType });
27
+ }
28
+ };
36
29
  export const isBuildError = function (error) {
37
- return canHaveErrorInfo(error) && error[CUSTOM_ERROR_KEY] !== undefined
38
- }
39
-
30
+ return canHaveErrorInfo(error) && error[CUSTOM_ERROR_KEY] !== undefined;
31
+ };
40
32
  // Exceptions that are not objects (including `Error` instances) cannot have an
41
33
  // `CUSTOM_ERROR_KEY` property
42
34
  const canHaveErrorInfo = function (error) {
43
- return error != null
44
- }
45
-
46
- export const CUSTOM_ERROR_KEY = 'customErrorInfo'
35
+ return error != null;
36
+ };
37
+ export const CUSTOM_ERROR_KEY = 'customErrorInfo';
@@ -1,21 +1,16 @@
1
1
  // Retrieve plugin's location and build logs
2
2
  export const getLocationMetadata = function (location, envMetadata) {
3
- const buildLogs = getBuildLogs(envMetadata)
4
-
5
- if (buildLogs === undefined && location === undefined) {
6
- return
7
- }
8
-
9
- return { buildLogs, ...location }
10
- }
11
-
3
+ const buildLogs = getBuildLogs(envMetadata);
4
+ if (buildLogs === undefined && location === undefined) {
5
+ return;
6
+ }
7
+ return { buildLogs, ...location };
8
+ };
12
9
  // Retrieve the URL to the build logs
13
10
  const getBuildLogs = function ({ SITE_NAME, DEPLOY_ID }) {
14
- if (SITE_NAME === undefined || DEPLOY_ID === undefined) {
15
- return
16
- }
17
-
18
- return `${NETLIFY_ORIGIN}/sites/${SITE_NAME}/deploys/${DEPLOY_ID}`
19
- }
20
-
21
- const NETLIFY_ORIGIN = 'https://app.netlify.com'
11
+ if (SITE_NAME === undefined || DEPLOY_ID === undefined) {
12
+ return;
13
+ }
14
+ return `${NETLIFY_ORIGIN}/sites/${SITE_NAME}/deploys/${DEPLOY_ID}`;
15
+ };
16
+ const NETLIFY_ORIGIN = 'https://app.netlify.com';