Skip to content

Commit

Permalink
Merge branch 'main' into update-deno-version-range
Browse files Browse the repository at this point in the history
  • Loading branch information
mrstork authored Dec 11, 2024
2 parents a89a5b6 + 5455393 commit 67ebec1
Show file tree
Hide file tree
Showing 13 changed files with 135 additions and 144 deletions.
64 changes: 32 additions & 32 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/build-info/src/runtime/bun.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,15 @@ test('detects node when bunfig.toml is present', async ({ fs }) => {
expect(detected[0].name).toBe('Bun')
})

test('detects node when bun.lock is present', async ({ fs }) => {
const cwd = mockFileSystem({
'bun.lock': '',
})

const detected = await new Project(fs, cwd).detectRuntime()
expect(detected[0].name).toBe('Bun')
})

test('detects node when bun.lockb is present', async ({ fs }) => {
const cwd = mockFileSystem({
'bun.lockb': '',
Expand Down
2 changes: 1 addition & 1 deletion packages/build-info/src/runtime/bun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ import { LangRuntime } from './runtime.js'
export class Bun extends LangRuntime {
id = 'bun'
name = 'Bun'
configFiles = ['bun.lockb', 'bunfig.toml']
configFiles = ['bun.lock', 'bun.lockb', 'bunfig.toml']
}
17 changes: 15 additions & 2 deletions packages/build/src/plugins/spawn.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { createRequire } from 'module'
import { platform } from 'os'
import { fileURLToPath, pathToFileURL } from 'url'
import { promisify } from 'util'

import { trace } from '@opentelemetry/api'
import { ExecaChildProcess, execaNode } from 'execa'
import { gte } from 'semver'
import { gte, satisfies } from 'semver'

import { FeatureFlags } from '../core/feature_flags.js'
import { addErrorInfo } from '../error/info.js'
Expand Down Expand Up @@ -217,5 +218,17 @@ const stopPlugin = async function ({
})
childProcess.disconnect()
}
childProcess.kill()

// On Windows with Node 21+, there's a bug where attempting to kill a child process
// results in an EPERM error. Ignore the error in that case.
// See: https://github.com/nodejs/node/issues/51766
// We also disable execa's `forceKillAfterTimeout` in this case
// which can cause unhandled rejection.
try {
childProcess.kill('SIGTERM', {
forceKillAfterTimeout: platform() === 'win32' && satisfies(process.version, '>=21') ? false : undefined,
})
} catch {
// no-op
}
}
3 changes: 2 additions & 1 deletion packages/build/src/plugins_core/blobs_upload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ const coreStep: CoreStepFunction = async function ({
systemLog(`Uploading blob ${key}`)

const { data, metadata } = await getFileWithMetadata(key, contentPath, metadataPath)
await blobStore.set(key, data, { metadata })
const arrayBuffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.length)
await blobStore.set(key, arrayBuffer, { metadata })
},
{ concurrency: 10 },
)
Expand Down
3 changes: 2 additions & 1 deletion packages/build/src/plugins_core/dev_blobs_upload/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ const coreStep: CoreStepFunction = async function ({
log(logs, `- Uploading blob ${key}`, { indent: true })
}
const { data, metadata } = await getFileWithMetadata(key, contentPath, metadataPath)
await blobStore.set(key, data, { metadata })
const arrayBuffer = data.buffer.slice(data.byteOffset, data.byteOffset + data.length)
await blobStore.set(key, arrayBuffer, { metadata })
},
{ concurrency: 10 },
)
Expand Down
47 changes: 5 additions & 42 deletions packages/config/src/api/site_info.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,53 +35,18 @@ export const getSiteInfo = async function ({
context,
offline = false,
testOpts = {},
featureFlags = {},
siteFeatureFlagPrefix,
}: GetSiteInfoOpts) {
const { env: testEnv = false } = testOpts

const useV2Endpoint = !!accountId && featureFlags.cli_integration_installations_meta

if (useV2Endpoint) {
if (api === undefined || mode === 'buildbot' || testEnv) {
const siteInfo: { id?: string; account_id?: string } = {}

if (siteId !== undefined) siteInfo.id = siteId
if (accountId !== undefined) siteInfo.account_id = accountId

const integrations =
mode === 'buildbot' && !offline
? await getIntegrations({ siteId, testOpts, offline, useV2Endpoint, accountId })
: []

return { siteInfo, accounts: [], addons: [], integrations }
}

const promises = [
getSite(api, siteId, siteFeatureFlagPrefix),
getAccounts(api),
getAddons(api, siteId),
getIntegrations({ siteId, testOpts, offline, useV2Endpoint, accountId }),
]

const [siteInfo, accounts, addons, integrations] = await Promise.all(promises)

if (siteInfo.use_envelope) {
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context })

siteInfo.build_settings.env = envelope
}

return { siteInfo, accounts, addons, integrations }
}

if (api === undefined || mode === 'buildbot' || testEnv) {
const siteInfo: { id?: string; account_id?: string } = {}

if (siteId !== undefined) siteInfo.id = siteId
if (accountId !== undefined) siteInfo.account_id = accountId

const integrations = mode === 'buildbot' && !offline ? await getIntegrations({ siteId, testOpts, offline }) : []
const integrations =
mode === 'buildbot' && !offline ? await getIntegrations({ siteId, testOpts, offline, accountId }) : []

return { siteInfo, accounts: [], addons: [], integrations }
}
Expand All @@ -90,7 +55,7 @@ export const getSiteInfo = async function ({
getSite(api, siteId, siteFeatureFlagPrefix),
getAccounts(api),
getAddons(api, siteId),
getIntegrations({ siteId, testOpts, offline }),
getIntegrations({ siteId, testOpts, offline, accountId }),
]

const [siteInfo, accounts, addons, integrations] = await Promise.all(promises)
Expand Down Expand Up @@ -144,15 +109,13 @@ type GetIntegrationsOpts = {
accountId?: string
testOpts: TestOptions
offline: boolean
useV2Endpoint?: boolean
}

const getIntegrations = async function ({
siteId,
accountId,
testOpts,
offline,
useV2Endpoint,
}: GetIntegrationsOpts): Promise<IntegrationResponse[]> {
if (!siteId || offline) {
return []
Expand All @@ -162,8 +125,8 @@ const getIntegrations = async function ({

const baseUrl = new URL(host ? `http://${host}` : `https://api.netlifysdk.com`)

// use future state feature flag
const url = useV2Endpoint
// if accountId isn't present, use safe v1 endpoint
const url = accountId
? `${baseUrl}team/${accountId}/integrations/installations/meta/${siteId}`
: `${baseUrl}site/${siteId}/integrations/safe`

Expand Down
Loading

0 comments on commit 67ebec1

Please sign in to comment.