@netlify/build 29.34.0 → 29.35.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.
@@ -1,3 +1,4 @@
1
+ import type { BufferedLogs } from '../log/logger.js';
1
2
  import { BuildFlags } from './types.js';
2
3
  /**
3
4
  * Main entry point of Netlify Build.
@@ -8,7 +9,7 @@ import { BuildFlags } from './types.js';
8
9
  export declare function buildSite(flags?: Partial<BuildFlags>): Promise<{
9
10
  success: boolean;
10
11
  severityCode: number;
11
- logs: any;
12
+ logs: BufferedLogs | undefined;
12
13
  netlifyConfig?: any;
13
14
  configMutations?: any;
14
15
  }>;
@@ -1,26 +1,12 @@
1
1
  import { promises as fs } from 'fs';
2
2
  import { resolve } from 'path';
3
3
  import { mergeConfigs } from '@netlify/config';
4
+ import { getConfigMutations } from '../../plugins/child/diff.js';
4
5
  import { filterConfig } from './util.js';
5
6
  // The properties that can be set using this API. Each element represents a
6
7
  // path using dot-notation — e.g. `["build", "functions"]` represents the
7
8
  // `build.functions` property.
8
- const ALLOWED_PROPERTIES = [
9
- ['build', 'edge_functions'],
10
- ['build', 'functions'],
11
- ['build', 'publish'],
12
- ['functions', '*'],
13
- ['functions', '*', '*'],
14
- ['headers'],
15
- ['images', 'remote_images'],
16
- ['redirects'],
17
- ];
18
- // For array properties, any values set in this API will be merged with the
19
- // main configuration file in such a way that user-defined values always take
20
- // precedence. The exception are these properties that let frameworks set
21
- // values that should be evaluated before any user-defined values. They use
22
- // a special notation where `headers!` represents "forced headers", etc.
23
- const OVERRIDE_PROPERTIES = new Set(['headers!', 'redirects!']);
9
+ const ALLOWED_PROPERTIES = [['images', 'remote_images']];
24
10
  const coreStep = async function ({ buildDir, netlifyConfig, systemLog = () => {
25
11
  // no-op
26
12
  }, }) {
@@ -38,26 +24,16 @@ const coreStep = async function ({ buildDir, netlifyConfig, systemLog = () => {
38
24
  systemLog(`Failed to read Deploy Configuration API: ${err.message}`);
39
25
  throw new Error('An error occured while processing the platform configurarion defined by your framework');
40
26
  }
41
- const configOverrides = {};
42
- for (const key in config) {
43
- // If the key uses the special notation for defining mutations that should
44
- // take precedence over user-defined properties, extract the canonical
45
- // property, set it on a different object, and delete it from the main one.
46
- if (OVERRIDE_PROPERTIES.has(key)) {
47
- const canonicalKey = key.slice(0, -1);
48
- configOverrides[canonicalKey] = config[key];
49
- delete config[key];
50
- }
51
- }
52
27
  // Filtering out any properties that can't be mutated using this API.
53
- config = filterConfig(config, [], ALLOWED_PROPERTIES, systemLog);
54
- // Merging the different configuration sources. The order here is important.
55
- // Leftmost elements of the array take precedence.
56
- const newConfig = mergeConfigs([config, netlifyConfig, configOverrides], { concatenateArrays: true });
57
- for (const key in newConfig) {
58
- netlifyConfig[key] = newConfig[key];
59
- }
60
- return {};
28
+ const filteredConfig = filterConfig(config, [], ALLOWED_PROPERTIES, systemLog);
29
+ // Merging the config extracted from the API with the initial config.
30
+ const newConfig = mergeConfigs([filteredConfig, netlifyConfig], { concatenateArrays: true });
31
+ // Diffing the initial and the new configs to compute the mutations (what
32
+ // changed between them).
33
+ const configMutations = getConfigMutations(netlifyConfig, newConfig, applyDeployConfig.event);
34
+ return {
35
+ configMutations,
36
+ };
61
37
  };
62
38
  export const applyDeployConfig = {
63
39
  event: 'onBuild',
@@ -37,6 +37,7 @@ export const firePluginStep = async function ({ event, childProcess, packageName
37
37
  errorParams,
38
38
  logs,
39
39
  debug,
40
+ source: packageName,
40
41
  });
41
42
  const newStatus = getSuccessStatus(status, { steps, event, packageName });
42
43
  return {
@@ -1,4 +1,4 @@
1
- export function updateNetlifyConfig({ configOpts, netlifyConfig, headersPath, redirectsPath, configMutations, newConfigMutations, configSideFiles, errorParams, logs, debug, }: {
1
+ export function updateNetlifyConfig({ configOpts, netlifyConfig, headersPath, redirectsPath, configMutations, newConfigMutations, configSideFiles, errorParams, logs, debug, source, }: {
2
2
  configOpts: any;
3
3
  netlifyConfig: any;
4
4
  headersPath: any;
@@ -9,6 +9,7 @@ export function updateNetlifyConfig({ configOpts, netlifyConfig, headersPath, re
9
9
  errorParams: any;
10
10
  logs: any;
11
11
  debug: any;
12
+ source?: string | undefined;
12
13
  }): Promise<{
13
14
  netlifyConfig: any;
14
15
  configMutations: any;
@@ -7,12 +7,17 @@ import { logConfigOnUpdate } from '../log/messages/config.js';
7
7
  import { logConfigMutations } from '../log/messages/mutations.js';
8
8
  // If `netlifyConfig` was updated or `_redirects` was created, the configuration
9
9
  // is updated by calling `@netlify/config` again.
10
- export const updateNetlifyConfig = async function ({ configOpts, netlifyConfig, headersPath, redirectsPath, configMutations, newConfigMutations, configSideFiles, errorParams, logs, debug, }) {
10
+ export const updateNetlifyConfig = async function ({ configOpts, netlifyConfig, headersPath, redirectsPath, configMutations, newConfigMutations, configSideFiles, errorParams, logs, debug, source = '', }) {
11
11
  if (!(await shouldUpdateConfig({ newConfigMutations, configSideFiles, headersPath, redirectsPath }))) {
12
12
  return { netlifyConfig, configMutations };
13
13
  }
14
14
  validateConfigMutations(newConfigMutations);
15
- logConfigMutations(logs, newConfigMutations, debug);
15
+ // Don't log configuration mutations performed by code that has been authored
16
+ // by Netlify (i.e. core steps or build plugins in the `@netlify/` scope),
17
+ // since that won't give users any useful or actionable information.
18
+ if (source !== '' && !source.startsWith('@netlify/')) {
19
+ logConfigMutations(logs, newConfigMutations, debug);
20
+ }
16
21
  const configMutationsA = [...configMutations, ...newConfigMutations];
17
22
  const { config: netlifyConfigA, headersPath: headersPathA, redirectsPath: redirectsPathA, } = await resolveUpdatedConfig(configOpts, configMutationsA);
18
23
  logConfigOnUpdate({ logs, netlifyConfig: netlifyConfigA, debug });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/build",
3
- "version": "29.34.0",
3
+ "version": "29.35.0",
4
4
  "description": "Netlify build module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -163,5 +163,5 @@
163
163
  "engines": {
164
164
  "node": "^14.16.0 || >=16.0.0"
165
165
  },
166
- "gitHead": "24f130e0d2e27091cd5998cb23f19718e3785824"
166
+ "gitHead": "536aea5ec8dc76503d247828c65c4d247fa2a7ae"
167
167
  }