2024-08-15 15:59:16 -04:00
|
|
|
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.
|
|
|
|
|
2024-08-15 17:47:16 -04:00
|
|
|
/// This module is shared between build script and the binaries. Use it sparsely.
|
2024-08-15 15:59:16 -04:00
|
|
|
use deno_core::anyhow::bail;
|
|
|
|
use deno_core::error::AnyError;
|
|
|
|
|
|
|
|
#[derive(Debug, Clone, Copy, PartialEq)]
|
|
|
|
pub enum ReleaseChannel {
|
|
|
|
/// Stable version, eg. 1.45.4, 2.0.0, 2.1.0
|
|
|
|
Stable,
|
|
|
|
|
|
|
|
/// Pointing to a git hash
|
|
|
|
Canary,
|
|
|
|
|
|
|
|
/// Long term support release
|
|
|
|
#[allow(unused)]
|
|
|
|
Lts,
|
|
|
|
|
2024-08-16 16:42:19 -04:00
|
|
|
/// Release candidate, eg. 1.46.0-rc.0, 2.0.0-rc.1
|
2024-08-15 15:59:16 -04:00
|
|
|
Rc,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl ReleaseChannel {
|
|
|
|
pub fn name(&self) -> &str {
|
|
|
|
match self {
|
2024-08-16 16:42:19 -04:00
|
|
|
Self::Stable => "stable",
|
2024-08-15 15:59:16 -04:00
|
|
|
Self::Canary => "canary",
|
|
|
|
Self::Rc => "release candidate",
|
2024-08-16 16:42:19 -04:00
|
|
|
Self::Lts => "long term support",
|
2024-08-15 15:59:16 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE(bartlomieju): do not ever change these values, tools like `patchver`
|
|
|
|
// rely on them.
|
|
|
|
pub fn serialize(&self) -> String {
|
|
|
|
match self {
|
|
|
|
Self::Stable => "stable",
|
|
|
|
Self::Canary => "canary",
|
|
|
|
Self::Rc => "rc",
|
|
|
|
Self::Lts => "lts",
|
|
|
|
}
|
|
|
|
.to_string()
|
|
|
|
}
|
|
|
|
|
|
|
|
// NOTE(bartlomieju): do not ever change these values, tools like `patchver`
|
|
|
|
// rely on them.
|
|
|
|
pub fn deserialize(str_: &str) -> Result<Self, AnyError> {
|
|
|
|
Ok(match str_ {
|
|
|
|
"stable" => Self::Stable,
|
|
|
|
"canary" => Self::Canary,
|
|
|
|
"rc" => Self::Rc,
|
|
|
|
"lts" => Self::Lts,
|
|
|
|
unknown => bail!("Unrecognized release channel: {}", unknown),
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|