diff --git a/assets/project-templates/place/gitconfig.txt b/assets/project-templates/place/gitconfig.txt new file mode 100644 index 00000000..411fd9ec --- /dev/null +++ b/assets/project-templates/place/gitconfig.txt @@ -0,0 +1,5 @@ +[core] + autocrlf = false + excludesFile = ~/.gitignore + eol = lf + safecrlf = false diff --git a/assets/project-templates/place/gitignore.txt b/assets/project-templates/place/gitignore.txt index 0ae5edc7..6fd96d6a 100644 --- a/assets/project-templates/place/gitignore.txt +++ b/assets/project-templates/place/gitignore.txt @@ -8,3 +8,12 @@ # Sourcemap /sourcemap.json + +# IDEs +/.idea + +# .env +/.env + +# atlas +/atlas.exe diff --git a/src/cli/init.rs b/src/cli/init.rs index e974bca3..8a46a382 100644 --- a/src/cli/init.rs +++ b/src/cli/init.rs @@ -18,6 +18,7 @@ use memofs::{InMemoryFs, Vfs, VfsSnapshot}; use super::resolve_path; const GIT_IGNORE_PLACEHOLDER: &str = "gitignore.txt"; +const GIT_CONFIG_PLACEHOLDER: &str = "gitconfig.txt"; static TEMPLATE_BINCODE: &[u8] = include_bytes!(concat!(env!("OUT_DIR"), "/templates.bincode")); @@ -106,6 +107,12 @@ impl InitCommand { } else { path.set_file_name(".gitignore"); } + } else if file_stem == GIT_CONFIG_PLACEHOLDER { + if self.skip_git { + continue; + } else { + path.set_file_name(".gitconfig"); + } } } write_if_not_exists( @@ -132,50 +139,33 @@ impl InitCommand { }; if !self.skip_rules { - if did_git_init { - log::debug!("Adding cursor rules as submodule..."); + log::debug!("Cloning cursor rules..."); - let result = Command::new("git") - .args([ - "submodule", - "add", - "https://github.com/jrmelsha/cursor-rules.git", - ".cursor", - ]) - .current_dir(&base_path) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status(); + let cursor_dir = base_path.join(".cursor"); + let result = Command::new("git") + .args([ + "clone", + "--depth", + "1", + "https://github.com/jrmelsha/cursor-rules.git", + ".cursor", + ]) + .current_dir(&base_path) + .stdout(Stdio::null()) + .stderr(Stdio::null()) + .status(); - match result { - Ok(status) if status.success() => { - println!("Added cursor rules as submodule."); - } - _ => { - log::debug!("Failed to add cursor rules submodule, skipping."); + match result { + Ok(status) if status.success() => { + // Remove .git so it's just files, not a submodule + let git_dir = cursor_dir.join(".git"); + if git_dir.exists() { + let _ = fs::remove_dir_all(&git_dir); } + println!("Cloned cursor rules successfully."); } - } else { - log::debug!("Cloning cursor rules (no git repo)..."); - - let result = Command::new("git") - .args([ - "clone", - "https://github.com/jrmelsha/cursor-rules.git", - ".cursor", - ]) - .current_dir(&base_path) - .stdout(Stdio::null()) - .stderr(Stdio::null()) - .status(); - - match result { - Ok(status) if status.success() => { - println!("Cloned cursor rules successfully."); - } - _ => { - log::debug!("Failed to clone cursor rules, skipping."); - } + _ => { + log::debug!("Failed to clone cursor rules, skipping."); } } }