@netlify/build 0.5.0 → 1.0.0-dl-test
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 +392 -0
- package/lib/core/config.js +124 -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 +17 -0
- package/lib/core/flags.js +206 -0
- package/lib/core/lingering.js +68 -0
- package/lib/core/main.js +114 -0
- package/lib/core/missing_side_file.js +17 -0
- package/lib/core/normalize_flags.js +62 -0
- package/lib/core/report_metrics.js +17 -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/lib/error/cancel.js +7 -0
- package/lib/error/colors.js +9 -0
- package/lib/error/handle.js +44 -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 +29 -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 +12 -0
- package/lib/log/header_func.js +13 -0
- package/lib/log/logger.js +140 -0
- package/lib/log/messages/compatibility.js +120 -0
- package/lib/log/messages/config.js +91 -0
- package/lib/log/messages/core.js +49 -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/lib/log/messages/plugins.js +25 -0
- package/lib/log/messages/status.js +14 -0
- package/lib/log/messages/steps.js +18 -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/lib/plugins/error.js +46 -0
- package/lib/plugins/events.js +12 -0
- 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 +55 -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/lib/plugins_core/deploy/manifest.yml +1 -0
- package/lib/plugins_core/edge_functions/index.js +106 -0
- package/lib/plugins_core/edge_functions/lib/error.js +17 -0
- package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +14 -0
- package/lib/plugins_core/functions/error.js +123 -0
- package/lib/plugins_core/functions/feature_flags.js +5 -0
- package/lib/plugins_core/functions/index.js +137 -0
- package/lib/plugins_core/functions/utils.js +45 -0
- package/lib/plugins_core/functions/zisi.js +64 -0
- package/lib/plugins_core/functions_install/index.js +10 -0
- package/lib/plugins_core/list.js +20 -0
- package/lib/plugins_core/save_artifacts/index.js +33 -0
- package/lib/report/statsd.js +56 -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 +62 -0
- package/lib/steps/error.js +65 -0
- package/lib/steps/get.js +44 -0
- package/lib/steps/plugin.js +55 -0
- package/lib/steps/return.js +27 -0
- package/lib/steps/run_core_steps.js +117 -0
- package/lib/steps/run_step.js +200 -0
- package/lib/steps/run_steps.js +102 -0
- package/lib/steps/update_config.js +66 -0
- package/lib/telemetry/main.js +94 -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 +30 -0
- package/lib/utils/errors.js +13 -0
- package/lib/utils/json.js +10 -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 +119 -56
- package/types/config/build.d.ts +52 -0
- package/types/config/functions.d.ts +36 -0
- package/types/config/inputs.d.ts +7 -0
- package/types/config/netlify_config.d.ts +58 -0
- package/types/index.d.ts +7 -0
- package/types/netlify_event_handler.d.ts +29 -0
- package/types/netlify_plugin.d.ts +29 -0
- package/types/netlify_plugin_constants.d.ts +51 -0
- package/types/netlify_plugin_options.d.ts +23 -0
- package/types/options/index.d.ts +1 -0
- package/types/options/netlify_plugin_build_util.d.ts +7 -0
- package/types/options/netlify_plugin_cache_util.d.ts +39 -0
- package/types/options/netlify_plugin_functions_util.d.ts +32 -0
- package/types/options/netlify_plugin_git_util.d.ts +41 -0
- package/types/options/netlify_plugin_run_util.d.ts +24 -0
- package/types/options/netlify_plugin_status_util.d.ts +24 -0
- package/types/options/netlify_plugin_utils.d.ts +15 -0
- package/types/utils/json_value.d.ts +1 -0
- package/types/utils/many.d.ts +6 -0
- package/README.md +0 -3
- package/src/core/bin.js +0 -139
- package/src/core/commands.js +0 -304
- package/src/core/config.js +0 -130
- package/src/core/constants.js +0 -86
- package/src/core/dry.js +0 -23
- package/src/core/main.js +0 -196
- package/src/env/changes.js +0 -49
- package/src/env/git.js +0 -27
- package/src/env/main.js +0 -97
- package/src/env/metadata.js +0 -81
- package/src/error/api.js +0 -32
- package/src/error/build.js +0 -32
- package/src/error/cancel.js +0 -22
- package/src/error/colors.js +0 -13
- package/src/error/info.js +0 -12
- package/src/error/monitor/normalize.js +0 -50
- package/src/error/monitor/print.js +0 -43
- package/src/error/monitor/report.js +0 -140
- package/src/error/monitor/start.js +0 -50
- package/src/error/parse/clean_stack.js +0 -86
- package/src/error/parse/location.js +0 -50
- package/src/error/parse/parse.js +0 -87
- package/src/error/parse/plugin.js +0 -68
- package/src/error/parse/properties.js +0 -20
- package/src/error/parse/serialize_log.js +0 -46
- package/src/error/parse/serialize_status.js +0 -28
- package/src/error/parse/stack.js +0 -45
- package/src/error/process.js +0 -13
- package/src/error/type.js +0 -143
- package/src/install/functions.js +0 -62
- package/src/install/local.js +0 -74
- package/src/install/main.js +0 -103
- package/src/install/missing.js +0 -86
- package/src/log/colors.js +0 -59
- package/src/log/description.js +0 -38
- package/src/log/header.js +0 -19
- package/src/log/logger.js +0 -55
- package/src/log/main.js +0 -290
- package/src/log/old_version.js +0 -45
- package/src/log/serialize.js +0 -15
- package/src/log/stream.js +0 -15
- package/src/log/theme.js +0 -32
- package/src/log/timer.js +0 -28
- package/src/plugins/child/api.js +0 -59
- package/src/plugins/child/error.js +0 -39
- package/src/plugins/child/load.js +0 -37
- package/src/plugins/child/logic.js +0 -31
- package/src/plugins/child/main.js +0 -48
- package/src/plugins/child/run.js +0 -30
- package/src/plugins/child/status.js +0 -53
- package/src/plugins/child/utils.js +0 -43
- package/src/plugins/child/validate.js +0 -71
- package/src/plugins/error.js +0 -73
- package/src/plugins/events.js +0 -77
- package/src/plugins/ipc.js +0 -136
- package/src/plugins/load.js +0 -66
- package/src/plugins/manifest/check.js +0 -80
- package/src/plugins/manifest/load.js +0 -54
- package/src/plugins/manifest/main.js +0 -24
- package/src/plugins/manifest/path.js +0 -12
- package/src/plugins/manifest/validate.js +0 -136
- package/src/plugins/node_version.js +0 -74
- package/src/plugins/options.js +0 -78
- package/src/plugins/package.js +0 -17
- package/src/plugins/resolve.js +0 -159
- package/src/plugins/spawn.js +0 -82
- package/src/plugins_core/cache/manifest.yml +0 -1
- package/src/plugins_core/cache/plugin.js +0 -75
- package/src/plugins_core/functions/manifest.yml +0 -1
- package/src/plugins_core/functions/plugin.js +0 -37
- package/src/plugins_core/functions_install/plugin.js +0 -14
- package/src/plugins_core/main.js +0 -38
- package/src/status/add.js +0 -56
- package/src/status/colors.js +0 -25
- package/src/status/report.js +0 -57
- package/src/telemetry/complete.js +0 -49
- package/src/telemetry/request.js +0 -28
- package/src/telemetry/track.js +0 -33
- package/src/utils/omit.js +0 -8
- package/src/utils/polyfills.js +0 -3
- package/src/utils/remove_falsy.js +0 -12
- package/src/utils/resolve.js +0 -39
- /package/{src → lib}/plugins_core/functions_install/manifest.yml +0 -0
package/src/log/main.js
DELETED
|
@@ -1,290 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
env: { NETLIFY_BUILD_DEBUG },
|
|
3
|
-
} = require('process')
|
|
4
|
-
|
|
5
|
-
const { arrowDown } = require('figures')
|
|
6
|
-
const prettyMs = require('pretty-ms')
|
|
7
|
-
|
|
8
|
-
const { name, version } = require('../../package.json')
|
|
9
|
-
const { serializeLogError } = require('../error/parse/serialize_log')
|
|
10
|
-
const { omit } = require('../utils/omit')
|
|
11
|
-
|
|
12
|
-
const { getCommandDescription, getBuildCommandDescription, getPluginOrigin } = require('./description')
|
|
13
|
-
const {
|
|
14
|
-
log,
|
|
15
|
-
logMessage,
|
|
16
|
-
logObject,
|
|
17
|
-
logArray,
|
|
18
|
-
logHeader,
|
|
19
|
-
logErrorHeader,
|
|
20
|
-
logSubHeader,
|
|
21
|
-
logErrorSubHeader,
|
|
22
|
-
} = require('./logger')
|
|
23
|
-
const { THEME } = require('./theme')
|
|
24
|
-
|
|
25
|
-
const logBuildStart = function() {
|
|
26
|
-
logHeader('Netlify Build')
|
|
27
|
-
logSubHeader('Version')
|
|
28
|
-
logMessage(`${name} ${version}`)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const logFlags = function(flags) {
|
|
32
|
-
const hiddenFlags = flags.mode === 'buildbot' ? [...HIDDEN_FLAGS, 'nodePath'] : HIDDEN_FLAGS
|
|
33
|
-
const flagsA = omit(flags, hiddenFlags)
|
|
34
|
-
logSubHeader('Flags')
|
|
35
|
-
logObject(flagsA)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const HIDDEN_FLAGS = ['token', 'cachedConfig', 'defaultConfig']
|
|
39
|
-
|
|
40
|
-
const logBuildDir = function(buildDir) {
|
|
41
|
-
logSubHeader('Current directory')
|
|
42
|
-
logMessage(buildDir)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const logConfigPath = function(configPath = NO_CONFIG_MESSAGE) {
|
|
46
|
-
logSubHeader('Config file')
|
|
47
|
-
logMessage(configPath)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const NO_CONFIG_MESSAGE = 'No config file was defined: using default values.'
|
|
51
|
-
|
|
52
|
-
const logConfig = function(netlifyConfig) {
|
|
53
|
-
if (!NETLIFY_BUILD_DEBUG) {
|
|
54
|
-
return
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
logSubHeader('Resolved config')
|
|
58
|
-
logObject(simplifyConfig(netlifyConfig))
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const logConfigOnError = function(netlifyConfig) {
|
|
62
|
-
if (netlifyConfig === undefined) {
|
|
63
|
-
return
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
logMessage(THEME.errorSubHeader('Resolved config'))
|
|
67
|
-
logObject(simplifyConfig(netlifyConfig))
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
// The resolved configuration gets assigned some default values (empty objects and arrays)
|
|
71
|
-
// to make it more convenient to use without checking for `undefined`.
|
|
72
|
-
// However those empty values are not useful to users, so we don't log them.
|
|
73
|
-
const simplifyConfig = function({ build: { environment, ...build }, plugins, ...netlifyConfig }) {
|
|
74
|
-
const environmentA = omit(environment, BUILDBOT_ENVIRONMENT)
|
|
75
|
-
const simplifiedBuild = {
|
|
76
|
-
...build,
|
|
77
|
-
...removeEmptyObject(environmentA, 'environment'),
|
|
78
|
-
}
|
|
79
|
-
return {
|
|
80
|
-
...netlifyConfig,
|
|
81
|
-
...removeEmptyObject(simplifiedBuild, 'build'),
|
|
82
|
-
...removeEmptyArray(plugins, 'plugins'),
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// Added by the buildbot. We only want to print environment variables specified
|
|
87
|
-
// by the user.
|
|
88
|
-
const BUILDBOT_ENVIRONMENT = [
|
|
89
|
-
'BRANCH',
|
|
90
|
-
'CONTEXT',
|
|
91
|
-
'DEPLOY_PRIME_URL',
|
|
92
|
-
'DEPLOY_URL',
|
|
93
|
-
'GO_VERSION',
|
|
94
|
-
'NETLIFY_IMAGES_CDN_DOMAIN',
|
|
95
|
-
'URL',
|
|
96
|
-
]
|
|
97
|
-
|
|
98
|
-
const removeEmptyObject = function(object, propName) {
|
|
99
|
-
return Object.keys(object).length === 0 ? {} : { [propName]: object }
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
const removeEmptyArray = function(array, propName) {
|
|
103
|
-
return array.length === 0 ? {} : { [propName]: array }
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
const logContext = function(context) {
|
|
107
|
-
if (context === undefined) {
|
|
108
|
-
return
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
logSubHeader('Context')
|
|
112
|
-
logMessage(context)
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const logInstallMissingPlugins = function(packages) {
|
|
116
|
-
logSubHeader('Installing plugins')
|
|
117
|
-
logArray(packages)
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
const logMissingPluginsWarning = function(packages) {
|
|
121
|
-
logErrorSubHeader('Missing plugins')
|
|
122
|
-
logMessage(
|
|
123
|
-
THEME.errorSubHeader(
|
|
124
|
-
`The following plugins should be installed either via the Netlify app or as a "dependency" inside your project's "package.json"`,
|
|
125
|
-
),
|
|
126
|
-
)
|
|
127
|
-
logArray(packages, { color: THEME.errorSubHeader })
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
const logInstallLocalPluginsDeps = function(localPluginsOptions) {
|
|
131
|
-
const packages = localPluginsOptions.map(getPackage)
|
|
132
|
-
logSubHeader('Installing local plugins dependencies')
|
|
133
|
-
logArray(packages)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const logInstallFunctionDependencies = function() {
|
|
137
|
-
log('Installing functions dependencies')
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const getPackage = function({ package }) {
|
|
141
|
-
return package
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
const logLoadingPlugins = function(pluginsOptions) {
|
|
145
|
-
const loadingPlugins = pluginsOptions.map(getPluginDescription)
|
|
146
|
-
|
|
147
|
-
if (loadingPlugins.length === 0) {
|
|
148
|
-
return
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
logSubHeader('Loading plugins')
|
|
152
|
-
logArray(loadingPlugins)
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
const getPluginDescription = function({ package, packageJson: { version }, loadedFrom, origin }) {
|
|
156
|
-
const versionA = version === undefined ? '' : `@${version}`
|
|
157
|
-
const pluginOrigin = getPluginOrigin(loadedFrom, origin)
|
|
158
|
-
return `${THEME.highlightWords(package)}${versionA} ${pluginOrigin}`
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const logDryRunStart = function(eventWidth, commandsCount) {
|
|
162
|
-
const columnWidth = getDryColumnWidth(eventWidth, commandsCount)
|
|
163
|
-
const line = '─'.repeat(columnWidth)
|
|
164
|
-
const secondLine = '─'.repeat(columnWidth)
|
|
165
|
-
|
|
166
|
-
logSubHeader('Netlify Build Commands')
|
|
167
|
-
logMessage(`For more information on build events see the docs https://github.com/netlify/build
|
|
168
|
-
|
|
169
|
-
Running \`netlify build\` will execute this build flow
|
|
170
|
-
|
|
171
|
-
${THEME.header(`┌─${line}─┬─${secondLine}─┐
|
|
172
|
-
│ ${DRY_HEADER_NAMES[0].padEnd(columnWidth)} │ ${DRY_HEADER_NAMES[1].padEnd(columnWidth)} │
|
|
173
|
-
└─${line}─┴─${secondLine}─┘`)}`)
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
const logDryRunCommand = function({ command: { event, package }, index, configPath, eventWidth, commandsCount }) {
|
|
177
|
-
const columnWidth = getDryColumnWidth(eventWidth, commandsCount)
|
|
178
|
-
const line = '─'.repeat(columnWidth)
|
|
179
|
-
const countText = `${index + 1}. `
|
|
180
|
-
const downArrow = commandsCount === index + 1 ? ' ' : ` ${arrowDown}`
|
|
181
|
-
const eventWidthA = columnWidth - countText.length - downArrow.length
|
|
182
|
-
const fullName = getPluginFullName({ package, configPath })
|
|
183
|
-
|
|
184
|
-
logMessage(
|
|
185
|
-
`${THEME.header(`┌─${line}─┐`)}
|
|
186
|
-
${THEME.header(`│ ${countText}${event.padEnd(eventWidthA)}${downArrow} │`)} ${fullName}
|
|
187
|
-
${THEME.header(`└─${line}─┘ `)}`,
|
|
188
|
-
)
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const getPluginFullName = function({ package, configPath }) {
|
|
192
|
-
if (package === undefined) {
|
|
193
|
-
return getBuildCommandDescription(configPath)
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
return `Plugin ${THEME.highlightWords(package)}`
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const getDryColumnWidth = function(eventWidth, commandsCount) {
|
|
200
|
-
const symbolsWidth = `${commandsCount}`.length + 4
|
|
201
|
-
return Math.max(eventWidth + symbolsWidth, DRY_HEADER_NAMES[1].length)
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
const DRY_HEADER_NAMES = ['Event', 'Location']
|
|
205
|
-
|
|
206
|
-
const logDryRunEnd = function() {
|
|
207
|
-
logMessage(`\nIf this looks good to you, run \`netlify build\` to execute the build\n`)
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
const logCommand = function({ event, package, index, configPath, error }) {
|
|
211
|
-
const description = getCommandDescription({ event, package, configPath })
|
|
212
|
-
const logHeaderFunc = error ? logErrorHeader : logHeader
|
|
213
|
-
logHeaderFunc(`${index + 1}. ${description}`)
|
|
214
|
-
logMessage('')
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const logBuildCommandStart = function(buildCommand) {
|
|
218
|
-
log(THEME.highlightWords(`$ ${buildCommand}`))
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
const logCommandSuccess = function() {
|
|
222
|
-
logMessage('')
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
const logTimer = function(durationMs, timerName) {
|
|
226
|
-
const duration = prettyMs(durationMs)
|
|
227
|
-
log(THEME.dimWords(`(${timerName} completed in ${duration})`))
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
const logStatuses = function(statuses) {
|
|
231
|
-
logHeader('Summary')
|
|
232
|
-
statuses.forEach(logStatus)
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
const logStatus = function({ package, title = `Plugin ${package} ran successfully`, summary, text }) {
|
|
236
|
-
const titleA = title.includes(package) ? title : `${package}: ${title}`
|
|
237
|
-
const body = text === undefined ? summary : `${summary}\n${THEME.dimWords(text)}`
|
|
238
|
-
logSubHeader(titleA)
|
|
239
|
-
logMessage(body)
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
const logCacheDir = function(path) {
|
|
243
|
-
logMessage(`Caching ${path}`)
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
const logPluginError = function(error, netlifyConfig) {
|
|
247
|
-
const { title, body } = serializeLogError(error)
|
|
248
|
-
logErrorHeader(title)
|
|
249
|
-
logMessage(`\n${body}\n`)
|
|
250
|
-
logConfigOnError(netlifyConfig)
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
const logBuildError = function(error) {
|
|
254
|
-
const { title, body, isSuccess, netlifyConfig } = serializeLogError(error)
|
|
255
|
-
const logFunction = isSuccess ? logHeader : logErrorHeader
|
|
256
|
-
logFunction(title)
|
|
257
|
-
logMessage(`\n${body}\n`)
|
|
258
|
-
logConfigOnError(netlifyConfig)
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
const logBuildSuccess = function() {
|
|
262
|
-
logHeader('Netlify Build Complete')
|
|
263
|
-
logMessage('')
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
module.exports = {
|
|
267
|
-
logBuildStart,
|
|
268
|
-
logFlags,
|
|
269
|
-
logBuildDir,
|
|
270
|
-
logConfigPath,
|
|
271
|
-
logConfig,
|
|
272
|
-
logContext,
|
|
273
|
-
logInstallMissingPlugins,
|
|
274
|
-
logMissingPluginsWarning,
|
|
275
|
-
logInstallLocalPluginsDeps,
|
|
276
|
-
logInstallFunctionDependencies,
|
|
277
|
-
logLoadingPlugins,
|
|
278
|
-
logDryRunStart,
|
|
279
|
-
logDryRunCommand,
|
|
280
|
-
logDryRunEnd,
|
|
281
|
-
logCommand,
|
|
282
|
-
logBuildCommandStart,
|
|
283
|
-
logCommandSuccess,
|
|
284
|
-
logTimer,
|
|
285
|
-
logStatuses,
|
|
286
|
-
logCacheDir,
|
|
287
|
-
logPluginError,
|
|
288
|
-
logBuildError,
|
|
289
|
-
logBuildSuccess,
|
|
290
|
-
}
|
package/src/log/old_version.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
env: { NETLIFY_BUILD_TEST },
|
|
3
|
-
stdout,
|
|
4
|
-
} = require('process')
|
|
5
|
-
|
|
6
|
-
const readPkgUp = require('read-pkg-up')
|
|
7
|
-
const UpdateNotifier = require('update-notifier')
|
|
8
|
-
|
|
9
|
-
// Many build errors happen in local builds that do not use the latest version
|
|
10
|
-
// of `@netlify/build`. We print a warning message on those.
|
|
11
|
-
// We only print this when Netlify CLI has been used. Programmatic usage might
|
|
12
|
-
// come from a deep dependency calling `@netlify/build` and user might not be
|
|
13
|
-
// able to take any upgrade action, making the message noisy.
|
|
14
|
-
const logOldCliVersionError = async function(mode) {
|
|
15
|
-
if (mode !== 'cli') {
|
|
16
|
-
return
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const pkg = await getPkg()
|
|
20
|
-
UpdateNotifier({ pkg, updateCheckInterval: 1 }).notify({
|
|
21
|
-
message: OLD_VERSION_MESSAGE,
|
|
22
|
-
shouldNotifyInNpmScript: true,
|
|
23
|
-
})
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const getPkg = async function() {
|
|
27
|
-
const { packageJson } = await readPkgUp({ cwd: __dirname, normalize: false })
|
|
28
|
-
|
|
29
|
-
// TODO: Find a way to test this without injecting code in the `src/`
|
|
30
|
-
if (NETLIFY_BUILD_TEST) {
|
|
31
|
-
// `update-notifier` does not do anything if not in a TTY.
|
|
32
|
-
// In tests, we need to monkey patch this
|
|
33
|
-
stdout.isTTY = true
|
|
34
|
-
|
|
35
|
-
return { ...packageJson, version: '0.0.1' }
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return packageJson
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const OLD_VERSION_MESSAGE = `Please update netlify-cli to its latest version.
|
|
42
|
-
If netlify-cli is already the latest version,
|
|
43
|
-
please update your dependencies lock file instead.`
|
|
44
|
-
|
|
45
|
-
module.exports = { logOldCliVersionError }
|
package/src/log/serialize.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const { dump, JSON_SCHEMA } = require('js-yaml')
|
|
2
|
-
|
|
3
|
-
const serializeObject = function(object) {
|
|
4
|
-
return dump(object, { schema: JSON_SCHEMA, noRefs: true, sortKeys: true, lineWidth: Infinity }).trimRight()
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const serializeArray = function(array) {
|
|
8
|
-
return array.map(addDash).join('\n')
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const addDash = function(string) {
|
|
12
|
-
return ` - ${string}`
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module.exports = { serializeObject, serializeArray }
|
package/src/log/stream.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
const { stdout, stderr } = require('process')
|
|
2
|
-
|
|
3
|
-
// Start streaming Bash command or plugin command output
|
|
4
|
-
const pipeOutput = function(childProcess) {
|
|
5
|
-
childProcess.stdout.pipe(stdout)
|
|
6
|
-
childProcess.stderr.pipe(stderr)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Stop streaming/buffering Bash command or plugin command output
|
|
10
|
-
const unpipeOutput = function(childProcess) {
|
|
11
|
-
childProcess.stdout.unpipe(stdout)
|
|
12
|
-
childProcess.stderr.unpipe(stderr)
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module.exports = { pipeOutput, unpipeOutput }
|
package/src/log/theme.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
cyanBright: { bold: cyanBrightBold },
|
|
3
|
-
cyan: { bold: cyanBold },
|
|
4
|
-
cyan,
|
|
5
|
-
redBright: { bold: redBrightBold },
|
|
6
|
-
red: { bold: redBold },
|
|
7
|
-
red,
|
|
8
|
-
gray,
|
|
9
|
-
} = require('chalk')
|
|
10
|
-
|
|
11
|
-
// Color theme. Please use this instead of requiring chalk directly, to ensure
|
|
12
|
-
// consistent colors.
|
|
13
|
-
const THEME = {
|
|
14
|
-
// Main headers
|
|
15
|
-
header: cyanBrightBold,
|
|
16
|
-
// Single lines used as subheaders
|
|
17
|
-
subHeader: cyanBold,
|
|
18
|
-
// Main headers indicating an error
|
|
19
|
-
errorHeader: redBrightBold,
|
|
20
|
-
// Single lines used as subheaders indicating an error
|
|
21
|
-
errorSubHeader: redBold,
|
|
22
|
-
// Non-headers indicating an error
|
|
23
|
-
errorLine: red,
|
|
24
|
-
// One of several words that should be highlighted inside a line
|
|
25
|
-
highlightWords: cyan,
|
|
26
|
-
// One of several words that should be dimmed inside a line
|
|
27
|
-
dimWords: gray,
|
|
28
|
-
// No colors
|
|
29
|
-
none: string => string,
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
module.exports = { THEME }
|
package/src/log/timer.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
const { hrtime } = require('process')
|
|
2
|
-
|
|
3
|
-
const { logTimer } = require('./main')
|
|
4
|
-
|
|
5
|
-
// Starts a timer
|
|
6
|
-
const startTimer = function() {
|
|
7
|
-
return hrtime()
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// Stops a timer
|
|
11
|
-
const endTimerDuration = function([startSecs, startNsecs]) {
|
|
12
|
-
const [endSecs, endNsecs] = hrtime()
|
|
13
|
-
const durationNs = (endSecs - startSecs) * NANOSECS_TO_SECS + endNsecs - startNsecs
|
|
14
|
-
const durationMs = Math.ceil(durationNs / NANOSECS_TO_MSECS)
|
|
15
|
-
return durationMs
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Ends a timer and prints the result on console
|
|
19
|
-
const endTimer = function(hrTime, timerName) {
|
|
20
|
-
const durationMs = endTimerDuration(hrTime)
|
|
21
|
-
logTimer(durationMs, timerName)
|
|
22
|
-
return durationMs
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const NANOSECS_TO_SECS = 1e9
|
|
26
|
-
const NANOSECS_TO_MSECS = 1e6
|
|
27
|
-
|
|
28
|
-
module.exports = { startTimer, endTimer }
|
package/src/plugins/child/api.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
env: { NETLIFY_BUILD_API_CLIENT },
|
|
3
|
-
} = require('process')
|
|
4
|
-
|
|
5
|
-
const NetlifyAPI = require('netlify')
|
|
6
|
-
|
|
7
|
-
const { failBuild } = require('../error')
|
|
8
|
-
|
|
9
|
-
// Retrieve Netlify API client, providing a authentication token was provided
|
|
10
|
-
const getApiClient = function({ manifest: { scopes = DEFAULT_SCOPES }, token }) {
|
|
11
|
-
// This feature is not currently finished due to lack of API support
|
|
12
|
-
// See https://github.com/netlify/build/issues/585
|
|
13
|
-
if (NETLIFY_BUILD_API_CLIENT !== '1') {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (!token) {
|
|
18
|
-
if (scopes.length !== 0) {
|
|
19
|
-
failBuild('This plugin requires a Netlify API authentication token')
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const api = new NetlifyAPI(token)
|
|
26
|
-
|
|
27
|
-
disableApiMethods(api, scopes)
|
|
28
|
-
|
|
29
|
-
return api
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const DEFAULT_SCOPES = []
|
|
33
|
-
|
|
34
|
-
// Redact API methods to scopes
|
|
35
|
-
const disableApiMethods = function(api, scopes) {
|
|
36
|
-
if (scopes.includes('*')) {
|
|
37
|
-
return
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
API_METHODS.filter(method => !scopes.includes(method)).forEach(method => {
|
|
41
|
-
api[method] = disabledApiMethod.bind(null, method)
|
|
42
|
-
})
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const getApiMethods = function() {
|
|
46
|
-
return NetlifyAPI.methods.map(getApiMethod)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const getApiMethod = function({ operationId }) {
|
|
50
|
-
return operationId
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const API_METHODS = getApiMethods()
|
|
54
|
-
|
|
55
|
-
const disabledApiMethod = async function(method) {
|
|
56
|
-
failBuild(`This plugin is not authorized to use "api.${method}". Please update the plugin scopes.`)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
module.exports = { getApiClient, API_METHODS }
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
// eslint-disable-next-line import/order
|
|
2
|
-
const logProcessErrors = require('log-process-errors')
|
|
3
|
-
|
|
4
|
-
const { hasColors } = require('../../log/colors')
|
|
5
|
-
const { isBuildError, ERROR_TYPE_SYM } = require('../error')
|
|
6
|
-
const { sendEventToParent } = require('../ipc')
|
|
7
|
-
|
|
8
|
-
// Handle any top-level error and communicate it back to parent
|
|
9
|
-
const handleError = async function({
|
|
10
|
-
name,
|
|
11
|
-
message,
|
|
12
|
-
stack,
|
|
13
|
-
[ERROR_TYPE_SYM]: type = DEFAULT_ERROR_TYPE,
|
|
14
|
-
...errorProps
|
|
15
|
-
}) {
|
|
16
|
-
await sendEventToParent('error', { name, message, stack, type, errorProps })
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const DEFAULT_ERROR_TYPE = 'pluginInternal'
|
|
20
|
-
|
|
21
|
-
// On uncaught exceptions and unhandled rejections, print the stack trace.
|
|
22
|
-
// Also, prevent child processes from crashing on uncaught exceptions.
|
|
23
|
-
const handleProcessErrors = function() {
|
|
24
|
-
logProcessErrors({ log: handleProcessError, colors: hasColors(), exitOn: [], level: { multipleResolves: 'silent' } })
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const handleProcessError = async function(error, level, originalError) {
|
|
28
|
-
if (level !== 'error') {
|
|
29
|
-
console[level](error)
|
|
30
|
-
return
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// Do not use log-process-errors prettification with errors thrown by `utils.build.*`
|
|
34
|
-
const errorA = isBuildError(originalError) ? originalError : error
|
|
35
|
-
|
|
36
|
-
await handleError(errorA)
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
module.exports = { handleError, handleProcessErrors }
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
const { getApiClient } = require('./api')
|
|
2
|
-
const { getLogic } = require('./logic')
|
|
3
|
-
const { validatePlugin } = require('./validate')
|
|
4
|
-
|
|
5
|
-
// Load context passed to every plugin method.
|
|
6
|
-
// This also requires the plugin file and fire its top-level function.
|
|
7
|
-
// This also validates the plugin.
|
|
8
|
-
// Do it when parent requests it using the `load` event.
|
|
9
|
-
// Also figure out the list of plugin commands. This is also passed to the parent.
|
|
10
|
-
const load = function(payload) {
|
|
11
|
-
const logic = getLogic(payload)
|
|
12
|
-
|
|
13
|
-
validatePlugin(logic)
|
|
14
|
-
|
|
15
|
-
const pluginCommands = getPluginCommands(logic)
|
|
16
|
-
|
|
17
|
-
const context = getContext(pluginCommands, payload)
|
|
18
|
-
return { pluginCommands, context }
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const getPluginCommands = function(logic) {
|
|
22
|
-
return Object.entries(logic)
|
|
23
|
-
.filter(isEventHandler)
|
|
24
|
-
.map(([event, method]) => ({ event, method }))
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const isEventHandler = function([, value]) {
|
|
28
|
-
return typeof value === 'function'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Retrieve context passed to every event handler
|
|
32
|
-
const getContext = function(pluginCommands, { manifest, inputs, netlifyConfig, constants, utilsData, token }) {
|
|
33
|
-
const api = getApiClient({ manifest, token })
|
|
34
|
-
return { pluginCommands, api, utilsData, constants, inputs, netlifyConfig }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
module.exports = { load }
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
// Require the plugin file and fire its top-level function.
|
|
2
|
-
// The returned object is the `logic` which includes all event handlers.
|
|
3
|
-
const getLogic = function({ pluginPath, inputs }) {
|
|
4
|
-
const logic = requireLogic(pluginPath)
|
|
5
|
-
const logicA = loadLogic({ logic, inputs })
|
|
6
|
-
return logicA
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const requireLogic = function(pluginPath) {
|
|
10
|
-
try {
|
|
11
|
-
return require(pluginPath)
|
|
12
|
-
} catch (error) {
|
|
13
|
-
error.message = `Could not import plugin:\n${error.message}`
|
|
14
|
-
throw error
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const loadLogic = function({ logic, inputs }) {
|
|
19
|
-
if (typeof logic !== 'function') {
|
|
20
|
-
return logic
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
try {
|
|
24
|
-
return logic(inputs)
|
|
25
|
-
} catch (error) {
|
|
26
|
-
error.message = `Could not load plugin:\n${error.message}`
|
|
27
|
-
throw error
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = { getLogic }
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
require('../../utils/polyfills')
|
|
2
|
-
|
|
3
|
-
// This needs to be done before `chalk` is loaded
|
|
4
|
-
// Note: `chalk` is also required by some of our dependencies.
|
|
5
|
-
// eslint-disable-next-line import/order
|
|
6
|
-
const { setColorLevel } = require('../../log/colors')
|
|
7
|
-
setColorLevel()
|
|
8
|
-
|
|
9
|
-
const { sendEventToParent, getEventsFromParent } = require('../ipc')
|
|
10
|
-
|
|
11
|
-
const { handleProcessErrors, handleError } = require('./error')
|
|
12
|
-
const { load } = require('./load')
|
|
13
|
-
const { run } = require('./run')
|
|
14
|
-
|
|
15
|
-
// Boot plugin child process.
|
|
16
|
-
const bootPlugin = async function() {
|
|
17
|
-
try {
|
|
18
|
-
handleProcessErrors()
|
|
19
|
-
|
|
20
|
-
const state = {}
|
|
21
|
-
// We need to fire them in parallel because `process.send()` can be slow
|
|
22
|
-
// to await, i.e. parent might send `load` event before child `ready` event
|
|
23
|
-
// returns.
|
|
24
|
-
await Promise.all([handleEvents(state), sendEventToParent('ready')])
|
|
25
|
-
} catch (error) {
|
|
26
|
-
await handleError(error)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Wait for events from parent to perform plugin methods
|
|
31
|
-
const handleEvents = async function(state) {
|
|
32
|
-
await getEventsFromParent((callId, eventName, payload) => handleEvent(callId, eventName, payload, state))
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Each event can pass `context` information to the next event
|
|
36
|
-
const handleEvent = async function(callId, eventName, payload, state) {
|
|
37
|
-
try {
|
|
38
|
-
const { context, ...response } = await EVENTS[eventName](payload, state.context)
|
|
39
|
-
state.context = { ...state.context, ...context }
|
|
40
|
-
await sendEventToParent(callId, response)
|
|
41
|
-
} catch (error) {
|
|
42
|
-
await handleError(error)
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const EVENTS = { load, run }
|
|
47
|
-
|
|
48
|
-
bootPlugin()
|
package/src/plugins/child/run.js
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
const { getNewEnvChanges, setEnvChanges } = require('../../env/changes.js')
|
|
2
|
-
const { setOldProperty } = require('../error')
|
|
3
|
-
|
|
4
|
-
const { getUtils } = require('./utils')
|
|
5
|
-
|
|
6
|
-
// Run a specific plugin event handler
|
|
7
|
-
const run = async function(
|
|
8
|
-
{ event, error, envChanges },
|
|
9
|
-
{ pluginCommands, api, utilsData, constants, inputs, netlifyConfig },
|
|
10
|
-
) {
|
|
11
|
-
const { method } = pluginCommands.find(pluginCommand => pluginCommand.event === event)
|
|
12
|
-
const runState = {}
|
|
13
|
-
const utils = getUtils({ utilsData, constants, runState })
|
|
14
|
-
const runOptions = { api, utils, constants, inputs, netlifyConfig, error }
|
|
15
|
-
validateOldSyntax(runOptions)
|
|
16
|
-
|
|
17
|
-
const envBefore = setEnvChanges(envChanges)
|
|
18
|
-
await method(runOptions)
|
|
19
|
-
const newEnvChanges = getNewEnvChanges(envBefore)
|
|
20
|
-
return { ...runState, newEnvChanges }
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Backward compatibility warnings. Non-enumerable.
|
|
24
|
-
// TODO: remove once no plugins is doing this anymore.
|
|
25
|
-
const validateOldSyntax = function(runOptions) {
|
|
26
|
-
setOldProperty(runOptions, 'pluginConfig', 'The "pluginConfig" argument has been renamed to "inputs"')
|
|
27
|
-
setOldProperty(runOptions.constants, 'BUILD_DIR', 'The "BUILD_DIR" argument has been renamed to "PUBLISH_DIR"')
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
module.exports = { run }
|