@netlify/build 29.24.2 → 29.25.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 +2 -1
- package/lib/core/build.js +8 -5
- package/lib/core/main.js +2 -1
- package/lib/core/types.d.ts +9 -1
- package/lib/log/messages/config.js +2 -1
- package/lib/steps/get.d.ts +2 -2
- package/lib/steps/get.js +30 -5
- package/package.json +5 -5
package/lib/core/build.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export declare const startBuild: (flags: Partial<BuildFlags>) => {
|
|
|
33
33
|
};
|
|
34
34
|
};
|
|
35
35
|
export declare const execBuild: any;
|
|
36
|
-
export declare const runAndReportBuild: ({ pluginsOptions, netlifyConfig, configOpts, siteInfo, configPath, outputConfigPath, headersPath, redirectsPath, packagePath, buildDir, repositoryRoot, nodePath, packageJson, userNodeVersion, childEnv, context, branch, buildbotServerSocket, constants, dry, mode, api, errorMonitor, deployId, errorParams, logs, debug, systemLog, verbose, timers, sendStatus, saveConfig, testOpts, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, }: {
|
|
36
|
+
export declare const runAndReportBuild: ({ pluginsOptions, netlifyConfig, configOpts, siteInfo, configPath, outputConfigPath, headersPath, redirectsPath, packagePath, buildDir, repositoryRoot, nodePath, packageJson, userNodeVersion, childEnv, context, branch, buildbotServerSocket, constants, dry, mode, api, errorMonitor, deployId, errorParams, logs, debug, systemLog, verbose, timers, sendStatus, saveConfig, testOpts, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }: {
|
|
37
37
|
pluginsOptions: any;
|
|
38
38
|
netlifyConfig: any;
|
|
39
39
|
configOpts: any;
|
|
@@ -74,6 +74,7 @@ export declare const runAndReportBuild: ({ pluginsOptions, netlifyConfig, config
|
|
|
74
74
|
integrations: any;
|
|
75
75
|
explicitSecretKeys: any;
|
|
76
76
|
edgeFunctionsBootstrapURL: any;
|
|
77
|
+
eventHandlers: any;
|
|
77
78
|
}) => Promise<{
|
|
78
79
|
pluginsOptions: any;
|
|
79
80
|
netlifyConfig: any;
|
package/lib/core/build.js
CHANGED
|
@@ -33,7 +33,7 @@ export const startBuild = function (flags) {
|
|
|
33
33
|
const rootTracingContext = startTracing(tracingOpts, getSystemLogger(logs, debug, systemLogFile));
|
|
34
34
|
return { ...flagsA, rootTracingContext, debug, systemLogFile, errorMonitor, logs, timers };
|
|
35
35
|
};
|
|
36
|
-
const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cachedConfigPath, outputConfigPath, cwd, packagePath, repositoryRoot, apiHost, token, siteId, context, branch, baseRelDir, env: envOpt, debug, systemLogFile, verbose, nodePath, functionsDistDir, edgeFunctionsDistDir, cacheDir, dry, mode, offline, deployId, buildId, testOpts, errorMonitor, errorParams, logs, timers, buildbotServerSocket, sendStatus, saveConfig, featureFlags, timeline, devCommand, quiet, framework, explicitSecretKeys, edgeFunctionsBootstrapURL, }) {
|
|
36
|
+
const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cachedConfigPath, outputConfigPath, cwd, packagePath, repositoryRoot, apiHost, token, siteId, context, branch, baseRelDir, env: envOpt, debug, systemLogFile, verbose, nodePath, functionsDistDir, edgeFunctionsDistDir, cacheDir, dry, mode, offline, deployId, buildId, testOpts, errorMonitor, errorParams, logs, timers, buildbotServerSocket, sendStatus, saveConfig, featureFlags, timeline, devCommand, quiet, framework, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }) {
|
|
37
37
|
const configOpts = getConfigOpts({
|
|
38
38
|
config,
|
|
39
39
|
defaultConfig,
|
|
@@ -135,6 +135,7 @@ const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cached
|
|
|
135
135
|
integrations,
|
|
136
136
|
explicitSecretKeys,
|
|
137
137
|
edgeFunctionsBootstrapURL,
|
|
138
|
+
eventHandlers,
|
|
138
139
|
});
|
|
139
140
|
return {
|
|
140
141
|
pluginsOptions: pluginsOptionsA,
|
|
@@ -149,7 +150,7 @@ const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cached
|
|
|
149
150
|
};
|
|
150
151
|
export const execBuild = measureDuration(tExecBuild, 'total', { parentTag: 'build_site' });
|
|
151
152
|
// Runs a build then report any plugin statuses
|
|
152
|
-
export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig, configOpts, siteInfo, configPath, outputConfigPath, headersPath, redirectsPath, packagePath, buildDir, repositoryRoot, nodePath, packageJson, userNodeVersion, childEnv, context, branch, buildbotServerSocket, constants, dry, mode, api, errorMonitor, deployId, errorParams, logs, debug, systemLog, verbose, timers, sendStatus, saveConfig, testOpts, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, }) {
|
|
153
|
+
export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig, configOpts, siteInfo, configPath, outputConfigPath, headersPath, redirectsPath, packagePath, buildDir, repositoryRoot, nodePath, packageJson, userNodeVersion, childEnv, context, branch, buildbotServerSocket, constants, dry, mode, api, errorMonitor, deployId, errorParams, logs, debug, systemLog, verbose, timers, sendStatus, saveConfig, testOpts, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }) {
|
|
153
154
|
try {
|
|
154
155
|
const { stepsCount, netlifyConfig: netlifyConfigA, statuses, pluginsOptions: pluginsOptionsA, failedPlugins, timers: timersA, configMutations, metrics, } = await initAndRunBuild({
|
|
155
156
|
pluginsOptions,
|
|
@@ -192,6 +193,7 @@ export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig
|
|
|
192
193
|
integrations,
|
|
193
194
|
explicitSecretKeys,
|
|
194
195
|
edgeFunctionsBootstrapURL,
|
|
196
|
+
eventHandlers,
|
|
195
197
|
});
|
|
196
198
|
await Promise.all([
|
|
197
199
|
reportStatuses({
|
|
@@ -252,7 +254,7 @@ export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig
|
|
|
252
254
|
}
|
|
253
255
|
};
|
|
254
256
|
// Initialize plugin processes then runs a build
|
|
255
|
-
const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configOpts, siteInfo, configPath, outputConfigPath, headersPath, redirectsPath, buildDir, packagePath, repositoryRoot, nodePath, packageJson, userNodeVersion, childEnv, context, branch, dry, mode, api, errorMonitor, deployId, errorParams, logs, debug, systemLog, verbose, sendStatus, saveConfig, timers, testOpts, buildbotServerSocket, constants, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, }) {
|
|
257
|
+
const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configOpts, siteInfo, configPath, outputConfigPath, headersPath, redirectsPath, buildDir, packagePath, repositoryRoot, nodePath, packageJson, userNodeVersion, childEnv, context, branch, dry, mode, api, errorMonitor, deployId, errorParams, logs, debug, systemLog, verbose, sendStatus, saveConfig, timers, testOpts, buildbotServerSocket, constants, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }) {
|
|
256
258
|
const { pluginsOptions: pluginsOptionsA, timers: timersA } = await getPluginsOptions({
|
|
257
259
|
pluginsOptions,
|
|
258
260
|
netlifyConfig,
|
|
@@ -324,6 +326,7 @@ const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configO
|
|
|
324
326
|
quiet,
|
|
325
327
|
explicitSecretKeys,
|
|
326
328
|
edgeFunctionsBootstrapURL,
|
|
329
|
+
eventHandlers,
|
|
327
330
|
});
|
|
328
331
|
await Promise.all([
|
|
329
332
|
warnOnMissingSideFiles({ buildDir, netlifyConfig: netlifyConfigA, logs }),
|
|
@@ -351,7 +354,7 @@ const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configO
|
|
|
351
354
|
};
|
|
352
355
|
// Load plugin main files, retrieve their event handlers then runs them,
|
|
353
356
|
// together with the build command
|
|
354
|
-
const runBuild = async function ({ childProcesses, pluginsOptions, netlifyConfig, configOpts, packageJson, configPath, outputConfigPath, userNodeVersion, headersPath, redirectsPath, buildDir, repositoryRoot, packagePath, nodePath, childEnv, context, branch, dry, buildbotServerSocket, constants, mode, api, errorMonitor, deployId, errorParams, logs, debug, systemLog, verbose, saveConfig, timers, testOpts, featureFlags, timeline, devCommand, quiet, explicitSecretKeys, edgeFunctionsBootstrapURL, }) {
|
|
357
|
+
const runBuild = async function ({ childProcesses, pluginsOptions, netlifyConfig, configOpts, packageJson, configPath, outputConfigPath, userNodeVersion, headersPath, redirectsPath, buildDir, repositoryRoot, packagePath, nodePath, childEnv, context, branch, dry, buildbotServerSocket, constants, mode, api, errorMonitor, deployId, errorParams, logs, debug, systemLog, verbose, saveConfig, timers, testOpts, featureFlags, timeline, devCommand, quiet, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }) {
|
|
355
358
|
const { pluginsSteps, timers: timersA } = await loadPlugins({
|
|
356
359
|
pluginsOptions,
|
|
357
360
|
childProcesses,
|
|
@@ -362,7 +365,7 @@ const runBuild = async function ({ childProcesses, pluginsOptions, netlifyConfig
|
|
|
362
365
|
verbose,
|
|
363
366
|
netlifyConfig,
|
|
364
367
|
});
|
|
365
|
-
const { steps, events } = timeline === 'dev' ? getDevSteps(devCommand, pluginsSteps) : getSteps(pluginsSteps);
|
|
368
|
+
const { steps, events } = timeline === 'dev' ? getDevSteps(devCommand, pluginsSteps, eventHandlers) : getSteps(pluginsSteps, eventHandlers);
|
|
366
369
|
if (dry) {
|
|
367
370
|
await doDryRun({ buildDir, steps, netlifyConfig, constants, buildbotServerSocket, logs });
|
|
368
371
|
return { netlifyConfig };
|
package/lib/core/main.js
CHANGED
|
@@ -17,7 +17,7 @@ const tracer = trace.getTracer('core');
|
|
|
17
17
|
* @param flags - build configuration CLI flags
|
|
18
18
|
*/
|
|
19
19
|
export async function buildSite(flags = {}) {
|
|
20
|
-
const { errorMonitor, framework, mode, logs, debug, systemLogFile, testOpts, statsdOpts, dry, telemetry, buildId, deployId, rootTracingContext, ...flagsA } = startBuild(flags);
|
|
20
|
+
const { errorMonitor, framework, mode, logs, debug, systemLogFile, testOpts, statsdOpts, dry, telemetry, buildId, deployId, rootTracingContext, eventHandlers, ...flagsA } = startBuild(flags);
|
|
21
21
|
const errorParams = { errorMonitor, mode, logs, debug, testOpts };
|
|
22
22
|
const systemLog = getSystemLogger(logs, debug, systemLogFile);
|
|
23
23
|
const attributes = {
|
|
@@ -43,6 +43,7 @@ export async function buildSite(flags = {}) {
|
|
|
43
43
|
testOpts,
|
|
44
44
|
errorParams,
|
|
45
45
|
framework,
|
|
46
|
+
eventHandlers,
|
|
46
47
|
});
|
|
47
48
|
await handleBuildSuccess({
|
|
48
49
|
framework,
|
package/lib/core/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NetlifyConfig } from '../../types/index.js';
|
|
1
|
+
import { NetlifyConfig, NetlifyPlugin } from '../../types/index.js';
|
|
2
2
|
export type Mode = 'buildbot' | 'cli' | 'require';
|
|
3
3
|
export type BuildCLIFlags = {
|
|
4
4
|
cachedConfig: Record<string, unknown>;
|
|
@@ -40,6 +40,13 @@ export type BuildCLIFlags = {
|
|
|
40
40
|
};
|
|
41
41
|
export type BuildFlags = BuildCLIFlags & {
|
|
42
42
|
env?: Record<string, unknown>;
|
|
43
|
+
eventHandlers?: EventHandlers;
|
|
44
|
+
};
|
|
45
|
+
type EventHandlers = {
|
|
46
|
+
[K in keyof NetlifyPlugin]: NetlifyPlugin[K] | {
|
|
47
|
+
handler: NetlifyPlugin[K];
|
|
48
|
+
description: string;
|
|
49
|
+
};
|
|
43
50
|
};
|
|
44
51
|
export type BuildResult = {
|
|
45
52
|
success: boolean;
|
|
@@ -82,3 +89,4 @@ export type TracingOptions = {
|
|
|
82
89
|
parentSpanId: string;
|
|
83
90
|
baggageFilePath: string;
|
|
84
91
|
};
|
|
92
|
+
export {};
|
|
@@ -52,9 +52,10 @@ const INTERNAL_FLAGS = [
|
|
|
52
52
|
'timeline',
|
|
53
53
|
'explicitSecretKeys',
|
|
54
54
|
'edgeFunctionsBootstrapURL',
|
|
55
|
+
'eventHandlers',
|
|
55
56
|
];
|
|
56
57
|
const HIDDEN_FLAGS = [...SECURE_FLAGS, ...TEST_FLAGS, ...INTERNAL_FLAGS];
|
|
57
|
-
const HIDDEN_DEBUG_FLAGS = [...SECURE_FLAGS, ...TEST_FLAGS];
|
|
58
|
+
const HIDDEN_DEBUG_FLAGS = [...SECURE_FLAGS, ...TEST_FLAGS, 'eventHandlers'];
|
|
58
59
|
export const logBuildDir = function (logs, buildDir) {
|
|
59
60
|
logSubHeader(logs, 'Current directory');
|
|
60
61
|
logMessage(logs, buildDir);
|
package/lib/steps/get.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function getSteps(steps: any): {
|
|
1
|
+
export function getSteps(steps: any, eventHandlers: any): {
|
|
2
2
|
steps: any;
|
|
3
3
|
events: any[];
|
|
4
4
|
};
|
|
5
|
-
export function getDevSteps(command: any, steps: any): {
|
|
5
|
+
export function getDevSteps(command: any, steps: any, eventHandlers: any): {
|
|
6
6
|
steps: any;
|
|
7
7
|
events: any[];
|
|
8
8
|
};
|
package/lib/steps/get.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { getUtils } from '../plugins/child/utils.js';
|
|
1
2
|
import { DEV_EVENTS, EVENTS } from '../plugins/events.js';
|
|
2
3
|
import { buildCommandCore } from '../plugins_core/build_command.js';
|
|
3
4
|
import { deploySite } from '../plugins_core/deploy/index.js';
|
|
@@ -6,14 +7,16 @@ import { bundleFunctions } from '../plugins_core/functions/index.js';
|
|
|
6
7
|
import { saveArtifacts } from '../plugins_core/save_artifacts/index.js';
|
|
7
8
|
import { scanForSecrets } from '../plugins_core/secrets_scanning/index.js';
|
|
8
9
|
// Get all build steps
|
|
9
|
-
export const getSteps = function (steps) {
|
|
10
|
+
export const getSteps = function (steps, eventHandlers) {
|
|
10
11
|
const stepsA = addCoreSteps(steps);
|
|
11
|
-
const
|
|
12
|
+
const eventSteps = getEventSteps(eventHandlers);
|
|
13
|
+
const stepsB = [...stepsA, ...eventSteps];
|
|
14
|
+
const stepsC = sortSteps(stepsB, EVENTS);
|
|
12
15
|
const events = getEvents(stepsB);
|
|
13
|
-
return { steps:
|
|
16
|
+
return { steps: stepsC, events };
|
|
14
17
|
};
|
|
15
18
|
// Get all dev steps
|
|
16
|
-
export const getDevSteps = function (command, steps) {
|
|
19
|
+
export const getDevSteps = function (command, steps, eventHandlers) {
|
|
17
20
|
const devCommandStep = {
|
|
18
21
|
event: 'onDev',
|
|
19
22
|
coreStep: async () => {
|
|
@@ -24,10 +27,32 @@ export const getDevSteps = function (command, steps) {
|
|
|
24
27
|
coreStepName: 'dev.command',
|
|
25
28
|
coreStepDescription: () => 'Run command for local development',
|
|
26
29
|
};
|
|
27
|
-
const
|
|
30
|
+
const eventSteps = getEventSteps(eventHandlers);
|
|
31
|
+
const sortedSteps = sortSteps([...steps, eventSteps, devCommandStep], DEV_EVENTS);
|
|
28
32
|
const events = getEvents(sortedSteps);
|
|
29
33
|
return { steps: sortedSteps, events };
|
|
30
34
|
};
|
|
35
|
+
const getEventSteps = function (eventHandlers) {
|
|
36
|
+
return Object.entries(eventHandlers ?? {}).map(([event, eventHandler]) => {
|
|
37
|
+
let description = `Event handler for ${event}`;
|
|
38
|
+
let handler = eventHandler;
|
|
39
|
+
if (typeof eventHandler !== 'function') {
|
|
40
|
+
description = eventHandler.description;
|
|
41
|
+
handler = eventHandler.handler;
|
|
42
|
+
}
|
|
43
|
+
return {
|
|
44
|
+
event,
|
|
45
|
+
coreStep: (args) => {
|
|
46
|
+
const { constants, event } = args;
|
|
47
|
+
const utils = getUtils({ event, constants, runState: {} });
|
|
48
|
+
return handler({ utils, ...args });
|
|
49
|
+
},
|
|
50
|
+
coreStepId: `options_${event}`,
|
|
51
|
+
coreStepName: `options.${event}`,
|
|
52
|
+
coreStepDescription: () => description,
|
|
53
|
+
};
|
|
54
|
+
});
|
|
55
|
+
};
|
|
31
56
|
const addCoreSteps = function (steps) {
|
|
32
57
|
return [buildCommandCore, ...steps, bundleFunctions, bundleEdgeFunctions, scanForSecrets, deploySite, saveArtifacts];
|
|
33
58
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "29.
|
|
3
|
+
"version": "29.25.0",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -68,13 +68,13 @@
|
|
|
68
68
|
"@honeycombio/opentelemetry-node": "^0.5.0",
|
|
69
69
|
"@netlify/cache-utils": "^5.1.5",
|
|
70
70
|
"@netlify/config": "^20.9.0",
|
|
71
|
-
"@netlify/edge-bundler": "9.
|
|
71
|
+
"@netlify/edge-bundler": "9.5.0",
|
|
72
72
|
"@netlify/framework-info": "^9.8.10",
|
|
73
|
-
"@netlify/functions-utils": "^5.2.
|
|
73
|
+
"@netlify/functions-utils": "^5.2.38",
|
|
74
74
|
"@netlify/git-utils": "^5.1.1",
|
|
75
75
|
"@netlify/plugins-list": "^6.71.0",
|
|
76
76
|
"@netlify/run-utils": "^5.1.1",
|
|
77
|
-
"@netlify/zip-it-and-ship-it": "9.25.
|
|
77
|
+
"@netlify/zip-it-and-ship-it": "9.25.6",
|
|
78
78
|
"@opentelemetry/api": "^1.4.1",
|
|
79
79
|
"@opentelemetry/core": "^1.17.1",
|
|
80
80
|
"@sindresorhus/slugify": "^2.0.0",
|
|
@@ -146,5 +146,5 @@
|
|
|
146
146
|
"engines": {
|
|
147
147
|
"node": "^14.16.0 || >=16.0.0"
|
|
148
148
|
},
|
|
149
|
-
"gitHead": "
|
|
149
|
+
"gitHead": "633f90410881f22105c6cb78003e92b92d0b02ef"
|
|
150
150
|
}
|