edgedriver
Advanced tools
Comparing version 5.6.0 to 5.6.1
@@ -1,4 +0,3 @@ | ||
/// <reference types="node" /> | ||
declare function start(params: unknown): Promise<import("child_process").ChildProcessWithoutNullStreams>; | ||
declare function download(edgeVersion?: string, cacheDir?: string): Promise<string>; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -12,2 +12,3 @@ import { type Logger } from '@wdio/logger'; | ||
export declare const log: Logger; | ||
export declare const EDGEDRIVER_BUCKET = "https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver?delimiter=%2F&maxresults=2500&restype=container&comp=list&_=1722752483611&timeout=60000"; | ||
//# sourceMappingURL=constants.d.ts.map |
@@ -15,2 +15,3 @@ import os from 'node:os'; | ||
export const log = logger('edgedriver'); | ||
export const EDGEDRIVER_BUCKET = 'https://msedgewebdriverstorage.blob.core.windows.net/edgewebdriver?delimiter=%2F&maxresults=2500&restype=container&comp=list&_=1722752483611&timeout=60000'; | ||
//# sourceMappingURL=constants.js.map |
@@ -117,3 +117,3 @@ /* istanbul ignore file */ | ||
} | ||
catch (err) { | ||
catch { | ||
execPaths = execSync(`grep -Er "${edgeExecRegex}" ${folder} | awk -F '=' '{print $2}'`, { stdio: 'pipe' }); | ||
@@ -120,0 +120,0 @@ } |
@@ -1,2 +0,1 @@ | ||
/// <reference types="node" /> | ||
import cp from 'node:child_process'; | ||
@@ -3,0 +2,0 @@ import { download as downloadDriver } from './install.js'; |
@@ -6,6 +6,7 @@ import path from 'node:path'; | ||
import { format } from 'node:util'; | ||
import { XMLParser } from 'fast-xml-parser'; | ||
import fetch from 'node-fetch'; | ||
import { BlobReader, BlobWriter, ZipReader } from '@zip.js/zip.js'; | ||
import findEdgePath from './finder.js'; | ||
import { TAGGED_VERSIONS, EDGE_PRODUCTS_API, TAGGED_VERSION_URL, LATEST_RELEASE_URL, DOWNLOAD_URL, BINARY_FILE, log } from './constants.js'; | ||
import { TAGGED_VERSIONS, EDGE_PRODUCTS_API, EDGEDRIVER_BUCKET, TAGGED_VERSION_URL, LATEST_RELEASE_URL, DOWNLOAD_URL, BINARY_FILE, log } from './constants.js'; | ||
import { hasAccess, getNameByArchitecture, sleep } from './utils.js'; | ||
@@ -27,8 +28,3 @@ export async function download(edgeVersion = process.env.EDGEDRIVER_VERSION, cacheDir = process.env.EDGEDRIVER_CACHE_DIR || os.tmpdir()) { | ||
const version = await fetchVersion(edgeVersion); | ||
const downloadUrl = format(DOWNLOAD_URL, version, getNameByArchitecture()); | ||
log.info(`Downloading Edgedriver from ${downloadUrl}`); | ||
const res = await fetch(downloadUrl); | ||
if (!res.body) { | ||
throw new Error(`Failed to download binary (statusCode ${res.status})`); | ||
} | ||
const res = await downloadDriver(version); | ||
await fsp.mkdir(cacheDir, { recursive: true }); | ||
@@ -41,2 +37,55 @@ await downloadZip(res, cacheDir); | ||
} | ||
async function downloadDriver(version) { | ||
try { | ||
const downloadUrl = format(DOWNLOAD_URL, version, getNameByArchitecture()); | ||
log.info(`Downloading Edgedriver from ${downloadUrl}`); | ||
const res = await fetch(downloadUrl); | ||
if (!res.body || !res.ok || res.status !== 200) { | ||
throw new Error(`Failed to download binary from ${downloadUrl} (statusCode ${res.status})`); | ||
} | ||
return res; | ||
} | ||
catch (err) { | ||
log.error(`Failed to download Edgedriver: ${err.message}, trying alternative download URL...`); | ||
} | ||
try { | ||
const majorVersion = version.split('.')[0]; | ||
const platform = process.platform === 'darwin' | ||
? 'macos' | ||
: process.platform === 'win32' | ||
? 'windows' | ||
: 'linux'; | ||
log.info(`Attempt to fetch latest v${majorVersion} for ${platform} from ${EDGEDRIVER_BUCKET}`); | ||
const versions = await fetch(EDGEDRIVER_BUCKET, { | ||
headers: { | ||
accept: '*/*', | ||
'accept-language': 'en-US,en;q=0.9', | ||
'cache-control': 'no-cache', | ||
'content-type': 'application/json; charset=utf-8', | ||
pragma: 'no-cache', | ||
} | ||
}); | ||
const parser = new XMLParser(); | ||
const { EnumerationResults } = parser.parse(await versions.text()); | ||
const blobName = `LATEST_RELEASE_${majorVersion}_${platform.toUpperCase()}`; | ||
const alternativeDownloadUrl = EnumerationResults.Blobs.Blob | ||
.find((blob) => blob.Name === blobName).Url; | ||
if (!alternativeDownloadUrl) { | ||
throw new Error(`Couldn't find alternative download URL for ${version}`); | ||
} | ||
log.info(`Downloading alternative Edgedriver version from ${alternativeDownloadUrl}`); | ||
const versionResponse = await fetch(alternativeDownloadUrl); | ||
const alternativeVersion = sanitizeVersion(await versionResponse.text()); | ||
const downloadUrl = format(DOWNLOAD_URL, alternativeVersion, getNameByArchitecture()); | ||
log.info(`Downloading Edgedriver from ${downloadUrl}`); | ||
const res = await fetch(downloadUrl); | ||
if (!res.body || !res.ok || res.status !== 200) { | ||
throw new Error(`Failed to download binary from ${downloadUrl} (statusCode ${res.status})`); | ||
} | ||
return res; | ||
} | ||
catch (err) { | ||
throw new Error(`Failed to download Edgedriver: ${err.message}`); | ||
} | ||
} | ||
async function getEdgeVersionWin(edgePath) { | ||
@@ -118,3 +167,3 @@ const versionPath = path.dirname(edgePath); | ||
const res = await fetch(format(TAGGED_VERSION_URL, edgeVersion.toUpperCase())); | ||
return (await res.text()).replace(/\0/g, '').slice(2).trim(); | ||
return sanitizeVersion(await res.text()); | ||
} | ||
@@ -128,4 +177,8 @@ /** | ||
const url = format(LATEST_RELEASE_URL, major.toString().toUpperCase(), platform.toUpperCase()); | ||
log.info(`Fetching latest version from ${url}`); | ||
const res = await fetch(url); | ||
return (await res.text()).replace(/\0/g, '').slice(2).trim(); | ||
if (!res.ok || res.status !== 200) { | ||
throw new Error(`Couldn't detect version for ${edgeVersion}`); | ||
} | ||
return sanitizeVersion(await res.text()); | ||
} | ||
@@ -150,2 +203,9 @@ throw new Error(`Couldn't detect version for ${edgeVersion}`); | ||
/** | ||
* Fetching the latest version from the CDN contains extra characters that need to be removed, | ||
* e.g. "��127.0.2651.87\n\n" | ||
*/ | ||
function sanitizeVersion(version) { | ||
return version.replace(/\0/g, '').slice(2).trim(); | ||
} | ||
/** | ||
* download on install | ||
@@ -152,0 +212,0 @@ */ |
@@ -68,3 +68,3 @@ import os from 'node:os'; | ||
} | ||
catch (err) { | ||
catch { | ||
// Not installed. | ||
@@ -88,3 +88,3 @@ } | ||
} | ||
catch (err) { | ||
catch { | ||
return false; | ||
@@ -91,0 +91,0 @@ } |
{ | ||
"name": "edgedriver", | ||
"version": "5.6.0", | ||
"version": "5.6.1", | ||
"description": "Microsofts' EdgeDriver for Node.js", | ||
@@ -49,26 +49,29 @@ "homepage": "https://webdriver.io", | ||
"devDependencies": { | ||
"@types/node": "^20.12.12", | ||
"@typescript-eslint/eslint-plugin": "^7.9.0", | ||
"@typescript-eslint/parser": "^7.9.0", | ||
"@vitest/coverage-v8": "^1.6.0", | ||
"eslint": "^8.57.0", | ||
"eslint-plugin-import": "^2.29.1", | ||
"eslint-plugin-unicorn": "^53.0.0", | ||
"husky": "^9.0.11", | ||
"npm-run-all2": "^6.1.2", | ||
"release-it": "^17.2.1", | ||
"@eslint/eslintrc": "^3.1.0", | ||
"@eslint/js": "^9.8.0", | ||
"@types/node": "^22.1.0", | ||
"@typescript-eslint/eslint-plugin": "^8.0.0", | ||
"@typescript-eslint/parser": "^8.0.0", | ||
"@vitest/coverage-v8": "^2.0.5", | ||
"eslint": "^9.8.0", | ||
"eslint-plugin-unicorn": "^55.0.0", | ||
"globals": "^15.9.0", | ||
"husky": "^9.1.4", | ||
"npm-run-all2": "^6.2.2", | ||
"release-it": "^17.6.0", | ||
"ts-node": "^10.9.2", | ||
"typescript": "^5.4.5", | ||
"vitest": "^1.6.0", | ||
"typescript": "^5.5.4", | ||
"vitest": "^2.0.5", | ||
"wait-port": "^1.1.0", | ||
"webdriverio": "^8.36.1" | ||
"webdriverio": "^8.39.1" | ||
}, | ||
"dependencies": { | ||
"@wdio/logger": "^8.28.0", | ||
"@wdio/logger": "^8.38.0", | ||
"@zip.js/zip.js": "^2.7.48", | ||
"decamelize": "^6.0.0", | ||
"edge-paths": "^3.0.5", | ||
"fast-xml-parser": "^4.4.1", | ||
"node-fetch": "^3.3.2", | ||
"which": "^4.0.0", | ||
"@zip.js/zip.js": "^2.7.44" | ||
"which": "^4.0.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
59177
642
7
17
7
+ Addedfast-xml-parser@^4.4.1
+ Addedfast-xml-parser@4.5.0(transitive)
+ Addedstrnum@1.0.5(transitive)
Updated@wdio/logger@^8.38.0
Updated@zip.js/zip.js@^2.7.48