@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,161 +1,114 @@
|
|
|
1
|
-
import { resolve } from 'path'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
import { getZipError } from './error.js'
|
|
10
|
-
import { getUserAndInternalFunctions, validateFunctionsSrc } from './utils.js'
|
|
11
|
-
import { getZisiParameters } from './zisi.js'
|
|
12
|
-
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { zipFunctions } from '@netlify/zip-it-and-ship-it';
|
|
3
|
+
import { pathExists } from 'path-exists';
|
|
4
|
+
import { log } from '../../log/logger.js';
|
|
5
|
+
import { logBundleResults, logFunctionsNonExistingDir, logFunctionsToBundle } from '../../log/messages/core_steps.js';
|
|
6
|
+
import { getZipError } from './error.js';
|
|
7
|
+
import { getUserAndInternalFunctions, validateFunctionsSrc } from './utils.js';
|
|
8
|
+
import { getZisiParameters } from './zisi.js';
|
|
13
9
|
// Returns `true` if at least one of the functions has been configured to use
|
|
14
10
|
// esbuild.
|
|
15
|
-
const isUsingEsbuild = (functionsConfig = {}) =>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const bundler = isUsingEsbuild(functionsConfig) ? 'esbuild' : 'zisi'
|
|
41
|
-
|
|
42
|
-
try {
|
|
43
|
-
// Printing an empty line before bundling output.
|
|
44
|
-
log(logs, '')
|
|
45
|
-
|
|
46
|
-
const sourceDirectories = [internalFunctionsSrc, functionsSrc].filter(Boolean)
|
|
47
|
-
const results = await zipItAndShipIt.zipFunctions(sourceDirectories, functionsDist, zisiParameters)
|
|
48
|
-
|
|
49
|
-
logBundleResults({ logs, results })
|
|
50
|
-
|
|
51
|
-
return { bundler }
|
|
52
|
-
} catch (error) {
|
|
53
|
-
throw await getZipError(error, functionsSrc)
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
11
|
+
const isUsingEsbuild = (functionsConfig = {}) => Object.values(functionsConfig).some((configObject) => configObject.node_bundler === 'esbuild');
|
|
12
|
+
const zipFunctionsAndLogResults = async ({ buildDir, childEnv, featureFlags, functionsConfig, functionsDist, functionsSrc, internalFunctionsSrc, isRunningLocally, logs, repositoryRoot, }) => {
|
|
13
|
+
const zisiParameters = getZisiParameters({
|
|
14
|
+
buildDir,
|
|
15
|
+
childEnv,
|
|
16
|
+
featureFlags,
|
|
17
|
+
functionsConfig,
|
|
18
|
+
functionsDist,
|
|
19
|
+
internalFunctionsSrc,
|
|
20
|
+
isRunningLocally,
|
|
21
|
+
repositoryRoot,
|
|
22
|
+
});
|
|
23
|
+
const bundler = isUsingEsbuild(functionsConfig) ? 'esbuild' : 'zisi';
|
|
24
|
+
try {
|
|
25
|
+
// Printing an empty line before bundling output.
|
|
26
|
+
log(logs, '');
|
|
27
|
+
const sourceDirectories = [internalFunctionsSrc, functionsSrc].filter(Boolean);
|
|
28
|
+
const results = await zipItAndShipIt.zipFunctions(sourceDirectories, functionsDist, zisiParameters);
|
|
29
|
+
logBundleResults({ logs, results });
|
|
30
|
+
return { bundler };
|
|
31
|
+
}
|
|
32
|
+
catch (error) {
|
|
33
|
+
throw await getZipError(error, functionsSrc);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
57
36
|
// Plugin to package Netlify functions with @netlify/zip-it-and-ship-it
|
|
58
|
-
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
const internalFunctionsSrcExists = await pathExists(internalFunctionsSrc)
|
|
77
|
-
const functionsSrcExists = await validateFunctionsSrc({ functionsSrc, logs, relativeFunctionsSrc })
|
|
78
|
-
const [userFunctions = [], internalFunctions = []] = await getUserAndInternalFunctions({
|
|
79
|
-
featureFlags,
|
|
80
|
-
functionsSrc,
|
|
81
|
-
functionsSrcExists,
|
|
82
|
-
internalFunctionsSrc,
|
|
83
|
-
internalFunctionsSrcExists,
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
if (functionsSrc && !functionsSrcExists) {
|
|
87
|
-
logFunctionsNonExistingDir(logs, relativeFunctionsSrc)
|
|
88
|
-
|
|
89
|
-
if (internalFunctions.length !== 0) {
|
|
90
|
-
log(logs, '')
|
|
37
|
+
const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC: relativeInternalFunctionsSrc, IS_LOCAL: isRunningLocally, FUNCTIONS_SRC: relativeFunctionsSrc, FUNCTIONS_DIST: relativeFunctionsDist, }, buildDir, logs, netlifyConfig, featureFlags, repositoryRoot, }) {
|
|
38
|
+
const functionsSrc = relativeFunctionsSrc === undefined ? undefined : resolve(buildDir, relativeFunctionsSrc);
|
|
39
|
+
const functionsDist = resolve(buildDir, relativeFunctionsDist);
|
|
40
|
+
const internalFunctionsSrc = resolve(buildDir, relativeInternalFunctionsSrc);
|
|
41
|
+
const internalFunctionsSrcExists = await pathExists(internalFunctionsSrc);
|
|
42
|
+
const functionsSrcExists = await validateFunctionsSrc({ functionsSrc, logs, relativeFunctionsSrc });
|
|
43
|
+
const [userFunctions = [], internalFunctions = []] = await getUserAndInternalFunctions({
|
|
44
|
+
featureFlags,
|
|
45
|
+
functionsSrc,
|
|
46
|
+
functionsSrcExists,
|
|
47
|
+
internalFunctionsSrc,
|
|
48
|
+
internalFunctionsSrcExists,
|
|
49
|
+
});
|
|
50
|
+
if (functionsSrc && !functionsSrcExists) {
|
|
51
|
+
logFunctionsNonExistingDir(logs, relativeFunctionsSrc);
|
|
52
|
+
if (internalFunctions.length !== 0) {
|
|
53
|
+
log(logs, '');
|
|
54
|
+
}
|
|
91
55
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
tags: {
|
|
122
|
-
bundler,
|
|
123
|
-
},
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
|
|
56
|
+
logFunctionsToBundle({
|
|
57
|
+
logs,
|
|
58
|
+
userFunctions,
|
|
59
|
+
userFunctionsSrc: relativeFunctionsSrc,
|
|
60
|
+
userFunctionsSrcExists: functionsSrcExists,
|
|
61
|
+
internalFunctions,
|
|
62
|
+
internalFunctionsSrc: relativeInternalFunctionsSrc,
|
|
63
|
+
});
|
|
64
|
+
if (userFunctions.length === 0 && internalFunctions.length === 0) {
|
|
65
|
+
return {};
|
|
66
|
+
}
|
|
67
|
+
const { bundler } = await zipFunctionsAndLogResults({
|
|
68
|
+
buildDir,
|
|
69
|
+
childEnv,
|
|
70
|
+
featureFlags,
|
|
71
|
+
functionsConfig: netlifyConfig.functions,
|
|
72
|
+
functionsDist,
|
|
73
|
+
functionsSrc,
|
|
74
|
+
internalFunctionsSrc,
|
|
75
|
+
isRunningLocally,
|
|
76
|
+
logs,
|
|
77
|
+
repositoryRoot,
|
|
78
|
+
});
|
|
79
|
+
return {
|
|
80
|
+
tags: {
|
|
81
|
+
bundler,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
};
|
|
127
85
|
// We run this core step if at least one of the functions directories (the
|
|
128
86
|
// one configured by the user or the internal one) exists. We use a dynamic
|
|
129
87
|
// `condition` because the directories might be created by the build command
|
|
130
88
|
// or plugins.
|
|
131
89
|
const hasFunctionsDirectories = async function ({ buildDir, constants: { INTERNAL_FUNCTIONS_SRC, FUNCTIONS_SRC } }) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
return await pathExists(internalFunctionsSrc)
|
|
141
|
-
}
|
|
142
|
-
|
|
90
|
+
const hasFunctionsSrc = FUNCTIONS_SRC !== undefined && FUNCTIONS_SRC !== '';
|
|
91
|
+
if (hasFunctionsSrc) {
|
|
92
|
+
return true;
|
|
93
|
+
}
|
|
94
|
+
const internalFunctionsSrc = resolve(buildDir, INTERNAL_FUNCTIONS_SRC);
|
|
95
|
+
return await pathExists(internalFunctionsSrc);
|
|
96
|
+
};
|
|
143
97
|
export const bundleFunctions = {
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
|
|
98
|
+
event: 'onBuild',
|
|
99
|
+
coreStep,
|
|
100
|
+
coreStepId: 'functions_bundling',
|
|
101
|
+
coreStepName: 'Functions bundling',
|
|
102
|
+
coreStepDescription: () => 'Functions bundling',
|
|
103
|
+
condition: hasFunctionsDirectories,
|
|
104
|
+
};
|
|
152
105
|
// Named imports with ES modules cannot be mocked (unlike CommonJS) because
|
|
153
106
|
// they are bound at load time.
|
|
154
107
|
// However, some of our tests are asserting which arguments are passed to
|
|
155
108
|
// `zip-it-and-ship-it` methods. Therefore, we need to use an intermediary
|
|
156
109
|
// function and export them so tests can use it.
|
|
157
110
|
export const zipItAndShipIt = {
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
}
|
|
111
|
+
async zipFunctions(...args) {
|
|
112
|
+
return await zipFunctions(...args);
|
|
113
|
+
},
|
|
114
|
+
};
|
|
@@ -1,66 +1,45 @@
|
|
|
1
|
-
import { promises as fs } from 'fs'
|
|
2
|
-
import { relative } from 'path'
|
|
3
|
-
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
import { addErrorInfo } from '../../error/info.js'
|
|
7
|
-
|
|
8
|
-
import { getZisiFeatureFlags } from './feature_flags.js'
|
|
9
|
-
|
|
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';
|
|
10
6
|
// Returns the `mainFile` of each function found in `functionsSrc`, relative to
|
|
11
7
|
// `functionsSrc`.
|
|
12
8
|
const getRelativeFunctionMainFiles = async function ({ featureFlags, functionsSrc }) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
internalFunctionsSrcExists,
|
|
28
|
-
}) => {
|
|
29
|
-
const paths = [
|
|
30
|
-
functionsSrcExists ? functionsSrc : undefined,
|
|
31
|
-
internalFunctionsSrcExists ? internalFunctionsSrc : undefined,
|
|
32
|
-
]
|
|
33
|
-
|
|
34
|
-
return Promise.all(paths.map((path) => path && getRelativeFunctionMainFiles({ featureFlags, functionsSrc: path })))
|
|
35
|
-
}
|
|
36
|
-
|
|
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
|
+
};
|
|
37
23
|
// Returns `true` if the functions directory exists and is valid. Returns
|
|
38
24
|
// `false` if it doesn't exist. Throws an error if it's invalid or can't
|
|
39
25
|
// be accessed.
|
|
40
26
|
export const validateFunctionsSrc = async function ({ functionsSrc, relativeFunctionsSrc }) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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;
|
|
50
38
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
addErrorInfo(error, { type: 'resolveConfig' })
|
|
57
|
-
|
|
58
|
-
throw error
|
|
59
|
-
} catch (error) {
|
|
60
|
-
if (error.code === 'ENOENT') {
|
|
61
|
-
return false
|
|
39
|
+
catch (error) {
|
|
40
|
+
if (error.code === 'ENOENT') {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
throw error;
|
|
62
44
|
}
|
|
63
|
-
|
|
64
|
-
throw error
|
|
65
|
-
}
|
|
66
|
-
}
|
|
45
|
+
};
|
|
@@ -1,56 +1,39 @@
|
|
|
1
|
-
import { join, resolve } from 'path'
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}) => {
|
|
17
|
-
const nodeVersion = childEnv.AWS_LAMBDA_JS_RUNTIME
|
|
18
|
-
const manifest = join(functionsDist, 'manifest.json')
|
|
19
|
-
const config = mapObject(functionsConfig, (expression, object) => [
|
|
20
|
-
expression,
|
|
21
|
-
normalizeFunctionConfig({ buildDir, featureFlags, functionConfig: object, isRunningLocally, nodeVersion }),
|
|
22
|
-
])
|
|
23
|
-
const zisiFeatureFlags = getZisiFeatureFlags(featureFlags)
|
|
24
|
-
// Only internal functions are allowed to have a json config file
|
|
25
|
-
const configFileDirectories = [resolve(internalFunctionsSrc)]
|
|
26
|
-
|
|
27
|
-
return { basePath: buildDir, config, manifest, featureFlags: zisiFeatureFlags, repositoryRoot, configFileDirectories }
|
|
28
|
-
}
|
|
29
|
-
|
|
1
|
+
import { join, resolve } from 'path';
|
|
2
|
+
import mapObject from 'map-obj';
|
|
3
|
+
import { getZisiFeatureFlags } from './feature_flags.js';
|
|
4
|
+
export const getZisiParameters = ({ buildDir, childEnv, featureFlags, functionsConfig, functionsDist, internalFunctionsSrc, isRunningLocally, repositoryRoot, }) => {
|
|
5
|
+
const nodeVersion = childEnv.AWS_LAMBDA_JS_RUNTIME;
|
|
6
|
+
const manifest = join(functionsDist, 'manifest.json');
|
|
7
|
+
const config = mapObject(functionsConfig, (expression, object) => [
|
|
8
|
+
expression,
|
|
9
|
+
normalizeFunctionConfig({ buildDir, featureFlags, functionConfig: object, isRunningLocally, nodeVersion }),
|
|
10
|
+
]);
|
|
11
|
+
const zisiFeatureFlags = getZisiFeatureFlags(featureFlags);
|
|
12
|
+
// Only internal functions are allowed to have a json config file
|
|
13
|
+
const configFileDirectories = [resolve(internalFunctionsSrc)];
|
|
14
|
+
return { basePath: buildDir, config, manifest, featureFlags: zisiFeatureFlags, repositoryRoot, configFileDirectories };
|
|
15
|
+
};
|
|
30
16
|
// The function configuration keys returned by @netlify/config are not an exact
|
|
31
17
|
// match to the properties that @netlify/zip-it-and-ship-it expects. We do that
|
|
32
18
|
// translation here.
|
|
33
19
|
export const normalizeFunctionConfig = ({ buildDir, functionConfig = {}, isRunningLocally, nodeVersion }) => ({
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// buildbot, the Go API client will handle the zipping.
|
|
55
|
-
zipGo: isRunningLocally ? true : undefined,
|
|
56
|
-
})
|
|
20
|
+
externalNodeModules: functionConfig.external_node_modules,
|
|
21
|
+
includedFiles: functionConfig.included_files,
|
|
22
|
+
includedFilesBasePath: buildDir,
|
|
23
|
+
ignoredNodeModules: functionConfig.ignored_node_modules,
|
|
24
|
+
nodeVersion,
|
|
25
|
+
schedule: functionConfig.schedule,
|
|
26
|
+
// When the user selects esbuild as the Node bundler, we still want to use
|
|
27
|
+
// the legacy ZISI bundler as a fallback. Rather than asking the user to
|
|
28
|
+
// make this decision, we abstract that complexity away by injecting the
|
|
29
|
+
// fallback behavior ourselves. We do this by transforming the value
|
|
30
|
+
// `esbuild` into `esbuild_zisi`, which zip-it-and-ship-it understands.
|
|
31
|
+
nodeBundler: functionConfig.node_bundler === 'esbuild' ? 'esbuild_zisi' : functionConfig.node_bundler,
|
|
32
|
+
// If the build is running in buildbot, we set the Rust target directory to a
|
|
33
|
+
// path that will get cached in between builds, allowing us to speed up the
|
|
34
|
+
// build process.
|
|
35
|
+
rustTargetDirectory: isRunningLocally ? undefined : resolve(buildDir, '.netlify', 'rust-functions-cache', '[name]'),
|
|
36
|
+
// Go functions should be zipped only when building locally. When running in
|
|
37
|
+
// buildbot, the Go API client will handle the zipping.
|
|
38
|
+
zipGo: isRunningLocally ? true : undefined,
|
|
39
|
+
});
|
|
@@ -1,13 +1,10 @@
|
|
|
1
|
-
import { pathExists } from 'path-exists'
|
|
2
|
-
|
|
3
|
-
import { installFunctionDependencies } from '../../install/functions.js'
|
|
4
|
-
|
|
1
|
+
import { pathExists } from 'path-exists';
|
|
2
|
+
import { installFunctionDependencies } from '../../install/functions.js';
|
|
5
3
|
// Plugin to package Netlify functions with @netlify/zip-it-and-ship-it
|
|
6
4
|
export const onPreBuild = async function ({ constants: { FUNCTIONS_SRC, IS_LOCAL } }) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
5
|
+
if (!(await pathExists(FUNCTIONS_SRC))) {
|
|
6
|
+
return {};
|
|
7
|
+
}
|
|
8
|
+
await installFunctionDependencies(FUNCTIONS_SRC, IS_LOCAL);
|
|
9
|
+
return {};
|
|
10
|
+
};
|
package/lib/plugins_core/list.js
CHANGED
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
import { fileURLToPath } from 'url'
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const FUNCTIONS_INSTALL_PLUGIN = fileURLToPath(new URL('functions_install/index.js', import.meta.url))
|
|
6
|
-
|
|
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));
|
|
7
4
|
// List of core plugin names
|
|
8
|
-
const FUNCTIONS_INSTALL_PLUGIN_NAME = '@netlify/plugin-functions-install-core'
|
|
9
|
-
const CORE_PLUGINS = new Set([FUNCTIONS_INSTALL_PLUGIN_NAME, LOCAL_INSTALL_PLUGIN_NAME])
|
|
10
|
-
|
|
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]);
|
|
11
7
|
// Plugins that are installed and enabled by default
|
|
12
8
|
export const listCorePlugins = function ({ FUNCTIONS_SRC }) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
9
|
+
const functionsInstallPlugin = getFunctionsInstallPlugin(FUNCTIONS_SRC);
|
|
10
|
+
return [functionsInstallPlugin].filter(Boolean);
|
|
11
|
+
};
|
|
17
12
|
const getFunctionsInstallPlugin = function (FUNCTIONS_SRC) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
24
|
-
|
|
13
|
+
if (FUNCTIONS_SRC === undefined) {
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
return { package: FUNCTIONS_INSTALL_PLUGIN_NAME, pluginPath: FUNCTIONS_INSTALL_PLUGIN, optional: true };
|
|
17
|
+
};
|
|
25
18
|
export const isCorePlugin = function (packageName) {
|
|
26
|
-
|
|
27
|
-
}
|
|
19
|
+
return CORE_PLUGINS.has(packageName);
|
|
20
|
+
};
|
package/lib/status/add.js
CHANGED
|
@@ -1,36 +1,30 @@
|
|
|
1
1
|
// Merge plugin status to the list of plugin statuses.
|
|
2
2
|
export const addStatus = function ({ newStatus, statuses, event, packageName, pluginPackageJson: { version } = {} }) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
return [...newStatuses, { ...newStatus, event, packageName, version }]
|
|
18
|
-
}
|
|
19
|
-
|
|
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
|
+
};
|
|
20
17
|
const canOverrideStatus = function (formerStatus, newStatus) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return STATES.indexOf(formerStatus.state) <= STATES.indexOf(newStatus.state)
|
|
33
|
-
}
|
|
34
|
-
|
|
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
|
+
};
|
|
35
29
|
// Possible status states, ordered by severity.
|
|
36
|
-
const STATES = ['success', 'canceled_plugin', 'failed_plugin', 'failed_build']
|
|
30
|
+
const STATES = ['success', 'canceled_plugin', 'failed_plugin', 'failed_build'];
|
package/lib/status/colors.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
|
-
import stripAnsi from 'strip-ansi'
|
|
2
|
-
|
|
1
|
+
import stripAnsi from 'strip-ansi';
|
|
3
2
|
// Remove colors from statuses
|
|
4
3
|
export const removeStatusesColors = function (statuses) {
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
4
|
+
return statuses.map(removeStatusColors);
|
|
5
|
+
};
|
|
8
6
|
const removeStatusColors = function (status) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const COLOR_ATTRIBUTES = ['title', 'summary', 'text']
|
|
14
|
-
|
|
7
|
+
const attributes = COLOR_ATTRIBUTES.map((attribute) => removeAttrColor(status, attribute));
|
|
8
|
+
return Object.assign({}, status, ...attributes);
|
|
9
|
+
};
|
|
10
|
+
const COLOR_ATTRIBUTES = ['title', 'summary', 'text'];
|
|
15
11
|
const removeAttrColor = function (status, attribute) {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
}
|
|
12
|
+
const value = status[attribute];
|
|
13
|
+
if (value === undefined) {
|
|
14
|
+
return {};
|
|
15
|
+
}
|
|
16
|
+
const valueA = stripAnsi(value);
|
|
17
|
+
return { [attribute]: valueA };
|
|
18
|
+
};
|
package/lib/status/load_error.js
CHANGED
|
@@ -1,11 +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
|
-
|
|
1
|
+
import { addErrorInfo } from '../error/info.js';
|
|
2
|
+
import { getFullErrorInfo } from '../error/parse/parse.js';
|
|
3
|
+
import { serializeErrorStatus } from '../error/parse/serialize_status.js';
|
|
5
4
|
// Errors that happen during plugin loads should be reported as error statuses
|
|
6
5
|
export const addPluginLoadErrorStatus = function ({ error, packageName, version, debug }) {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
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
|
+
};
|