@netlify/edge-bundler 14.7.0 → 14.7.1
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/dist/node/bridge.d.ts +7 -1
- package/dist/node/bridge.js +23 -12
- package/dist/node/bridge.test.js +38 -0
- package/dist/node/config.js +2 -1
- package/package.json +2 -2
package/dist/node/bridge.d.ts
CHANGED
|
@@ -40,7 +40,13 @@ export declare class DenoBridge {
|
|
|
40
40
|
versionRange: string;
|
|
41
41
|
constructor(options: DenoOptions);
|
|
42
42
|
private downloadBinary;
|
|
43
|
-
getBinaryVersion(binaryPath: string): Promise<
|
|
43
|
+
getBinaryVersion(binaryPath: string): Promise<{
|
|
44
|
+
version: string;
|
|
45
|
+
error?: undefined;
|
|
46
|
+
} | {
|
|
47
|
+
version?: undefined;
|
|
48
|
+
error: Error;
|
|
49
|
+
}>;
|
|
44
50
|
private getCachedBinary;
|
|
45
51
|
private getGlobalBinary;
|
|
46
52
|
private getRemoteBinary;
|
package/dist/node/bridge.js
CHANGED
|
@@ -40,17 +40,27 @@ export class DenoBridge {
|
|
|
40
40
|
await this.ensureCacheDirectory();
|
|
41
41
|
this.logger.system(`Downloading Deno CLI to ${this.cacheDirectory}`);
|
|
42
42
|
const binaryPath = await download(this.cacheDirectory, this.versionRange, this.logger);
|
|
43
|
-
const
|
|
44
|
-
//
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
const result = await this.getBinaryVersion(binaryPath);
|
|
44
|
+
// If we can't execute the downloaded binary, provide actionable info to diagnose and self-heal if possible
|
|
45
|
+
if (result.error) {
|
|
46
|
+
const error = new Error(`Failed to set up Deno for Edge Functions.
|
|
47
|
+
Error: ${result.error.message}
|
|
48
|
+
Downloaded to: ${binaryPath}
|
|
49
|
+
Platform: ${process.platform}/${process.arch}
|
|
50
|
+
|
|
51
|
+
This may be caused by permissions, antivirus software, or platform incompatibility.
|
|
52
|
+
|
|
53
|
+
Try clearing the Deno cache directory and retrying:
|
|
54
|
+
${this.cacheDirectory}
|
|
55
|
+
|
|
56
|
+
Supported Deno versions: ${this.versionRange}
|
|
57
|
+
|
|
58
|
+
To install Deno manually: https://ntl.fyi/install-deno`);
|
|
49
59
|
await this.onAfterDownload?.(error);
|
|
50
60
|
this.logger.system('Could not run downloaded Deno CLI', error);
|
|
51
61
|
throw error;
|
|
52
62
|
}
|
|
53
|
-
await this.writeVersionFile(
|
|
63
|
+
await this.writeVersionFile(result.version);
|
|
54
64
|
await this.onAfterDownload?.();
|
|
55
65
|
return binaryPath;
|
|
56
66
|
}
|
|
@@ -60,12 +70,13 @@ export class DenoBridge {
|
|
|
60
70
|
const version = stdout.match(/^deno ([\d.]+)/);
|
|
61
71
|
if (!version) {
|
|
62
72
|
this.logger.system(`getBinaryVersion no version found. binaryPath ${binaryPath}`);
|
|
63
|
-
return;
|
|
73
|
+
return { error: new Error('Could not parse Deno version from output') };
|
|
64
74
|
}
|
|
65
|
-
return version[1];
|
|
75
|
+
return { version: version[1] };
|
|
66
76
|
}
|
|
67
77
|
catch (error) {
|
|
68
78
|
this.logger.system('getBinaryVersion failed', error);
|
|
79
|
+
return { error: error instanceof Error ? error : new Error(String(error)) };
|
|
69
80
|
}
|
|
70
81
|
}
|
|
71
82
|
async getCachedBinary() {
|
|
@@ -90,9 +101,9 @@ export class DenoBridge {
|
|
|
90
101
|
return;
|
|
91
102
|
}
|
|
92
103
|
const globalBinaryName = 'deno';
|
|
93
|
-
const
|
|
94
|
-
if (
|
|
95
|
-
this.logger.system(`No globalVersion or semver not satisfied. globalVersion: ${
|
|
104
|
+
const result = await this.getBinaryVersion(globalBinaryName);
|
|
105
|
+
if (result.error || !semver.satisfies(result.version, this.versionRange)) {
|
|
106
|
+
this.logger.system(`No globalVersion or semver not satisfied. globalVersion: ${result.version}, versionRange: ${this.versionRange}`);
|
|
96
107
|
return;
|
|
97
108
|
}
|
|
98
109
|
return globalBinaryName;
|
package/dist/node/bridge.test.js
CHANGED
|
@@ -101,3 +101,41 @@ test('Does inherit environment variables if `extendEnv` is not set', async () =>
|
|
|
101
101
|
expect(environmentVariables).toEqual(['LULU=LALA', 'TADA=TUDU']);
|
|
102
102
|
await rm(tmpDir.path, { force: true, recursive: true, maxRetries: 10 });
|
|
103
103
|
});
|
|
104
|
+
test('Provides actionable error message when downloaded binary cannot be executed', async () => {
|
|
105
|
+
const tmpDir = await tmp.dir();
|
|
106
|
+
const latestVersion = semver.minVersion(DENO_VERSION_RANGE)?.version ?? '';
|
|
107
|
+
const data = new PassThrough();
|
|
108
|
+
const archive = archiver('zip', { zlib: { level: 9 } });
|
|
109
|
+
archive.pipe(data);
|
|
110
|
+
// Create a binary that will fail to execute (invalid content)
|
|
111
|
+
archive.append(Buffer.from('invalid binary content'), {
|
|
112
|
+
name: platform === 'win32' ? 'deno.exe' : 'deno',
|
|
113
|
+
});
|
|
114
|
+
archive.finalize();
|
|
115
|
+
const target = getPlatformTarget();
|
|
116
|
+
nock('https://dl.deno.land').get('/release-latest.txt').reply(200, `v${latestVersion}`);
|
|
117
|
+
nock('https://dl.deno.land')
|
|
118
|
+
.get(`/release/v${latestVersion}/deno-${target}.zip`)
|
|
119
|
+
.reply(200, () => data);
|
|
120
|
+
const deno = new DenoBridge({
|
|
121
|
+
cacheDirectory: tmpDir.path,
|
|
122
|
+
useGlobal: false,
|
|
123
|
+
});
|
|
124
|
+
try {
|
|
125
|
+
await deno.getBinaryPath();
|
|
126
|
+
expect.fail('Should have thrown an error');
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
expect(error).toBeInstanceOf(Error);
|
|
130
|
+
const errorMessage = error.message;
|
|
131
|
+
expect(errorMessage).toContain('Failed to set up Deno for Edge Functions');
|
|
132
|
+
expect(errorMessage).toMatch(/Error:/);
|
|
133
|
+
expect(errorMessage).toMatch(/Downloaded to: .+deno(\.exe)?/);
|
|
134
|
+
expect(errorMessage).toContain(tmpDir.path);
|
|
135
|
+
expect(errorMessage).toMatch(/Platform: (darwin|linux|win32)\/(x64|arm64|ia32)/);
|
|
136
|
+
expect(errorMessage).toContain('This may be caused by permissions, antivirus software, or platform incompatibility');
|
|
137
|
+
expect(errorMessage).toContain('Try clearing the Deno cache directory and retrying');
|
|
138
|
+
expect(errorMessage).toContain('https://ntl.fyi/install-deno');
|
|
139
|
+
}
|
|
140
|
+
await rm(tmpDir.path, { force: true, recursive: true, maxRetries: 10 });
|
|
141
|
+
});
|
package/dist/node/config.js
CHANGED
|
@@ -38,7 +38,8 @@ export const getFunctionConfig = async ({ deno, functionPath, importMap, log, })
|
|
|
38
38
|
// with the extractor.
|
|
39
39
|
const collector = await tmp.file();
|
|
40
40
|
// Retrieving the version of Deno.
|
|
41
|
-
const
|
|
41
|
+
const result = await deno.getBinaryVersion((await deno.getBinaryPath({ silent: true })).path);
|
|
42
|
+
const version = new SemVer(result.version || '');
|
|
42
43
|
// The extractor will use its exit code to signal different error scenarios,
|
|
43
44
|
// based on the list of exit codes we send as an argument. We then capture
|
|
44
45
|
// the exit code to know exactly what happened and guide people accordingly.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/edge-bundler",
|
|
3
|
-
"version": "14.7.
|
|
3
|
+
"version": "14.7.1",
|
|
4
4
|
"description": "Intelligently prepare Netlify Edge Functions for deployment",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/node/index.js",
|
|
@@ -80,5 +80,5 @@
|
|
|
80
80
|
"urlpattern-polyfill": "8.0.2",
|
|
81
81
|
"uuid": "^11.0.0"
|
|
82
82
|
},
|
|
83
|
-
"gitHead": "
|
|
83
|
+
"gitHead": "b08cf327fc8a631e3520c5f3326ace1d40e22c85"
|
|
84
84
|
}
|