Skip to content

Commit

Permalink
fix: add Cargo.lock to project template to avoid broken dependencies
Browse files Browse the repository at this point in the history
By pinning new project's dependencies to specific versions, we avoid
problems like #187 which are caused by changes in the dependencies
(in this case we were using a prerelease version of a dependency which
updated one of its dependencies to edition=2024, but this will also
prevent accidental semver-breaking changes from breaking our builds,
too).

This also adds a justfile that makes it easy to update the lockfile.
  • Loading branch information
m4tx committed Feb 23, 2025
1 parent 6f9e4fb commit 39ef88c
Show file tree
Hide file tree
Showing 4 changed files with 2,993 additions and 2 deletions.
8 changes: 8 additions & 0 deletions cot-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,13 @@ enum Commands {
#[arg(long)]
name: Option<String>,
/// Use the latest `cot` version from git instead of a published crate
/// (conflicts with --cot-path)
#[arg(long)]
use_git: bool,
/// Use `cot` from the specified path instead of a published crate
/// (conflicts with --use-git)
#[arg(long)]
cot_path: Option<PathBuf>,
},
/// Generate migrations for a Cot project
MakeMigrations {
Expand Down Expand Up @@ -67,6 +72,7 @@ fn main() -> anyhow::Result<()> {
path,
name,
use_git,
cot_path,
} => {
let project_name = match name {
None => {
Expand All @@ -80,6 +86,8 @@ fn main() -> anyhow::Result<()> {

let cot_source = if use_git {
CotSource::Git
} else if let Some(path) = &cot_path {
CotSource::Path(path)
} else {
CotSource::PublishedCrate
};
Expand Down
4 changes: 2 additions & 2 deletions cot-cli/src/new_project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ macro_rules! project_file {
};
}

const PROJECT_FILES: [(&str, &str); 9] = [
const PROJECT_FILES: [(&str, &str); 10] = [
project_file!("Cargo.toml.template"),
project_file!("Cargo.lock.template"),
project_file!("bacon.toml"),
project_file!(".gitignore"),
project_file!("src/main.rs"),
Expand All @@ -28,7 +29,6 @@ const PROJECT_FILES: [(&str, &str); 9] = [
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub enum CotSource<'a> {
Git,
#[allow(dead_code)] // used in integration tests
Path(&'a Path),
PublishedCrate,
}
Expand Down
Loading

0 comments on commit 39ef88c

Please sign in to comment.