@netlify/build 29.18.0 → 29.19.0-rc.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.js +11 -4
- package/lib/core/config.js +2 -1
- package/lib/core/constants.js +3 -1
- package/lib/core/flags.js +4 -0
- package/lib/plugins/options.js +2 -1
- package/lib/plugins/resolve.js +14 -8
- package/lib/plugins_core/deploy/index.js +2 -1
- package/lib/plugins_core/edge_functions/index.js +5 -5
- package/lib/plugins_core/functions/index.js +5 -5
- package/lib/plugins_core/save_artifacts/index.js +2 -1
- package/lib/steps/core_step.js +2 -1
- package/lib/steps/plugin.js +2 -1
- package/lib/steps/run_core_steps.js +3 -1
- package/lib/steps/run_step.js +18 -4
- package/lib/steps/run_steps.js +2 -1
- package/lib/time/main.js +6 -0
- package/package.json +5 -6
package/lib/core/build.js
CHANGED
|
@@ -33,12 +33,13 @@ 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, 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, }) {
|
|
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, }) {
|
|
37
37
|
const configOpts = getConfigOpts({
|
|
38
38
|
config,
|
|
39
39
|
defaultConfig,
|
|
40
40
|
cwd,
|
|
41
41
|
repositoryRoot,
|
|
42
|
+
packagePath,
|
|
42
43
|
apiHost,
|
|
43
44
|
token,
|
|
44
45
|
siteId,
|
|
@@ -81,6 +82,7 @@ const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cached
|
|
|
81
82
|
functionsDistDir,
|
|
82
83
|
edgeFunctionsDistDir,
|
|
83
84
|
cacheDir,
|
|
85
|
+
packagePath,
|
|
84
86
|
netlifyConfig,
|
|
85
87
|
siteInfo,
|
|
86
88
|
apiHost,
|
|
@@ -103,6 +105,7 @@ const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cached
|
|
|
103
105
|
redirectsPath,
|
|
104
106
|
buildDir,
|
|
105
107
|
repositoryRoot: repositoryRootA,
|
|
108
|
+
packagePath,
|
|
106
109
|
nodePath,
|
|
107
110
|
packageJson,
|
|
108
111
|
userNodeVersion,
|
|
@@ -145,7 +148,7 @@ const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cached
|
|
|
145
148
|
};
|
|
146
149
|
export const execBuild = measureDuration(tExecBuild, 'total', { parentTag: 'build_site' });
|
|
147
150
|
// Runs a build then report any plugin statuses
|
|
148
|
-
export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig, configOpts, siteInfo, configPath, outputConfigPath, headersPath, redirectsPath, 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, }) {
|
|
151
|
+
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, }) {
|
|
149
152
|
try {
|
|
150
153
|
const { stepsCount, netlifyConfig: netlifyConfigA, statuses, pluginsOptions: pluginsOptionsA, failedPlugins, timers: timersA, configMutations, metrics, } = await initAndRunBuild({
|
|
151
154
|
pluginsOptions,
|
|
@@ -157,6 +160,7 @@ export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig
|
|
|
157
160
|
headersPath,
|
|
158
161
|
redirectsPath,
|
|
159
162
|
buildDir,
|
|
163
|
+
packagePath,
|
|
160
164
|
repositoryRoot,
|
|
161
165
|
nodePath,
|
|
162
166
|
packageJson,
|
|
@@ -246,13 +250,14 @@ export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig
|
|
|
246
250
|
}
|
|
247
251
|
};
|
|
248
252
|
// Initialize plugin processes then runs a build
|
|
249
|
-
const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configOpts, siteInfo, configPath, outputConfigPath, headersPath, redirectsPath, buildDir, 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, }) {
|
|
253
|
+
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, }) {
|
|
250
254
|
const { pluginsOptions: pluginsOptionsA, timers: timersA } = await getPluginsOptions({
|
|
251
255
|
pluginsOptions,
|
|
252
256
|
netlifyConfig,
|
|
253
257
|
siteInfo,
|
|
254
258
|
buildDir,
|
|
255
259
|
nodePath,
|
|
260
|
+
packagePath,
|
|
256
261
|
packageJson,
|
|
257
262
|
userNodeVersion,
|
|
258
263
|
mode,
|
|
@@ -289,6 +294,7 @@ const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configO
|
|
|
289
294
|
headersPath,
|
|
290
295
|
redirectsPath,
|
|
291
296
|
buildDir,
|
|
297
|
+
packagePath,
|
|
292
298
|
repositoryRoot,
|
|
293
299
|
nodePath,
|
|
294
300
|
childEnv,
|
|
@@ -341,7 +347,7 @@ const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configO
|
|
|
341
347
|
};
|
|
342
348
|
// Load plugin main files, retrieve their event handlers then runs them,
|
|
343
349
|
// together with the build command
|
|
344
|
-
const runBuild = async function ({ childProcesses, pluginsOptions, netlifyConfig, configOpts, packageJson, configPath, outputConfigPath, userNodeVersion, headersPath, redirectsPath, buildDir, repositoryRoot, nodePath, childEnv, context, branch, dry, buildbotServerSocket, constants, mode, api, errorMonitor, deployId, errorParams, logs, debug, systemLog, verbose, saveConfig, timers, testOpts, featureFlags, timeline, devCommand, quiet, explicitSecretKeys, }) {
|
|
350
|
+
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, }) {
|
|
345
351
|
const { pluginsSteps, timers: timersA } = await loadPlugins({
|
|
346
352
|
pluginsOptions,
|
|
347
353
|
childProcesses,
|
|
@@ -366,6 +372,7 @@ const runBuild = async function ({ childProcesses, pluginsOptions, netlifyConfig
|
|
|
366
372
|
redirectsPath,
|
|
367
373
|
buildDir,
|
|
368
374
|
repositoryRoot,
|
|
375
|
+
packagePath,
|
|
369
376
|
nodePath,
|
|
370
377
|
childEnv,
|
|
371
378
|
context,
|
package/lib/core/config.js
CHANGED
|
@@ -15,11 +15,12 @@ import { getUserNodeVersion } from './user_node_version.js';
|
|
|
15
15
|
// the build
|
|
16
16
|
// - If plugins change the configuration, `configMutations` is used instead
|
|
17
17
|
// In both cases, almost all options should remain the same.
|
|
18
|
-
export const getConfigOpts = function ({ config, defaultConfig, cwd, repositoryRoot, apiHost, token, siteId, context, branch, baseRelDir, envOpt, mode, offline, deployId, buildId, testOpts, featureFlags, }) {
|
|
18
|
+
export const getConfigOpts = function ({ config, defaultConfig, cwd, repositoryRoot, packagePath, apiHost, token, siteId, context, branch, baseRelDir, envOpt, mode, offline, deployId, buildId, testOpts, featureFlags, }) {
|
|
19
19
|
return {
|
|
20
20
|
config,
|
|
21
21
|
defaultConfig,
|
|
22
22
|
cwd,
|
|
23
|
+
packagePath,
|
|
23
24
|
repositoryRoot,
|
|
24
25
|
context,
|
|
25
26
|
branch,
|
package/lib/core/constants.js
CHANGED
|
@@ -4,12 +4,14 @@ import mapObj from 'map-obj';
|
|
|
4
4
|
import { pathExists } from 'path-exists';
|
|
5
5
|
import { ROOT_PACKAGE_JSON } from '../utils/json.js';
|
|
6
6
|
// Retrieve constants passed to plugins
|
|
7
|
-
export const getConstants = async function ({ configPath, buildDir, functionsDistDir, edgeFunctionsDistDir, cacheDir, netlifyConfig, siteInfo: { id: siteId }, apiHost, token, mode, }) {
|
|
7
|
+
export const getConstants = async function ({ configPath, buildDir, packagePath, functionsDistDir, edgeFunctionsDistDir, cacheDir, netlifyConfig, siteInfo: { id: siteId }, apiHost, token, mode, }) {
|
|
8
8
|
const isLocal = mode !== 'buildbot';
|
|
9
9
|
const normalizedCacheDir = getCacheDir({ cacheDir, cwd: buildDir });
|
|
10
10
|
const constants = {
|
|
11
11
|
// Path to the Netlify configuration file
|
|
12
12
|
CONFIG_PATH: configPath,
|
|
13
|
+
// In monorepos this is the path that is used to point to a package that should be deployed
|
|
14
|
+
PACKAGE_PATH: packagePath,
|
|
13
15
|
// The directory where built serverless functions are placed before deployment
|
|
14
16
|
FUNCTIONS_DIST: functionsDistDir,
|
|
15
17
|
// The directory where built Edge Functions are placed before deployment
|
package/lib/core/flags.js
CHANGED
|
@@ -43,6 +43,10 @@ Default: current directory`,
|
|
|
43
43
|
describe: `Git repository root directory. Used to retrieve the configuration file.
|
|
44
44
|
Default: automatically guessed`,
|
|
45
45
|
},
|
|
46
|
+
packagePath: {
|
|
47
|
+
string: true,
|
|
48
|
+
describe: `When using a monorepo, specifies the relative path from the repository root to the package being built`,
|
|
49
|
+
},
|
|
46
50
|
apiHost: {
|
|
47
51
|
string: true,
|
|
48
52
|
describe: `Netlify API endpoint.
|
package/lib/plugins/options.js
CHANGED
|
@@ -8,12 +8,13 @@ import { getPackageJson } from '../utils/package.js';
|
|
|
8
8
|
import { useManifest } from './manifest/main.js';
|
|
9
9
|
import { resolvePluginsPath } from './resolve.js';
|
|
10
10
|
// Load core plugins and user plugins
|
|
11
|
-
const tGetPluginsOptions = async function ({ pluginsOptions, netlifyConfig: { plugins }, siteInfo, buildDir, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, integrations, }) {
|
|
11
|
+
const tGetPluginsOptions = async function ({ pluginsOptions, netlifyConfig: { plugins }, siteInfo, buildDir, packagePath, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, integrations, }) {
|
|
12
12
|
const pluginsOptionsA = await resolvePluginsPath({
|
|
13
13
|
pluginsOptions,
|
|
14
14
|
siteInfo,
|
|
15
15
|
buildDir,
|
|
16
16
|
nodePath,
|
|
17
|
+
packagePath,
|
|
17
18
|
packageJson,
|
|
18
19
|
userNodeVersion,
|
|
19
20
|
mode,
|
package/lib/plugins/resolve.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
|
+
import { join } from 'path';
|
|
1
2
|
import { addErrorInfo } from '../error/info.js';
|
|
2
3
|
import { installMissingPlugins, installIntegrationPlugins } from '../install/missing.js';
|
|
3
4
|
import { resolvePath, tryResolvePath } from '../utils/resolve.js';
|
|
4
5
|
import { addExpectedVersions } from './expected_version.js';
|
|
5
6
|
import { addPluginsNodeVersion } from './node_version.js';
|
|
6
7
|
import { addPinnedVersions } from './pinned_version.js';
|
|
8
|
+
const AUTO_PLUGINS_DIR = '.netlify/plugins/';
|
|
7
9
|
// Try to find plugins in four places, by priority order:
|
|
8
10
|
// - already loaded (core plugins)
|
|
9
11
|
// - local plugin
|
|
10
12
|
// - external plugin already installed in `node_modules`, most likely through `package.json`
|
|
11
13
|
// - automatically installed by us, to `.netlify/plugins/`
|
|
12
|
-
export const resolvePluginsPath = async function ({ pluginsOptions, siteInfo, buildDir, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, integrations, }) {
|
|
13
|
-
const autoPluginsDir = getAutoPluginsDir(buildDir);
|
|
14
|
+
export const resolvePluginsPath = async function ({ pluginsOptions, siteInfo, buildDir, packagePath, nodePath, packageJson, userNodeVersion, mode, api, logs, debug, sendStatus, testOpts, featureFlags, integrations, }) {
|
|
15
|
+
const autoPluginsDir = getAutoPluginsDir(buildDir, packagePath);
|
|
14
16
|
const pluginsOptionsA = await Promise.all(pluginsOptions.map((pluginOptions) => resolvePluginPath({ pluginOptions, buildDir, autoPluginsDir })));
|
|
15
17
|
const pluginsOptionsB = addPluginsNodeVersion({
|
|
16
18
|
pluginsOptions: pluginsOptionsA,
|
|
@@ -41,13 +43,17 @@ export const resolvePluginsPath = async function ({ pluginsOptions, siteInfo, bu
|
|
|
41
43
|
}
|
|
42
44
|
return [...pluginsOptionsE, ...integrationPluginOptions];
|
|
43
45
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
46
|
+
/**
|
|
47
|
+
* Find the path to the directory used to install plugins automatically.
|
|
48
|
+
* It is a subdirectory of `buildDir`, so that the plugin can require the
|
|
49
|
+
* project's dependencies (peer dependencies).
|
|
50
|
+
* @param {string} buildDir
|
|
51
|
+
* @param {string} [packagePath]
|
|
52
|
+
* @returns
|
|
53
|
+
*/
|
|
54
|
+
const getAutoPluginsDir = function (buildDir, packagePath) {
|
|
55
|
+
return join(buildDir, packagePath || '', AUTO_PLUGINS_DIR);
|
|
49
56
|
};
|
|
50
|
-
const AUTO_PLUGINS_DIR = '.netlify/plugins/';
|
|
51
57
|
const resolvePluginPath = async function ({ pluginOptions, pluginOptions: { packageName, loadedFrom }, buildDir, autoPluginsDir, }) {
|
|
52
58
|
// Core plugins
|
|
53
59
|
if (loadedFrom !== undefined) {
|
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import { saveUpdatedConfig, restoreUpdatedConfig } from '../../core/config.js';
|
|
2
2
|
import { logDeploySuccess } from '../../log/messages/plugins.js';
|
|
3
3
|
import { createBuildbotClient, connectBuildbotClient, closeBuildbotClient, deploySiteWithBuildbotClient, } from './buildbot_client.js';
|
|
4
|
-
const coreStep = async function ({ buildDir, configPath, repositoryRoot, constants, buildbotServerSocket, events, logs, featureFlags, context, branch, configMutations, headersPath, redirectsPath, debug, saveConfig, }) {
|
|
4
|
+
const coreStep = async function ({ buildDir, configPath, repositoryRoot, packagePath, constants, buildbotServerSocket, events, logs, featureFlags, context, branch, configMutations, headersPath, redirectsPath, debug, saveConfig, }) {
|
|
5
5
|
const client = createBuildbotClient(buildbotServerSocket);
|
|
6
6
|
try {
|
|
7
7
|
await connectBuildbotClient(client);
|
|
8
8
|
await saveUpdatedConfig({
|
|
9
9
|
configMutations,
|
|
10
10
|
buildDir,
|
|
11
|
+
packagePath,
|
|
11
12
|
repositoryRoot,
|
|
12
13
|
configPath,
|
|
13
14
|
headersPath,
|
|
@@ -8,11 +8,11 @@ import { validateEdgeFunctionsManifest } from './validate_manifest/validate_edge
|
|
|
8
8
|
// TODO: Replace this with a custom cache directory.
|
|
9
9
|
const DENO_CLI_CACHE_DIRECTORY = '.netlify/plugins/deno-cli';
|
|
10
10
|
const IMPORT_MAP_FILENAME = 'edge-functions-import-map.json';
|
|
11
|
-
const coreStep = async function ({ buildDir, constants: { EDGE_FUNCTIONS_DIST: distDirectory, EDGE_FUNCTIONS_SRC: srcDirectory, INTERNAL_EDGE_FUNCTIONS_SRC: internalSrcDirectory, IS_LOCAL: isRunningLocally, }, debug, systemLog, featureFlags, logs, netlifyConfig, }) {
|
|
11
|
+
const coreStep = async function ({ buildDir, packagePath, constants: { EDGE_FUNCTIONS_DIST: distDirectory, EDGE_FUNCTIONS_SRC: srcDirectory, INTERNAL_EDGE_FUNCTIONS_SRC: internalSrcDirectory, IS_LOCAL: isRunningLocally, }, debug, systemLog, featureFlags, logs, netlifyConfig, }) {
|
|
12
12
|
const { edge_functions: declarations = [] } = netlifyConfig;
|
|
13
13
|
const { deno_import_map: userDefinedImportMap } = netlifyConfig.functions['*'];
|
|
14
|
-
const distPath = resolve(buildDir, distDirectory);
|
|
15
|
-
const internalSrcPath = resolve(buildDir, internalSrcDirectory);
|
|
14
|
+
const distPath = resolve(buildDir, packagePath || '', distDirectory);
|
|
15
|
+
const internalSrcPath = resolve(buildDir, packagePath || '', internalSrcDirectory);
|
|
16
16
|
const distImportMapPath = join(dirname(internalSrcPath), IMPORT_MAP_FILENAME);
|
|
17
17
|
const srcPath = srcDirectory ? resolve(buildDir, srcDirectory) : undefined;
|
|
18
18
|
const sourcePaths = [internalSrcPath, srcPath].filter(Boolean);
|
|
@@ -72,12 +72,12 @@ const getMetrics = (manifest) => {
|
|
|
72
72
|
// one configured by the user or the internal one) exists. We use a dynamic
|
|
73
73
|
// `condition` because the directories might be created by the build command
|
|
74
74
|
// or plugins.
|
|
75
|
-
const hasEdgeFunctionsDirectories = async function ({ buildDir, constants: { INTERNAL_EDGE_FUNCTIONS_SRC, EDGE_FUNCTIONS_SRC }, }) {
|
|
75
|
+
const hasEdgeFunctionsDirectories = async function ({ buildDir, packagePath, constants: { INTERNAL_EDGE_FUNCTIONS_SRC, EDGE_FUNCTIONS_SRC }, }) {
|
|
76
76
|
const hasFunctionsSrc = EDGE_FUNCTIONS_SRC !== undefined && EDGE_FUNCTIONS_SRC !== '';
|
|
77
77
|
if (hasFunctionsSrc) {
|
|
78
78
|
return true;
|
|
79
79
|
}
|
|
80
|
-
const internalFunctionsSrc = resolve(buildDir, INTERNAL_EDGE_FUNCTIONS_SRC);
|
|
80
|
+
const internalFunctionsSrc = resolve(buildDir, packagePath || '', INTERNAL_EDGE_FUNCTIONS_SRC);
|
|
81
81
|
return await pathExists(internalFunctionsSrc);
|
|
82
82
|
};
|
|
83
83
|
const logFunctions = async ({ internalSrcDirectory, internalSrcPath, logs, srcDirectory: userFunctionsSrc, srcPath, }) => {
|
|
@@ -39,10 +39,10 @@ const zipFunctionsAndLogResults = async ({ buildDir, childEnv, featureFlags, fun
|
|
|
39
39
|
}
|
|
40
40
|
};
|
|
41
41
|
// Plugin to package Netlify functions with @netlify/zip-it-and-ship-it
|
|
42
|
-
const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC: relativeInternalFunctionsSrc, IS_LOCAL: isRunningLocally, FUNCTIONS_SRC: relativeFunctionsSrc, FUNCTIONS_DIST: relativeFunctionsDist, }, buildDir, logs, netlifyConfig, featureFlags, repositoryRoot, userNodeVersion, systemLog, }) {
|
|
42
|
+
const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC: relativeInternalFunctionsSrc, IS_LOCAL: isRunningLocally, FUNCTIONS_SRC: relativeFunctionsSrc, FUNCTIONS_DIST: relativeFunctionsDist, }, buildDir, packagePath, logs, netlifyConfig, featureFlags, repositoryRoot, userNodeVersion, systemLog, }) {
|
|
43
43
|
const functionsSrc = relativeFunctionsSrc === undefined ? undefined : resolve(buildDir, relativeFunctionsSrc);
|
|
44
|
-
const functionsDist = resolve(buildDir, relativeFunctionsDist);
|
|
45
|
-
const internalFunctionsSrc = resolve(buildDir, relativeInternalFunctionsSrc);
|
|
44
|
+
const functionsDist = resolve(buildDir, packagePath || '', relativeFunctionsDist);
|
|
45
|
+
const internalFunctionsSrc = resolve(buildDir, packagePath || '', relativeInternalFunctionsSrc);
|
|
46
46
|
const internalFunctionsSrcExists = await pathExists(internalFunctionsSrc);
|
|
47
47
|
const functionsSrcExists = await validateFunctionsSrc({ functionsSrc, relativeFunctionsSrc });
|
|
48
48
|
const [userFunctions = [], internalFunctions = []] = await getUserAndInternalFunctions({
|
|
@@ -95,12 +95,12 @@ const coreStep = async function ({ childEnv, constants: { INTERNAL_FUNCTIONS_SRC
|
|
|
95
95
|
// one configured by the user or the internal one) exists. We use a dynamic
|
|
96
96
|
// `condition` because the directories might be created by the build command
|
|
97
97
|
// or plugins.
|
|
98
|
-
const hasFunctionsDirectories = async function ({ buildDir, constants: { INTERNAL_FUNCTIONS_SRC, FUNCTIONS_SRC } }) {
|
|
98
|
+
const hasFunctionsDirectories = async function ({ buildDir, packagePath, constants: { INTERNAL_FUNCTIONS_SRC, FUNCTIONS_SRC }, }) {
|
|
99
99
|
const hasFunctionsSrc = FUNCTIONS_SRC !== undefined && FUNCTIONS_SRC !== '';
|
|
100
100
|
if (hasFunctionsSrc) {
|
|
101
101
|
return true;
|
|
102
102
|
}
|
|
103
|
-
const internalFunctionsSrc = resolve(buildDir, INTERNAL_FUNCTIONS_SRC);
|
|
103
|
+
const internalFunctionsSrc = resolve(buildDir, packagePath || '', INTERNAL_FUNCTIONS_SRC);
|
|
104
104
|
return await pathExists(internalFunctionsSrc);
|
|
105
105
|
};
|
|
106
106
|
export const bundleFunctions = {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { saveUpdatedConfig } from '../../core/config.js';
|
|
2
2
|
import { shouldDeploy } from '../deploy/index.js';
|
|
3
|
-
const coreStep = async function ({ buildDir, configPath, outputConfigPath, repositoryRoot, logs, featureFlags, context, branch, configMutations, headersPath, redirectsPath, debug, saveConfig, }) {
|
|
3
|
+
const coreStep = async function ({ buildDir, configPath, packagePath, outputConfigPath, repositoryRoot, logs, featureFlags, context, branch, configMutations, headersPath, redirectsPath, debug, saveConfig, }) {
|
|
4
4
|
await saveUpdatedConfig({
|
|
5
5
|
configMutations,
|
|
6
6
|
buildDir,
|
|
7
7
|
repositoryRoot,
|
|
8
8
|
configPath,
|
|
9
|
+
packagePath,
|
|
9
10
|
outputConfigPath,
|
|
10
11
|
headersPath,
|
|
11
12
|
redirectsPath,
|
package/lib/steps/core_step.js
CHANGED
|
@@ -2,7 +2,7 @@ import { setEnvChanges } from '../env/changes.js';
|
|
|
2
2
|
import { addErrorInfo, isBuildError } from '../error/info.js';
|
|
3
3
|
import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js';
|
|
4
4
|
// Fire a core step
|
|
5
|
-
export const fireCoreStep = async function ({ coreStep, coreStepId, coreStepName, configPath, outputConfigPath, buildDir, repositoryRoot, constants, buildbotServerSocket, events, logs, nodePath, childEnv, context, branch, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, featureFlags, debug, systemLog, saveConfig, userNodeVersion, explicitSecretKeys, }) {
|
|
5
|
+
export const fireCoreStep = async function ({ coreStep, coreStepId, coreStepName, configPath, outputConfigPath, buildDir, repositoryRoot, packagePath, constants, buildbotServerSocket, events, logs, nodePath, childEnv, context, branch, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, featureFlags, debug, systemLog, saveConfig, userNodeVersion, explicitSecretKeys, }) {
|
|
6
6
|
try {
|
|
7
7
|
const configSideFiles = await listConfigSideFiles([headersPath, redirectsPath]);
|
|
8
8
|
const childEnvA = setEnvChanges(envChanges, { ...childEnv });
|
|
@@ -12,6 +12,7 @@ export const fireCoreStep = async function ({ coreStep, coreStepId, coreStepName
|
|
|
12
12
|
buildDir,
|
|
13
13
|
repositoryRoot,
|
|
14
14
|
constants,
|
|
15
|
+
packagePath,
|
|
15
16
|
buildbotServerSocket,
|
|
16
17
|
events,
|
|
17
18
|
logs,
|
package/lib/steps/plugin.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getSuccessStatus } from '../status/success.js';
|
|
|
6
6
|
import { getPluginErrorType } from './error.js';
|
|
7
7
|
import { updateNetlifyConfig, listConfigSideFiles } from './update_config.js';
|
|
8
8
|
// Fire a plugin step
|
|
9
|
-
export const firePluginStep = async function ({ event, childProcess, packageName, pluginPackageJson, loadedFrom, origin, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, constants, steps, error, logs, featureFlags, debug, verbose, }) {
|
|
9
|
+
export const firePluginStep = async function ({ event, childProcess, packageName, packagePath, pluginPackageJson, loadedFrom, origin, envChanges, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, constants, steps, error, logs, featureFlags, debug, verbose, }) {
|
|
10
10
|
const listeners = pipePluginOutput(childProcess, logs);
|
|
11
11
|
const isTrustedPlugin = pluginPackageJson?.name?.startsWith('@netlify/');
|
|
12
12
|
try {
|
|
@@ -29,6 +29,7 @@ export const firePluginStep = async function ({ event, childProcess, packageName
|
|
|
29
29
|
configOpts,
|
|
30
30
|
netlifyConfig,
|
|
31
31
|
headersPath,
|
|
32
|
+
packagePath,
|
|
32
33
|
redirectsPath,
|
|
33
34
|
configMutations,
|
|
34
35
|
newConfigMutations,
|
|
@@ -39,13 +39,14 @@ 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, defaultConfig, cachedConfig, debug, nodePath, functionsDistDir, edgeFunctionsDistDir, errorMonitor, mode, logs, errorParams, featureFlags, buildSteps, repositoryRoot, systemLog, }) {
|
|
42
|
+
const executeBuildStep = async function ({ config, packagePath, defaultConfig, cachedConfig, debug, nodePath, functionsDistDir, edgeFunctionsDistDir, errorMonitor, mode, logs, errorParams, featureFlags, buildSteps, repositoryRoot, systemLog, }) {
|
|
43
43
|
const configOpts = getConfigOpts({
|
|
44
44
|
config,
|
|
45
45
|
defaultConfig,
|
|
46
46
|
featureFlags,
|
|
47
47
|
mode,
|
|
48
48
|
repositoryRoot,
|
|
49
|
+
packagePath,
|
|
49
50
|
});
|
|
50
51
|
const { netlifyConfig, buildDir, siteInfo, childEnv, userNodeVersion, repositoryRoot: repositoryRootA, } = await loadConfig({
|
|
51
52
|
configOpts,
|
|
@@ -58,6 +59,7 @@ const executeBuildStep = async function ({ config, defaultConfig, cachedConfig,
|
|
|
58
59
|
const constants = await getConstants({
|
|
59
60
|
buildDir,
|
|
60
61
|
functionsDistDir,
|
|
62
|
+
packagePath,
|
|
61
63
|
edgeFunctionsDistDir,
|
|
62
64
|
netlifyConfig,
|
|
63
65
|
siteInfo,
|
package/lib/steps/run_step.js
CHANGED
|
@@ -10,11 +10,13 @@ import { firePluginStep } from './plugin.js';
|
|
|
10
10
|
import { getStepReturn } from './return.js';
|
|
11
11
|
const tracer = trace.getTracer('steps');
|
|
12
12
|
// Run a step (core, build command or plugin)
|
|
13
|
-
export const runStep = async function ({ event, childProcess, packageName, coreStep, coreStepId, coreStepName, coreStepDescription, pluginPackageJson, loadedFrom, origin, condition, configPath, outputConfigPath, buildDir, repositoryRoot, nodePath, index, childEnv, context, branch, envChanges, constants, steps, buildbotServerSocket, events, mode, api, errorMonitor, deployId, errorParams, error, failedPlugins, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, logs, debug, systemLog, verbose, saveConfig, timers, testOpts, featureFlags, quiet, userNodeVersion, explicitSecretKeys, }) {
|
|
13
|
+
export const runStep = async function ({ event, childProcess, packageName, coreStep, coreStepId, coreStepName, coreStepDescription, pluginPackageJson, loadedFrom, origin, condition, configPath, outputConfigPath, buildDir, packagePath, repositoryRoot, nodePath, index, childEnv, context, branch, envChanges, constants, steps, buildbotServerSocket, events, mode, api, errorMonitor, deployId, errorParams, error, failedPlugins, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, logs, debug, systemLog, verbose, saveConfig, timers, testOpts, featureFlags, quiet, userNodeVersion, explicitSecretKeys, }) {
|
|
14
14
|
// Add relevant attributes to the upcoming span context
|
|
15
15
|
const attributes = {
|
|
16
16
|
'build.execution.step.name': coreStepName,
|
|
17
17
|
'build.execution.step.package_name': packageName,
|
|
18
|
+
'build.execution.step.package_path': packagePath,
|
|
19
|
+
'build.execution.step.build_dir': buildDir,
|
|
18
20
|
'build.execution.step.id': coreStepId,
|
|
19
21
|
'build.execution.step.loaded_from': loadedFrom,
|
|
20
22
|
'build.execution.step.origin': origin,
|
|
@@ -32,6 +34,7 @@ export const runStep = async function ({ event, childProcess, packageName, coreS
|
|
|
32
34
|
failedPlugins,
|
|
33
35
|
netlifyConfig,
|
|
34
36
|
condition,
|
|
37
|
+
packagePath,
|
|
35
38
|
constants: constantsA,
|
|
36
39
|
buildbotServerSocket,
|
|
37
40
|
buildDir,
|
|
@@ -57,6 +60,7 @@ export const runStep = async function ({ event, childProcess, packageName, coreS
|
|
|
57
60
|
coreStep,
|
|
58
61
|
coreStepId,
|
|
59
62
|
coreStepName,
|
|
63
|
+
packagePath,
|
|
60
64
|
configPath,
|
|
61
65
|
outputConfigPath,
|
|
62
66
|
buildDir,
|
|
@@ -148,10 +152,18 @@ export const runStep = async function ({ event, childProcess, packageName, coreS
|
|
|
148
152
|
// or available. However, one might be created by a build plugin, in which case,
|
|
149
153
|
// those core plugins should be triggered. We use a dynamic `condition()` to
|
|
150
154
|
// model this behavior.
|
|
151
|
-
const shouldRunStep = async function ({ event, packageName, error, failedPlugins, netlifyConfig, condition, constants, buildbotServerSocket, buildDir, saveConfig, explicitSecretKeys, }) {
|
|
155
|
+
const shouldRunStep = async function ({ event, packageName, error, packagePath, failedPlugins, netlifyConfig, condition, constants, buildbotServerSocket, buildDir, saveConfig, explicitSecretKeys, }) {
|
|
152
156
|
if (failedPlugins.includes(packageName) ||
|
|
153
157
|
(condition !== undefined &&
|
|
154
|
-
!(await condition({
|
|
158
|
+
!(await condition({
|
|
159
|
+
packagePath,
|
|
160
|
+
buildDir,
|
|
161
|
+
constants,
|
|
162
|
+
buildbotServerSocket,
|
|
163
|
+
netlifyConfig,
|
|
164
|
+
saveConfig,
|
|
165
|
+
explicitSecretKeys,
|
|
166
|
+
})))) {
|
|
155
167
|
return false;
|
|
156
168
|
}
|
|
157
169
|
if (error !== undefined) {
|
|
@@ -167,7 +179,7 @@ const getFireStep = function (packageName, coreStepId, event) {
|
|
|
167
179
|
const parentTag = normalizeTagName(packageName);
|
|
168
180
|
return measureDuration(tFireStep, event, { parentTag, category: 'pluginEvent' });
|
|
169
181
|
};
|
|
170
|
-
const tFireStep = function ({ event, childProcess, packageName, pluginPackageJson, loadedFrom, origin, coreStep, coreStepId, coreStepName, configPath, outputConfigPath, buildDir, repositoryRoot, nodePath, childEnv, context, branch, envChanges, constants, steps, buildbotServerSocket, events, error, logs, debug, systemLog, verbose, saveConfig, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, featureFlags, userNodeVersion, explicitSecretKeys, }) {
|
|
182
|
+
const tFireStep = function ({ event, childProcess, packageName, pluginPackageJson, loadedFrom, origin, coreStep, coreStepId, coreStepName, configPath, outputConfigPath, buildDir, repositoryRoot, packagePath, nodePath, childEnv, context, branch, envChanges, constants, steps, buildbotServerSocket, events, error, logs, debug, systemLog, verbose, saveConfig, errorParams, configOpts, netlifyConfig, configMutations, headersPath, redirectsPath, featureFlags, userNodeVersion, explicitSecretKeys, }) {
|
|
171
183
|
if (coreStep !== undefined) {
|
|
172
184
|
return fireCoreStep({
|
|
173
185
|
coreStep,
|
|
@@ -177,6 +189,7 @@ const tFireStep = function ({ event, childProcess, packageName, pluginPackageJso
|
|
|
177
189
|
outputConfigPath,
|
|
178
190
|
buildDir,
|
|
179
191
|
repositoryRoot,
|
|
192
|
+
packagePath,
|
|
180
193
|
constants,
|
|
181
194
|
buildbotServerSocket,
|
|
182
195
|
events,
|
|
@@ -204,6 +217,7 @@ const tFireStep = function ({ event, childProcess, packageName, pluginPackageJso
|
|
|
204
217
|
event,
|
|
205
218
|
childProcess,
|
|
206
219
|
packageName,
|
|
220
|
+
packagePath,
|
|
207
221
|
pluginPackageJson,
|
|
208
222
|
loadedFrom,
|
|
209
223
|
origin,
|
package/lib/steps/run_steps.js
CHANGED
|
@@ -7,7 +7,7 @@ import { runStep } from './run_step.js';
|
|
|
7
7
|
// list of `failedPlugins` (that ran `utils.build.failPlugin()`).
|
|
8
8
|
// If an error arises, runs `onError` events.
|
|
9
9
|
// Runs `onEnd` events at the end, whether an error was thrown or not.
|
|
10
|
-
export const runSteps = async function ({ steps, buildbotServerSocket, events, configPath, outputConfigPath, headersPath, redirectsPath, buildDir, repositoryRoot, nodePath, childEnv, context, branch, constants, mode, api, errorMonitor, deployId, errorParams, netlifyConfig, configOpts, logs, debug, systemLog, verbose, saveConfig, timers, testOpts, featureFlags, quiet, userNodeVersion, explicitSecretKeys, }) {
|
|
10
|
+
export const runSteps = async function ({ steps, buildbotServerSocket, events, configPath, outputConfigPath, headersPath, redirectsPath, buildDir, packagePath, repositoryRoot, nodePath, childEnv, context, branch, constants, mode, api, errorMonitor, deployId, errorParams, netlifyConfig, configOpts, logs, debug, systemLog, verbose, saveConfig, timers, testOpts, featureFlags, quiet, userNodeVersion, explicitSecretKeys, }) {
|
|
11
11
|
const { index: stepsCount, error: errorA, netlifyConfig: netlifyConfigC, statuses: statusesB, failedPlugins: failedPluginsA, timers: timersC, configMutations: configMutationsB, metrics: metricsC, } = await pReduce(steps, async ({ index, error, failedPlugins, envChanges, netlifyConfig: netlifyConfigA, configMutations, headersPath: headersPathA, redirectsPath: redirectsPathA, statuses, timers: timersA, metrics: metricsA, }, { event, childProcess, packageName, coreStep, coreStepId, coreStepName, coreStepDescription, pluginPackageJson, loadedFrom, origin, condition, }) => {
|
|
12
12
|
const { newIndex = index, newError = error, failedPlugin = [], newEnvChanges = {}, netlifyConfig: netlifyConfigB = netlifyConfigA, configMutations: configMutationsA = configMutations, headersPath: headersPathB = headersPathA, redirectsPath: redirectsPathB = redirectsPathA, newStatus, timers: timersB = timersA, metrics: metricsB = [], } = await runStep({
|
|
13
13
|
event,
|
|
@@ -24,6 +24,7 @@ export const runSteps = async function ({ steps, buildbotServerSocket, events, c
|
|
|
24
24
|
configPath,
|
|
25
25
|
outputConfigPath,
|
|
26
26
|
buildDir,
|
|
27
|
+
packagePath,
|
|
27
28
|
repositoryRoot,
|
|
28
29
|
nodePath,
|
|
29
30
|
index,
|
package/lib/time/main.js
CHANGED
|
@@ -23,6 +23,12 @@ const kMeasureDuration = function (func, stageTag, { parentTag = undefined, cate
|
|
|
23
23
|
return { ...returnObject, timers: timersB, durationNs };
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
|
+
// TODO: type properly like this and fix all the upstream type issues
|
|
27
|
+
// export const measureDuration: <T extends (...args: any) => any>(
|
|
28
|
+
// fn: T,
|
|
29
|
+
// tag: string,
|
|
30
|
+
// options?: { parentTag?: any; category?: any },
|
|
31
|
+
// ) => T = keepFuncProps(kMeasureDuration)
|
|
26
32
|
// Ensure the wrapped function `name` is not `anonymous` in stack traces
|
|
27
33
|
export const measureDuration = keepFuncProps(kMeasureDuration);
|
|
28
34
|
// Create a new object representing a completed timer
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/build",
|
|
3
|
-
"version": "29.
|
|
3
|
+
"version": "29.19.0-rc.0",
|
|
4
4
|
"description": "Netlify build module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/core/main.js",
|
|
@@ -65,14 +65,14 @@
|
|
|
65
65
|
"@bugsnag/js": "^7.0.0",
|
|
66
66
|
"@honeycombio/opentelemetry-node": "^0.4.0",
|
|
67
67
|
"@netlify/cache-utils": "^5.1.5",
|
|
68
|
-
"@netlify/config": "^20.
|
|
68
|
+
"@netlify/config": "^20.8.0",
|
|
69
69
|
"@netlify/edge-bundler": "8.17.1",
|
|
70
70
|
"@netlify/framework-info": "^9.8.10",
|
|
71
71
|
"@netlify/functions-utils": "^5.2.20",
|
|
72
72
|
"@netlify/git-utils": "^5.1.1",
|
|
73
|
-
"@netlify/plugins-list": "^6.
|
|
73
|
+
"@netlify/plugins-list": "^6.71.0",
|
|
74
74
|
"@netlify/run-utils": "^5.1.1",
|
|
75
|
-
"@netlify/zip-it-and-ship-it": "9.
|
|
75
|
+
"@netlify/zip-it-and-ship-it": "9.15.0",
|
|
76
76
|
"@opentelemetry/api": "^1.4.1",
|
|
77
77
|
"@sindresorhus/slugify": "^2.0.0",
|
|
78
78
|
"ansi-escapes": "^6.0.0",
|
|
@@ -147,6 +147,5 @@
|
|
|
147
147
|
"compilerOptions": {
|
|
148
148
|
"module": "commonjs"
|
|
149
149
|
}
|
|
150
|
-
}
|
|
151
|
-
"gitHead": "f79e1dae2fb91563cfb4ca527d6c832f2c36de8a"
|
|
150
|
+
}
|
|
152
151
|
}
|