Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: netlify/build
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 492b2e3de82bc00b0427eac5a12f847bb72404fa
Choose a base ref
...
head repository: netlify/build
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 14419e3fd6fdeaba6d8f4460e5c13871db7f26ef
Choose a head ref
  • 4 commits
  • 29 files changed
  • 8 contributors

Commits on May 29, 2024

  1. feat: log plugin initialisation error on single line (#5684)

    eduardoboucas authored May 29, 2024
    Copy the full SHA
    3aecbfc View commit details
  2. feat: add timeout config prop for functions (#5683)

    Co-authored-by: Antonio Rodríguez <antonio.rodriguez@netlify.com>
    Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
    3 people authored May 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    7bfd4ea View commit details
  3. feat: retrieve integration meta data from new endpoint (#5647)

    * chore: add flag to split logic - in progress
    
    * chore: link
    
    * chore: in progress with ff split
    
    * chore: correct flag
    
    * chore: debug tests
    
    * chore: debug tests
    
    * chore: test coverage added
    
    * chore: remove logs
    
    * chore: change local dep
    
    * chore: remove flag comment
    
    * chore: user v2 as flag var name
    
    * chore: add link to linear issue
    
    * chore: make error func return never
    
    * chore: remove else
    
    * chore: fix typing by return error func that returns never
    
    ---------
    
    Co-authored-by: Lewis Thorley <lewis.thorley@netlify.com>
    Co-authored-by: Karin Hendrikse <30577427+khendrikse@users.noreply.github.com>
    3 people authored May 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    b8899e0 View commit details
  4. chore: release main (#5685)

    netlify-circleci authored May 29, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    14419e3 View commit details
Showing with 390 additions and 52 deletions.
  1. +4 −4 .release-please-manifest.json
  2. +8 −8 package-lock.json
  3. +16 −0 packages/build/CHANGELOG.md
  4. +4 −4 packages/build/package.json
  5. +6 −8 packages/build/src/plugins/system_log.ts
  6. +1 −3 packages/build/tests/plugins/tests.js
  7. +7 −0 packages/config/CHANGELOG.md
  8. +1 −1 packages/config/package.json
  9. +49 −11 packages/config/src/api/site_info.ts
  10. +1 −1 packages/config/src/error.ts
  11. +0 −1 packages/config/src/main.ts
  12. +109 −5 packages/config/tests/api/tests.js
  13. +9 −0 packages/functions-utils/CHANGELOG.md
  14. +2 −2 packages/functions-utils/package.json
  15. +7 −0 packages/zip-it-and-ship-it/CHANGELOG.md
  16. +1 −1 packages/zip-it-and-ship-it/package.json
  17. +1 −0 packages/zip-it-and-ship-it/src/config.ts
  18. +2 −0 packages/zip-it-and-ship-it/src/main.ts
  19. +3 −0 packages/zip-it-and-ship-it/src/manifest.ts
  20. +5 −0 packages/zip-it-and-ship-it/src/runtimes/node/in_source_config/index.ts
  21. +7 −1 packages/zip-it-and-ship-it/src/runtimes/node/index.ts
  22. +1 −0 packages/zip-it-and-ship-it/src/runtimes/runtime.ts
  23. +1 −0 packages/zip-it-and-ship-it/tests/__snapshots__/list_function.test.ts.snap
  24. +25 −0 packages/zip-it-and-ship-it/tests/__snapshots__/list_functions.test.ts.snap
  25. +94 −0 packages/zip-it-and-ship-it/tests/__snapshots__/list_functions_files.test.ts.snap
  26. +2 −1 ...p-it-and-ship-it/tests/fixtures-esm/v2-api-name-generator/.netlify/functions-internal/server.json
  27. +1 −0 ...ip-it-and-ship-it/tests/fixtures-esm/v2-api-name-generator/.netlify/functions-internal/server.mjs
  28. +14 −0 packages/zip-it-and-ship-it/tests/unit/runtimes/node/in_source_config.test.ts
  29. +9 −1 packages/zip-it-and-ship-it/tests/v2api.test.ts
8 changes: 4 additions & 4 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"packages/build-info": "7.13.2",
"packages/build": "29.45.0",
"packages/build": "29.46.0",
"packages/edge-bundler": "12.0.1",
"packages/cache-utils": "5.1.5",
"packages/config": "20.12.6",
"packages/config": "20.13.0",
"packages/framework-info": "9.8.13",
"packages/functions-utils": "5.2.59",
"packages/functions-utils": "5.2.60",
"packages/git-utils": "5.1.1",
"packages/headers-parser": "7.1.4",
"packages/js-client": "13.1.16",
@@ -14,5 +14,5 @@
"packages/run-utils": "5.1.1",
"packages/opentelemetry-sdk-setup": "1.1.3",
"packages/opentelemetry-utils": "1.2.1",
"packages/zip-it-and-ship-it": "9.33.2"
"packages/zip-it-and-ship-it": "9.34.0"
}
16 changes: 8 additions & 8 deletions package-lock.json

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

16 changes: 16 additions & 0 deletions packages/build/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -105,6 +105,22 @@
* dependencies
* @netlify/config bumped from ^20.8.0 to ^20.8.1

## [29.46.0](https://github.com/netlify/build/compare/build-v29.45.0...build-v29.46.0) (2024-05-29)


### Features

* log plugin initialisation error on single line ([#5684](https://github.com/netlify/build/issues/5684)) ([3aecbfc](https://github.com/netlify/build/commit/3aecbfccd2a3eef5cf4889432550423fd594e876))


### Dependencies

* The following workspace dependencies were updated
* dependencies
* @netlify/config bumped from ^20.12.6 to ^20.13.0
* @netlify/functions-utils bumped from ^5.2.59 to ^5.2.60
* @netlify/zip-it-and-ship-it bumped from 9.33.2 to 9.34.0

## [29.45.0](https://github.com/netlify/build/compare/build-v29.44.0...build-v29.45.0) (2024-05-29)


8 changes: 4 additions & 4 deletions packages/build/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@netlify/build",
"version": "29.45.0",
"version": "29.46.0",
"description": "Netlify build module",
"type": "module",
"exports": "./lib/index.js",
@@ -70,15 +70,15 @@
"@bugsnag/js": "^7.0.0",
"@netlify/blobs": "^7.3.0",
"@netlify/cache-utils": "^5.1.5",
"@netlify/config": "^20.12.6",
"@netlify/config": "^20.13.0",
"@netlify/edge-bundler": "12.0.1",
"@netlify/framework-info": "^9.8.13",
"@netlify/functions-utils": "^5.2.59",
"@netlify/functions-utils": "^5.2.60",
"@netlify/git-utils": "^5.1.1",
"@netlify/opentelemetry-utils": "^1.2.1",
"@netlify/plugins-list": "^6.80.0",
"@netlify/run-utils": "^5.1.1",
"@netlify/zip-it-and-ship-it": "9.33.2",
"@netlify/zip-it-and-ship-it": "9.34.0",
"@sindresorhus/slugify": "^2.0.0",
"ansi-escapes": "^6.0.0",
"chalk": "^5.0.0",
14 changes: 6 additions & 8 deletions packages/build/src/plugins/system_log.ts
Original file line number Diff line number Diff line change
@@ -15,22 +15,20 @@ export const captureStandardError = (
}
}

let receivedChunks = false
let buffer = ''

const listener = (chunk: Buffer) => {
if (!receivedChunks) {
receivedChunks = true

systemLog(`Plugin failed to initialize during the "${eventName}" phase`)
}

systemLog(chunk.toString().trimEnd())
buffer += chunk.toString()
}

childProcess.stderr?.on('data', listener)

const cleanup = () => {
childProcess.stderr?.removeListener('data', listener)

if (buffer.length !== 0) {
systemLog(`Plugin failed to initialize during the "${eventName}" phase: ${buffer.trim()}`)
}
}

return cleanup
4 changes: 1 addition & 3 deletions packages/build/tests/plugins/tests.js
Original file line number Diff line number Diff line change
@@ -360,10 +360,8 @@ test('Plugin errors that occur during the loading phase are piped to system logs

if (platform !== 'win32') {
const systemLog = await fs.readFile(systemLogFile.path, { encoding: 'utf8' })
const lines = systemLog.split('\n')

t.is(lines[0].trim(), 'Plugin failed to initialize during the "load" phase')
t.is(lines[1].trim(), 'An error message thrown by Node.js')
t.is(systemLog.trim(), `Plugin failed to initialize during the "load" phase: An error message thrown by Node.js`)
}

t.snapshot(normalizeOutput(output))
7 changes: 7 additions & 0 deletions packages/config/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -76,6 +76,13 @@
* dependencies
* netlify bumped from ^13.1.8 to ^13.1.9

## [20.13.0](https://github.com/netlify/build/compare/config-v20.12.6...config-v20.13.0) (2024-05-29)


### Features

* retrieve integration meta data from new endpoint ([#5647](https://github.com/netlify/build/issues/5647)) ([b8899e0](https://github.com/netlify/build/commit/b8899e06a31f5615ef41d8a4ab251bcc96717837))

## [20.12.6](https://github.com/netlify/build/compare/config-v20.12.5...config-v20.12.6) (2024-05-23)


2 changes: 1 addition & 1 deletion packages/config/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@netlify/config",
"version": "20.12.6",
"version": "20.13.0",
"description": "Netlify config module",
"type": "module",
"exports": "./lib/index.js",
60 changes: 49 additions & 11 deletions packages/config/src/api/site_info.ts
Original file line number Diff line number Diff line change
@@ -14,7 +14,6 @@ type GetSiteInfoOpts = {
offline?: boolean
api?: NetlifyAPI
context?: string
featureFlags?: Record<string, boolean>
testOpts?: TestOptions
}
/**
@@ -37,22 +36,49 @@ export const getSiteInfo = async function ({
}: GetSiteInfoOpts) {
const { env: testEnv = false } = testOpts

if (api === undefined || mode === 'buildbot' || testEnv) {
if (api === undefined || testEnv || offline) {
const siteInfo = siteId === undefined ? {} : { id: siteId }

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

const siteInfo = await getSite(api, siteId, siteFeatureFlagPrefix)
const featureFlags = siteInfo.feature_flags

const useV2Endpoint = featureFlags?.cli_integration_installations_meta

if (useV2Endpoint) {
const promises = [
getAccounts(api),
getAddons(api, siteId),
getIntegrations({ siteId, testOpts, offline, accountId: siteInfo.account_id, featureFlags }),
]

const [accounts, addons, integrations] = await Promise.all<any[]>(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 (mode === 'buildbot') {
const siteInfo = siteId === undefined ? {} : { id: siteId }

const integrations = await getIntegrations({ siteId, testOpts, offline, featureFlags })

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

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

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

if (siteInfo.use_envelope) {
const envelope = await getEnvelope({ api, accountId: siteInfo.account_slug, siteId, context })
@@ -72,7 +98,7 @@ const getSite = async function (api: NetlifyAPI, siteId: string, siteFeatureFlag
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}`)
return throwUserError(`Failed retrieving site data for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`)
}
}

@@ -81,7 +107,7 @@ const getAccounts = async function (api: NetlifyAPI) {
const accounts = await (api as any).listAccountsForUser()
return Array.isArray(accounts) ? accounts : []
} catch (error) {
throwUserError(`Failed retrieving user account: ${error.message}. ${ERROR_CALL_TO_ACTION}`)
return throwUserError(`Failed retrieving user account: ${error.message}. ${ERROR_CALL_TO_ACTION}`)
}
}

@@ -94,20 +120,24 @@ const getAddons = async function (api: NetlifyAPI, siteId: string) {
const addons = await (api as any).listServiceInstancesForSite({ siteId })
return Array.isArray(addons) ? addons : []
} catch (error) {
throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`)
return throwUserError(`Failed retrieving addons for site ${siteId}: ${error.message}. ${ERROR_CALL_TO_ACTION}`)
}
}

type GetIntegrationsOpts = {
siteId?: string
accountId?: string
testOpts: TestOptions
offline: boolean
featureFlags?: Record<string, boolean>
}

const getIntegrations = async function ({
siteId,
accountId,
testOpts,
offline,
featureFlags,
}: GetIntegrationsOpts): Promise<IntegrationResponse[]> {
if (!siteId || offline) {
return []
@@ -117,13 +147,21 @@ const getIntegrations = async function ({

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

const useV2Endpoint = featureFlags?.cli_integration_installations_meta

const url = useV2Endpoint
? `${baseUrl}team/${accountId}/integrations/installations/meta`
: `${baseUrl}site/${siteId}/integrations/safe`

try {
const response = await fetch(`${baseUrl}site/${siteId}/integrations/safe`)
const response = await fetch(url)

const integrations = await response.json()
return Array.isArray(integrations) ? integrations : []
} catch (error) {
// for now, we'll just ignore errors, as this is early days
// Integrations should not block the build if they fail to load
// TODO: We should consider blocking the build as integrations are a critical part of the build process
// https://linear.app/netlify/issue/CT-1214/implement-strategy-in-builds-to-deal-with-integrations-that-we-fail-to
return []
}
}
2 changes: 1 addition & 1 deletion packages/config/src/error.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// We distinguish between errors thrown intentionally and uncaught exceptions
// (such as bugs) with a `customErrorInfo.type` property.
export const throwUserError = function (messageOrError: string | Error, error?: Error) {
export const throwUserError = function (messageOrError: string | Error, error?: Error): never {
const errorA = getError(messageOrError, error)
errorA[CUSTOM_ERROR_KEY] = { type: USER_ERROR_TYPE }
throw errorA
1 change: 0 additions & 1 deletion packages/config/src/main.ts
Original file line number Diff line number Diff line change
@@ -73,7 +73,6 @@ export const resolveConfig = async function (opts) {
mode,
offline,
siteFeatureFlagPrefix,
featureFlags,
testOpts,
})

Loading