Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: insiders download (#124) #142

Merged
merged 1 commit into from
Feb 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading