@netlify/build 25.0.0 → 26.0.0
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/package.json +6 -4
- package/src/core/bin.js +7 -8
- package/src/core/config.js +18 -35
- package/src/core/constants.js +8 -14
- package/src/core/dry.js +4 -8
- package/src/core/feature_flags.js +2 -6
- package/src/core/flags.js +2 -6
- package/src/core/lingering.js +7 -7
- package/src/core/main.js +25 -29
- package/src/core/missing_side_file.js +4 -8
- package/src/core/normalize_flags.js +5 -9
- package/src/core/severity.js +2 -6
- package/src/core/user_node_version.js +7 -11
- package/src/env/changes.js +5 -9
- package/src/env/main.js +4 -8
- package/src/env/metadata.js +3 -7
- package/src/error/api.js +4 -8
- package/src/error/build.js +4 -8
- package/src/error/cancel.js +1 -5
- package/src/error/colors.js +2 -6
- package/src/error/handle.js +10 -14
- package/src/error/info.js +6 -10
- package/src/error/monitor/location.js +1 -5
- package/src/error/monitor/normalize.js +2 -6
- package/src/error/monitor/print.js +2 -8
- package/src/error/monitor/report.js +11 -15
- package/src/error/monitor/start.js +9 -11
- package/src/error/parse/clean_stack.js +4 -8
- package/src/error/parse/location.js +2 -6
- package/src/error/parse/normalize.js +1 -5
- package/src/error/parse/parse.js +10 -14
- package/src/error/parse/plugin.js +2 -6
- package/src/error/parse/properties.js +3 -7
- package/src/error/parse/serialize_log.js +2 -6
- package/src/error/parse/serialize_status.js +1 -5
- package/src/error/parse/stack.js +2 -6
- package/src/error/type.js +1 -5
- package/src/install/functions.js +5 -9
- package/src/install/local.js +5 -9
- package/src/install/main.js +6 -10
- package/src/install/missing.js +9 -13
- package/src/log/colors.js +5 -11
- package/src/log/description.js +2 -6
- package/src/log/header.js +2 -6
- package/src/log/header_func.js +3 -7
- package/src/log/logger.js +20 -40
- package/src/log/messages/compatibility.js +9 -18
- package/src/log/messages/config.js +12 -27
- package/src/log/messages/core.js +20 -31
- package/src/log/messages/core_steps.js +7 -15
- package/src/log/messages/dry.js +7 -15
- package/src/log/messages/install.js +4 -12
- package/src/log/messages/ipc.js +8 -20
- package/src/log/messages/mutations.js +8 -17
- package/src/log/messages/plugins.js +5 -14
- package/src/log/messages/status.js +3 -9
- package/src/log/messages/steps.js +6 -14
- package/src/log/old_version.js +6 -10
- package/src/log/serialize.js +3 -7
- package/src/log/stream.js +6 -15
- package/src/log/theme.js +14 -29
- package/src/plugins/child/diff.js +5 -9
- package/src/plugins/child/error.js +7 -11
- package/src/plugins/child/lazy.js +2 -6
- package/src/plugins/child/load.js +6 -10
- package/src/plugins/child/logic.js +6 -7
- package/src/plugins/child/main.js +5 -7
- package/src/plugins/child/run.js +6 -10
- package/src/plugins/child/status.js +4 -8
- package/src/plugins/child/typescript.js +5 -9
- package/src/plugins/child/utils.js +21 -27
- package/src/plugins/child/validate.js +6 -11
- package/src/plugins/compatibility.js +13 -16
- package/src/plugins/error.js +6 -15
- package/src/plugins/events.js +5 -20
- package/src/plugins/expected_version.js +9 -13
- package/src/plugins/ipc.js +12 -21
- package/src/plugins/list.js +6 -15
- package/src/plugins/load.js +13 -9
- package/src/plugins/manifest/check.js +4 -8
- package/src/plugins/manifest/load.js +6 -10
- package/src/plugins/manifest/main.js +5 -9
- package/src/plugins/manifest/path.js +3 -7
- package/src/plugins/manifest/validate.js +3 -7
- package/src/plugins/node_version.js +9 -15
- package/src/plugins/options.js +12 -17
- package/src/plugins/pinned_version.js +4 -8
- package/src/plugins/resolve.js +7 -11
- package/src/plugins/spawn.js +10 -12
- package/src/plugins_core/add.js +2 -6
- package/src/plugins_core/build_command.js +7 -11
- package/src/plugins_core/deploy/buildbot_client.js +11 -20
- package/src/plugins_core/deploy/index.js +5 -9
- package/src/plugins_core/functions/error.js +4 -8
- package/src/plugins_core/functions/feature_flags.js +1 -5
- package/src/plugins_core/functions/index.js +20 -14
- package/src/plugins_core/functions/utils.js +9 -13
- package/src/plugins_core/functions_install/index.js +3 -7
- package/src/plugins_core/list.js +10 -7
- package/src/status/add.js +1 -5
- package/src/status/colors.js +2 -6
- package/src/status/load_error.js +4 -8
- package/src/status/report.js +4 -8
- package/src/status/success.js +2 -6
- package/src/steps/core_step.js +4 -8
- package/src/steps/error.js +7 -11
- package/src/steps/get.js +7 -12
- package/src/steps/plugin.js +8 -12
- package/src/steps/return.js +4 -8
- package/src/steps/run_step.js +8 -12
- package/src/steps/run_steps.js +5 -9
- package/src/steps/update_config.js +10 -14
- package/src/telemetry/main.js +8 -12
- package/src/time/aggregate.js +2 -6
- package/src/time/main.js +8 -12
- package/src/time/measure.js +4 -8
- package/src/time/report.js +5 -9
- package/src/utils/errors.js +1 -5
- package/src/utils/json.js +19 -0
- package/src/utils/omit.js +2 -6
- package/src/utils/package.js +3 -7
- package/src/utils/remove_falsy.js +2 -6
- package/src/utils/resolve.js +8 -6
- package/src/utils/semver.js +9 -13
- package/types/config/functions.d.ts +1 -1
|
@@ -1,30 +1,26 @@
|
|
|
1
|
-
|
|
1
|
+
import { bindOpts as cacheBindOpts } from '@netlify/cache-utils'
|
|
2
|
+
import { add as functionsAdd, list as functionsList, listAll as functionsListAll } from '@netlify/functions-utils'
|
|
3
|
+
import { getGitUtils } from '@netlify/git-utils'
|
|
4
|
+
import { run, runCommand } from '@netlify/run-utils'
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
import { failBuild, failPlugin, cancelBuild, failPluginWithWarning } from '../error.js'
|
|
7
|
+
import { isSoftFailEvent } from '../events.js'
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const cacheUtilsPromise = import('@netlify/cache-utils')
|
|
10
|
-
const functionsUtilsPromise = import('@netlify/functions-utils')
|
|
11
|
-
const gitUtilsPromise = import('@netlify/git-utils')
|
|
12
|
-
const runUtilsPromise = import('@netlify/run-utils')
|
|
9
|
+
import { addLazyProp } from './lazy.js'
|
|
10
|
+
import { show } from './status.js'
|
|
13
11
|
|
|
14
12
|
// Retrieve the `utils` argument.
|
|
15
|
-
const getUtils =
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
runUtilsPromise,
|
|
21
|
-
])
|
|
13
|
+
export const getUtils = function ({
|
|
14
|
+
event,
|
|
15
|
+
constants: { FUNCTIONS_SRC, INTERNAL_FUNCTIONS_SRC, CACHE_DIR },
|
|
16
|
+
runState,
|
|
17
|
+
}) {
|
|
22
18
|
// eslint-disable-next-line fp/no-mutation
|
|
23
19
|
run.command = runCommand
|
|
24
20
|
|
|
25
21
|
const build = getBuildUtils(event)
|
|
26
|
-
const cache = getCacheUtils(
|
|
27
|
-
const functions = getFunctionsUtils(
|
|
22
|
+
const cache = getCacheUtils(CACHE_DIR)
|
|
23
|
+
const functions = getFunctionsUtils(FUNCTIONS_SRC, INTERNAL_FUNCTIONS_SRC)
|
|
28
24
|
const status = getStatusUtils(runState)
|
|
29
25
|
const utils = { build, cache, run, functions, status }
|
|
30
26
|
addLazyProp(utils, 'git', () => getGitUtils())
|
|
@@ -43,20 +39,18 @@ const getBuildUtils = function (event) {
|
|
|
43
39
|
return { failBuild, failPlugin, cancelBuild }
|
|
44
40
|
}
|
|
45
41
|
|
|
46
|
-
const getCacheUtils = function (
|
|
47
|
-
return
|
|
42
|
+
const getCacheUtils = function (CACHE_DIR) {
|
|
43
|
+
return cacheBindOpts({ cacheDir: CACHE_DIR })
|
|
48
44
|
}
|
|
49
45
|
|
|
50
|
-
const getFunctionsUtils = function (
|
|
46
|
+
const getFunctionsUtils = function (FUNCTIONS_SRC, INTERNAL_FUNCTIONS_SRC) {
|
|
51
47
|
const functionsDirectories = [INTERNAL_FUNCTIONS_SRC, FUNCTIONS_SRC].filter(Boolean)
|
|
52
|
-
const add = (src) =>
|
|
53
|
-
const list =
|
|
54
|
-
const listAll =
|
|
48
|
+
const add = (src) => functionsAdd(src, INTERNAL_FUNCTIONS_SRC, { fail: failBuild })
|
|
49
|
+
const list = functionsList.bind(null, functionsDirectories, { fail: failBuild })
|
|
50
|
+
const listAll = functionsListAll.bind(null, functionsDirectories, { fail: failBuild })
|
|
55
51
|
return { add, list, listAll }
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
const getStatusUtils = function (runState) {
|
|
59
55
|
return { show: show.bind(undefined, runState) }
|
|
60
56
|
}
|
|
61
|
-
|
|
62
|
-
module.exports = { getUtils }
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const { serializeArray } = require('../../log/serialize')
|
|
5
|
-
const { listEvents } = require('../events')
|
|
1
|
+
import { addErrorInfo } from '../../error/info.js'
|
|
2
|
+
import { serializeArray } from '../../log/serialize.js'
|
|
3
|
+
import { EVENTS } from '../events.js'
|
|
6
4
|
|
|
7
5
|
// Validate the shape of a plugin return value
|
|
8
|
-
const validatePlugin =
|
|
6
|
+
export const validatePlugin = function (logic) {
|
|
9
7
|
try {
|
|
10
8
|
// This validation must work with the return value of `import()` which has
|
|
11
9
|
// a `Module` prototype, not `Object`
|
|
@@ -13,9 +11,8 @@ const validatePlugin = async function (logic) {
|
|
|
13
11
|
throw new Error('Plugin must be an object or a function')
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
const EVENTS = await listEvents()
|
|
17
14
|
Object.entries(logic).forEach(([propName, value]) => {
|
|
18
|
-
validateEventHandler(value, propName
|
|
15
|
+
validateEventHandler(value, propName)
|
|
19
16
|
})
|
|
20
17
|
} catch (error) {
|
|
21
18
|
addErrorInfo(error, { type: 'pluginValidation' })
|
|
@@ -24,7 +21,7 @@ const validatePlugin = async function (logic) {
|
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
// All other properties are event handlers
|
|
27
|
-
const validateEventHandler = function (value, propName
|
|
24
|
+
const validateEventHandler = function (value, propName) {
|
|
28
25
|
if (!EVENTS.includes(propName)) {
|
|
29
26
|
throw new Error(`Invalid event '${propName}'.
|
|
30
27
|
Please use a valid event name. One of:
|
|
@@ -35,5 +32,3 @@ ${serializeArray(EVENTS)}`)
|
|
|
35
32
|
throw new TypeError(`Invalid event handler '${propName}': must be a function`)
|
|
36
33
|
}
|
|
37
34
|
}
|
|
38
|
-
|
|
39
|
-
module.exports = { validatePlugin }
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const { satisfies, clean: cleanVersion } = require('semver')
|
|
1
|
+
import pEvery from 'p-every'
|
|
2
|
+
import pLocate from 'p-locate'
|
|
3
|
+
import semver from 'semver'
|
|
5
4
|
|
|
6
|
-
|
|
5
|
+
import { importJsonFile } from '../utils/json.js'
|
|
6
|
+
import { resolvePath } from '../utils/resolve.js'
|
|
7
7
|
|
|
8
8
|
// Retrieve the `expectedVersion` of a plugin:
|
|
9
9
|
// - This is the version which should be run
|
|
@@ -14,7 +14,7 @@ const { resolvePath } = require('../utils/resolve')
|
|
|
14
14
|
// - This is the same logic except it does not use version pinning
|
|
15
15
|
// - This is only used to print a warning message when the `compatibleVersion`
|
|
16
16
|
// is older than the currently used version.
|
|
17
|
-
const getExpectedVersion = async function ({ versions, nodeVersion, packageJson, buildDir, pinnedVersion }) {
|
|
17
|
+
export const getExpectedVersion = async function ({ versions, nodeVersion, packageJson, buildDir, pinnedVersion }) {
|
|
18
18
|
const { version, conditions } = await getCompatibleEntry({
|
|
19
19
|
versions,
|
|
20
20
|
nodeVersion,
|
|
@@ -42,7 +42,7 @@ const getExpectedVersion = async function ({ versions, nodeVersion, packageJson,
|
|
|
42
42
|
// - Otherwise, use `latestVersion`
|
|
43
43
|
const getCompatibleEntry = async function ({ versions, nodeVersion, packageJson, buildDir, pinnedVersion }) {
|
|
44
44
|
if (pinnedVersion !== undefined) {
|
|
45
|
-
return versions.find(({ version }) => satisfies(version, pinnedVersion)) || { version: pinnedVersion }
|
|
45
|
+
return versions.find(({ version }) => semver.satisfies(version, pinnedVersion)) || { version: pinnedVersion }
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
const versionsWithConditions = versions.filter(hasConditions)
|
|
@@ -76,7 +76,7 @@ const getConditionWarning = function ({ type, condition }) {
|
|
|
76
76
|
// Plugins can use `compatibility.{version}.nodeVersion: 'allowedNodeVersion'`
|
|
77
77
|
// to deliver different plugin versions based on the Node.js version
|
|
78
78
|
const nodeVersionTest = function (allowedNodeVersion, { nodeVersion }) {
|
|
79
|
-
return satisfies(nodeVersion, allowedNodeVersion)
|
|
79
|
+
return semver.satisfies(nodeVersion, allowedNodeVersion)
|
|
80
80
|
}
|
|
81
81
|
|
|
82
82
|
const nodeVersionWarning = function (allowedNodeVersion) {
|
|
@@ -100,16 +100,15 @@ const siteDependencyTest = async function ({ dependencyName, allowedVersion, sit
|
|
|
100
100
|
}
|
|
101
101
|
|
|
102
102
|
// if this is a valid version we can apply the rule directly
|
|
103
|
-
if (
|
|
104
|
-
return satisfies(siteDependency, allowedVersion)
|
|
103
|
+
if (semver.clean(siteDependency) !== null) {
|
|
104
|
+
return semver.satisfies(siteDependency, allowedVersion)
|
|
105
105
|
}
|
|
106
106
|
|
|
107
107
|
try {
|
|
108
108
|
// if this is a range we need to get the exact version
|
|
109
109
|
const packageJsonPath = await resolvePath(`${dependencyName}/package.json`, buildDir)
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
return satisfies(version, allowedVersion)
|
|
110
|
+
const { version } = await importJsonFile(packageJsonPath)
|
|
111
|
+
return semver.satisfies(version, allowedVersion)
|
|
113
112
|
} catch (error) {
|
|
114
113
|
return false
|
|
115
114
|
}
|
|
@@ -123,9 +122,7 @@ const siteDependencyWarning = function ([dependencyName, allowedVersion]) {
|
|
|
123
122
|
return `${dependencyName}@${allowedVersion}`
|
|
124
123
|
}
|
|
125
124
|
|
|
126
|
-
const CONDITIONS = {
|
|
125
|
+
export const CONDITIONS = {
|
|
127
126
|
nodeVersion: { test: nodeVersionTest, warning: nodeVersionWarning },
|
|
128
127
|
siteDependencies: { test: siteDependenciesTest, warning: siteDependenciesWarning },
|
|
129
128
|
}
|
|
130
|
-
|
|
131
|
-
module.exports = { getExpectedVersion, CONDITIONS }
|
package/src/plugins/error.js
CHANGED
|
@@ -1,29 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const { addErrorInfo } = require('../error/info')
|
|
4
|
-
const { logFailPluginWarning } = require('../log/messages/plugins')
|
|
1
|
+
import { addErrorInfo } from '../error/info.js'
|
|
2
|
+
import { logFailPluginWarning } from '../log/messages/plugins.js'
|
|
5
3
|
|
|
6
4
|
// Stop build.
|
|
7
5
|
// As opposed to throwing an error directly or to uncaught exceptions, this is
|
|
8
6
|
// displayed as a user error, not an implementation error.
|
|
9
|
-
const failBuild = function (message, opts) {
|
|
7
|
+
export const failBuild = function (message, opts) {
|
|
10
8
|
throw normalizeError('failBuild', failBuild, message, opts)
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
// Stop plugin. Same as `failBuild` but only stops plugin not whole build
|
|
14
|
-
const failPlugin = function (message, opts) {
|
|
12
|
+
export const failPlugin = function (message, opts) {
|
|
15
13
|
throw normalizeError('failPlugin', failPlugin, message, opts)
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
// Cancel build. Same as `failBuild` except it marks the build as "canceled".
|
|
19
|
-
const cancelBuild = function (message, opts) {
|
|
17
|
+
export const cancelBuild = function (message, opts) {
|
|
20
18
|
throw normalizeError('cancelBuild', cancelBuild, message, opts)
|
|
21
19
|
}
|
|
22
20
|
|
|
23
21
|
// `onSuccess`, `onEnd` and `onError` cannot cancel the build since they are run
|
|
24
22
|
// or might be run after deployment. When calling `failBuild()` or
|
|
25
23
|
// `cancelBuild()`, `failPlugin()` is run instead and a warning is printed.
|
|
26
|
-
const failPluginWithWarning = function (methodName, event, message, opts) {
|
|
24
|
+
export const failPluginWithWarning = function (methodName, event, message, opts) {
|
|
27
25
|
logFailPluginWarning(methodName, event)
|
|
28
26
|
failPlugin(message, opts)
|
|
29
27
|
}
|
|
@@ -47,10 +45,3 @@ const getError = function (error, message, func) {
|
|
|
47
45
|
Error.captureStackTrace(errorA, func)
|
|
48
46
|
return errorA
|
|
49
47
|
}
|
|
50
|
-
|
|
51
|
-
module.exports = {
|
|
52
|
-
failBuild,
|
|
53
|
-
failPlugin,
|
|
54
|
-
failPluginWithWarning,
|
|
55
|
-
cancelBuild,
|
|
56
|
-
}
|
package/src/plugins/events.js
CHANGED
|
@@ -1,32 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const netlifyConfigPromise = import('@netlify/config')
|
|
4
|
-
|
|
5
|
-
const listEvents = async function () {
|
|
6
|
-
const { EVENTS } = await netlifyConfigPromise
|
|
7
|
-
return EVENTS
|
|
8
|
-
}
|
|
1
|
+
export { EVENTS } from '@netlify/config'
|
|
9
2
|
|
|
10
3
|
const isAmongEvents = function (events, event) {
|
|
11
4
|
return events.includes(event)
|
|
12
5
|
}
|
|
13
6
|
|
|
14
7
|
// Check if failure of the event should not make the build fail
|
|
15
|
-
const isSoftFailEvent = isAmongEvents.bind(null, ['onSuccess', 'onError', 'onEnd'])
|
|
8
|
+
export const isSoftFailEvent = isAmongEvents.bind(null, ['onSuccess', 'onError', 'onEnd'])
|
|
16
9
|
|
|
17
10
|
// Check if the event is triggered even when the build fails
|
|
18
|
-
const runsAlsoOnBuildFailure = isAmongEvents.bind(null, ['onError', 'onEnd'])
|
|
11
|
+
export const runsAlsoOnBuildFailure = isAmongEvents.bind(null, ['onError', 'onEnd'])
|
|
19
12
|
|
|
20
13
|
// Check if the event is only triggered when the build fails
|
|
21
|
-
const runsOnlyOnBuildFailure = isAmongEvents.bind(null, ['onError'])
|
|
14
|
+
export const runsOnlyOnBuildFailure = isAmongEvents.bind(null, ['onError'])
|
|
22
15
|
|
|
23
16
|
// Check if the event is happening after deploy
|
|
24
|
-
const runsAfterDeploy = isAmongEvents.bind(null, ['onSuccess', 'onEnd'])
|
|
25
|
-
|
|
26
|
-
module.exports = {
|
|
27
|
-
listEvents,
|
|
28
|
-
isSoftFailEvent,
|
|
29
|
-
runsAlsoOnBuildFailure,
|
|
30
|
-
runsOnlyOnBuildFailure,
|
|
31
|
-
runsAfterDeploy,
|
|
32
|
-
}
|
|
17
|
+
export const runsAfterDeploy = isAmongEvents.bind(null, ['onSuccess', 'onEnd'])
|
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import semver from 'semver'
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
import { addErrorInfo } from '../error/info.js'
|
|
4
|
+
import { importJsonFile } from '../utils/json.js'
|
|
5
|
+
import { resolvePath } from '../utils/resolve.js'
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const { getExpectedVersion } = require('./compatibility')
|
|
9
|
-
const { getPluginsList } = require('./list')
|
|
7
|
+
import { getExpectedVersion } from './compatibility.js'
|
|
8
|
+
import { getPluginsList } from './list.js'
|
|
10
9
|
|
|
11
10
|
// When using plugins in our official list, those are installed in .netlify/plugins/
|
|
12
11
|
// We ensure that the last version that's been approved is always the one being used.
|
|
13
12
|
// We also ensure that the plugin is our official list.
|
|
14
|
-
const addExpectedVersions = async function ({
|
|
13
|
+
export const addExpectedVersions = async function ({
|
|
15
14
|
pluginsOptions,
|
|
16
15
|
autoPluginsDir,
|
|
17
16
|
packageJson,
|
|
@@ -89,14 +88,13 @@ const isMissingVersion = async function ({ autoPluginsDir, packageName, pluginPa
|
|
|
89
88
|
// Plugin was not previously installed
|
|
90
89
|
(pluginPath === undefined ||
|
|
91
90
|
// Plugin was previously installed but a different version should be used
|
|
92
|
-
!satisfies(await getAutoPluginVersion(packageName, autoPluginsDir), expectedVersion))
|
|
91
|
+
!semver.satisfies(await getAutoPluginVersion(packageName, autoPluginsDir), expectedVersion))
|
|
93
92
|
)
|
|
94
93
|
}
|
|
95
94
|
|
|
96
95
|
const getAutoPluginVersion = async function (packageName, autoPluginsDir) {
|
|
97
96
|
const packageJsonPath = await resolvePath(`${packageName}/package.json`, autoPluginsDir)
|
|
98
|
-
|
|
99
|
-
const { version } = require(packageJsonPath)
|
|
97
|
+
const { version } = await importJsonFile(packageJsonPath)
|
|
100
98
|
return version
|
|
101
99
|
}
|
|
102
100
|
|
|
@@ -119,5 +117,3 @@ Please run "npm install -D ${packageName}" or "yarn add -D ${packageName}".`,
|
|
|
119
117
|
addErrorInfo(error, { type: 'resolveConfig' })
|
|
120
118
|
throw error
|
|
121
119
|
}
|
|
122
|
-
|
|
123
|
-
module.exports = { addExpectedVersions }
|
package/src/plugins/ipc.js
CHANGED
|
@@ -1,24 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import process from 'process'
|
|
2
|
+
import { promisify } from 'util'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
4
|
+
import pEvent from 'p-event'
|
|
5
|
+
import { v4 as uuidv4 } from 'uuid'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const { jsonToError, errorToJson } = require('../error/build')
|
|
10
|
-
const { addErrorInfo } = require('../error/info')
|
|
11
|
-
const {
|
|
7
|
+
import { jsonToError, errorToJson } from '../error/build.js'
|
|
8
|
+
import { addErrorInfo } from '../error/info.js'
|
|
9
|
+
import {
|
|
12
10
|
logSendingEventToChild,
|
|
13
11
|
logSentEventToChild,
|
|
14
12
|
logReceivedEventFromChild,
|
|
15
13
|
logSendingEventToParent,
|
|
16
|
-
}
|
|
14
|
+
} from '../log/messages/ipc.js'
|
|
17
15
|
|
|
18
16
|
// Send event from child to parent process then wait for response
|
|
19
17
|
// We need to fire them in parallel because `process.send()` can be slow
|
|
20
18
|
// to await, i.e. child might send response before parent start listening for it
|
|
21
|
-
const callChild = async function ({ childProcess, eventName, payload, logs, verbose }) {
|
|
19
|
+
export const callChild = async function ({ childProcess, eventName, payload, logs, verbose }) {
|
|
22
20
|
const callId = uuidv4()
|
|
23
21
|
const [response] = await Promise.all([
|
|
24
22
|
getEventFromChild(childProcess, callId),
|
|
@@ -36,7 +34,7 @@ const callChild = async function ({ childProcess, eventName, payload, logs, verb
|
|
|
36
34
|
// - child process `exit`
|
|
37
35
|
// In the later two cases, we propagate the error.
|
|
38
36
|
// We need to make `p-event` listeners are properly cleaned up too.
|
|
39
|
-
const getEventFromChild = async function (childProcess, callId) {
|
|
37
|
+
export const getEventFromChild = async function (childProcess, callId) {
|
|
40
38
|
if (childProcessHasExited(childProcess)) {
|
|
41
39
|
throw getChildExitError('Could not receive event from child process because it already exited.')
|
|
42
40
|
}
|
|
@@ -104,7 +102,7 @@ const sendEventToChild = async function ({ childProcess, callId, eventName, payl
|
|
|
104
102
|
// This runs forever until `childProcess.kill()` is called.
|
|
105
103
|
// We need to use `new Promise()` and callbacks because this runs forever.
|
|
106
104
|
// eslint-disable-next-line promise/prefer-await-to-callbacks
|
|
107
|
-
const getEventsFromParent = function (callback) {
|
|
105
|
+
export const getEventsFromParent = function (callback) {
|
|
108
106
|
return new Promise((resolve, reject) => {
|
|
109
107
|
process.on('message', async (message) => {
|
|
110
108
|
try {
|
|
@@ -120,7 +118,7 @@ const getEventsFromParent = function (callback) {
|
|
|
120
118
|
}
|
|
121
119
|
|
|
122
120
|
// Send event from child to parent process
|
|
123
|
-
const sendEventToParent = async function (callId, payload, verbose, error) {
|
|
121
|
+
export const sendEventToParent = async function (callId, payload, verbose, error) {
|
|
124
122
|
logSendingEventToParent(verbose, error)
|
|
125
123
|
await promisify(process.send.bind(process))([callId, payload])
|
|
126
124
|
}
|
|
@@ -145,10 +143,3 @@ const parsePayload = function ({ error = {}, error: { name } = {}, ...payload })
|
|
|
145
143
|
const errorA = jsonToError(error)
|
|
146
144
|
return { ...payload, error: errorA }
|
|
147
145
|
}
|
|
148
|
-
|
|
149
|
-
module.exports = {
|
|
150
|
-
callChild,
|
|
151
|
-
getEventFromChild,
|
|
152
|
-
getEventsFromParent,
|
|
153
|
-
sendEventToParent,
|
|
154
|
-
}
|
package/src/plugins/list.js
CHANGED
|
@@ -1,15 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
import { pluginsUrl, pluginsList as oldPluginsList } from '@netlify/plugins-list'
|
|
2
|
+
import got from 'got'
|
|
3
|
+
import isPlainObj from 'is-plain-obj'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
const isPlainObj = require('is-plain-obj')
|
|
5
|
+
import { logPluginsList, logPluginsFetchError } from '../log/messages/plugins.js'
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
const netlifyPluginsList = import('@netlify/plugins-list')
|
|
8
|
-
|
|
9
|
-
const { logPluginsList } = require('../log/messages/plugins')
|
|
10
|
-
const { logPluginsFetchError } = require('../log/messages/plugins')
|
|
11
|
-
|
|
12
|
-
const { CONDITIONS } = require('./compatibility')
|
|
7
|
+
import { CONDITIONS } from './compatibility.js'
|
|
13
8
|
|
|
14
9
|
// Retrieve the list of plugins officially vetted by us and displayed in our
|
|
15
10
|
// plugins directory UI.
|
|
@@ -18,14 +13,13 @@ const { CONDITIONS } = require('./compatibility')
|
|
|
18
13
|
// make this request is somewhat ok (in the 100ms range).
|
|
19
14
|
// We only fetch this plugins list when needed, i.e. we defer it as much as
|
|
20
15
|
// possible.
|
|
21
|
-
const getPluginsList = async function ({ debug, logs, testOpts: { pluginsListUrl } }) {
|
|
16
|
+
export const getPluginsList = async function ({ debug, logs, testOpts: { pluginsListUrl } }) {
|
|
22
17
|
// We try not to mock in integration tests. However, sending a request for
|
|
23
18
|
// each test would be too slow and make tests unreliable.
|
|
24
19
|
if (pluginsListUrl === 'test') {
|
|
25
20
|
return []
|
|
26
21
|
}
|
|
27
22
|
|
|
28
|
-
const { pluginsUrl } = await netlifyPluginsList
|
|
29
23
|
const pluginsListUrlA = pluginsListUrl === undefined ? pluginsUrl : pluginsListUrl
|
|
30
24
|
const pluginsList = await fetchPluginsList({ logs, pluginsListUrl: pluginsListUrlA })
|
|
31
25
|
const pluginsListA = normalizePluginsList(pluginsList)
|
|
@@ -50,7 +44,6 @@ const fetchPluginsList = async function ({ logs, pluginsListUrl }) {
|
|
|
50
44
|
// buildbot release.
|
|
51
45
|
} catch (error) {
|
|
52
46
|
logPluginsFetchError(logs, error.message)
|
|
53
|
-
const { pluginsList: oldPluginsList } = await netlifyPluginsList
|
|
54
47
|
return oldPluginsList
|
|
55
48
|
}
|
|
56
49
|
}
|
|
@@ -91,5 +84,3 @@ const isCondition = function ([type]) {
|
|
|
91
84
|
const normalizeCondition = function ([type, condition]) {
|
|
92
85
|
return { type, condition }
|
|
93
86
|
}
|
|
94
|
-
|
|
95
|
-
module.exports = { getPluginsList }
|
package/src/plugins/load.js
CHANGED
|
@@ -1,14 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { addErrorInfo } from '../error/info.js'
|
|
2
|
+
import { addPluginLoadErrorStatus } from '../status/load_error.js'
|
|
3
|
+
import { measureDuration } from '../time/main.js'
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
const { addPluginLoadErrorStatus } = require('../status/load_error')
|
|
5
|
-
const { measureDuration } = require('../time/main')
|
|
6
|
-
|
|
7
|
-
const { callChild } = require('./ipc')
|
|
5
|
+
import { callChild } from './ipc.js'
|
|
8
6
|
|
|
9
7
|
// Retrieve all plugins steps
|
|
10
8
|
// Can use either a module name or a file path to the plugin.
|
|
11
|
-
const loadPlugins = async function ({
|
|
9
|
+
export const loadPlugins = async function ({
|
|
10
|
+
pluginsOptions,
|
|
11
|
+
childProcesses,
|
|
12
|
+
packageJson,
|
|
13
|
+
timers,
|
|
14
|
+
logs,
|
|
15
|
+
debug,
|
|
16
|
+
verbose,
|
|
17
|
+
}) {
|
|
12
18
|
return pluginsOptions.length === 0
|
|
13
19
|
? { pluginsSteps: [], timers }
|
|
14
20
|
: await loadAllPlugins({ pluginsOptions, childProcesses, packageJson, timers, logs, debug, verbose })
|
|
@@ -62,5 +68,3 @@ const loadPlugin = async function (
|
|
|
62
68
|
throw error
|
|
63
69
|
}
|
|
64
70
|
}
|
|
65
|
-
|
|
66
|
-
module.exports = { loadPlugins }
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const { serializeObject } = require('../../log/serialize')
|
|
5
|
-
const { THEME } = require('../../log/theme')
|
|
1
|
+
import { addErrorInfo } from '../../error/info.js'
|
|
2
|
+
import { serializeObject } from '../../log/serialize.js'
|
|
3
|
+
import { THEME } from '../../log/theme.js'
|
|
6
4
|
|
|
7
5
|
// Check that plugin inputs match the validation specified in "manifest.yml"
|
|
8
6
|
// Also assign default values
|
|
9
|
-
const checkInputs = function ({
|
|
7
|
+
export const checkInputs = function ({
|
|
10
8
|
inputs,
|
|
11
9
|
manifest: { inputs: rules = [] },
|
|
12
10
|
packageName,
|
|
@@ -106,5 +104,3 @@ const addInputError = function ({ error, name, packageName, pluginPackageJson, l
|
|
|
106
104
|
location: { event: 'load', packageName, input: name, loadedFrom, origin },
|
|
107
105
|
})
|
|
108
106
|
}
|
|
109
|
-
|
|
110
|
-
module.exports = { checkInputs }
|
|
@@ -1,18 +1,16 @@
|
|
|
1
|
-
|
|
1
|
+
import { readFile } from 'fs'
|
|
2
|
+
import { promisify } from 'util'
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
const { promisify } = require('util')
|
|
4
|
+
import { load as loadYaml, JSON_SCHEMA } from 'js-yaml'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
import { addErrorInfo } from '../../error/info.js'
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const { validateManifest } = require('./validate')
|
|
8
|
+
import { validateManifest } from './validate.js'
|
|
11
9
|
|
|
12
10
|
const pReadFile = promisify(readFile)
|
|
13
11
|
|
|
14
12
|
// Load "manifest.yml" using its file path
|
|
15
|
-
const loadManifest = async function ({ manifestPath, packageName, pluginPackageJson, loadedFrom, origin }) {
|
|
13
|
+
export const loadManifest = async function ({ manifestPath, packageName, pluginPackageJson, loadedFrom, origin }) {
|
|
16
14
|
try {
|
|
17
15
|
const rawManifest = await loadRawManifest(manifestPath)
|
|
18
16
|
const manifest = await parseManifest(rawManifest)
|
|
@@ -44,5 +42,3 @@ const parseManifest = async function (rawManifest) {
|
|
|
44
42
|
throw new Error(`Could not parse plugin's "manifest.yml"\n${error.message}`)
|
|
45
43
|
}
|
|
46
44
|
}
|
|
47
|
-
|
|
48
|
-
module.exports = { loadManifest }
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import { addPluginLoadErrorStatus } from '../../status/load_error.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const { loadManifest } = require('./load')
|
|
7
|
-
const { getManifestPath } = require('./path')
|
|
3
|
+
import { checkInputs } from './check.js'
|
|
4
|
+
import { loadManifest } from './load.js'
|
|
5
|
+
import { getManifestPath } from './path.js'
|
|
8
6
|
|
|
9
7
|
// Load plugin's `manifest.yml`
|
|
10
|
-
const useManifest = async function (
|
|
8
|
+
export const useManifest = async function (
|
|
11
9
|
{ packageName, loadedFrom, origin, inputs },
|
|
12
10
|
{ pluginDir, packageDir, pluginPackageJson, pluginPackageJson: { version }, debug },
|
|
13
11
|
) {
|
|
@@ -22,5 +20,3 @@ const useManifest = async function (
|
|
|
22
20
|
throw error
|
|
23
21
|
}
|
|
24
22
|
}
|
|
25
|
-
|
|
26
|
-
module.exports = { useManifest }
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import locatePath from 'locate-path'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { addErrorInfo } = require('../../error/info')
|
|
3
|
+
import { addErrorInfo } from '../../error/info.js'
|
|
6
4
|
|
|
7
5
|
// Retrieve "manifest.yml" path for a specific plugin
|
|
8
|
-
const getManifestPath = async function ({ pluginDir, packageDir, packageName }) {
|
|
6
|
+
export const getManifestPath = async function ({ pluginDir, packageDir, packageName }) {
|
|
9
7
|
const dirs = [pluginDir, packageDir]
|
|
10
8
|
.filter(Boolean)
|
|
11
9
|
.flatMap((dir) => MANIFEST_FILENAMES.map((filename) => `${dir}/${filename}`))
|
|
@@ -31,5 +29,3 @@ This might mean:
|
|
|
31
29
|
}
|
|
32
30
|
|
|
33
31
|
const MANIFEST_FILENAMES = ['manifest.yml', 'manifest.yaml']
|
|
34
|
-
|
|
35
|
-
module.exports = { getManifestPath }
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import isPlainObj from 'is-plain-obj'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { THEME } = require('../../log/theme')
|
|
3
|
+
import { THEME } from '../../log/theme.js'
|
|
6
4
|
|
|
7
5
|
// Validate `manifest.yml` syntax
|
|
8
|
-
const validateManifest = function (manifest, rawManifest) {
|
|
6
|
+
export const validateManifest = function (manifest, rawManifest) {
|
|
9
7
|
try {
|
|
10
8
|
validateBasic(manifest)
|
|
11
9
|
validateUnknownProps(manifest)
|
|
@@ -108,5 +106,3 @@ const validateInputRequired = function ({ required }) {
|
|
|
108
106
|
throw new Error('"required" property must be a boolean')
|
|
109
107
|
}
|
|
110
108
|
}
|
|
111
|
-
|
|
112
|
-
module.exports = { validateManifest }
|