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

workspace-support #599

Closed
Closed
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
8 changes: 7 additions & 1 deletion cargo-shuttle/src/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::io::Write;
use std::path::{Path, PathBuf};

use anyhow::Result;
use cargo::core::find_workspace_root;
use cargo::ops::NewOptions;
use cargo_edit::{find, get_latest_dependency, registry_url};
use indoc::indoc;
Expand Down Expand Up @@ -669,7 +670,12 @@ pub fn cargo_shuttle_init(path: PathBuf, framework: Framework) -> Result<()> {
let mut dependencies = Table::new();

// Set "shuttle-service" version to `[dependencies]` table
let manifest_path = find(Some(path.as_path())).unwrap();
let config = cargo::util::config::Config::default().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

I'm just not sure if cargo_shuttle_init is the correct function to update though. I think this function needs to be updated or removed (which is better)

fn find_root_directory(dir: &Path) -> Option<PathBuf> {
dir.ancestors()
.find(|ancestor| ancestor.join("Cargo.toml").exists())
.map(|path| path.to_path_buf())
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you run it already or shall I do it??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://docs.rs/project-root/latest/src/project_root/lib.rs.html#19-34

I think replacing existing function with this one will do.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll leave the testing to you 😄

let workspace_root = find_workspace_root(&path, &config).unwrap();
let manifest_path = match workspace_root {
None => find(Some(path.as_path())).unwrap(),
Some(root) => find(Some(root.as_path())).unwrap(),
};
let url = registry_url(manifest_path.as_path(), None).expect("Could not find registry URL");

set_inline_table_dependency_version(
Expand Down