From b6786541687ae19031a0594a68529e4bb3a75bf9 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Mon, 16 Oct 2023 15:29:00 +0300 Subject: [PATCH 1/6] Add Pulumi, ShellCheck, and some other tools --- src/cli/cmd/init/handlers/rust.rs | 8 +++++--- src/cli/cmd/init/handlers/tools.rs | 30 ++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/src/cli/cmd/init/handlers/rust.rs b/src/cli/cmd/init/handlers/rust.rs index 0878ef5e..f2852ddd 100644 --- a/src/cli/cmd/init/handlers/rust.rs +++ b/src/cli/cmd/init/handlers/rust.rs @@ -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] = &["audit", "bloat", "edit", "outdated", "udeps", "watch"]; pub(crate) struct Rust; @@ -57,6 +55,10 @@ 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")); + } } } } diff --git a/src/cli/cmd/init/handlers/tools.rs b/src/cli/cmd/init/handlers/tools.rs index d126f81b..bc741459 100644 --- a/src/cli/cmd/init/handlers/tools.rs +++ b/src/cli/cmd/init/handlers/tools.rs @@ -21,5 +21,35 @@ impl Handler for Tools { { flake.dev_shell_packages.push(String::from("bazel")); } + + 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")); + } + + 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")); + } + + if project.has_file("Tiltfile") && Prompt::for_tool("Tilt") { + flake.dev_shell_packages.push(String::from("tilt")); + } + + 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")); + } + + if project.has_file("Pulumi.yaml") && Prompt::for_tool("Pulumi") { + flake.dev_shell_packages.push(String::from("pulumi")); + } + + if project.has_file(".shellcheckrc") && Prompt::for_tool("ShellCheck") { + flake.dev_shell_packages.push(String::from("shellcheck")); + } } } From d6d0b0235ab5d2d6207131e9cea55ac5f7dd5982 Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Mon, 16 Oct 2023 15:53:25 +0300 Subject: [PATCH 2/6] Add cargo-deny handler --- src/cli/cmd/init/handlers/rust.rs | 4 ++++ src/cli/cmd/init/handlers/tools.rs | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/cli/cmd/init/handlers/rust.rs b/src/cli/cmd/init/handlers/rust.rs index f2852ddd..33fe155d 100644 --- a/src/cli/cmd/init/handlers/rust.rs +++ b/src/cli/cmd/init/handlers/rust.rs @@ -59,6 +59,10 @@ impl Handler for Rust { 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")); + } } } } diff --git a/src/cli/cmd/init/handlers/tools.rs b/src/cli/cmd/init/handlers/tools.rs index bc741459..3dd590e2 100644 --- a/src/cli/cmd/init/handlers/tools.rs +++ b/src/cli/cmd/init/handlers/tools.rs @@ -51,5 +51,9 @@ impl Handler for Tools { if project.has_file(".shellcheckrc") && Prompt::for_tool("ShellCheck") { flake.dev_shell_packages.push(String::from("shellcheck")); } + + if project.has_file("Vagrantfile") && Prompt::for_tool("Vagrant") { + flake.dev_shell_packages.push(String::from("vagrant")); + } } } From 7433fa554a2b34b865c75812ae40a6ecf81957ea Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Mon, 16 Oct 2023 16:01:14 +0300 Subject: [PATCH 3/6] Add handler for cargo-audit --- src/cli/cmd/init/handlers/rust.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cli/cmd/init/handlers/rust.rs b/src/cli/cmd/init/handlers/rust.rs index 33fe155d..0a0d14ae 100644 --- a/src/cli/cmd/init/handlers/rust.rs +++ b/src/cli/cmd/init/handlers/rust.rs @@ -2,7 +2,7 @@ use crate::cli::cmd::init::prompt::Prompt; use super::{Flake, Handler, Input, Project}; -const CARGO_TOOLS: &[&str] = &["audit", "bloat", "edit", "outdated", "udeps", "watch"]; +const CARGO_TOOLS: &[&str] = &["bloat", "edit", "outdated", "udeps", "watch"]; pub(crate) struct Rust; @@ -63,6 +63,10 @@ impl Handler for Rust { 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")); + } } } } From cc37f6940f9addb388ac4c1998109eaf57e61fac Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Mon, 16 Oct 2023 16:27:43 +0300 Subject: [PATCH 4/6] Add Ansible handler --- src/cli/cmd/init/handlers/tools.rs | 32 ++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/cli/cmd/init/handlers/tools.rs b/src/cli/cmd/init/handlers/tools.rs index 3dd590e2..80b7b191 100644 --- a/src/cli/cmd/init/handlers/tools.rs +++ b/src/cli/cmd/init/handlers/tools.rs @@ -16,12 +16,27 @@ 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")); } @@ -30,30 +45,31 @@ impl Handler for Tools { flake.dev_shell_packages.push(String::from("flyctl")); } - 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")); - } - + // 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")); } - if project.has_file("Pulumi.yaml") && Prompt::for_tool("Pulumi") { - flake.dev_shell_packages.push(String::from("pulumi")); - } - + // 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")); + } } } From 43cb1a4bf9e7e39bc6fd31b6780f9bd20e72ff9c Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Mon, 16 Oct 2023 16:43:07 +0300 Subject: [PATCH 5/6] Add support for static site generators --- src/cli/cmd/init/handlers/tools.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/cli/cmd/init/handlers/tools.rs b/src/cli/cmd/init/handlers/tools.rs index 80b7b191..bb66c592 100644 --- a/src/cli/cmd/init/handlers/tools.rs +++ b/src/cli/cmd/init/handlers/tools.rs @@ -71,5 +71,21 @@ impl Handler for 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")); + } } } From ce7bd7b9256222a80b013cb657b23cc2518cee9d Mon Sep 17 00:00:00 2001 From: Luc Perkins Date: Mon, 16 Oct 2023 16:45:23 +0300 Subject: [PATCH 6/6] Add pre-commit-hooks handler --- src/cli/cmd/init/handlers/tools.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/cli/cmd/init/handlers/tools.rs b/src/cli/cmd/init/handlers/tools.rs index bb66c592..10610819 100644 --- a/src/cli/cmd/init/handlers/tools.rs +++ b/src/cli/cmd/init/handlers/tools.rs @@ -87,5 +87,12 @@ impl Handler for Tools { 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")); + } } }