Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deps #1202

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 55 additions & 55 deletions Cargo.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions scarb/src/core/lockfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use anyhow::{anyhow, Context, Result};
use semver::Version;
use serde::{Deserialize, Serialize};
use serde_repr::{Deserialize_repr, Serialize_repr};
use toml_edit::Document;
use toml_edit::DocumentMut;
use typed_builder::TypedBuilder;

use crate::core::{Checksum, ManifestDependency, PackageId, PackageName, Resolve, SourceId};
Expand Down Expand Up @@ -103,9 +103,9 @@ impl Lockfile {
.map(|p| p.try_into())
}

fn body(&self) -> Result<Document> {
fn body(&self) -> Result<DocumentMut> {
let doc = toml_edit::ser::to_string_pretty(self)?;
let mut doc = doc.parse::<Document>()?;
let mut doc = doc.parse::<DocumentMut>()?;

for packages in doc["package"].as_array_of_tables_mut().iter_mut() {
for pkg in packages.iter_mut() {
Expand Down
4 changes: 2 additions & 2 deletions scarb/src/manifest_editor/add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::mem;
use anyhow::{anyhow, ensure, Context, Result};
use camino::{Utf8Path, Utf8PathBuf};
use indoc::formatdoc;
use toml_edit::{value, Document, Entry, InlineTable, Item};
use toml_edit::{value, DocumentMut, Entry, InlineTable, Item};
use url::Url;

use crate::core::{GitReference, PackageName};
Expand Down Expand Up @@ -50,7 +50,7 @@ struct GitSource {

impl Op for AddDependency {
#[tracing::instrument(level = "trace", skip(doc, ctx))]
fn apply_to(self: Box<Self>, doc: &mut Document, ctx: OpCtx<'_>) -> Result<()> {
fn apply_to(self: Box<Self>, doc: &mut DocumentMut, ctx: OpCtx<'_>) -> Result<()> {
let tab = get_table_mut(doc, &[self.dep_type.toml_section_str()])?;

let dep = Dep::resolve(*self, ctx)?;
Expand Down
6 changes: 3 additions & 3 deletions scarb/src/manifest_editor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::str::FromStr;

use anyhow::{Context, Result};
use camino::Utf8Path;
use toml_edit::Document;
use toml_edit::DocumentMut;

pub use add::AddDependency;
pub use dep_id::DepId;
Expand All @@ -21,7 +21,7 @@ mod remove;
mod tomlx;

pub trait Op {
fn apply_to(self: Box<Self>, doc: &mut Document, ctx: OpCtx<'_>) -> Result<()>;
fn apply_to(self: Box<Self>, doc: &mut DocumentMut, ctx: OpCtx<'_>) -> Result<()>;
}

pub struct OpCtx<'c> {
Expand All @@ -44,7 +44,7 @@ pub fn edit(
let manifest_path = fsx::canonicalize_utf8(manifest_path)?;

let original_raw_manifest = fsx::read_to_string(&manifest_path)?;
let mut doc = Document::from_str(&original_raw_manifest)
let mut doc = DocumentMut::from_str(&original_raw_manifest)
.with_context(|| format!("failed to read manifest at: {manifest_path}"))?;

for op in ops {
Expand Down
4 changes: 2 additions & 2 deletions scarb/src/manifest_editor/remove.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{anyhow, Result};
use toml_edit::Document;
use toml_edit::DocumentMut;

use scarb_ui::components::Status;

Expand All @@ -17,7 +17,7 @@ pub struct RemoveDependency {

impl Op for RemoveDependency {
#[tracing::instrument(level = "trace", skip(doc, ctx))]
fn apply_to(self: Box<Self>, doc: &mut Document, ctx: OpCtx<'_>) -> Result<()> {
fn apply_to(self: Box<Self>, doc: &mut DocumentMut, ctx: OpCtx<'_>) -> Result<()> {
let tab = get_table_mut(doc, &[self.dep_type.toml_section_str()])?;

// section is hardcoded as there's no support for other section types yet
Expand Down
4 changes: 2 additions & 2 deletions scarb/src/manifest_editor/tomlx.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{ensure, Result};
use toml_edit::{Document, Item, Table};
use toml_edit::{DocumentMut, Item, Table};

pub fn get_table_mut<'a>(doc: &'a mut Document, path: &[&str]) -> Result<&'a mut Item> {
pub fn get_table_mut<'a>(doc: &'a mut DocumentMut, path: &[&str]) -> Result<&'a mut Item> {
return visit(doc.as_item_mut(), path);

fn visit<'a>(item: &'a mut Item, path: &[&str]) -> Result<&'a mut Item> {
Expand Down
4 changes: 2 additions & 2 deletions utils/scarb-test-support/src/fsx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub trait ChildPathEx {
fn files(&self) -> Vec<String>;
fn tree(&self) -> String;
fn assert_is_json<T: DeserializeOwned>(&self) -> T;
fn assert_is_toml_document(&self) -> toml_edit::Document;
fn assert_is_toml_document(&self) -> toml_edit::DocumentMut;
}

impl ChildPathEx for ChildPath {
Expand Down Expand Up @@ -117,7 +117,7 @@ impl ChildPathEx for ChildPath {
serde_json::from_reader(reader).unwrap()
}

fn assert_is_toml_document(&self) -> toml_edit::Document {
fn assert_is_toml_document(&self) -> toml_edit::DocumentMut {
self.read_to_string().parse().unwrap()
}
}
Expand Down
6 changes: 3 additions & 3 deletions utils/scarb-test-support/src/project_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use assert_fs::fixture::ChildPath;
use assert_fs::prelude::*;
use camino::Utf8PathBuf;
use semver::Version;
use toml_edit::{Document, Item, Value};
use toml_edit::{DocumentMut, Item, Value};

use scarb_build_metadata::CAIRO_VERSION;
use to_version::ToVersion;
Expand Down Expand Up @@ -108,7 +108,7 @@ impl ProjectBuilder {
}

pub fn render_manifest(&self) -> String {
let mut doc = Document::new();
let mut doc = DocumentMut::new();
doc["package"] = toml_edit::table();
doc["package"]["name"] = Item::Value(Value::from(self.name.clone()));
doc["package"]["version"] = Item::Value(Value::from(self.version.to_string()));
Expand All @@ -123,7 +123,7 @@ impl ProjectBuilder {
manifest.push_str(&self.manifest_package_extra);
}

let mut doc = manifest.parse::<Document>().unwrap();
let mut doc = manifest.parse::<DocumentMut>().unwrap();
doc["dependencies"] = toml_edit::table();
for (name, dep) in &self.deps {
doc["dependencies"][name.clone()] = Item::Value(dep.clone());
Expand Down
4 changes: 2 additions & 2 deletions utils/scarb-test-support/src/workspace_builder.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use crate::project_builder::{DepBuilder, ProjectBuilder};
use assert_fs::prelude::*;
use toml_edit::{Array, Document, Item, Value};
use toml_edit::{Array, DocumentMut, Item, Value};

#[derive(Default)]
pub struct WorkspaceBuilder {
Expand Down Expand Up @@ -36,7 +36,7 @@ impl WorkspaceBuilder {
}

pub fn build(&self, t: &impl PathChild) {
let mut doc = Document::new();
let mut doc = DocumentMut::new();
doc["workspace"] = toml_edit::table();
doc["workspace"]["members"] =
Item::Value(Value::from(Array::from_iter(self.members.clone())));
Expand Down
4 changes: 2 additions & 2 deletions xtask/src/set_cairo_version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::Result;
use clap::Parser;
use semver::Version;
use toml_edit::{Document, InlineTable, Value};
use toml_edit::{DocumentMut, InlineTable, Value};
use xshell::{cmd, Shell};

use crate::set_scarb_version;
Expand All @@ -27,7 +27,7 @@ struct Spec {
pub fn main(args: Args) -> Result<()> {
let sh = Shell::new()?;

let mut cargo_toml = sh.read_file("Cargo.toml")?.parse::<Document>()?;
let mut cargo_toml = sh.read_file("Cargo.toml")?.parse::<DocumentMut>()?;
let deps = &mut cargo_toml["workspace"]["dependencies"]
.as_table_mut()
.unwrap();
Expand Down
6 changes: 3 additions & 3 deletions xtask/src/set_scarb_version.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use anyhow::{ensure, Result};
use clap::Parser;
use semver::{Prerelease, Version};
use toml_edit::{value, Document};
use toml_edit::{value, DocumentMut};
use xshell::{cmd, Shell};

pub fn expected_scarb_version() -> Result<Version> {
Expand All @@ -10,7 +10,7 @@ pub fn expected_scarb_version() -> Result<Version> {
// deliberately not using cargo_metadata, to reduce build times of xtasks.

let sh = Shell::new()?;
let cargo_lock = sh.read_file("Cargo.lock")?.parse::<Document>()?;
let cargo_lock = sh.read_file("Cargo.lock")?.parse::<DocumentMut>()?;
let packages = cargo_lock["package"].as_array_of_tables().unwrap();
let compiler = {
let pkgs = packages
Expand Down Expand Up @@ -41,7 +41,7 @@ pub struct Args {
pub fn main(args: Args) -> Result<()> {
let sh = Shell::new()?;

let mut cargo_toml = sh.read_file("Cargo.toml")?.parse::<Document>()?;
let mut cargo_toml = sh.read_file("Cargo.toml")?.parse::<DocumentMut>()?;
let package = cargo_toml["workspace"]["package"].as_table_mut().unwrap();

let mut version = expected_scarb_version()?;
Expand Down
Loading