@netlify/config 20.21.7 → 21.0.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.
@@ -10,6 +10,7 @@ type GetSiteInfoOpts = {
10
10
  featureFlags?: Record<string, boolean>;
11
11
  testOpts?: TestOptions;
12
12
  siteFeatureFlagPrefix: string;
13
+ token: string;
13
14
  };
14
15
  /**
15
16
  * Retrieve Netlify Site information, if available.
@@ -20,7 +21,7 @@ type GetSiteInfoOpts = {
20
21
  * Silently ignore API errors. For example the network connection might be down,
21
22
  * but local builds should still work regardless.
22
23
  */
23
- export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, featureFlags, }: GetSiteInfoOpts) => Promise<{
24
+ export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, token, featureFlags, }: GetSiteInfoOpts) => Promise<{
24
25
  siteInfo: any;
25
26
  accounts: any;
26
27
  addons: any;
@@ -11,9 +11,8 @@ import { ERROR_CALL_TO_ACTION } from '../log/messages.js';
11
11
  * Silently ignore API errors. For example the network connection might be down,
12
12
  * but local builds should still work regardless.
13
13
  */
14
- export const getSiteInfo = async function ({ api, siteId, accountId, mode, context, offline = false, testOpts = {}, siteFeatureFlagPrefix, featureFlags = {}, }) {
14
+ export const getSiteInfo = async function ({ api, siteId, accountId, mode, context, offline = false, testOpts = {}, siteFeatureFlagPrefix, token, featureFlags = {}, }) {
15
15
  const { env: testEnv = false } = testOpts;
16
- const errorOnExtensionFetchFail = featureFlags.error_builds_on_extension_fetch_fail;
17
16
  if (api === undefined || mode === 'buildbot' || testEnv) {
18
17
  const siteInfo = {};
19
18
  if (siteId !== undefined)
@@ -21,7 +20,7 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
21
20
  if (accountId !== undefined)
22
21
  siteInfo.account_id = accountId;
23
22
  const integrations = mode === 'buildbot' && !offline
24
- ? await getIntegrations({ siteId, testOpts, offline, accountId, errorOnExtensionFetchFail })
23
+ ? await getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags })
25
24
  : [];
26
25
  return { siteInfo, accounts: [], addons: [], integrations };
27
26
  }
@@ -29,7 +28,7 @@ export const getSiteInfo = async function ({ api, siteId, accountId, mode, conte
29
28
  getSite(api, siteId, siteFeatureFlagPrefix),
30
29
  getAccounts(api),
31
30
  getAddons(api, siteId),
32
- getIntegrations({ siteId, testOpts, offline, accountId, errorOnExtensionFetchFail }),
31
+ getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags }),
33
32
  ];
34
33
  const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
35
34
  if (siteInfo.use_envelope) {
@@ -71,39 +70,36 @@ const getAddons = async function (api, siteId) {
71
70
  throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
72
71
  }
73
72
  };
