Skip to content

Commit

Permalink
Merge branch 'main' into release-please--branches--main
Browse files Browse the repository at this point in the history
  • Loading branch information
khendrikse authored Jun 12, 2024
2 parents 85c9655 + 055e9a7 commit 9e82b87
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
10 changes: 6 additions & 4 deletions packages/config/src/api/site_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ type GetSiteInfoOpts = {
context?: string
featureFlags?: Record<string, boolean>
testOpts?: TestOptions
siteFeatureFlagPrefix: string
}
/**
* Retrieve Netlify Site information, if available.
Expand All @@ -35,6 +36,7 @@ export const getSiteInfo = async function ({
offline = false,
testOpts = {},
featureFlags = {},
siteFeatureFlagPrefix,
}: GetSiteInfoOpts) {
const { env: testEnv = false } = testOpts

Expand All @@ -53,7 +55,7 @@ export const getSiteInfo = async function ({
}

const promises = [
getSite(api, siteId),
getSite(api, siteId, siteFeatureFlagPrefix),
getAccounts(api),
getAddons(api, siteId),
getIntegrations({ siteId, testOpts, offline, useV2Endpoint, accountId }),
Expand All @@ -79,7 +81,7 @@ export const getSiteInfo = async function ({
}

const promises = [
getSite(api, siteId),
getSite(api, siteId, siteFeatureFlagPrefix),
getAccounts(api),
getAddons(api, siteId),
getIntegrations({ siteId, testOpts, offline }),
Expand All @@ -96,13 +98,13 @@ export const getSiteInfo = async function ({
return { siteInfo, accounts, addons, integrations }
}

const getSite = async function (api: NetlifyAPI, siteId: string) {
const getSite = async function (api: NetlifyAPI, siteId: string, siteFeatureFlagPrefix: string) {
if (siteId === undefined) {
return {}
}

try {
const site = await (api as any).getSite({ siteId })
const site = await (api as any).getSite({ siteId, feature_flags: siteFeatureFlagPrefix })
return { ...site, id: siteId }
} catch (error) {
throwUserError(`Failed retrieving site data for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`)
Expand Down
16 changes: 14 additions & 2 deletions packages/config/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,19 @@ import { getRedirectsPath, addRedirects } from './redirects.js'
* `config` together with related properties such as the `configPath`.
*/
export const resolveConfig = async function (opts) {
const { cachedConfig, cachedConfigPath, host, scheme, packagePath, pathPrefix, testOpts, token, offline, ...optsA } =
addDefaultOpts(opts) as $TSFixMe
const {
cachedConfig,
cachedConfigPath,
host,
scheme,
packagePath,
pathPrefix,
testOpts,
token,
offline,
siteFeatureFlagPrefix,
...optsA
} = addDefaultOpts(opts) as $TSFixMe
// `api` is not JSON-serializable, so we cannot cache it inside `cachedConfig`
const api = getApiClient({ token, offline, host, scheme, pathPrefix, testOpts })

Expand Down Expand Up @@ -62,6 +73,7 @@ export const resolveConfig = async function (opts) {
siteId,
accountId,
mode,
siteFeatureFlagPrefix,
offline,
featureFlags,
testOpts,
Expand Down

0 comments on commit 9e82b87

Please sign in to comment.