Skip to content

Commit 6e8ad7e

Browse files
ObserverOfTimeamaanq
authored andcommitted
fix(xtask): update paths in bump-version
and remove the toml dependency
1 parent 22d6585 commit 6e8ad7e

File tree

4 files changed

+17
-77
lines changed

4 files changed

+17
-77
lines changed

Cargo.lock

Lines changed: 0 additions & 60 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,6 @@ tar = "0.4.40"
151151
tempfile = "3.21.0"
152152
thiserror = "2.0.16"
153153
tiny_http = "0.12.0"
154-
toml = "0.8.23"
155154
topological-sort = "0.2.2"
156155
unindent = "0.2.4"
157156
url = { version = "2.5.4", features = ["serde"] }

crates/xtask/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ cc.workspace = true
2222
clap.workspace = true
2323
git2.workspace = true
2424
indoc.workspace = true
25-
toml.workspace = true
2625
regex.workspace = true
2726
semver.workspace = true
2827
serde.workspace = true

crates/xtask/src/bump.rs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ use anyhow::{anyhow, Result};
44
use git2::{DiffOptions, Repository};
55
use indoc::indoc;
66
use semver::{BuildMetadata, Prerelease, Version};
7-
use toml::Value;
87

98
use crate::{create_commit, BumpVersion};
109

@@ -241,7 +240,7 @@ fn update_crates(current_version: &Version, next_version: &Version) -> Result<()
241240
.arg("--force")
242241
.arg("tree-sitter{,-cli,-config,-generate,-loader,-highlight,-tags}")
243242
.arg("--ignore-changes")
244-
.arg("lib/language/*");
243+
.arg("crates/language/*");
245244

246245
let status = cmd.status()?;
247246

@@ -253,7 +252,10 @@ fn update_crates(current_version: &Version, next_version: &Version) -> Result<()
253252
}
254253

255254
fn update_npm(next_version: &Version) -> Result<()> {
256-
for path in ["lib/binding_web/package.json", "cli/npm/package.json"] {
255+
for path in [
256+
"lib/binding_web/package.json",
257+
"crates/cli/npm/package.json",
258+
] {
257259
let package_json =
258260
serde_json::from_str::<serde_json::Value>(&std::fs::read_to_string(path)?)?;
259261

@@ -275,13 +277,11 @@ fn update_npm(next_version: &Version) -> Result<()> {
275277
}
276278

277279
fn update_zig(next_version: &Version) -> Result<()> {
278-
let zig = std::fs::read_to_string("build.zig.zon")?;
279-
280-
let zig = zig
280+
let zig = std::fs::read_to_string("build.zig.zon")?
281281
.lines()
282282
.map(|line| {
283-
if line.starts_with(" .version") {
284-
format!(" .version = \"{next_version}\",")
283+
if line.starts_with(" .version") {
284+
format!(" .version = \"{next_version}\",")
285285
} else {
286286
line.to_string()
287287
}
@@ -297,11 +297,13 @@ fn update_zig(next_version: &Version) -> Result<()> {
297297

298298
/// read Cargo.toml and get the version
299299
fn fetch_workspace_version() -> Result<String> {
300-
let cargo_toml = toml::from_str::<Value>(&std::fs::read_to_string("Cargo.toml")?)?;
301-
302-
Ok(cargo_toml["workspace"]["package"]["version"]
303-
.as_str()
304-
.unwrap()
305-
.trim_matches('"')
306-
.to_string())
300+
std::fs::read_to_string("Cargo.toml")?
301+
.lines()
302+
.find(|line| line.starts_with("version = "))
303+
.and_then(|line| {
304+
line.split_terminator('"')
305+
.next_back()
306+
.map(|s| s.to_string())
307+
})
308+
.ok_or_else(|| anyhow!("No version found in Cargo.toml"))
307309
}

0 commit comments

Comments
 (0)