@netlify/build 19.0.5 → 19.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +2 -2
- package/src/error/build.js +2 -3
- package/src/plugins/child/load.js +7 -10
- package/src/plugins/child/run.js +2 -5
- package/src/plugins/ipc.js +3 -4
- package/src/plugins/load.js +3 -3
- package/src/plugins/spawn.js +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "19.0.
|
|
3
|
+
"version": "19.0.6",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"main": "src/core/main.js",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"ci",
|
|
37
37
|
"plugins",
|
|
38
38
|
"continuous-integration",
|
|
39
|
-
"continuous-delivery",
|
|
40
39
|
"continuous-deployment",
|
|
40
|
+
"continuous-delivery",
|
|
41
41
|
"continuous-testing",
|
|
42
42
|
"netlify-plugin",
|
|
43
43
|
"netlify"
|
package/src/error/build.js
CHANGED
|
@@ -5,7 +5,8 @@ const safeJsonStringify = require('safe-json-stringify')
|
|
|
5
5
|
const { CUSTOM_ERROR_KEY } = require('./info')
|
|
6
6
|
|
|
7
7
|
// Retrieve error information from child process and re-build it in current
|
|
8
|
-
// process. We need this since errors are not
|
|
8
|
+
// process. We need this since errors static properties are not kept by
|
|
9
|
+
// `v8.serialize()`.
|
|
9
10
|
const jsonToError = function ({ name, message, stack, ...errorProps }) {
|
|
10
11
|
// eslint-disable-next-line unicorn/error-message
|
|
11
12
|
const error = new Error('')
|
|
@@ -35,8 +36,6 @@ const assignErrorProp = function (error, name, value) {
|
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
// Inverse of `jsonToError()`.
|
|
38
|
-
// IPC uses JSON for the payload. We ensure there are not circular references
|
|
39
|
-
// as those would make the message sending fail.
|
|
40
39
|
const errorToJson = function ({ name, message, stack, [CUSTOM_ERROR_KEY]: customError, ...errorProps }) {
|
|
41
40
|
return {
|
|
42
41
|
...safeJsonStringify.ensureProperties(errorProps),
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
+
const filterObj = require('filter-obj')
|
|
4
|
+
|
|
3
5
|
const { getLogic } = require('./logic')
|
|
4
6
|
const { registerTypeScript } = require('./typescript')
|
|
5
7
|
const { validatePlugin } = require('./validate')
|
|
@@ -15,21 +17,16 @@ const load = function ({ pluginPath, inputs, packageJson }) {
|
|
|
15
17
|
|
|
16
18
|
validatePlugin(logic)
|
|
17
19
|
|
|
18
|
-
const
|
|
20
|
+
const methods = filterObj(logic, isEventHandler)
|
|
21
|
+
const events = Object.keys(methods)
|
|
19
22
|
|
|
20
23
|
// Context passed to every event handler
|
|
21
|
-
const context = {
|
|
22
|
-
|
|
23
|
-
return { pluginSteps, context }
|
|
24
|
-
}
|
|
24
|
+
const context = { methods, inputs, packageJson }
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
return Object.entries(logic)
|
|
28
|
-
.filter(isEventHandler)
|
|
29
|
-
.map(([event, method]) => ({ event, method }))
|
|
26
|
+
return { events, context }
|
|
30
27
|
}
|
|
31
28
|
|
|
32
|
-
const isEventHandler = function (
|
|
29
|
+
const isEventHandler = function (event, value) {
|
|
33
30
|
return typeof value === 'function'
|
|
34
31
|
}
|
|
35
32
|
|
package/src/plugins/child/run.js
CHANGED
|
@@ -6,11 +6,8 @@ const { cloneNetlifyConfig, getConfigMutations } = require('./diff')
|
|
|
6
6
|
const { getUtils } = require('./utils')
|
|
7
7
|
|
|
8
8
|
// Run a specific plugin event handler
|
|
9
|
-
const run = async function (
|
|
10
|
-
|
|
11
|
-
{ pluginSteps, inputs, packageJson },
|
|
12
|
-
) {
|
|
13
|
-
const { method } = pluginSteps.find((pluginStep) => pluginStep.event === event)
|
|
9
|
+
const run = async function ({ event, error, constants, envChanges, netlifyConfig }, { methods, inputs, packageJson }) {
|
|
10
|
+
const method = methods[event]
|
|
14
11
|
const runState = {}
|
|
15
12
|
const utils = getUtils({ event, constants, runState })
|
|
16
13
|
const netlifyConfigCopy = cloneNetlifyConfig(netlifyConfig)
|
package/src/plugins/ipc.js
CHANGED
|
@@ -113,10 +113,9 @@ const sendEventToParent = async function (callId, payload) {
|
|
|
113
113
|
await promisify(process.send.bind(process))([callId, payload])
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
//
|
|
117
|
-
// convert from/to
|
|
118
|
-
//
|
|
119
|
-
// dropping support for Node.js <=12.6.0
|
|
116
|
+
// Error static properties are not serializable through `child_process`
|
|
117
|
+
// (which uses `v8.serialize()` under the hood) so we need to convert from/to
|
|
118
|
+
// plain objects.
|
|
120
119
|
const serializePayload = function ({ error = {}, error: { name } = {}, ...payload }) {
|
|
121
120
|
if (name === undefined) {
|
|
122
121
|
return payload
|
package/src/plugins/load.js
CHANGED
|
@@ -37,8 +37,8 @@ const loadPlugin = async function (
|
|
|
37
37
|
const loadEvent = 'load'
|
|
38
38
|
|
|
39
39
|
try {
|
|
40
|
-
const {
|
|
41
|
-
const
|
|
40
|
+
const { events } = await callChild(childProcess, 'load', { pluginPath, inputs, packageJson })
|
|
41
|
+
const pluginSteps = events.map((event) => ({
|
|
42
42
|
event,
|
|
43
43
|
packageName,
|
|
44
44
|
loadedFrom,
|
|
@@ -46,7 +46,7 @@ const loadPlugin = async function (
|
|
|
46
46
|
pluginPackageJson,
|
|
47
47
|
childProcess,
|
|
48
48
|
}))
|
|
49
|
-
return
|
|
49
|
+
return pluginSteps
|
|
50
50
|
} catch (error) {
|
|
51
51
|
addErrorInfo(error, {
|
|
52
52
|
plugin: { packageName, pluginPackageJson },
|