mirror of
https://github.com/Microsoft/vscode
synced 2024-10-05 19:02:54 +00:00
cli: get update endpoint from build
This commit is contained in:
parent
5b24e93b35
commit
54ca489a5b
6
.vscode/settings.json
vendored
6
.vscode/settings.json
vendored
|
@ -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": [
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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<Release, AnyError> {
|
||||
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<Release, AnyError> {
|
||||
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<reqwest::Response, AnyError> {
|
||||
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),
|
||||
|
|
|
@ -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<reqwest::Error> for AnyError {
|
||||
|
|
Loading…
Reference in a new issue