@netlify/build 29.0.1-rc → 29.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.
- package/bin.js +5 -0
- package/lib/core/bin.js +66 -0
- package/lib/core/build.js +356 -0
- package/lib/core/config.js +121 -0
- package/lib/core/constants.js +116 -0
- package/lib/core/dev.js +27 -0
- package/lib/core/dry.js +21 -0
- package/lib/core/feature_flags.js +21 -0
- package/lib/core/flags.js +201 -0
- package/lib/core/lingering.js +68 -0
- package/lib/core/main.js +110 -0
- package/lib/core/missing_side_file.js +17 -0
- package/lib/core/normalize_flags.js +59 -0
- package/lib/core/severity.js +21 -0
- package/lib/core/types.js +8 -0
- package/lib/core/user_node_version.js +32 -0
- package/lib/env/changes.js +43 -0
- package/lib/env/main.js +14 -0
- package/lib/env/metadata.js +68 -0
- package/lib/error/api.js +37 -0
- package/lib/error/build.js +36 -0
- package/{src → lib}/error/cancel.js +5 -6
- package/lib/error/colors.js +9 -0
- package/lib/error/handle.js +46 -0
- package/lib/error/info.js +37 -0
- package/lib/error/monitor/location.js +16 -0
- package/lib/error/monitor/normalize.js +86 -0
- package/lib/error/monitor/print.js +20 -0
- package/lib/error/monitor/report.js +120 -0
- package/lib/error/monitor/start.js +61 -0
- package/lib/error/parse/clean_stack.js +70 -0
- package/lib/error/parse/location.js +50 -0
- package/lib/error/parse/normalize.js +24 -0
- package/lib/error/parse/parse.js +67 -0
- package/lib/error/parse/plugin.js +55 -0
- package/lib/error/parse/properties.js +16 -0
- package/lib/error/parse/serialize_log.js +34 -0
- package/lib/error/parse/serialize_status.js +18 -0
- package/lib/error/parse/stack.js +34 -0
- package/lib/error/report.js +27 -0
- package/lib/error/type.js +177 -0
- package/lib/install/functions.js +20 -0
- package/lib/install/local.js +45 -0
- package/lib/install/main.js +67 -0
- package/lib/install/missing.js +54 -0
- package/lib/log/colors.js +28 -0
- package/lib/log/description.js +21 -0
- package/lib/log/header.js +14 -0
- package/lib/log/header_func.js +13 -0
- package/lib/log/logger.js +140 -0
- package/lib/log/messages/compatibility.js +146 -0
- package/lib/log/messages/config.js +91 -0
- package/lib/log/messages/core.js +51 -0
- package/lib/log/messages/core_steps.js +75 -0
- package/lib/log/messages/dry.js +41 -0
- package/lib/log/messages/install.js +25 -0
- package/lib/log/messages/ipc.js +29 -0
- package/lib/log/messages/mutations.js +62 -0
- package/{src → lib}/log/messages/plugins.js +18 -32
- package/lib/log/messages/status.js +14 -0
- package/lib/log/messages/steps.js +18 -0
- package/lib/log/old_version.js +32 -0
- package/lib/log/serialize.js +10 -0
- package/lib/log/stream.js +68 -0
- package/lib/log/theme.js +27 -0
- package/lib/plugins/child/diff.js +46 -0
- package/lib/plugins/child/error.js +26 -0
- package/lib/plugins/child/lazy.js +15 -0
- package/lib/plugins/child/load.js +22 -0
- package/lib/plugins/child/logic.js +57 -0
- package/lib/plugins/child/main.js +37 -0
- package/lib/plugins/child/run.js +19 -0
- package/lib/plugins/child/status.js +63 -0
- package/lib/plugins/child/typescript.js +28 -0
- package/lib/plugins/child/utils.js +42 -0
- package/lib/plugins/child/validate.js +31 -0
- package/lib/plugins/compatibility.js +104 -0
- package/{src → lib}/plugins/error.js +31 -35
- package/{src → lib}/plugins/events.js +7 -12
- package/lib/plugins/expected_version.js +81 -0
- package/lib/plugins/internal.js +10 -0
- package/lib/plugins/ipc.js +120 -0
- package/lib/plugins/list.js +73 -0
- package/lib/plugins/load.js +50 -0
- package/lib/plugins/manifest/check.js +85 -0
- package/lib/plugins/manifest/load.js +38 -0
- package/lib/plugins/manifest/main.js +19 -0
- package/lib/plugins/manifest/path.js +24 -0
- package/lib/plugins/manifest/validate.js +91 -0
- package/lib/plugins/node_version.js +35 -0
- package/lib/plugins/options.js +70 -0
- package/lib/plugins/pinned_version.js +83 -0
- package/lib/plugins/resolve.js +110 -0
- package/lib/plugins/spawn.js +58 -0
- package/lib/plugins_core/add.js +35 -0
- package/lib/plugins_core/build_command.js +50 -0
- package/lib/plugins_core/deploy/buildbot_client.js +87 -0
- package/lib/plugins_core/deploy/index.js +49 -0
- package/{src → lib}/plugins_core/deploy/manifest.yml +0 -0
- package/lib/plugins_core/edge_functions/index.js +76 -0
- package/{src → lib}/plugins_core/edge_functions/lib/error.js +13 -17
- package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +21 -0
- package/lib/plugins_core/functions/error.js +123 -0
- package/lib/plugins_core/functions/feature_flags.js +6 -0
- package/lib/plugins_core/functions/index.js +114 -0
- package/lib/plugins_core/functions/utils.js +45 -0
- package/lib/plugins_core/functions/zisi.js +39 -0
- package/{src → lib}/plugins_core/functions_install/index.js +8 -11
- package/{src → lib}/plugins_core/functions_install/manifest.yml +0 -0
- package/lib/plugins_core/list.js +20 -0
- package/lib/report/statsd.js +31 -0
- package/lib/status/add.js +30 -0
- package/lib/status/colors.js +18 -0
- package/lib/status/load_error.js +10 -0
- package/lib/status/report.js +83 -0
- package/lib/status/success.js +14 -0
- package/lib/steps/core_step.js +59 -0
- package/lib/steps/error.js +65 -0
- package/lib/steps/get.js +43 -0
- package/lib/steps/plugin.js +55 -0
- package/lib/steps/return.js +25 -0
- package/lib/steps/run_core_steps.js +117 -0
- package/lib/steps/run_step.js +190 -0
- package/lib/steps/run_steps.js +96 -0
- package/lib/steps/update_config.js +66 -0
- package/lib/telemetry/main.js +97 -0
- package/lib/time/aggregate.js +109 -0
- package/lib/time/main.js +31 -0
- package/lib/time/measure.js +16 -0
- package/lib/time/report.js +24 -0
- package/lib/utils/errors.js +13 -0
- package/lib/utils/json.js +15 -0
- package/lib/utils/omit.js +3 -0
- package/lib/utils/package.js +24 -0
- package/lib/utils/remove_falsy.js +8 -0
- package/lib/utils/resolve.js +41 -0
- package/lib/utils/runtime.js +5 -0
- package/lib/utils/semver.js +28 -0
- package/package.json +41 -24
- package/types/config/netlify_config.d.ts +4 -4
- package/types/netlify_plugin_constants.d.ts +8 -8
- package/src/core/bin.js +0 -83
- package/src/core/build.js +0 -554
- package/src/core/config.js +0 -186
- package/src/core/constants.js +0 -156
- package/src/core/dev.js +0 -31
- package/src/core/dry.js +0 -39
- package/src/core/feature_flags.js +0 -22
- package/src/core/flags.js +0 -204
- package/src/core/lingering.js +0 -85
- package/src/core/main.js +0 -165
- package/src/core/missing_side_file.js +0 -29
- package/src/core/normalize_flags.js +0 -70
- package/src/core/severity.js +0 -22
- package/src/core/user_node_version.js +0 -41
- package/src/env/changes.js +0 -52
- package/src/env/main.js +0 -19
- package/src/env/metadata.js +0 -81
- package/src/error/api.js +0 -46
- package/src/error/build.js +0 -50
- package/src/error/colors.js +0 -11
- package/src/error/handle.js +0 -57
- package/src/error/info.js +0 -46
- package/src/error/monitor/location.js +0 -21
- package/src/error/monitor/normalize.js +0 -96
- package/src/error/monitor/print.js +0 -42
- package/src/error/monitor/report.js +0 -138
- package/src/error/monitor/start.js +0 -69
- package/src/error/parse/clean_stack.js +0 -87
- package/src/error/parse/location.js +0 -62
- package/src/error/parse/normalize.js +0 -29
- package/src/error/parse/parse.js +0 -97
- package/src/error/parse/plugin.js +0 -70
- package/src/error/parse/properties.js +0 -23
- package/src/error/parse/serialize_log.js +0 -42
- package/src/error/parse/serialize_status.js +0 -23
- package/src/error/parse/stack.js +0 -43
- package/src/error/type.js +0 -189
- package/src/install/functions.js +0 -28
- package/src/install/local.js +0 -62
- package/src/install/main.js +0 -81
- package/src/install/missing.js +0 -67
- package/src/log/colors.js +0 -34
- package/src/log/description.js +0 -26
- package/src/log/header.js +0 -16
- package/src/log/header_func.js +0 -17
- package/src/log/logger.js +0 -161
- package/src/log/messages/compatibility.js +0 -164
- package/src/log/messages/config.js +0 -107
- package/src/log/messages/core.js +0 -70
- package/src/log/messages/core_steps.js +0 -104
- package/src/log/messages/dry.js +0 -63
- package/src/log/messages/install.js +0 -20
- package/src/log/messages/ipc.js +0 -38
- package/src/log/messages/mutations.js +0 -82
- package/src/log/messages/status.js +0 -16
- package/src/log/messages/steps.js +0 -22
- package/src/log/old_version.js +0 -41
- package/src/log/serialize.js +0 -13
- package/src/log/stream.js +0 -85
- package/src/log/theme.js +0 -26
- package/src/plugins/child/diff.js +0 -55
- package/src/plugins/child/error.js +0 -32
- package/src/plugins/child/lazy.js +0 -18
- package/src/plugins/child/load.js +0 -29
- package/src/plugins/child/logic.js +0 -57
- package/src/plugins/child/main.js +0 -51
- package/src/plugins/child/run.js +0 -28
- package/src/plugins/child/status.js +0 -74
- package/src/plugins/child/typescript.js +0 -45
- package/src/plugins/child/utils.js +0 -56
- package/src/plugins/child/validate.js +0 -34
- package/src/plugins/compatibility.js +0 -128
- package/src/plugins/expected_version.js +0 -119
- package/src/plugins/ipc.js +0 -145
- package/src/plugins/list.js +0 -86
- package/src/plugins/load.js +0 -70
- package/src/plugins/manifest/check.js +0 -106
- package/src/plugins/manifest/load.js +0 -41
- package/src/plugins/manifest/main.js +0 -22
- package/src/plugins/manifest/path.js +0 -31
- package/src/plugins/manifest/validate.js +0 -108
- package/src/plugins/node_version.js +0 -50
- package/src/plugins/options.js +0 -88
- package/src/plugins/pinned_version.js +0 -131
- package/src/plugins/resolve.js +0 -152
- package/src/plugins/spawn.js +0 -66
- package/src/plugins_core/add.js +0 -49
- package/src/plugins_core/build_command.js +0 -75
- package/src/plugins_core/deploy/buildbot_client.js +0 -102
- package/src/plugins_core/deploy/index.js +0 -73
- package/src/plugins_core/edge_functions/index.js +0 -123
- package/src/plugins_core/edge_functions/lib/internal_manifest.js +0 -54
- package/src/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +0 -89
- package/src/plugins_core/functions/error.js +0 -163
- package/src/plugins_core/functions/feature_flags.js +0 -6
- package/src/plugins_core/functions/index.js +0 -160
- package/src/plugins_core/functions/utils.js +0 -66
- package/src/plugins_core/functions/zisi.js +0 -53
- package/src/plugins_core/list.js +0 -27
- package/src/status/add.js +0 -36
- package/src/status/colors.js +0 -23
- package/src/status/load_error.js +0 -11
- package/src/status/report.js +0 -137
- package/src/status/success.js +0 -18
- package/src/steps/core_step.js +0 -92
- package/src/steps/error.js +0 -102
- package/src/steps/get.js +0 -51
- package/src/steps/plugin.js +0 -85
- package/src/steps/return.js +0 -52
- package/src/steps/run_core_steps.js +0 -200
- package/src/steps/run_step.js +0 -304
- package/src/steps/run_steps.js +0 -179
- package/src/steps/update_config.js +0 -93
- package/src/telemetry/main.js +0 -136
- package/src/time/aggregate.js +0 -146
- package/src/time/main.js +0 -48
- package/src/time/measure.js +0 -22
- package/src/time/report.js +0 -59
- package/src/utils/errors.js +0 -12
- package/src/utils/json.js +0 -19
- package/src/utils/omit.js +0 -6
- package/src/utils/package.js +0 -23
- package/src/utils/remove_falsy.js +0 -10
- package/src/utils/resolve.js +0 -46
- package/src/utils/semver.js +0 -34
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { log } from '../../log/logger.js'
|
|
2
|
-
|
|
3
|
-
// Print event payload instead of sending actual request during tests
|
|
4
|
-
export const printEventForTest = function (
|
|
5
|
-
{ name: errorClass, message: errorMessage },
|
|
6
|
-
{
|
|
7
|
-
context,
|
|
8
|
-
groupingHash,
|
|
9
|
-
severity,
|
|
10
|
-
unhandled,
|
|
11
|
-
_metadata: {
|
|
12
|
-
location,
|
|
13
|
-
plugin: { packageName, homepage } = {},
|
|
14
|
-
pluginPackageJson,
|
|
15
|
-
tsConfig,
|
|
16
|
-
env: { BUILD_ID } = {},
|
|
17
|
-
other,
|
|
18
|
-
},
|
|
19
|
-
},
|
|
20
|
-
logs,
|
|
21
|
-
) {
|
|
22
|
-
const eventString = JSON.stringify(
|
|
23
|
-
{
|
|
24
|
-
errorClass,
|
|
25
|
-
errorMessage,
|
|
26
|
-
context,
|
|
27
|
-
groupingHash,
|
|
28
|
-
severity,
|
|
29
|
-
unhandled,
|
|
30
|
-
location,
|
|
31
|
-
packageName,
|
|
32
|
-
pluginPackageJson: pluginPackageJson !== undefined,
|
|
33
|
-
homepage,
|
|
34
|
-
tsConfig,
|
|
35
|
-
BUILD_ID,
|
|
36
|
-
other,
|
|
37
|
-
},
|
|
38
|
-
null,
|
|
39
|
-
2,
|
|
40
|
-
)
|
|
41
|
-
log(logs, `\nError monitoring payload:\n${eventString}`)
|
|
42
|
-
}
|
|
@@ -1,138 +0,0 @@
|
|
|
1
|
-
import { type as osType, freemem, totalmem } from 'os'
|
|
2
|
-
import { promisify } from 'util'
|
|
3
|
-
|
|
4
|
-
import osName from 'os-name'
|
|
5
|
-
|
|
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'
|
|
10
|
-
|
|
11
|
-
import { getLocationMetadata } from './location.js'
|
|
12
|
-
import { normalizeGroupingMessage } from './normalize.js'
|
|
13
|
-
import { printEventForTest } from './print.js'
|
|
14
|
-
|
|
15
|
-
// Report a build failure for monitoring purpose
|
|
16
|
-
export const reportBuildError = async function ({ error, errorMonitor, childEnv, logs, testOpts }) {
|
|
17
|
-
if (errorMonitor === undefined) {
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const { errorInfo, type, severity, title, group = title } = parseErrorInfo(error)
|
|
22
|
-
const severityA = getSeverity(severity, errorInfo)
|
|
23
|
-
const groupA = getGroup(group, errorInfo)
|
|
24
|
-
const groupingHash = getGroupingHash(groupA, error, type, errorInfo)
|
|
25
|
-
const metadata = getMetadata(errorInfo, childEnv, groupingHash)
|
|
26
|
-
const app = getApp()
|
|
27
|
-
const eventProps = getEventProps({ severity: severityA, group: groupA, groupingHash, metadata, app })
|
|
28
|
-
|
|
29
|
-
const errorName = updateErrorName(error, type)
|
|
30
|
-
try {
|
|
31
|
-
await reportError({ errorMonitor, error, logs, testOpts, eventProps })
|
|
32
|
-
} finally {
|
|
33
|
-
error.name = errorName
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
// Plugin authors test their plugins as local plugins. Errors there are more
|
|
38
|
-
// like development errors, and should be reported as `info` only.
|
|
39
|
-
const getSeverity = function (severity, { location: { loadedFrom } = {} }) {
|
|
40
|
-
if (loadedFrom === 'local' || severity === 'none') {
|
|
41
|
-
return 'info'
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return severity
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const getGroup = function (group, errorInfo) {
|
|
48
|
-
if (typeof group !== 'function') {
|
|
49
|
-
return group
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return group(errorInfo)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
const getGroupingHash = function (group, error, type, errorInfo = {}) {
|
|
56
|
-
// If the error has a `normalizedMessage`, we use it as the grouping hash.
|
|
57
|
-
if (errorInfo.normalizedMessage) {
|
|
58
|
-
return errorInfo.normalizedMessage
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const message = error instanceof Error && typeof error.message === 'string' ? error.message : String(error)
|
|
62
|
-
const messageA = normalizeGroupingMessage(message, type)
|
|
63
|
-
return `${group}\n${messageA}`
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
const getMetadata = function ({ location, plugin, tsConfig }, childEnv, groupingHash) {
|
|
67
|
-
const pluginMetadata = getPluginMetadata({ location, plugin })
|
|
68
|
-
const envMetadata = getEnvMetadata(childEnv)
|
|
69
|
-
const locationMetadata = getLocationMetadata(location, envMetadata)
|
|
70
|
-
return { location: locationMetadata, ...pluginMetadata, tsConfig, env: envMetadata, other: { groupingHash } }
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const getPluginMetadata = function ({ location, plugin }) {
|
|
74
|
-
if (plugin === undefined) {
|
|
75
|
-
return {}
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
const { pluginPackageJson, ...pluginA } = plugin
|
|
79
|
-
const homepage = getHomepage(pluginPackageJson, location)
|
|
80
|
-
return { plugin: { ...pluginA, homepage }, pluginPackageJson }
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
const getApp = function () {
|
|
84
|
-
return {
|
|
85
|
-
osName: osType(),
|
|
86
|
-
osVersion: osName(),
|
|
87
|
-
freeMemory: freemem(),
|
|
88
|
-
totalMemory: totalmem(),
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
// `error.name` is shown proeminently in the Bugsnag UI. We need to update it to
|
|
93
|
-
// match error `type` since it is more granular and useful.
|
|
94
|
-
// But we change it back after Bugsnag is done reporting.
|
|
95
|
-
const updateErrorName = function (error, type) {
|
|
96
|
-
const { name } = error
|
|
97
|
-
// This might fail if `name` is a getter or is non-writable.
|
|
98
|
-
try {
|
|
99
|
-
error.name = type
|
|
100
|
-
} catch {}
|
|
101
|
-
return name
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
const reportError = async function ({ errorMonitor, error, logs, testOpts, eventProps }) {
|
|
105
|
-
if (testOpts.errorMonitor) {
|
|
106
|
-
printEventForTest(error, eventProps, logs)
|
|
107
|
-
return
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
try {
|
|
111
|
-
await promisify(errorMonitor.notify)(error, (event) => onError(event, eventProps))
|
|
112
|
-
// Failsafe
|
|
113
|
-
} catch {
|
|
114
|
-
log(logs, `Error monitor could not notify\n${error.stack}`)
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
const getEventProps = function ({ severity, group, groupingHash, metadata, app }) {
|
|
119
|
-
// `unhandled` is used to calculate Releases "stabiity score", which is
|
|
120
|
-
// basically the percentage of unhandled errors. Since we handle all errors,
|
|
121
|
-
// we need to implement this according to error types.
|
|
122
|
-
const unhandled = severity === 'error'
|
|
123
|
-
return { severity, context: group, groupingHash, _metadata: metadata, app, unhandled }
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
// Add more information to Bugsnag events
|
|
127
|
-
const onError = function (event, eventProps) {
|
|
128
|
-
// Bugsnag client requires directly mutating the `event`
|
|
129
|
-
// eslint-disable-next-line fp/no-mutating-assign
|
|
130
|
-
Object.assign(event, {
|
|
131
|
-
...eventProps,
|
|
132
|
-
unhandled: event.unhandled || eventProps.unhandled,
|
|
133
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
134
|
-
_metadata: { ...event._metadata, ...eventProps._metadata },
|
|
135
|
-
app: { ...event.app, ...eventProps.app },
|
|
136
|
-
})
|
|
137
|
-
return true
|
|
138
|
-
}
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { fileURLToPath } from 'url'
|
|
2
|
-
|
|
3
|
-
import Bugsnag from '@bugsnag/js'
|
|
4
|
-
import memoizeOne from 'memoize-one'
|
|
5
|
-
|
|
6
|
-
import { log } from '../../log/logger.js'
|
|
7
|
-
import { ROOT_PACKAGE_JSON } from '../../utils/json.js'
|
|
8
|
-
|
|
9
|
-
const projectRoot = fileURLToPath(new URL('../../..', import.meta.url))
|
|
10
|
-
|
|
11
|
-
// Start a client to monitor errors
|
|
12
|
-
export const startErrorMonitor = function ({ flags: { mode }, logs, bugsnagKey }) {
|
|
13
|
-
if (!bugsnagKey) {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const isTest = isBugsnagTest(bugsnagKey)
|
|
18
|
-
const releaseStage = getReleaseStage(mode)
|
|
19
|
-
const logger = getLogger(logs, isTest)
|
|
20
|
-
try {
|
|
21
|
-
const errorMonitor = startBugsnag({
|
|
22
|
-
apiKey: bugsnagKey,
|
|
23
|
-
appVersion: `${ROOT_PACKAGE_JSON.name} ${ROOT_PACKAGE_JSON.version}`,
|
|
24
|
-
appType: ROOT_PACKAGE_JSON.name,
|
|
25
|
-
releaseStage,
|
|
26
|
-
logger,
|
|
27
|
-
projectRoot,
|
|
28
|
-
})
|
|
29
|
-
|
|
30
|
-
// Allows knowing the percentage of failed builds per release
|
|
31
|
-
if (!isTest) {
|
|
32
|
-
errorMonitor.startSession()
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
return errorMonitor
|
|
36
|
-
// Failsafe
|
|
37
|
-
} catch (error) {
|
|
38
|
-
log(logs, `Error monitor could not start\n${error.stack}`)
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const isBugsnagTest = function (bugsnagKey) {
|
|
43
|
-
return bugsnagKey === BUGSNAG_TEST_KEY
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const BUGSNAG_TEST_KEY = '00000000000000000000000000000000'
|
|
47
|
-
|
|
48
|
-
// Bugsnag.start() caches a global instance and warns on duplicate calls.
|
|
49
|
-
// This ensures the warning message is not shown when calling the main function
|
|
50
|
-
// several times.
|
|
51
|
-
const startBugsnag = memoizeOne(Bugsnag.start.bind(Bugsnag), () => true)
|
|
52
|
-
|
|
53
|
-
// Based the release stage on the `mode`
|
|
54
|
-
const getReleaseStage = function (mode = DEFAULT_RELEASE_STAGE) {
|
|
55
|
-
return mode
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const DEFAULT_RELEASE_STAGE = 'unknown'
|
|
59
|
-
|
|
60
|
-
// We don't want Bugsnag logs except on warnings/errors.
|
|
61
|
-
// We also want to use our own `log` utility, unprefixed.
|
|
62
|
-
// In tests, we don't print Bugsnag because it sometimes randomly fails to
|
|
63
|
-
// send sessions, which prints warning messags in test snapshots.
|
|
64
|
-
const getLogger = function (logs, isTest) {
|
|
65
|
-
const logFunc = isTest ? noop : log.bind(null, logs)
|
|
66
|
-
return { debug: noop, info: noop, warn: logFunc, error: logFunc }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const noop = function () {}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import { cwd } from 'process'
|
|
2
|
-
|
|
3
|
-
import cleanStack from 'clean-stack'
|
|
4
|
-
import stripAnsi from 'strip-ansi'
|
|
5
|
-
|
|
6
|
-
// Clean stack traces:
|
|
7
|
-
// - remove our internal code, e.g. the logic spawning plugins
|
|
8
|
-
// - remove node modules and Node.js internals
|
|
9
|
-
// - strip process.cwd()
|
|
10
|
-
// - remove colors
|
|
11
|
-
// Keep non stack trace lines as is.
|
|
12
|
-
// We do not use libraries that patch `Error.prepareStackTrace()` because they
|
|
13
|
-
// tend to create issues.
|
|
14
|
-
export const cleanStacks = function ({ stack, rawStack, debug }) {
|
|
15
|
-
if (stack === undefined) {
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// Internal errors / bugs keep their full stack trace
|
|
20
|
-
// Same in debug mode
|
|
21
|
-
if (rawStack || debug) {
|
|
22
|
-
return stack
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
return stack.split('\n').reduce(cleanStackLine, '').replace(INITIAL_NEWLINES, '')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const cleanStackLine = function (lines, line) {
|
|
29
|
-
const lineA = line.replace(getCwd(), '')
|
|
30
|
-
const lineB = stripAnsi(lineA)
|
|
31
|
-
|
|
32
|
-
if (!STACK_LINE_REGEXP.test(lineB)) {
|
|
33
|
-
return `${lines}\n${lineA}`
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
if (shouldRemoveStackLine(lineB)) {
|
|
37
|
-
return lines
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const lineC = cleanStack(lineB)
|
|
41
|
-
|
|
42
|
-
if (lineC === '') {
|
|
43
|
-
return lines
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return `${lines}\n${lineC}`
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// `process.cwd()` can sometimes fail: directory name too long, current
|
|
50
|
-
// directory has been removed, access denied.
|
|
51
|
-
const getCwd = function () {
|
|
52
|
-
try {
|
|
53
|
-
return cwd()
|
|
54
|
-
} catch {
|
|
55
|
-
return ''
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Check if a line is part of a stack trace
|
|
60
|
-
const STACK_LINE_REGEXP = /^\s+at /
|
|
61
|
-
|
|
62
|
-
const shouldRemoveStackLine = function (line) {
|
|
63
|
-
const lineA = normalizePathSlashes(line)
|
|
64
|
-
return INTERNAL_STACK_STRINGS.some((stackString) => lineA.includes(stackString)) || INTERNAL_STACK_REGEXP.test(lineA)
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const INTERNAL_STACK_STRINGS = [
|
|
68
|
-
// Anonymous function
|
|
69
|
-
'<anonymous>',
|
|
70
|
-
'(index 0)',
|
|
71
|
-
// nyc internal code
|
|
72
|
-
'node_modules/append-transform',
|
|
73
|
-
'node_modules/signal-exit',
|
|
74
|
-
// Node internals
|
|
75
|
-
'(node:',
|
|
76
|
-
]
|
|
77
|
-
|
|
78
|
-
// This is only needed for local builds and tests
|
|
79
|
-
const INTERNAL_STACK_REGEXP = /(packages|@netlify)\/build\/(src\/|tests\/helpers\/|tests\/.*\/tests.js|node_modules)/
|
|
80
|
-
|
|
81
|
-
const INITIAL_NEWLINES = /^\n+/
|
|
82
|
-
|
|
83
|
-
const normalizePathSlashes = function (line) {
|
|
84
|
-
return line.replace(BACKLASH_REGEXP, '/')
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const BACKLASH_REGEXP = /\\/g
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { getBuildCommandDescription, getPluginOrigin } from '../../log/description.js'
|
|
2
|
-
|
|
3
|
-
// Retrieve an error's location to print in logs.
|
|
4
|
-
// Each error type has its own logic (or none if there's no location to print).
|
|
5
|
-
export const getLocationInfo = function ({ stack, location, locationType }) {
|
|
6
|
-
// No location to print
|
|
7
|
-
if (locationType === undefined && stack === undefined) {
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// The location is only the stack trace
|
|
12
|
-
if (locationType === undefined) {
|
|
13
|
-
return stack
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const locationString = LOCATIONS[locationType](location)
|
|
17
|
-
return [locationString, stack].filter(Boolean).join('\n')
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const getBuildCommandLocation = function ({ buildCommand, buildCommandOrigin }) {
|
|
21
|
-
const description = getBuildCommandDescription(buildCommandOrigin)
|
|
22
|
-
return `In ${description}:
|
|
23
|
-
${buildCommand}`
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const getFunctionsBundlingLocation = function ({ functionName, functionType }) {
|
|
27
|
-
if (functionType === 'edge') {
|
|
28
|
-
return 'While bundling edge function'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return `While bundling function "${functionName}"`
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
const getCoreStepLocation = function ({ coreStepName }) {
|
|
35
|
-
return `During ${coreStepName}`
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const getBuildFailLocation = function ({ event, packageName, loadedFrom, origin }) {
|
|
39
|
-
const eventMessage = getEventMessage(event)
|
|
40
|
-
const pluginOrigin = getPluginOrigin(loadedFrom, origin)
|
|
41
|
-
return `${eventMessage} "${packageName}" ${pluginOrigin}`
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const getEventMessage = function (event) {
|
|
45
|
-
if (event === 'load') {
|
|
46
|
-
return `While loading`
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
return `In "${event}" event in`
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const getApiLocation = function ({ endpoint, parameters }) {
|
|
53
|
-
return `While calling the Netlify API endpoint '${endpoint}' with:\n${JSON.stringify(parameters, null, 2)}`
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
const LOCATIONS = {
|
|
57
|
-
buildCommand: getBuildCommandLocation,
|
|
58
|
-
functionsBundling: getFunctionsBundlingLocation,
|
|
59
|
-
coreStep: getCoreStepLocation,
|
|
60
|
-
buildFail: getBuildFailLocation,
|
|
61
|
-
api: getApiLocation,
|
|
62
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
// Ensure error is an `Error` instance.
|
|
2
|
-
// If is an `Error` instance but is missing usual `Error` properties, we make
|
|
3
|
-
// sure its static properties are preserved.
|
|
4
|
-
export const normalizeError = function (error) {
|
|
5
|
-
if (Array.isArray(error)) {
|
|
6
|
-
return normalizeArray(error)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
if (!(error instanceof Error)) {
|
|
10
|
-
return new Error(String(error))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
if (typeof error.message !== 'string') {
|
|
14
|
-
error.message = String(error)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (typeof error.stack !== 'string') {
|
|
18
|
-
Error.captureStackTrace(error, normalizeError)
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
return error
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Some libraries throw arrays of Errors
|
|
25
|
-
const normalizeArray = function (errorArray) {
|
|
26
|
-
const [error, ...errors] = errorArray.map(normalizeError)
|
|
27
|
-
error.errors = errors
|
|
28
|
-
return error
|
|
29
|
-
}
|
package/src/error/parse/parse.js
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
import { serializeObject } from '../../log/serialize.js'
|
|
2
|
-
import { getErrorInfo } from '../info.js'
|
|
3
|
-
import { getTypeInfo } from '../type.js'
|
|
4
|
-
|
|
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'
|
|
10
|
-
|
|
11
|
-
// Add additional type-specific error information
|
|
12
|
-
export const getFullErrorInfo = function ({ error, colors, debug }) {
|
|
13
|
-
const basicErrorInfo = parseErrorInfo(error)
|
|
14
|
-
const {
|
|
15
|
-
message,
|
|
16
|
-
stack,
|
|
17
|
-
errorProps,
|
|
18
|
-
errorInfo,
|
|
19
|
-
errorInfo: { location = {}, plugin = {}, tsConfig },
|
|
20
|
-
severity,
|
|
21
|
-
title,
|
|
22
|
-
stackType,
|
|
23
|
-
locationType,
|
|
24
|
-
showErrorProps,
|
|
25
|
-
rawStack,
|
|
26
|
-
} = basicErrorInfo
|
|
27
|
-
|
|
28
|
-
const titleA = getTitle(title, errorInfo)
|
|
29
|
-
|
|
30
|
-
const { message: messageA, stack: stackA } = getStackInfo({ message, stack, stackType, rawStack, severity, debug })
|
|
31
|
-
|
|
32
|
-
const pluginInfo = getPluginInfo(plugin, location)
|
|
33
|
-
const tsConfigInfo = getTsConfigInfo(tsConfig)
|
|
34
|
-
const locationInfo = getLocationInfo({ stack: stackA, location, locationType })
|
|
35
|
-
const errorPropsA = getErrorProps({ errorProps, showErrorProps, colors })
|
|
36
|
-
|
|
37
|
-
return {
|
|
38
|
-
...basicErrorInfo,
|
|
39
|
-
title: titleA,
|
|
40
|
-
message: messageA,
|
|
41
|
-
tsConfigInfo,
|
|
42
|
-
pluginInfo,
|
|
43
|
-
locationInfo,
|
|
44
|
-
errorProps: errorPropsA,
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Serialize the `tsConfig` error information
|
|
49
|
-
const getTsConfigInfo = function (tsConfig) {
|
|
50
|
-
if (tsConfig === undefined) {
|
|
51
|
-
return
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
return serializeObject(tsConfig)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Parse error instance into all the basic properties containing information
|
|
58
|
-
export const parseErrorInfo = function (error) {
|
|
59
|
-
const { message, stack, ...errorProps } = normalizeError(error)
|
|
60
|
-
const [errorInfo, errorPropsA] = getErrorInfo(errorProps)
|
|
61
|
-
const {
|
|
62
|
-
type,
|
|
63
|
-
severity,
|
|
64
|
-
title,
|
|
65
|
-
group,
|
|
66
|
-
stackType,
|
|
67
|
-
locationType,
|
|
68
|
-
showErrorProps,
|
|
69
|
-
showInBuildLog = true,
|
|
70
|
-
rawStack,
|
|
71
|
-
} = getTypeInfo(errorInfo)
|
|
72
|
-
const basicErrorInfo = {
|
|
73
|
-
message,
|
|
74
|
-
stack,
|
|
75
|
-
errorProps: errorPropsA,
|
|
76
|
-
errorInfo,
|
|
77
|
-
type,
|
|
78
|
-
severity,
|
|
79
|
-
title,
|
|
80
|
-
group,
|
|
81
|
-
stackType,
|
|
82
|
-
locationType,
|
|
83
|
-
showInBuildLog,
|
|
84
|
-
showErrorProps,
|
|
85
|
-
rawStack,
|
|
86
|
-
}
|
|
87
|
-
return basicErrorInfo
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// Retrieve title to print in logs
|
|
91
|
-
const getTitle = function (title, errorInfo) {
|
|
92
|
-
if (typeof title !== 'function') {
|
|
93
|
-
return title
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return title(errorInfo)
|
|
97
|
-
}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
// Retrieve plugin's package.json details to include in error messages.
|
|
2
|
-
// Please note `pluginPackageJson` has been normalized by `normalize-package-data`.
|
|
3
|
-
export const getPluginInfo = function ({ pluginPackageJson = {} }, { packageName, loadedFrom }) {
|
|
4
|
-
if (Object.keys(pluginPackageJson).length === 0) {
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
return Object.entries(FIELDS)
|
|
9
|
-
.map(([name, getField]) => serializeField({ name, getField, pluginPackageJson, packageName, loadedFrom }))
|
|
10
|
-
.filter(Boolean)
|
|
11
|
-
.join('\n')
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Serialize a single package.json field
|
|
15
|
-
const serializeField = function ({ name, getField, pluginPackageJson, packageName, loadedFrom }) {
|
|
16
|
-
const field = getField(pluginPackageJson, { packageName, loadedFrom })
|
|
17
|
-
if (field === undefined) {
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const nameA = `${name}:`.padEnd(NAME_PADDING)
|
|
22
|
-
return `${nameA}${field}`
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const NAME_PADDING = 16
|
|
26
|
-
|
|
27
|
-
const getPackage = function (pluginPackageJson, { packageName }) {
|
|
28
|
-
return packageName
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const getVersion = function ({ version }) {
|
|
32
|
-
if (version === '') {
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return version
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const getHomepage = function (pluginPackageJson = {}, { loadedFrom } = {}) {
|
|
40
|
-
return (
|
|
41
|
-
getRepository(pluginPackageJson) ||
|
|
42
|
-
getNpmLink(pluginPackageJson, { loadedFrom }) ||
|
|
43
|
-
getIssuesLink(pluginPackageJson)
|
|
44
|
-
)
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
const getRepository = function ({ repository: { url } = {} }) {
|
|
48
|
-
return url
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
const getNpmLink = function ({ name }, { loadedFrom }) {
|
|
52
|
-
if (!name || loadedFrom === 'local') {
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
return `https://www.npmjs.com/package/${name}`
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const getIssuesLink = function ({ bugs: { url } = {} }) {
|
|
60
|
-
return url
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// List of package.json to serialize
|
|
64
|
-
const FIELDS = {
|
|
65
|
-
Package: getPackage,
|
|
66
|
-
Version: getVersion,
|
|
67
|
-
Repository: getRepository,
|
|
68
|
-
'npm link': getNpmLink,
|
|
69
|
-
'Report issues': getIssuesLink,
|
|
70
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { inspect } from 'util'
|
|
2
|
-
|
|
3
|
-
import { omit } from '../../utils/omit.js'
|
|
4
|
-
|
|
5
|
-
// In uncaught exceptions, print error static properties
|
|
6
|
-
export const getErrorProps = function ({ errorProps, showErrorProps, colors }) {
|
|
7
|
-
if (!showErrorProps) {
|
|
8
|
-
return
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const errorPropsA = omit(errorProps, CLEANED_ERROR_PROPS)
|
|
12
|
-
|
|
13
|
-
if (Object.keys(errorPropsA).length === 0) {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
return inspect(errorPropsA, { colors, depth: INSPECT_MAX_DEPTH })
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const INSPECT_MAX_DEPTH = 5
|
|
21
|
-
|
|
22
|
-
// Remove error static properties that should not be logged
|
|
23
|
-
const CLEANED_ERROR_PROPS = ['requireStack']
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { THEME } from '../../log/theme.js'
|
|
2
|
-
|
|
3
|
-
// Serialize an error object into a title|body string to print in logs
|
|
4
|
-
export const serializeLogError = function ({
|
|
5
|
-
fullErrorInfo: { title, severity, message, pluginInfo, locationInfo, tsConfigInfo, errorProps },
|
|
6
|
-
}) {
|
|
7
|
-
const body = getBody({ message, pluginInfo, locationInfo, tsConfigInfo, errorProps, severity })
|
|
8
|
-
return { title, body }
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const getBody = function ({ message, pluginInfo, locationInfo, tsConfigInfo, errorProps, severity }) {
|
|
12
|
-
if (severity === 'none') {
|
|
13
|
-
return message
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return Object.entries({
|
|
17
|
-
message,
|
|
18
|
-
tsConfigInfo,
|
|
19
|
-
pluginInfo,
|
|
20
|
-
locationInfo,
|
|
21
|
-
errorProps,
|
|
22
|
-
})
|
|
23
|
-
.filter(blockHasValue)
|
|
24
|
-
.map(serializeBlock)
|
|
25
|
-
.join('\n\n')
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const blockHasValue = function ([, value]) {
|
|
29
|
-
return value !== undefined
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const serializeBlock = function ([key, value]) {
|
|
33
|
-
return `${THEME.errorSubHeader(LOG_BLOCK_NAMES[key])}\n${value}`
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const LOG_BLOCK_NAMES = {
|
|
37
|
-
message: 'Error message',
|
|
38
|
-
pluginInfo: 'Plugin details',
|
|
39
|
-
locationInfo: 'Error location',
|
|
40
|
-
tsConfigInfo: 'TypeScript configuration',
|
|
41
|
-
errorProps: 'Error properties',
|
|
42
|
-
}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
// Serialize an error object to `statuses` properties
|
|
2
|
-
export const serializeErrorStatus = function ({ fullErrorInfo: { title, message, locationInfo, errorProps }, state }) {
|
|
3
|
-
const text = getText({ locationInfo, errorProps })
|
|
4
|
-
return { state, title, summary: message, text }
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const getText = function ({ locationInfo, errorProps }) {
|
|
8
|
-
const parts = [locationInfo, getErrorProps(errorProps)].filter(Boolean)
|
|
9
|
-
|
|
10
|
-
if (parts.length === 0) {
|
|
11
|
-
return
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return parts.join('\n\n')
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const getErrorProps = function (errorProps) {
|
|
18
|
-
if (errorProps === undefined) {
|
|
19
|
-
return
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return `Error properties:\n${errorProps}`
|
|
23
|
-
}
|