From aa37acf1dcccc3cfed0736168e9d14488fa86e82 Mon Sep 17 00:00:00 2001 From: Bauke Date: Mon, 15 Jan 2024 13:37:43 +0100 Subject: [PATCH] Move the pnpm scripts to cargo-make tasks. --- Makefile.toml | 71 ++++++++++++++++++++++++++------------------------- README.md | 7 +---- package.json | 5 ---- 3 files changed, 37 insertions(+), 46 deletions(-) diff --git a/Makefile.toml b/Makefile.toml index d7da164..db1753f 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -1,40 +1,41 @@ -[tasks.fmt] -command = "cargo" -args = ["fmt", "${@}"] - -[tasks.check] -command = "cargo" -args = ["check", "${@}"] - -[tasks.clippy] -command = "cargo" -args = ["clippy", "${@}"] - -[tasks.test] -command = "cargo" -args = ["test", "${@}"] - -[tasks.doc] -command = "cargo" -args = ["doc", "${@}"] - +# Build the website. [tasks.build] +clear = true command = "cargo" -args = ["build", "${@}"] +args = ["run", "--release"] -[tasks.complete-check] -dependencies = ["fmt", "check", "clippy", "test", "doc", "build"] +# Remove build directories. +[tasks.clean] +clear = true +command = "pnpm" +args = ["trash", "public"] -[tasks.code-coverage] -workspace = false -install_crate = "cargo-tarpaulin" +# Deploy the website to Netlify. +[tasks.deploy-netlify] +clear = true +command = "pnpm" +dependencies = ["clean", "lint", "build"] +args = ["netlify", "deploy", "-p", "-d", "public/", "-s", "bauke.xyz"] + +# Run all other linting tasks. +[tasks.lint] +clear = true +dependencies = ["lint-clippy", "lint-js", "lint-scss"] + +# Run Clippy. +[tasks.lint-clippy] +clear = true command = "cargo" -args = [ - "tarpaulin", - "--exclude-files=target/*", - "--out=html", - "--output-dir=coverage", - "--skip-clean", - "--target-dir=target/tarpaulin", - "--workspace" -] +args = ["clippy"] + +# Run XO. +[tasks.lint-js] +clear = true +command = "pnpm" +args = ["xo"] + +# Run Stylelint. +[tasks.lint-scss] +clear = true +command = "pnpm" +args = ["stylelint", "source/**/*.scss"] diff --git a/README.md b/README.md index 63ff66d..af9f1b6 100644 --- a/README.md +++ b/README.md @@ -4,12 +4,7 @@ ## Development -Requires working installations of [Rust and Cargo](https://www.rust-lang.org/learn/get-started), [NodeJS](https://nodejs.org) and [pnpm](https://pnpm.io). - -* Install the dependencies with `pnpm install`. -* Build the website with `cargo run`. -* Deploy to Netlify with `pnpm run deploy`. -* Test the code with `pnpm test`. +With [Nix flakes](https://nixos.wiki/wiki/Flakes) and [direnv](https://direnv.net/) installed and enabled, all the required dependencies are automatically loaded from [`shell.nix`](./shell.nix). Then [cargo-make](https://sagiegurari.github.io/cargo-make/) can be used to build, deploy and lint the code. The available tasks are all described in the [`Makefile.toml`](Makefile.toml) configuration. ## License diff --git a/package.json b/package.json index f4268e4..c42feea 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,5 @@ { "private": "true", - "scripts": { - "deploy": "cargo run --release -q && pnpm deploy:netlify", - "deploy:netlify": "netlify deploy --prod --dir 'public/' -s bauke.xyz", - "test": "xo && stylelint 'source/**/*.scss'" - }, "dependencies": { "modern-normalize": "^1.1.0" },