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

Support more tools for fh init #58

Merged
merged 6 commits into from
Oct 16, 2023
Merged
Show file tree
Hide file tree
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
16 changes: 13 additions & 3 deletions src/cli/cmd/init/handlers/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ use crate::cli::cmd::init::prompt::Prompt;

use super::{Flake, Handler, Input, Project};

const CARGO_TOOLS: &[&str] = &[
"audit", "bloat", "cross", "edit", "outdated", "udeps", "watch",
];
const CARGO_TOOLS: &[&str] = &["bloat", "edit", "outdated", "udeps", "watch"];

pub(crate) struct Rust;

Expand Down Expand Up @@ -57,6 +55,18 @@ impl Handler for Rust {
.env_vars
.insert(String::from("RUST_BACKTRACE"), String::from("1"));
}

if project.has_file("Cross.toml") && Prompt::bool("This project appears to use cross-rs. Would you like to add the cargo-cross tool to your environment?") {
flake.dev_shell_packages.push(String::from("cargo-cross"));
}

if project.has_file("deny.toml") && Prompt::bool("This project appears to use cargo-deny. Would you like to add it to your environment?") {
flake.dev_shell_packages.push(String::from("cargo-deny"));
}

if project.has_file("audit.toml") && Prompt::bool("This project appears to use cargo-audit. Would you like to add it to your environment?") {
flake.dev_shell_packages.push(String::from("cargo-audit"));
}
}
}
}
73 changes: 73 additions & 0 deletions src/cli/cmd/init/handlers/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,83 @@ impl Handler for Tools {
flake.dev_shell_packages.push(attr);
}

// Build tools
if project.has_one_of(&["WORKSPACE", ".bazelrc", ".bazelversion", "BUILD.bazel"])
&& Prompt::for_tool("Bazel")
{
flake.dev_shell_packages.push(String::from("bazel"));
}

// Deployment
if project.has_file("site.yml") && Prompt::for_tool("Ansible") {
flake.dev_shell_packages.push(String::from("ansible"));
}

if project.has_file("Pulumi.yaml") && Prompt::for_tool("Pulumi") {
flake.dev_shell_packages.push(String::from("pulumi"));
}

// SaaS deployment tools
if project.has_file("vercel.json") && Prompt::bool("This project appears to deploy to Vercel. Would you like to add the Vercel CLI to your environment?") {
flake.dev_shell_packages.push(String::from("nodePackages.vercel"));
}

if project.has_file("netlify.toml") && Prompt::bool("This project appears to deploy to Netlify. Would you like to add the Netlify CLI to your environment?") {
flake.dev_shell_packages.push(String::from("netlify-cli"));
}

if project.has_file("fly.toml") && Prompt::bool("This project appears to deploy to Fly. Would you like to add the Fly CLI to your environment?") {
flake.dev_shell_packages.push(String::from("flyctl"));
}

// Kubernetes tools
if project.has_file("Tiltfile") && Prompt::for_tool("Tilt") {
flake.dev_shell_packages.push(String::from("tilt"));
}

// Schema-driven development
if project.has_one_of(&["buf.yaml", "buf.lock", "buf.gen.yaml", "buf.work.yaml"])
&& Prompt::for_tool("Buf")
{
flake.dev_shell_packages.push(String::from("buf"));
}

// Checkers
if project.has_file(".shellcheckrc") && Prompt::for_tool("ShellCheck") {
flake.dev_shell_packages.push(String::from("shellcheck"));
}

// Virtual machines
if project.has_file("Vagrantfile") && Prompt::for_tool("Vagrant") {
flake.dev_shell_packages.push(String::from("vagrant"));
}

// SQL tools
if project.has_file("sqlx-data.json") && Prompt::bool("This project appears to use sqlx for Rust. Would you like to add the sqlx CLI to your environment?") {
flake.dev_shell_packages.push(String::from("sqlx-cli"));
}

// Static site generation
if project.has_one_of(&["hugo.json", "hugo.toml", "hugo.yaml"]) && Prompt::for_tool("Hugo")
{
flake.dev_shell_packages.push(String::from("hugo"));
}

if project.has_one_of(&["_config.toml", "_config.toml"]) && Prompt::for_tool("Jekyll") {
flake
.dev_shell_packages
.push(String::from("rubyPackages.jekyll"));
}

if project.has_one_of(&["mkdocs.yaml", "mkdocs.yml"]) && Prompt::for_tool("MkDocs") {
flake.dev_shell_packages.push(String::from("mkdocs"));
}

// Git
if project.has_file(".pre-commit-config.yaml") && Prompt::for_tool("pre-commit-hooks") {
flake
.dev_shell_packages
.push(String::from("python311Packages.pre-commit-hooks"));
}
}
}