@netlify/build 27.20.3 → 27.20.5
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/lib/core/bin.js +42 -59
- package/lib/core/build.js +333 -536
- package/lib/core/config.js +94 -159
- package/lib/core/constants.js +95 -135
- package/lib/core/dev.js +26 -30
- package/lib/core/dry.js +18 -36
- package/lib/core/feature_flags.js +13 -16
- package/lib/core/flags.js +168 -169
- package/lib/core/lingering.js +44 -61
- package/lib/core/main.js +94 -136
- package/lib/core/missing_side_file.js +12 -24
- package/lib/core/normalize_flags.js +52 -63
- package/lib/core/severity.js +13 -15
- package/lib/core/user_node_version.js +26 -35
- package/lib/env/changes.js +29 -37
- package/lib/env/main.js +10 -15
- package/lib/env/metadata.js +63 -76
- package/lib/error/api.js +31 -40
- package/lib/error/build.js +27 -38
- package/lib/error/cancel.js +5 -6
- package/lib/error/colors.js +7 -9
- package/lib/error/handle.js +38 -49
- package/lib/error/info.js +26 -35
- package/lib/error/monitor/location.js +12 -17
- package/lib/error/monitor/normalize.js +75 -85
- package/lib/error/monitor/print.js +19 -41
- package/lib/error/monitor/report.js +102 -121
- package/lib/error/monitor/start.js +43 -56
- package/lib/error/parse/clean_stack.js +52 -69
- package/lib/error/parse/location.js +40 -52
- package/lib/error/parse/normalize.js +18 -23
- package/lib/error/parse/parse.js +59 -93
- package/lib/error/parse/plugin.js +42 -57
- package/lib/error/parse/properties.js +13 -20
- package/lib/error/parse/serialize_log.js +29 -37
- package/lib/error/parse/serialize_status.js +15 -23
- package/lib/error/parse/stack.js +29 -38
- package/lib/error/type.js +132 -150
- package/lib/install/functions.js +16 -24
- package/lib/install/local.js +31 -48
- package/lib/install/main.js +52 -66
- package/lib/install/missing.js +40 -53
- package/lib/log/colors.js +15 -22
- package/lib/log/description.js +16 -21
- package/lib/log/header.js +11 -13
- package/lib/log/header_func.js +11 -15
- package/lib/log/logger.js +88 -119
- package/lib/log/messages/compatibility.js +100 -158
- package/lib/log/messages/config.js +76 -92
- package/lib/log/messages/core.js +40 -60
- package/lib/log/messages/core_steps.js +63 -92
- package/lib/log/messages/dry.js +31 -53
- package/lib/log/messages/install.js +21 -28
- package/lib/log/messages/ipc.js +21 -30
- package/lib/log/messages/mutations.js +51 -71
- package/lib/log/messages/plugins.js +18 -31
- package/lib/log/messages/status.js +12 -14
- package/lib/log/messages/steps.js +14 -18
- package/lib/log/old_version.js +23 -32
- package/lib/log/serialize.js +7 -10
- package/lib/log/stream.js +48 -65
- package/lib/log/theme.js +22 -23
- package/lib/plugins/child/diff.js +31 -40
- package/lib/plugins/child/error.js +20 -26
- package/lib/plugins/child/lazy.js +11 -14
- package/lib/plugins/child/load.js +15 -22
- package/lib/plugins/child/logic.js +51 -58
- package/lib/plugins/child/main.js +32 -46
- package/lib/plugins/child/run.js +18 -27
- package/lib/plugins/child/status.js +52 -63
- package/lib/plugins/child/typescript.js +19 -36
- package/lib/plugins/child/utils.js +36 -49
- package/lib/plugins/child/validate.js +25 -28
- package/lib/plugins/compatibility.js +64 -92
- package/lib/plugins/error.js +29 -35
- package/lib/plugins/events.js +7 -12
- package/lib/plugins/expected_version.js +61 -99
- package/lib/plugins/ipc.js +79 -102
- package/lib/plugins/list.js +49 -62
- package/lib/plugins/load.js +44 -64
- package/lib/plugins/manifest/check.js +64 -85
- package/lib/plugins/manifest/load.js +34 -37
- package/lib/plugins/manifest/main.js +16 -21
- package/lib/plugins/manifest/path.js +18 -25
- package/lib/plugins/manifest/validate.js +77 -94
- package/lib/plugins/node_version.js +22 -42
- package/lib/plugins/options.js +45 -78
- package/lib/plugins/pinned_version.js +58 -106
- package/lib/plugins/resolve.js +91 -133
- package/lib/plugins/spawn.js +43 -61
- package/lib/plugins_core/add.js +26 -40
- package/lib/plugins_core/build_command.js +47 -72
- package/lib/plugins_core/deploy/buildbot_client.js +61 -87
- package/lib/plugins_core/deploy/index.js +47 -71
- package/lib/plugins_core/edge_functions/index.js +73 -116
- package/lib/plugins_core/edge_functions/lib/error.js +13 -17
- package/lib/plugins_core/edge_functions/lib/internal_manifest.js +45 -55
- package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +65 -80
- package/lib/plugins_core/functions/error.js +88 -128
- package/lib/plugins_core/functions/feature_flags.js +5 -5
- package/lib/plugins_core/functions/index.js +98 -145
- package/lib/plugins_core/functions/utils.js +36 -57
- package/lib/plugins_core/functions/zisi.js +35 -52
- package/lib/plugins_core/functions_install/index.js +8 -11
- package/lib/plugins_core/list.js +15 -22
- package/lib/status/add.js +26 -32
- package/lib/status/colors.js +14 -19
- package/lib/status/load_error.js +8 -9
- package/lib/status/report.js +72 -126
- package/lib/status/success.js +10 -14
- package/lib/steps/core_step.js +54 -89
- package/lib/steps/error.js +50 -87
- package/lib/steps/get.js +33 -41
- package/lib/steps/plugin.js +53 -83
- package/lib/steps/return.js +24 -51
- package/lib/steps/run_core_steps.js +119 -171
- package/lib/steps/run_step.js +154 -270
- package/lib/steps/run_steps.js +91 -174
- package/lib/steps/update_config.js +45 -72
- package/lib/telemetry/main.js +89 -128
- package/lib/time/aggregate.js +84 -110
- package/lib/time/main.js +23 -34
- package/lib/time/measure.js +11 -15
- package/lib/time/report.js +32 -44
- package/lib/utils/errors.js +10 -9
- package/lib/utils/json.js +11 -15
- package/lib/utils/omit.js +3 -4
- package/lib/utils/package.js +19 -22
- package/lib/utils/remove_falsy.js +5 -7
- package/lib/utils/resolve.js +30 -34
- package/lib/utils/runtime.js +4 -4
- package/lib/utils/semver.js +19 -25
- package/package.json +15 -8
|
@@ -1,51 +1,37 @@
|
|
|
1
|
-
import { setInspectColors } from '../../log/colors.js'
|
|
2
|
-
import { sendEventToParent, getEventsFromParent } from '../ipc.js'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { run } from './run.js'
|
|
7
|
-
|
|
1
|
+
import { setInspectColors } from '../../log/colors.js';
|
|
2
|
+
import { sendEventToParent, getEventsFromParent } from '../ipc.js';
|
|
3
|
+
import { handleProcessErrors, handleError } from './error.js';
|
|
4
|
+
import { load } from './load.js';
|
|
5
|
+
import { run } from './run.js';
|
|
8
6
|
// Boot plugin child process.
|
|
9
7
|
const bootPlugin = async function () {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
8
|
+
const state = { context: { verbose: false } };
|
|
9
|
+
try {
|
|
10
|
+
handleProcessErrors();
|
|
11
|
+
setInspectColors();
|
|
12
|
+
// We need to fire them in parallel because `process.send()` can be slow
|
|
13
|
+
// to await, i.e. parent might send `load` event before child `ready` event
|
|
14
|
+
// returns.
|
|
15
|
+
await Promise.all([handleEvents(state), sendEventToParent('ready', {}, false)]);
|
|
16
|
+
}
|
|
17
|
+
catch (error) {
|
|
18
|
+
await handleError(error, state.context.verbose);
|
|
19
|
+
}
|
|
20
|
+
};
|
|
25
21
|
// Wait for events from parent to perform plugin methods
|
|
26
22
|
const handleEvents = async function (state) {
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
|
|
23
|
+
await getEventsFromParent((callId, eventName, payload) => handleEvent({ callId, eventName, payload, state }));
|
|
24
|
+
};
|
|
30
25
|
// Each event can pass `context` information to the next event
|
|
31
|
-
const handleEvent = async function ({
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
await sendEventToParent(callId, response, verbose)
|
|
44
|
-
} catch (error) {
|
|
45
|
-
await handleError(error, verbose)
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const EVENTS = { load, run }
|
|
50
|
-
|
|
51
|
-
bootPlugin()
|
|
26
|
+
const handleEvent = async function ({ callId, eventName, payload, state, state: { context: { verbose }, }, }) {
|
|
27
|
+
try {
|
|
28
|
+
const { context, ...response } = await EVENTS[eventName](payload, state.context);
|
|
29
|
+
state.context = { ...state.context, ...context };
|
|
30
|
+
await sendEventToParent(callId, response, verbose);
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
await handleError(error, verbose);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
const EVENTS = { load, run };
|
|
37
|
+
bootPlugin();
|
package/lib/plugins/child/run.js
CHANGED
|
@@ -1,28 +1,19 @@
|
|
|
1
|
-
import { getNewEnvChanges, setEnvChanges } from '../../env/changes.js'
|
|
2
|
-
import { logPluginMethodStart, logPluginMethodEnd } from '../../log/messages/ipc.js'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
import { getUtils } from './utils.js'
|
|
6
|
-
|
|
1
|
+
import { getNewEnvChanges, setEnvChanges } from '../../env/changes.js';
|
|
2
|
+
import { logPluginMethodStart, logPluginMethodEnd } from '../../log/messages/ipc.js';
|
|
3
|
+
import { cloneNetlifyConfig, getConfigMutations } from './diff.js';
|
|
4
|
+
import { getUtils } from './utils.js';
|
|
7
5
|
// Run a specific plugin event handler
|
|
8
|
-
export const run = async function (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
logPluginMethodEnd(verbose)
|
|
23
|
-
|
|
24
|
-
const newEnvChanges = getNewEnvChanges(envBefore, netlifyConfig, netlifyConfigCopy)
|
|
25
|
-
|
|
26
|
-
const configMutations = getConfigMutations(netlifyConfig, netlifyConfigCopy, event)
|
|
27
|
-
return { ...runState, newEnvChanges, configMutations }
|
|
28
|
-
}
|
|
6
|
+
export const run = async function ({ event, error, constants, envChanges, netlifyConfig }, { methods, inputs, packageJson, verbose }) {
|
|
7
|
+
const method = methods[event];
|
|
8
|
+
const runState = {};
|
|
9
|
+
const utils = getUtils({ event, constants, runState });
|
|
10
|
+
const netlifyConfigCopy = cloneNetlifyConfig(netlifyConfig);
|
|
11
|
+
const runOptions = { utils, constants, inputs, netlifyConfig: netlifyConfigCopy, packageJson, error };
|
|
12
|
+
const envBefore = setEnvChanges(envChanges);
|
|
13
|
+
logPluginMethodStart(verbose);
|
|
14
|
+
await method(runOptions);
|
|
15
|
+
logPluginMethodEnd(verbose);
|
|
16
|
+
const newEnvChanges = getNewEnvChanges(envBefore, netlifyConfig, netlifyConfigCopy);
|
|
17
|
+
const configMutations = getConfigMutations(netlifyConfig, netlifyConfigCopy, event);
|
|
18
|
+
return { ...runState, newEnvChanges, configMutations };
|
|
19
|
+
};
|
|
@@ -1,74 +1,63 @@
|
|
|
1
|
-
import isPlainObj from 'is-plain-obj'
|
|
2
|
-
import mapObj from 'map-obj'
|
|
3
|
-
|
|
4
|
-
import { addErrorInfo } from '../../error/info.js'
|
|
5
|
-
|
|
1
|
+
import isPlainObj from 'is-plain-obj';
|
|
2
|
+
import mapObj from 'map-obj';
|
|
3
|
+
import { addErrorInfo } from '../../error/info.js';
|
|
6
4
|
// Report status information to the UI
|
|
7
5
|
export const show = function (runState, showArgs) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
6
|
+
validateShowArgs(showArgs);
|
|
7
|
+
const { title, summary, text, extraData } = removeEmptyStrings(showArgs);
|
|
8
|
+
runState.status = { state: 'success', title, summary, text, extraData };
|
|
9
|
+
};
|
|
13
10
|
// Validate arguments of `utils.status.show()`
|
|
14
11
|
const validateShowArgs = function (showArgs) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
|
|
12
|
+
try {
|
|
13
|
+
validateShowArgsObject(showArgs);
|
|
14
|
+
const { title, summary, text, extraData, ...otherArgs } = showArgs;
|
|
15
|
+
validateShowArgsKeys(otherArgs);
|
|
16
|
+
Object.entries({ title, summary, text }).forEach(validateStringArg);
|
|
17
|
+
validateShowArgsSummary(summary);
|
|
18
|
+
validateShowArgsExtraData(extraData);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
error.message = `utils.status.show() ${error.message}`;
|
|
22
|
+
addErrorInfo(error, { type: 'pluginValidation' });
|
|
23
|
+
throw error;
|
|
24
|
+
}
|
|
25
|
+
};
|
|
29
26
|
const validateShowArgsObject = function (showArgs) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
|
|
27
|
+
if (showArgs === undefined) {
|
|
28
|
+
throw new Error('requires an argument');
|
|
29
|
+
}
|
|
30
|
+
if (!isPlainObj(showArgs)) {
|
|
31
|
+
throw new Error('argument must be a plain object');
|
|
32
|
+
}
|
|
33
|
+
};
|
|
39
34
|
const validateShowArgsKeys = function (otherArgs) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
35
|
+
const otherKeys = Object.keys(otherArgs).map((arg) => `"${arg}"`);
|
|
36
|
+
if (otherKeys.length !== 0) {
|
|
37
|
+
throw new Error(`must only contain "title", "summary" or "text" properties, not ${otherKeys.join(', ')}`);
|
|
38
|
+
}
|
|
39
|
+
};
|
|
46
40
|
const validateStringArg = function ([key, value]) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
41
|
+
if (value !== undefined && typeof value !== 'string') {
|
|
42
|
+
throw new Error(`"${key}" property must be a string`);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
52
45
|
const validateShowArgsSummary = function (summary) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
57
|
-
|
|
46
|
+
if (summary === undefined || summary.trim() === '') {
|
|
47
|
+
throw new Error('requires specifying a "summary" property');
|
|
48
|
+
}
|
|
49
|
+
};
|
|
58
50
|
const validateShowArgsExtraData = function (extraData) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
51
|
+
if (extraData !== undefined && Array.isArray(extraData) === false) {
|
|
52
|
+
throw new TypeError('provided extra data must be an array');
|
|
53
|
+
}
|
|
54
|
+
};
|
|
64
55
|
const removeEmptyStrings = function (showArgs) {
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
56
|
+
return mapObj(showArgs, removeEmptyString);
|
|
57
|
+
};
|
|
68
58
|
const removeEmptyString = function (key, value) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}
|
|
59
|
+
if (typeof value === 'string' && value.trim() === '') {
|
|
60
|
+
return [key];
|
|
61
|
+
}
|
|
62
|
+
return [key, value];
|
|
63
|
+
};
|
|
@@ -1,45 +1,28 @@
|
|
|
1
|
-
import { extname } from 'path'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
import { addErrorInfo } from '../../error/info.js'
|
|
6
|
-
|
|
1
|
+
import { extname } from 'path';
|
|
2
|
+
import { register } from 'ts-node';
|
|
3
|
+
import { addErrorInfo } from '../../error/info.js';
|
|
7
4
|
// Allow local plugins to be written with TypeScript.
|
|
8
5
|
// Local plugins cannot be transpiled by the build command since they can be run
|
|
9
6
|
// before it. Therefore, we type-check and transpile them automatically using
|
|
10
7
|
// `ts-node`.
|
|
11
8
|
export const registerTypeScript = function (pluginPath) {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
9
|
+
if (!isTypeScriptPlugin(pluginPath)) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
return register();
|
|
13
|
+
};
|
|
19
14
|
// On TypeScript errors, adds information about the `ts-node` configuration,
|
|
20
15
|
// which includes the resolved `tsconfig.json`.
|
|
21
16
|
export const addTsErrorInfo = function (error, tsNodeService) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
options: realTsNodeOptions,
|
|
31
|
-
} = tsNodeService
|
|
32
|
-
|
|
33
|
-
// filter out functions as they cannot be serialized
|
|
34
|
-
const tsNodeOptions = Object.fromEntries(
|
|
35
|
-
Object.entries(realTsNodeOptions).filter(([, val]) => typeof val !== 'function'),
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
addErrorInfo(error, { tsConfig: { compilerOptions, tsNodeOptions } })
|
|
39
|
-
}
|
|
40
|
-
|
|
17
|
+
if (tsNodeService === undefined) {
|
|
18
|
+
return;
|
|
19
|
+
}
|
|
20
|
+
const { config: { raw: { compilerOptions }, }, options: realTsNodeOptions, } = tsNodeService;
|
|
21
|
+
// filter out functions as they cannot be serialized
|
|
22
|
+
const tsNodeOptions = Object.fromEntries(Object.entries(realTsNodeOptions).filter(([, val]) => typeof val !== 'function'));
|
|
23
|
+
addErrorInfo(error, { tsConfig: { compilerOptions, tsNodeOptions } });
|
|
24
|
+
};
|
|
41
25
|
const isTypeScriptPlugin = function (pluginPath) {
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
const TYPESCRIPT_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.cts'])
|
|
26
|
+
return TYPESCRIPT_EXTENSIONS.has(extname(pluginPath));
|
|
27
|
+
};
|
|
28
|
+
const TYPESCRIPT_EXTENSIONS = new Set(['.ts', '.tsx', '.mts', '.cts']);
|
|
@@ -1,55 +1,42 @@
|
|
|
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'
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import { addLazyProp } from './lazy.js'
|
|
10
|
-
import { show } from './status.js'
|
|
11
|
-
|
|
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';
|
|
5
|
+
import { failBuild, failPlugin, cancelBuild, failPluginWithWarning } from '../error.js';
|
|
6
|
+
import { isSoftFailEvent } from '../events.js';
|
|
7
|
+
import { addLazyProp } from './lazy.js';
|
|
8
|
+
import { show } from './status.js';
|
|
12
9
|
// Retrieve the `utils` argument.
|
|
13
|
-
export const getUtils = function ({
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const status = getStatusUtils(runState)
|
|
24
|
-
const utils = { build, cache, run, functions, status }
|
|
25
|
-
addLazyProp(utils, 'git', () => getGitUtils())
|
|
26
|
-
return utils
|
|
27
|
-
}
|
|
28
|
-
|
|
10
|
+
export const getUtils = function ({ event, constants: { FUNCTIONS_SRC, INTERNAL_FUNCTIONS_SRC, CACHE_DIR }, runState, }) {
|
|
11
|
+
run.command = runCommand;
|
|
12
|
+
const build = getBuildUtils(event);
|
|
13
|
+
const cache = getCacheUtils(CACHE_DIR);
|
|
14
|
+
const functions = getFunctionsUtils(FUNCTIONS_SRC, INTERNAL_FUNCTIONS_SRC);
|
|
15
|
+
const status = getStatusUtils(runState);
|
|
16
|
+
const utils = { build, cache, run, functions, status };
|
|
17
|
+
addLazyProp(utils, 'git', () => getGitUtils());
|
|
18
|
+
return utils;
|
|
19
|
+
};
|
|
29
20
|
const getBuildUtils = function (event) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
21
|
+
if (isSoftFailEvent(event)) {
|
|
22
|
+
return {
|
|
23
|
+
failPlugin,
|
|
24
|
+
failBuild: failPluginWithWarning.bind(null, 'failBuild', event),
|
|
25
|
+
cancelBuild: failPluginWithWarning.bind(null, 'cancelBuild', event),
|
|
26
|
+
};
|
|
35
27
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
return { failBuild, failPlugin, cancelBuild }
|
|
39
|
-
}
|
|
40
|
-
|
|
28
|
+
return { failBuild, failPlugin, cancelBuild };
|
|
29
|
+
};
|
|
41
30
|
const getCacheUtils = function (CACHE_DIR) {
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
31
|
+
return cacheBindOpts({ cacheDir: CACHE_DIR });
|
|
32
|
+
};
|
|
45
33
|
const getFunctionsUtils = function (FUNCTIONS_SRC, INTERNAL_FUNCTIONS_SRC) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
52
|
-
|
|
34
|
+
const functionsDirectories = [INTERNAL_FUNCTIONS_SRC, FUNCTIONS_SRC].filter(Boolean);
|
|
35
|
+
const add = (src) => functionsAdd(src, INTERNAL_FUNCTIONS_SRC, { fail: failBuild });
|
|
36
|
+
const list = functionsList.bind(null, functionsDirectories, { fail: failBuild });
|
|
37
|
+
const listAll = functionsListAll.bind(null, functionsDirectories, { fail: failBuild });
|
|
38
|
+
return { add, list, listAll };
|
|
39
|
+
};
|
|
53
40
|
const getStatusUtils = function (runState) {
|
|
54
|
-
|
|
55
|
-
}
|
|
41
|
+
return { show: show.bind(undefined, runState) };
|
|
42
|
+
};
|
|
@@ -1,34 +1,31 @@
|
|
|
1
|
-
import { addErrorInfo } from '../../error/info.js'
|
|
2
|
-
import { serializeArray } from '../../log/serialize.js'
|
|
3
|
-
import { DEV_EVENTS, EVENTS } from '../events.js'
|
|
4
|
-
|
|
1
|
+
import { addErrorInfo } from '../../error/info.js';
|
|
2
|
+
import { serializeArray } from '../../log/serialize.js';
|
|
3
|
+
import { DEV_EVENTS, EVENTS } from '../events.js';
|
|
5
4
|
// Validate the shape of a plugin return value
|
|
6
5
|
export const validatePlugin = function (logic) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
try {
|
|
7
|
+
// This validation must work with the return value of `import()` which has
|
|
8
|
+
// a `Module` prototype, not `Object`
|
|
9
|
+
if (typeof logic !== 'object' || logic === null) {
|
|
10
|
+
throw new Error('Plugin must be an object or a function');
|
|
11
|
+
}
|
|
12
|
+
Object.entries(logic).forEach(([propName, value]) => {
|
|
13
|
+
validateEventHandler(value, propName);
|
|
14
|
+
});
|
|
12
15
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
addErrorInfo(error, { type: 'pluginValidation' })
|
|
19
|
-
throw error
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
|
|
16
|
+
catch (error) {
|
|
17
|
+
addErrorInfo(error, { type: 'pluginValidation' });
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
};
|
|
23
21
|
// All other properties are event handlers
|
|
24
22
|
const validateEventHandler = function (value, propName) {
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
if (!EVENTS.includes(propName) && !DEV_EVENTS.includes(propName)) {
|
|
24
|
+
throw new Error(`Invalid event '${propName}'.
|
|
27
25
|
Please use a valid event name. One of:
|
|
28
|
-
${serializeArray(EVENTS)}`)
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
26
|
+
${serializeArray(EVENTS)}`);
|
|
27
|
+
}
|
|
28
|
+
if (typeof value !== 'function') {
|
|
29
|
+
throw new TypeError(`Invalid event handler '${propName}': must be a function`);
|
|
30
|
+
}
|
|
31
|
+
};
|