2024-01-01 14:58:21 -05:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
2020-03-23 11:37:24 -04:00
|
|
|
|
|
|
|
//! This module provides feature to upgrade deno executable
|
|
|
|
|
2022-12-12 21:30:44 -05:00
|
|
|
use crate::args::Flags;
|
2022-06-27 16:54:09 -04:00
|
|
|
use crate::args::UpgradeFlags;
|
2022-10-20 19:50:55 -04:00
|
|
|
use crate::colors;
|
2023-05-01 14:35:23 -04:00
|
|
|
use crate::factory::CliFactory;
|
2022-12-12 21:30:44 -05:00
|
|
|
use crate::http_util::HttpClient;
|
2024-06-03 17:17:08 -04:00
|
|
|
use crate::http_util::HttpClientProvider;
|
2024-08-15 15:59:16 -04:00
|
|
|
use crate::shared::ReleaseChannel;
|
2024-08-08 03:19:05 -04:00
|
|
|
use crate::util::archive;
|
2022-12-01 18:05:49 -05:00
|
|
|
use crate::util::progress_bar::ProgressBar;
|
2022-12-12 20:52:10 -05:00
|
|
|
use crate::util::progress_bar::ProgressBarStyle;
|
2022-10-20 10:15:21 -04:00
|
|
|
use crate::version;
|
2022-10-20 19:50:55 -04:00
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
use async_trait::async_trait;
|
2021-11-16 09:02:28 -05:00
|
|
|
use deno_core::anyhow::bail;
|
2022-12-02 14:53:10 -05:00
|
|
|
use deno_core::anyhow::Context;
|
2021-11-09 05:06:45 -05:00
|
|
|
use deno_core::error::AnyError;
|
2023-08-23 19:03:05 -04:00
|
|
|
use deno_core::unsync::spawn;
|
2024-08-09 05:44:21 -04:00
|
|
|
use deno_core::url::Url;
|
2023-04-06 18:46:44 -04:00
|
|
|
use deno_semver::Version;
|
2021-12-18 16:14:42 -05:00
|
|
|
use once_cell::sync::Lazy;
|
2022-10-22 14:31:25 -04:00
|
|
|
use std::borrow::Cow;
|
2022-03-18 18:40:44 -04:00
|
|
|
use std::env;
|
2020-03-23 11:37:24 -04:00
|
|
|
use std::fs;
|
2023-08-25 09:43:07 -04:00
|
|
|
use std::io::IsTerminal;
|
2022-10-21 11:07:17 -04:00
|
|
|
use std::ops::Sub;
|
2020-03-23 11:37:24 -04:00
|
|
|
use std::path::Path;
|
|
|
|
use std::path::PathBuf;
|
|
|
|
use std::process::Command;
|
2023-05-01 16:42:05 -04:00
|
|
|
use std::sync::Arc;
|
2022-10-20 10:15:21 -04:00
|
|
|
use std::time::Duration;
|
2020-03-23 11:37:24 -04:00
|
|
|
|
2020-11-22 10:07:05 -05:00
|
|
|
const RELEASE_URL: &str = "https://github.com/denoland/deno/releases";
|
2024-08-09 05:44:21 -04:00
|
|
|
const CANARY_URL: &str = "https://dl.deno.land/canary";
|
2020-03-23 11:37:24 -04:00
|
|
|
|
2024-02-13 11:22:30 -05:00
|
|
|
pub static ARCHIVE_NAME: Lazy<String> =
|
|
|
|
Lazy::new(|| format!("deno-{}.zip", env!("TARGET")));
|
|
|
|
|
2022-10-20 10:15:21 -04:00
|
|
|
// How often query server for new version. In hours.
|
|
|
|
const UPGRADE_CHECK_INTERVAL: i64 = 24;
|
|
|
|
|
|
|
|
const UPGRADE_CHECK_FETCH_DELAY: Duration = Duration::from_millis(500);
|
|
|
|
|
2022-10-22 14:31:25 -04:00
|
|
|
/// Environment necessary for doing the update checker.
|
|
|
|
/// An alternate trait implementation can be provided for testing purposes.
|
2023-11-17 16:40:12 -05:00
|
|
|
trait UpdateCheckerEnvironment: Clone {
|
2022-10-22 14:31:25 -04:00
|
|
|
fn read_check_file(&self) -> String;
|
|
|
|
fn write_check_file(&self, text: &str);
|
|
|
|
fn current_time(&self) -> chrono::DateTime<chrono::Utc>;
|
|
|
|
}
|
2022-10-20 10:15:21 -04:00
|
|
|
|
2022-10-22 14:31:25 -04:00
|
|
|
#[derive(Clone)]
|
|
|
|
struct RealUpdateCheckerEnvironment {
|
2022-11-25 19:04:30 -05:00
|
|
|
cache_file_path: PathBuf,
|
2022-10-22 14:31:25 -04:00
|
|
|
current_time: chrono::DateTime<chrono::Utc>,
|
|
|
|
}
|
2022-10-20 10:15:21 -04:00
|
|
|
|
2022-10-22 14:31:25 -04:00
|
|
|
impl RealUpdateCheckerEnvironment {
|
2023-11-17 16:40:12 -05:00
|
|
|
pub fn new(cache_file_path: PathBuf) -> Self {
|
2022-10-22 14:31:25 -04:00
|
|
|
Self {
|
2022-11-25 19:04:30 -05:00
|
|
|
cache_file_path,
|
2022-10-22 14:31:25 -04:00
|
|
|
// cache the current time
|
2024-05-23 07:59:11 -04:00
|
|
|
current_time: chrono::Utc::now(),
|
2022-10-20 17:01:17 -04:00
|
|
|
}
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
}
|
2022-10-20 10:15:21 -04:00
|
|
|
|
2022-10-22 14:31:25 -04:00
|
|
|
impl UpdateCheckerEnvironment for RealUpdateCheckerEnvironment {
|
|
|
|
fn read_check_file(&self) -> String {
|
2022-11-25 19:04:30 -05:00
|
|
|
std::fs::read_to_string(&self.cache_file_path).unwrap_or_default()
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn write_check_file(&self, text: &str) {
|
2022-11-25 19:04:30 -05:00
|
|
|
let _ = std::fs::write(&self.cache_file_path, text);
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
2022-10-20 19:50:55 -04:00
|
|
|
|
2022-10-22 14:31:25 -04:00
|
|
|
fn current_time(&self) -> chrono::DateTime<chrono::Utc> {
|
|
|
|
self.current_time
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
#[derive(Debug, Copy, Clone)]
|
|
|
|
enum UpgradeCheckKind {
|
|
|
|
Execution,
|
|
|
|
Lsp,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait(?Send)]
|
|
|
|
trait VersionProvider: Clone {
|
2024-08-07 04:29:23 -04:00
|
|
|
/// Fetch latest available version for the given release channel
|
|
|
|
async fn latest_version(
|
|
|
|
&self,
|
|
|
|
release_channel: ReleaseChannel,
|
2024-08-12 14:32:53 -04:00
|
|
|
) -> Result<AvailableVersion, AnyError>;
|
2024-08-07 04:29:23 -04:00
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
/// Returns either a semver or git hash. It's up to implementor to
|
|
|
|
/// decide which one is appropriate, but in general only "stable"
|
|
|
|
/// and "lts" versions use semver.
|
2023-11-17 16:40:12 -05:00
|
|
|
fn current_version(&self) -> Cow<str>;
|
|
|
|
|
2024-08-16 16:42:19 -04:00
|
|
|
fn get_current_exe_release_channel(&self) -> ReleaseChannel;
|
2023-11-17 16:40:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
struct RealVersionProvider {
|
2024-06-03 17:17:08 -04:00
|
|
|
http_client_provider: Arc<HttpClientProvider>,
|
2023-11-17 16:40:12 -05:00
|
|
|
check_kind: UpgradeCheckKind,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RealVersionProvider {
|
|
|
|
pub fn new(
|
2024-06-03 17:17:08 -04:00
|
|
|
http_client_provider: Arc<HttpClientProvider>,
|
2023-11-17 16:40:12 -05:00
|
|
|
check_kind: UpgradeCheckKind,
|
|
|
|
) -> Self {
|
|
|
|
Self {
|
2024-06-03 17:17:08 -04:00
|
|
|
http_client_provider,
|
2023-11-17 16:40:12 -05:00
|
|
|
check_kind,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[async_trait(?Send)]
|
|
|
|
impl VersionProvider for RealVersionProvider {
|
2024-08-07 04:29:23 -04:00
|
|
|
async fn latest_version(
|
|
|
|
&self,
|
|
|
|
release_channel: ReleaseChannel,
|
2024-08-12 14:32:53 -04:00
|
|
|
) -> Result<AvailableVersion, AnyError> {
|
2024-08-07 04:29:23 -04:00
|
|
|
fetch_latest_version(
|
2024-06-03 17:17:08 -04:00
|
|
|
&self.http_client_provider.get_or_create()?,
|
2024-08-07 04:29:23 -04:00
|
|
|
release_channel,
|
2024-06-03 17:17:08 -04:00
|
|
|
self.check_kind,
|
|
|
|
)
|
|
|
|
.await
|
2023-11-17 16:40:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn current_version(&self) -> Cow<str> {
|
2024-08-15 17:47:16 -04:00
|
|
|
Cow::Borrowed(version::DENO_VERSION_INFO.version_or_git_hash())
|
2023-11-17 16:40:12 -05:00
|
|
|
}
|
2024-08-07 04:29:23 -04:00
|
|
|
|
2024-08-16 16:42:19 -04:00
|
|
|
fn get_current_exe_release_channel(&self) -> ReleaseChannel {
|
|
|
|
version::DENO_VERSION_INFO.release_channel
|
2024-08-07 04:29:23 -04:00
|
|
|
}
|
2023-11-17 16:40:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
struct UpdateChecker<
|
|
|
|
TEnvironment: UpdateCheckerEnvironment,
|
|
|
|
TVersionProvider: VersionProvider,
|
|
|
|
> {
|
2022-10-22 14:31:25 -04:00
|
|
|
env: TEnvironment,
|
2023-11-17 16:40:12 -05:00
|
|
|
version_provider: TVersionProvider,
|
2022-10-22 14:31:25 -04:00
|
|
|
maybe_file: Option<CheckVersionFile>,
|
|
|
|
}
|
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
impl<
|
|
|
|
TEnvironment: UpdateCheckerEnvironment,
|
|
|
|
TVersionProvider: VersionProvider,
|
|
|
|
> UpdateChecker<TEnvironment, TVersionProvider>
|
|
|
|
{
|
|
|
|
pub fn new(env: TEnvironment, version_provider: TVersionProvider) -> Self {
|
2022-10-22 14:31:25 -04:00
|
|
|
let maybe_file = CheckVersionFile::parse(env.read_check_file());
|
2023-11-17 16:40:12 -05:00
|
|
|
Self {
|
|
|
|
env,
|
|
|
|
version_provider,
|
|
|
|
maybe_file,
|
|
|
|
}
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn should_check_for_new_version(&self) -> bool {
|
2024-08-12 14:32:53 -04:00
|
|
|
let Some(file) = &self.maybe_file else {
|
|
|
|
return true;
|
|
|
|
};
|
|
|
|
|
|
|
|
let last_check_age = self
|
|
|
|
.env
|
|
|
|
.current_time()
|
|
|
|
.signed_duration_since(file.last_checked);
|
|
|
|
last_check_age > chrono::Duration::hours(UPGRADE_CHECK_INTERVAL)
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
/// Returns the current exe release channel and a version if a new one is available and it should be prompted about.
|
|
|
|
pub fn should_prompt(&self) -> Option<(ReleaseChannel, String)> {
|
2022-10-22 14:31:25 -04:00
|
|
|
let file = self.maybe_file.as_ref()?;
|
2023-06-26 09:10:27 -04:00
|
|
|
// If the current version saved is not the actually current version of the binary
|
2022-11-05 19:06:58 -04:00
|
|
|
// It means
|
2023-02-07 22:32:30 -05:00
|
|
|
// - We already check for a new version today
|
2022-11-05 19:06:58 -04:00
|
|
|
// - The user have probably upgraded today
|
|
|
|
// So we should not prompt and wait for tomorrow for the latest version to be updated again
|
2023-11-17 16:40:12 -05:00
|
|
|
let current_version = self.version_provider.current_version();
|
|
|
|
if file.current_version != current_version {
|
2022-11-05 19:06:58 -04:00
|
|
|
return None;
|
|
|
|
}
|
2023-11-17 16:40:12 -05:00
|
|
|
if file.latest_version == current_version {
|
2022-10-22 14:31:25 -04:00
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
if let Ok(current) = Version::parse_standard(¤t_version) {
|
2023-02-15 13:20:40 -05:00
|
|
|
if let Ok(latest) = Version::parse_standard(&file.latest_version) {
|
2022-10-28 12:43:49 -04:00
|
|
|
if current >= latest {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-10-22 14:31:25 -04:00
|
|
|
let last_prompt_age = self
|
|
|
|
.env
|
|
|
|
.current_time()
|
|
|
|
.signed_duration_since(file.last_prompt);
|
|
|
|
if last_prompt_age > chrono::Duration::hours(UPGRADE_CHECK_INTERVAL) {
|
2024-08-12 14:32:53 -04:00
|
|
|
Some((file.current_release_channel, file.latest_version.clone()))
|
2022-10-22 14:31:25 -04:00
|
|
|
} else {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Store that we showed the update message to the user.
|
|
|
|
pub fn store_prompted(self) {
|
|
|
|
if let Some(file) = self.maybe_file {
|
|
|
|
self.env.write_check_file(
|
|
|
|
&file.with_last_prompt(self.env.current_time()).serialize(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-01-24 07:30:45 -05:00
|
|
|
fn get_minor_version(version: &str) -> &str {
|
|
|
|
version.rsplitn(2, '.').collect::<Vec<&str>>()[1]
|
|
|
|
}
|
|
|
|
|
2023-01-25 10:29:27 -05:00
|
|
|
fn print_release_notes(current_version: &str, new_version: &str) {
|
2024-08-12 14:32:53 -04:00
|
|
|
// TODO(bartlomieju): we might want to reconsider this one for RC releases.
|
|
|
|
// TODO(bartlomieju): also maybe just parse using `Version::standard` instead
|
|
|
|
// of using `get_minor_version`?
|
2024-08-09 05:44:21 -04:00
|
|
|
if get_minor_version(current_version) == get_minor_version(new_version) {
|
|
|
|
return;
|
2023-01-25 10:29:27 -05:00
|
|
|
}
|
2024-08-09 05:44:21 -04:00
|
|
|
|
|
|
|
log::info!(
|
2024-08-13 18:32:20 -04:00
|
|
|
"{}\n\n {}\n",
|
|
|
|
colors::gray("Release notes:"),
|
2024-08-09 05:44:21 -04:00
|
|
|
colors::bold(format!(
|
|
|
|
"https://github.com/denoland/deno/releases/tag/v{}",
|
|
|
|
&new_version,
|
|
|
|
))
|
|
|
|
);
|
|
|
|
log::info!(
|
2024-08-13 18:32:20 -04:00
|
|
|
"{}\n\n {}\n",
|
|
|
|
colors::gray("Blog post:"),
|
2024-08-09 05:44:21 -04:00
|
|
|
colors::bold(format!(
|
|
|
|
"https://deno.com/blog/v{}",
|
|
|
|
get_minor_version(new_version)
|
|
|
|
))
|
|
|
|
);
|
2023-01-24 07:30:45 -05:00
|
|
|
}
|
|
|
|
|
2023-11-14 17:10:51 -05:00
|
|
|
pub fn upgrade_check_enabled() -> bool {
|
|
|
|
matches!(
|
|
|
|
env::var("DENO_NO_UPDATE_CHECK"),
|
|
|
|
Err(env::VarError::NotPresent)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2023-05-01 16:42:05 -04:00
|
|
|
pub fn check_for_upgrades(
|
2024-06-03 17:17:08 -04:00
|
|
|
http_client_provider: Arc<HttpClientProvider>,
|
2023-05-01 16:42:05 -04:00
|
|
|
cache_file_path: PathBuf,
|
|
|
|
) {
|
2023-11-14 17:10:51 -05:00
|
|
|
if !upgrade_check_enabled() {
|
2022-10-22 14:31:25 -04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
let env = RealUpdateCheckerEnvironment::new(cache_file_path);
|
2024-08-12 14:32:53 -04:00
|
|
|
let version_provider = RealVersionProvider::new(
|
|
|
|
http_client_provider.clone(),
|
|
|
|
UpgradeCheckKind::Execution,
|
|
|
|
);
|
2023-11-17 16:40:12 -05:00
|
|
|
let update_checker = UpdateChecker::new(env, version_provider);
|
2022-10-22 14:31:25 -04:00
|
|
|
|
|
|
|
if update_checker.should_check_for_new_version() {
|
|
|
|
let env = update_checker.env.clone();
|
2023-11-17 16:40:12 -05:00
|
|
|
let version_provider = update_checker.version_provider.clone();
|
2022-10-22 14:31:25 -04:00
|
|
|
// do this asynchronously on a separate task
|
2023-05-14 17:40:01 -04:00
|
|
|
spawn(async move {
|
2022-10-22 14:31:25 -04:00
|
|
|
// Sleep for a small amount of time to not unnecessarily impact startup
|
|
|
|
// time.
|
|
|
|
tokio::time::sleep(UPGRADE_CHECK_FETCH_DELAY).await;
|
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
fetch_and_store_latest_version(&env, &version_provider).await;
|
2023-11-23 11:20:40 -05:00
|
|
|
|
|
|
|
// text is used by the test suite
|
|
|
|
log::debug!("Finished upgrade checker.")
|
2022-10-22 14:31:25 -04:00
|
|
|
});
|
|
|
|
}
|
2022-10-20 19:50:55 -04:00
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
// Don't bother doing any more computation if we're not in TTY environment.
|
|
|
|
let should_prompt =
|
|
|
|
log::log_enabled!(log::Level::Info) && std::io::stderr().is_terminal();
|
|
|
|
|
|
|
|
if !should_prompt {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-10-26 17:20:41 -04:00
|
|
|
// Print a message if an update is available
|
2024-08-12 14:32:53 -04:00
|
|
|
if let Some((release_channel, upgrade_version)) =
|
|
|
|
update_checker.should_prompt()
|
|
|
|
{
|
|
|
|
match release_channel {
|
|
|
|
ReleaseChannel::Stable => {
|
2024-05-08 22:45:06 -04:00
|
|
|
log::info!(
|
|
|
|
"{} {} → {} {}",
|
2022-10-26 17:20:41 -04:00
|
|
|
colors::green("A new release of Deno is available:"),
|
2024-08-15 17:47:16 -04:00
|
|
|
colors::cyan(version::DENO_VERSION_INFO.deno),
|
2024-05-08 22:45:06 -04:00
|
|
|
colors::cyan(&upgrade_version),
|
2022-10-31 06:48:28 -04:00
|
|
|
colors::italic_gray("Run `deno upgrade` to install it.")
|
|
|
|
);
|
2022-10-26 17:20:41 -04:00
|
|
|
}
|
2024-08-12 14:32:53 -04:00
|
|
|
ReleaseChannel::Canary => {
|
|
|
|
log::info!(
|
|
|
|
"{} {}",
|
|
|
|
colors::green("A new canary release of Deno is available."),
|
|
|
|
colors::italic_gray("Run `deno upgrade --canary` to install it.")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
ReleaseChannel::Rc => {
|
|
|
|
log::info!(
|
|
|
|
"{} {}",
|
|
|
|
colors::green("A new release candidate of Deno is available."),
|
|
|
|
colors::italic_gray("Run `deno upgrade --rc` to install it.")
|
|
|
|
);
|
|
|
|
}
|
|
|
|
// TODO(bartlomieju)
|
|
|
|
ReleaseChannel::Lts => unreachable!(),
|
2022-10-20 19:50:55 -04:00
|
|
|
}
|
2024-08-12 14:32:53 -04:00
|
|
|
|
|
|
|
update_checker.store_prompted();
|
2022-10-20 19:50:55 -04:00
|
|
|
}
|
2022-10-20 10:15:21 -04:00
|
|
|
}
|
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
|
|
|
pub struct LspVersionUpgradeInfo {
|
|
|
|
pub latest_version: String,
|
|
|
|
pub is_canary: bool,
|
|
|
|
}
|
|
|
|
|
2023-11-14 17:10:51 -05:00
|
|
|
pub async fn check_for_upgrades_for_lsp(
|
2024-06-03 17:17:08 -04:00
|
|
|
http_client_provider: Arc<HttpClientProvider>,
|
2023-11-17 16:40:12 -05:00
|
|
|
) -> Result<Option<LspVersionUpgradeInfo>, AnyError> {
|
2023-11-14 17:10:51 -05:00
|
|
|
if !upgrade_check_enabled() {
|
|
|
|
return Ok(None);
|
|
|
|
}
|
2023-11-17 16:40:12 -05:00
|
|
|
|
|
|
|
let version_provider =
|
2024-06-03 17:17:08 -04:00
|
|
|
RealVersionProvider::new(http_client_provider, UpgradeCheckKind::Lsp);
|
2023-11-17 16:40:12 -05:00
|
|
|
check_for_upgrades_for_lsp_with_provider(&version_provider).await
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn check_for_upgrades_for_lsp_with_provider(
|
|
|
|
version_provider: &impl VersionProvider,
|
|
|
|
) -> Result<Option<LspVersionUpgradeInfo>, AnyError> {
|
2024-08-16 16:42:19 -04:00
|
|
|
let release_channel = version_provider.get_current_exe_release_channel();
|
2024-08-07 04:29:23 -04:00
|
|
|
let latest_version = version_provider.latest_version(release_channel).await?;
|
2023-11-17 16:40:12 -05:00
|
|
|
let current_version = version_provider.current_version();
|
2024-08-07 04:29:23 -04:00
|
|
|
|
|
|
|
// Nothing to upgrade
|
2024-08-12 14:32:53 -04:00
|
|
|
if current_version == latest_version.version_or_hash {
|
2024-08-07 04:29:23 -04:00
|
|
|
return Ok(None);
|
|
|
|
}
|
|
|
|
|
|
|
|
match release_channel {
|
2024-08-16 16:42:19 -04:00
|
|
|
ReleaseChannel::Stable | ReleaseChannel::Rc => {
|
2024-08-07 04:29:23 -04:00
|
|
|
if let Ok(current) = Version::parse_standard(¤t_version) {
|
2024-08-12 14:32:53 -04:00
|
|
|
if let Ok(latest) =
|
|
|
|
Version::parse_standard(&latest_version.version_or_hash)
|
|
|
|
{
|
2024-08-07 04:29:23 -04:00
|
|
|
if current >= latest {
|
|
|
|
return Ok(None); // nothing to upgrade
|
|
|
|
}
|
2023-11-14 17:10:51 -05:00
|
|
|
}
|
|
|
|
}
|
2024-08-07 04:29:23 -04:00
|
|
|
Ok(Some(LspVersionUpgradeInfo {
|
2024-08-12 14:32:53 -04:00
|
|
|
latest_version: latest_version.display,
|
2024-08-07 04:29:23 -04:00
|
|
|
is_canary: false,
|
|
|
|
}))
|
2023-11-14 17:10:51 -05:00
|
|
|
}
|
2024-08-07 04:29:23 -04:00
|
|
|
|
|
|
|
ReleaseChannel::Canary => Ok(Some(LspVersionUpgradeInfo {
|
2024-08-12 14:32:53 -04:00
|
|
|
latest_version: latest_version.display,
|
|
|
|
is_canary: true,
|
|
|
|
})),
|
|
|
|
|
2024-08-07 04:29:23 -04:00
|
|
|
// TODO(bartlomieju)
|
|
|
|
ReleaseChannel::Lts => unreachable!(),
|
2023-11-17 16:40:12 -05:00
|
|
|
}
|
2023-11-14 17:10:51 -05:00
|
|
|
}
|
|
|
|
|
2022-10-22 14:31:25 -04:00
|
|
|
async fn fetch_and_store_latest_version<
|
|
|
|
TEnvironment: UpdateCheckerEnvironment,
|
2023-11-17 16:40:12 -05:00
|
|
|
TVersionProvider: VersionProvider,
|
2022-10-22 14:31:25 -04:00
|
|
|
>(
|
|
|
|
env: &TEnvironment,
|
2023-11-17 16:40:12 -05:00
|
|
|
version_provider: &TVersionProvider,
|
2022-10-22 14:31:25 -04:00
|
|
|
) {
|
2024-08-16 16:42:19 -04:00
|
|
|
let release_channel = version_provider.get_current_exe_release_channel();
|
2024-08-07 04:29:23 -04:00
|
|
|
let Ok(latest_version) =
|
|
|
|
version_provider.latest_version(release_channel).await
|
|
|
|
else {
|
|
|
|
return;
|
2022-10-22 14:31:25 -04:00
|
|
|
};
|
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
let version_file = CheckVersionFile {
|
|
|
|
// put a date in the past here so that prompt can be shown on next run
|
|
|
|
last_prompt: env
|
|
|
|
.current_time()
|
|
|
|
.sub(chrono::Duration::hours(UPGRADE_CHECK_INTERVAL + 1)),
|
|
|
|
last_checked: env.current_time(),
|
|
|
|
current_version: version_provider.current_version().to_string(),
|
|
|
|
latest_version: latest_version.version_or_hash,
|
|
|
|
current_release_channel: release_channel,
|
|
|
|
};
|
|
|
|
|
|
|
|
env.write_check_file(&version_file.serialize());
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
|
2022-12-12 21:30:44 -05:00
|
|
|
pub async fn upgrade(
|
2024-07-23 19:00:48 -04:00
|
|
|
flags: Arc<Flags>,
|
2022-12-12 21:30:44 -05:00
|
|
|
upgrade_flags: UpgradeFlags,
|
|
|
|
) -> Result<(), AnyError> {
|
2024-07-23 19:00:48 -04:00
|
|
|
let factory = CliFactory::from_flags(flags);
|
2024-08-09 05:44:21 -04:00
|
|
|
let http_client_provider = factory.http_client_provider();
|
|
|
|
let client = http_client_provider.get_or_create()?;
|
2022-12-02 14:53:10 -05:00
|
|
|
let current_exe_path = std::env::current_exe()?;
|
2024-07-23 19:00:48 -04:00
|
|
|
let full_path_output_flag = match &upgrade_flags.output {
|
|
|
|
Some(output) => Some(
|
|
|
|
std::env::current_dir()
|
|
|
|
.context("failed getting cwd")?
|
|
|
|
.join(output),
|
|
|
|
),
|
|
|
|
None => None,
|
|
|
|
};
|
2023-07-20 15:51:02 -04:00
|
|
|
let output_exe_path =
|
2024-03-14 19:53:46 -04:00
|
|
|
full_path_output_flag.as_ref().unwrap_or(¤t_exe_path);
|
2023-07-20 15:51:02 -04:00
|
|
|
|
2024-08-09 05:44:21 -04:00
|
|
|
let permissions = set_exe_permissions(¤t_exe_path, output_exe_path)?;
|
2020-11-29 14:00:35 -05:00
|
|
|
|
2024-08-09 05:44:21 -04:00
|
|
|
let force_selection_of_new_version =
|
|
|
|
upgrade_flags.force || full_path_output_flag.is_some();
|
2023-05-15 21:21:59 -04:00
|
|
|
|
2024-08-09 05:44:21 -04:00
|
|
|
let requested_version =
|
|
|
|
RequestedVersion::from_upgrade_flags(upgrade_flags.clone())?;
|
2020-11-29 14:00:35 -05:00
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
let maybe_selected_version_to_upgrade = match &requested_version {
|
2024-08-09 05:44:21 -04:00
|
|
|
RequestedVersion::Latest(channel) => {
|
|
|
|
find_latest_version_to_upgrade(
|
|
|
|
http_client_provider.clone(),
|
2024-08-12 14:32:53 -04:00
|
|
|
*channel,
|
2024-08-09 05:44:21 -04:00
|
|
|
force_selection_of_new_version,
|
2024-08-07 04:29:23 -04:00
|
|
|
)
|
2024-08-09 05:44:21 -04:00
|
|
|
.await?
|
|
|
|
}
|
|
|
|
RequestedVersion::SpecificVersion(channel, version) => {
|
|
|
|
select_specific_version_for_upgrade(
|
2024-08-12 14:32:53 -04:00
|
|
|
*channel,
|
|
|
|
version.clone(),
|
2024-08-09 05:44:21 -04:00
|
|
|
force_selection_of_new_version,
|
|
|
|
)?
|
2020-03-23 11:37:24 -04:00
|
|
|
}
|
2020-05-09 06:31:15 -04:00
|
|
|
};
|
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
let Some(selected_version_to_upgrade) = maybe_selected_version_to_upgrade
|
|
|
|
else {
|
2024-08-09 05:44:21 -04:00
|
|
|
return Ok(());
|
2020-11-29 14:00:35 -05:00
|
|
|
};
|
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
let download_url = get_download_url(
|
|
|
|
&selected_version_to_upgrade.version_or_hash,
|
|
|
|
requested_version.is_canary(),
|
|
|
|
)?;
|
2024-08-09 05:44:21 -04:00
|
|
|
log::info!("{}", colors::gray(format!("Downloading {}", &download_url)));
|
|
|
|
let Some(archive_data) = download_package(&client, download_url).await?
|
|
|
|
else {
|
|
|
|
log::error!("Download could not be found, aborting");
|
|
|
|
std::process::exit(1)
|
|
|
|
};
|
2020-11-22 10:07:05 -05:00
|
|
|
|
2024-08-07 07:59:12 -04:00
|
|
|
log::info!(
|
|
|
|
"{}",
|
2024-08-12 14:32:53 -04:00
|
|
|
colors::gray(format!(
|
|
|
|
"Deno is upgrading to version {}",
|
|
|
|
&selected_version_to_upgrade.display
|
|
|
|
))
|
2024-08-07 07:59:12 -04:00
|
|
|
);
|
2020-11-22 10:07:05 -05:00
|
|
|
|
2023-03-22 14:55:19 -04:00
|
|
|
let temp_dir = tempfile::TempDir::new()?;
|
2024-08-08 03:19:05 -04:00
|
|
|
let new_exe_path = archive::unpack_into_dir(archive::UnpackArgs {
|
|
|
|
exe_name: "deno",
|
|
|
|
archive_name: &ARCHIVE_NAME,
|
|
|
|
archive_data: &archive_data,
|
|
|
|
is_windows: cfg!(windows),
|
|
|
|
dest_path: temp_dir.path(),
|
|
|
|
})?;
|
2020-05-09 06:31:15 -04:00
|
|
|
fs::set_permissions(&new_exe_path, permissions)?;
|
2020-11-29 14:00:35 -05:00
|
|
|
check_exe(&new_exe_path)?;
|
2020-05-09 06:31:15 -04:00
|
|
|
|
2022-12-12 20:52:10 -05:00
|
|
|
if upgrade_flags.dry_run {
|
|
|
|
fs::remove_file(&new_exe_path)?;
|
|
|
|
log::info!("Upgraded successfully (dry run)");
|
2024-08-12 14:32:53 -04:00
|
|
|
if !requested_version.is_canary() {
|
|
|
|
print_release_notes(
|
2024-08-15 17:47:16 -04:00
|
|
|
version::DENO_VERSION_INFO.deno,
|
2024-08-12 14:32:53 -04:00
|
|
|
&selected_version_to_upgrade.version_or_hash,
|
|
|
|
);
|
2023-01-25 10:29:27 -05:00
|
|
|
}
|
2024-08-09 05:44:21 -04:00
|
|
|
drop(temp_dir);
|
|
|
|
return Ok(());
|
|
|
|
}
|
|
|
|
|
|
|
|
let output_exe_path =
|
|
|
|
full_path_output_flag.as_ref().unwrap_or(¤t_exe_path);
|
|
|
|
let output_result = if *output_exe_path == current_exe_path {
|
|
|
|
replace_exe(&new_exe_path, output_exe_path)
|
2022-12-12 20:52:10 -05:00
|
|
|
} else {
|
2024-08-09 05:44:21 -04:00
|
|
|
fs::rename(&new_exe_path, output_exe_path)
|
|
|
|
.or_else(|_| fs::copy(&new_exe_path, output_exe_path).map(|_| ()))
|
|
|
|
};
|
|
|
|
check_windows_access_denied_error(output_result, output_exe_path)?;
|
|
|
|
|
|
|
|
log::info!(
|
2024-08-13 18:32:20 -04:00
|
|
|
"\nUpgraded successfully to Deno {}\n",
|
|
|
|
colors::green(selected_version_to_upgrade.display())
|
2024-08-09 05:44:21 -04:00
|
|
|
);
|
2024-08-12 14:32:53 -04:00
|
|
|
if !requested_version.is_canary() {
|
2024-08-15 17:47:16 -04:00
|
|
|
print_release_notes(
|
|
|
|
version::DENO_VERSION_INFO.deno,
|
|
|
|
&selected_version_to_upgrade.display,
|
|
|
|
);
|
2024-08-09 05:44:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
drop(temp_dir); // delete the temp dir
|
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
|
|
|
enum RequestedVersion {
|
|
|
|
Latest(ReleaseChannel),
|
|
|
|
SpecificVersion(ReleaseChannel, String),
|
|
|
|
}
|
|
|
|
|
|
|
|
impl RequestedVersion {
|
|
|
|
fn from_upgrade_flags(upgrade_flags: UpgradeFlags) -> Result<Self, AnyError> {
|
|
|
|
let is_canary = upgrade_flags.canary;
|
2024-08-12 14:32:53 -04:00
|
|
|
let is_release_candidate = upgrade_flags.release_candidate;
|
2024-08-09 05:44:21 -04:00
|
|
|
|
|
|
|
let Some(passed_version) = upgrade_flags.version else {
|
|
|
|
let channel = if is_canary {
|
|
|
|
ReleaseChannel::Canary
|
2024-08-12 14:32:53 -04:00
|
|
|
} else if is_release_candidate {
|
|
|
|
ReleaseChannel::Rc
|
2024-08-09 05:44:21 -04:00
|
|
|
} else {
|
|
|
|
ReleaseChannel::Stable
|
|
|
|
};
|
|
|
|
return Ok(Self::Latest(channel));
|
|
|
|
};
|
|
|
|
|
|
|
|
let re_hash = lazy_regex::regex!("^[0-9a-f]{40}$");
|
|
|
|
let passed_version = passed_version
|
|
|
|
.strip_prefix('v')
|
|
|
|
.unwrap_or(&passed_version)
|
|
|
|
.to_string();
|
|
|
|
|
|
|
|
let (channel, passed_version) = if is_canary {
|
|
|
|
if !re_hash.is_match(&passed_version) {
|
|
|
|
bail!("Invalid commit hash passed");
|
|
|
|
}
|
|
|
|
(ReleaseChannel::Canary, passed_version)
|
2022-12-02 14:53:10 -05:00
|
|
|
} else {
|
2024-08-09 05:44:21 -04:00
|
|
|
if Version::parse_standard(&passed_version).is_err() {
|
|
|
|
bail!("Invalid version passed");
|
|
|
|
};
|
|
|
|
(ReleaseChannel::Stable, passed_version)
|
2022-12-02 14:53:10 -05:00
|
|
|
};
|
2024-08-09 05:44:21 -04:00
|
|
|
|
|
|
|
Ok(RequestedVersion::SpecificVersion(channel, passed_version))
|
|
|
|
}
|
2024-08-12 14:32:53 -04:00
|
|
|
|
|
|
|
/// Channels that use Git hashes as versions are considered canary.
|
|
|
|
pub fn is_canary(&self) -> bool {
|
|
|
|
match self {
|
|
|
|
Self::Latest(channel) => {
|
|
|
|
matches!(channel, ReleaseChannel::Canary | ReleaseChannel::Rc)
|
|
|
|
}
|
|
|
|
Self::SpecificVersion(channel, _) => {
|
|
|
|
matches!(channel, ReleaseChannel::Canary | ReleaseChannel::Rc)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2024-08-09 05:44:21 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn select_specific_version_for_upgrade(
|
|
|
|
release_channel: ReleaseChannel,
|
|
|
|
version: String,
|
|
|
|
force: bool,
|
2024-08-12 14:32:53 -04:00
|
|
|
) -> Result<Option<AvailableVersion>, AnyError> {
|
2024-08-09 05:44:21 -04:00
|
|
|
match release_channel {
|
|
|
|
ReleaseChannel::Stable => {
|
2024-08-16 16:42:19 -04:00
|
|
|
let current_is_passed = if version::DENO_VERSION_INFO.release_channel
|
|
|
|
!= ReleaseChannel::Canary
|
|
|
|
{
|
2024-08-15 17:47:16 -04:00
|
|
|
version::DENO_VERSION_INFO.deno == version
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
2024-08-09 05:44:21 -04:00
|
|
|
|
|
|
|
if !force && current_is_passed {
|
2024-08-15 17:47:16 -04:00
|
|
|
log::info!(
|
|
|
|
"Version {} is already installed",
|
|
|
|
version::DENO_VERSION_INFO.deno
|
|
|
|
);
|
2024-08-09 05:44:21 -04:00
|
|
|
return Ok(None);
|
|
|
|
}
|
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
Ok(Some(AvailableVersion {
|
|
|
|
version_or_hash: version.to_string(),
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel,
|
2024-08-12 14:32:53 -04:00
|
|
|
display: version,
|
|
|
|
}))
|
2024-08-09 05:44:21 -04:00
|
|
|
}
|
|
|
|
ReleaseChannel::Canary => {
|
2024-08-15 17:47:16 -04:00
|
|
|
let current_is_passed = version::DENO_VERSION_INFO.git_hash == version;
|
2024-08-09 05:44:21 -04:00
|
|
|
if !force && current_is_passed {
|
2024-08-15 17:47:16 -04:00
|
|
|
log::info!(
|
|
|
|
"Version {} is already installed",
|
|
|
|
version::DENO_VERSION_INFO.deno
|
|
|
|
);
|
2024-08-09 05:44:21 -04:00
|
|
|
return Ok(None);
|
|
|
|
}
|
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
Ok(Some(AvailableVersion {
|
|
|
|
version_or_hash: version.to_string(),
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel,
|
2024-08-12 14:32:53 -04:00
|
|
|
display: version,
|
|
|
|
}))
|
2024-08-09 05:44:21 -04:00
|
|
|
}
|
|
|
|
// TODO(bartlomieju)
|
|
|
|
ReleaseChannel::Rc => unreachable!(),
|
|
|
|
// TODO(bartlomieju)
|
|
|
|
ReleaseChannel::Lts => unreachable!(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
async fn find_latest_version_to_upgrade(
|
|
|
|
http_client_provider: Arc<HttpClientProvider>,
|
|
|
|
release_channel: ReleaseChannel,
|
|
|
|
force: bool,
|
2024-08-12 14:32:53 -04:00
|
|
|
) -> Result<Option<AvailableVersion>, AnyError> {
|
2024-08-09 05:44:21 -04:00
|
|
|
log::info!(
|
|
|
|
"{}",
|
|
|
|
colors::gray(&format!("Looking up {} version", release_channel.name()))
|
|
|
|
);
|
|
|
|
|
|
|
|
let client = http_client_provider.get_or_create()?;
|
2024-08-12 14:32:53 -04:00
|
|
|
let latest_version_found =
|
2024-08-09 05:44:21 -04:00
|
|
|
fetch_latest_version(&client, release_channel, UpgradeCheckKind::Execution)
|
|
|
|
.await?;
|
|
|
|
|
|
|
|
let (maybe_newer_latest_version, current_version) = match release_channel {
|
|
|
|
ReleaseChannel::Stable => {
|
2024-08-15 17:47:16 -04:00
|
|
|
let current_version = version::DENO_VERSION_INFO.deno;
|
2024-08-16 16:42:19 -04:00
|
|
|
let current_is_most_recent = if version::DENO_VERSION_INFO.release_channel
|
|
|
|
!= ReleaseChannel::Canary
|
|
|
|
{
|
2024-08-15 17:47:16 -04:00
|
|
|
let current = Version::parse_standard(current_version).unwrap();
|
|
|
|
let latest =
|
|
|
|
Version::parse_standard(&latest_version_found.version_or_hash)
|
|
|
|
.unwrap();
|
|
|
|
current >= latest
|
|
|
|
} else {
|
|
|
|
false
|
|
|
|
};
|
2024-08-09 05:44:21 -04:00
|
|
|
|
|
|
|
if !force && current_is_most_recent {
|
|
|
|
(None, current_version)
|
|
|
|
} else {
|
2024-08-12 14:32:53 -04:00
|
|
|
(Some(latest_version_found), current_version)
|
2020-07-06 18:21:26 -04:00
|
|
|
}
|
|
|
|
}
|
2024-08-09 05:44:21 -04:00
|
|
|
ReleaseChannel::Canary => {
|
2024-08-15 17:47:16 -04:00
|
|
|
let current_version = version::DENO_VERSION_INFO.git_hash;
|
2024-08-12 14:32:53 -04:00
|
|
|
let current_is_most_recent =
|
|
|
|
current_version == latest_version_found.version_or_hash;
|
2024-08-09 05:44:21 -04:00
|
|
|
|
|
|
|
if !force && current_is_most_recent {
|
|
|
|
(None, current_version)
|
|
|
|
} else {
|
2024-08-12 14:32:53 -04:00
|
|
|
(Some(latest_version_found), current_version)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ReleaseChannel::Rc => {
|
2024-08-15 17:47:16 -04:00
|
|
|
let current_version = version::DENO_VERSION_INFO.git_hash;
|
2024-08-12 14:32:53 -04:00
|
|
|
let current_is_most_recent =
|
|
|
|
current_version == latest_version_found.version_or_hash;
|
|
|
|
|
|
|
|
if !force && current_is_most_recent {
|
|
|
|
(None, current_version)
|
|
|
|
} else {
|
|
|
|
(Some(latest_version_found), current_version)
|
2024-08-09 05:44:21 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
// TODO(bartlomieju)
|
|
|
|
ReleaseChannel::Lts => unreachable!(),
|
|
|
|
};
|
|
|
|
|
|
|
|
log::info!("");
|
|
|
|
if let Some(newer_latest_version) = maybe_newer_latest_version.as_ref() {
|
2024-08-07 07:59:12 -04:00
|
|
|
log::info!(
|
2024-08-13 18:32:20 -04:00
|
|
|
"Found latest {} version {}",
|
|
|
|
newer_latest_version.release_channel.name(),
|
|
|
|
color_print::cformat!("<g>{}</>", newer_latest_version.display())
|
2024-08-09 05:44:21 -04:00
|
|
|
);
|
|
|
|
} else {
|
|
|
|
log::info!(
|
2024-08-13 18:32:20 -04:00
|
|
|
"Local deno version {} is the most recent release",
|
|
|
|
color_print::cformat!("<g>{}</>", current_version)
|
2024-08-07 07:59:12 -04:00
|
|
|
);
|
2020-03-23 11:37:24 -04:00
|
|
|
}
|
2024-08-09 05:44:21 -04:00
|
|
|
log::info!("");
|
2020-05-09 06:31:15 -04:00
|
|
|
|
2024-08-09 05:44:21 -04:00
|
|
|
Ok(maybe_newer_latest_version)
|
2020-03-23 11:37:24 -04:00
|
|
|
}
|
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
#[derive(Debug, Clone, PartialEq)]
|
|
|
|
struct AvailableVersion {
|
|
|
|
version_or_hash: String,
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel: ReleaseChannel,
|
2024-08-16 16:42:19 -04:00
|
|
|
// TODO(bartlomieju): remove this one
|
2024-08-12 14:32:53 -04:00
|
|
|
display: String,
|
2024-08-09 05:44:21 -04:00
|
|
|
}
|
|
|
|
|
2024-08-13 18:32:20 -04:00
|
|
|
impl AvailableVersion {
|
|
|
|
/// Format display version, appending `v` before version number
|
|
|
|
/// for non-canary releases.
|
|
|
|
fn display(&self) -> Cow<str> {
|
|
|
|
match self.release_channel {
|
|
|
|
ReleaseChannel::Canary => Cow::Borrowed(&self.display),
|
|
|
|
_ => Cow::Owned(format!("v{}", self.display)),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-07 04:29:23 -04:00
|
|
|
async fn fetch_latest_version(
|
2022-12-12 21:30:44 -05:00
|
|
|
client: &HttpClient,
|
2024-08-07 04:29:23 -04:00
|
|
|
release_channel: ReleaseChannel,
|
2023-11-17 16:40:12 -05:00
|
|
|
check_kind: UpgradeCheckKind,
|
2024-08-12 14:32:53 -04:00
|
|
|
) -> Result<AvailableVersion, AnyError> {
|
2024-08-07 04:29:23 -04:00
|
|
|
let url = get_latest_version_url(release_channel, env!("TARGET"), check_kind);
|
2024-07-17 19:37:31 -04:00
|
|
|
let text = client.download_text(url.parse()?).await?;
|
2024-08-12 14:32:53 -04:00
|
|
|
let version = normalize_version_from_server(release_channel, &text)?;
|
|
|
|
Ok(version)
|
2020-03-23 11:37:24 -04:00
|
|
|
}
|
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
fn normalize_version_from_server(
|
2024-08-07 04:29:23 -04:00
|
|
|
release_channel: ReleaseChannel,
|
2023-11-17 16:40:12 -05:00
|
|
|
text: &str,
|
2024-08-12 14:32:53 -04:00
|
|
|
) -> Result<AvailableVersion, AnyError> {
|
2023-11-17 16:40:12 -05:00
|
|
|
let text = text.trim();
|
2024-08-07 04:29:23 -04:00
|
|
|
match release_channel {
|
2024-08-16 16:42:19 -04:00
|
|
|
ReleaseChannel::Stable | ReleaseChannel::Rc | ReleaseChannel::Lts => {
|
2024-08-12 14:32:53 -04:00
|
|
|
let v = text.trim_start_matches('v').to_string();
|
|
|
|
Ok(AvailableVersion {
|
|
|
|
version_or_hash: v.to_string(),
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel,
|
2024-08-12 14:32:53 -04:00
|
|
|
display: v.to_string(),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
ReleaseChannel::Canary => Ok(AvailableVersion {
|
|
|
|
version_or_hash: text.to_string(),
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel,
|
2024-08-12 14:32:53 -04:00
|
|
|
display: text.to_string(),
|
|
|
|
}),
|
2023-11-14 17:10:51 -05:00
|
|
|
}
|
2023-11-17 16:40:12 -05:00
|
|
|
}
|
|
|
|
|
2024-08-07 04:29:23 -04:00
|
|
|
fn get_latest_version_url(
|
|
|
|
release_channel: ReleaseChannel,
|
2024-01-30 14:50:54 -05:00
|
|
|
target_tuple: &str,
|
2023-11-17 16:40:12 -05:00
|
|
|
check_kind: UpgradeCheckKind,
|
|
|
|
) -> String {
|
2024-08-07 04:29:23 -04:00
|
|
|
let file_name = match release_channel {
|
|
|
|
ReleaseChannel::Stable => Cow::Borrowed("release-latest.txt"),
|
|
|
|
ReleaseChannel::Canary => {
|
2024-01-30 14:50:54 -05:00
|
|
|
Cow::Owned(format!("canary-{target_tuple}-latest.txt"))
|
|
|
|
}
|
2024-08-12 14:32:53 -04:00
|
|
|
ReleaseChannel::Rc => Cow::Borrowed("release-rc.txt"),
|
2024-08-07 04:29:23 -04:00
|
|
|
_ => unreachable!(),
|
2023-11-17 16:40:12 -05:00
|
|
|
};
|
|
|
|
let query_param = match check_kind {
|
|
|
|
UpgradeCheckKind::Execution => "",
|
|
|
|
UpgradeCheckKind::Lsp => "?lsp",
|
|
|
|
};
|
2023-11-17 22:46:15 -05:00
|
|
|
format!("{}/{}{}", base_upgrade_url(), file_name, query_param)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn base_upgrade_url() -> Cow<'static, str> {
|
2023-11-23 11:20:40 -05:00
|
|
|
// this is used by the test suite
|
2023-11-17 22:46:15 -05:00
|
|
|
if let Ok(url) = env::var("DENO_DONT_USE_INTERNAL_BASE_UPGRADE_URL") {
|
|
|
|
Cow::Owned(url)
|
|
|
|
} else {
|
|
|
|
Cow::Borrowed("https://dl.deno.land")
|
|
|
|
}
|
2020-11-29 14:00:35 -05:00
|
|
|
}
|
|
|
|
|
2024-08-09 05:44:21 -04:00
|
|
|
fn get_download_url(version: &str, is_canary: bool) -> Result<Url, AnyError> {
|
|
|
|
let download_url = if is_canary {
|
|
|
|
format!("{}/{}/{}", CANARY_URL, version, *ARCHIVE_NAME)
|
|
|
|
} else {
|
|
|
|
format!("{}/download/v{}/{}", RELEASE_URL, version, *ARCHIVE_NAME)
|
|
|
|
};
|
|
|
|
|
|
|
|
Url::parse(&download_url).with_context(|| {
|
|
|
|
format!(
|
|
|
|
"Failed to parse URL to download new release: {}",
|
|
|
|
download_url
|
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-11-22 10:07:05 -05:00
|
|
|
async fn download_package(
|
2022-12-12 21:30:44 -05:00
|
|
|
client: &HttpClient,
|
2024-08-09 05:44:21 -04:00
|
|
|
download_url: Url,
|
|
|
|
) -> Result<Option<Vec<u8>>, AnyError> {
|
|
|
|
let progress_bar = ProgressBar::new(ProgressBarStyle::DownloadBars);
|
|
|
|
// provide an empty string here in order to prefer the downloading
|
|
|
|
// text above which will stay alive after the progress bars are complete
|
|
|
|
let progress = progress_bar.update("");
|
|
|
|
let maybe_bytes = client
|
|
|
|
.download_with_progress(download_url.clone(), None, &progress)
|
|
|
|
.await
|
|
|
|
.with_context(|| format!("Failed downloading {download_url}. The version you requested may not have been built for the current architecture."))?;
|
|
|
|
Ok(maybe_bytes)
|
2020-03-23 11:37:24 -04:00
|
|
|
}
|
|
|
|
|
2022-12-02 14:53:10 -05:00
|
|
|
fn replace_exe(from: &Path, to: &Path) -> Result<(), std::io::Error> {
|
2020-03-23 11:37:24 -04:00
|
|
|
if cfg!(windows) {
|
|
|
|
// On windows you cannot replace the currently running executable.
|
|
|
|
// so first we rename it to deno.old.exe
|
2022-12-02 14:53:10 -05:00
|
|
|
fs::rename(to, to.with_extension("old.exe"))?;
|
2020-03-23 11:37:24 -04:00
|
|
|
} else {
|
2022-12-02 14:53:10 -05:00
|
|
|
fs::remove_file(to)?;
|
2020-03-23 11:37:24 -04:00
|
|
|
}
|
|
|
|
// Windows cannot rename files across device boundaries, so if rename fails,
|
|
|
|
// we try again with copy.
|
2022-12-02 14:53:10 -05:00
|
|
|
fs::rename(from, to).or_else(|_| fs::copy(from, to).map(|_| ()))?;
|
2020-03-23 11:37:24 -04:00
|
|
|
Ok(())
|
|
|
|
}
|
|
|
|
|
2024-08-09 05:44:21 -04:00
|
|
|
fn check_windows_access_denied_error(
|
|
|
|
output_result: Result<(), std::io::Error>,
|
|
|
|
output_exe_path: &Path,
|
|
|
|
) -> Result<(), AnyError> {
|
|
|
|
let Err(err) = output_result else {
|
|
|
|
return Ok(());
|
|
|
|
};
|
|
|
|
|
|
|
|
if !cfg!(windows) {
|
|
|
|
return Err(err.into());
|
|
|
|
}
|
|
|
|
|
|
|
|
const WIN_ERROR_ACCESS_DENIED: i32 = 5;
|
|
|
|
if err.raw_os_error() != Some(WIN_ERROR_ACCESS_DENIED) {
|
|
|
|
return Err(err.into());
|
|
|
|
};
|
|
|
|
|
|
|
|
Err(err).with_context(|| {
|
|
|
|
format!(
|
|
|
|
concat!(
|
|
|
|
"Could not replace the deno executable. This may be because an ",
|
|
|
|
"existing deno process is running. Please ensure there are no ",
|
|
|
|
"running deno processes (ex. Stop-Process -Name deno ; deno {}), ",
|
|
|
|
"close any editors before upgrading, and ensure you have ",
|
|
|
|
"sufficient permission to '{}'."
|
|
|
|
),
|
|
|
|
// skip the first argument, which is the executable path
|
|
|
|
std::env::args().skip(1).collect::<Vec<_>>().join(" "),
|
|
|
|
output_exe_path.display(),
|
|
|
|
)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
fn set_exe_permissions(
|
|
|
|
current_exe_path: &Path,
|
|
|
|
output_exe_path: &Path,
|
|
|
|
) -> Result<std::fs::Permissions, AnyError> {
|
|
|
|
let Ok(metadata) = fs::metadata(output_exe_path) else {
|
|
|
|
let metadata = fs::metadata(current_exe_path)?;
|
|
|
|
return Ok(metadata.permissions());
|
|
|
|
};
|
|
|
|
|
|
|
|
let permissions = metadata.permissions();
|
|
|
|
if permissions.readonly() {
|
|
|
|
bail!(
|
|
|
|
"You do not have write permission to {}",
|
|
|
|
output_exe_path.display()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
#[cfg(unix)]
|
|
|
|
if std::os::unix::fs::MetadataExt::uid(&metadata) == 0
|
|
|
|
&& !nix::unistd::Uid::effective().is_root()
|
|
|
|
{
|
|
|
|
bail!(concat!(
|
|
|
|
"You don't have write permission to {} because it's owned by root.\n",
|
|
|
|
"Consider updating deno through your package manager if its installed from it.\n",
|
|
|
|
"Otherwise run `deno upgrade` as root.",
|
|
|
|
), output_exe_path.display());
|
|
|
|
}
|
|
|
|
Ok(permissions)
|
|
|
|
}
|
|
|
|
|
2020-11-29 14:00:35 -05:00
|
|
|
fn check_exe(exe_path: &Path) -> Result<(), AnyError> {
|
2020-03-23 11:37:24 -04:00
|
|
|
let output = Command::new(exe_path)
|
|
|
|
.arg("-V")
|
|
|
|
.stderr(std::process::Stdio::inherit())
|
|
|
|
.output()?;
|
|
|
|
assert!(output.status.success());
|
|
|
|
Ok(())
|
|
|
|
}
|
2022-10-20 10:15:21 -04:00
|
|
|
|
2022-10-22 14:31:25 -04:00
|
|
|
#[derive(Debug)]
|
2022-10-20 17:01:17 -04:00
|
|
|
struct CheckVersionFile {
|
2022-10-20 19:50:55 -04:00
|
|
|
pub last_prompt: chrono::DateTime<chrono::Utc>,
|
2022-10-20 17:01:17 -04:00
|
|
|
pub last_checked: chrono::DateTime<chrono::Utc>,
|
2022-11-05 19:06:58 -04:00
|
|
|
pub current_version: String,
|
2022-10-20 17:01:17 -04:00
|
|
|
pub latest_version: String,
|
2024-08-12 14:32:53 -04:00
|
|
|
pub current_release_channel: ReleaseChannel,
|
2022-10-20 17:01:17 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
impl CheckVersionFile {
|
|
|
|
pub fn parse(content: String) -> Option<Self> {
|
|
|
|
let split_content = content.split('!').collect::<Vec<_>>();
|
2022-10-20 10:15:21 -04:00
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
if split_content.len() != 5 {
|
2022-10-20 17:01:17 -04:00
|
|
|
return None;
|
|
|
|
}
|
2022-10-20 10:15:21 -04:00
|
|
|
|
2022-10-20 19:50:55 -04:00
|
|
|
let latest_version = split_content[2].trim().to_owned();
|
2022-10-20 17:01:17 -04:00
|
|
|
if latest_version.is_empty() {
|
|
|
|
return None;
|
2022-10-20 10:15:21 -04:00
|
|
|
}
|
2022-11-05 19:06:58 -04:00
|
|
|
let current_version = split_content[3].trim().to_owned();
|
|
|
|
if current_version.is_empty() {
|
|
|
|
return None;
|
|
|
|
}
|
2024-08-12 14:32:53 -04:00
|
|
|
let current_release_channel = split_content[4].trim().to_owned();
|
|
|
|
if current_release_channel.is_empty() {
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
let Ok(current_release_channel) =
|
|
|
|
ReleaseChannel::deserialize(¤t_release_channel)
|
|
|
|
else {
|
|
|
|
return None;
|
|
|
|
};
|
2022-10-20 17:01:17 -04:00
|
|
|
|
2022-10-20 19:50:55 -04:00
|
|
|
let last_prompt = chrono::DateTime::parse_from_rfc3339(split_content[0])
|
|
|
|
.map(|dt| dt.with_timezone(&chrono::Utc))
|
|
|
|
.ok()?;
|
|
|
|
let last_checked = chrono::DateTime::parse_from_rfc3339(split_content[1])
|
2022-10-20 17:01:17 -04:00
|
|
|
.map(|dt| dt.with_timezone(&chrono::Utc))
|
|
|
|
.ok()?;
|
|
|
|
|
|
|
|
Some(CheckVersionFile {
|
2022-10-20 19:50:55 -04:00
|
|
|
last_prompt,
|
2022-10-20 17:01:17 -04:00
|
|
|
last_checked,
|
2022-11-05 19:06:58 -04:00
|
|
|
current_version,
|
2022-10-20 17:01:17 -04:00
|
|
|
latest_version,
|
2024-08-12 14:32:53 -04:00
|
|
|
current_release_channel,
|
2022-10-20 17:01:17 -04:00
|
|
|
})
|
2022-10-20 10:15:21 -04:00
|
|
|
}
|
|
|
|
|
2022-10-20 19:50:55 -04:00
|
|
|
fn serialize(&self) -> String {
|
|
|
|
format!(
|
2024-08-12 14:32:53 -04:00
|
|
|
"{}!{}!{}!{}!{}",
|
2022-10-20 19:50:55 -04:00
|
|
|
self.last_prompt.to_rfc3339(),
|
|
|
|
self.last_checked.to_rfc3339(),
|
2022-11-05 19:06:58 -04:00
|
|
|
self.latest_version,
|
|
|
|
self.current_version,
|
2024-08-15 17:47:16 -04:00
|
|
|
self.current_release_channel.serialize()
|
2022-10-20 19:50:55 -04:00
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn with_last_prompt(self, dt: chrono::DateTime<chrono::Utc>) -> Self {
|
|
|
|
Self {
|
|
|
|
last_prompt: dt,
|
|
|
|
..self
|
|
|
|
}
|
|
|
|
}
|
2022-10-20 10:15:21 -04:00
|
|
|
}
|
|
|
|
|
2022-10-20 17:01:17 -04:00
|
|
|
#[cfg(test)]
|
|
|
|
mod test {
|
2023-11-17 16:40:12 -05:00
|
|
|
use std::cell::RefCell;
|
|
|
|
use std::rc::Rc;
|
2022-10-22 14:31:25 -04:00
|
|
|
|
2022-10-20 17:01:17 -04:00
|
|
|
use super::*;
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_parse_upgrade_check_file() {
|
2024-08-12 14:32:53 -04:00
|
|
|
// NOTE(bartlomieju): pre-1.46 format
|
|
|
|
let maybe_file = CheckVersionFile::parse(
|
2022-11-05 19:06:58 -04:00
|
|
|
"2020-01-01T00:00:00+00:00!2020-01-01T00:00:00+00:00!1.2.3!1.2.2"
|
|
|
|
.to_string(),
|
2024-08-12 14:32:53 -04:00
|
|
|
);
|
|
|
|
assert!(maybe_file.is_none());
|
|
|
|
// NOTE(bartlomieju): post-1.46 format
|
|
|
|
let file = CheckVersionFile::parse(
|
|
|
|
"2020-01-01T00:00:00+00:00!2020-01-01T00:00:00+00:00!1.2.3!1.2.2!stable"
|
|
|
|
.to_string(),
|
2022-10-20 19:50:55 -04:00
|
|
|
)
|
|
|
|
.unwrap();
|
|
|
|
assert_eq!(
|
|
|
|
file.last_prompt.to_rfc3339(),
|
|
|
|
"2020-01-01T00:00:00+00:00".to_string()
|
|
|
|
);
|
2022-10-20 17:01:17 -04:00
|
|
|
assert_eq!(
|
|
|
|
file.last_checked.to_rfc3339(),
|
|
|
|
"2020-01-01T00:00:00+00:00".to_string()
|
|
|
|
);
|
|
|
|
assert_eq!(file.latest_version, "1.2.3".to_string());
|
2022-11-05 19:06:58 -04:00
|
|
|
assert_eq!(file.current_version, "1.2.2".to_string());
|
2024-08-12 14:32:53 -04:00
|
|
|
assert_eq!(file.current_release_channel, ReleaseChannel::Stable);
|
2022-10-20 10:15:21 -04:00
|
|
|
|
2022-10-20 17:01:17 -04:00
|
|
|
let result =
|
|
|
|
CheckVersionFile::parse("2020-01-01T00:00:00+00:00!".to_string());
|
|
|
|
assert!(result.is_none());
|
|
|
|
|
|
|
|
let result = CheckVersionFile::parse("garbage!test".to_string());
|
|
|
|
assert!(result.is_none());
|
|
|
|
|
|
|
|
let result = CheckVersionFile::parse("test".to_string());
|
|
|
|
assert!(result.is_none());
|
|
|
|
}
|
2022-10-20 10:15:21 -04:00
|
|
|
|
2022-10-20 17:01:17 -04:00
|
|
|
#[test]
|
|
|
|
fn test_serialize_upgrade_check_file() {
|
2024-08-12 14:32:53 -04:00
|
|
|
let mut file = CheckVersionFile {
|
2022-10-20 19:50:55 -04:00
|
|
|
last_prompt: chrono::DateTime::parse_from_rfc3339("2020-01-01T00:00:00Z")
|
|
|
|
.unwrap()
|
|
|
|
.with_timezone(&chrono::Utc),
|
2022-10-20 17:01:17 -04:00
|
|
|
last_checked: chrono::DateTime::parse_from_rfc3339(
|
|
|
|
"2020-01-01T00:00:00Z",
|
|
|
|
)
|
2022-10-20 10:15:21 -04:00
|
|
|
.unwrap()
|
|
|
|
.with_timezone(&chrono::Utc),
|
2022-10-20 17:01:17 -04:00
|
|
|
latest_version: "1.2.3".to_string(),
|
2022-11-05 19:06:58 -04:00
|
|
|
current_version: "1.2.2".to_string(),
|
2024-08-12 14:32:53 -04:00
|
|
|
current_release_channel: ReleaseChannel::Stable,
|
2022-10-20 17:01:17 -04:00
|
|
|
};
|
2022-10-20 19:50:55 -04:00
|
|
|
assert_eq!(
|
|
|
|
file.serialize(),
|
2024-08-12 14:32:53 -04:00
|
|
|
"2020-01-01T00:00:00+00:00!2020-01-01T00:00:00+00:00!1.2.3!1.2.2!stable"
|
|
|
|
);
|
|
|
|
file.current_release_channel = ReleaseChannel::Canary;
|
|
|
|
assert_eq!(
|
|
|
|
file.serialize(),
|
|
|
|
"2020-01-01T00:00:00+00:00!2020-01-01T00:00:00+00:00!1.2.3!1.2.2!canary"
|
|
|
|
);
|
|
|
|
file.current_release_channel = ReleaseChannel::Rc;
|
|
|
|
assert_eq!(
|
|
|
|
file.serialize(),
|
|
|
|
"2020-01-01T00:00:00+00:00!2020-01-01T00:00:00+00:00!1.2.3!1.2.2!rc"
|
|
|
|
);
|
|
|
|
file.current_release_channel = ReleaseChannel::Lts;
|
|
|
|
assert_eq!(
|
|
|
|
file.serialize(),
|
|
|
|
"2020-01-01T00:00:00+00:00!2020-01-01T00:00:00+00:00!1.2.3!1.2.2!lts"
|
2022-10-20 19:50:55 -04:00
|
|
|
);
|
2022-10-20 17:01:17 -04:00
|
|
|
}
|
2022-10-22 14:31:25 -04:00
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
struct TestUpdateCheckerEnvironment {
|
2023-11-17 16:40:12 -05:00
|
|
|
file_text: Rc<RefCell<String>>,
|
2024-08-12 14:32:53 -04:00
|
|
|
release_channel: Rc<RefCell<ReleaseChannel>>,
|
2023-11-17 16:40:12 -05:00
|
|
|
current_version: Rc<RefCell<String>>,
|
2024-08-12 14:32:53 -04:00
|
|
|
latest_version: Rc<RefCell<Result<AvailableVersion, String>>>,
|
2023-11-17 16:40:12 -05:00
|
|
|
time: Rc<RefCell<chrono::DateTime<chrono::Utc>>>,
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
impl TestUpdateCheckerEnvironment {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
Self {
|
|
|
|
file_text: Default::default(),
|
|
|
|
current_version: Default::default(),
|
2024-08-12 14:32:53 -04:00
|
|
|
release_channel: Rc::new(RefCell::new(ReleaseChannel::Stable)),
|
|
|
|
latest_version: Rc::new(RefCell::new(Ok(AvailableVersion {
|
|
|
|
version_or_hash: "".to_string(),
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel: ReleaseChannel::Stable,
|
2024-08-12 14:32:53 -04:00
|
|
|
display: "".to_string(),
|
|
|
|
}))),
|
2024-05-23 07:59:11 -04:00
|
|
|
time: Rc::new(RefCell::new(chrono::Utc::now())),
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add_hours(&self, hours: i64) {
|
2023-11-17 16:40:12 -05:00
|
|
|
let mut time = self.time.borrow_mut();
|
2022-10-22 14:31:25 -04:00
|
|
|
*time = time
|
|
|
|
.checked_add_signed(chrono::Duration::hours(hours))
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_file_text(&self, text: &str) {
|
2023-11-17 16:40:12 -05:00
|
|
|
*self.file_text.borrow_mut() = text.to_string();
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_current_version(&self, version: &str) {
|
2023-11-17 16:40:12 -05:00
|
|
|
*self.current_version.borrow_mut() = version.to_string();
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
|
2024-08-13 18:32:20 -04:00
|
|
|
pub fn set_latest_version(
|
|
|
|
&self,
|
|
|
|
version: &str,
|
|
|
|
release_channel: ReleaseChannel,
|
|
|
|
) {
|
2024-08-12 14:32:53 -04:00
|
|
|
*self.latest_version.borrow_mut() = Ok(AvailableVersion {
|
|
|
|
version_or_hash: version.to_string(),
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel,
|
2024-08-12 14:32:53 -04:00
|
|
|
display: version.to_string(),
|
|
|
|
});
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
pub fn set_latest_version_err(&self, err: &str) {
|
2023-11-17 16:40:12 -05:00
|
|
|
*self.latest_version.borrow_mut() = Err(err.to_string());
|
|
|
|
}
|
|
|
|
|
2024-08-12 14:32:53 -04:00
|
|
|
pub fn set_release_channel(&self, channel: ReleaseChannel) {
|
|
|
|
*self.release_channel.borrow_mut() = channel;
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
#[async_trait(?Send)]
|
|
|
|
impl VersionProvider for TestUpdateCheckerEnvironment {
|
2024-08-07 04:29:23 -04:00
|
|
|
// TODO(bartlomieju): update to handle `Lts` and `Rc` channels
|
|
|
|
async fn latest_version(
|
|
|
|
&self,
|
|
|
|
_release_channel: ReleaseChannel,
|
2024-08-12 14:32:53 -04:00
|
|
|
) -> Result<AvailableVersion, AnyError> {
|
2023-11-17 16:40:12 -05:00
|
|
|
match self.latest_version.borrow().clone() {
|
|
|
|
Ok(result) => Ok(result),
|
|
|
|
Err(err) => bail!("{}", err),
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
fn current_version(&self) -> Cow<str> {
|
2023-11-17 16:40:12 -05:00
|
|
|
Cow::Owned(self.current_version.borrow().clone())
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
2024-08-07 04:29:23 -04:00
|
|
|
|
2024-08-16 16:42:19 -04:00
|
|
|
fn get_current_exe_release_channel(&self) -> ReleaseChannel {
|
|
|
|
*self.release_channel.borrow()
|
2024-08-07 04:29:23 -04:00
|
|
|
}
|
2023-11-17 16:40:12 -05:00
|
|
|
}
|
2022-10-22 14:31:25 -04:00
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
impl UpdateCheckerEnvironment for TestUpdateCheckerEnvironment {
|
2022-10-22 14:31:25 -04:00
|
|
|
fn read_check_file(&self) -> String {
|
2023-11-17 16:40:12 -05:00
|
|
|
self.file_text.borrow().clone()
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
fn write_check_file(&self, text: &str) {
|
|
|
|
self.set_file_text(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
fn current_time(&self) -> chrono::DateTime<chrono::Utc> {
|
2023-11-17 16:40:12 -05:00
|
|
|
*self.time.borrow()
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn test_update_checker() {
|
|
|
|
let env = TestUpdateCheckerEnvironment::new();
|
|
|
|
env.set_current_version("1.0.0");
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("1.1.0", ReleaseChannel::Stable);
|
2023-11-17 16:40:12 -05:00
|
|
|
let checker = UpdateChecker::new(env.clone(), env.clone());
|
2022-10-22 14:31:25 -04:00
|
|
|
|
|
|
|
// no version, so we should check, but not prompt
|
|
|
|
assert!(checker.should_check_for_new_version());
|
|
|
|
assert_eq!(checker.should_prompt(), None);
|
|
|
|
|
|
|
|
// store the latest version
|
2023-11-17 16:40:12 -05:00
|
|
|
fetch_and_store_latest_version(&env, &env).await;
|
2022-10-22 14:31:25 -04:00
|
|
|
|
|
|
|
// reload
|
2023-11-17 16:40:12 -05:00
|
|
|
let checker = UpdateChecker::new(env.clone(), env.clone());
|
2022-10-22 14:31:25 -04:00
|
|
|
|
|
|
|
// should not check for latest version because we just did
|
|
|
|
assert!(!checker.should_check_for_new_version());
|
|
|
|
// but should prompt
|
2024-08-12 14:32:53 -04:00
|
|
|
assert_eq!(
|
|
|
|
checker.should_prompt(),
|
|
|
|
Some((ReleaseChannel::Stable, "1.1.0".to_string()))
|
|
|
|
);
|
2022-10-22 14:31:25 -04:00
|
|
|
|
|
|
|
// fast forward an hour and bump the latest version
|
|
|
|
env.add_hours(1);
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("1.2.0", ReleaseChannel::Stable);
|
2022-10-22 14:31:25 -04:00
|
|
|
assert!(!checker.should_check_for_new_version());
|
2024-08-12 14:32:53 -04:00
|
|
|
assert_eq!(
|
|
|
|
checker.should_prompt(),
|
|
|
|
Some((ReleaseChannel::Stable, "1.1.0".to_string()))
|
|
|
|
);
|
2022-10-22 14:31:25 -04:00
|
|
|
|
|
|
|
// fast forward again and it should check for a newer version
|
|
|
|
env.add_hours(UPGRADE_CHECK_INTERVAL);
|
|
|
|
assert!(checker.should_check_for_new_version());
|
2024-08-12 14:32:53 -04:00
|
|
|
assert_eq!(
|
|
|
|
checker.should_prompt(),
|
|
|
|
Some((ReleaseChannel::Stable, "1.1.0".to_string()))
|
|
|
|
);
|
2022-10-22 14:31:25 -04:00
|
|
|
|
2023-11-17 16:40:12 -05:00
|
|
|
fetch_and_store_latest_version(&env, &env).await;
|
2022-10-22 14:31:25 -04:00
|
|
|
|
|
|
|
// reload and store that we prompted
|
2023-11-17 16:40:12 -05:00
|
|
|
let checker = UpdateChecker::new(env.clone(), env.clone());
|
2022-10-22 14:31:25 -04:00
|
|
|
assert!(!checker.should_check_for_new_version());
|
2024-08-12 14:32:53 -04:00
|
|
|
assert_eq!(
|
|
|
|
checker.should_prompt(),
|
|
|
|
Some((ReleaseChannel::Stable, "1.2.0".to_string()))
|
|
|
|
);
|
2022-10-22 14:31:25 -04:00
|
|
|
checker.store_prompted();
|
|
|
|
|
|
|
|
// reload and it should now say not to prompt
|
2023-11-17 16:40:12 -05:00
|
|
|
let checker = UpdateChecker::new(env.clone(), env.clone());
|
2022-10-22 14:31:25 -04:00
|
|
|
assert!(!checker.should_check_for_new_version());
|
|
|
|
assert_eq!(checker.should_prompt(), None);
|
|
|
|
|
|
|
|
// but if we fast forward past the upgrade interval it should prompt again
|
|
|
|
env.add_hours(UPGRADE_CHECK_INTERVAL + 1);
|
|
|
|
assert!(checker.should_check_for_new_version());
|
2024-08-12 14:32:53 -04:00
|
|
|
assert_eq!(
|
|
|
|
checker.should_prompt(),
|
|
|
|
Some((ReleaseChannel::Stable, "1.2.0".to_string()))
|
|
|
|
);
|
2022-10-22 14:31:25 -04:00
|
|
|
|
|
|
|
// upgrade the version and it should stop prompting
|
|
|
|
env.set_current_version("1.2.0");
|
|
|
|
assert!(checker.should_check_for_new_version());
|
|
|
|
assert_eq!(checker.should_prompt(), None);
|
|
|
|
|
|
|
|
// now try failing when fetching the latest version
|
|
|
|
env.add_hours(UPGRADE_CHECK_INTERVAL + 1);
|
|
|
|
env.set_latest_version_err("Failed");
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("1.3.0", ReleaseChannel::Stable);
|
2022-10-22 14:31:25 -04:00
|
|
|
|
|
|
|
// this will silently fail
|
2023-11-17 16:40:12 -05:00
|
|
|
fetch_and_store_latest_version(&env, &env).await;
|
2022-10-22 14:31:25 -04:00
|
|
|
assert!(checker.should_check_for_new_version());
|
|
|
|
assert_eq!(checker.should_prompt(), None);
|
2024-08-12 14:32:53 -04:00
|
|
|
|
|
|
|
// now switch to RC release
|
|
|
|
env.set_release_channel(ReleaseChannel::Rc);
|
|
|
|
env.set_current_version("1.46.0-rc.0");
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("1.46.0-rc.1", ReleaseChannel::Rc);
|
2024-08-12 14:32:53 -04:00
|
|
|
fetch_and_store_latest_version(&env, &env).await;
|
|
|
|
env.add_hours(UPGRADE_CHECK_INTERVAL + 1);
|
|
|
|
|
|
|
|
// We should check for new version and prompt
|
|
|
|
let checker = UpdateChecker::new(env.clone(), env.clone());
|
|
|
|
assert!(checker.should_check_for_new_version());
|
|
|
|
assert_eq!(
|
|
|
|
checker.should_prompt(),
|
|
|
|
Some((ReleaseChannel::Rc, "1.46.0-rc.1".to_string()))
|
|
|
|
);
|
2022-10-22 14:31:25 -04:00
|
|
|
}
|
2022-10-28 12:43:49 -04:00
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn test_update_checker_current_newer_than_latest() {
|
|
|
|
let env = TestUpdateCheckerEnvironment::new();
|
|
|
|
let file_content = CheckVersionFile {
|
|
|
|
last_prompt: env
|
|
|
|
.current_time()
|
|
|
|
.sub(chrono::Duration::hours(UPGRADE_CHECK_INTERVAL + 1)),
|
|
|
|
last_checked: env.current_time(),
|
|
|
|
latest_version: "1.26.2".to_string(),
|
2022-11-05 19:06:58 -04:00
|
|
|
current_version: "1.27.0".to_string(),
|
2024-08-12 14:32:53 -04:00
|
|
|
current_release_channel: ReleaseChannel::Stable,
|
2022-10-28 12:43:49 -04:00
|
|
|
}
|
|
|
|
.serialize();
|
|
|
|
env.write_check_file(&file_content);
|
|
|
|
env.set_current_version("1.27.0");
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("1.26.2", ReleaseChannel::Stable);
|
2023-11-17 16:40:12 -05:00
|
|
|
let checker = UpdateChecker::new(env.clone(), env);
|
2022-10-28 12:43:49 -04:00
|
|
|
|
|
|
|
// since currently running version is newer than latest available (eg. CDN
|
|
|
|
// propagation might be delated) we should not prompt
|
|
|
|
assert_eq!(checker.should_prompt(), None);
|
|
|
|
}
|
2022-11-05 19:06:58 -04:00
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn test_should_not_prompt_if_current_cli_version_has_changed() {
|
|
|
|
let env = TestUpdateCheckerEnvironment::new();
|
|
|
|
let file_content = CheckVersionFile {
|
|
|
|
last_prompt: env
|
|
|
|
.current_time()
|
|
|
|
.sub(chrono::Duration::hours(UPGRADE_CHECK_INTERVAL + 1)),
|
|
|
|
last_checked: env.current_time(),
|
|
|
|
latest_version: "1.26.2".to_string(),
|
|
|
|
current_version: "1.25.0".to_string(),
|
2024-08-12 14:32:53 -04:00
|
|
|
current_release_channel: ReleaseChannel::Stable,
|
2022-11-05 19:06:58 -04:00
|
|
|
}
|
|
|
|
.serialize();
|
|
|
|
env.write_check_file(&file_content);
|
|
|
|
// simulate an upgrade done to a canary version
|
|
|
|
env.set_current_version("61fbfabe440f1cfffa7b8d17426ffdece4d430d0");
|
2023-11-17 16:40:12 -05:00
|
|
|
let checker = UpdateChecker::new(env.clone(), env);
|
2022-11-05 19:06:58 -04:00
|
|
|
assert_eq!(checker.should_prompt(), None);
|
|
|
|
}
|
2023-11-17 16:40:12 -05:00
|
|
|
|
|
|
|
#[test]
|
2024-08-07 04:29:23 -04:00
|
|
|
fn test_get_latest_version_url() {
|
2023-11-17 16:40:12 -05:00
|
|
|
assert_eq!(
|
2024-08-07 04:29:23 -04:00
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Canary,
|
2024-01-30 14:50:54 -05:00
|
|
|
"aarch64-apple-darwin",
|
|
|
|
UpgradeCheckKind::Execution
|
|
|
|
),
|
|
|
|
"https://dl.deno.land/canary-aarch64-apple-darwin-latest.txt"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2024-08-07 04:29:23 -04:00
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Canary,
|
2024-01-30 14:50:54 -05:00
|
|
|
"aarch64-apple-darwin",
|
|
|
|
UpgradeCheckKind::Lsp
|
|
|
|
),
|
|
|
|
"https://dl.deno.land/canary-aarch64-apple-darwin-latest.txt?lsp"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2024-08-07 04:29:23 -04:00
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Canary,
|
2024-01-30 14:50:54 -05:00
|
|
|
"x86_64-pc-windows-msvc",
|
|
|
|
UpgradeCheckKind::Execution
|
|
|
|
),
|
|
|
|
"https://dl.deno.land/canary-x86_64-pc-windows-msvc-latest.txt"
|
2023-11-17 16:40:12 -05:00
|
|
|
);
|
|
|
|
assert_eq!(
|
2024-08-07 04:29:23 -04:00
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Canary,
|
2024-01-30 14:50:54 -05:00
|
|
|
"x86_64-pc-windows-msvc",
|
|
|
|
UpgradeCheckKind::Lsp
|
|
|
|
),
|
|
|
|
"https://dl.deno.land/canary-x86_64-pc-windows-msvc-latest.txt?lsp"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2024-08-07 04:29:23 -04:00
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Stable,
|
2024-01-30 14:50:54 -05:00
|
|
|
"aarch64-apple-darwin",
|
|
|
|
UpgradeCheckKind::Execution
|
|
|
|
),
|
|
|
|
"https://dl.deno.land/release-latest.txt"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2024-08-07 04:29:23 -04:00
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Stable,
|
2024-01-30 14:50:54 -05:00
|
|
|
"aarch64-apple-darwin",
|
|
|
|
UpgradeCheckKind::Lsp
|
|
|
|
),
|
|
|
|
"https://dl.deno.land/release-latest.txt?lsp"
|
2023-11-17 16:40:12 -05:00
|
|
|
);
|
|
|
|
assert_eq!(
|
2024-08-07 04:29:23 -04:00
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Stable,
|
2024-01-30 14:50:54 -05:00
|
|
|
"x86_64-pc-windows-msvc",
|
|
|
|
UpgradeCheckKind::Execution
|
|
|
|
),
|
2023-11-17 16:40:12 -05:00
|
|
|
"https://dl.deno.land/release-latest.txt"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2024-08-07 04:29:23 -04:00
|
|
|
get_latest_version_url(
|
2024-08-12 14:32:53 -04:00
|
|
|
ReleaseChannel::Rc,
|
2024-01-30 14:50:54 -05:00
|
|
|
"x86_64-pc-windows-msvc",
|
|
|
|
UpgradeCheckKind::Lsp
|
|
|
|
),
|
2024-08-12 14:32:53 -04:00
|
|
|
"https://dl.deno.land/release-rc.txt?lsp"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Rc,
|
|
|
|
"aarch64-apple-darwin",
|
|
|
|
UpgradeCheckKind::Execution
|
|
|
|
),
|
|
|
|
"https://dl.deno.land/release-rc.txt"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Rc,
|
|
|
|
"aarch64-apple-darwin",
|
|
|
|
UpgradeCheckKind::Lsp
|
|
|
|
),
|
|
|
|
"https://dl.deno.land/release-rc.txt?lsp"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Rc,
|
|
|
|
"x86_64-pc-windows-msvc",
|
|
|
|
UpgradeCheckKind::Execution
|
|
|
|
),
|
|
|
|
"https://dl.deno.land/release-rc.txt"
|
|
|
|
);
|
|
|
|
assert_eq!(
|
|
|
|
get_latest_version_url(
|
|
|
|
ReleaseChannel::Rc,
|
|
|
|
"x86_64-pc-windows-msvc",
|
|
|
|
UpgradeCheckKind::Lsp
|
|
|
|
),
|
|
|
|
"https://dl.deno.land/release-rc.txt?lsp"
|
2023-11-17 16:40:12 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_normalize_version_server() {
|
|
|
|
// should strip v for stable
|
|
|
|
assert_eq!(
|
2024-08-12 14:32:53 -04:00
|
|
|
normalize_version_from_server(ReleaseChannel::Stable, "v1.0.0").unwrap(),
|
|
|
|
AvailableVersion {
|
|
|
|
version_or_hash: "1.0.0".to_string(),
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel: ReleaseChannel::Stable,
|
2024-08-12 14:32:53 -04:00
|
|
|
display: "1.0.0".to_string()
|
|
|
|
},
|
2023-11-17 16:40:12 -05:00
|
|
|
);
|
|
|
|
// should not replace v after start
|
|
|
|
assert_eq!(
|
|
|
|
normalize_version_from_server(
|
2024-08-07 04:29:23 -04:00
|
|
|
ReleaseChannel::Stable,
|
2023-11-17 16:40:12 -05:00
|
|
|
" v1.0.0-test-v\n\n "
|
2024-08-12 14:32:53 -04:00
|
|
|
)
|
|
|
|
.unwrap(),
|
|
|
|
AvailableVersion {
|
|
|
|
version_or_hash: "1.0.0-test-v".to_string(),
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel: ReleaseChannel::Stable,
|
2024-08-12 14:32:53 -04:00
|
|
|
display: "1.0.0-test-v".to_string()
|
|
|
|
}
|
2023-11-17 16:40:12 -05:00
|
|
|
);
|
|
|
|
// should not strip v for canary
|
|
|
|
assert_eq!(
|
|
|
|
normalize_version_from_server(
|
2024-08-07 04:29:23 -04:00
|
|
|
ReleaseChannel::Canary,
|
2023-11-17 16:40:12 -05:00
|
|
|
" v1452345asdf \n\n "
|
2024-08-12 14:32:53 -04:00
|
|
|
)
|
|
|
|
.unwrap(),
|
|
|
|
AvailableVersion {
|
|
|
|
version_or_hash: "v1452345asdf".to_string(),
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel: ReleaseChannel::Canary,
|
2024-08-12 14:32:53 -04:00
|
|
|
display: "v1452345asdf".to_string()
|
|
|
|
}
|
|
|
|
);
|
|
|
|
assert_eq!(
|
2024-08-16 16:42:19 -04:00
|
|
|
normalize_version_from_server(ReleaseChannel::Rc, "v1.46.0-rc.0\n\n")
|
|
|
|
.unwrap(),
|
2024-08-12 14:32:53 -04:00
|
|
|
AvailableVersion {
|
2024-08-16 16:42:19 -04:00
|
|
|
version_or_hash: "1.46.0-rc.0".to_string(),
|
2024-08-13 18:32:20 -04:00
|
|
|
release_channel: ReleaseChannel::Rc,
|
2024-08-16 16:42:19 -04:00
|
|
|
display: "1.46.0-rc.0".to_string(),
|
2024-08-12 14:32:53 -04:00
|
|
|
},
|
2023-11-17 16:40:12 -05:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test]
|
|
|
|
async fn test_upgrades_lsp() {
|
|
|
|
let env = TestUpdateCheckerEnvironment::new();
|
|
|
|
env.set_current_version("1.0.0");
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("2.0.0", ReleaseChannel::Stable);
|
2023-11-17 16:40:12 -05:00
|
|
|
|
|
|
|
// greater
|
|
|
|
{
|
|
|
|
let maybe_info = check_for_upgrades_for_lsp_with_provider(&env)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
assert_eq!(
|
|
|
|
maybe_info,
|
|
|
|
Some(LspVersionUpgradeInfo {
|
|
|
|
latest_version: "2.0.0".to_string(),
|
|
|
|
is_canary: false,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
// equal
|
|
|
|
{
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("1.0.0", ReleaseChannel::Stable);
|
2023-11-17 16:40:12 -05:00
|
|
|
let maybe_info = check_for_upgrades_for_lsp_with_provider(&env)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
assert_eq!(maybe_info, None);
|
|
|
|
}
|
|
|
|
// less
|
|
|
|
{
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("0.9.0", ReleaseChannel::Stable);
|
2023-11-17 16:40:12 -05:00
|
|
|
let maybe_info = check_for_upgrades_for_lsp_with_provider(&env)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
assert_eq!(maybe_info, None);
|
|
|
|
}
|
|
|
|
// canary equal
|
|
|
|
{
|
|
|
|
env.set_current_version("123");
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("123", ReleaseChannel::Stable);
|
2024-08-12 14:32:53 -04:00
|
|
|
env.set_release_channel(ReleaseChannel::Canary);
|
2023-11-17 16:40:12 -05:00
|
|
|
let maybe_info = check_for_upgrades_for_lsp_with_provider(&env)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
assert_eq!(maybe_info, None);
|
|
|
|
}
|
|
|
|
// canary different
|
|
|
|
{
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("1234", ReleaseChannel::Stable);
|
2023-11-17 16:40:12 -05:00
|
|
|
let maybe_info = check_for_upgrades_for_lsp_with_provider(&env)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
assert_eq!(
|
|
|
|
maybe_info,
|
|
|
|
Some(LspVersionUpgradeInfo {
|
|
|
|
latest_version: "1234".to_string(),
|
|
|
|
is_canary: true,
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2024-08-12 14:32:53 -04:00
|
|
|
// rc equal
|
|
|
|
{
|
|
|
|
env.set_release_channel(ReleaseChannel::Rc);
|
|
|
|
env.set_current_version("1.2.3-rc.0");
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("1.2.3-rc.0", ReleaseChannel::Rc);
|
2024-08-12 14:32:53 -04:00
|
|
|
let maybe_info = check_for_upgrades_for_lsp_with_provider(&env)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
assert_eq!(maybe_info, None);
|
|
|
|
}
|
|
|
|
// canary different
|
|
|
|
{
|
2024-08-13 18:32:20 -04:00
|
|
|
env.set_latest_version("1.2.3-rc.0", ReleaseChannel::Rc);
|
|
|
|
env.set_latest_version("1.2.3-rc.1", ReleaseChannel::Rc);
|
2024-08-12 14:32:53 -04:00
|
|
|
let maybe_info = check_for_upgrades_for_lsp_with_provider(&env)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
assert_eq!(
|
|
|
|
maybe_info,
|
|
|
|
Some(LspVersionUpgradeInfo {
|
|
|
|
latest_version: "1.2.3-rc.1".to_string(),
|
2024-08-16 16:42:19 -04:00
|
|
|
is_canary: false,
|
2024-08-12 14:32:53 -04:00
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
2023-11-17 16:40:12 -05:00
|
|
|
}
|
2022-10-20 10:15:21 -04:00
|
|
|
}
|