@netlify/build 29.46.4 → 29.47.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.
@@ -32,7 +32,7 @@ export declare const startBuild: (flags: Partial<BuildFlags>) => {
32
32
  };
33
33
  };
34
34
  export declare const execBuild: any;
35
- 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, systemLogFile, verbose, timers, sendStatus, saveConfig, testOpts, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }: {
35
+ 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, token, errorMonitor, deployId, errorParams, logs, debug, systemLog, systemLogFile, verbose, timers, sendStatus, saveConfig, testOpts, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }: {
36
36
  pluginsOptions: any;
37
37
  netlifyConfig: any;
38
38
  configOpts: any;
@@ -55,6 +55,7 @@ export declare const runAndReportBuild: ({ pluginsOptions, netlifyConfig, config
55
55
  dry: any;
56
56
  mode: any;
57
57
  api: any;
58
+ token: any;
58
59
  errorMonitor: any;
59
60
  deployId: any;
60
61
  errorParams: any;
package/lib/core/build.js CHANGED
@@ -13,6 +13,7 @@ import { reportStatuses } from '../status/report.js';
13
13
  import { getDevSteps, getSteps } from '../steps/get.js';
14
14
  import { runSteps } from '../steps/run_steps.js';
15
15
  import { initTimers, measureDuration } from '../time/main.js';
16
+ import { getBlobsEnvironmentContext } from '../utils/blobs.js';
16
17
  import { getConfigOpts, loadConfig } from './config.js';
17
18
  import { getConstants } from './constants.js';
18
19
  import { doDryRun } from './dry.js';
@@ -114,6 +115,7 @@ const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cached
114
115
  dry,
115
116
  mode,
116
117
  api,
118
+ token,
117
119
  errorMonitor,
118
120
  deployId,
119
121
  errorParams,
@@ -150,7 +152,7 @@ const tExecBuild = async function ({ config, defaultConfig, cachedConfig, cached
150
152
  };
151
153
  export const execBuild = measureDuration(tExecBuild, 'total', { parentTag: 'build_site' });
152
154
  // Runs a build then report any plugin statuses
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, systemLogFile, verbose, timers, sendStatus, saveConfig, testOpts, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }) {
155
+ 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, token, errorMonitor, deployId, errorParams, logs, debug, systemLog, systemLogFile, verbose, timers, sendStatus, saveConfig, testOpts, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }) {
154
156
  try {
155
157
  const { stepsCount, netlifyConfig: netlifyConfigA, statuses, pluginsOptions: pluginsOptionsA, failedPlugins, timers: timersA, configMutations, metrics, } = await initAndRunBuild({
156
158
  pluginsOptions,
@@ -173,6 +175,7 @@ export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig
173
175
  dry,
174
176
  mode,
175
177
  api,
178
+ token,
176
179
  errorMonitor,
177
180
  deployId,
178
181
  errorParams,
@@ -255,7 +258,7 @@ export const runAndReportBuild = async function ({ pluginsOptions, netlifyConfig
255
258
  }
256
259
  };
257
260
  // Initialize plugin processes then runs a build
258
- 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, systemLogFile, verbose, sendStatus, saveConfig, timers, testOpts, buildbotServerSocket, constants, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }) {
261
+ const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configOpts, siteInfo, configPath, outputConfigPath, headersPath, redirectsPath, buildDir, packagePath, repositoryRoot, nodePath, packageJson, userNodeVersion, childEnv, context, branch, dry, mode, api, token, errorMonitor, deployId, errorParams, logs, debug, systemLog, systemLogFile, verbose, sendStatus, saveConfig, timers, testOpts, buildbotServerSocket, constants, featureFlags, timeline, devCommand, quiet, integrations, explicitSecretKeys, edgeFunctionsBootstrapURL, eventHandlers, }) {
259
262
  const { pluginsOptions: pluginsOptionsA, timers: timersA } = await getPluginsOptions({
260
263
  pluginsOptions,
261
264
  netlifyConfig,
@@ -277,6 +280,9 @@ const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configO
277
280
  context,
278
281
  systemLog,
279
282
  });
283
+ const pluginsEnv = featureFlags.build_inject_blobs_context
284
+ ? { ...childEnv, ...getBlobsEnvironmentContext({ api, deployId: deployId, siteId: siteInfo?.id, token }) }
285
+ : childEnv;
280
286
  if (pluginsOptionsA?.length) {
281
287
  const buildPlugins = {};
282
288
  for (const plugin of pluginsOptionsA) {
@@ -290,7 +296,7 @@ const initAndRunBuild = async function ({ pluginsOptions, netlifyConfig, configO
290
296
  const { childProcesses, timers: timersB } = await startPlugins({
291
297
  pluginsOptions: pluginsOptionsA,
292
298
  buildDir,
293
- childEnv,
299
+ childEnv: pluginsEnv,
294
300
  logs,
295
301
  debug,
296
302
  timers: timersA,
@@ -10,6 +10,7 @@ const getFeatureFlag = function (name) {
10
10
  };
11
11
  // Default values for feature flags
12
12
  export const DEFAULT_FEATURE_FLAGS = {
13
+ build_inject_blobs_context: false,
13
14
  buildbot_zisi_trace_nft: false,
14
15
  buildbot_zisi_esbuild_parser: false,
15
16
  buildbot_zisi_system_log: false,
@@ -1,4 +1,5 @@
1
1
  import type { BuildFlags, Mode, TestOptions } from './types.js';
2
+ export declare const DEFAULT_API_HOST = "api.netlify.com";
2
3
  export type ResolvedFlags = {
3
4
  env: Record<string, unknown>;
4
5
  token: string;
@@ -2,6 +2,7 @@ import { env, execPath } from 'process';
2
2
  import { logFlags } from '../log/messages/config.js';
3
3
  import { removeFalsy } from '../utils/remove_falsy.js';
4
4
  import { DEFAULT_FEATURE_FLAGS } from './feature_flags.js';
5
+ export const DEFAULT_API_HOST = 'api.netlify.com';
5
6
  const REQUIRE_MODE = 'require';
6
7
  const DEFAULT_EDGE_FUNCTIONS_DIST = '.netlify/edge-functions-dist/';
7
8
  const DEFAULT_FUNCTIONS_DIST = '.netlify/functions/';
@@ -49,7 +50,7 @@ const getDefaultFlags = function ({ env: envOpt = {} }, combinedEnv) {
49
50
  bugsnagKey: combinedEnv.BUGSNAG_KEY,
50
51
  sendStatus: false,
51
52
  saveConfig: false,
52
- apiHost: 'api.netlify.com',
53
+ apiHost: DEFAULT_API_HOST,
53
54
  testOpts: {},
54
55
  featureFlags: DEFAULT_FEATURE_FLAGS,
55
56
  statsd: { port: DEFAULT_STATSD_PORT },
@@ -2,6 +2,7 @@ import { version as nodeVersion } from 'node:process';
2
2
  import { getDeployStore } from '@netlify/blobs';
3
3
  import pMap from 'p-map';
4
4
  import semver from 'semver';
5
+ import { DEFAULT_API_HOST } from '../../core/normalize_flags.js';
5
6
  import { log, logError } from '../../log/logger.js';
6
7
  import { getFileWithMetadata, getKeysToUpload, scanForBlobs } from '../../utils/blobs.js';
7
8
  const coreStep = async function ({ debug, logs, deployId, buildDir, quiet, packagePath, constants: { SITE_ID, NETLIFY_API_TOKEN, NETLIFY_API_HOST }, }) {
@@ -10,7 +11,7 @@ const coreStep = async function ({ debug, logs, deployId, buildDir, quiet, packa
10
11
  return {};
11
12
  }
12
13
  // for cli deploys with `netlify deploy --build` the `NETLIFY_API_HOST` is undefined
13
- const apiHost = NETLIFY_API_HOST || 'api.netlify.com';
14
+ const apiHost = NETLIFY_API_HOST || DEFAULT_API_HOST;
14
15
  const storeOpts = {
15
16
  siteID: SITE_ID,
16
17
  deployID: deployId,
@@ -1,6 +1,20 @@
1
1
  /// <reference types="node" resolution-mode="require"/>
2
2
  /** Retrieve the absolute path of the deploy scoped internal blob directories */
3
3
  export declare const getBlobsDirs: (buildDir: string, packagePath?: string) => string[];
4
+ interface EnvironmentContext {
5
+ api?: {
6
+ host: string;
7
+ scheme: string;
8
+ };
9
+ deployId?: string;
10
+ siteId?: string;
11
+ token?: string;
12
+ }
13
+ export declare const getBlobsEnvironmentContext: ({ api, deployId, siteId, token, }: EnvironmentContext) => {
14
+ NETLIFY_BLOBS_CONTEXT?: undefined;
15
+ } | {
16
+ NETLIFY_BLOBS_CONTEXT: string;
17
+ };
4
18
  /**
5
19
  * Detect if there are any blobs to upload, and if so, what directory they're
6
20
  * in and whether that directory is the legacy `.netlify/blobs` path or the
@@ -21,3 +35,4 @@ export declare const getFileWithMetadata: (blobsDir: string, key: string) => Pro
21
35
  data: Buffer;
22
36
  metadata: Record<string, string>;
23
37
  }>;
38
+ export {};
@@ -1,6 +1,7 @@
1
1
  import { readFile } from 'node:fs/promises';
2
2
  import path from 'node:path';
3
3
  import { fdir } from 'fdir';
4
+ import { DEFAULT_API_HOST } from '../core/normalize_flags.js';
4
5
  const LEGACY_BLOBS_PATH = '.netlify/blobs/deploy';
5
6
  const DEPLOY_CONFIG_BLOBS_PATH = '.netlify/deploy/v1/blobs/deploy';
6
7
  /** Retrieve the absolute path of the deploy scoped internal blob directories */
@@ -8,6 +9,22 @@ export const getBlobsDirs = (buildDir, packagePath) => [
8
9
  path.resolve(buildDir, packagePath || '', DEPLOY_CONFIG_BLOBS_PATH),
9
10
  path.resolve(buildDir, packagePath || '', LEGACY_BLOBS_PATH),
10
11
  ];
12
+ // TODO: Move this work to a method exported by `@netlify/blobs`.
13
+ export const getBlobsEnvironmentContext = ({ api = { host: DEFAULT_API_HOST, scheme: 'https' }, deployId, siteId, token, }) => {
14
+ if (!deployId || !siteId || !token) {
15
+ return {};
16
+ }
17
+ const payload = {
18
+ apiURL: `${api.scheme}://${api.host}`,
19
+ deployID: deployId,
20
+ siteID: siteId,
21
+ token,
22
+ };
23
+ const encodedPayload = Buffer.from(JSON.stringify(payload)).toString('base64');
24
+ return {
25
+ NETLIFY_BLOBS_CONTEXT: encodedPayload,
26
+ };
27
+ };
11
28
  /**
12
29
  * Detect if there are any blobs to upload, and if so, what directory they're
13
30
  * in and whether that directory is the legacy `.netlify/blobs` path or the
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "29.46.4",
3
+ "version": "29.47.0",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -70,15 +70,15 @@
70
70
  "@bugsnag/js": "^7.0.0",
71
71
  "@netlify/blobs": "^7.3.0",
72
72
  "@netlify/cache-utils": "^5.1.5",
73
- "@netlify/config": "^20.14.1",
73
+ "@netlify/config": "^20.15.0",
74
74
  "@netlify/edge-bundler": "12.0.1",
75
75
  "@netlify/framework-info": "^9.8.13",
76
- "@netlify/functions-utils": "^5.2.61",
76
+ "@netlify/functions-utils": "^5.2.62",
77
77
  "@netlify/git-utils": "^5.1.1",
78
78
  "@netlify/opentelemetry-utils": "^1.2.1",
79
79
  "@netlify/plugins-list": "^6.80.0",
80
80
  "@netlify/run-utils": "^5.1.1",
81
- "@netlify/zip-it-and-ship-it": "9.34.1",
81
+ "@netlify/zip-it-and-ship-it": "9.34.2",
82
82
  "@sindresorhus/slugify": "^2.0.0",
83
83
  "ansi-escapes": "^6.0.0",
84
84
  "chalk": "^5.0.0",
@@ -165,5 +165,5 @@
165
165
  "engines": {
166
166
  "node": "^14.16.0 || >=16.0.0"
167
167
  },
168
- "gitHead": "c99f5dcf3198d3a279ee06d7e42c204405cd977a"
168
+ "gitHead": "d4a4f3c4e6171dc9a70e79b10e7f7be55f9e8d76"
169
169
  }