@netlify/config 20.21.6 → 20.22.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
102
  catch (error) {
107
- return [];
103
+ return throwUserError(`Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
108
104
  }
109
105
  };
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,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/config",
3
- "version": "20.21.6",
3
+ "version": "20.22.0",
4
4
  "description": "Netlify config module",
5
5
  "type": "module",
6
6
  "exports": "./lib/index.js",
@@ -74,7 +74,7 @@
74
74
  "is-plain-obj": "^4.0.0",
75
75
  "js-yaml": "^4.0.0",
76
76
  "map-obj": "^5.0.0",
77
- "netlify": "^13.3.2",
77
+ "netlify": "^13.3.3",
78
78
  "node-fetch": "^3.3.1",
79
79
  "omit.js": "^2.0.2",
80
80
  "p-locate": "^6.0.0",
@@ -95,5 +95,5 @@
95
95
  "engines": {
96
96
  "node": "^14.16.0 || >=16.0.0"
97
97
  },
98
- "gitHead": "269e3fe56ea6a36062302df981793e9fe12db324"
98
+ "gitHead": "b1de419113daee962ab37b1e75bcfc0d32f778e7"
99
99
  }