From 2d67c6b7cd71b6590718d83f95b2a2ffdf3f0c0a Mon Sep 17 00:00:00 2001 From: Christos Hadjiaslanis Date: Mon, 17 Oct 2022 19:35:59 +0300 Subject: [PATCH] feat: added publish: false in generated Cargo.toml to avoid accidental cargo publish (#358) --- cargo-shuttle/src/init.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cargo-shuttle/src/init.rs b/cargo-shuttle/src/init.rs index 88d51faa1..651849025 100644 --- a/cargo-shuttle/src/init.rs +++ b/cargo-shuttle/src/init.rs @@ -564,12 +564,16 @@ pub fn cargo_shuttle_init(path: PathBuf, framework: Box) -> Res // Create an empty `[lib]` table cargo_doc["lib"] = Item::Table(Table::new()); + // Add publish: false to avoid accidental `cargo publish` + cargo_doc["package"]["publish"] = value(false); + // Create `[dependencies]` table let mut dependencies = Table::new(); // Set "shuttle-service" version to `[dependencies]` table let manifest_path = find(Some(path.as_path())).unwrap(); let url = registry_url(manifest_path.as_path(), None).expect("Could not find registry URL"); + set_inline_table_dependency_version( "shuttle-service", &mut dependencies, @@ -589,6 +593,7 @@ pub fn cargo_shuttle_init(path: PathBuf, framework: Box) -> Res // Truncate Cargo.toml and write the updated `Document` to it let mut cargo_toml = File::create(cargo_toml_path)?; + cargo_doc["dependencies"] = Item::Table(dependencies); cargo_toml.write_all(cargo_doc.to_string().as_bytes())?;