@netlify/build 27.20.4 → 27.20.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.
Files changed (133) hide show
  1. package/lib/core/bin.js +42 -59
  2. package/lib/core/build.js +333 -536
  3. package/lib/core/config.js +94 -159
  4. package/lib/core/constants.js +95 -135
  5. package/lib/core/dev.js +26 -30
  6. package/lib/core/dry.js +18 -36
  7. package/lib/core/feature_flags.js +13 -16
  8. package/lib/core/flags.js +168 -169
  9. package/lib/core/lingering.js +44 -61
  10. package/lib/core/main.js +94 -136
  11. package/lib/core/missing_side_file.js +12 -24
  12. package/lib/core/normalize_flags.js +52 -63
  13. package/lib/core/severity.js +13 -15
  14. package/lib/core/user_node_version.js +26 -35
  15. package/lib/env/changes.js +29 -37
  16. package/lib/env/main.js +10 -15
  17. package/lib/env/metadata.js +63 -76
  18. package/lib/error/api.js +31 -40
  19. package/lib/error/build.js +27 -38
  20. package/lib/error/cancel.js +5 -6
  21. package/lib/error/colors.js +7 -9
  22. package/lib/error/handle.js +38 -49
  23. package/lib/error/info.js +26 -35
  24. package/lib/error/monitor/location.js +12 -17
  25. package/lib/error/monitor/normalize.js +75 -85
  26. package/lib/error/monitor/print.js +19 -41
  27. package/lib/error/monitor/report.js +102 -121
  28. package/lib/error/monitor/start.js +43 -56
  29. package/lib/error/parse/clean_stack.js +52 -69
  30. package/lib/error/parse/location.js +40 -52
  31. package/lib/error/parse/normalize.js +18 -23
  32. package/lib/error/parse/parse.js +59 -93
  33. package/lib/error/parse/plugin.js +42 -57
  34. package/lib/error/parse/properties.js +13 -20
  35. package/lib/error/parse/serialize_log.js +29 -37
  36. package/lib/error/parse/serialize_status.js +15 -23
  37. package/lib/error/parse/stack.js +29 -38
  38. package/lib/error/type.js +132 -150
  39. package/lib/install/functions.js +16 -24
  40. package/lib/install/local.js +31 -48
  41. package/lib/install/main.js +52 -66
  42. package/lib/install/missing.js +40 -53
  43. package/lib/log/colors.js +15 -22
  44. package/lib/log/description.js +16 -21
  45. package/lib/log/header.js +11 -13
  46. package/lib/log/header_func.js +11 -15
  47. package/lib/log/logger.js +88 -119
  48. package/lib/log/messages/compatibility.js +100 -158
  49. package/lib/log/messages/config.js +76 -92
  50. package/lib/log/messages/core.js +40 -60
  51. package/lib/log/messages/core_steps.js +63 -92
  52. package/lib/log/messages/dry.js +31 -53
  53. package/lib/log/messages/install.js +21 -28
  54. package/lib/log/messages/ipc.js +21 -30
  55. package/lib/log/messages/mutations.js +51 -71
  56. package/lib/log/messages/plugins.js +18 -31
  57. package/lib/log/messages/status.js +12 -14
  58. package/lib/log/messages/steps.js +14 -18
  59. package/lib/log/old_version.js +23 -32
  60. package/lib/log/serialize.js +7 -10
  61. package/lib/log/stream.js +48 -65
  62. package/lib/log/theme.js +22 -23
  63. package/lib/plugins/child/diff.js +31 -40
  64. package/lib/plugins/child/error.js +20 -26
  65. package/lib/plugins/child/lazy.js +11 -14
  66. package/lib/plugins/child/load.js +15 -22
  67. package/lib/plugins/child/logic.js +51 -58
  68. package/lib/plugins/child/main.js +32 -46
  69. package/lib/plugins/child/run.js +18 -27
  70. package/lib/plugins/child/status.js +52 -63
  71. package/lib/plugins/child/typescript.js +19 -36
  72. package/lib/plugins/child/utils.js +36 -49
  73. package/lib/plugins/child/validate.js +25 -28
  74. package/lib/plugins/compatibility.js +64 -92
  75. package/lib/plugins/error.js +29 -35
  76. package/lib/plugins/events.js +7 -12
  77. package/lib/plugins/expected_version.js +61 -99
  78. package/lib/plugins/ipc.js +79 -102
  79. package/lib/plugins/list.js +49 -62
  80. package/lib/plugins/load.js +44 -64
  81. package/lib/plugins/manifest/check.js +64 -85
  82. package/lib/plugins/manifest/load.js +34 -37
  83. package/lib/plugins/manifest/main.js +16 -21
  84. package/lib/plugins/manifest/path.js +18 -25
  85. package/lib/plugins/manifest/validate.js +77 -94
  86. package/lib/plugins/node_version.js +22 -42
  87. package/lib/plugins/options.js +45 -78
  88. package/lib/plugins/pinned_version.js +58 -106
  89. package/lib/plugins/resolve.js +91 -133
  90. package/lib/plugins/spawn.js +43 -61
  91. package/lib/plugins_core/add.js +26 -40
  92. package/lib/plugins_core/build_command.js +47 -72
  93. package/lib/plugins_core/deploy/buildbot_client.js +61 -87
  94. package/lib/plugins_core/deploy/index.js +47 -71
  95. package/lib/plugins_core/edge_functions/index.js +73 -116
  96. package/lib/plugins_core/edge_functions/lib/error.js +13 -17
  97. package/lib/plugins_core/edge_functions/lib/internal_manifest.js +45 -55
  98. package/lib/plugins_core/edge_functions/validate_manifest/validate_edge_functions_manifest.js +65 -80
  99. package/lib/plugins_core/functions/error.js +88 -128
  100. package/lib/plugins_core/functions/feature_flags.js +5 -5
  101. package/lib/plugins_core/functions/index.js +98 -145
  102. package/lib/plugins_core/functions/utils.js +36 -57
  103. package/lib/plugins_core/functions/zisi.js +35 -52
  104. package/lib/plugins_core/functions_install/index.js +8 -11
  105. package/lib/plugins_core/list.js +15 -22
  106. package/lib/status/add.js +26 -32
  107. package/lib/status/colors.js +14 -19
  108. package/lib/status/load_error.js +8 -9
  109. package/lib/status/report.js +72 -126
  110. package/lib/status/success.js +10 -14
  111. package/lib/steps/core_step.js +54 -89
  112. package/lib/steps/error.js +50 -87
  113. package/lib/steps/get.js +33 -41
  114. package/lib/steps/plugin.js +53 -83
  115. package/lib/steps/return.js +24 -51
  116. package/lib/steps/run_core_steps.js +119 -171
  117. package/lib/steps/run_step.js +154 -270
  118. package/lib/steps/run_steps.js +91 -174
  119. package/lib/steps/update_config.js +45 -72
  120. package/lib/telemetry/main.js +89 -128
  121. package/lib/time/aggregate.js +84 -110
  122. package/lib/time/main.js +23 -34
  123. package/lib/time/measure.js +11 -15
  124. package/lib/time/report.js +32 -44
  125. package/lib/utils/errors.js +10 -9
  126. package/lib/utils/json.js +11 -15
  127. package/lib/utils/omit.js +3 -4
  128. package/lib/utils/package.js +19 -22
  129. package/lib/utils/remove_falsy.js +5 -7
  130. package/lib/utils/resolve.js +30 -34
  131. package/lib/utils/runtime.js +4 -4
  132. package/lib/utils/semver.js +19 -25
  133. package/package.json +14 -7