74
- const getIntegrations = async function ({ siteId, accountId, testOpts, offline, errorOnExtensionFetchFail, }) {
73
+ const getIntegrations = async function ({ siteId, accountId, testOpts, offline, token, featureFlags, }) {
75
74
  if (!siteId || offline) {
76
75
  return [];
77
76
  }
77
+ const sendBuildBotTokenToJigsaw = featureFlags?.send_build_bot_token_to_jigsaw;
78
78
  const { host } = testOpts;
79
79
  const baseUrl = new URL(host ? `http://${host}` : `https://api.netlifysdk.com`);
80
80
  // if accountId isn't present, use safe v1 endpoint
81
81
  const url = accountId
82
82
  ? `${baseUrl}team/${accountId}/integrations/installations/meta/${siteId}`
83
83
  : `${baseUrl}site/${siteId}/integrations/safe`;
84
- if (errorOnExtensionFetchFail) {
85
- try {
86
- const response = await fetch(url);
87
- if (!response.ok) {
88
- throw new Error(`Unexpected status code ${response.status} from fetching extensions`);
89
- }
90
- const bodyText = await response.text();
91
- if (bodyText === '') {
92
- return [];
93
- }
94
- const integrations = await JSON.parse(bodyText);
95
- return Array.isArray(integrations) ? integrations : [];
84
+ try {
85
+ const requestOptions = {};
86
+ if (sendBuildBotTokenToJigsaw && token) {
87
+ requestOptions.headers = {
88
+ 'netlify-sdk-build-bot-token': token,
89
+ };
96
90
  }
97
- catch (error) {
98
- return throwUserError(`Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
91
+ const response = await fetch(url, requestOptions);
92
+ if (!response.ok) {
93
+ throw new Error(`Unexpected status code ${response.status} from fetching extensions`);
99
94
  }
100
- }
101
- try {
102
- const response = await fetch(url);
103
- const integrations = await response.json();
95
+ const bodyText = await response.text();
96
+ if (bodyText === '') {
97
+ return [];
98
+ }
99
+ const integrations = await JSON.parse(bodyText);
104
100
  return Array.isArray(integrations) ? integrations : [];
105
101
  }
106
- catch {
107
- return [];
102
+ catch (error) {
103
+ return throwUserError(`Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
108
104
  }
109
105
  };
package/lib/env/main.js CHANGED
@@ -66,7 +66,7 @@ const convertToString = (value) => {
66
66
  };
67
67
  // Environment variables not set by users, but meant to mimic the production
68
68
  // environment.
69
- const getGeneralEnv = async function ({ siteInfo, siteInfo: { id, name }, buildDir, branch, deployId, buildId, context, }) {
69
+ const getGeneralEnv = async function ({ siteInfo, siteInfo: { id, name, account_id: accountId }, buildDir, branch, deployId, buildId, context, }) {
70
70
  const gitEnv = await getGitEnv(buildDir, branch);
71
71
  const deployUrls = getDeployUrls({ siteInfo: siteInfo, branch, deployId });
72
72
  return removeFalsy({
@@ -74,6 +74,7 @@ const getGeneralEnv = async function ({ siteInfo, siteInfo: { id, name }, buildD
74
74
  SITE_NAME: name,
75
75
  DEPLOY_ID: deployId,
76
76
  BUILD_ID: buildId,
77
+ ACCOUNT_ID: accountId,
77
78
  ...deployUrls,
78
79
  CONTEXT: context,
79
80
  NETLIFY_LOCAL: 'true',
package/lib/headers.d.ts CHANGED
@@ -3,14 +3,13 @@ export function getHeadersPath({ build: { publish } }: {
3
3
  publish: any;
4
4
  };
5
5
  }): string;
6
- export function addHeaders({ config: { headers: configHeaders, ...config }, headersPath, logs, featureFlags, }: {
6
+ export function addHeaders({ config: { headers: configHeaders, ...config }, headersPath, logs }: {
7
7
  config: {
8
8
  [x: string]: any;
9
9
  headers: any;
10
10
  };
11
11
  headersPath: any;
12
12
  logs: any;
13
- featureFlags: any;
14
13
  }): Promise<{
15
- headers: import("packages/headers-parser/lib/types.js").Header[];
14
+ headers: (import("@netlify/headers-parser").MinimalHeader | import("@netlify/headers-parser").Header)[];
16
15
  }>;
package/lib/headers.js CHANGED
@@ -7,12 +7,11 @@ export const getHeadersPath = function ({ build: { publish } }) {
7
7
  };
8
8
  const HEADERS_FILENAME = '_headers';
9
9
  // Add `config.headers`
10
- export const addHeaders = async function ({ config: { headers: configHeaders, ...config }, headersPath, logs, featureFlags, }) {
10
+ export const addHeaders = async function ({ config: { headers: configHeaders, ...config }, headersPath, logs }) {
11
11
  const { headers, errors } = await parseAllHeaders({
12
12
  headersFiles: [headersPath],
13
13
  configHeaders,
14
14
  minimal: true,
15
- featureFlags,
16
15
  });
17
16
  warnHeadersParsing(logs, errors);
18
17
  warnHeadersCaseSensitivity(logs, headers);
package/lib/main.js CHANGED
@@ -45,6 +45,7 @@ export const resolveConfig = async function (opts) {
45
45
  offline,
46
46
  featureFlags,
47
47
  testOpts,
48
+ token,
48
49
  });
49
50
  const { defaultConfig: defaultConfigA, baseRelDir: baseRelDirA } = parseDefaultConfig({
50
51
  defaultConfig,
@@ -204,7 +205,7 @@ const getFullConfig = async function ({ configOpt, cwd, context, repositoryRoot,
204
205
  });
205
206
  const { config: configB, buildDir, base: baseA, } = await resolveFiles({ packagePath, config: configA, repositoryRoot, base, baseRelDir });
206
207
  const headersPath = getHeadersPath(configB);
207
- const configC = await addHeaders({ config: configB, headersPath, logs, featureFlags });
208
+ const configC = await addHeaders({ config: configB, headersPath, logs });
208
209
  const redirectsPath = getRedirectsPath(configC);
209
210
  const configD = await addRedirects({ config: configC, redirectsPath, logs, featureFlags });
210
211
  return { configPath, config: configD, buildDir, base: baseA, redirectsPath, headersPath };
@@ -16,7 +16,7 @@ export const updateConfig = async function (configMutations, { buildDir, configP
16
16
  const inlineConfig = applyMutations({}, configMutations);
17
17
  const normalizedInlineConfig = ensureConfigPriority(inlineConfig, context, branch);
18
18
  const updatedConfig = await mergeWithConfig(normalizedInlineConfig, configPath);
19
- const configWithHeaders = await addHeaders({ config: updatedConfig, headersPath, logs, featureFlags });
19
+ const configWithHeaders = await addHeaders({ config: updatedConfig, headersPath, logs });
20
20
  const finalConfig = await addRedirects({ config: configWithHeaders, redirectsPath, logs, featureFlags });
21
21
  const simplifiedConfig = simplifyConfig(finalConfig);
22
22
  await backupConfig({ buildDir, configPath, headersPath, redirectsPath });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "20.21.7",
3
+ "version": "21.0.0",
4
4
  "description": "Netlify config module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -59,7 +59,7 @@
59
59
  "license": "MIT",
60
60
  "dependencies": {
61
61
  "@iarna/toml": "^2.2.5",
62
- "@netlify/headers-parser": "^7.3.0",
62
+ "@netlify/headers-parser": "^8.0.0",
63
63
  "@netlify/redirect-parser": "^14.5.0",
64
64
  "chalk": "^5.0.0",
65
65
  "cron-parser": "^4.1.0",
@@ -95,5 +95,5 @@
95
95
  "engines": {
96
96
  "node": "^14.16.0 || >=16.0.0"
97
97
  },
98
- "gitHead": "09e899aeb71775da157dd9c02f41ceadeeb9f401"
98
+ "gitHead": "65206cf82369d2e0412c707c763590690cc1819a"
99
99
  }