@netlify/edge-bundler 1.12.1 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/deno/bundle.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { writeStage2 } from 'https://62ea8d05a6858300091547ed--edge.netlify.com/bundler/mod.ts'
1
+ import { writeStage2 } from 'https://62f5f45fbc76ed0009624267--edge.netlify.com/bundler/mod.ts'
2
2
 
3
3
  const [payload] = Deno.args
4
4
  const { basePath, destPath, functions, imports } = JSON.parse(payload)
package/dist/bridge.js CHANGED
@@ -27,7 +27,7 @@ class DenoBridge {
27
27
  await ((_a = this.onBeforeDownload) === null || _a === void 0 ? void 0 : _a.call(this));
28
28
  await this.ensureCacheDirectory();
29
29
  this.logger.system(`Downloading Deno CLI to ${this.cacheDirectory}`);
30
- const binaryPath = await download(this.cacheDirectory, this.versionRange);
30
+ const binaryPath = await download(this.cacheDirectory, this.versionRange, this.logger);
31
31
  const downloadedVersion = await this.getBinaryVersion(binaryPath);
32
32
  // We should never get here, because it means that `DENO_VERSION_RANGE` is
33
33
  // a malformed semver range. If this does happen, let's throw an error so
@@ -35,6 +35,7 @@ class DenoBridge {
35
35
  if (downloadedVersion === undefined) {
36
36
  const error = new Error('There was a problem setting up the Edge Functions environment. To try a manual installation, visit https://ntl.fyi/install-deno.');
37
37
  await ((_b = this.onAfterDownload) === null || _b === void 0 ? void 0 : _b.call(this, error));
38
+ this.logger.system('Could not run downloaded Deno CLI', error);
38
39
  throw error;
39
40
  }
40
41
  await this.writeVersionFile(downloadedVersion);
@@ -46,13 +47,12 @@ class DenoBridge {
46
47
  const { stdout } = await execa(binaryPath, ['--version']);
47
48
  const version = stdout.match(/^deno ([\d.]+)/);
48
49
  if (!version) {
50
+ this.logger.system(`getBinaryVersion no version found. binaryPath ${binaryPath}`);
49
51
  return;
50
52
  }
51
53
  return version[1];
52
54
  }
53
- catch (error) {
54
- this.logger.system('Error checking Deno binary version', error);
55
- }
55
+ catch { }
56
56
  }
57
57
  async getCachedBinary() {
58
58
  const versionFilePath = path.join(this.cacheDirectory, DENO_VERSION_FILE);
@@ -60,10 +60,12 @@ class DenoBridge {
60
60
  try {
61
61
  cachedVersion = await fs.readFile(versionFilePath, 'utf8');
62
62
  }
63
- catch {
63
+ catch (error) {
64
+ this.logger.system('Error getting cached binary', error);
64
65
  return;
65
66
  }
66
67
  if (!semver.satisfies(cachedVersion, this.versionRange)) {
68
+ this.logger.system(`semver not satisfied. cachedVersion: ${cachedVersion}, versionRange: ${this.versionRange}`);
67
69
  return;
68
70
  }
69
71
  const binaryName = `deno${getBinaryExtension()}`;
@@ -76,6 +78,7 @@ class DenoBridge {
76
78
  const globalBinaryName = 'deno';
77
79
  const globalVersion = await this.getBinaryVersion(globalBinaryName);
78
80
  if (globalVersion === undefined || !semver.satisfies(globalVersion, this.versionRange)) {
81
+ this.logger.system(`No globalVersion or semver not satisfied. globalVersion: ${globalVersion}, versionRange: ${this.versionRange}`);
79
82
  return;
80
83
  }
81
84
  return globalBinaryName;
@@ -1,2 +1,3 @@
1
- declare const download: (targetDirectory: string, versionRange: string) => Promise<string>;
1
+ import { Logger } from './logger.js';
2
+ declare const download: (targetDirectory: string, versionRange: string, logger: Logger) => Promise<string>;
2
3
  export { download };
@@ -2,11 +2,12 @@ import fs from 'fs';
2
2
  import path from 'path';
3
3
  import fetch from 'node-fetch';
4
4
  import StreamZip from 'node-stream-zip';
5
+ import pRetry from 'p-retry';
5
6
  import semver from 'semver';
6
7
  import { getBinaryExtension, getPlatformTarget } from './platform.js';
7
- const download = async (targetDirectory, versionRange) => {
8
+ const download = async (targetDirectory, versionRange, logger) => {
8
9
  const zipPath = path.join(targetDirectory, 'deno-cli-latest.zip');
9
- const data = await downloadVersion(versionRange);
10
+ const data = await downloadVersionWithRetry(versionRange, logger);
10
11
  const binaryName = `deno${getBinaryExtension()}`;
11
12
  const binaryPath = path.join(targetDirectory, binaryName);
12
13
  const file = fs.createWriteStream(zipPath);
@@ -33,6 +34,12 @@ const downloadVersion = async (versionRange) => {
33
34
  }
34
35
  return res.body;
35
36
  };
37
+ const downloadVersionWithRetry = async (versionRange, logger) => await pRetry(async () => await downloadVersion(versionRange), {
38
+ retries: 3,
39
+ onFailedAttempt: (error) => {
40
+ logger.system('Deno CLI download retry attempt error', error);
41
+ },
42
+ });
36
43
  const extractBinaryFromZip = async (zipPath, binaryPath, binaryName) => {
37
44
  const { async: StreamZipAsync } = StreamZip;
38
45
  const zip = new StreamZipAsync({ file: zipPath });
@@ -5,7 +5,7 @@ import { pathToFileURL } from 'url';
5
5
  import del from 'del';
6
6
  import { wrapBundleError } from '../bundle_error.js';
7
7
  import { getFileHash } from '../utils/sha256.js';
8
- const BOOTSTRAP_LATEST = 'https://62ea8d05a6858300091547ed--edge.netlify.com/bootstrap/index-combined.ts';
8
+ const BOOTSTRAP_LATEST = 'https://62f5f45fbc76ed0009624267--edge.netlify.com/bootstrap/index-combined.ts';
9
9
  const bundleJS = async ({ buildID, debug, deno, distDirectory, functions, importMap, }) => {
10
10
  const stage2Path = await generateStage2({ distDirectory, functions, fileName: `${buildID}-pre.js` });
11
11
  const extension = '.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@netlify/edge-bundler",
3
- "version": "1.12.1",
3
+ "version": "1.13.0",
4
4
  "description": "Intelligently prepare Netlify Edge Functions for deployment",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -86,6 +86,7 @@
86
86
  "glob-to-regexp": "^0.4.1",
87
87
  "node-fetch": "^3.1.1",
88
88
  "node-stream-zip": "^1.15.0",
89
+ "p-retry": "^5.1.1",
89
90
  "p-wait-for": "^4.1.0",
90
91
  "path-key": "^4.0.0",
91
92
  "semver": "^7.3.5",