Skip to content

Commit

Permalink
fix: insiders download (webdriverio-community#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jay McCure committed Feb 13, 2025
1 parent 06ac26c commit 0e6bdd4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
5 changes: 4 additions & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,11 @@ export const DEFAULT_VSCODE_SETTINGS = {
*/
[SETTINGS_KEY]: {}
}
const VSCODE_RAW_REPO = 'https://raw.githubusercontent.com/microsoft/vscode/'
export const VSCODE_RELEASES = 'https://update.code.visualstudio.com/api/releases/stable'
export const VSCODE_MANIFEST_URL = 'https://raw.githubusercontent.com/microsoft/vscode/%s/cgmanifest.json'
export const VSCODE_INSIDER_RELEASES = 'https://update.code.visualstudio.com/api/releases/insider'
export const VSCODE_MANIFEST_URL = `${VSCODE_RAW_REPO}%s/cgmanifest.json`
export const VSCODE_INSIDER_MANIFEST_URL = `${VSCODE_RAW_REPO}refs/heads/main/cgmanifest.json`
export const VSCODE_WEB_STANDALONE = 'https://update.code.visualstudio.com/api/update/web-standalone/%s/latest'

export const DEFAULT_VSCODE_WEB_HOSTNAME = 'localhost'
Expand Down
22 changes: 15 additions & 7 deletions src/launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ import { HttpsProxyAgent } from 'hpagent'
import startServer from './server/index.js'
import { fileExist, directoryExists } from './utils.js'
import {
DEFAULT_CHANNEL, VSCODE_RELEASES, VSCODE_MANIFEST_URL, DEFAULT_CACHE_PATH,
VSCODE_CAPABILITY_KEY, VSCODE_WEB_STANDALONE, DEFAULT_VSCODE_WEB_HOSTNAME
DEFAULT_CHANNEL, VSCODE_RELEASES, VSCODE_INSIDER_RELEASES, VSCODE_MANIFEST_URL, VSCODE_INSIDER_MANIFEST_URL,
DEFAULT_CACHE_PATH, VSCODE_CAPABILITY_KEY, VSCODE_WEB_STANDALONE, DEFAULT_VSCODE_WEB_HOSTNAME
} from './constants.js'
import type {
ServiceOptions, VSCodeCapabilities, WebStandaloneResponse,
Expand Down Expand Up @@ -201,11 +201,14 @@ export default class VSCodeServiceLauncher {
* @returns "main" if `desiredReleaseChannel` is "insiders" otherwise a concrete VSCode version
*/
private async _fetchVSCodeVersion (desiredReleaseChannel?: string) {
if (desiredReleaseChannel === 'insiders') {
return 'main'
}

try {
if (desiredReleaseChannel === 'insiders') {
log.info(`Fetch latest insider release from ${VSCODE_INSIDER_RELEASES}`)
const { body: versions } = await request(VSCODE_INSIDER_RELEASES, {})
const availableVersions: string[] = await versions.json() as string[]

return availableVersions[0]
}
log.info(`Fetch releases from ${VSCODE_RELEASES}`)
const { body: versions } = await request(VSCODE_RELEASES, {})
const availableVersions: string[] = await versions.json() as string[]
Expand Down Expand Up @@ -240,7 +243,12 @@ export default class VSCodeServiceLauncher {
*/
private async _fetchChromedriverVersion (vscodeVersion: string) {
try {
const { body } = await request(format(VSCODE_MANIFEST_URL, vscodeVersion), {})
const manifestUrl = vscodeVersion.includes('insider')
? VSCODE_INSIDER_MANIFEST_URL
: format(VSCODE_MANIFEST_URL, vscodeVersion)

log.info(`manifest url: ${manifestUrl}`)
const { body } = await request(manifestUrl, {})
const manifest = await body.json() as Manifest
const chromium = manifest.registrations.find((r: any) => r.component.git.name === 'chromium')

Expand Down

0 comments on commit 0e6bdd4

Please sign in to comment.