@@ -1,51 +1,37 @@
1
- import { setInspectColors } from '../../log/colors.js'
2
- import { sendEventToParent, getEventsFromParent } from '../ipc.js'
3
-
4
- import { handleProcessErrors, handleError } from './error.js'
5
- import { load } from './load.js'
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
- const state = { context: { verbose: false } }
11
-
12
- try {
13
- handleProcessErrors()
14
- setInspectColors()
15
-
16
- // We need to fire them in parallel because `process.send()` can be slow
17
- // to await, i.e. parent might send `load` event before child `ready` event
18
- // returns.
19
- await Promise.all([handleEvents(state), sendEventToParent('ready', {}, false)])
20
- } catch (error) {
21
- await handleError(error, state.context.verbose)
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
- await getEventsFromParent((callId, eventName, payload) => handleEvent({ callId, eventName, payload, state }))
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
- callId,
33
- eventName,
34
- payload,
35
- state,
36
- state: {
37
- context: { verbose },
38
- },
39
- }) {
40
- try {
41
- const { context, ...response } = await EVENTS[eventName](payload, state.context)
42
- state.context = { ...state.context, ...context }
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();
@@ -1,28 +1,19 @@
1
- import { getNewEnvChanges, setEnvChanges } from '../../env/changes.js'
2
- import { logPluginMethodStart, logPluginMethodEnd } from '../../log/messages/ipc.js'
3
-
4
- import { cloneNetlifyConfig, getConfigMutations } from './diff.js'
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
- { event, error, constants, envChanges, netlifyConfig },
10
- { methods, inputs, packageJson, verbose },
11
- ) {
12
- const method = methods[event]
13
- const runState = {}
14
- const utils = getUtils({ event, constants, runState })
15
- const netlifyConfigCopy = cloneNetlifyConfig(netlifyConfig)
16
- const runOptions = { utils, constants, inputs, netlifyConfig: netlifyConfigCopy, packageJson, error }
17
-
18
- const envBefore = setEnvChanges(envChanges)
19
-
20
- logPluginMethodStart(verbose)
21
- await method(runOptions)
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
- validateShowArgs(showArgs)
9
- const { title, summary, text, extraData } = removeEmptyStrings(showArgs)
10
- runState.status = { state: 'success', title, summary, text, extraData }
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
- try {
16
- validateShowArgsObject(showArgs)
17
- const { title, summary, text, extraData, ...otherArgs } = showArgs
18
- validateShowArgsKeys(otherArgs)
19
- Object.entries({ title, summary, text }).forEach(validateStringArg)
20
- validateShowArgsSummary(summary)
21
- validateShowArgsExtraData(extraData)
22
- } catch (error) {
23
- error.message = `utils.status.show() ${error.message}`
24
- addErrorInfo(error, { type: 'pluginValidation' })
25
- throw error
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
- if (showArgs === undefined) {
31
- throw new Error('requires an argument')
32
- }
33
-
34
- if (!isPlainObj(showArgs)) {
35
- throw new Error('argument must be a plain object')
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
- const otherKeys = Object.keys(otherArgs).map((arg) => `"${arg}"`)
41
- if (otherKeys.length !== 0) {
42
- throw new Error(`must only contain "title", "summary" or "text" properties, not ${otherKeys.join(', ')}`)
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
- if (value !== undefined && typeof value !== 'string') {
48
- throw new Error(`"${key}" property must be a string`)
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
- if (summary === undefined || summary.trim() === '') {
54
- throw new Error('requires specifying a "summary" property')
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
- if (extraData !== undefined && Array.isArray(extraData) === false) {
60
- throw new TypeError('provided extra data must be an array')
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
- return mapObj(showArgs, removeEmptyString)
66
- }
67
-
56
+ return mapObj(showArgs, removeEmptyString);
57
+ };
68
58
  const removeEmptyString = function (key, value) {
69
- if (typeof value === 'string' && value.trim() === '') {
70
- return [key]
71
- }
72
-
73
- return [key, value]
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 { register } from 'ts-node'
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
- if (!isTypeScriptPlugin(pluginPath)) {
13
- return
14
- }
15
-
16
- return register()
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
- if (tsNodeService === undefined) {
23
- return
24
- }
25
-
26
- const {
27
- config: {
28
- raw: { compilerOptions },
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
- return TYPESCRIPT_EXTENSIONS.has(extname(pluginPath))
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 { failBuild, failPlugin, cancelBuild, failPluginWithWarning } from '../error.js'
7
- import { isSoftFailEvent } from '../events.js'
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
- event,
15
- constants: { FUNCTIONS_SRC, INTERNAL_FUNCTIONS_SRC, CACHE_DIR },
16
- runState,
17
- }) {
18
- run.command = runCommand
19
-
20
- const build = getBuildUtils(event)
21
- const cache = getCacheUtils(CACHE_DIR)
22
- const functions = getFunctionsUtils(FUNCTIONS_SRC, INTERNAL_FUNCTIONS_SRC)
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
- if (isSoftFailEvent(event)) {
31
- return {
32
- failPlugin,
33
- failBuild: failPluginWithWarning.bind(null, 'failBuild', event),
34
- cancelBuild: failPluginWithWarning.bind(null, 'cancelBuild', event),
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
- return cacheBindOpts({ cacheDir: CACHE_DIR })
43
- }
44
-
31
+ return cacheBindOpts({ cacheDir: CACHE_DIR });
32
+ };
45
33
  const getFunctionsUtils = function (FUNCTIONS_SRC, INTERNAL_FUNCTIONS_SRC) {
46
- const functionsDirectories = [INTERNAL_FUNCTIONS_SRC, FUNCTIONS_SRC].filter(Boolean)
47
- const add = (src) => functionsAdd(src, INTERNAL_FUNCTIONS_SRC, { fail: failBuild })
48
- const list = functionsList.bind(null, functionsDirectories, { fail: failBuild })
49
- const listAll = functionsListAll.bind(null, functionsDirectories, { fail: failBuild })
50
- return { add, list, listAll }
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
- return { show: show.bind(undefined, runState) }
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
- try {
8
- // This validation must work with the return value of `import()` which has
9
- // a `Module` prototype, not `Object`
10
- if (typeof logic !== 'object' || logic === null) {
11
- throw new Error('Plugin must be an object or a function')
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
- Object.entries(logic).forEach(([propName, value]) => {
15
- validateEventHandler(value, propName)
16
- })
17
- } catch (error) {
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
- if (!EVENTS.includes(propName) && !DEV_EVENTS.includes(propName)) {
26
- throw new Error(`Invalid event '${propName}'.
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
- if (typeof value !== 'function') {
32
- throw new TypeError(`Invalid event handler '${propName}': must be a function`)
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
+ };