Skip to content

Commit a09c02a

Browse files
authored
Merge branch 'main' into jake/efs
2 parents b93e4a8 + d2276a9 commit a09c02a

File tree

18 files changed

+295
-149
lines changed

18 files changed

+295
-149
lines changed

.release-please-manifest.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
{
22
"packages/build-info": "9.0.2",
3-
"packages/build": "30.0.6",
4-
"packages/edge-bundler": "12.3.3",
3+
"packages/build": "30.1.1",
4+
"packages/edge-bundler": "12.4.0",
55
"packages/cache-utils": "5.2.0",
6-
"packages/config": "21.0.4",
6+
"packages/config": "21.0.6",
77
"packages/framework-info": "9.9.2",
88
"packages/functions-utils": "5.3.13",
99
"packages/git-utils": "5.2.0",
1010
"packages/headers-parser": "8.0.0",
11-
"packages/js-client": "13.3.3",
11+
"packages/js-client": "13.3.4",
1212
"packages/nock-udp": "4.0.0",
1313
"packages/redirect-parser": "14.5.1",
1414
"packages/run-utils": "5.2.0",

package-lock.json

Lines changed: 124 additions & 124 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/build/CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,30 @@
105105
* dependencies
106106
* @netlify/config bumped from ^20.8.0 to ^20.8.1
107107

108+
## [30.1.1](https://github.com/netlify/build/compare/build-v30.1.0...build-v30.1.1) (2025-04-01)
109+
110+
111+
### Dependencies
112+
113+
* The following workspace dependencies were updated
114+
* dependencies
115+
* @netlify/config bumped from ^21.0.5 to ^21.0.6
116+
117+
## [30.1.0](https://github.com/netlify/build/compare/build-v30.0.6...build-v30.1.0) (2025-03-28)
118+
119+
120+
### Features
121+
122+
* update deno version range to include v2 ([#6118](https://github.com/netlify/build/issues/6118)) ([297177f](https://github.com/netlify/build/commit/297177f56ac64c27ac3393f12d1129ce73d8177c))
123+
124+
125+
### Dependencies
126+
127+
* The following workspace dependencies were updated
128+
* dependencies
129+
* @netlify/config bumped from ^21.0.4 to ^21.0.5
130+
* @netlify/edge-bundler bumped from 12.3.3 to 12.4.0
131+
108132
## [30.0.6](https://github.com/netlify/build/compare/build-v30.0.5...build-v30.0.6) (2025-03-24)
109133

110134

packages/build/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netlify/build",
3-
"version": "30.0.6",
3+
"version": "30.1.1",
44
"description": "Netlify build module",
55
"type": "module",
66
"exports": "./lib/index.js",
@@ -69,8 +69,8 @@
6969
"@bugsnag/js": "^7.0.0",
7070
"@netlify/blobs": "^8.1.2",
7171
"@netlify/cache-utils": "^5.2.0",
72-
"@netlify/config": "^21.0.4",
73-
"@netlify/edge-bundler": "12.3.3",
72+
"@netlify/config": "^21.0.6",
73+
"@netlify/edge-bundler": "12.4.0",
7474
"@netlify/framework-info": "^9.9.2",
7575
"@netlify/functions-utils": "^5.3.13",
7676
"@netlify/git-utils": "^5.2.0",

packages/config/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,22 @@
7676
* dependencies
7777
* netlify bumped from ^13.1.8 to ^13.1.9
7878

79+
## [21.0.6](https://github.com/netlify/build/compare/config-v21.0.5...config-v21.0.6) (2025-04-01)
80+
81+
82+
### Bug Fixes
83+
84+
* ensure extension api is always called with the right host ([#6168](https://github.com/netlify/build/issues/6168)) ([6b34ebf](https://github.com/netlify/build/commit/6b34ebf300dc45606cf787e7127b5b376b69e574))
85+
86+
## [21.0.5](https://github.com/netlify/build/compare/config-v21.0.4...config-v21.0.5) (2025-03-28)
87+
88+
89+
### Dependencies
90+
91+
* The following workspace dependencies were updated
92+
* dependencies
93+
* netlify bumped from ^13.3.3 to ^13.3.4
94+
7995
## [21.0.4](https://github.com/netlify/build/compare/config-v21.0.3...config-v21.0.4) (2025-03-24)
8096

8197

packages/config/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@netlify/config",
3-
"version": "21.0.4",
3+
"version": "21.0.6",
44
"description": "Netlify config module",
55
"type": "module",
66
"exports": "./lib/index.js",
@@ -72,7 +72,7 @@
7272
"is-plain-obj": "^4.0.0",
7373
"js-yaml": "^4.0.0",
7474
"map-obj": "^5.0.0",
75-
"netlify": "^13.3.3",
75+
"netlify": "^13.3.4",
7676
"@netlify/headers-parser": "^8.0.0",
7777
"@netlify/redirect-parser": "^14.5.1",
7878
"node-fetch": "^3.3.1",

packages/config/src/api/site_info.ts

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import type { RequestInit } from 'node-fetch'
44

55
import { getEnvelope } from '../env/envelope.js'
66
import { throwUserError } from '../error.js'
7+
import {
8+
EXTENSION_API_BASE_URL,
9+
EXTENSION_API_STAGING_BASE_URL,
10+
NETLIFY_API_BASE_URL,
11+
NETLIFY_API_STAGING_BASE_URL,
12+
} from '../integrations.js'
713
import { ERROR_CALL_TO_ACTION } from '../log/messages.js'
814
import { IntegrationResponse } from '../types/api.js'
915
import { ModeOption, TestOptions } from '../types/options.js'
@@ -53,7 +59,16 @@ export const getSiteInfo = async function ({
5359

5460
const integrations =
5561
mode === 'buildbot' && !offline
56-
? await getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl })
62+
? await getIntegrations({
63+
siteId,
64+
testOpts,
65+
offline,
66+
accountId,
67+
token,
68+
featureFlags,
69+
extensionApiBaseUrl,
70+
mode,
71+
})
5772
: []
5873

5974
return { siteInfo, accounts: [], addons: [], integrations }
@@ -63,7 +78,7 @@ export const getSiteInfo = async function ({
6378
getSite(api, siteId, siteFeatureFlagPrefix),
6479
getAccounts(api),
6580
getAddons(api, siteId),
66-
getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl }),
81+
getIntegrations({ siteId, testOpts, offline, accountId, token, featureFlags, extensionApiBaseUrl, mode }),
6782
]
6883

6984
const [siteInfo, accounts, addons, integrations] = await Promise.all(promises)
@@ -120,6 +135,7 @@ type GetIntegrationsOpts = {
120135
token?: string
121136
featureFlags?: Record<string, boolean>
122137
extensionApiBaseUrl: string
138+
mode: ModeOption
123139
}
124140

125141
const getIntegrations = async function ({
@@ -130,19 +146,36 @@ const getIntegrations = async function ({
130146
token,
131147
featureFlags,
132148
extensionApiBaseUrl,
149+
mode,
133150
}: GetIntegrationsOpts): Promise<IntegrationResponse[]> {
134151
if (!siteId || offline) {
135152
return []
136153
}
137154
const sendBuildBotTokenToJigsaw = featureFlags?.send_build_bot_token_to_jigsaw
138-
const { host, setBaseUrl } = testOpts
155+
const { host: originalHost, setBaseUrl } = testOpts
156+
157+
// TODO(kh): I am adding this purely for local staging development.
158+
// We should remove this once we have fixed https://github.com/netlify/cli/blob/b5a5c7525edd28925c5c2e3e5f0f00c4261eaba5/src/lib/build.ts#L125
159+
let host = originalHost
160+
161+
// If there is a host, we use it to fetch the integrations
162+
// we check if the host is staging or production and set the host accordingly,
163+
// sadly necessary because of https://github.com/netlify/cli/blob/b5a5c7525edd28925c5c2e3e5f0f00c4261eaba5/src/lib/build.ts#L125
164+
if (originalHost) {
165+
if (originalHost?.includes(NETLIFY_API_STAGING_BASE_URL)) {
166+
host = EXTENSION_API_STAGING_BASE_URL
167+
} else if (originalHost?.includes(NETLIFY_API_BASE_URL)) {
168+
host = EXTENSION_API_BASE_URL
169+
} else {
170+
host = `http://${originalHost}`
171+
}
172+
}
139173

174+
const baseUrl = new URL(host ?? extensionApiBaseUrl)
140175
// We only use this for testing
141176
if (host && setBaseUrl) {
142177
setBaseUrl(extensionApiBaseUrl)
143178
}
144-
145-
const baseUrl = new URL(host ? `http://${host}` : extensionApiBaseUrl)
146179
// if accountId isn't present, use safe v1 endpoint
147180
const url = accountId
148181
? `${baseUrl}team/${accountId}/integrations/installations/meta/${siteId}`
@@ -151,8 +184,14 @@ const getIntegrations = async function ({
151184
try {
152185
const requestOptions = {} as RequestInit
153186

187+
// This is used to identify where the request is coming from
188+
requestOptions.headers = {
189+
'netlify-config-mode': mode,
190+
}
191+
154192
if (sendBuildBotTokenToJigsaw && token) {
155193
requestOptions.headers = {
194+
...requestOptions.headers,
156195
'netlify-sdk-build-bot-token': token,
157196
}
158197
}

packages/config/src/integrations.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Integration } from './types/integrations.js'
44
import { TestOptions } from './types/options.js'
55

66
export const NETLIFY_API_STAGING_BASE_URL = 'api-staging.netlify.com'
7+
export const NETLIFY_API_BASE_URL = 'api.netlify.com'
78
export const EXTENSION_API_BASE_URL = 'https://api.netlifysdk.com'
89
export const EXTENSION_API_STAGING_BASE_URL = 'https://api-staging.netlifysdk.com'
910

packages/config/src/main.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ export const resolveConfig = async function (opts) {
5555
}
5656

5757
// TODO(kh): remove this mapping and get the extensionApiHost from the opts
58-
const extensionApiBaseUrl =
59-
host === NETLIFY_API_STAGING_BASE_URL ? EXTENSION_API_STAGING_BASE_URL : EXTENSION_API_BASE_URL
58+
const extensionApiBaseUrl = host?.includes(NETLIFY_API_STAGING_BASE_URL)
59+
? EXTENSION_API_STAGING_BASE_URL
60+
: EXTENSION_API_BASE_URL
6061

6162
const {
6263
config: configOpt,

packages/config/tests/api/tests.js

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,7 @@ test('Integrations are returned if accountId is present and mode is dev', async
425425
t.assert(config.integrations[0].has_build === true)
426426
})
427427

428-
test('Integrations are returned and called with a netlify-sdk-build-bot-token', async (t) => {
428+
test('Integrations are returned and called with a netlify-sdk-build-bot-token header', async (t) => {
429429
const { output, requests } = await new Fixture('./fixtures/base')
430430
.withFlags({
431431
siteId: 'test',
@@ -451,6 +451,32 @@ test('Integrations are returned and called with a netlify-sdk-build-bot-token',
451451
t.assert(config.integrations[0].has_build === true)
452452
})
453453

454+
test('Integrations are returned and called with a netlify-config-mode header', async (t) => {
455+
const { output, requests } = await new Fixture('./fixtures/base')
456+
.withFlags({
457+
siteId: 'test',
458+
mode: 'dev',
459+
token: 'test',
460+
accountId: 'account1',
461+
featureFlags: {
462+
send_build_bot_token_to_jigsaw: true,
463+
},
464+
})
465+
.runConfigServer([SITE_INFO_DATA, TEAM_INSTALLATIONS_META_RESPONSE, FETCH_INTEGRATIONS_EMPTY_RESPONSE])
466+
467+
const config = JSON.parse(output)
468+
const installationsHeaders = requests.find(
469+
(request) => request.url === TEAM_INSTALLATIONS_META_RESPONSE.path,
470+
)?.headers
471+
472+
t.assert(installationsHeaders.includes('netlify-config-mode'))
473+
t.assert(config.integrations)
474+
t.assert(config.integrations.length === 1)
475+
t.assert(config.integrations[0].slug === 'test')
476+
t.assert(config.integrations[0].version === 'so-cool-v2')
477+
t.assert(config.integrations[0].has_build === true)
478+
})
479+
454480
test('Integrations are not returned if failed to fetch integrations', async (t) => {
455481
const { output } = await new Fixture('./fixtures/base')
456482
.withFlags({

0 commit comments

Comments
 (0)