@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/error/type.js
DELETED
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
// Retrieve error-type specific information
|
|
2
|
-
const getTypeInfo = function({ type }) {
|
|
3
|
-
const typeA = TYPES[type] === undefined ? DEFAULT_TYPE : type
|
|
4
|
-
return { type: typeA, state: DEFAULT_STATE, ...TYPES[typeA] }
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
// List of error types, and their related properties
|
|
8
|
-
// Related to build error logs:
|
|
9
|
-
// - `title`: main title shown in build error logs and in the UI (statuses)
|
|
10
|
-
// - `locationType`: retrieve a human-friendly location of the error, printed
|
|
11
|
-
// in build error logs
|
|
12
|
-
// - `isSuccess`: `true` when this should not be reported as an error
|
|
13
|
-
// - `showErrorProps`: `true` when the `Error` instance static properties
|
|
14
|
-
// should be printed in build error logs. Only useful when the `Error`
|
|
15
|
-
// instance was not created by us.
|
|
16
|
-
// - `rawStack`: `true` when the stack trace should be cleaned up
|
|
17
|
-
// - `stackType`: how the stack trace should appear in build error logs:
|
|
18
|
-
// - `none`: not printed
|
|
19
|
-
// - `stack`: printed as is
|
|
20
|
-
// - `message`: printed as is, but taken from `error.message`.
|
|
21
|
-
// Used when `error.stack` is not being correct due to the error being
|
|
22
|
-
// passed between different processes.
|
|
23
|
-
// Related to error statuses:
|
|
24
|
-
// - `state`: error status state. Defaults to `failed_build`
|
|
25
|
-
// Related to Bugsnag:
|
|
26
|
-
// - `group`: main title shown in Bugsnag. Also used to group errors together
|
|
27
|
-
// in Bugsnag, combined with `error.message`.
|
|
28
|
-
// Defaults to `title`.
|
|
29
|
-
// - `severity`: Bugsnag error severity:
|
|
30
|
-
// - `info`: user error
|
|
31
|
-
// - `warning`: plugin author error, or possible system error
|
|
32
|
-
// - `error`: likely system error
|
|
33
|
-
const TYPES = {
|
|
34
|
-
// User configuration error (`@netlify/config`, wrong Node.js version)
|
|
35
|
-
resolveConfig: {
|
|
36
|
-
title: 'Configuration error',
|
|
37
|
-
stackType: 'none',
|
|
38
|
-
severity: 'info',
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
// User misconfigured a plugin
|
|
42
|
-
pluginInput: {
|
|
43
|
-
title: ({ location: { package, input } }) => `Plugin "${package}" invalid input "${input}"`,
|
|
44
|
-
stackType: 'none',
|
|
45
|
-
locationType: 'buildFail',
|
|
46
|
-
severity: 'info',
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
// `build.command` non-0 exit code
|
|
50
|
-
buildCommand: {
|
|
51
|
-
title: '"build.command" failed',
|
|
52
|
-
group: ({ location: { buildCommand } }) => buildCommand,
|
|
53
|
-
stackType: 'message',
|
|
54
|
-
locationType: 'buildCommand',
|
|
55
|
-
severity: 'info',
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
// Plugin called `utils.build.failBuild()`
|
|
59
|
-
failBuild: {
|
|
60
|
-
title: ({ location: { package } }) => `Plugin "${package}" failed`,
|
|
61
|
-
stackType: 'stack',
|
|
62
|
-
locationType: 'buildFail',
|
|
63
|
-
severity: 'info',
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
// Plugin called `utils.build.failPlugin()`
|
|
67
|
-
failPlugin: {
|
|
68
|
-
title: ({ location: { package } }) => `Plugin "${package}" failed`,
|
|
69
|
-
stackType: 'stack',
|
|
70
|
-
locationType: 'buildFail',
|
|
71
|
-
severity: 'info',
|
|
72
|
-
state: 'failed_plugin',
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
// Plugin called `utils.build.cancelBuild()`
|
|
76
|
-
cancelBuild: {
|
|
77
|
-
title: ({ location: { package } }) => `Build canceled by ${package}`,
|
|
78
|
-
stackType: 'stack',
|
|
79
|
-
locationType: 'buildFail',
|
|
80
|
-
isSuccess: true,
|
|
81
|
-
severity: 'info',
|
|
82
|
-
state: 'canceled_build',
|
|
83
|
-
},
|
|
84
|
-
|
|
85
|
-
// Plugin has an invalid shape
|
|
86
|
-
pluginValidation: {
|
|
87
|
-
title: ({ location: { package } }) => `Plugin "${package}" internal error`,
|
|
88
|
-
stackType: 'stack',
|
|
89
|
-
locationType: 'buildFail',
|
|
90
|
-
severity: 'warning',
|
|
91
|
-
},
|
|
92
|
-
|
|
93
|
-
// Plugin threw an uncaught exception
|
|
94
|
-
pluginInternal: {
|
|
95
|
-
title: ({ location: { package } }) => `Plugin "${package}" internal error`,
|
|
96
|
-
stackType: 'stack',
|
|
97
|
-
showErrorProps: true,
|
|
98
|
-
rawStack: true,
|
|
99
|
-
locationType: 'buildFail',
|
|
100
|
-
severity: 'warning',
|
|
101
|
-
},
|
|
102
|
-
|
|
103
|
-
// Bug while orchestrating child processes
|
|
104
|
-
ipc: {
|
|
105
|
-
title: ({ location: { package } }) => `Plugin "${package}" internal error`,
|
|
106
|
-
stackType: 'none',
|
|
107
|
-
locationType: 'buildFail',
|
|
108
|
-
severity: 'warning',
|
|
109
|
-
},
|
|
110
|
-
|
|
111
|
-
// Error while installing user packages (missing plugins, local plugins or functions dependencies)
|
|
112
|
-
dependencies: {
|
|
113
|
-
title: 'Dependencies installation error',
|
|
114
|
-
stackType: 'none',
|
|
115
|
-
severity: 'warning',
|
|
116
|
-
},
|
|
117
|
-
|
|
118
|
-
// Request error when `@netlify/build` was calling Netlify API
|
|
119
|
-
api: {
|
|
120
|
-
title: ({ location: { endpoint } }) => `API error on "${endpoint}"`,
|
|
121
|
-
stackType: 'message',
|
|
122
|
-
showErrorProps: true,
|
|
123
|
-
locationType: 'api',
|
|
124
|
-
severity: 'error',
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
// `@netlify/build` threw an uncaught exception
|
|
128
|
-
exception: {
|
|
129
|
-
title: 'Core internal error',
|
|
130
|
-
stackType: 'stack',
|
|
131
|
-
showErrorProps: true,
|
|
132
|
-
rawStack: true,
|
|
133
|
-
severity: 'error',
|
|
134
|
-
},
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// When no error type matches, it's an uncaught exception, i.e. a bug
|
|
138
|
-
const DEFAULT_TYPE = 'exception'
|
|
139
|
-
|
|
140
|
-
// When no `state` is provided
|
|
141
|
-
const DEFAULT_STATE = 'failed_build'
|
|
142
|
-
|
|
143
|
-
module.exports = { getTypeInfo }
|
package/src/install/functions.js
DELETED
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
const { dirname, resolve } = require('path')
|
|
2
|
-
|
|
3
|
-
const readdirp = require('readdirp')
|
|
4
|
-
|
|
5
|
-
const { addErrorInfo } = require('../error/info')
|
|
6
|
-
const { logInstallFunctionDependencies } = require('../log/main')
|
|
7
|
-
|
|
8
|
-
const { installDependencies } = require('./main')
|
|
9
|
-
|
|
10
|
-
// Install dependencies of Netlify Functions
|
|
11
|
-
const installFunctionDependencies = async function(functionsSrc, isLocal) {
|
|
12
|
-
const packagePaths = await getPackagePaths(functionsSrc)
|
|
13
|
-
if (packagePaths.length === 0) {
|
|
14
|
-
return
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
logInstallFunctionDependencies()
|
|
18
|
-
|
|
19
|
-
const packageRoots = packagePaths.map(getPackageRoot)
|
|
20
|
-
await Promise.all(packageRoots.map(packageRoot => installDependencies({ packageRoot, isLocal })))
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const getPackagePaths = function(functionsSrc) {
|
|
24
|
-
return readdirp.promise(functionsSrc, { depth: 1, fileFilter: 'package.json' })
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
const getPackageRoot = function({ fullPath }) {
|
|
28
|
-
return dirname(fullPath)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const checkDeprecatedFunctionsInstall = async function(plugins, functionsSrc, buildDir) {
|
|
32
|
-
if (functionsSrc === undefined) {
|
|
33
|
-
return
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const usesNewSyntax = plugins.some(isFunctionsInstallPlugin)
|
|
37
|
-
if (usesNewSyntax) {
|
|
38
|
-
return
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const packagePaths = await getPackagePaths(resolve(buildDir, functionsSrc))
|
|
42
|
-
if (packagePaths.length === 0) {
|
|
43
|
-
return
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const error = new Error(`Please use the plugin "@netlify/plugin-functions-install-core" to install dependencies from the "package.json" inside your "${functionsSrc}" directory.
|
|
47
|
-
Example "netlify.toml":
|
|
48
|
-
|
|
49
|
-
[build]
|
|
50
|
-
functions = "${functionsSrc}"
|
|
51
|
-
|
|
52
|
-
[[plugins]]
|
|
53
|
-
package = "@netlify/plugin-functions-install-core"`)
|
|
54
|
-
addErrorInfo(error, { type: 'resolveConfig' })
|
|
55
|
-
throw error
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
const isFunctionsInstallPlugin = function({ package }) {
|
|
59
|
-
return package === '@netlify/plugin-functions-install-core'
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
module.exports = { installFunctionDependencies, checkDeprecatedFunctionsInstall }
|
package/src/install/local.js
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
const pkgDir = require('pkg-dir')
|
|
2
|
-
|
|
3
|
-
const { addErrorInfo } = require('../error/info')
|
|
4
|
-
const { logInstallLocalPluginsDeps } = require('../log/main')
|
|
5
|
-
|
|
6
|
-
const { installDependencies } = require('./main')
|
|
7
|
-
|
|
8
|
-
// Install dependencies of local plugins.
|
|
9
|
-
const installLocalPluginsDependencies = async function({ plugins, pluginsOptions, buildDir, mode }) {
|
|
10
|
-
const localPluginsOptions = getLocalPluginsOptions(pluginsOptions)
|
|
11
|
-
if (localPluginsOptions.length === 0) {
|
|
12
|
-
return
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const localPluginsOptionsA = await removeMainRoot(localPluginsOptions, buildDir)
|
|
16
|
-
if (localPluginsOptionsA.length === 0) {
|
|
17
|
-
return
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
checkLocalPluginsInstall(plugins)
|
|
21
|
-
|
|
22
|
-
logInstallLocalPluginsDeps(localPluginsOptionsA)
|
|
23
|
-
await Promise.all(
|
|
24
|
-
localPluginsOptionsA.map(({ packageDir }) =>
|
|
25
|
-
installDependencies({ packageRoot: packageDir, isLocal: mode !== 'buildbot' }),
|
|
26
|
-
),
|
|
27
|
-
)
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
// Users must add this plugin to their `netlify.toml` `plugins` to use this
|
|
31
|
-
// feature. We don't want to provide it by default because this makes build
|
|
32
|
-
// slow and buggy.
|
|
33
|
-
// TODO: remove once users all added this plugin to their `netlify.toml`
|
|
34
|
-
const checkLocalPluginsInstall = function(plugins) {
|
|
35
|
-
if (plugins.some(isLocalInstallOptIn)) {
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const error = new Error(`Please use the plugin "@netlify/plugin-local-install-core" to install dependencies from the "package.json" inside your local plugins.
|
|
40
|
-
Example "netlify.toml":
|
|
41
|
-
|
|
42
|
-
[[plugins]]
|
|
43
|
-
package = "@netlify/plugin-local-install-core"`)
|
|
44
|
-
addErrorInfo(error, { type: 'resolveConfig' })
|
|
45
|
-
throw error
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const isLocalInstallOptIn = function({ package }) {
|
|
49
|
-
return package === LOCAL_INSTALL_NAME
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const LOCAL_INSTALL_NAME = '@netlify/plugin-local-install-core'
|
|
53
|
-
|
|
54
|
-
// Core plugins and non-local plugins already have their dependencies installed
|
|
55
|
-
const getLocalPluginsOptions = function(pluginsOptions) {
|
|
56
|
-
return pluginsOptions.filter(isLocalPlugin).filter(isUnique)
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
const isLocalPlugin = function({ loadedFrom }) {
|
|
60
|
-
return loadedFrom === 'local'
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
// Remove duplicates
|
|
64
|
-
const isUnique = function({ packageDir }, index, pluginsOptions) {
|
|
65
|
-
return pluginsOptions.slice(index + 1).every(pluginOption => pluginOption.packageDir !== packageDir)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// We only install dependencies of local plugins that have their own `package.json`
|
|
69
|
-
const removeMainRoot = async function(localPluginsOptions, buildDir) {
|
|
70
|
-
const mainPackageDir = await pkgDir(buildDir)
|
|
71
|
-
return localPluginsOptions.filter(({ packageDir }) => packageDir !== mainPackageDir)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
module.exports = { installLocalPluginsDependencies, LOCAL_INSTALL_NAME }
|
package/src/install/main.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
const { homedir } = require('os')
|
|
2
|
-
|
|
3
|
-
const execa = require('execa')
|
|
4
|
-
const pathExists = require('path-exists')
|
|
5
|
-
const { gte: gteVersion } = require('semver')
|
|
6
|
-
|
|
7
|
-
const { addErrorInfo } = require('../error/info')
|
|
8
|
-
|
|
9
|
-
// Install Node.js dependencies in a specific directory
|
|
10
|
-
const installDependencies = function({ packageRoot, isLocal }) {
|
|
11
|
-
return runCommand({ packageRoot, isLocal, type: 'install' })
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Add new Node.js dependencies
|
|
15
|
-
const addDependencies = function({ packageRoot, isLocal, packages }) {
|
|
16
|
-
return runCommand({ packageRoot, packages, isLocal, type: 'add' })
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const runCommand = async function({ packageRoot, packages, isLocal, type }) {
|
|
20
|
-
try {
|
|
21
|
-
const command = await getCommand({ packageRoot, type, isLocal })
|
|
22
|
-
const packagesList = packages === undefined ? '' : ` ${packages.join(' ')}`
|
|
23
|
-
await execa.command(`${command}${packagesList}`, { cwd: packageRoot, all: true })
|
|
24
|
-
} catch (error) {
|
|
25
|
-
const message = getErrorMessage(error.all)
|
|
26
|
-
const errorA = new Error(`Error while installing dependencies in ${packageRoot}\n${message}`)
|
|
27
|
-
addErrorInfo(errorA, { type: 'dependencies' })
|
|
28
|
-
throw errorA
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Retrieve the shell command to install or add dependencies
|
|
33
|
-
const getCommand = async function({ packageRoot, type, isLocal }) {
|
|
34
|
-
const manager = await getManager(packageRoot)
|
|
35
|
-
const command = COMMANDS[manager][type]
|
|
36
|
-
const commandA = await fixNpmCiCompat(command)
|
|
37
|
-
const commandB = addYarnCustomCache(commandA, manager, isLocal)
|
|
38
|
-
return commandB
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const getManager = async function(packageRoot) {
|
|
42
|
-
if (await pathExists(`${packageRoot}/yarn.lock`)) {
|
|
43
|
-
return 'yarn'
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return 'npm'
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const COMMANDS = {
|
|
50
|
-
npm: {
|
|
51
|
-
add: 'npm install --no-progress --no-audit --no-fund',
|
|
52
|
-
install: 'npm install --no-progress --no-audit --no-fund',
|
|
53
|
-
},
|
|
54
|
-
yarn: {
|
|
55
|
-
add: 'yarn add --no-progress --non-interactive --ignore-workspace-root-check',
|
|
56
|
-
install: 'yarn install --no-progress --non-interactive',
|
|
57
|
-
},
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// npm ci was introduced in npm@5.7.0 which is shipped in Node >= 8.12.0 and
|
|
61
|
-
// Node >= 10.3.0
|
|
62
|
-
// TODO: remove once we stop supporting Node <8.12.0, Node 9 and Node <10.3.0
|
|
63
|
-
const fixNpmCiCompat = async function(command) {
|
|
64
|
-
if (!command.includes('npm ci')) {
|
|
65
|
-
return command
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const { stdout } = await execa.command('npm --version')
|
|
69
|
-
if (gteVersion(stdout, NPM_CI_MIN_VERSION)) {
|
|
70
|
-
return command
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return command.replace('npm ci', 'npm install')
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const NPM_CI_MIN_VERSION = '5.7.0'
|
|
77
|
-
|
|
78
|
-
// In CI, yarn uses a custom cache folder
|
|
79
|
-
const addYarnCustomCache = function(command, manager, isLocal) {
|
|
80
|
-
if (manager !== 'yarn' || isLocal) {
|
|
81
|
-
return command
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return `${command} --cache-folder=${YARN_CI_CACHE_DIR}`
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const YARN_CI_CACHE_DIR = `${homedir()}/.yarn_cache`
|
|
88
|
-
|
|
89
|
-
// Retrieve message to add to install errors
|
|
90
|
-
const getErrorMessage = function(allOutput) {
|
|
91
|
-
return allOutput
|
|
92
|
-
.split('\n')
|
|
93
|
-
.filter(isNotNpmLogMessage)
|
|
94
|
-
.join('\n')
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// Debug logs shown at the end of npm errors is not useful in Netlify Build
|
|
98
|
-
const isNotNpmLogMessage = function(line) {
|
|
99
|
-
return NPM_LOG_MESSAGES.every(message => !line.includes(message))
|
|
100
|
-
}
|
|
101
|
-
const NPM_LOG_MESSAGES = ['complete log of this run', '-debug.log']
|
|
102
|
-
|
|
103
|
-
module.exports = { installDependencies, addDependencies }
|
package/src/install/missing.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
const { writeFile } = require('fs')
|
|
2
|
-
const { promisify } = require('util')
|
|
3
|
-
|
|
4
|
-
const makeDir = require('make-dir')
|
|
5
|
-
const pathExists = require('path-exists')
|
|
6
|
-
|
|
7
|
-
const { logInstallMissingPlugins } = require('../log/main')
|
|
8
|
-
|
|
9
|
-
const { addDependencies } = require('./main')
|
|
10
|
-
|
|
11
|
-
const pWriteFile = promisify(writeFile)
|
|
12
|
-
|
|
13
|
-
// Find the path to the directory used to install plugins automatically.
|
|
14
|
-
// It is a subdirectory of `buildDir`, so that the plugin can require the
|
|
15
|
-
// project's dependencies (peer dependencies).
|
|
16
|
-
const getAutoPluginsDirPath = function(buildDir) {
|
|
17
|
-
return `${buildDir}/${AUTO_PLUGINS_DIR}`
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const AUTO_PLUGINS_DIR = '.netlify/plugins/'
|
|
21
|
-
|
|
22
|
-
// Automatically install plugins if not already installed nor cached in the
|
|
23
|
-
// build image.
|
|
24
|
-
// This is a fallback that is discouraged.
|
|
25
|
-
// We are always using `npm` to mimic the behavior of plugins cached in the
|
|
26
|
-
// build image. Users requiring `yarn` or custom npm/yarn flags should install
|
|
27
|
-
// the plugin in their `package.json`.
|
|
28
|
-
const installMissingPlugins = async function({ pluginsOptions, autoPluginsDir, mode }) {
|
|
29
|
-
const packages = getMissingPlugins(pluginsOptions)
|
|
30
|
-
if (packages.length === 0) {
|
|
31
|
-
return
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
logInstallMissingPlugins(packages)
|
|
35
|
-
|
|
36
|
-
await createAutoPluginsDir(autoPluginsDir)
|
|
37
|
-
await addDependencies({ packageRoot: autoPluginsDir, isLocal: mode !== 'buildbot', packages })
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
const getMissingPlugins = function(pluginsOptions) {
|
|
41
|
-
return pluginsOptions.filter(isMissingPlugin).map(getPackage)
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
const isMissingPlugin = function({ pluginPath }) {
|
|
45
|
-
return pluginPath === undefined
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
const getPackage = function({ package }) {
|
|
49
|
-
return package
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
const createAutoPluginsDir = async function(autoPluginsDir) {
|
|
53
|
-
await ensureDir(autoPluginsDir)
|
|
54
|
-
await createPackageJson(autoPluginsDir)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
// Create the directory if it does not exist
|
|
58
|
-
const ensureDir = async function(autoPluginsDir) {
|
|
59
|
-
if (await pathExists(autoPluginsDir)) {
|
|
60
|
-
return
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
await makeDir(autoPluginsDir)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Create a dummy `package.json` so we can run `npm install` and get a lock file
|
|
67
|
-
const createPackageJson = async function(autoPluginsDir) {
|
|
68
|
-
const packageJsonPath = `${autoPluginsDir}/package.json`
|
|
69
|
-
if (await pathExists(packageJsonPath)) {
|
|
70
|
-
return
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const packageJsonContent = JSON.stringify(AUTO_PLUGINS_PACKAGE_JSON, null, 2)
|
|
74
|
-
await pWriteFile(packageJsonPath, packageJsonContent)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
const AUTO_PLUGINS_PACKAGE_JSON = {
|
|
78
|
-
name: 'netlify-local-plugins',
|
|
79
|
-
description: 'This directory contains Build plugins that have been automatically installed by Netlify.',
|
|
80
|
-
version: '1.0.0',
|
|
81
|
-
private: true,
|
|
82
|
-
author: 'Netlify',
|
|
83
|
-
license: 'MIT',
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
module.exports = { getAutoPluginsDirPath, installMissingPlugins }
|
package/src/log/colors.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
env,
|
|
3
|
-
// eslint-disable-next-line node/no-unsupported-features/node-builtins
|
|
4
|
-
stdout: { isTTY, getColorDepth },
|
|
5
|
-
} = require('process')
|
|
6
|
-
const {
|
|
7
|
-
inspect: { defaultOptions },
|
|
8
|
-
} = require('util')
|
|
9
|
-
|
|
10
|
-
// Set the amount of colors to use by `chalk` (and underlying `supports-color`)
|
|
11
|
-
// 0 is no colors, 1 is 16 colors, 2 is 256 colors, 3 is 16 million colors.
|
|
12
|
-
const setColorLevel = function() {
|
|
13
|
-
env.FORCE_COLOR = getColorLevel()
|
|
14
|
-
defaultOptions.colors = hasColors()
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const getColorLevel = function() {
|
|
18
|
-
// Allow user overridding this logic
|
|
19
|
-
if (env.FORCE_COLOR) {
|
|
20
|
-
return env.FORCE_COLOR
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// In unit tests when using `PRINT` mode
|
|
24
|
-
if (env.PRINT === '1') {
|
|
25
|
-
return '1'
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// This also ensure colors are used in the BuildBot
|
|
29
|
-
// We cannot use the --mode CLI flag since this must be loaded before `chalk`
|
|
30
|
-
if (env.NETLIFY) {
|
|
31
|
-
return '1'
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
// If the output is not a console (e.g. redirected to `less` or to a file),
|
|
35
|
-
// we disable colors because ANSI sequences are a problem most of the time in
|
|
36
|
-
// that case
|
|
37
|
-
// We cannot test this since unit tests are never in an interactive terminal
|
|
38
|
-
if (!isTTY) {
|
|
39
|
-
return '0'
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
// Node <9.9.0 does not have `getColorDepth()`. Default to 16 colors then.
|
|
43
|
-
if (getColorDepth === undefined) {
|
|
44
|
-
return '1'
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
// Guess how many colors are supported, mostly based on environment variables
|
|
48
|
-
// This allows using 256 colors or 16 million colors on terminals that
|
|
49
|
-
// support it
|
|
50
|
-
return DEPTH_TO_LEVEL[getColorDepth()]
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
const DEPTH_TO_LEVEL = { 1: '0', 4: '1', 8: '2', 24: '3' }
|
|
54
|
-
|
|
55
|
-
const hasColors = function() {
|
|
56
|
-
return env.FORCE_COLOR !== '0' && env.FORCE_COLOR !== 'false'
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
module.exports = { setColorLevel, hasColors }
|
package/src/log/description.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
const { basename } = require('path')
|
|
2
|
-
|
|
3
|
-
// Retrieve description of `build.command` or of an event handler
|
|
4
|
-
const getCommandDescription = function({ event, package, configPath }) {
|
|
5
|
-
if (package === undefined) {
|
|
6
|
-
return getBuildCommandDescription(configPath)
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return `${event} command from ${package}`
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
// Retrieve description of `build.command`
|
|
13
|
-
const getBuildCommandDescription = function(configPath) {
|
|
14
|
-
if (configPath === undefined) {
|
|
15
|
-
return `Build command from settings`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return `build.command from ${basename(configPath)}`
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Retrieve human-friendly plugin origin
|
|
22
|
-
const getPluginOrigin = function(loadedFrom, origin) {
|
|
23
|
-
const originName = ORIGINS[origin]
|
|
24
|
-
|
|
25
|
-
if (loadedFrom === 'package.json') {
|
|
26
|
-
return `from ${originName} and package.json`
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return `from ${originName}`
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const ORIGINS = {
|
|
33
|
-
core: 'core',
|
|
34
|
-
ui: 'Netlify app',
|
|
35
|
-
config: 'netlify.toml',
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
module.exports = { getCommandDescription, getBuildCommandDescription, getPluginOrigin }
|
package/src/log/header.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
const stringWidth = require('string-width')
|
|
2
|
-
|
|
3
|
-
// Print a rectangular header
|
|
4
|
-
const getHeader = function(message) {
|
|
5
|
-
const messageWidth = stringWidth(message)
|
|
6
|
-
const headerWidth = Math.max(HEADER_MIN_WIDTH, messageWidth + MIN_PADDING * 2)
|
|
7
|
-
const line = '─'.repeat(headerWidth)
|
|
8
|
-
const paddingWidth = (headerWidth - messageWidth) / 2
|
|
9
|
-
const paddingLeft = ' '.repeat(Math.floor(paddingWidth))
|
|
10
|
-
const paddingRight = ' '.repeat(Math.ceil(paddingWidth))
|
|
11
|
-
return `┌${line}┐
|
|
12
|
-
│${paddingLeft}${message}${paddingRight}│
|
|
13
|
-
└${line}┘`
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
const HEADER_MIN_WIDTH = 29
|
|
17
|
-
const MIN_PADDING = 1
|
|
18
|
-
|
|
19
|
-
module.exports = { getHeader }
|
package/src/log/logger.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const { pointer } = require('figures')
|
|
2
|
-
const indentString = require('indent-string')
|
|
3
|
-
|
|
4
|
-
const { getHeader } = require('./header')
|
|
5
|
-
const { serializeObject, serializeArray } = require('./serialize')
|
|
6
|
-
const { THEME } = require('./theme')
|
|
7
|
-
|
|
8
|
-
// This should be used instead of `console.log()`
|
|
9
|
-
const log = function(string) {
|
|
10
|
-
const stringA = String(string).replace(EMPTY_LINES_REGEXP, EMPTY_LINE)
|
|
11
|
-
console.log(stringA)
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// We need to add a zero width space character in empty lines. Otherwise the
|
|
15
|
-
// buildbot removes those due to a bug: https://github.com/netlify/buildbot/issues/595
|
|
16
|
-
const EMPTY_LINES_REGEXP = /^\s*$/gm
|
|
17
|
-
const EMPTY_LINE = '\u{200b}'
|
|
18
|
-
|
|
19
|
-
const logMessage = function(string) {
|
|
20
|
-
const stringA = indentString(string, INDENT_SIZE)
|
|
21
|
-
log(stringA)
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
const INDENT_SIZE = 2
|
|
25
|
-
|
|
26
|
-
const logObject = function(object) {
|
|
27
|
-
const string = serializeObject(object)
|
|
28
|
-
logMessage(string)
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const logArray = function(array, { color = THEME.none } = {}) {
|
|
32
|
-
const string = color(serializeArray(array))
|
|
33
|
-
logMessage(string)
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const logHeader = function(string, { color = THEME.header } = {}) {
|
|
37
|
-
const stringA = `\n${color(getHeader(string))}`
|
|
38
|
-
log(stringA)
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const logErrorHeader = function(string) {
|
|
42
|
-
return logHeader(string, { color: THEME.errorHeader })
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const logSubHeader = function(string) {
|
|
46
|
-
const stringA = `\n${THEME.subHeader(`${pointer} ${string}`)}`
|
|
47
|
-
log(stringA)
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const logErrorSubHeader = function(string) {
|
|
51
|
-
const stringA = `\n${THEME.errorSubHeader(`${pointer} ${string}`)}`
|
|
52
|
-
log(stringA)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
module.exports = { log, logMessage, logObject, logArray, logHeader, logErrorHeader, logSubHeader, logErrorSubHeader }
|