@netlify/build 0.4.48 → 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 -88
- 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 -52
- package/src/install/local.js +0 -65
- 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 -348
- 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 -40
- package/src/plugins/child/logic.js +0 -31
- package/src/plugins/child/main.js +0 -48
- package/src/plugins/child/normalize.js +0 -20
- package/src/plugins/child/run.js +0 -34
- package/src/plugins/child/status.js +0 -53
- package/src/plugins/child/utils.js +0 -43
- package/src/plugins/child/validate.js +0 -46
- package/src/plugins/error.js +0 -44
- 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 -47
- package/src/plugins/manifest/main.js +0 -28
- 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
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import { relative } from 'path';
|
|
3
|
+
import { listFunctions } from '@netlify/zip-it-and-ship-it';
|
|
4
|
+
import { addErrorInfo } from '../../error/info.js';
|
|
5
|
+
import { getZisiFeatureFlags } from './feature_flags.js';
|
|
6
|
+
// Returns the `mainFile` of each function found in `functionsSrc`, relative to
|
|
7
|
+
// `functionsSrc`.
|
|
8
|
+
const getRelativeFunctionMainFiles = async function ({ featureFlags, functionsSrc }) {
|
|
9
|
+
if (functionsSrc === undefined) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const zisiFeatureFlags = getZisiFeatureFlags(featureFlags);
|
|
13
|
+
const functions = await listFunctions(functionsSrc, { featureFlags: zisiFeatureFlags });
|
|
14
|
+
return functions.map(({ mainFile }) => relative(functionsSrc, mainFile));
|
|
15
|
+
};
|
|
16
|
+
export const getUserAndInternalFunctions = ({ featureFlags, functionsSrc, functionsSrcExists, internalFunctionsSrc, internalFunctionsSrcExists, }) => {
|
|
17
|
+
const paths = [
|
|
18
|
+
functionsSrcExists ? functionsSrc : undefined,
|
|
19
|
+
internalFunctionsSrcExists ? internalFunctionsSrc : undefined,
|
|
20
|
+
];
|
|
21
|
+
return Promise.all(paths.map((path) => path && getRelativeFunctionMainFiles({ featureFlags, functionsSrc: path })));
|
|
22
|
+
};
|
|
23
|
+
// Returns `true` if the functions directory exists and is valid. Returns
|
|
24
|
+
// `false` if it doesn't exist. Throws an error if it's invalid or can't
|
|
25
|
+
// be accessed.
|
|
26
|
+
export const validateFunctionsSrc = async function ({ functionsSrc, relativeFunctionsSrc }) {
|
|
27
|
+
if (functionsSrc === undefined) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
try {
|
|
31
|
+
const stats = await fs.stat(functionsSrc);
|
|
32
|
+
if (stats.isDirectory()) {
|
|
33
|
+
return true;
|
|
34
|
+
}
|
|
35
|
+
const error = new Error(`The Netlify Functions setting should target a directory, not a regular file: ${relativeFunctionsSrc}`);
|
|
36
|
+
addErrorInfo(error, { type: 'resolveConfig' });
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error.code === 'ENOENT') {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
44
|
+
}
|
|
45
|
+
};
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { join, resolve } from 'path';
|
|
2
|
+
import mapObject from 'map-obj';
|
|
3
|
+
import semver from 'semver';
|
|
4
|
+
import { getZisiFeatureFlags } from './feature_flags.js';
|
|
5
|
+
const getLambdaNodeVersion = (childEnv, userNodeVersion) => {
|
|
6
|
+
if (childEnv.AWS_LAMBDA_JS_RUNTIME) {
|
|
7
|
+
return childEnv.AWS_LAMBDA_JS_RUNTIME;
|
|
8
|
+
}
|
|
9
|
+
// As of time of writing the default Lambda Node.js version is 16 and
|
|
10
|
+
// we do not want to take the risk and downgrade users from this default version on initial release
|
|
11
|
+
// of the dependency between user and lambda Node.js version.
|
|
12
|
+
// The check ensures that if the user version is lower than 16 we keep the default version.
|
|
13
|
+
//
|
|
14
|
+
// TODO: Remove this once Node.js 16 is deprecated. Do NOT change this if the default Lambda version is updated.
|
|
15
|
+
if (semver.gte(userNodeVersion, '16.0.0')) {
|
|
16
|
+
return userNodeVersion;
|
|
17
|
+
}
|
|
18
|
+
return undefined;
|
|
19
|
+
};
|
|
20
|
+
export const getZisiParameters = ({ buildDir, childEnv, featureFlags, functionsConfig, functionsDist, internalFunctionsSrc, isRunningLocally, repositoryRoot, userNodeVersion, }) => {
|
|
21
|
+
const nodeVersion = getLambdaNodeVersion(childEnv, userNodeVersion);
|
|
22
|
+
const manifest = join(functionsDist, 'manifest.json');
|
|
23
|
+
const config = mapObject(functionsConfig, (expression, object) => [
|
|
24
|
+
expression,
|
|
25
|
+
normalizeFunctionConfig({ buildDir, functionConfig: object, isRunningLocally, nodeVersion }),
|
|
26
|
+
]);
|
|
27
|
+
const zisiFeatureFlags = getZisiFeatureFlags(featureFlags);
|
|
28
|
+
// Only internal functions are allowed to have a json config file
|
|
29
|
+
const configFileDirectories = [resolve(internalFunctionsSrc)];
|
|
30
|
+
return {
|
|
31
|
+
basePath: buildDir,
|
|
32
|
+
config,
|
|
33
|
+
manifest,
|
|
34
|
+
featureFlags: zisiFeatureFlags,
|
|
35
|
+
repositoryRoot,
|
|
36
|
+
configFileDirectories,
|
|
37
|
+
internalSrcFolder: internalFunctionsSrc,
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
// The function configuration keys returned by @netlify/config are not an exact
|
|
41
|
+
// match to the properties that @netlify/zip-it-and-ship-it expects. We do that
|
|
42
|
+
// translation here.
|
|
43
|
+
export const normalizeFunctionConfig = ({ buildDir, functionConfig = {}, isRunningLocally, nodeVersion, }) => ({
|
|
44
|
+
externalNodeModules: functionConfig.external_node_modules,
|
|
45
|
+
includedFiles: functionConfig.included_files,
|
|
46
|
+
name: functionConfig.name,
|
|
47
|
+
includedFilesBasePath: buildDir,
|
|
48
|
+
ignoredNodeModules: functionConfig.ignored_node_modules,
|
|
49
|
+
nodeVersion,
|
|
50
|
+
schedule: functionConfig.schedule,
|
|
51
|
+
// When the user selects esbuild as the Node bundler, we still want to use
|
|
52
|
+
// the legacy ZISI bundler as a fallback. Rather than asking the user to
|
|
53
|
+
// make this decision, we abstract that complexity away by injecting the
|
|
54
|
+
// fallback behavior ourselves. We do this by transforming the value
|
|
55
|
+
// `esbuild` into `esbuild_zisi`, which zip-it-and-ship-it understands.
|
|
56
|
+
nodeBundler: functionConfig.node_bundler === 'esbuild' ? 'esbuild_zisi' : functionConfig.node_bundler,
|
|
57
|
+
// If the build is running in buildbot, we set the Rust target directory to a
|
|
58
|
+
// path that will get cached in between builds, allowing us to speed up the
|
|
59
|
+
// build process.
|
|
60
|
+
rustTargetDirectory: isRunningLocally ? undefined : resolve(buildDir, '.netlify', 'rust-functions-cache', '[name]'),
|
|
61
|
+
// Go functions should be zipped only when building locally. When running in
|
|
62
|
+
// buildbot, the Go API client will handle the zipping.
|
|
63
|
+
zipGo: isRunningLocally ? true : undefined,
|
|
64
|
+
});
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { pathExists } from 'path-exists';
|
|
2
|
+
import { installFunctionDependencies } from '../../install/functions.js';
|
|
3
|
+
// Plugin to package Netlify functions with @netlify/zip-it-and-ship-it
|
|
4
|
+
export const onPreBuild = async function ({ constants: { FUNCTIONS_SRC, IS_LOCAL } }) {
|
|
5
|
+
if (!(await pathExists(FUNCTIONS_SRC))) {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
await installFunctionDependencies(FUNCTIONS_SRC, IS_LOCAL);
|
|
9
|
+
return {};
|
|
10
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { fileURLToPath } from 'url';
|
|
2
|
+
import { LOCAL_INSTALL_PLUGIN_NAME } from '../install/local.js';
|
|
3
|
+
const FUNCTIONS_INSTALL_PLUGIN = fileURLToPath(new URL('functions_install/index.js', import.meta.url));
|
|
4
|
+
// List of core plugin names
|
|
5
|
+
const FUNCTIONS_INSTALL_PLUGIN_NAME = '@netlify/plugin-functions-install-core';
|
|
6
|
+
const CORE_PLUGINS = new Set([FUNCTIONS_INSTALL_PLUGIN_NAME, LOCAL_INSTALL_PLUGIN_NAME]);
|
|
7
|
+
// Plugins that are installed and enabled by default
|
|
8
|
+
export const listCorePlugins = function ({ FUNCTIONS_SRC }) {
|
|
9
|
+
const functionsInstallPlugin = getFunctionsInstallPlugin(FUNCTIONS_SRC);
|
|
10
|
+
return [functionsInstallPlugin].filter(Boolean);
|
|
11
|
+
};
|
|
12
|
+
const getFunctionsInstallPlugin = function (FUNCTIONS_SRC) {
|
|
13
|
+
if (FUNCTIONS_SRC === undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return { package: FUNCTIONS_INSTALL_PLUGIN_NAME, pluginPath: FUNCTIONS_INSTALL_PLUGIN, optional: true };
|
|
17
|
+
};
|
|
18
|
+
export const isCorePlugin = function (packageName) {
|
|
19
|
+
return CORE_PLUGINS.has(packageName);
|
|
20
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { saveUpdatedConfig } from '../../core/config.js';
|
|
2
|
+
import { shouldDeploy } from '../deploy/index.js';
|
|
3
|
+
const coreStep = async function ({ buildDir, configPath, outputConfigPath, repositoryRoot, logs, featureFlags, context, branch, configMutations, headersPath, redirectsPath, debug, saveConfig, }) {
|
|
4
|
+
await saveUpdatedConfig({
|
|
5
|
+
configMutations,
|
|
6
|
+
buildDir,
|
|
7
|
+
repositoryRoot,
|
|
8
|
+
configPath,
|
|
9
|
+
outputConfigPath,
|
|
10
|
+
headersPath,
|
|
11
|
+
redirectsPath,
|
|
12
|
+
logs,
|
|
13
|
+
featureFlags,
|
|
14
|
+
context,
|
|
15
|
+
branch,
|
|
16
|
+
debug,
|
|
17
|
+
saveConfig,
|
|
18
|
+
});
|
|
19
|
+
return {};
|
|
20
|
+
};
|
|
21
|
+
// This step and the deploy step must be mutually exclusive, or we end up
|
|
22
|
+
// mutating the config twice.
|
|
23
|
+
const shouldSaveArtifacts = (options) => {
|
|
24
|
+
return !shouldDeploy(options) && options.saveConfig === true;
|
|
25
|
+
};
|
|
26
|
+
export const saveArtifacts = {
|
|
27
|
+
event: 'onPostBuild',
|
|
28
|
+
coreStep,
|
|
29
|
+
coreStepId: 'save_artifacts',
|
|
30
|
+
coreStepName: 'Save deploy artifacts',
|
|
31
|
+
coreStepDescription: () => 'Save deploy artifacts',
|
|
32
|
+
condition: shouldSaveArtifacts,
|
|
33
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { promisify } from 'util';
|
|
2
|
+
import slugify from '@sindresorhus/slugify';
|
|
3
|
+
import { StatsD } from 'hot-shots';
|
|
4
|
+
export const validateStatsDOptions = function (statsdOpts) {
|
|
5
|
+
return !!(statsdOpts && statsdOpts.host && statsdOpts.port);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Start a new StatsD Client and a new UDP socket
|
|
9
|
+
*/
|
|
10
|
+
export const startClient = async function (statsdOpts) {
|
|
11
|
+
const { host, port } = statsdOpts;
|
|
12
|
+
return new StatsD({
|
|
13
|
+
host,
|
|
14
|
+
port,
|
|
15
|
+
// This caches the dns resolution for subsequent sends of metrics for this instance
|
|
16
|
+
// Because we only try to send the metrics on close, this comes only into effect if `bufferFlushInterval` time is exceeded
|
|
17
|
+
cacheDns: true,
|
|
18
|
+
// set the maxBufferSize to infinite and the bufferFlushInterval very high, so that we only
|
|
19
|
+
// send the metrics on close or if more than 10 seconds past by
|
|
20
|
+
maxBufferSize: Infinity,
|
|
21
|
+
bufferFlushInterval: 10_000,
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Close the StatsD Client
|
|
26
|
+
*
|
|
27
|
+
* UDP packets are buffered and flushed every 10 seconds and
|
|
28
|
+
* closing the client forces all buffered metrics to be flushed.
|
|
29
|
+
*/
|
|
30
|
+
export const closeClient = async function (client) {
|
|
31
|
+
await promisify(client.close.bind(client))();
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Make sure the timer name does not include special characters.
|
|
35
|
+
* For example, the `packageName` of local plugins includes dots.
|
|
36
|
+
*/
|
|
37
|
+
export const normalizeTagName = function (name) {
|
|
38
|
+
return slugify(name, { separator: '_' });
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Formats and flattens the tags as array
|
|
42
|
+
* We do this because we might send the same tag with different values `{ tag: ['a', 'b'] }`
|
|
43
|
+
* which cannot be represented in an flattened object and `hot-shots` also supports tags as array in the format `['tag:a', 'tag:b']`
|
|
44
|
+
*/
|
|
45
|
+
export const formatTags = function (tags) {
|
|
46
|
+
return Object.entries(tags)
|
|
47
|
+
.map(([key, value]) => {
|
|
48
|
+
if (Array.isArray(value)) {
|
|
49
|
+
return value.map((subValue) => `${key}:${subValue}`);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
return `${key}:${value}`;
|
|
53
|
+
}
|
|
54
|
+
})
|
|
55
|
+
.flat();
|
|
56
|
+
};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Merge plugin status to the list of plugin statuses.
|
|
2
|
+
export const addStatus = function ({ newStatus, statuses, event, packageName, pluginPackageJson: { version } = {} }) {
|
|
3
|
+
// Either:
|
|
4
|
+
// - `build.command`
|
|
5
|
+
// - no status was set
|
|
6
|
+
if (newStatus === undefined) {
|
|
7
|
+
return statuses;
|
|
8
|
+
}
|
|
9
|
+
const formerStatus = statuses.find((status) => status.packageName === packageName);
|
|
10
|
+
if (!canOverrideStatus(formerStatus, newStatus)) {
|
|
11
|
+
return statuses;
|
|
12
|
+
}
|
|
13
|
+
// Overrides plugin's previous status and add more information
|
|
14
|
+
const newStatuses = statuses.filter((status) => status !== formerStatus);
|
|
15
|
+
return [...newStatuses, { ...newStatus, event, packageName, version }];
|
|
16
|
+
};
|
|
17
|
+
const canOverrideStatus = function (formerStatus, newStatus) {
|
|
18
|
+
// No previous status
|
|
19
|
+
if (formerStatus === undefined) {
|
|
20
|
+
return true;
|
|
21
|
+
}
|
|
22
|
+
// Implicit statuses can never override
|
|
23
|
+
if (newStatus.implicit) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
// Error statuses can only be overwritten by more severe error statuses
|
|
27
|
+
return STATES.indexOf(formerStatus.state) <= STATES.indexOf(newStatus.state);
|
|
28
|
+
};
|
|
29
|
+
// Possible status states, ordered by severity.
|
|
30
|
+
const STATES = ['success', 'canceled_plugin', 'failed_plugin', 'failed_build'];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import stripAnsi from 'strip-ansi';
|
|
2
|
+
// Remove colors from statuses
|
|
3
|
+
export const removeStatusesColors = function (statuses) {
|
|
4
|
+
return statuses.map(removeStatusColors);
|
|
5
|
+
};
|
|
6
|
+
const removeStatusColors = function (status) {
|
|
7
|
+
const attributes = COLOR_ATTRIBUTES.map((attribute) => removeAttrColor(status, attribute));
|
|
8
|
+
return Object.assign({}, status, ...attributes);
|
|
9
|
+
};
|
|
10
|
+
const COLOR_ATTRIBUTES = ['title', 'summary', 'text'];
|
|
11
|
+
const removeAttrColor = function (status, attribute) {
|
|
12
|
+
const value = status[attribute];
|
|
13
|
+
if (value === undefined) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
const valueA = stripAnsi(value);
|
|
17
|
+
return { [attribute]: valueA };
|
|
18
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { addErrorInfo } from '../error/info.js';
|
|
2
|
+
import { getFullErrorInfo } from '../error/parse/parse.js';
|
|
3
|
+
import { serializeErrorStatus } from '../error/parse/serialize_status.js';
|
|
4
|
+
// Errors that happen during plugin loads should be reported as error statuses
|
|
5
|
+
export const addPluginLoadErrorStatus = function ({ error, packageName, version, debug }) {
|
|
6
|
+
const fullErrorInfo = getFullErrorInfo({ error, colors: false, debug });
|
|
7
|
+
const errorStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_build' });
|
|
8
|
+
const statuses = [{ ...errorStatus, event: 'load', packageName, version }];
|
|
9
|
+
addErrorInfo(error, { statuses });
|
|
10
|
+
};
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { handleBuildError } from '../error/handle.js';
|
|
2
|
+
import { logStatuses } from '../log/messages/status.js';
|
|
3
|
+
import { removeStatusesColors } from './colors.js';
|
|
4
|
+
// Report plugin statuses to the console and API
|
|
5
|
+
export const reportStatuses = async function ({ statuses, childEnv, api, mode, pluginsOptions, netlifyConfig, errorMonitor, deployId, logs, debug, sendStatus, testOpts, }) {
|
|
6
|
+
const finalStatuses = getFinalStatuses({ statuses, pluginsOptions });
|
|
7
|
+
if (finalStatuses.length === 0) {
|
|
8
|
+
return;
|
|
9
|
+
}
|
|
10
|
+
const statusesA = removeStatusesColors(finalStatuses);
|
|
11
|
+
printStatuses({ statuses: statusesA, mode, logs });
|
|
12
|
+
await sendApiStatuses({
|
|
13
|
+
statuses: statusesA,
|
|
14
|
+
childEnv,
|
|
15
|
+
api,
|
|
16
|
+
mode,
|
|
17
|
+
netlifyConfig,
|
|
18
|
+
errorMonitor,
|
|
19
|
+
deployId,
|
|
20
|
+
logs,
|
|
21
|
+
debug,
|
|
22
|
+
sendStatus,
|
|
23
|
+
testOpts,
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
// Some plugins might not have completed due to a build error.
|
|
27
|
+
// In that case, we add a dummy plugin run with state "skipped".
|
|
28
|
+
// This allows the API to know both plugins that have completed and only started
|
|
29
|
+
const getFinalStatuses = function ({ statuses = [], pluginsOptions }) {
|
|
30
|
+
return pluginsOptions.map(({ packageName }) => getPluginStatus(packageName, statuses));
|
|
31
|
+
};
|
|
32
|
+
const getPluginStatus = function (packageName, statuses) {
|
|
33
|
+
const pluginStatus = statuses.find((status) => status.packageName === packageName);
|
|
34
|
+
if (pluginStatus !== undefined) {
|
|
35
|
+
return pluginStatus;
|
|
36
|
+
}
|
|
37
|
+
return { packageName, state: 'skipped' };
|
|
38
|
+
};
|
|
39
|
+
// When not in production, print statuses to console.
|
|
40
|
+
// Only print successful ones, since errors are logged afterwards.
|
|
41
|
+
const printStatuses = function ({ statuses, mode, logs }) {
|
|
42
|
+
if (mode === 'buildbot') {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const successStatuses = statuses.filter(shouldPrintStatus);
|
|
46
|
+
if (successStatuses.length === 0) {
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
49
|
+
logStatuses(logs, successStatuses);
|
|
50
|
+
};
|
|
51
|
+
const shouldPrintStatus = function ({ state, summary }) {
|
|
52
|
+
return state === 'success' && summary !== undefined;
|
|
53
|
+
};
|
|
54
|
+
// In production, send statuses to the API
|
|
55
|
+
const sendApiStatuses = async function ({ statuses, childEnv, api, mode, netlifyConfig, errorMonitor, deployId, logs, debug, sendStatus, testOpts, }) {
|
|
56
|
+
if ((mode !== 'buildbot' && !sendStatus) || api === undefined || !deployId) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
await Promise.all(statuses.map((status) => sendApiStatus({ api, status, childEnv, mode, netlifyConfig, errorMonitor, deployId, logs, debug, testOpts })));
|
|
60
|
+
};
|
|
61
|
+
const sendApiStatus = async function ({ api, status: { packageName, version, state, event, title, summary, text, extraData }, childEnv, mode, netlifyConfig, errorMonitor, deployId, logs, debug, testOpts, }) {
|
|
62
|
+
try {
|
|
63
|
+
await api.createPluginRun({
|
|
64
|
+
deploy_id: deployId,
|
|
65
|
+
body: {
|
|
66
|
+
package: packageName,
|
|
67
|
+
version,
|
|
68
|
+
state,
|
|
69
|
+
reporting_event: event,
|
|
70
|
+
title,
|
|
71
|
+
summary,
|
|
72
|
+
text,
|
|
73
|
+
extra_data: extraData,
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
// Bitballoon API randomly fails with 502.
|
|
77
|
+
// Builds should be successful when this API call fails, but we still want
|
|
78
|
+
// to report the error both in logs and in error monitoring.
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
await handleBuildError(error, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts });
|
|
82
|
+
}
|
|
83
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { runsOnlyOnBuildFailure } from '../plugins/events.js';
|
|
2
|
+
// The last event handler of a plugin (except for `onError` and `onEnd`)
|
|
3
|
+
// defaults to `utils.status.show({ state: 'success' })` without any `summary`.
|
|
4
|
+
export const getSuccessStatus = function (newStatus, { steps, event, packageName }) {
|
|
5
|
+
if (newStatus === undefined && isLastNonErrorStep({ steps, event, packageName })) {
|
|
6
|
+
return IMPLICIT_STATUS;
|
|
7
|
+
}
|
|
8
|
+
return newStatus;
|
|
9
|
+
};
|
|
10
|
+
const isLastNonErrorStep = function ({ steps, event, packageName }) {
|
|
11
|
+
const nonErrorSteps = steps.filter((step) => step.packageName === packageName && !runsOnlyOnBuildFailure(step.event));
|
|
12
|
+
return nonErrorSteps.length === 0 || nonErrorSteps[nonErrorSteps.length - 1].event === event;
|
|
13
|
+
};
|
|
14
|
+
const IMPLICIT_STATUS = { state: 'success', implicit: true };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { setEnvChanges } from '../env/changes.js';
|
|
2
|
+
import { addErrorInfo, isBuildError } from '../error/info.js';
|
|
3
|
+
import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js';
|
|
4
|
+
// Fire a core step
|
|
5
|
+
export const fireCoreStep = async function ({ coreStep, coreStepId, coreStepName, configPath, outputConfigPath, buildDir, repositoryRoot, constants, buildbotServerSocket, events, logs, nodePath, childEnv, context, branch, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, featureFlags, debug, systemLog, saveConfig, userNodeVersion, }) {
|
|
6
|
+
try {
|
|
7
|
+
const configSideFiles = await listConfigSideFiles([headersPath, redirectsPath]);
|
|
8
|
+
const childEnvA = setEnvChanges(envChanges, { ...childEnv });
|
|
9
|
+
const { newEnvChanges = {}, configMutations: newConfigMutations = [], tags, metrics, } = await coreStep({
|
|
10
|
+
configPath,
|
|
11
|
+
outputConfigPath,
|
|
12
|
+
buildDir,
|
|
13
|
+
repositoryRoot,
|
|
14
|
+
constants,
|
|
15
|
+
buildbotServerSocket,
|
|
16
|
+
events,
|
|
17
|
+
logs,
|
|
18
|
+
context,
|
|
19
|
+
branch,
|
|
20
|
+
childEnv: childEnvA,
|
|
21
|
+
netlifyConfig,
|
|
22
|
+
nodePath,
|
|
23
|
+
configMutations,
|
|
24
|
+
headersPath,
|
|
25
|
+
redirectsPath,
|
|
26
|
+
featureFlags,
|
|
27
|
+
debug,
|
|
28
|
+
systemLog,
|
|
29
|
+
saveConfig,
|
|
30
|
+
userNodeVersion,
|
|
31
|
+
});
|
|
32
|
+
const { netlifyConfig: netlifyConfigA, configMutations: configMutationsA, headersPath: headersPathA, redirectsPath: redirectsPathA, } = await updateNetlifyConfig({
|
|
33
|
+
configOpts,
|
|
34
|
+
netlifyConfig,
|
|
35
|
+
headersPath,
|
|
36
|
+
redirectsPath,
|
|
37
|
+
configMutations,
|
|
38
|
+
newConfigMutations,
|
|
39
|
+
configSideFiles,
|
|
40
|
+
errorParams,
|
|
41
|
+
logs,
|
|
42
|
+
debug,
|
|
43
|
+
});
|
|
44
|
+
return {
|
|
45
|
+
newEnvChanges,
|
|
46
|
+
netlifyConfig: netlifyConfigA,
|
|
47
|
+
configMutations: configMutationsA,
|
|
48
|
+
headersPath: headersPathA,
|
|
49
|
+
redirectsPath: redirectsPathA,
|
|
50
|
+
tags,
|
|
51
|
+
metrics,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
catch (newError) {
|
|
55
|
+
if (!isBuildError(newError)) {
|
|
56
|
+
addErrorInfo(newError, { type: 'coreStep', location: { coreStepName } });
|
|
57
|
+
}
|
|
58
|
+
// always add the current stage
|
|
59
|
+
addErrorInfo(newError, { stage: coreStepId });
|
|
60
|
+
return { newError };
|
|
61
|
+
}
|
|
62
|
+
};
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { cancelBuild } from '../error/cancel.js';
|
|
2
|
+
import { handleBuildError } from '../error/handle.js';
|
|
3
|
+
import { getFullErrorInfo, parseErrorInfo } from '../error/parse/parse.js';
|
|
4
|
+
import { serializeErrorStatus } from '../error/parse/serialize_status.js';
|
|
5
|
+
import { isSoftFailEvent } from '../plugins/events.js';
|
|
6
|
+
// Handle build command errors and plugin errors:
|
|
7
|
+
// - usually, propagate the error to make the build stop.
|
|
8
|
+
// - `utils.build.cancelBuild()` also cancels the build by calling the API
|
|
9
|
+
// - `utils.build.failPlugin()` or post-deploy errors do not make the build
|
|
10
|
+
// stop, but are still reported, and prevent future events from the same
|
|
11
|
+
// plugin.
|
|
12
|
+
// This also computes error statuses that are sent to the API.
|
|
13
|
+
export const handleStepError = function ({ event, newError, childEnv, mode, api, errorMonitor, deployId, coreStep, netlifyConfig, logs, debug, testOpts, }) {
|
|
14
|
+
// Core steps do not report error statuses
|
|
15
|
+
if (coreStep !== undefined) {
|
|
16
|
+
return { newError };
|
|
17
|
+
}
|
|
18
|
+
const fullErrorInfo = getFullErrorInfo({ error: newError, colors: false, debug });
|
|
19
|
+
const { type } = fullErrorInfo;
|
|
20
|
+
if (type === 'failPlugin' || isSoftFailEvent(event)) {
|
|
21
|
+
return handleFailPlugin({
|
|
22
|
+
fullErrorInfo,
|
|
23
|
+
newError,
|
|
24
|
+
childEnv,
|
|
25
|
+
mode,
|
|
26
|
+
errorMonitor,
|
|
27
|
+
netlifyConfig,
|
|
28
|
+
logs,
|
|
29
|
+
debug,
|
|
30
|
+
testOpts,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (type === 'cancelBuild') {
|
|
34
|
+
return handleCancelBuild({ fullErrorInfo, newError, api, deployId });
|
|
35
|
+
}
|
|
36
|
+
return handleFailBuild({ fullErrorInfo, newError });
|
|
37
|
+
};
|
|
38
|
+
// On `utils.build.failPlugin()` or during `onSuccess` or `onEnd`
|
|
39
|
+
const handleFailPlugin = async function ({ fullErrorInfo, fullErrorInfo: { errorInfo: { location: { packageName } = {} }, }, newError, childEnv, mode, errorMonitor, netlifyConfig, logs, debug, testOpts, }) {
|
|
40
|
+
const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_plugin' });
|
|
41
|
+
await handleBuildError(newError, { errorMonitor, netlifyConfig, childEnv, mode, logs, debug, testOpts });
|
|
42
|
+
return { failedPlugin: [packageName], newStatus };
|
|
43
|
+
};
|
|
44
|
+
// On `utils.build.cancelBuild()`
|
|
45
|
+
const handleCancelBuild = async function ({ fullErrorInfo, newError, api, deployId }) {
|
|
46
|
+
const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'canceled_build' });
|
|
47
|
+
await cancelBuild({ api, deployId });
|
|
48
|
+
return { newError, newStatus };
|
|
49
|
+
};
|
|
50
|
+
// On `utils.build.failBuild()` or uncaught exception
|
|
51
|
+
const handleFailBuild = function ({ fullErrorInfo, newError }) {
|
|
52
|
+
const newStatus = serializeErrorStatus({ fullErrorInfo, state: 'failed_build' });
|
|
53
|
+
return { newError, newStatus };
|
|
54
|
+
};
|
|
55
|
+
// Unlike community plugins, core plugin bugs should be handled as system errors
|
|
56
|
+
export const getPluginErrorType = function (error, loadedFrom) {
|
|
57
|
+
if (!isCorePluginBug(error, loadedFrom)) {
|
|
58
|
+
return {};
|
|
59
|
+
}
|
|
60
|
+
return { type: 'corePlugin' };
|
|
61
|
+
};
|
|
62
|
+
const isCorePluginBug = function (error, loadedFrom) {
|
|
63
|
+
const { severity } = parseErrorInfo(error);
|
|
64
|
+
return severity === 'warning' && loadedFrom === 'core';
|
|
65
|
+
};
|
package/lib/steps/get.js
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { DEV_EVENTS, EVENTS } from '../plugins/events.js';
|
|
2
|
+
import { buildCommandCore } from '../plugins_core/build_command.js';
|
|
3
|
+
import { deploySite } from '../plugins_core/deploy/index.js';
|
|
4
|
+
import { bundleEdgeFunctions } from '../plugins_core/edge_functions/index.js';
|
|
5
|
+
import { bundleFunctions } from '../plugins_core/functions/index.js';
|
|
6
|
+
import { saveArtifacts } from '../plugins_core/save_artifacts/index.js';
|
|
7
|
+
// Get all build steps
|
|
8
|
+
export const getSteps = function (steps) {
|
|
9
|
+
const stepsA = addCoreSteps(steps);
|
|
10
|
+
const stepsB = sortSteps(stepsA, EVENTS);
|
|
11
|
+
const events = getEvents(stepsB);
|
|
12
|
+
return { steps: stepsB, events };
|
|
13
|
+
};
|
|
14
|
+
// Get all dev steps
|
|
15
|
+
export const getDevSteps = function (command, steps) {
|
|
16
|
+
const devCommandStep = {
|
|
17
|
+
event: 'onDev',
|
|
18
|
+
coreStep: async () => {
|
|
19
|
+
await command();
|
|
20
|
+
return {};
|
|
21
|
+
},
|
|
22
|
+
coreStepId: 'dev_command',
|
|
23
|
+
coreStepName: 'dev.command',
|
|
24
|
+
coreStepDescription: () => 'Run command for local development',
|
|
25
|
+
};
|
|
26
|
+
const sortedSteps = sortSteps([...steps, devCommandStep], DEV_EVENTS);
|
|
27
|
+
const events = getEvents(sortedSteps);
|
|
28
|
+
return { steps: sortedSteps, events };
|
|
29
|
+
};
|
|
30
|
+
const addCoreSteps = function (steps) {
|
|
31
|
+
return [buildCommandCore, ...steps, bundleFunctions, bundleEdgeFunctions, deploySite, saveArtifacts];
|
|
32
|
+
};
|
|
33
|
+
// Sort plugin steps by event order.
|
|
34
|
+
const sortSteps = function (steps, events) {
|
|
35
|
+
return events.flatMap((event) => steps.filter((step) => step.event === event));
|
|
36
|
+
};
|
|
37
|
+
// Retrieve list of unique events
|
|
38
|
+
const getEvents = function (steps) {
|
|
39
|
+
const events = steps.map(getEvent);
|
|
40
|
+
return [...new Set(events)];
|
|
41
|
+
};
|
|
42
|
+
const getEvent = function ({ event }) {
|
|
43
|
+
return event;
|
|
44
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { addErrorInfo } from '../error/info.js';
|
|
2
|
+
import { logStepCompleted } from '../log/messages/ipc.js';
|
|
3
|
+
import { pipePluginOutput, unpipePluginOutput } from '../log/stream.js';
|
|
4
|
+
import { callChild } from '../plugins/ipc.js';
|
|
5
|
+
import { getSuccessStatus } from '../status/success.js';
|
|
6
|
+
import { getPluginErrorType } from './error.js';
|
|
7
|
+
import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js';
|
|
8
|
+
// Fire a plugin step
|
|
9
|
+
export const firePluginStep = async function ({ event, childProcess, packageName, pluginPackageJson, loadedFrom, origin, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, constants, steps, error, logs, debug, verbose, }) {
|
|
10
|
+
const listeners = pipePluginOutput(childProcess, logs);
|
|
11
|
+
try {
|
|
12
|
+
const configSideFiles = await listConfigSideFiles([headersPath, redirectsPath]);
|
|
13
|
+
const { newEnvChanges, configMutations: newConfigMutations, status, } = await callChild({
|
|
14
|
+
childProcess,
|
|
15
|
+
eventName: 'run',
|
|
16
|
+
payload: { event, error, envChanges, netlifyConfig, constants },
|
|
17
|
+
logs,
|
|
18
|
+
verbose,
|
|
19
|
+
});
|
|
20
|
+
const { netlifyConfig: netlifyConfigA, configMutations: configMutationsA, headersPath: headersPathA, redirectsPath: redirectsPathA, } = await updateNetlifyConfig({
|
|
21
|
+
configOpts,
|
|
22
|
+
netlifyConfig,
|
|
23
|
+
headersPath,
|
|
24
|
+
redirectsPath,
|
|
25
|
+
configMutations,
|
|
26
|
+
newConfigMutations,
|
|
27
|
+
configSideFiles,
|
|
28
|
+
errorParams,
|
|
29
|
+
logs,
|
|
30
|
+
debug,
|
|
31
|
+
});
|
|
32
|
+
const newStatus = getSuccessStatus(status, { steps, event, packageName });
|
|
33
|
+
return {
|
|
34
|
+
newEnvChanges,
|
|
35
|
+
netlifyConfig: netlifyConfigA,
|
|
36
|
+
configMutations: configMutationsA,
|
|
37
|
+
headersPath: headersPathA,
|
|
38
|
+
redirectsPath: redirectsPathA,
|
|
39
|
+
newStatus,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
catch (newError) {
|
|
43
|
+
const errorType = getPluginErrorType(newError, loadedFrom);
|
|
44
|
+
addErrorInfo(newError, {
|
|
45
|
+
...errorType,
|
|
46
|
+
plugin: { pluginPackageJson, packageName },
|
|
47
|
+
location: { event, packageName, loadedFrom, origin },
|
|
48
|
+
});
|
|
49
|
+
return { newError };
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
await unpipePluginOutput(childProcess, logs, listeners);
|
|
53
|
+
logStepCompleted(logs, verbose);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { logTimer } from '../log/messages/core.js';
|
|
2
|
+
import { logStepSuccess } from '../log/messages/steps.js';
|
|
3
|
+
import { handleStepError } from './error.js';
|
|
4
|
+
// Retrieve the return value of a step
|
|
5
|
+
export const getStepReturn = function ({ event, packageName, newError, newEnvChanges, newStatus, coreStep, coreStepName: timerName = `${packageName} ${event}`, childEnv, mode, api, errorMonitor, deployId, netlifyConfig, configMutations, headersPath, redirectsPath, logs, debug, timers, durationNs, testOpts, systemLog, quiet, metrics, }) {
|
|
6
|
+
if (newError !== undefined) {
|
|
7
|
+
return handleStepError({
|
|
8
|
+
event,
|
|
9
|
+
newError,
|
|
10
|
+
childEnv,
|
|
11
|
+
mode,
|
|
12
|
+
api,
|
|
13
|
+
errorMonitor,
|
|
14
|
+
deployId,
|
|
15
|
+
coreStep,
|
|
16
|
+
netlifyConfig,
|
|
17
|
+
logs,
|
|
18
|
+
debug,
|
|
19
|
+
testOpts,
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
if (!quiet) {
|
|
23
|
+
logStepSuccess(logs);
|
|
24
|
+
logTimer(logs, durationNs, timerName, systemLog);
|
|
25
|
+
}
|
|
26
|
+
return { newEnvChanges, netlifyConfig, configMutations, headersPath, redirectsPath, newStatus, timers, metrics };
|
|
27
|
+
};
|