@netlify/edge-bundler
Advanced tools
Comparing version 8.14.1 to 8.14.2
@@ -56,3 +56,3 @@ import { Buffer } from 'buffer'; | ||
expect(output).toBe('LULU=LALA'); | ||
await rm(tmpDir.path, { force: true, recursive: true }); | ||
await rm(tmpDir.path, { force: true, recursive: true, maxRetries: 10 }); | ||
}); | ||
@@ -82,3 +82,3 @@ test('Does inherit environment variables if `extendEnv` is true', async () => { | ||
expect(environmentVariables).toEqual(['LULU=LALA', 'TADA=TUDU']); | ||
await rm(tmpDir.path, { force: true, recursive: true }); | ||
await rm(tmpDir.path, { force: true, recursive: true, maxRetries: 10 }); | ||
}); | ||
@@ -108,3 +108,3 @@ test('Does inherit environment variables if `extendEnv` is not set', async () => { | ||
expect(environmentVariables).toEqual(['LULU=LALA', 'TADA=TUDU']); | ||
await rm(tmpDir.path, { force: true, recursive: true }); | ||
await rm(tmpDir.path, { force: true, recursive: true, maxRetries: 10 }); | ||
}); |
@@ -1,6 +0,5 @@ | ||
import { promises as fs } from 'fs'; | ||
import { access, readdir, readFile, rm, writeFile } from 'fs/promises'; | ||
import { join, resolve } from 'path'; | ||
import process from 'process'; | ||
import { pathToFileURL } from 'url'; | ||
import { deleteAsync } from 'del'; | ||
import tmp from 'tmp-promise'; | ||
@@ -29,6 +28,6 @@ import { test, expect, vi } from 'vitest'; | ||
}); | ||
const generatedFiles = await fs.readdir(distPath); | ||
const generatedFiles = await readdir(distPath); | ||
expect(result.functions.length).toBe(3); | ||
expect(generatedFiles.length).toBe(2); | ||
const manifestFile = await fs.readFile(resolve(distPath, 'manifest.json'), 'utf8'); | ||
const manifestFile = await readFile(resolve(distPath, 'manifest.json'), 'utf8'); | ||
const manifest = JSON.parse(manifestFile); | ||
@@ -61,6 +60,6 @@ expect(() => validateManifest(manifest)).not.toThrowError(); | ||
}); | ||
const generatedFiles = await fs.readdir(distPath); | ||
const generatedFiles = await readdir(distPath); | ||
expect(result.functions.length).toBe(1); | ||
expect(generatedFiles.length).toBe(2); | ||
const manifestFile = await fs.readFile(resolve(distPath, 'manifest.json'), 'utf8'); | ||
const manifestFile = await readFile(resolve(distPath, 'manifest.json'), 'utf8'); | ||
const manifest = JSON.parse(manifestFile); | ||
@@ -169,6 +168,6 @@ const { bundles } = manifest; | ||
const result = await bundle([sourceDirectory], distPath, declarations, options); | ||
const outFiles = await fs.readdir(distPath); | ||
const outFiles = await readdir(distPath); | ||
expect(result.functions.length).toBe(1); | ||
expect(outFiles.length).toBe(2); | ||
const denoDir = await fs.readdir(join(cacheDir.path, 'deno_dir')); | ||
const denoDir = await readdir(join(cacheDir.path, 'deno_dir')); | ||
expect(denoDir.includes('gen')).toBe(true); | ||
@@ -190,6 +189,6 @@ await cleanup(); | ||
}); | ||
const generatedFiles = await fs.readdir(distPath); | ||
const generatedFiles = await readdir(distPath); | ||
expect(result.functions.length).toBe(1); | ||
expect(generatedFiles.length).toBe(2); | ||
const manifestFile = await fs.readFile(resolve(distPath, 'manifest.json'), 'utf8'); | ||
const manifestFile = await readFile(resolve(distPath, 'manifest.json'), 'utf8'); | ||
const manifest = JSON.parse(manifestFile); | ||
@@ -219,3 +218,3 @@ const { bundles } = manifest; | ||
}; | ||
await fs.writeFile(importMapFile.path, JSON.stringify(importMap)); | ||
await writeFile(importMapFile.path, JSON.stringify(importMap)); | ||
// Deno configuration files need to be in the current working directory. | ||
@@ -230,3 +229,3 @@ // There's not a great way for us to set the working directory of the `deno` | ||
try { | ||
await fs.access(denoConfigPath); | ||
await access(denoConfigPath); | ||
throw new Error(`The file at '${denoConfigPath} would be overwritten by this test. Please move the file to a different location and try again.'`); | ||
@@ -239,3 +238,3 @@ } | ||
} | ||
await fs.writeFile(denoConfigPath, JSON.stringify(denoConfig)); | ||
await writeFile(denoConfigPath, JSON.stringify(denoConfig)); | ||
expect(() => bundle([sourceDirectory], distPath, declarations, { | ||
@@ -246,3 +245,4 @@ basePath, | ||
await cleanup(); | ||
await deleteAsync([denoConfigPath, importMapFile.path], { force: true }); | ||
await rm(denoConfigPath, { force: true, recursive: true, maxRetries: 10 }); | ||
await rm(importMapFile.path, { force: true, recursive: true, maxRetries: 10 }); | ||
}); | ||
@@ -263,6 +263,6 @@ test('Processes a function that imports a custom layer', async () => { | ||
}); | ||
const generatedFiles = await fs.readdir(distPath); | ||
const generatedFiles = await readdir(distPath); | ||
expect(result.functions.length).toBe(1); | ||
expect(generatedFiles.length).toBe(2); | ||
const manifestFile = await fs.readFile(resolve(distPath, 'manifest.json'), 'utf8'); | ||
const manifestFile = await readFile(resolve(distPath, 'manifest.json'), 'utf8'); | ||
const manifest = JSON.parse(manifestFile); | ||
@@ -290,6 +290,6 @@ const { bundles, layers } = manifest; | ||
}); | ||
const generatedFiles = await fs.readdir(distPath); | ||
const generatedFiles = await readdir(distPath); | ||
expect(result.functions.length).toBe(3); | ||
expect(generatedFiles.length).toBe(2); | ||
const manifestFile = await fs.readFile(resolve(distPath, 'manifest.json'), 'utf8'); | ||
const manifestFile = await readFile(resolve(distPath, 'manifest.json'), 'utf8'); | ||
const manifest = JSON.parse(manifestFile); | ||
@@ -330,3 +330,3 @@ const { bundles, function_config: functionConfig } = manifest; | ||
}; | ||
await fs.writeFile(importMap.path, JSON.stringify(importMapContents)); | ||
await writeFile(importMap.path, JSON.stringify(importMapContents)); | ||
const nonExistingImportMapPath = join(distPath, 'some-file-that-does-not-exist.json'); | ||
@@ -343,3 +343,3 @@ const result = await bundle([sourceDirectory], distPath, [ | ||
}); | ||
const generatedFiles = await fs.readdir(distPath); | ||
const generatedFiles = await readdir(distPath); | ||
expect(result.functions.length).toBe(2); | ||
@@ -346,0 +346,0 @@ expect(generatedFiles.length).toBe(2); |
import { promises as fs } from 'fs'; | ||
import { rm } from 'fs/promises'; | ||
import { join, resolve } from 'path'; | ||
import { pathToFileURL } from 'url'; | ||
import { deleteAsync } from 'del'; | ||
import tmp from 'tmp-promise'; | ||
@@ -132,3 +132,3 @@ import { test, expect, vi, describe } from 'vitest'; | ||
} | ||
await deleteAsync(tmpDir, { force: true }); | ||
await rm(tmpDir, { force: true, recursive: true, maxRetries: 10 }); | ||
}); | ||
@@ -200,3 +200,3 @@ }); | ||
}, new ImportMap([importMapFile]), deno, logger)).resolves.not.toThrow(); | ||
await deleteAsync(tmpDir, { force: true }); | ||
await rm(tmpDir, { force: true, recursive: true, maxRetries: 10 }); | ||
}); | ||
@@ -226,3 +226,3 @@ test('Fails validation if default export is not function', async () => { | ||
await expect(config).rejects.toThrowError(invalidDefaultExportErr(path)); | ||
await deleteAsync(tmpDir, { force: true }); | ||
await rm(tmpDir, { force: true, recursive: true, maxRetries: 10 }); | ||
}); | ||
@@ -251,3 +251,3 @@ test('Fails validation if default export is not present', async () => { | ||
await expect(config).rejects.toThrowError(invalidDefaultExportErr(path)); | ||
await deleteAsync(tmpDir, { force: true }); | ||
await rm(tmpDir, { force: true, recursive: true, maxRetries: 10 }); | ||
}); |
@@ -45,3 +45,2 @@ import { createWriteStream, promises as fs } from 'fs'; | ||
const res = await fetch(url); | ||
// eslint-disable-next-line no-magic-numbers | ||
if (res.body === null || res.status < 200 || res.status > 299) { | ||
@@ -48,0 +47,0 @@ throw new Error(`Download failed with status code ${res.status}`); |
@@ -33,3 +33,3 @@ import { rm } from 'fs/promises'; | ||
afterEach(async (ctx) => { | ||
await rm(ctx.tmpDir, { force: true, recursive: true }); | ||
await rm(ctx.tmpDir, { force: true, recursive: true, maxRetries: 10 }); | ||
}); | ||
@@ -36,0 +36,0 @@ test('tries downloading binary up to 4 times', async (ctx) => { |
@@ -1,13 +0,12 @@ | ||
import { promises as fs } from 'fs'; | ||
import { mkdir, rm, writeFile } from 'fs/promises'; | ||
import { join } from 'path'; | ||
import { pathToFileURL } from 'url'; | ||
import { deleteAsync } from 'del'; | ||
const defaultFormatExportTypeError = (name) => `The Edge Function "${name}" has failed to load. Does it have a function as the default export?`; | ||
const defaultFormatImportError = (name) => `There was an error with Edge Function "${name}".`; | ||
const generateStage2 = async ({ bootstrapURL, distDirectory, fileName, formatExportTypeError, formatImportError, functions, }) => { | ||
await deleteAsync(distDirectory, { force: true }); | ||
await fs.mkdir(distDirectory, { recursive: true }); | ||
await rm(distDirectory, { force: true, recursive: true, maxRetries: 3 }); | ||
await mkdir(distDirectory, { recursive: true }); | ||
const entryPoint = getLocalEntryPoint(functions, { bootstrapURL, formatExportTypeError, formatImportError }); | ||
const stage2Path = join(distDirectory, fileName); | ||
await fs.writeFile(stage2Path, entryPoint); | ||
await writeFile(stage2Path, entryPoint); | ||
return stage2Path; | ||
@@ -14,0 +13,0 @@ }; |
@@ -46,3 +46,3 @@ import { Buffer } from 'buffer'; | ||
expect(afterDownload).toHaveBeenCalledTimes(1); | ||
await rm(tmpDir.path, { force: true, recursive: true }); | ||
await rm(tmpDir.path, { force: true, recursive: true, maxRetries: 10 }); | ||
}); |
@@ -1,5 +0,4 @@ | ||
import { promises as fs } from 'fs'; | ||
import { rm, writeFile } from 'fs/promises'; | ||
import { join } from 'path'; | ||
import { pathToFileURL } from 'url'; | ||
import { deleteAsync } from 'del'; | ||
import { execa } from 'execa'; | ||
@@ -26,3 +25,3 @@ import tmp from 'tmp-promise'; | ||
const bootstrapURL = pathToFileURL(printerPath).toString(); | ||
await fs.writeFile(printerPath, printer); | ||
await writeFile(printerPath, printer); | ||
const functions = [ | ||
@@ -34,7 +33,7 @@ { name: 'func1', path: join(tmpDir, 'func1.mjs'), response: 'Hello from function 1' }, | ||
const contents = `export default () => ${JSON.stringify(func.response)}`; | ||
await fs.writeFile(func.path, contents); | ||
await writeFile(func.path, contents); | ||
} | ||
const stage2 = getLocalEntryPoint(functions.map(({ name, path }) => ({ name, path })), { bootstrapURL }); | ||
const stage2Path = join(tmpDir, 'stage2.mjs'); | ||
await fs.writeFile(stage2Path, stage2); | ||
await writeFile(stage2Path, stage2); | ||
const { stdout, stderr } = await execa('deno', ['run', '--allow-all', stage2Path]); | ||
@@ -47,3 +46,3 @@ expect(stderr).toBe(''); | ||
} | ||
await deleteAsync(tmpDir, { force: true }); | ||
await rm(tmpDir, { force: true, recursive: true }); | ||
}); |
@@ -27,3 +27,3 @@ import { readFile, rm, writeFile } from 'fs/promises'; | ||
mock.mockRestore(); | ||
await rm(tmpDir.path, { force: true, recursive: true }); | ||
await rm(tmpDir.path, { force: true, recursive: true, maxRetries: 10 }); | ||
}); | ||
@@ -47,3 +47,3 @@ test('`ensureLatestTypes` does not update the Deno CLI cache if the local version of types is up-to-date', async () => { | ||
mock.mockRestore(); | ||
await rm(tmpDir.path, { force: true, recursive: true }); | ||
await rm(tmpDir.path, { force: true, recursive: true, maxRetries: 10 }); | ||
}); | ||
@@ -64,3 +64,3 @@ test('`ensureLatestTypes` does not throw if the types URL is not available', async () => { | ||
mock.mockRestore(); | ||
await rm(tmpDir.path, { force: true, recursive: true }); | ||
await rm(tmpDir.path, { force: true, recursive: true, maxRetries: 10 }); | ||
}); |
{ | ||
"name": "@netlify/edge-bundler", | ||
"version": "8.14.1", | ||
"version": "8.14.2", | ||
"description": "Intelligently prepare Netlify Edge Functions for deployment", | ||
@@ -81,3 +81,2 @@ "type": "module", | ||
"common-path-prefix": "^3.0.0", | ||
"del": "^7.0.0", | ||
"env-paths": "^3.0.0", | ||
@@ -84,0 +83,0 @@ "execa": "^6.0.0", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
3096903
21
7766
27
- Removeddel@^7.0.0
- Removed@nodelib/fs.scandir@2.1.5(transitive)
- Removed@nodelib/fs.stat@2.0.5(transitive)
- Removed@nodelib/fs.walk@1.2.8(transitive)
- Removedaggregate-error@4.0.1(transitive)
- Removedbalanced-match@1.0.2(transitive)
- Removedbrace-expansion@1.1.11(transitive)
- Removedbraces@3.0.3(transitive)
- Removedclean-stack@4.2.0(transitive)
- Removedconcat-map@0.0.1(transitive)
- Removeddel@7.1.0(transitive)
- Removeddir-glob@3.0.1(transitive)
- Removedescape-string-regexp@5.0.0(transitive)
- Removedfast-glob@3.3.2(transitive)
- Removedfastq@1.17.1(transitive)
- Removedfill-range@7.1.1(transitive)
- Removedfs.realpath@1.0.0(transitive)
- Removedglob@7.2.3(transitive)
- Removedglob-parent@5.1.2(transitive)
- Removedglobby@13.2.2(transitive)
- Removedgraceful-fs@4.2.11(transitive)
- Removedignore@5.3.2(transitive)
- Removedindent-string@5.0.0(transitive)
- Removedinflight@1.0.6(transitive)
- Removedinherits@2.0.4(transitive)
- Removedis-extglob@2.1.1(transitive)
- Removedis-glob@4.0.3(transitive)
- Removedis-number@7.0.0(transitive)
- Removedis-path-cwd@3.0.0(transitive)
- Removedmerge2@1.4.1(transitive)
- Removedmicromatch@4.0.8(transitive)
- Removedminimatch@3.1.2(transitive)
- Removedonce@1.4.0(transitive)
- Removedp-map@5.5.0(transitive)
- Removedpath-is-absolute@1.0.1(transitive)
- Removedpath-type@4.0.0(transitive)
- Removedpicomatch@2.3.1(transitive)
- Removedqueue-microtask@1.2.3(transitive)
- Removedreusify@1.0.4(transitive)
- Removedrimraf@3.0.2(transitive)
- Removedrun-parallel@1.2.0(transitive)
- Removedslash@4.0.0(transitive)
- Removedto-regex-range@5.0.1(transitive)
- Removedwrappy@1.0.2(transitive)