fix(typst): Skip typst when self-update is disabled (#1397)
This commit is contained in:
25
Cargo.lock
generated
25
Cargo.lock
generated
@@ -2347,18 +2347,28 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
|
||||
|
||||
[[package]]
|
||||
name = "serde"
|
||||
version = "1.0.203"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094"
|
||||
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||
dependencies = [
|
||||
"serde_core",
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_core"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||
dependencies = [
|
||||
"serde_derive",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "serde_derive"
|
||||
version = "1.0.203"
|
||||
version = "1.0.228"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba"
|
||||
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -2367,13 +2377,15 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "serde_json"
|
||||
version = "1.0.117"
|
||||
version = "1.0.145"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3"
|
||||
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||
dependencies = [
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
"serde",
|
||||
"serde_core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -2905,6 +2917,7 @@ dependencies = [
|
||||
"self_update",
|
||||
"semver",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"shell-words",
|
||||
"shellexpand",
|
||||
"strum",
|
||||
|
||||
@@ -54,6 +54,7 @@ rust-i18n = "3.0.1"
|
||||
sys-locale = "0.3.1"
|
||||
jetbrains-toolbox-updater = "5.0.0"
|
||||
indexmap = { version = "2.9.0", features = ["serde"] }
|
||||
serde_json = "1.0.145"
|
||||
|
||||
[package.metadata.generate-rpm]
|
||||
assets = [{ source = "target/release/topgrade", dest = "/usr/bin/topgrade" }]
|
||||
|
||||
@@ -5,6 +5,7 @@ use jetbrains_toolbox_updater::{find_jetbrains_toolbox, update_jetbrains_toolbox
|
||||
use regex::bytes::Regex;
|
||||
use rust_i18n::t;
|
||||
use semver::Version;
|
||||
use serde::Deserialize;
|
||||
use std::ffi::OsString;
|
||||
use std::iter::once;
|
||||
use std::path::PathBuf;
|
||||
@@ -1779,9 +1780,40 @@ pub fn run_yazi(ctx: &ExecutionContext) -> Result<()> {
|
||||
ctx.execute(ya).args(["pkg", "upgrade"]).status_checked()
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct TypstInfo {
|
||||
build: TypstBuild,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct TypstBuild {
|
||||
settings: TypstSettings,
|
||||
}
|
||||
|
||||
#[derive(Deserialize)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
struct TypstSettings {
|
||||
self_update: bool,
|
||||
}
|
||||
|
||||
pub fn run_typst(ctx: &ExecutionContext) -> Result<()> {
|
||||
let typst = require("typst")?;
|
||||
|
||||
let raw_info = ctx
|
||||
.execute(&typst)
|
||||
.args(["info", "-f", "json"])
|
||||
.output_checked_utf8()?
|
||||
.stdout;
|
||||
let info: TypstInfo = serde_json::from_str(&raw_info).wrap_err_with(|| {
|
||||
output_changed_message!(
|
||||
"typst info -f json",
|
||||
"json output invalid or does not contain .build.settings.self-update"
|
||||
)
|
||||
})?;
|
||||
if !info.build.settings.self_update {
|
||||
return Err(SkipStep("This build of typst does not have self-update enabled".to_string()).into());
|
||||
}
|
||||
|
||||
print_separator("Typst");
|
||||
|
||||
ctx.execute(typst).args(["update"]).status_checked()
|
||||
|
||||
Reference in New Issue
Block a user