Skip to content

Commit

Permalink
fix: pin bootstrap version used in config extraction (#469)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt authored Sep 6, 2023
1 parent 9728d1a commit 19d142d
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 15 deletions.
6 changes: 4 additions & 2 deletions deno/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
const [functionURL, collectorURL, bootstrapURL, rawExitCodes] = Deno.args
// this needs to be updated whenever there's a change to globalThis.Netlify in bootstrap
import { Netlify } from "https://64e8753eae24930008fac6d9--edge.netlify.app/bootstrap/index-combined.ts"

const [functionURL, collectorURL, rawExitCodes] = Deno.args
const exitCodes = JSON.parse(rawExitCodes)

const { Netlify } = await import(bootstrapURL)
globalThis.Netlify = Netlify

let func
Expand Down
5 changes: 2 additions & 3 deletions node/bundler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ const bundle = async (
onBeforeDownload,
systemLogger,
internalSrcFolder,
bootstrapURL = 'https://edge.netlify.com/bootstrap/index-combined.ts',
}: BundleOptions = {},
) => {
const logger = getLogger(systemLogger, debug)
Expand Down Expand Up @@ -115,11 +114,11 @@ const bundle = async (
// Retrieving a configuration object for each function.
// Run `getFunctionConfig` in parallel as it is a non-trivial operation and spins up deno
const internalConfigPromises = internalFunctions.map(
async (func) => [func.name, await getFunctionConfig({ func, importMap, deno, log: logger, bootstrapURL })] as const,
async (func) => [func.name, await getFunctionConfig({ func, importMap, deno, log: logger })] as const,
)

const userConfigPromises = userFunctions.map(
async (func) => [func.name, await getFunctionConfig({ func, importMap, deno, log: logger, bootstrapURL })] as const,
async (func) => [func.name, await getFunctionConfig({ func, importMap, deno, log: logger })] as const,
)

// Creating a hash of function names to configuration objects.
Expand Down
6 changes: 0 additions & 6 deletions node/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@ import { FunctionConfig, getFunctionConfig } from './config.js'
import type { Declaration } from './declaration.js'
import { ImportMap } from './import_map.js'

const bootstrapURL = 'https://edge.netlify.com/bootstrap/index-combined.ts'

const importMapFile = {
baseURL: new URL('file:///some/path/import-map.json'),
imports: {
Expand Down Expand Up @@ -146,7 +144,6 @@ describe('`getFunctionConfig` extracts configuration properties from function fi
importMap: new ImportMap([importMapFile]),
deno,
log: logger,
bootstrapURL,
})

if (func.error) {
Expand Down Expand Up @@ -284,7 +281,6 @@ test('Passes validation if default export exists and is a function', async () =>
importMap: new ImportMap([importMapFile]),
deno,
log: logger,
bootstrapURL,
}),
).resolves.not.toThrow()

Expand Down Expand Up @@ -321,7 +317,6 @@ test('Fails validation if default export is not function', async () => {
importMap: new ImportMap([importMapFile]),
deno,
log: logger,
bootstrapURL,
})

await expect(config).rejects.toThrowError(invalidDefaultExportErr(path))
Expand Down Expand Up @@ -358,7 +353,6 @@ test('Fails validation if default export is not present', async () => {
importMap: new ImportMap([importMapFile]),
deno,
log: logger,
bootstrapURL,
})

await expect(config).rejects.toThrowError(invalidDefaultExportErr(path))
Expand Down
3 changes: 0 additions & 3 deletions node/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,11 @@ export const getFunctionConfig = async ({
func,
importMap,
deno,
bootstrapURL,
log,
}: {
func: EdgeFunction
importMap: ImportMap
deno: DenoBridge
bootstrapURL: string
log: Logger
}) => {
// The extractor is a Deno script that will import the function and run its
Expand Down Expand Up @@ -94,7 +92,6 @@ export const getFunctionConfig = async ({
extractorPath,
pathToFileURL(func.path).href,
pathToFileURL(collector.path).href,
bootstrapURL,
JSON.stringify(ConfigExitCode),
],
{ rejectOnExitCode: false },
Expand Down
2 changes: 1 addition & 1 deletion node/server/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const prepareServer = ({

if (options.getFunctionsConfig) {
functionsConfig = await Promise.all(
functions.map((func) => getFunctionConfig({ func, importMap, deno, bootstrapURL, log: logger })),
functions.map((func) => getFunctionConfig({ func, importMap, deno, log: logger })),
)
}

Expand Down

0 comments on commit 19d142d

Please sign in to comment.