From cef5e60d293945702b9b980ec37545de2d29c878 Mon Sep 17 00:00:00 2001 From: Roland Fredenhagen Date: Tue, 3 Oct 2023 22:14:39 +0700 Subject: [PATCH] moved output dir to parent Co-authored-by: Shahar "Dawn" Or Co-authored-by: Remy Clarke <60509493+ClarkeRemy@users.noreply.github.com> --- .github/workflows/ci.yml | 2 +- Cargo.lock | 189 +++++++++++++++++++-------------------- Cargo.toml | 3 +- builder/Cargo.toml | 1 + builder/src/lib.rs | 11 --- builder/src/main.rs | 15 +++- builder/src/tailwind.rs | 21 ++--- src/main.rs | 6 +- ssg-parent/src/dev.rs | 8 +- 9 files changed, 125 insertions(+), 131 deletions(-) delete mode 100644 builder/src/lib.rs diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8d3b0320..620c2d84 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: - run: cargo install cargo-run-bin - run: npm ci - run: ./git_hooks/pre-commit - - run: cargo run --package builder + - run: cargo run --package builder $(cargo run print-output-dir) - name: no_untracked run: | set -euxo pipefail diff --git a/Cargo.lock b/Cargo.lock index ee155463..ebb4dafb 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,12 +7,12 @@ name = "_" version = "0.0.0" dependencies = [ "anyhow", - "builder", + "camino", "cargo-watch", "chrono", "clap 4.2.0", "console-subscriber", - "indexmap", + "indexmap 1.9.3", "once_cell", "serde", "serde_json", @@ -291,7 +291,7 @@ dependencies = [ "log", "parking", "polling", - "rustix 0.37.4", + "rustix", "slab", "socket2", "waker-fn", @@ -693,6 +693,7 @@ dependencies = [ "camino", "chrono", "chrono-tz", + "clap 4.2.0", "comrak", "console-subscriber", "const_format", @@ -702,7 +703,7 @@ dependencies = [ "futures", "getset", "global_counter", - "indexmap", + "indexmap 1.9.3", "itertools", "maud", "once_cell", @@ -907,7 +908,7 @@ dependencies = [ "bitflags 1.3.2", "clap_derive 3.2.25", "clap_lex 0.2.4", - "indexmap", + "indexmap 1.9.3", "once_cell", "strsim 0.10.0", "termcolor", @@ -1110,18 +1111,18 @@ checksum = "fbdcdcb6d86f71c5e97409ad45898af11cbc995b4ee8112d59095a28d376c935" [[package]] name = "const_format" -version = "0.2.30" +version = "0.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7309d9b4d3d2c0641e018d449232f2e28f1b22933c137f157d3dbc14228b8c0e" +checksum = "c990efc7a285731f9a4378d81aff2f0e85a2c8781a05ef0f8baa8dac54d0ff48" dependencies = [ "const_format_proc_macros", ] [[package]] name = "const_format_proc_macros" -version = "0.2.29" +version = "0.2.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d897f47bf7270cf70d370f8f98c1abb6d2d4cf60a6845d30e05bfb90c6568650" +checksum = "e026b6ce194a874cb9cf32cd5772d1ef9767cc8fcb5765948d74f37a9d8b2bf6" dependencies = [ "proc-macro2", "quote", @@ -1449,9 +1450,9 @@ dependencies = [ [[package]] name = "deunicode" -version = "0.4.3" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" +checksum = "d95203a6a50906215a502507c0f879a0ce7ff205a6111e2db2a5ef8e4bb92e43" [[package]] name = "digest" @@ -1610,6 +1611,12 @@ dependencies = [ "termcolor", ] +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + [[package]] name = "erased-serde" version = "0.3.25" @@ -1619,17 +1626,6 @@ dependencies = [ "serde", ] -[[package]] -name = "errno" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f639046355ee4f37944e44f60642c6f3a7efa3cf6b78c78a0d989a8ce6c396a1" -dependencies = [ - "errno-dragonfly", - "libc", - "winapi 0.3.9", -] - [[package]] name = "errno" version = "0.3.0" @@ -1665,9 +1661,9 @@ checksum = "e88a8acf291dafb59c2d96e8f59828f3838bb1a70398823ade51a84de6a6deed" [[package]] name = "fancy-regex" -version = "0.7.1" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9d6b8560a05112eb52f04b00e5d3790c0dd75d9d980eb8a122fb23b92a623ccf" +checksum = "b95f7c0680e4142284cf8b22c14a476e87d61b004a3a0861872b32ef7ead40a2" dependencies = [ "bit-set", "regex", @@ -2005,7 +2001,7 @@ dependencies = [ "futures-sink", "futures-util", "http", - "indexmap", + "indexmap 1.9.3", "slab", "tokio", "tokio-util", @@ -2018,6 +2014,12 @@ version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" +[[package]] +name = "hashbrown" +version = "0.14.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7dfda62a12f55daeae5015f81b0baea145391cb4520f86c248fc615d72640d12" + [[package]] name = "hdrhistogram" version = "7.5.2" @@ -2197,9 +2199,9 @@ dependencies = [ [[package]] name = "http-serde" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e272971f774ba29341db2f686255ff8a979365a26fb9e4277f6b6d9ec0cdd5e" +checksum = "6f560b665ad9f1572cfcaf034f7fb84338a7ce945216d64a90fd81f046a3caee" dependencies = [ "http", "serde", @@ -2341,7 +2343,17 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", +] + +[[package]] +name = "indexmap" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8adf3ddd720272c6ea8bf59463c04e0f93d0bbf7c5439b691bca2987e0270897" +dependencies = [ + "equivalent", + "hashbrown 0.14.1", ] [[package]] @@ -2442,7 +2454,7 @@ checksum = "256017f749ab3117e93acb91063009e1f1bb56d03965b14c2c8df4eb02c524d8" dependencies = [ "hermit-abi 0.3.1", "io-lifetimes", - "rustix 0.37.4", + "rustix", "windows-sys 0.45.0", ] @@ -2590,12 +2602,6 @@ version = "0.5.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" -[[package]] -name = "linux-raw-sys" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f051f77a7c8e6957c0696eac88f26b0117e54f52d3fc682ab19397a8812846a4" - [[package]] name = "linux-raw-sys" version = "0.3.0" @@ -2747,9 +2753,9 @@ dependencies = [ [[package]] name = "miette" -version = "5.6.0" +version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "07749fb52853e739208049fb513287c6f448de9103dfa78b05ae01f2fc5809bb" +checksum = "59bb584eaeeab6bd0226ccf3509a69d7936d148cf3d036ad350abe35e8c6856e" dependencies = [ "miette-derive", "once_cell", @@ -2759,13 +2765,13 @@ dependencies = [ [[package]] name = "miette-derive" -version = "5.6.0" +version = "5.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2a07ad93a80d1b92bb44cb42d7c49b49c9aab1778befefad49cceb5e4c5bf460" +checksum = "49e7bc1560b95a3c4a25d03de42fe76ca718ab92d1a22a55b9b4cf67b3ae635c" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn 2.0.11", ] [[package]] @@ -3213,9 +3219,9 @@ dependencies = [ [[package]] name = "paste" -version = "1.0.12" +version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9f746c4065a8fa3fe23974dd82f15431cc8d40779821001404d10d2e79ca7d79" +checksum = "de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c" [[package]] name = "pathdiff" @@ -3322,20 +3328,20 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.26" +version = "0.3.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" +checksum = "26072860ba924cbfa98ea39c8c19b4dd6a4a25423dbdf219c1eca91aa0cf6964" [[package]] name = "plist" -version = "1.4.3" +version = "1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9bd9647b268a3d3e14ff09c23201133a62589c658db02bb7388c7246aafe0590" +checksum = "bdc0001cfea3db57a2e24bc0d818e9e20e554b5f97fabb9bc231dc240269ae06" dependencies = [ "base64 0.21.0", - "indexmap", + "indexmap 1.9.3", "line-wrap", - "quick-xml 0.28.1", + "quick-xml 0.29.0", "serde", "time 0.3.20", ] @@ -3474,9 +3480,9 @@ dependencies = [ [[package]] name = "quick-xml" -version = "0.28.1" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5c1a97b1bc42b1d550bfb48d4262153fe400a12bab1511821736f7eac76d7e2" +checksum = "81b9228215d82c7b61490fec1de287136b5de6f5700f6e58ea9ad61a7964ca51" dependencies = [ "memchr", ] @@ -3614,7 +3620,7 @@ checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" dependencies = [ "aho-corasick", "memchr", - "regex-syntax", + "regex-syntax 0.6.29", ] [[package]] @@ -3623,7 +3629,7 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132" dependencies = [ - "regex-syntax", + "regex-syntax 0.6.29", ] [[package]] @@ -3632,11 +3638,17 @@ version = "0.6.29" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" +[[package]] +name = "regex-syntax" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbb5fb1acd8a1a18b3dd5be62d25485eb770e05afb408a9627d14d451bae12da" + [[package]] name = "relative-path" -version = "1.8.0" +version = "1.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bf2521270932c3c7bed1a59151222bd7643c79310f2916f01925e1e16255698" +checksum = "c707298afce11da2efef2f600116fa93ffa7a032b5d7b628aa17711ec81383ca" [[package]] name = "reqwest" @@ -3680,9 +3692,9 @@ dependencies = [ [[package]] name = "reqwest-middleware" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99c50db2c7ccd815f976473dd7d0bde296f8c3b77c383acf4fc021cdcf10852b" +checksum = "ff44108c7925d082f2861e683a88618b68235ad9cdc60d64d9d1188efc951cdb" dependencies = [ "anyhow", "async-trait", @@ -3753,20 +3765,6 @@ dependencies = [ "semver 1.0.17", ] -[[package]] -name = "rustix" -version = "0.36.11" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db4165c9963ab29e422d6c26fbc1d37f15bace6b2810221f9d925023480fcf0e" -dependencies = [ - "bitflags 1.3.2", - "errno 0.2.8", - "io-lifetimes", - "libc", - "linux-raw-sys 0.1.4", - "windows-sys 0.45.0", -] - [[package]] name = "rustix" version = "0.37.4" @@ -3774,10 +3772,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c348b5dc624ecee40108aa2922fed8bad89d7fcc2b9f8cb18f632898ac4a37f9" dependencies = [ "bitflags 1.3.2", - "errno 0.3.0", + "errno", "io-lifetimes", "libc", - "linux-raw-sys 0.3.0", + "linux-raw-sys", "windows-sys 0.45.0", ] @@ -3997,11 +3995,11 @@ dependencies = [ [[package]] name = "serde_yaml" -version = "0.9.19" +version = "0.9.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f82e6c8c047aa50a7328632d067bcae6ef38772a79e28daf32f735e0e4f3dd10" +checksum = "1a49e178e4452f45cb61d0cd8cebc1b0fafd3e41929e996cef79aa3aca91f574" dependencies = [ - "indexmap", + "indexmap 2.0.2", "itoa 1.0.6", "ryu", "serde", @@ -4414,22 +4412,20 @@ checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" [[package]] name = "syntect" -version = "5.0.0" +version = "5.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6c454c27d9d7d9a84c7803aaa3c50cd088d2906fe3c6e42da3209aa623576a8" +checksum = "e02b4b303bf8d08bfeb0445cba5068a3d306b6baece1d5582171a9bf49188f91" dependencies = [ "bincode", "bitflags 1.3.2", "fancy-regex", "flate2", "fnv", - "lazy_static", "once_cell", "onig", "plist", - "regex-syntax", + "regex-syntax 0.7.5", "serde", - "serde_derive", "serde_json", "thiserror", "walkdir", @@ -4465,7 +4461,7 @@ dependencies = [ "cfg-if 1.0.0", "fastrand", "redox_syscall 0.3.5", - "rustix 0.37.4", + "rustix", "windows-sys 0.45.0", ] @@ -4480,12 +4476,12 @@ dependencies = [ [[package]] name = "terminal_size" -version = "0.2.5" +version = "0.2.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9afddd2cec1c0909f06b00ef33f94ab2cc0578c4a610aa208ddfec8aa2b43a" +checksum = "8e6bf6f19e9f8ed8d4048dc22981458ebcf406d67e94cd422e5ecd73d63b3237" dependencies = [ - "rustix 0.36.11", - "windows-sys 0.45.0", + "rustix", + "windows-sys 0.48.0", ] [[package]] @@ -4768,7 +4764,7 @@ version = "0.19.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "239410c8609e8125456927e6707163a3b1fdb40561e4b803bc041f466ccfdc13" dependencies = [ - "indexmap", + "indexmap 1.9.3", "toml_datetime", "winnow", ] @@ -4813,7 +4809,7 @@ checksum = "b8fa9be0de6cf49e536ce1851f987bd21a43b771b09473c3549a6c853db37c1c" dependencies = [ "futures-core", "futures-util", - "indexmap", + "indexmap 1.9.3", "pin-project", "pin-project-lite 0.2.9", "rand 0.8.5", @@ -4945,9 +4941,9 @@ dependencies = [ [[package]] name = "uncased" -version = "0.9.7" +version = "0.9.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09b01702b0fd0b3fadcf98e098780badda8742d4f4a7676615cad90e8ac73622" +checksum = "9b9bc53168a4be7402ab86c3aad243a84dd7381d09be0eddc81280c1da95ca68" dependencies = [ "version_check", ] @@ -5018,9 +5014,9 @@ dependencies = [ [[package]] name = "unsafe-libyaml" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad2024452afd3874bf539695e04af6732ba06517424dbf958fdb16a01f3bef6c" +checksum = "f28467d3e1d3c6586d8f25fa243f544f5800fec42d97032474e17222c2b75cfa" [[package]] name = "untrusted" @@ -5536,12 +5532,9 @@ dependencies = [ [[package]] name = "xdg" -version = "2.4.1" +version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c4583db5cbd4c4c0303df2d15af80f0539db703fa1c68802d4cbbd2dd0f88f6" -dependencies = [ - "dirs 4.0.0", -] +checksum = "213b7324336b53d2414b2db8537e56544d981803139155afa84f76eeebb7a546" [[package]] name = "yaml-rust" @@ -5618,9 +5611,9 @@ dependencies = [ [[package]] name = "zip" -version = "0.6.4" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0445d0fbc924bb93539b4316c11afb121ea39296f99a3c4c9edad09e3658cdef" +checksum = "760394e246e4c28189f19d488c058bf16f564016aefac5d32bb1f3b51d5e9261" dependencies = [ "byteorder", "crc32fast", diff --git a/Cargo.toml b/Cargo.toml index 57238a81..1c548f59 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,5 @@ [workspace] +members = ["builder"] [package] name = "_" @@ -10,7 +11,7 @@ tokio_console = ["dep:console-subscriber"] [dependencies] anyhow = { version = "1.0.66", features = ["backtrace"] } -builder = { version = "0.0.0", path = "builder" } +camino = "1.1.4" chrono = { version = "0.4.19", features = ["serde"] } clap = { version = "4.1.4", features = ["derive"] } console-subscriber = { version = "0.1.8", optional = true } diff --git a/builder/Cargo.toml b/builder/Cargo.toml index da563a6b..529cc980 100644 --- a/builder/Cargo.toml +++ b/builder/Cargo.toml @@ -11,6 +11,7 @@ anyhow = { version = "1.0.66", features = ["backtrace"] } camino = "1.1.4" chrono = { version = "0.4.19", features = ["serde"] } chrono-tz = { version = "0.6.1", features = ["serde"] } +clap = { version = "4.1.4", features = ["derive"] } comrak = "0.17.1" console-subscriber = { version = "0.1.8", optional = true } const_format = "0.2.30" diff --git a/builder/src/lib.rs b/builder/src/lib.rs deleted file mode 100644 index 00631b08..00000000 --- a/builder/src/lib.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![warn(clippy::all, clippy::pedantic)] - -use camino::Utf8PathBuf; -use once_cell::sync::Lazy; - -pub static OUTPUT_DIR: Lazy = Lazy::new(|| { - Utf8PathBuf::from(env!("CARGO_MANIFEST_DIR")) - .parent() - .unwrap() - .join(".vercel/output/static") -}); diff --git a/builder/src/main.rs b/builder/src/main.rs index b91c4e2e..d68a1524 100644 --- a/builder/src/main.rs +++ b/builder/src/main.rs @@ -19,15 +19,22 @@ mod syn_helpers; mod tailwind; mod url; -use builder::OUTPUT_DIR; +use anyhow::Result; +use camino::Utf8PathBuf; +use clap::Parser; use ssg_child::generate_static_site; -use anyhow::Result; +#[derive(Parser)] +struct Cli { + output_dir: Utf8PathBuf, +} #[tokio::main] async fn main() -> Result<()> { + let Cli { output_dir } = Cli::parse(); + let file_specs = file_specs::get()?; - let mut generation_task = generate_static_site(OUTPUT_DIR.clone(), file_specs); + let mut generation_task = generate_static_site(output_dir.clone(), file_specs); generation_task.set_file_result_fn(|progress_report| { eprintln!("{progress_report:?}"); @@ -35,7 +42,7 @@ async fn main() -> Result<()> { generation_task.await?; - tailwind::execute().await?; + tailwind::execute(&output_dir).await?; Ok(()) } diff --git a/builder/src/tailwind.rs b/builder/src/tailwind.rs index 6ecf7d22..0d339825 100644 --- a/builder/src/tailwind.rs +++ b/builder/src/tailwind.rs @@ -1,12 +1,10 @@ use std::io::{stdout, Write}; use anyhow::ensure; -use camino::Utf8PathBuf; +use camino::{Utf8Path, Utf8PathBuf}; use tokio::process::Command; -use crate::OUTPUT_DIR; - -pub(crate) async fn execute() -> anyhow::Result<()> { +pub(crate) async fn execute(output_dir: &Utf8Path) -> anyhow::Result<()> { let output = Command::new("npx") .args([ "tailwindcss", @@ -16,21 +14,16 @@ pub(crate) async fn execute() -> anyhow::Result<()> { .collect::() .as_ref(), "--output", - [".".as_ref(), OUTPUT_DIR.as_path(), "index.css".as_ref()] + [".".as_ref(), output_dir, "index.css".as_ref()] .iter() .collect::() .as_ref(), "--content", // TODO explicit list instead of pattern - [ - ".".as_ref(), - OUTPUT_DIR.as_path(), - "**".as_ref(), - "*.html".as_ref(), - ] - .iter() - .collect::() - .as_ref(), + [".".as_ref(), output_dir, "**".as_ref(), "*.html".as_ref()] + .iter() + .collect::() + .as_ref(), ]) .output() .await?; diff --git a/src/main.rs b/src/main.rs index cdc14300..de6f7182 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,9 +1,13 @@ #![warn(clippy::all, clippy::pedantic)] -use builder::OUTPUT_DIR; +use camino::Utf8PathBuf; use clap::{Parser, Subcommand}; +use once_cell::sync::Lazy; use ssg_parent::{dev, DevError}; +pub static OUTPUT_DIR: Lazy = + Lazy::new(|| Utf8PathBuf::from(env!("CARGO_MANIFEST_DIR")).join(".vercel/output/static")); + #[derive(Debug, Parser)] struct Cli { #[command(subcommand)] diff --git a/ssg-parent/src/dev.rs b/ssg-parent/src/dev.rs index 239dd60d..eaed95fb 100644 --- a/ssg-parent/src/dev.rs +++ b/ssg-parent/src/dev.rs @@ -38,7 +38,13 @@ where .boxed(); let mut cargo_run_builder = tokio::process::Command::new("cargo"); - cargo_run_builder.args(["run", "--package", BUILDER_CRATE_NAME]); + cargo_run_builder.args([ + "run", + "--package", + BUILDER_CRATE_NAME, + "--", + output_dir.as_str(), + ]); let url = local_url(port);