@netlify/config 20.21.3 → 20.21.4
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/api/site_info.d.ts +1 -1
- package/lib/api/site_info.js +24 -6
- package/package.json +2 -2
package/lib/api/site_info.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ type GetSiteInfoOpts = {
|
|
|
20
20
|
* Silently ignore API errors. For example the network connection might be down,
|
|
21
21
|
* but local builds should still work regardless.
|
|
22
22
|
*/
|
|
23
|
-
export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, }: GetSiteInfoOpts) => Promise<{
|
|
23
|
+
export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, featureFlags, }: GetSiteInfoOpts) => Promise<{
|
|
24
24
|
siteInfo: any;
|
|
25
25
|
accounts: any;
|
|
26
26
|
addons: any;
|
package/lib/api/site_info.js
CHANGED
|
@@ -11,22 +11,25 @@ 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, }) {
|
|
14
|
+
export const getSiteInfo = async function ({ api, siteId, accountId, mode, context, offline = false, testOpts = {}, siteFeatureFlagPrefix, featureFlags = {}, }) {
|
|
15
15
|
const { env: testEnv = false } = testOpts;
|
|
16
|
+
const errorOnExtensionFetchFail = featureFlags.error_builds_on_extension_fetch_fail;
|
|
16
17
|
if (api === undefined || mode === 'buildbot' || testEnv) {
|
|
17
18
|
const siteInfo = {};
|
|
18
19
|
if (siteId !== undefined)
|
|
19
20
|
siteInfo.id = siteId;
|
|
20
21
|
if (accountId !== undefined)
|
|
21
22
|
siteInfo.account_id = accountId;
|
|
22
|
-
const integrations = mode === 'buildbot' && !offline
|
|
23
|
+
const integrations = mode === 'buildbot' && !offline
|
|
24
|
+
? await getIntegrations({ siteId, testOpts, offline, accountId, errorOnExtensionFetchFail })
|
|
25
|
+
: [];
|
|
23
26
|
return { siteInfo, accounts: [], addons: [], integrations };
|
|
24
27
|
}
|
|
25
28
|
const promises = [
|
|
26
29
|
getSite(api, siteId, siteFeatureFlagPrefix),
|
|
27
30
|
getAccounts(api),
|
|
28
31
|
getAddons(api, siteId),
|
|
29
|
-
getIntegrations({ siteId, testOpts, offline, accountId }),
|
|
32
|
+
getIntegrations({ siteId, testOpts, offline, accountId, errorOnExtensionFetchFail }),
|
|
30
33
|
];
|
|
31
34
|
const [siteInfo, accounts, addons, integrations] = await Promise.all(promises);
|
|
32
35
|
if (siteInfo.use_envelope) {
|
|
@@ -68,7 +71,7 @@ const getAddons = async function (api, siteId) {
|
|
|
68
71
|
throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
69
72
|
}
|
|
70
73
|
};
|
|
71
|
-
const getIntegrations = async function ({ siteId, accountId, testOpts, offline, }) {
|
|
74
|
+
const getIntegrations = async function ({ siteId, accountId, testOpts, offline, errorOnExtensionFetchFail, }) {
|
|
72
75
|
if (!siteId || offline) {
|
|
73
76
|
return [];
|
|
74
77
|
}
|
|
@@ -78,14 +81,29 @@ const getIntegrations = async function ({ siteId, accountId, testOpts, offline,
|
|
|
78
81
|
const url = accountId
|
|
79
82
|
? `${baseUrl}team/${accountId}/integrations/installations/meta/${siteId}`
|
|
80
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 : [];
|
|
96
|
+
}
|
|
97
|
+
catch (error) {
|
|
98
|
+
return throwUserError(`Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
81
101
|
try {
|
|
82
102
|
const response = await fetch(url);
|
|
83
103
|
const integrations = await response.json();
|
|
84
104
|
return Array.isArray(integrations) ? integrations : [];
|
|
85
105
|
}
|
|
86
106
|
catch (error) {
|
|
87
|
-
// TODO: We should consider blocking the build as integrations are a critical part of the build process
|
|
88
|
-
// https://linear.app/netlify/issue/CT-1214/implement-strategy-in-builds-to-deal-with-integrations-that-we-fail-to
|
|
89
107
|
return [];
|
|
90
108
|
}
|
|
91
109
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/config",
|
|
3
|
-
"version": "20.21.
|
|
3
|
+
"version": "20.21.4",
|
|
4
4
|
"description": "Netlify config module",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/index.js",
|
|
@@ -95,5 +95,5 @@
|
|
|
95
95
|
"engines": {
|
|
96
96
|
"node": "^14.16.0 || >=16.0.0"
|
|
97
97
|
},
|
|
98
|
-
"gitHead": "
|
|
98
|
+
"gitHead": "04134491e36ab1b6ccf5990edf1885e43d8a15a0"
|
|
99
99
|
}
|