Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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