diff --git a/.vscode/settings.json b/.vscode/settings.json index 30bf48efe64..184042b4f2e 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,6 +6,7 @@ ".build": true, ".profile-oss": true, "**/.DS_Store": true, + "cli/target": true, "build/**/*.js": { "when": "$(basename).ts" } @@ -86,6 +87,11 @@ "editor.defaultFormatter": "vscode.typescript-language-features", "editor.formatOnSave": true }, + "[rust]": { + "editor.defaultFormatter": "rust-lang.rust-analyzer", + "editor.formatOnSave": true, + "editor.insertSpaces": true + }, "typescript.tsc.autoDetect": "off", "testing.autoRun.mode": "rerun", "conventionalCommits.scopes": [ diff --git a/cli/src/constants.rs b/cli/src/constants.rs index 03f12cfd2a5..5076625d547 100644 --- a/cli/src/constants.rs +++ b/cli/src/constants.rs @@ -24,6 +24,7 @@ pub const LAUNCHER_ASSET_NAME: Option<&'static str> = pub const LAUNCHER_AI_KEY: Option<&'static str> = option_env!("LAUNCHER_AI_KEY"); pub const LAUNCHER_AI_ENDPOINT: Option<&'static str> = option_env!("LAUNCHER_AI_ENDPOINT"); +pub const VSCODE_CLI_UPDATE_ENDPOINT: Option<&'static str> = option_env!("LAUNCHER_AI_ENDPOINT"); pub const TUNNEL_SERVICE_USER_AGENT_ENV_VAR: &str = "TUNNEL_SERVICE_USER_AGENT"; diff --git a/cli/src/update_service.rs b/cli/src/update_service.rs index c37715c8a0b..e2513f6ab80 100644 --- a/cli/src/update_service.rs +++ b/cli/src/update_service.rs @@ -8,9 +8,12 @@ use std::path::Path; use serde::Deserialize; use crate::{ + constants::VSCODE_CLI_UPDATE_ENDPOINT, debug, log, options, spanf, util::{ - errors::{AnyError, StatusError, UnsupportedPlatformError, WrappedError}, + errors::{ + AnyError, StatusError, UnsupportedPlatformError, UpdatesNotConfigured, WrappedError, + }, io::ReportCopyProgress, }, }; @@ -54,11 +57,13 @@ impl UpdateService { quality: options::Quality, version: &str, ) -> Result { + let update_endpoint = VSCODE_CLI_UPDATE_ENDPOINT.ok_or(UpdatesNotConfigured())?; let download_segment = target .download_segment(platform) .ok_or(UnsupportedPlatformError())?; let download_url = format!( - "https://update.code.visualstudio.com/api/versions/{}/{}/{}", + "{}/api/versions/{}/{}/{}", + update_endpoint, version, download_segment, quality_download_segment(quality), @@ -92,11 +97,13 @@ impl UpdateService { target: TargetKind, quality: options::Quality, ) -> Result { + let update_endpoint = VSCODE_CLI_UPDATE_ENDPOINT.ok_or(UpdatesNotConfigured())?; let download_segment = target .download_segment(platform) .ok_or(UnsupportedPlatformError())?; let download_url = format!( - "https://update.code.visualstudio.com/api/latest/{}/{}", + "{}/api/latest/{}/{}", + update_endpoint, download_segment, quality_download_segment(quality), ); @@ -127,13 +134,15 @@ impl UpdateService { &self, release: &Release, ) -> Result { + let update_endpoint = VSCODE_CLI_UPDATE_ENDPOINT.ok_or(UpdatesNotConfigured())?; let download_segment = release .target .download_segment(release.platform) .ok_or(UnsupportedPlatformError())?; let download_url = format!( - "https://update.code.visualstudio.com/commit:{}/{}/{}", + "{}/commit:{}/{}/{}", + update_endpoint, release.commit, download_segment, quality_download_segment(release.quality), diff --git a/cli/src/util/errors.rs b/cli/src/util/errors.rs index 9c643446b6e..47f6a64e359 100644 --- a/cli/src/util/errors.rs +++ b/cli/src/util/errors.rs @@ -316,6 +316,14 @@ impl std::fmt::Display for ServerHasClosed { } } +#[derive(Debug)] +pub struct UpdatesNotConfigured(); + +impl std::fmt::Display for UpdatesNotConfigured { + fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { + write!(f, "Update service is not configured") + } +} #[derive(Debug)] pub struct ServiceAlreadyRegistered(); @@ -408,7 +416,8 @@ makeAnyError!( CannotForwardControlPort, ServerHasClosed, ServiceAlreadyRegistered, - WindowsNeedsElevation + WindowsNeedsElevation, + UpdatesNotConfigured ); impl From for AnyError {