fix(cli): read lockfile from workspace on the info command, closes #4232 (#4423)

This commit is contained in:
Lucas Fernandes Nogueira
2022-06-21 09:19:36 -07:00
committed by GitHub
parent 35dd51db68
commit 12f65219ea
2 changed files with 19 additions and 11 deletions

View File

@@ -0,0 +1,6 @@
---
"cli.rs": patch
"cli.js": patch
---
The `info` command now can check the Cargo lockfile on workspaces.

View File

@@ -2,10 +2,11 @@
// SPDX-License-Identifier: Apache-2.0
// SPDX-License-Identifier: MIT
use crate::helpers::{
config::get as get_config, framework::infer_from_package_json as infer_framework,
use crate::{
helpers::{config::get as get_config, framework::infer_from_package_json as infer_framework},
interface::rust::get_workspace_dir,
Result,
};
use crate::Result;
use clap::Parser;
use colored::Colorize;
use serde::Deserialize;
@@ -476,12 +477,12 @@ fn crate_version(
};
let lock_version = match (lock, crate_lock_packages.is_empty()) {
(Some(_lock), true) => crate_lock_packages
(Some(_lock), false) => crate_lock_packages
.iter()
.map(|p| p.version.clone())
.collect::<Vec<String>>()
.join(", "),
(Some(_lock), false) => "unknown lockfile".to_string(),
(Some(_lock), true) => "unknown lockfile".to_string(),
_ => "no lockfile".to_string(),
};
@@ -789,12 +790,13 @@ pub fn command(_options: Options) -> Result<()> {
} else {
None
};
let lock: Option<CargoLock> =
if let Ok(lock_contents) = read_to_string(tauri_dir.join("Cargo.lock")) {
toml::from_str(&lock_contents).ok()
} else {
None
};
let lock: Option<CargoLock> = if let Ok(lock_contents) =
read_to_string(get_workspace_dir(&tauri_dir).join("Cargo.lock"))
{
toml::from_str(&lock_contents).ok()
} else {
None
};
for (dep, label) in [
("tauri", format!("{} {}", "tauri", "[RUST]".dimmed())),