Skip to content

Commit 92e23e0

Browse files
committed
fix: implement some feedback
1 parent cb0225e commit 92e23e0

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

packages/config/src/api/integrations.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,17 @@ import { TestOptions } from '../types/options.js'
44

55
type AvailableIntegration = { slug: string; hostSiteUrl: string; hasBuild?: boolean }
66

7-
type GetAvailableIntegrationsOpts = { testOpts: TestOptions; offline: boolean; netlifyApiHost: string }
7+
type GetAvailableIntegrationsOpts = { testOpts: TestOptions; offline: boolean; extensionApiBaseUrl: string }
88

99
export const getAvailableIntegrations = async function ({
1010
testOpts,
1111
offline,
12-
netlifyApiHost,
12+
extensionApiBaseUrl,
1313
}: GetAvailableIntegrationsOpts): Promise<AvailableIntegration[]> {
1414
if (offline) {
1515
return []
1616
}
1717
const { host } = testOpts
18-
const extensionApiBaseUrl =
19-
netlifyApiHost === 'api.netlify.com' ? 'https://api.netlifysdk.com/' : `https://api-staging.netlifysdk.com/`
2018
const baseUrl = new URL(host ? `http://${host}/` : extensionApiBaseUrl)
2119

2220
try {

packages/config/src/api/site_info.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ type GetSiteInfoOpts = {
1919
testOpts?: TestOptions
2020
siteFeatureFlagPrefix: string
2121
token: string
22-
netlifyApiHost: string
22+
extensionApiBaseUrl: string
2323
}
2424
/**
2525
* Retrieve Netlify Site information, if available.
@@ -41,7 +41,7 @@ export const getSiteInfo = async function ({
4141
siteFeatureFlagPrefix,
4242
token,
4343
featureFlags = {},
44-
netlifyApiHost,
44+
extensionApiBaseUrl,
4545
}: GetSiteInfoOpts) {
4646
const { env: testEnv = false } = testOpts
4747

@@ -53,7 +53,7 @@ export const getSiteInfo = async function ({
5353

5454
const integrations =
5555
mode === 'buildbot' && !offline
56-
? await getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, netlifyApiHost })
56+
? await getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl })
5757
: []
5858

5959
return { siteInfo, accounts: [], addons: [], integrations }
@@ -63,7 +63,7 @@ export const getSiteInfo = async function ({
6363
getSite(api, siteId, siteFeatureFlagPrefix),
6464
getAccounts(api),
6565
getAddons(api, siteId),
66-
getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, netlifyApiHost }),
66+
getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl }),
6767
]
6868

6969
const [siteInfo, accounts, addons, integrations] = await Promise.all(promises)
@@ -119,7 +119,7 @@ type GetIntegrationsOpts = {
119119
offline: boolean
120120
token?: string
121121
featureFlags?: Record<string, boolean>
122-
netlifyApiHost: string
122+
extensionApiBaseUrl: string
123123
}
124124

125125
const getIntegrations = async function ({
@@ -129,15 +129,13 @@ const getIntegrations = async function ({
129129
offline,
130130
token,
131131
featureFlags,
132-
netlifyApiHost,
132+
extensionApiBaseUrl,
133133
}: GetIntegrationsOpts): Promise<IntegrationResponse[]> {
134134
if (!siteId || offline) {
135135
return []
136136
}
137137
const sendBuildBotTokenToJigsaw = featureFlags?.send_build_bot_token_to_jigsaw
138138
const { host } = testOpts
139-
const extensionApiBaseUrl =
140-
netlifyApiHost === 'api.netlify.com' ? 'https://api.netlifysdk.com' : `https://api-staging.netlifysdk.com `
141139
const baseUrl = new URL(host ? `http://${host}` : extensionApiBaseUrl)
142140

143141
// if accountId isn't present, use safe v1 endpoint

packages/config/src/integrations.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ type MergeIntegrationsOpts = {
99
context: string
1010
testOpts?: TestOptions
1111
offline: boolean
12-
netlifyApiHost: string
12+
extensionApiBaseUrl: string
1313
}
1414

1515
export const mergeIntegrations = async function ({
@@ -18,9 +18,9 @@ export const mergeIntegrations = async function ({
1818
context,
1919
testOpts = {},
2020
offline,
21-
netlifyApiHost,
21+
extensionApiBaseUrl,
2222
}: MergeIntegrationsOpts): Promise<Integration[]> {
23-
const availableIntegrations = await getAvailableIntegrations({ testOpts, offline, netlifyApiHost })
23+
const availableIntegrations = await getAvailableIntegrations({ testOpts, offline, extensionApiBaseUrl })
2424

2525
// Include all API integrations, unless they have a `dev` property and we are in the `dev` context
2626
const resolvedApiIntegrations = apiIntegrations.filter(

packages/config/src/main.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ export const resolveConfig = async function (opts) {
4949
return parsedCachedConfig
5050
}
5151

52+
// TODO(kh): remove this mapping and get the extensionApiHost from the opts
53+
const extensionApiBaseUrl =
54+
host === 'api.netlify.com' ? 'https://api.netlifysdk.com' : `https://api-staging.netlifysdk.com `
55+
5256
const {
5357
config: configOpt,
5458
defaultConfig,
@@ -81,7 +85,7 @@ export const resolveConfig = async function (opts) {
8185
featureFlags,
8286
testOpts,
8387
token,
84-
netlifyApiHost: host,
88+
extensionApiBaseUrl,
8589
})
8690

8791
const { defaultConfig: defaultConfigA, baseRelDir: baseRelDirA } = parseDefaultConfig({
@@ -132,7 +136,7 @@ export const resolveConfig = async function (opts) {
132136
context: context,
133137
testOpts,
134138
offline,
135-
netlifyApiHost: host,
139+
extensionApiBaseUrl,
136140
})
137141

138142
const result = {

0 commit comments

Comments
 (0)