Feature/UI sideload (#2658)

* ui sideloading

* remove subtlecrypto import

* fix parser

* misc fixes

* allow docker pull during compat conversion
This commit is contained in:
Aiden McClelland
2024-06-28 15:03:01 -06:00
committed by GitHub
parent c16d8a1da1
commit 822dd5e100
101 changed files with 1901 additions and 797 deletions

View File

@@ -25,20 +25,20 @@ enum Version {
V0_3_5_1(Wrapper<v0_3_5_1::Version>),
V0_3_5_2(Wrapper<v0_3_5_2::Version>),
V0_3_6(Wrapper<v0_3_6::Version>),
Other(emver::Version),
Other(exver::Version),
}
impl Version {
fn from_util_version(version: crate::util::VersionString) -> Self {
fn from_exver_version(version: exver::Version) -> Self {
serde_json::to_value(version.clone())
.and_then(serde_json::from_value)
.unwrap_or_else(|_e| {
tracing::warn!("Can't deserialize: {:?} and falling back to other", version);
Version::Other(version.into_version())
Version::Other(version)
})
}
#[cfg(test)]
fn as_sem_ver(&self) -> emver::Version {
fn as_exver(&self) -> exver::Version {
match self {
Version::LT0_3_5(LTWrapper(_, x)) => x.clone(),
Version::V0_3_5(Wrapper(x)) => x.semver(),
@@ -56,8 +56,8 @@ where
{
type Previous: VersionT;
fn new() -> Self;
fn semver(&self) -> emver::Version;
fn compat(&self) -> &'static emver::VersionRange;
fn semver(&self) -> exver::Version;
fn compat(&self) -> &'static exver::VersionRange;
fn up(&self, db: &TypedPatchDb<Database>) -> impl Future<Output = Result<(), Error>> + Send;
fn down(&self, db: &TypedPatchDb<Database>) -> impl Future<Output = Result<(), Error>> + Send;
fn commit(
@@ -158,7 +158,7 @@ where
}
#[derive(Debug, Clone)]
struct LTWrapper<T>(T, emver::Version);
struct LTWrapper<T>(T, exver::Version);
impl<T> serde::Serialize for LTWrapper<T>
where
T: VersionT,
@@ -172,10 +172,10 @@ where
T: VersionT,
{
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let v = crate::util::VersionString::deserialize(deserializer)?;
let v = exver::Version::deserialize(deserializer)?;
let version = T::new();
if *v < version.semver() {
Ok(Self(version, v.into_version()))
if v < version.semver() {
Ok(Self(version, v))
} else {
Err(serde::de::Error::custom("Mismatched Version"))
}
@@ -197,9 +197,9 @@ where
T: VersionT,
{
fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
let v = crate::util::VersionString::deserialize(deserializer)?;
let v = exver::Version::deserialize(deserializer)?;
let version = T::new();
if *v == version.semver() {
if v == version.semver() {
Ok(Wrapper(version))
} else {
Err(serde::de::Error::custom("Mismatched Version"))
@@ -212,7 +212,7 @@ pub async fn init(
mut progress: PhaseProgressTrackerHandle,
) -> Result<(), Error> {
progress.start();
let version = Version::from_util_version(
let version = Version::from_exver_version(
db.peek()
.await
.as_public()
@@ -256,9 +256,18 @@ mod tests {
use super::*;
fn em_version() -> impl Strategy<Value = emver::Version> {
any::<(usize, usize, usize, usize)>().prop_map(|(major, minor, patch, super_minor)| {
emver::Version::new(major, minor, patch, super_minor)
fn em_version() -> impl Strategy<Value = exver::Version> {
any::<(usize, usize, usize, bool)>().prop_map(|(major, minor, patch, alpha)| {
if alpha {
exver::Version::new(
[0, major, minor]
.into_iter()
.chain(Some(patch).filter(|n| *n != 0)),
[],
)
} else {
exver::Version::new([major, minor, patch], [])
}
})
}
@@ -273,15 +282,15 @@ mod tests {
proptest! {
#[test]
fn emversion_isomorphic_version(original in em_version()) {
let version = Version::from_util_version(original.clone().into());
let back = version.as_sem_ver();
fn exversion_isomorphic_version(original in em_version()) {
let version = Version::from_exver_version(original.clone().into());
let back = version.as_exver();
prop_assert_eq!(original, back, "All versions should round trip");
}
#[test]
fn version_isomorphic_em_version(version in versions()) {
let sem_ver = version.as_sem_ver();
let back = Version::from_util_version(sem_ver.into());
let sem_ver = version.as_exver();
let back = Version::from_exver_version(sem_ver.into());
prop_assert_eq!(format!("{:?}",version), format!("{:?}", back), "All versions should round trip");
}
}

View File

@@ -1,4 +1,4 @@
use emver::VersionRange;
use exver::{ExtendedVersion, VersionRange};
use super::VersionT;
use crate::db::model::Database;
@@ -6,17 +6,25 @@ use crate::prelude::*;
use crate::version::Current;
lazy_static::lazy_static! {
pub static ref V0_3_0_COMPAT: VersionRange = VersionRange::Conj(
Box::new(VersionRange::Anchor(
emver::GTE,
emver::Version::new(0, 3, 0, 0),
)),
Box::new(VersionRange::Anchor(emver::LTE, Current::new().semver())),
pub static ref V0_3_0_COMPAT: VersionRange = VersionRange::and(
VersionRange::anchor(
exver::GTE,
ExtendedVersion::new(
exver::Version::new([0, 3, 0], []),
exver::Version::default(),
),
),
VersionRange::anchor(
exver::LTE,
ExtendedVersion::new(
Current::new().semver(),
exver::Version::default(),
)
),
);
static ref V0_3_5: exver::Version = exver::Version::new([0, 3, 5], []);
}
const V0_3_5: emver::Version = emver::Version::new(0, 3, 5, 0);
#[derive(Clone, Debug)]
pub struct Version;
@@ -25,8 +33,8 @@ impl VersionT for Version {
fn new() -> Self {
Version
}
fn semver(&self) -> emver::Version {
V0_3_5
fn semver(&self) -> exver::Version {
V0_3_5.clone()
}
fn compat(&self) -> &'static VersionRange {
&V0_3_0_COMPAT

View File

@@ -1,11 +1,13 @@
use emver::VersionRange;
use exver::VersionRange;
use super::v0_3_5::V0_3_0_COMPAT;
use super::{v0_3_5, VersionT};
use crate::db::model::Database;
use crate::prelude::*;
const V0_3_5_1: emver::Version = emver::Version::new(0, 3, 5, 1);
lazy_static::lazy_static! {
static ref V0_3_5_1: exver::Version = exver::Version::new([0, 3, 5, 1], []);
}
#[derive(Clone, Debug)]
pub struct Version;
@@ -15,8 +17,8 @@ impl VersionT for Version {
fn new() -> Self {
Version
}
fn semver(&self) -> emver::Version {
V0_3_5_1
fn semver(&self) -> exver::Version {
V0_3_5_1.clone()
}
fn compat(&self) -> &'static VersionRange {
&V0_3_0_COMPAT

View File

@@ -1,11 +1,13 @@
use emver::VersionRange;
use exver::VersionRange;
use super::v0_3_5::V0_3_0_COMPAT;
use super::{v0_3_5_1, VersionT};
use crate::db::model::Database;
use crate::prelude::*;
const V0_3_5_2: emver::Version = emver::Version::new(0, 3, 5, 2);
lazy_static::lazy_static! {
static ref V0_3_5_2: exver::Version = exver::Version::new([0, 3, 5, 2], []);
}
#[derive(Clone, Debug)]
pub struct Version;
@@ -15,8 +17,8 @@ impl VersionT for Version {
fn new() -> Self {
Version
}
fn semver(&self) -> emver::Version {
V0_3_5_2
fn semver(&self) -> exver::Version {
V0_3_5_2.clone()
}
fn compat(&self) -> &'static VersionRange {
&V0_3_0_COMPAT

View File

@@ -1,11 +1,13 @@
use emver::VersionRange;
use exver::VersionRange;
use super::v0_3_5::V0_3_0_COMPAT;
use super::{v0_3_5_1, VersionT};
use crate::db::model::Database;
use crate::prelude::*;
const V0_3_6: emver::Version = emver::Version::new(0, 3, 6, 0);
lazy_static::lazy_static! {
static ref V0_3_6: exver::Version = exver::Version::new([0, 3, 6], []);
}
#[derive(Clone, Debug)]
pub struct Version;
@@ -15,8 +17,8 @@ impl VersionT for Version {
fn new() -> Self {
Version
}
fn semver(&self) -> emver::Version {
V0_3_6
fn semver(&self) -> exver::Version {
V0_3_6.clone()
}
fn compat(&self) -> &'static VersionRange {
&V0_3_0_COMPAT