@netlify/build 37.2.0 → 37.3.1
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 +2 -1
- package/lib/core/constants.d.ts +6 -1
- package/lib/core/constants.js +4 -1
- package/lib/core/flags.d.ts +5 -0
- package/lib/core/flags.js +6 -0
- package/lib/core/normalize_flags.d.ts +1 -0
- package/lib/core/normalize_flags.js +2 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +1 -0
- package/lib/plugins_core/functions/index.d.ts +1 -2
- package/lib/plugins_core/functions/index.js +15 -23
- package/lib/plugins_core/functions/server_entry.d.ts +4 -3
- package/lib/plugins_core/functions/server_entry.js +17 -21
- package/lib/plugins_core/functions/zisi.d.ts +3 -5
- package/lib/plugins_core/functions/zisi.js +4 -9
- package/lib/plugins_core/server/index.d.ts +18 -0
- package/lib/plugins_core/server/index.js +44 -0
- package/lib/steps/get.js +2 -0
- package/lib/steps/run_core_steps.js +2 -1
- package/package.json +5 -5
package/lib/core/build.d.ts
CHANGED
package/lib/core/build.js
CHANGED
|
@@ -32,7 +32,7 @@ export const startBuild = function (flags) {
|
|
|
32
32
|
const errorMonitor = startErrorMonitor({ flags: { debug, systemLogFile, ...flagsA }, logs, bugsnagKey });
|
|
33
33
|
return { ...flagsA, debug, systemLogFile, errorMonitor, logs, timers };
|
|
34
34
|
};
|
|
35
|
-
const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cachedConfigPath, outputConfigPath, cwd, packagePath, repositoryRoot, apiHost, token, siteId, accountId, 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, explicitSecretKeys, enhancedSecretScan, edgeFunctionsBootstrapURL, eventHandlers, skewProtectionToken, }) {
|
|
35
|
+
const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cachedConfigPath, outputConfigPath, cwd, packagePath, repositoryRoot, apiHost, token, siteId, accountId, context, branch, baseRelDir, env: envOpt, debug, systemLogFile, verbose, nodePath, functionsDistDir, edgeFunctionsDistDir, serverDistDir, cacheDir, dry, mode, offline, deployId, buildId, testOpts, errorMonitor, errorParams, logs, timers, buildbotServerSocket, sendStatus, saveConfig, featureFlags, timeline, devCommand, quiet, explicitSecretKeys, enhancedSecretScan, edgeFunctionsBootstrapURL, eventHandlers, skewProtectionToken, }) {
|
|
36
36
|
const configOpts = getConfigOpts({
|
|
37
37
|
config,
|
|
38
38
|
defaultConfig,
|
|
@@ -73,6 +73,7 @@ const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cached
|
|
|
73
73
|
buildDir,
|
|
74
74
|
functionsDistDir,
|
|
75
75
|
edgeFunctionsDistDir,
|
|
76
|
+
serverDistDir,
|
|
76
77
|
cacheDir,
|
|
77
78
|
packagePath,
|
|
78
79
|
netlifyConfig,
|
package/lib/core/constants.d.ts
CHANGED
|
@@ -37,6 +37,10 @@ export interface NetlifyPluginConstants {
|
|
|
37
37
|
* the directory where built Edge Functions are placed before deployment. Its value is always defined, but the target might not have been created yet.
|
|
38
38
|
*/
|
|
39
39
|
EDGE_FUNCTIONS_DIST: string;
|
|
40
|
+
/**
|
|
41
|
+
* the directory where the built Netlify Server is placed before deployment. Its value is always defined, but the target might not have been created yet.
|
|
42
|
+
*/
|
|
43
|
+
SERVER_DIST: string;
|
|
40
44
|
/**
|
|
41
45
|
* the directory where database migrations are placed before deployment.
|
|
42
46
|
*/
|
|
@@ -84,12 +88,13 @@ export interface NetlifyPluginConstants {
|
|
|
84
88
|
/**
|
|
85
89
|
* Retrieve constants passed to plugins
|
|
86
90
|
*/
|
|
87
|
-
export declare const getConstants: ({ configPath, buildDir, packagePath, functionsDistDir, edgeFunctionsDistDir, cacheDir, netlifyConfig, siteInfo: { id: siteId, account_id: accountId }, apiHost, token, mode, }: {
|
|
91
|
+
export declare const getConstants: ({ configPath, buildDir, packagePath, functionsDistDir, edgeFunctionsDistDir, serverDistDir, cacheDir, netlifyConfig, siteInfo: { id: siteId, account_id: accountId }, apiHost, token, mode, }: {
|
|
88
92
|
configPath: any;
|
|
89
93
|
buildDir: any;
|
|
90
94
|
packagePath: any;
|
|
91
95
|
functionsDistDir: any;
|
|
92
96
|
edgeFunctionsDistDir: any;
|
|
97
|
+
serverDistDir: any;
|
|
93
98
|
cacheDir: any;
|
|
94
99
|
netlifyConfig: any;
|
|
95
100
|
siteInfo: {
|
package/lib/core/constants.js
CHANGED
|
@@ -5,7 +5,7 @@ import { ROOT_PACKAGE_JSON } from '../utils/json.js';
|
|
|
5
5
|
/**
|
|
6
6
|
* Retrieve constants passed to plugins
|
|
7
7
|
*/
|
|
8
|
-
export const getConstants = async function ({ configPath, buildDir, packagePath, functionsDistDir, edgeFunctionsDistDir, cacheDir, netlifyConfig, siteInfo: { id: siteId, account_id: accountId }, apiHost, token, mode, }) {
|
|
8
|
+
export const getConstants = async function ({ configPath, buildDir, packagePath, functionsDistDir, edgeFunctionsDistDir, serverDistDir, cacheDir, netlifyConfig, siteInfo: { id: siteId, account_id: accountId }, apiHost, token, mode, }) {
|
|
9
9
|
const isLocal = mode !== 'buildbot';
|
|
10
10
|
const normalizedCacheDir = getCacheDir({ cacheDir, cwd: join(buildDir, packagePath || '') });
|
|
11
11
|
const constants = {
|
|
@@ -21,6 +21,8 @@ export const getConstants = async function ({ configPath, buildDir, packagePath,
|
|
|
21
21
|
// only on local development join with the packagePath as this directory
|
|
22
22
|
// on buildbot this `functionsDistDir` is an absolute path to `/tmp/zisi-.....` so we cannot join it with the pacakgePath
|
|
23
23
|
EDGE_FUNCTIONS_DIST: !isLocal ? edgeFunctionsDistDir : join(packagePath || '', edgeFunctionsDistDir),
|
|
24
|
+
// The directory where the built Netlify Server is placed before deployment
|
|
25
|
+
SERVER_DIST: !isLocal ? serverDistDir : join(packagePath || '', serverDistDir),
|
|
24
26
|
// Path to the Netlify build cache folder
|
|
25
27
|
CACHE_DIR: normalizedCacheDir,
|
|
26
28
|
// Boolean indicating whether the build was run locally (Netlify CLI) or in the production CI
|
|
@@ -126,6 +128,7 @@ const CONSTANT_PATHS = new Set([
|
|
|
126
128
|
'INTERNAL_FUNCTIONS_SRC',
|
|
127
129
|
'DB_MIGRATIONS_DIST',
|
|
128
130
|
'EDGE_FUNCTIONS_DIST',
|
|
131
|
+
'SERVER_DIST',
|
|
129
132
|
'EDGE_FUNCTIONS_SRC',
|
|
130
133
|
'DB_MIGRATIONS_SRC',
|
|
131
134
|
'CACHE_DIR',
|
package/lib/core/flags.d.ts
CHANGED
package/lib/core/flags.js
CHANGED
|
@@ -123,6 +123,12 @@ Default: automatically guessed`,
|
|
|
123
123
|
edgeFunctionsDistDir: {
|
|
124
124
|
string: true,
|
|
125
125
|
describe: `Path to the directory where packaged Edge Functions are kept.
|
|
126
|
+
Default: automatically guessed`,
|
|
127
|
+
hidden: true,
|
|
128
|
+
},
|
|
129
|
+
serverDistDir: {
|
|
130
|
+
string: true,
|
|
131
|
+
describe: `Path to the directory where the packaged Netlify Server is kept.
|
|
126
132
|
Default: automatically guessed`,
|
|
127
133
|
hidden: true,
|
|
128
134
|
},
|
|
@@ -9,6 +9,7 @@ export type ResolvedFlags = {
|
|
|
9
9
|
verbose: boolean;
|
|
10
10
|
/** The dist directory of the functions @default `.netlify/functions/` */
|
|
11
11
|
functionsDistDir: string;
|
|
12
|
+
serverDistDir: string;
|
|
12
13
|
/** The dist directory of the edge functions @default `.netlify/edge-functions-dist/` */
|
|
13
14
|
edgeFunctionsDistDir: string;
|
|
14
15
|
/** The directory that is used for storing the cache @default `.netlify/cache/` */
|
|
@@ -6,6 +6,7 @@ export const DEFAULT_API_HOST = 'api.netlify.com';
|
|
|
6
6
|
const REQUIRE_MODE = 'require';
|
|
7
7
|
const DEFAULT_EDGE_FUNCTIONS_DIST = '.netlify/edge-functions-dist/';
|
|
8
8
|
const DEFAULT_FUNCTIONS_DIST = '.netlify/functions/';
|
|
9
|
+
const DEFAULT_SERVER_DIST = '.netlify/server/';
|
|
9
10
|
const DEFAULT_CACHE_DIR = '.netlify/cache/';
|
|
10
11
|
const DEFAULT_STATSD_PORT = 8125;
|
|
11
12
|
const DEFAULT_OTEL_TRACING_PORT = 4317;
|
|
@@ -42,6 +43,7 @@ const getDefaultFlags = function ({ env: envOpt = {} }, combinedEnv) {
|
|
|
42
43
|
telemetry: false,
|
|
43
44
|
verbose: Boolean(combinedEnv.NETLIFY_BUILD_DEBUG),
|
|
44
45
|
functionsDistDir: DEFAULT_FUNCTIONS_DIST,
|
|
46
|
+
serverDistDir: DEFAULT_SERVER_DIST,
|
|
45
47
|
edgeFunctionsDistDir: DEFAULT_EDGE_FUNCTIONS_DIST,
|
|
46
48
|
cacheDir: DEFAULT_CACHE_DIR,
|
|
47
49
|
deployId: combinedEnv.DEPLOY_ID,
|
package/lib/index.d.ts
CHANGED
|
@@ -11,4 +11,5 @@ export type { NetlifyPluginUtils } from './types/options/netlify_plugin_utils.js
|
|
|
11
11
|
export type { ListedFunction, ListedFunctionFile } from './types/options/netlify_plugin_functions_util.js';
|
|
12
12
|
export { startDev } from './core/dev.js';
|
|
13
13
|
export { runCoreSteps } from './steps/run_core_steps.js';
|
|
14
|
+
export { SERVER_DIRECTORY } from './plugins_core/functions/server_entry.js';
|
|
14
15
|
export default buildSite;
|
package/lib/index.js
CHANGED
|
@@ -3,5 +3,6 @@ export { getVersion } from './utils/json.js';
|
|
|
3
3
|
// actual main types
|
|
4
4
|
export { startDev } from './core/dev.js';
|
|
5
5
|
export { runCoreSteps } from './steps/run_core_steps.js';
|
|
6
|
+
export { SERVER_DIRECTORY } from './plugins_core/functions/server_entry.js';
|
|
6
7
|
// default export the buildSite function
|
|
7
8
|
export default buildSite;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { zipFunctions, type FunctionResult } from '@netlify/zip-it-and-ship-it';
|
|
2
2
|
import type { CoreStepFunction } from '../types.js';
|
|
3
3
|
export declare const bundleFunctions: {
|
|
4
4
|
event: string;
|
|
@@ -18,6 +18,5 @@ export declare const bundleFunctions: {
|
|
|
18
18
|
}) => Promise<boolean>;
|
|
19
19
|
};
|
|
20
20
|
export declare const zipItAndShipIt: {
|
|
21
|
-
bundle(options: BundleOptions): Promise<BundleResult>;
|
|
22
21
|
zipFunctions(input: import("@netlify/zip-it-and-ship-it").MixedPaths, destFolder: string, args_2?: import("@netlify/zip-it-and-ship-it").ZipFunctionsOptions | undefined): Promise<FunctionResult[]>;
|
|
23
22
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { resolve } from 'path';
|
|
2
|
-
import {
|
|
2
|
+
import { zipFunctions } from '@netlify/zip-it-and-ship-it';
|
|
3
3
|
import { pathExists } from '../../utils/path_exists.js';
|
|
4
4
|
import { addErrorInfo } from '../../error/info.js';
|
|
5
5
|
import { log } from '../../log/logger.js';
|
|
@@ -7,7 +7,7 @@ import { getGeneratedFunctions } from '../../steps/return_values.js';
|
|
|
7
7
|
import { logBundleResults, logFunctionsNonExistingDir, logFunctionsToBundle, trackBundleResults, } from '../../log/messages/core_steps.js';
|
|
8
8
|
import { FRAMEWORKS_API_FUNCTIONS_PATH } from '../../utils/frameworks_api.js';
|
|
9
9
|
import { getZipError } from './error.js';
|
|
10
|
-
import { getServerEntry,
|
|
10
|
+
import { getServerEntry, SERVER_DIRECTORY, useServerAsFunction, writeServerShim } from './server_entry.js';
|
|
11
11
|
import { getUserAndInternalFunctions, validateFunctionsSrc } from './utils.js';
|
|
12
12
|
import { getZisiParameters } from './zisi.js';
|
|
13
13
|
// see https://docs.netlify.com/functions/trigger-on-events/#available-triggers
|
|
@@ -42,7 +42,7 @@ const validateCustomRoutes = function (functions) {
|
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
const zipFunctionsAndLogResults = async ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, functionsSrc, generatedFunctions, frameworkFunctionsSrc, internalFunctionsSrc, isRunningLocally, logs, repositoryRoot,
|
|
45
|
+
const zipFunctionsAndLogResults = async ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, functionsSrc, generatedFunctions, frameworkFunctionsSrc, internalFunctionsSrc, isRunningLocally, logs, repositoryRoot, userNodeVersion, systemLog, }) => {
|
|
46
46
|
const zisiParameters = getZisiParameters({
|
|
47
47
|
branch,
|
|
48
48
|
buildDir,
|
|
@@ -52,24 +52,22 @@ const zipFunctionsAndLogResults = async ({ branch, buildDir, childEnv, featureFl
|
|
|
52
52
|
functionsDist,
|
|
53
53
|
internalFunctionsSrc,
|
|
54
54
|
isRunningLocally,
|
|
55
|
-
paths: {
|
|
56
|
-
generated: {
|
|
57
|
-
directories: [internalFunctionsSrc, frameworkFunctionsSrc].filter(Boolean),
|
|
58
|
-
functions: generatedFunctions,
|
|
59
|
-
},
|
|
60
|
-
user: {
|
|
61
|
-
directories: [functionsSrc].filter(Boolean),
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
55
|
repositoryRoot,
|
|
65
|
-
server,
|
|
66
56
|
userNodeVersion,
|
|
67
57
|
systemLog,
|
|
68
58
|
});
|
|
69
59
|
try {
|
|
70
60
|
// Printing an empty line before bundling output.
|
|
71
61
|
log(logs, '');
|
|
72
|
-
const
|
|
62
|
+
const results = await zipItAndShipIt.zipFunctions({
|
|
63
|
+
generated: {
|
|
64
|
+
directories: [internalFunctionsSrc, frameworkFunctionsSrc].filter(Boolean),
|
|
65
|
+
functions: generatedFunctions,
|
|
66
|
+
},
|
|
67
|
+
user: {
|
|
68
|
+
directories: [functionsSrc].filter(Boolean),
|
|
69
|
+
},
|
|
70
|
+
}, functionsDist, zisiParameters);
|
|
73
71
|
validateCustomRoutes(results);
|
|
74
72
|
logBundleResults({ logs, results });
|
|
75
73
|
const summary = trackBundleResults({ results, systemLog });
|
|
@@ -104,13 +102,11 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
|
|
|
104
102
|
}
|
|
105
103
|
}
|
|
106
104
|
const generatedFunctions = getGeneratedFunctions(returnValues);
|
|
107
|
-
const serverEntry = await getServerEntry({ buildDir, packagePath
|
|
105
|
+
const serverEntry = useServerAsFunction(featureFlags) ? await getServerEntry({ buildDir, packagePath }) : undefined;
|
|
108
106
|
if (serverEntry) {
|
|
109
107
|
log(logs, `Netlify Server detected at ${serverEntry.relativeEntryPath}`);
|
|
110
108
|
}
|
|
111
|
-
const
|
|
112
|
-
const standalone = featureFlags?.netlify_build_server_standalone === true;
|
|
113
|
-
const serverShimPath = serverEntry && asFunction ? await writeServerShim(serverEntry) : undefined;
|
|
109
|
+
const serverShimPath = serverEntry === undefined ? undefined : await writeServerShim(serverEntry);
|
|
114
110
|
logFunctionsToBundle({
|
|
115
111
|
logs,
|
|
116
112
|
userFunctions,
|
|
@@ -147,7 +143,6 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
|
|
|
147
143
|
...generatedFunctions.map((func) => func.path),
|
|
148
144
|
...(serverShimPath === undefined ? [] : [serverShimPath]),
|
|
149
145
|
],
|
|
150
|
-
server: serverEntry && standalone ? { path: serverEntry.entryPath } : undefined,
|
|
151
146
|
});
|
|
152
147
|
const fallback = fallbackCount > 0 ? 'true' : 'false';
|
|
153
148
|
const warnings = warningsCount > 0 ? 'true' : 'false';
|
|
@@ -166,7 +161,7 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
|
|
|
166
161
|
// `condition` because the directories might be created by the build command
|
|
167
162
|
// or plugins.
|
|
168
163
|
const hasFunctionsDirectories = async function ({ buildDir, constants: { INTERNAL_FUNCTIONS_SRC, FUNCTIONS_SRC }, featureFlags, packagePath, returnValues, }) {
|
|
169
|
-
if (
|
|
164
|
+
if (useServerAsFunction(featureFlags) && (await pathExists(resolve(buildDir, packagePath || '', SERVER_DIRECTORY)))) {
|
|
170
165
|
return true;
|
|
171
166
|
}
|
|
172
167
|
const hasFunctionsSrc = FUNCTIONS_SRC !== undefined && FUNCTIONS_SRC !== '';
|
|
@@ -215,9 +210,6 @@ export const bundleFunctions = {
|
|
|
215
210
|
// `zip-it-and-ship-it` methods. Therefore, we need to use an intermediary
|
|
216
211
|
// function and export them so tests can use it.
|
|
217
212
|
export const zipItAndShipIt = {
|
|
218
|
-
async bundle(options) {
|
|
219
|
-
return await bundle(options);
|
|
220
|
-
},
|
|
221
213
|
async zipFunctions(...args) {
|
|
222
214
|
return await zipFunctions(...args);
|
|
223
215
|
},
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import { type FeatureFlags } from '../../core/feature_flags.js';
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const SERVER_DIRECTORY = "netlify/server";
|
|
3
|
+
export declare const useServerAsFunction: (featureFlags?: FeatureFlags) => boolean;
|
|
4
|
+
export declare const useServerStandalone: (featureFlags?: FeatureFlags) => boolean;
|
|
3
5
|
export interface ServerEntry {
|
|
4
6
|
entryPath: string;
|
|
5
7
|
packageRoot: string;
|
|
6
8
|
relativeEntryPath: string;
|
|
7
9
|
}
|
|
8
|
-
export declare const getServerEntry: ({ buildDir, packagePath,
|
|
10
|
+
export declare const getServerEntry: ({ buildDir, packagePath, }: {
|
|
9
11
|
buildDir: string;
|
|
10
12
|
packagePath?: string;
|
|
11
|
-
featureFlags?: FeatureFlags;
|
|
12
13
|
}) => Promise<ServerEntry | undefined>;
|
|
13
14
|
/**
|
|
14
15
|
* Writes the file a server is bundled from when it travels as a function, and
|
|
@@ -1,33 +1,29 @@
|
|
|
1
|
-
import { mkdir,
|
|
2
|
-
import { join, resolve } from 'path';
|
|
3
|
-
import {
|
|
1
|
+
import { mkdir, writeFile } from 'fs/promises';
|
|
2
|
+
import { basename, join, resolve } from 'path';
|
|
3
|
+
import { findServerEntry } from '@netlify/zip-it-and-ship-it';
|
|
4
4
|
import { addErrorInfo } from '../../error/info.js';
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
export const
|
|
5
|
+
// Where a site's server lives, relative to the package root.
|
|
6
|
+
export const SERVER_DIRECTORY = 'netlify/server';
|
|
7
|
+
export const useServerAsFunction = (featureFlags) => featureFlags?.netlify_build_server_entry === true;
|
|
8
|
+
export const useServerStandalone = (featureFlags) => featureFlags?.netlify_build_server_standalone === true;
|
|
8
9
|
// Finds the user's server entrypoint.
|
|
9
|
-
export const getServerEntry = async ({ buildDir, packagePath,
|
|
10
|
-
if (!useServer(featureFlags)) {
|
|
11
|
-
return undefined;
|
|
12
|
-
}
|
|
10
|
+
export const getServerEntry = async ({ buildDir, packagePath, }) => {
|
|
13
11
|
const packageRoot = resolve(buildDir, packagePath ?? '');
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
12
|
+
let entryPath;
|
|
13
|
+
try {
|
|
14
|
+
entryPath = await findServerEntry(join(packageRoot, SERVER_DIRECTORY));
|
|
17
15
|
}
|
|
18
|
-
|
|
19
|
-
if (candidates.length === 0) {
|
|
20
|
-
return undefined;
|
|
21
|
-
}
|
|
22
|
-
if (candidates.length > 1) {
|
|
23
|
-
const error = new Error(`Found multiple server entrypoints in ${SERVER_ENTRY_DIR} (${candidates.join(', ')}). A site can have one server only.`);
|
|
16
|
+
catch (error) {
|
|
24
17
|
addErrorInfo(error, { type: 'resolveConfig' });
|
|
25
18
|
throw error;
|
|
26
19
|
}
|
|
20
|
+
if (entryPath === undefined) {
|
|
21
|
+
return undefined;
|
|
22
|
+
}
|
|
27
23
|
return {
|
|
28
|
-
entryPath
|
|
24
|
+
entryPath,
|
|
29
25
|
packageRoot,
|
|
30
|
-
relativeEntryPath: `${
|
|
26
|
+
relativeEntryPath: `${SERVER_DIRECTORY}/${basename(entryPath)}`,
|
|
31
27
|
};
|
|
32
28
|
};
|
|
33
29
|
// Everything below carries a server through the functions plumbing, which is
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type FunctionConfig, type ZipFunctionsOptions } from '@netlify/zip-it-and-ship-it';
|
|
2
2
|
import type { FeatureFlags } from '../../core/feature_flags.js';
|
|
3
3
|
type GetZisiParametersType = {
|
|
4
4
|
branch?: string;
|
|
@@ -11,11 +11,9 @@ type GetZisiParametersType = {
|
|
|
11
11
|
isRunningLocally: boolean;
|
|
12
12
|
repositoryRoot: string;
|
|
13
13
|
userNodeVersion: string;
|
|
14
|
-
systemLog:
|
|
15
|
-
paths: MixedPaths;
|
|
16
|
-
server?: ServerOptions;
|
|
14
|
+
systemLog: ZipFunctionsOptions['systemLog'];
|
|
17
15
|
};
|
|
18
|
-
export declare const getZisiParameters: ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, internalFunctionsSrc, isRunningLocally,
|
|
16
|
+
export declare const getZisiParameters: ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, internalFunctionsSrc, isRunningLocally, repositoryRoot, userNodeVersion, systemLog, }: GetZisiParametersType) => ZipFunctionsOptions;
|
|
19
17
|
export declare const normalizeFunctionConfig: ({ buildDir, functionConfig, isRunningLocally, nodeVersion, }: {
|
|
20
18
|
buildDir: string;
|
|
21
19
|
functionConfig: Record<string, any>;
|
|
@@ -16,7 +16,7 @@ const getLambdaNodeVersion = (childEnv, userNodeVersion) => {
|
|
|
16
16
|
}
|
|
17
17
|
return undefined;
|
|
18
18
|
};
|
|
19
|
-
export const getZisiParameters = ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, internalFunctionsSrc, isRunningLocally,
|
|
19
|
+
export const getZisiParameters = ({ branch, buildDir, childEnv, featureFlags, functionsConfig, functionsDist, internalFunctionsSrc, isRunningLocally, repositoryRoot, userNodeVersion, systemLog, }) => {
|
|
20
20
|
const nodeVersion = getLambdaNodeVersion(childEnv, userNodeVersion);
|
|
21
21
|
const manifest = join(functionsDist, 'manifest.json');
|
|
22
22
|
const config = Object.fromEntries(Object.entries(functionsConfig).map(([expression, object]) => [
|
|
@@ -30,16 +30,11 @@ export const getZisiParameters = ({ branch, buildDir, childEnv, featureFlags, fu
|
|
|
30
30
|
return {
|
|
31
31
|
basePath: buildDir,
|
|
32
32
|
branch,
|
|
33
|
-
|
|
34
|
-
featureFlags: zisiFeatureFlags,
|
|
35
|
-
functions: {
|
|
36
|
-
config,
|
|
37
|
-
configFileDirectories,
|
|
38
|
-
paths,
|
|
39
|
-
},
|
|
33
|
+
config,
|
|
40
34
|
manifest,
|
|
35
|
+
featureFlags: zisiFeatureFlags,
|
|
41
36
|
repositoryRoot,
|
|
42
|
-
|
|
37
|
+
configFileDirectories,
|
|
43
38
|
systemLog,
|
|
44
39
|
};
|
|
45
40
|
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { type ServerResult, zipServer } from '@netlify/zip-it-and-ship-it';
|
|
2
|
+
import type { FeatureFlags } from '../../core/feature_flags.js';
|
|
3
|
+
import type { CoreStepFunction } from '../types.js';
|
|
4
|
+
export declare const bundleServer: {
|
|
5
|
+
event: string;
|
|
6
|
+
coreStep: CoreStepFunction;
|
|
7
|
+
coreStepId: string;
|
|
8
|
+
coreStepName: string;
|
|
9
|
+
coreStepDescription: () => string;
|
|
10
|
+
condition: ({ buildDir, featureFlags, packagePath, }: {
|
|
11
|
+
buildDir: string;
|
|
12
|
+
featureFlags?: FeatureFlags;
|
|
13
|
+
packagePath?: string;
|
|
14
|
+
}) => Promise<boolean>;
|
|
15
|
+
};
|
|
16
|
+
export declare const zipItAndShipIt: {
|
|
17
|
+
zipServer(srcPath: string, destFolder: string, args_2?: import("@netlify/zip-it-and-ship-it").ZipServerOptions | undefined): Promise<ServerResult>;
|
|
18
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { resolve } from 'path';
|
|
2
|
+
import { zipServer } from '@netlify/zip-it-and-ship-it';
|
|
3
|
+
import { log } from '../../log/logger.js';
|
|
4
|
+
import { pathExists } from '../../utils/path_exists.js';
|
|
5
|
+
import { getZisiFeatureFlags } from '../functions/feature_flags.js';
|
|
6
|
+
import { getServerEntry, SERVER_DIRECTORY, useServerStandalone } from '../functions/server_entry.js';
|
|
7
|
+
const coreStep = async function ({ buildDir, constants: { SERVER_DIST }, featureFlags, logs, packagePath, repositoryRoot, systemLog, }) {
|
|
8
|
+
const serverEntry = await getServerEntry({ buildDir, packagePath });
|
|
9
|
+
if (serverEntry === undefined) {
|
|
10
|
+
return {};
|
|
11
|
+
}
|
|
12
|
+
log(logs, `Netlify Server detected at ${serverEntry.relativeEntryPath}`);
|
|
13
|
+
await zipItAndShipIt.zipServer(serverEntry.entryPath, resolve(buildDir, SERVER_DIST), {
|
|
14
|
+
basePath: buildDir,
|
|
15
|
+
featureFlags: getZisiFeatureFlags(featureFlags ?? {}),
|
|
16
|
+
repositoryRoot,
|
|
17
|
+
systemLog,
|
|
18
|
+
});
|
|
19
|
+
return {};
|
|
20
|
+
};
|
|
21
|
+
// The directory can be created by the build command or by a plugin, so this is
|
|
22
|
+
// checked when the step is about to run rather than when it is scheduled.
|
|
23
|
+
const hasServerDirectory = async function ({ buildDir, featureFlags, packagePath, }) {
|
|
24
|
+
if (!useServerStandalone(featureFlags)) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
return await pathExists(resolve(buildDir, packagePath ?? '', SERVER_DIRECTORY));
|
|
28
|
+
};
|
|
29
|
+
export const bundleServer = {
|
|
30
|
+
event: 'onBuild',
|
|
31
|
+
coreStep,
|
|
32
|
+
coreStepId: 'server_bundling',
|
|
33
|
+
coreStepName: 'Server bundling',
|
|
34
|
+
coreStepDescription: () => 'Server bundling',
|
|
35
|
+
condition: hasServerDirectory,
|
|
36
|
+
};
|
|
37
|
+
// Named imports with ES modules cannot be mocked (unlike CommonJS) because they
|
|
38
|
+
// are bound at load time, and the tests assert on what reaches
|
|
39
|
+
// `zip-it-and-ship-it`.
|
|
40
|
+
export const zipItAndShipIt = {
|
|
41
|
+
async zipServer(...args) {
|
|
42
|
+
return await zipServer(...args);
|
|
43
|
+
},
|
|
44
|
+
};
|
package/lib/steps/get.js
CHANGED
|
@@ -12,6 +12,7 @@ import { copyDbMigrations } from '../plugins_core/db_setup/migrations.js';
|
|
|
12
12
|
import { preCleanup } from '../plugins_core/pre_cleanup/index.js';
|
|
13
13
|
import { preDevCleanup } from '../plugins_core/pre_dev_cleanup/index.js';
|
|
14
14
|
import { saveArtifacts } from '../plugins_core/save_artifacts/index.js';
|
|
15
|
+
import { bundleServer } from '../plugins_core/server/index.js';
|
|
15
16
|
import { scanForSecrets } from '../plugins_core/secrets_scanning/index.js';
|
|
16
17
|
import { applySpaFallback } from '../plugins_core/spa_fallback/index.js';
|
|
17
18
|
// Get all build steps
|
|
@@ -71,6 +72,7 @@ const addCoreSteps = function (steps) {
|
|
|
71
72
|
applyDeployConfig,
|
|
72
73
|
...steps,
|
|
73
74
|
bundleFunctions,
|
|
75
|
+
bundleServer,
|
|
74
76
|
bundleEdgeFunctions,
|
|
75
77
|
copyDbMigrations,
|
|
76
78
|
applySpaFallback,
|
|
@@ -39,7 +39,7 @@ const getBuildSteps = function (buildSteps) {
|
|
|
39
39
|
const allSteps = getSteps([]).steps.filter(({ coreStepId }) => buildSteps.includes(coreStepId));
|
|
40
40
|
return allSteps;
|
|
41
41
|
};
|
|
42
|
-
const executeBuildStep = async function ({ config, packagePath, defaultConfig, cachedConfig, debug, nodePath, functionsDistDir, edgeFunctionsDistDir, errorMonitor, mode, logs, errorParams, featureFlags, buildSteps, repositoryRoot, systemLog, edgeFunctionsBootstrapURL, deployId, token, quiet, }) {
|
|
42
|
+
const executeBuildStep = async function ({ config, packagePath, defaultConfig, cachedConfig, debug, nodePath, functionsDistDir, edgeFunctionsDistDir, serverDistDir, errorMonitor, mode, logs, errorParams, featureFlags, buildSteps, repositoryRoot, systemLog, edgeFunctionsBootstrapURL, deployId, token, quiet, }) {
|
|
43
43
|
const configOpts = getConfigOpts({
|
|
44
44
|
config,
|
|
45
45
|
defaultConfig,
|
|
@@ -62,6 +62,7 @@ const executeBuildStep = async function ({ config, packagePath, defaultConfig, c
|
|
|
62
62
|
functionsDistDir,
|
|
63
63
|
packagePath,
|
|
64
64
|
edgeFunctionsDistDir,
|
|
65
|
+
serverDistDir,
|
|
65
66
|
netlifyConfig,
|
|
66
67
|
siteInfo,
|
|
67
68
|
mode,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "37.
|
|
3
|
+
"version": "37.3.1",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
"@netlify/blobs": "^11.0.3",
|
|
68
68
|
"@netlify/cache-utils": "^7.1.2",
|
|
69
69
|
"@netlify/config": "^25.2.5",
|
|
70
|
-
"@netlify/edge-bundler": "16.1.
|
|
71
|
-
"@netlify/functions-utils": "^7.1.
|
|
70
|
+
"@netlify/edge-bundler": "16.1.1",
|
|
71
|
+
"@netlify/functions-utils": "^7.1.13",
|
|
72
72
|
"@netlify/git-utils": "^7.1.1",
|
|
73
73
|
"@netlify/opentelemetry-utils": "^4.0.0",
|
|
74
74
|
"@netlify/plugins-list": "^6.81.6",
|
|
75
75
|
"@netlify/run-utils": "^7.1.0",
|
|
76
|
-
"@netlify/zip-it-and-ship-it": "16.1
|
|
76
|
+
"@netlify/zip-it-and-ship-it": "16.2.1",
|
|
77
77
|
"@sindresorhus/slugify": "^2.0.0",
|
|
78
78
|
"ansis": "^4.1.0",
|
|
79
79
|
"execa": "^8.0.0",
|
|
@@ -137,5 +137,5 @@
|
|
|
137
137
|
"engines": {
|
|
138
138
|
"node": ">=22.12.0"
|
|
139
139
|
},
|
|
140
|
-
"gitHead": "
|
|
140
|
+
"gitHead": "d99b17e8a25b18687ce7b7657621dd22827304b7"
|
|
141
141
|
}
|