@netlify/config
Advanced tools
Comparing version 20.21.3 to 20.21.4
@@ -23,3 +23,3 @@ import { NetlifyAPI } from 'netlify'; | ||
*/ | ||
export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, }: GetSiteInfoOpts) => Promise<{ | ||
export declare const getSiteInfo: ({ api, siteId, accountId, mode, context, offline, testOpts, siteFeatureFlagPrefix, featureFlags, }: GetSiteInfoOpts) => Promise<{ | ||
siteInfo: any; | ||
@@ -26,0 +26,0 @@ accounts: any; |
@@ -14,4 +14,5 @@ import fetch from 'node-fetch'; | ||
*/ | ||
export const getSiteInfo = async function ({ api, siteId, accountId, mode, context, offline = false, testOpts = {}, siteFeatureFlagPrefix, }) { | ||
export const getSiteInfo = async function ({ api, siteId, accountId, mode, context, offline = false, testOpts = {}, siteFeatureFlagPrefix, featureFlags = {}, }) { | ||
const { env: testEnv = false } = testOpts; | ||
const errorOnExtensionFetchFail = featureFlags.error_builds_on_extension_fetch_fail; | ||
if (api === undefined || mode === 'buildbot' || testEnv) { | ||
@@ -23,3 +24,5 @@ const siteInfo = {}; | ||
siteInfo.account_id = accountId; | ||
const integrations = mode === 'buildbot' && !offline ? await getIntegrations({ siteId, testOpts, offline, accountId }) : []; | ||
const integrations = mode === 'buildbot' && !offline | ||
? await getIntegrations({ siteId, testOpts, offline, accountId, errorOnExtensionFetchFail }) | ||
: []; | ||
return { siteInfo, accounts: [], addons: [], integrations }; | ||
@@ -31,3 +34,3 @@ } | ||
getAddons(api, siteId), | ||
getIntegrations({ siteId, testOpts, offline, accountId }), | ||
getIntegrations({ siteId, testOpts, offline, accountId, errorOnExtensionFetchFail }), | ||
]; | ||
@@ -74,3 +77,3 @@ const [siteInfo, accounts, addons, integrations] = await Promise.all(promises); | ||
}; | ||
const getIntegrations = async function ({ siteId, accountId, testOpts, offline, }) { | ||
const getIntegrations = async function ({ siteId, accountId, testOpts, offline, errorOnExtensionFetchFail, }) { | ||
if (!siteId || offline) { | ||
@@ -85,2 +88,19 @@ return []; | ||
: `${baseUrl}site/${siteId}/integrations/safe`; | ||
if (errorOnExtensionFetchFail) { | ||
try { | ||
const response = await fetch(url); | ||
if (!response.ok) { | ||
throw new Error(`Unexpected status code ${response.status} from fetching extensions`); | ||
} | ||
const bodyText = await response.text(); | ||
if (bodyText === '') { | ||
return []; | ||
} | ||
const integrations = await JSON.parse(bodyText); | ||
return Array.isArray(integrations) ? integrations : []; | ||
} | ||
catch (error) { | ||
return throwUserError(`Failed retrieving extensions for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`); | ||
} | ||
} | ||
try { | ||
@@ -92,6 +112,4 @@ const response = await fetch(url); | ||
catch (error) { | ||
// TODO: We should consider blocking the build as integrations are a critical part of the build process | ||
// https://linear.app/netlify/issue/CT-1214/implement-strategy-in-builds-to-deal-with-integrations-that-we-fail-to | ||
return []; | ||
} | ||
}; |
{ | ||
"name": "@netlify/config", | ||
"version": "20.21.3", | ||
"version": "20.21.4", | ||
"description": "Netlify config module", | ||
@@ -98,3 +98,3 @@ "type": "module", | ||
}, | ||
"gitHead": "0a66a5592b80f8b2e2538ebc385d3eea8777c7b7" | ||
"gitHead": "04134491e36ab1b6ccf5990edf1885e43d8a15a0" | ||
} |
167069
4023
4