@netlify/build 33.5.1 → 34.0.0
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/build.d.ts +1 -0
- package/lib/core/build.js +8 -4
- package/lib/core/dev.d.ts +2 -0
- package/lib/core/dev.js +10 -2
- package/lib/core/main.js +10 -2
- package/lib/log/messages/core_steps.js +12 -8
- package/lib/plugins_core/edge_functions/index.js +1 -1
- package/lib/plugins_core/functions/index.d.ts +1 -1
- package/lib/plugins_core/functions/index.js +19 -22
- package/lib/plugins_core/functions/zisi.js +0 -1
- package/lib/steps/return_values.d.ts +18 -0
- package/lib/steps/return_values.js +13 -0
- package/lib/steps/run_steps.js +1 -1
- package/package.json +6 -6
- package/lib/types/step.d.ts +0 -9
- package/lib/types/step.js +0 -1
package/lib/core/build.d.ts
CHANGED
package/lib/core/build.js
CHANGED
|
@@ -85,7 +85,7 @@ const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cached
|
|
|
85
85
|
const pluginsOptions = addCorePlugins({ netlifyConfig, constants });
|
|
86
86
|
// `errorParams` is purposely stateful
|
|
87
87
|
Object.assign(errorParams, { netlifyConfig, pluginsOptions, siteInfo, childEnv, userNodeVersion });
|
|
88
|
-
const { pluginsOptions: pluginsOptionsA, netlifyConfig: netlifyConfigA, stepsCount, timers: timersB, configMutations, metrics, } = await runAndReportBuild({
|
|
88
|
+
const { pluginsOptions: pluginsOptionsA, netlifyConfig: netlifyConfigA, stepsCount, timers: timersB, configMutations, metrics, returnValues, } = await runAndReportBuild({
|
|
89
89
|
pluginsOptions,
|
|
90
90
|
netlifyConfig,
|
|
91
91
|
defaultConfig,
|
|
@@ -141,13 +141,14 @@ const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cached
|
|
|
141
141
|
timers: timersB,
|
|
142
142
|
configMutations,
|
|
143
143
|
metrics,
|
|
144
|
+
returnValues,
|
|
144
145
|
};
|
|
145
146
|
};
|
|
146
147
|
export const execBuild = measureDuration(tExecBuild, 'total', { parentTag: 'build_site' });
|
|
147
148
|
// Runs a build then report any plugin statuses
|
|
148
149
|
export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig, defaultConfig, configOpts, siteInfo, configPath, outputConfigPath, headersPath, redirectsPath, packagePath, buildDir, repositoryRoot, nodePath, packageJson, userNodeVersion, childEnv, context, branch, buildbotServerSocket, constants, dry, mode, api, token, errorMonitor, deployId, errorParams, logs, debug, systemLog, systemLogFile, verbose, timers, sendStatus, saveConfig, testOpts, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, enhancedSecretScan, edgeFunctionsBootstrapURL, eventHandlers, }) {
|
|
149
150
|
try {
|
|
150
|
-
const { stepsCount, netlifyConfig: netlifyConfigA, statuses, pluginsOptions: pluginsOptionsA, failedPlugins, timers: timersA, configMutations, metrics, } = await initAndRunBuild({
|
|
151
|
+
const { stepsCount, netlifyConfig: netlifyConfigA, statuses, pluginsOptions: pluginsOptionsA, failedPlugins, timers: timersA, configMutations, metrics, returnValues, } = await initAndRunBuild({
|
|
151
152
|
pluginsOptions,
|
|
152
153
|
netlifyConfig,
|
|
153
154
|
defaultConfig,
|
|
@@ -231,6 +232,7 @@ export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig
|
|
|
231
232
|
timers: timersA,
|
|
232
233
|
configMutations,
|
|
233
234
|
metrics,
|
|
235
|
+
returnValues,
|
|
234
236
|
};
|
|
235
237
|
}
|
|
236
238
|
catch (error) {
|
|
@@ -303,7 +305,7 @@ const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, default
|
|
|
303
305
|
systemLogFile,
|
|
304
306
|
});
|
|
305
307
|
try {
|
|
306
|
-
const { stepsCount, netlifyConfig: netlifyConfigA, statuses, failedPlugins, timers: timersC, configMutations, metrics, } = await runBuild({
|
|
308
|
+
const { stepsCount, netlifyConfig: netlifyConfigA, statuses, failedPlugins, timers: timersC, configMutations, metrics, returnValues, } = await runBuild({
|
|
307
309
|
childProcesses,
|
|
308
310
|
pluginsOptions: pluginsOptionsA,
|
|
309
311
|
netlifyConfig,
|
|
@@ -359,6 +361,7 @@ const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, default
|
|
|
359
361
|
timers: timersC,
|
|
360
362
|
configMutations,
|
|
361
363
|
metrics,
|
|
364
|
+
returnValues,
|
|
362
365
|
};
|
|
363
366
|
}
|
|
364
367
|
finally {
|
|
@@ -396,7 +399,7 @@ const runBuild = async function ({ childProcesses, pluginsOptions, netlifyConfig
|
|
|
396
399
|
await doDryRun({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs, featureFlags });
|
|
397
400
|
return { netlifyConfig };
|
|
398
401
|
}
|
|
399
|
-
const { stepsCount, netlifyConfig: netlifyConfigA, statuses, failedPlugins, timers: timersB, configMutations, metrics, } = await runSteps({
|
|
402
|
+
const { stepsCount, netlifyConfig: netlifyConfigA, statuses, failedPlugins, timers: timersB, configMutations, metrics, returnValues, } = await runSteps({
|
|
400
403
|
steps,
|
|
401
404
|
buildbotServerSocket,
|
|
402
405
|
events,
|
|
@@ -442,5 +445,6 @@ const runBuild = async function ({ childProcesses, pluginsOptions, netlifyConfig
|
|
|
442
445
|
timers: timersB,
|
|
443
446
|
configMutations,
|
|
444
447
|
metrics,
|
|
448
|
+
returnValues,
|
|
445
449
|
};
|
|
446
450
|
};
|
package/lib/core/dev.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export function startDev(devCommand: any, flags?: {}): Promise<{
|
|
|
4
4
|
netlifyConfig: any;
|
|
5
5
|
logs: import("../log/logger.js").BufferedLogs | undefined;
|
|
6
6
|
configMutations: any;
|
|
7
|
+
generatedFunctions: import("../steps/return_values.js").GeneratedFunction[];
|
|
7
8
|
error?: undefined;
|
|
8
9
|
} | {
|
|
9
10
|
success: boolean;
|
|
@@ -15,4 +16,5 @@ export function startDev(devCommand: any, flags?: {}): Promise<{
|
|
|
15
16
|
};
|
|
16
17
|
netlifyConfig?: undefined;
|
|
17
18
|
configMutations?: undefined;
|
|
19
|
+
generatedFunctions?: undefined;
|
|
18
20
|
}>;
|
package/lib/core/dev.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { handleBuildError } from '../error/handle.js';
|
|
2
|
+
import { getGeneratedFunctions } from '../steps/return_values.js';
|
|
2
3
|
import { execBuild, startBuild } from './build.js';
|
|
3
4
|
import { getSeverity } from './severity.js';
|
|
4
5
|
export const startDev = async (devCommand, flags = {}) => {
|
|
5
6
|
const { errorMonitor, mode, logs, debug, testOpts, ...normalizedFlags } = startBuild(flags);
|
|
6
7
|
const errorParams = { errorMonitor, mode, logs, debug, testOpts };
|
|
7
8
|
try {
|
|
8
|
-
const { netlifyConfig: netlifyConfigA, configMutations } = await execBuild({
|
|
9
|
+
const { netlifyConfig: netlifyConfigA, configMutations, returnValues, } = await execBuild({
|
|
9
10
|
...normalizedFlags,
|
|
10
11
|
errorMonitor,
|
|
11
12
|
errorParams,
|
|
@@ -17,7 +18,14 @@ export const startDev = async (devCommand, flags = {}) => {
|
|
|
17
18
|
devCommand,
|
|
18
19
|
});
|
|
19
20
|
const { success, severityCode } = getSeverity('success');
|
|
20
|
-
return {
|
|
21
|
+
return {
|
|
22
|
+
success,
|
|
23
|
+
severityCode,
|
|
24
|
+
netlifyConfig: netlifyConfigA,
|
|
25
|
+
logs,
|
|
26
|
+
configMutations,
|
|
27
|
+
generatedFunctions: getGeneratedFunctions(returnValues),
|
|
28
|
+
};
|
|
21
29
|
}
|
|
22
30
|
catch (error) {
|
|
23
31
|
const { severity, message, stack } = await handleBuildError(error, errorParams);
|
package/lib/core/main.js
CHANGED
|
@@ -4,6 +4,7 @@ import { handleBuildError } from '../error/handle.js';
|
|
|
4
4
|
import { reportError } from '../error/report.js';
|
|
5
5
|
import { getSystemLogger } from '../log/logger.js';
|
|
6
6
|
import { logTimer, logBuildSuccess } from '../log/messages/core.js';
|
|
7
|
+
import { getGeneratedFunctions } from '../steps/return_values.js';
|
|
7
8
|
import { trackBuildComplete } from '../telemetry/main.js';
|
|
8
9
|
import { reportTimers } from '../time/report.js';
|
|
9
10
|
import { execBuild, startBuild } from './build.js';
|
|
@@ -32,7 +33,7 @@ export async function buildSite(flags = {}) {
|
|
|
32
33
|
const rootCtx = context.with(getGlobalContext(), () => setMultiSpanAttributes(attributes));
|
|
33
34
|
return await tracer.startActiveSpan('exec-build', {}, rootCtx, async (span) => {
|
|
34
35
|
try {
|
|
35
|
-
const { pluginsOptions, netlifyConfig: netlifyConfigA, siteInfo, userNodeVersion, stepsCount, timers, durationNs, configMutations, metrics, } = await execBuild({
|
|
36
|
+
const { pluginsOptions, netlifyConfig: netlifyConfigA, siteInfo, userNodeVersion, stepsCount, timers, durationNs, configMutations, metrics, returnValues, } = await execBuild({
|
|
36
37
|
...flagsA,
|
|
37
38
|
buildId,
|
|
38
39
|
systemLogFile,
|
|
@@ -77,7 +78,14 @@ export async function buildSite(flags = {}) {
|
|
|
77
78
|
testOpts,
|
|
78
79
|
errorParams,
|
|
79
80
|
});
|
|
80
|
-
return {
|
|
81
|
+
return {
|
|
82
|
+
success,
|
|
83
|
+
severityCode,
|
|
84
|
+
netlifyConfig: netlifyConfigA,
|
|
85
|
+
logs,
|
|
86
|
+
configMutations,
|
|
87
|
+
generatedFunctions: getGeneratedFunctions(returnValues),
|
|
88
|
+
};
|
|
81
89
|
}
|
|
82
90
|
catch (error) {
|
|
83
91
|
const { severity } = await handleBuildError(error, errorParams);
|
|
@@ -50,15 +50,19 @@ export const logFunctionsNonExistingDir = function (logs, relativeFunctionsSrc)
|
|
|
50
50
|
// Print the list of Netlify Functions about to be bundled
|
|
51
51
|
export const logFunctionsToBundle = function ({ logs, userFunctions, userFunctionsSrc, userFunctionsSrcExists, internalFunctions, internalFunctionsSrc, frameworkFunctions, generatedFunctions, type = 'Functions', }) {
|
|
52
52
|
let needsSpace = false;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
if (needsSpace)
|
|
57
|
-
log(logs, '');
|
|
58
|
-
log(logs, `Packaging ${type} generated by ${THEME.highlightWords(displayName)} ${generatorType}:`);
|
|
59
|
-
logArray(logs, functionNames, { indent: false });
|
|
60
|
-
needsSpace = true;
|
|
53
|
+
for (const id in generatedFunctions) {
|
|
54
|
+
if (generatedFunctions[id].length === 0) {
|
|
55
|
+
continue;
|
|
61
56
|
}
|
|
57
|
+
// Getting the generator block from the first function, since it will be
|
|
58
|
+
// the same for all of them.
|
|
59
|
+
const { generator } = generatedFunctions[id][0];
|
|
60
|
+
const functionNames = generatedFunctions[id].map((func) => path.basename(func.path));
|
|
61
|
+
if (needsSpace)
|
|
62
|
+
log(logs, '');
|
|
63
|
+
log(logs, `Packaging ${type} generated by ${THEME.highlightWords(generator.displayName)} ${generator.type}:`);
|
|
64
|
+
logArray(logs, functionNames, { indent: false });
|
|
65
|
+
needsSpace = true;
|
|
62
66
|
}
|
|
63
67
|
if (internalFunctions.length !== 0) {
|
|
64
68
|
if (needsSpace)
|
|
@@ -123,7 +123,7 @@ const logFunctions = async ({ frameworksAPISrcPath, internalSrcDirectory, intern
|
|
|
123
123
|
internalFunctionsSrc: internalSrcDirectory,
|
|
124
124
|
frameworkFunctions: frameworkFunctions.map(({ name }) => name),
|
|
125
125
|
type: 'Edge Functions',
|
|
126
|
-
generatedFunctions:
|
|
126
|
+
generatedFunctions: {},
|
|
127
127
|
});
|
|
128
128
|
};
|
|
129
129
|
export const bundleEdgeFunctions = {
|
|
@@ -49,5 +49,5 @@ export declare const bundleFunctions: {
|
|
|
49
49
|
}) => Promise<boolean>;
|
|
50
50
|
};
|
|
51
51
|
export declare const zipItAndShipIt: {
|
|
52
|
-
zipFunctions(
|
|
52
|
+
zipFunctions(input: import("packages/zip-it-and-ship-it/dist/zip.js").ZipFunctionsPaths, destFolder: string, args_2?: import("@netlify/zip-it-and-ship-it").ZipFunctionsOptions | undefined): Promise<FunctionResult[]>;
|
|
53
53
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolve } from 'path';
|
|
2
2
|
import { RUNTIME, zipFunctions } from '@netlify/zip-it-and-ship-it';
|
|
3
3
|
import { pathExists } from 'path-exists';
|
|
4
4
|
import { addErrorInfo } from '../../error/info.js';
|
|
5
5
|
import { log } from '../../log/logger.js';
|
|
6
|
+
import { getGeneratedFunctions } from '../../steps/return_values.js';
|
|
6
7
|
import { logBundleResults, logFunctionsNonExistingDir, logFunctionsToBundle } from '../../log/messages/core_steps.js';
|
|
7
8
|
import { FRAMEWORKS_API_FUNCTIONS_ENDPOINT } from '../../utils/frameworks_api.js';
|
|
8
9
|
import { getZipError } from './error.js';
|
|
@@ -63,8 +64,15 @@ const zipFunctionsAndLogResults = async ({ branch, buildDir, childEnv, featureFl
|
|
|
63
64
|
try {
|
|
64
65
|
// Printing an empty line before bundling output.
|
|
65
66
|
log(logs, '');
|
|
66
|
-
const
|
|
67
|
-
|
|
67
|
+
const results = await zipItAndShipIt.zipFunctions({
|
|
68
|
+
generated: {
|
|
69
|
+
directories: [internalFunctionsSrc, frameworkFunctionsSrc].filter(Boolean),
|
|
70
|
+
functions: generatedFunctions,
|
|
71
|
+
},
|
|
72
|
+
user: {
|
|
73
|
+
directories: [functionsSrc].filter(Boolean),
|
|
74
|
+
},
|
|
75
|
+
}, functionsDist, zisiParameters);
|
|
68
76
|
validateCustomRoutes(results);
|
|
69
77
|
const bundlers = Array.from(getBundlers(results));
|
|
70
78
|
logBundleResults({ logs, results });
|
|
@@ -98,7 +106,7 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
|
|
|
98
106
|
log(logs, '');
|
|
99
107
|
}
|
|
100
108
|
}
|
|
101
|
-
const generatedFunctions =
|
|
109
|
+
const generatedFunctions = getGeneratedFunctions(returnValues);
|
|
102
110
|
logFunctionsToBundle({
|
|
103
111
|
logs,
|
|
104
112
|
userFunctions,
|
|
@@ -107,7 +115,7 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
|
|
|
107
115
|
internalFunctions,
|
|
108
116
|
internalFunctionsSrc: relativeInternalFunctionsSrc,
|
|
109
117
|
frameworkFunctions,
|
|
110
|
-
generatedFunctions: getGeneratedFunctionsByGenerator(
|
|
118
|
+
generatedFunctions: getGeneratedFunctionsByGenerator(generatedFunctions),
|
|
111
119
|
});
|
|
112
120
|
if (userFunctions.length === 0 &&
|
|
113
121
|
internalFunctions.length === 0 &&
|
|
@@ -130,7 +138,7 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
|
|
|
130
138
|
repositoryRoot,
|
|
131
139
|
userNodeVersion,
|
|
132
140
|
systemLog,
|
|
133
|
-
generatedFunctions,
|
|
141
|
+
generatedFunctions: generatedFunctions.map((func) => func.path),
|
|
134
142
|
});
|
|
135
143
|
const metrics = getMetrics(internalFunctions, userFunctions);
|
|
136
144
|
return {
|
|
@@ -166,25 +174,14 @@ const hasFunctionsDirectories = async function ({ buildDir, constants: { INTERNA
|
|
|
166
174
|
}
|
|
167
175
|
return false;
|
|
168
176
|
};
|
|
169
|
-
// Takes a list of return values and produces an array with the paths of all
|
|
170
|
-
// generated functions.
|
|
171
|
-
const getGeneratedFunctionPaths = (returnValues) => {
|
|
172
|
-
return Object.values(returnValues).flatMap((returnValue) => returnValue.generatedFunctions?.map((func) => func.path) || []);
|
|
173
|
-
};
|
|
174
177
|
// Takes a list of return values and produces an object with the names of the
|
|
175
178
|
// generated functions for each generator. This is used for printing logs only.
|
|
176
|
-
const getGeneratedFunctionsByGenerator = (
|
|
179
|
+
const getGeneratedFunctionsByGenerator = (generatedFunctions) => {
|
|
177
180
|
const result = {};
|
|
178
|
-
for (const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
183
|
-
result[id] = {
|
|
184
|
-
displayName,
|
|
185
|
-
generatorType,
|
|
186
|
-
functionNames: generatedFunctions.map((func) => basename(func.path)),
|
|
187
|
-
};
|
|
181
|
+
for (const func of generatedFunctions) {
|
|
182
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
183
|
+
result[func.generator.name] = result[func.generator.name] || [];
|
|
184
|
+
result[func.generator.name].push(func);
|
|
188
185
|
}
|
|
189
186
|
return result;
|
|
190
187
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
type GeneratorType = 'build plugin' | 'extension';
|
|
2
|
+
export interface GeneratedFunction {
|
|
3
|
+
generator: {
|
|
4
|
+
displayName: string;
|
|
5
|
+
name: string;
|
|
6
|
+
type: GeneratorType;
|
|
7
|
+
};
|
|
8
|
+
path: string;
|
|
9
|
+
}
|
|
10
|
+
export interface ReturnValue {
|
|
11
|
+
displayName?: string;
|
|
12
|
+
generatedFunctions?: {
|
|
13
|
+
path: string;
|
|
14
|
+
}[];
|
|
15
|
+
generatorType: GeneratorType;
|
|
16
|
+
}
|
|
17
|
+
export declare const getGeneratedFunctions: (returnValues?: Record<string, ReturnValue>) => GeneratedFunction[];
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const getGeneratedFunctions = (returnValues) => {
|
|
2
|
+
return Object.entries(returnValues ?? {}).flatMap(([name, returnValue]) => {
|
|
3
|
+
const generator = {
|
|
4
|
+
displayName: returnValue.displayName ?? name,
|
|
5
|
+
name,
|
|
6
|
+
type: returnValue.generatorType,
|
|
7
|
+
};
|
|
8
|
+
return (returnValue.generatedFunctions?.map((func) => ({
|
|
9
|
+
generator,
|
|
10
|
+
path: func.path,
|
|
11
|
+
})) ?? []);
|
|
12
|
+
});
|
|
13
|
+
};
|
package/lib/steps/run_steps.js
CHANGED
|
@@ -67,7 +67,7 @@ export const runSteps = async function ({ defaultConfig, steps, buildbotServerSo
|
|
|
67
67
|
edgeFunctionsBootstrapURL,
|
|
68
68
|
});
|
|
69
69
|
const statusesA = addStatus({ newStatus, statuses, event, packageName, pluginPackageJson });
|
|
70
|
-
/** @type import('../
|
|
70
|
+
/** @type import('../steps/return_values.js').ReturnValue */
|
|
71
71
|
const augmentedReturnValue = returnValue
|
|
72
72
|
? {
|
|
73
73
|
...returnValue,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "34.0.0",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -67,16 +67,16 @@
|
|
|
67
67
|
"license": "MIT",
|
|
68
68
|
"dependencies": {
|
|
69
69
|
"@bugsnag/js": "^8.0.0",
|
|
70
|
-
"@netlify/blobs": "^10.0.
|
|
70
|
+
"@netlify/blobs": "^10.0.3",
|
|
71
71
|
"@netlify/cache-utils": "^6.0.3",
|
|
72
|
-
"@netlify/config": "^23.0
|
|
72
|
+
"@netlify/config": "^23.1.0",
|
|
73
73
|
"@netlify/edge-bundler": "14.0.6",
|
|
74
|
-
"@netlify/functions-utils": "^6.0.
|
|
74
|
+
"@netlify/functions-utils": "^6.0.14",
|
|
75
75
|
"@netlify/git-utils": "^6.0.2",
|
|
76
76
|
"@netlify/opentelemetry-utils": "^2.0.1",
|
|
77
77
|
"@netlify/plugins-list": "^6.80.0",
|
|
78
78
|
"@netlify/run-utils": "^6.0.2",
|
|
79
|
-
"@netlify/zip-it-and-ship-it": "
|
|
79
|
+
"@netlify/zip-it-and-ship-it": "13.0.0",
|
|
80
80
|
"@sindresorhus/slugify": "^2.0.0",
|
|
81
81
|
"ansi-escapes": "^7.0.0",
|
|
82
82
|
"chalk": "^5.0.0",
|
|
@@ -156,5 +156,5 @@
|
|
|
156
156
|
"engines": {
|
|
157
157
|
"node": ">=18.14.0"
|
|
158
158
|
},
|
|
159
|
-
"gitHead": "
|
|
159
|
+
"gitHead": "cc8bccf13040e0e43282845c5a3a6d17db659ce8"
|
|
160
160
|
}
|
package/lib/types/step.d.ts
DELETED
package/lib/types/step.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|