From 28e8dbd33f45c37a83d71d8fc068aff63f8c6a9e Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Sun, 2 Feb 2025 21:27:06 -0500 Subject: [PATCH 1/8] Handle cargo-generate using library instead of binary --- Cargo.lock | 1129 ++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 1 + README.md | 5 +- src/command/new.rs | 104 ++-- src/config/dotenvs.rs | 1 - src/ext/exe.rs | 78 --- src/ext/tests.rs | 12 - src/lib.rs | 4 +- 8 files changed, 1161 insertions(+), 173 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bac6d7e9..6c206fe4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -51,6 +51,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" dependencies = [ "cfg-if", + "const-random", "getrandom", "once_cell", "serde", @@ -67,6 +68,15 @@ dependencies = [ "memchr", ] +[[package]] +name = "aligned" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "377e4c0ba83e4431b10df45c1d4666f178ea9c552cac93e60c3a88bf32785923" +dependencies = [ + "as-slice", +] + [[package]] name = "alloc-no-stdlib" version = "2.0.4" @@ -168,6 +178,12 @@ version = "1.0.95" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34ac096ce696dc2fcabef30516bb13c0a68a11d30131d3df6f04711467681b04" +[[package]] +name = "anymap2" +version = "0.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d301b3b94cb4b2f23d7917810addbbaff90738e0ca2be692bd027e70d7e0330c" + [[package]] name = "arbitrary" version = "1.4.1" @@ -183,6 +199,15 @@ version = "0.7.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7c02d123df017efcdfbd739ef81735b36c5ba83ec3c59c80a9d7ecc718f92e50" +[[package]] +name = "as-slice" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "516b6b4f0e40d50dcda9365d53964ec74560ad4284da2e7fc97122cd83174516" +dependencies = [ + "stable_deref_trait", +] + [[package]] name = "ast_node" version = "3.0.0" @@ -206,6 +231,17 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "auth-git2" +version = "0.5.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3810b5af212b013fe7302b12d86616c6c39a48e18f2e4b812a5a9e5710213791" +dependencies = [ + "dirs", + "git2", + "terminal-prompt", +] + [[package]] name = "auto_impl" version = "1.2.1" @@ -404,6 +440,17 @@ dependencies = [ "thiserror 1.0.69", ] +[[package]] +name = "bstr" +version = "1.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "531a9155a481e2ee699d4f98f43c0ca4ff8ee1bfd55c31e9e98fb29d2b176fe0" +dependencies = [ + "memchr", + "regex-automata", + "serde", +] + [[package]] name = "bumpalo" version = "3.16.0" @@ -456,6 +503,49 @@ dependencies = [ "serde", ] +[[package]] +name = "cargo-generate" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd20c031c5650a045e60c7bc274aa2a20d32fd604b9265e760562ceda4bdbf26" +dependencies = [ + "anstyle", + "anyhow", + "auth-git2", + "cargo-util-schemas", + "clap", + "console", + "dialoguer", + "env_logger", + "fs-err", + "git2", + "gix-config", + "heck", + "home", + "ignore", + "indexmap 2.7.1", + "indicatif", + "liquid", + "liquid-core", + "liquid-derive", + "liquid-lib", + "log", + "names", + "paste", + "path-absolutize", + "regex", + "remove_dir_all", + "rhai", + "sanitize-filename", + "semver 1.0.25", + "serde", + "tempfile", + "thiserror 2.0.11", + "time", + "toml", + "walkdir", +] + [[package]] name = "cargo-leptos" version = "0.2.27" @@ -468,6 +558,7 @@ dependencies = [ "brotli", "bytes", "camino", + "cargo-generate", "cargo_metadata", "clap", "derive_more", @@ -511,6 +602,22 @@ dependencies = [ "serde", ] +[[package]] +name = "cargo-util-schemas" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26a31f1bb58068aa01b7809533b02c26b1e64a7810ae99131da5af1a4b8e7fc2" +dependencies = [ + "semver 1.0.25", + "serde", + "serde-untagged", + "serde-value", + "thiserror 1.0.69", + "toml", + "unicode-xid", + "url", +] + [[package]] name = "cargo_metadata" version = "0.19.1" @@ -532,6 +639,8 @@ version = "1.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229" dependencies = [ + "jobserver", + "libc", "shlex", ] @@ -579,6 +688,7 @@ dependencies = [ "anstyle", "clap_lex", "strsim", + "terminal_size", ] [[package]] @@ -614,9 +724,30 @@ dependencies = [ "encode_unicode", "libc", "once_cell", + "unicode-width 0.2.0", "windows-sys 0.59.0", ] +[[package]] +name = "const-random" +version = "0.1.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87e00182fe74b066627d63b85fd550ac2998d4b0bd86bfed477a0ae4c7c71359" +dependencies = [ + "const-random-macro", +] + +[[package]] +name = "const-random-macro" +version = "0.1.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9d839f2a20b0aee515dc581a6172f2321f96cab76c1a38a4c584a194955390e" +dependencies = [ + "getrandom", + "once_cell", + "tiny-keccak", +] + [[package]] name = "const-str" version = "0.3.2" @@ -704,6 +835,12 @@ version = "0.8.21" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28" +[[package]] +name = "crunchy" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43da5946c66ffcc7745f48db692ffbb10a83bfe0afd96235c5c2a4fb23994929" + [[package]] name = "crypto-common" version = "0.1.6" @@ -746,6 +883,15 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "cvt" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2ae9bf77fbf2d39ef573205d554d87e86c12f1994e9ea335b0651b9b278bcf1" +dependencies = [ + "cfg-if", +] + [[package]] name = "darling" version = "0.20.10" @@ -825,6 +971,15 @@ dependencies = [ "uuid", ] +[[package]] +name = "deranged" +version = "0.3.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +dependencies = [ + "powerfmt", +] + [[package]] name = "derive-where" version = "1.2.7" @@ -899,6 +1054,19 @@ dependencies = [ "unicode-xid", ] +[[package]] +name = "dialoguer" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "658bce805d770f407bc62102fca7c2c64ceef2fbcb2b8bd19d2765ce093980de" +dependencies = [ + "console", + "shell-words", + "tempfile", + "thiserror 1.0.69", + "zeroize", +] + [[package]] name = "digest" version = "0.10.7" @@ -980,18 +1148,51 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "34aa73646ffb006b8f5147f3dc182bd4bcb190227ce861fc4a4844bf8e3cb2c0" +[[package]] +name = "env_filter" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "186e05a59d4c50738528153b83b0b0194d3a29507dfec16eccd4b342903397d0" +dependencies = [ + "log", + "regex", +] + [[package]] name = "env_home" version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c7f84e12ccf0a7ddc17a6c41c93326024c42920d7ee630d04950e6926645c0fe" +[[package]] +name = "env_logger" +version = "0.11.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dcaee3d8e3cfc3fd92428d477bc97fc29ec8716d180c0d74c643bb26166660e0" +dependencies = [ + "anstream", + "anstyle", + "env_filter", + "humantime", + "log", +] + [[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.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24e2389d65ab4fab27dc2a5de7b191e1f6617d1f1c8855c0dc569c94a4cbb18d" +dependencies = [ + "serde", + "typeid", +] + [[package]] name = "errno" version = "0.3.10" @@ -1008,6 +1209,12 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" +[[package]] +name = "faster-hex" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a2a2b11eda1d40935b26cf18f6833c526845ae8c41e58d09af6adeb6f0269183" + [[package]] name = "fastrand" version = "2.3.0" @@ -1081,6 +1288,29 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "fs-err" +version = "3.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8bb60e7409f34ef959985bc9d9c5ee8f5db24ee46ed9775850548021710f807f" +dependencies = [ + "autocfg", +] + +[[package]] +name = "fs_at" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "14af6c9694ea25db25baa2a1788703b9e7c6648dcaeeebeb98f7561b5384c036" +dependencies = [ + "aligned", + "cfg-if", + "cvt", + "libc", + "nix", + "windows-sys 0.52.0", +] + [[package]] name = "fsevent-sys" version = "4.1.0" @@ -1186,6 +1416,257 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" +[[package]] +name = "git2" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b903b73e45dc0c6c596f2d37eccece7c1c8bb6e4407b001096387c63d0d93724" +dependencies = [ + "bitflags 2.8.0", + "libc", + "libgit2-sys", + "log", + "openssl-probe", + "openssl-sys", + "url", +] + +[[package]] +name = "gix-actor" +version = "0.32.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fc19e312cd45c4a66cd003f909163dc2f8e1623e30a0c0c6df3776e89b308665" +dependencies = [ + "bstr", + "gix-date", + "gix-utils", + "itoa", + "thiserror 1.0.69", + "winnow 0.6.26", +] + +[[package]] +name = "gix-config" +version = "0.40.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78e797487e6ca3552491de1131b4f72202f282fb33f198b1c34406d765b42bb0" +dependencies = [ + "bstr", + "gix-config-value", + "gix-features", + "gix-glob", + "gix-path", + "gix-ref", + "gix-sec", + "memchr", + "once_cell", + "smallvec", + "thiserror 1.0.69", + "unicode-bom", + "winnow 0.6.26", +] + +[[package]] +name = "gix-config-value" +version = "0.14.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "11365144ef93082f3403471dbaa94cfe4b5e72743bdb9560719a251d439f4cee" +dependencies = [ + "bitflags 2.8.0", + "bstr", + "gix-path", + "libc", + "thiserror 2.0.11", +] + +[[package]] +name = "gix-date" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c57c477b645ee248b173bb1176b52dd528872f12c50375801a58aaf5ae91113f" +dependencies = [ + "bstr", + "itoa", + "jiff", + "thiserror 2.0.11", +] + +[[package]] +name = "gix-features" +version = "0.38.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac7045ac9fe5f9c727f38799d002a7ed3583cd777e3322a7c4b43e3cf437dc69" +dependencies = [ + "gix-hash", + "gix-trace", + "gix-utils", + "libc", + "prodash", + "sha1_smol", + "walkdir", +] + +[[package]] +name = "gix-fs" +version = "0.11.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2bfe6249cfea6d0c0e0990d5226a4cb36f030444ba9e35e0639275db8f98575" +dependencies = [ + "fastrand", + "gix-features", + "gix-utils", +] + +[[package]] +name = "gix-glob" +version = "0.16.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "74908b4bbc0a0a40852737e5d7889f676f081e340d5451a16e5b4c50d592f111" +dependencies = [ + "bitflags 2.8.0", + "bstr", + "gix-features", + "gix-path", +] + +[[package]] +name = "gix-hash" +version = "0.14.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f93d7df7366121b5018f947a04d37f034717e113dcf9ccd85c34b58e57a74d5e" +dependencies = [ + "faster-hex", + "thiserror 1.0.69", +] + +[[package]] +name = "gix-lock" +version = "14.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3bc7fe297f1f4614774989c00ec8b1add59571dc9b024b4c00acb7dedd4e19d" +dependencies = [ + "gix-tempfile", + "gix-utils", + "thiserror 1.0.69", +] + +[[package]] +name = "gix-object" +version = "0.44.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2f5b801834f1de7640731820c2df6ba88d95480dc4ab166a5882f8ff12b88efa" +dependencies = [ + "bstr", + "gix-actor", + "gix-date", + "gix-features", + "gix-hash", + "gix-utils", + "gix-validate", + "itoa", + "smallvec", + "thiserror 1.0.69", + "winnow 0.6.26", +] + +[[package]] +name = "gix-path" +version = "0.10.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c40f12bb65a8299be0cfb90fe718e3be236b7a94b434877012980863a883a99f" +dependencies = [ + "bstr", + "gix-trace", + "home", + "once_cell", + "thiserror 2.0.11", +] + +[[package]] +name = "gix-ref" +version = "0.47.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ae0d8406ebf9aaa91f55a57f053c5a1ad1a39f60fdf0303142b7be7ea44311e5" +dependencies = [ + "gix-actor", + "gix-features", + "gix-fs", + "gix-hash", + "gix-lock", + "gix-object", + "gix-path", + "gix-tempfile", + "gix-utils", + "gix-validate", + "memmap2", + "thiserror 1.0.69", + "winnow 0.6.26", +] + +[[package]] +name = "gix-sec" +version = "0.10.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d84dae13271f4313f8d60a166bf27e54c968c7c33e2ffd31c48cafe5da649875" +dependencies = [ + "bitflags 2.8.0", + "gix-path", + "libc", + "windows-sys 0.52.0", +] + +[[package]] +name = "gix-tempfile" +version = "14.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "046b4927969fa816a150a0cda2e62c80016fe11fb3c3184e4dddf4e542f108aa" +dependencies = [ + "gix-fs", + "libc", + "once_cell", + "parking_lot", + "tempfile", +] + +[[package]] +name = "gix-trace" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7c396a2036920c69695f760a65e7f2677267ccf483f25046977d87e4cb2665f7" + +[[package]] +name = "gix-utils" +version = "0.1.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff08f24e03ac8916c478c8419d7d3c33393da9bb41fa4c24455d5406aeefd35f" +dependencies = [ + "fastrand", + "unicode-normalization", +] + +[[package]] +name = "gix-validate" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9eaa01c3337d885617c0a42e92823922a2aea71f4caeace6fe87002bdcadbd90" +dependencies = [ + "bstr", + "thiserror 2.0.11", +] + +[[package]] +name = "globset" +version = "0.4.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15f1ce686646e7f1e19bf7d5533fe443a45dbfb990e00629110797578b42fb19" +dependencies = [ + "aho-corasick", + "bstr", + "log", + "regex-automata", + "regex-syntax", +] + [[package]] name = "hashbrown" version = "0.12.3" @@ -1233,6 +1714,15 @@ version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231dfb89cfffdbc30e7fc41579ed6066ad03abda9e567ccafae602b97ec5024" +[[package]] +name = "home" +version = "0.5.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "589533453244b0995c858700322199b2becb13b627df2851f64a2775d024abcf" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "hstr" version = "0.2.15" @@ -1293,6 +1783,12 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" +[[package]] +name = "humantime" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" + [[package]] name = "hyper" version = "1.5.2" @@ -1533,6 +2029,22 @@ version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cb56e1aa765b4b4f3aadfab769793b7087bb03a4ea4920644a6d238e2df5b9ed" +[[package]] +name = "ignore" +version = "0.4.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6d89fd380afde86567dfba715db065673989d6253f42b88179abd3eae47bda4b" +dependencies = [ + "crossbeam-deque", + "globset", + "log", + "memchr", + "regex-automata", + "same-file", + "walkdir", + "winapi-util", +] + [[package]] name = "indexmap" version = "1.9.3" @@ -1554,6 +2066,19 @@ dependencies = [ "serde", ] +[[package]] +name = "indicatif" +version = "0.17.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "183b3088984b400f4cfac3620d5e076c84da5364016b4f49473de574b2586235" +dependencies = [ + "console", + "number_prefix", + "portable-atomic", + "unicode-width 0.2.0", + "web-time", +] + [[package]] name = "inotify" version = "0.10.2" @@ -1638,12 +2163,59 @@ dependencies = [ "either", ] +[[package]] +name = "itertools" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285" +dependencies = [ + "either", +] + [[package]] name = "itoa" version = "1.0.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" +[[package]] +name = "jiff" +version = "0.1.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c04ef77ae73f3cf50510712722f0c4e8b46f5aaa1bf5ffad2ae213e6495e78e5" +dependencies = [ + "jiff-tzdb-platform", + "log", + "portable-atomic", + "portable-atomic-util", + "serde", + "windows-sys 0.59.0", +] + +[[package]] +name = "jiff-tzdb" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cf2cec2f5d266af45a071ece48b1fb89f3b00b2421ac3a5fe10285a6caaa60d3" + +[[package]] +name = "jiff-tzdb-platform" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a63c62e404e7b92979d2792352d885a7f8f83fd1d0d31eea582d77b2ceca697e" +dependencies = [ + "jiff-tzdb", +] + +[[package]] +name = "jobserver" +version = "0.1.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48d1dbcbbeb6a7fec7e059840aa538bd62aaccf972c7346c4d9d2059312853d0" +dependencies = [ + "libc", +] + [[package]] name = "js-sys" version = "0.3.77" @@ -1683,6 +2255,16 @@ dependencies = [ "libc", ] +[[package]] +name = "kstring" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "558bf9508a558512042d3095138b1f7b8fe90c5467d94f9f1da28b3731c5dbd1" +dependencies = [ + "serde", + "static_assertions", +] + [[package]] name = "lazy_static" version = "1.5.0" @@ -1743,6 +2325,20 @@ dependencies = [ "rle-decode-fast", ] +[[package]] +name = "libgit2-sys" +version = "0.17.0+1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "10472326a8a6477c3c20a64547b0059e4b0d086869eee31e6d7da728a8eb7224" +dependencies = [ + "cc", + "libc", + "libssh2-sys", + "libz-sys", + "openssl-sys", + "pkg-config", +] + [[package]] name = "libredox" version = "0.1.3" @@ -1754,6 +2350,32 @@ dependencies = [ "redox_syscall", ] +[[package]] +name = "libssh2-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "220e4f05ad4a218192533b300327f5150e809b54c4ec83b5a1d91833601811b9" +dependencies = [ + "cc", + "libc", + "libz-sys", + "openssl-sys", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "libz-sys" +version = "1.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "df9b68e50e6e0b26f672573834882eb57759f6db9b3be2ea3c35c91188bb4eaa" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + [[package]] name = "lightningcss" version = "1.0.0-alpha.63" @@ -1806,6 +2428,60 @@ version = "0.4.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d26c52dbd32dccf2d10cac7725f8eae5296885fb5703b261f7d0a0739ec807ab" +[[package]] +name = "liquid" +version = "0.26.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d394f129df4bc476c828219f621c1a9e42c9d40c31e2849242087cb5ee279448" +dependencies = [ + "liquid-core", + "liquid-derive", + "liquid-lib", + "serde", +] + +[[package]] +name = "liquid-core" +version = "0.26.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e7b563798f47f5158238ece76514553c2ce8ca58a20dd59abb21dfdbc3724980" +dependencies = [ + "anymap2", + "itertools 0.14.0", + "kstring", + "liquid-derive", + "pest", + "pest_derive", + "regex", + "serde", + "time", +] + +[[package]] +name = "liquid-derive" +version = "0.26.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ddde51013c8d2694f8c162c2ceb7abaed91f5175ec1e75a6392e35913e907c5d" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", +] + +[[package]] +name = "liquid-lib" +version = "0.26.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e2bf4efd9b4a38bf76fac10d8f010ac568251761290a3dbffd4719d41c9f044" +dependencies = [ + "itertools 0.14.0", + "liquid-core", + "percent-encoding", + "regex", + "time", + "unicode-segmentation", +] + [[package]] name = "litemap" version = "0.7.4" @@ -1871,6 +2547,15 @@ version = "2.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +[[package]] +name = "memmap2" +version = "0.9.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd3f7eed9d3848f8b98834af67102b720745c4ec028fcd0aa0239277e7de374f" +dependencies = [ + "libc", +] + [[package]] name = "miette" version = "7.4.0" @@ -1882,7 +2567,7 @@ dependencies = [ "owo-colors", "textwrap", "thiserror 1.0.69", - "unicode-width", + "unicode-width 0.1.14", ] [[package]] @@ -1929,12 +2614,33 @@ dependencies = [ "windows-sys 0.52.0", ] +[[package]] +name = "names" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7bddcd3bf5144b6392de80e04c347cd7fab2508f6df16a85fc496ecd5cec39bc" +dependencies = [ + "rand", +] + [[package]] name = "new_debug_unreachable" version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "650eef8c711430f1a879fdd01d4745a7deea475becfb90269c06775983bbf086" +[[package]] +name = "nix" +version = "0.29.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "71e2746dc3a24dd78b3cfcb7be93368c6de9963d30f43a6a73998a9cf4b17b46" +dependencies = [ + "bitflags 2.8.0", + "cfg-if", + "cfg_aliases", + "libc", +] + [[package]] name = "nom" version = "7.1.3" @@ -1954,6 +2660,15 @@ dependencies = [ "winapi", ] +[[package]] +name = "normpath" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c8911957c4b1549ac0dc74e30db9c8b0e66ddcd6d7acc33098f4c63a64a6d7ed" +dependencies = [ + "windows-sys 0.59.0", +] + [[package]] name = "notify" version = "7.0.0" @@ -2002,6 +2717,12 @@ dependencies = [ "serde", ] +[[package]] +name = "num-conv" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "51d515d32fb182ee37cda2ccdcb92950d6a3c2893aa280e540671c2cd0f3b1d9" + [[package]] name = "num-integer" version = "0.1.46" @@ -2030,6 +2751,12 @@ dependencies = [ "libc", ] +[[package]] +name = "number_prefix" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" + [[package]] name = "object" version = "0.36.7" @@ -2044,6 +2771,27 @@ name = "once_cell" version = "1.20.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1261fe7e33c73b354eab43b1273a57c8f967d0391e80353e51f764ac02cf6775" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "openssl-probe" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d05e27ee213611ffe7d6348b942e8f942b37114c00cc03cec254295a4a17852e" + +[[package]] +name = "openssl-sys" +version = "0.9.105" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b22d5b84be05a8d6947c7cb71f7c849aa0f112acd4bf51c2a7c1c988ac0a9dc" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] [[package]] name = "option-ext" @@ -2051,6 +2799,15 @@ version = "0.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" +[[package]] +name = "ordered-float" +version = "2.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68f19d67e5a2795c94e73e0bb1cc1a7edeb2e28efd39e2e1c9b7a40c1108b11c" +dependencies = [ + "num-traits", +] + [[package]] name = "outref" version = "0.1.0" @@ -2122,6 +2879,15 @@ version = "1.0.15" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" +[[package]] +name = "path-absolutize" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4af381fe79fa195b4909485d99f73a80792331df0625188e707854f0b3383f5" +dependencies = [ + "path-dedot", +] + [[package]] name = "path-clean" version = "0.1.0" @@ -2134,6 +2900,15 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "17359afc20d7ab31fdb42bb844c8b3bb1dabd7dcf7e68428492da7f16966fcef" +[[package]] +name = "path-dedot" +version = "3.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07ba0ad7e047712414213ff67533e6dd477af0a4e1d14fb52343e53d30ea9397" +dependencies = [ + "once_cell", +] + [[package]] name = "pathdiff" version = "0.2.3" @@ -2149,6 +2924,51 @@ version = "2.3.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e" +[[package]] +name = "pest" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b7cafe60d6cf8e62e1b9b2ea516a089c008945bb5a275416789e7db0bc199dc" +dependencies = [ + "memchr", + "thiserror 2.0.11", + "ucd-trie", +] + +[[package]] +name = "pest_derive" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "816518421cfc6887a0d62bf441b6ffb4536fcc926395a69e1a85852d4363f57e" +dependencies = [ + "pest", + "pest_generator", +] + +[[package]] +name = "pest_generator" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7d1396fd3a870fc7838768d171b4616d5c91f6cc25e377b673d714567d99377b" +dependencies = [ + "pest", + "pest_meta", + "proc-macro2", + "quote", + "syn 2.0.96", +] + +[[package]] +name = "pest_meta" +version = "2.7.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e1e58089ea25d717bfd31fb534e4f3afcc2cc569c70de3e239778991ea3b7dea" +dependencies = [ + "once_cell", + "pest", + "sha2", +] + [[package]] name = "petgraph" version = "0.6.5" @@ -2223,6 +3043,33 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" +[[package]] +name = "pkg-config" +version = "0.3.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2" + +[[package]] +name = "portable-atomic" +version = "1.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "280dc24453071f1b63954171985a0b0d30058d287960968b9b2aca264c8d4ee6" + +[[package]] +name = "portable-atomic-util" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d8a2f0d8d040d7848a709caf78912debcc3f33ee4b3cac47d73d1e1069e83507" +dependencies = [ + "portable-atomic", +] + +[[package]] +name = "powerfmt" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "439ee305def115ba05938db6eb1644ff94165c5ab5e9420d1c1bcedbba909391" + [[package]] name = "ppv-lite86" version = "0.2.20" @@ -2299,6 +3146,12 @@ dependencies = [ "yansi", ] +[[package]] +name = "prodash" +version = "28.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "744a264d26b88a6a7e37cbad97953fa233b94d585236310bcbc88474b4092d79" + [[package]] name = "psm" version = "0.1.24" @@ -2520,6 +3373,20 @@ version = "0.8.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c" +[[package]] +name = "remove_dir_all" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a694f9e0eb3104451127f6cc1e5de55f59d3b1fc8c5ddfaeb6f1e716479ceb4a" +dependencies = [ + "cfg-if", + "cvt", + "fs_at", + "libc", + "normpath 1.3.0", + "windows-sys 0.59.0", +] + [[package]] name = "rend" version = "0.4.2" @@ -2573,6 +3440,34 @@ dependencies = [ "windows-registry", ] +[[package]] +name = "rhai" +version = "1.20.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0277a46f29fe3b3eb10821ca2c65a4751b686b6c84422aae31695ba167b0fbc" +dependencies = [ + "ahash 0.8.11", + "bitflags 2.8.0", + "instant", + "num-traits", + "once_cell", + "rhai_codegen", + "smallvec", + "smartstring", + "thin-vec", +] + +[[package]] +name = "rhai_codegen" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5a11a05ee1ce44058fa3d5961d05194fdbe3ad6b40f904af764d81b86450e6b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.96", +] + [[package]] name = "ring" version = "0.17.8" @@ -2748,6 +3643,16 @@ dependencies = [ "winapi-util", ] +[[package]] +name = "sanitize-filename" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2ed72fbaf78e6f2d41744923916966c4fbe3d7c74e3037a8ee482f1115572603" +dependencies = [ + "lazy_static", + "regex", +] + [[package]] name = "scoped-tls" version = "1.0.1" @@ -2799,6 +3704,27 @@ dependencies = [ "serde_derive", ] +[[package]] +name = "serde-untagged" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2676ba99bd82f75cae5cbd2c8eda6fa0b8760f18978ea840e980dd5567b5c5b6" +dependencies = [ + "erased-serde", + "serde", + "typeid", +] + +[[package]] +name = "serde-value" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f3a1a3341211875ef120e117ea7fd5228530ae7e7036a779fdc9117be6b3282c" +dependencies = [ + "ordered-float", + "serde", +] + [[package]] name = "serde_derive" version = "1.0.217" @@ -2832,6 +3758,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87607cb1398ed59d48732e575a4c28a7a8ebf2454b964fe3f224f2afc07909e1" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -2855,6 +3790,29 @@ dependencies = [ "digest", ] +[[package]] +name = "sha1_smol" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbfa15b3dddfee50a0fff136974b3e1bde555604ba463834a7eb7deb6417705d" + +[[package]] +name = "sha2" +version = "0.10.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "793db75ad2bcafc3ffa7c68b215fee268f537982cd901d132f89c6343f3a3dc8" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest", +] + +[[package]] +name = "shell-words" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24188a676b6ae68c3b2cb3a01be17fbf7240ce009799bb56d5b1409051e78fde" + [[package]] name = "shlex" version = "1.3.0" @@ -3154,7 +4112,7 @@ dependencies = [ "swc_eq_ignore_macros", "swc_visit", "tracing", - "unicode-width", + "unicode-width 0.1.14", "url", ] @@ -3500,7 +4458,7 @@ dependencies = [ "anyhow", "dashmap", "lru", - "normpath", + "normpath 0.2.0", "once_cell", "parking_lot", "path-clean 0.1.0", @@ -4072,18 +5030,37 @@ checksum = "bc1ee6eef34f12f765cb94725905c6312b6610ab2b0940889cfe58dae7bc3c72" [[package]] name = "tempfile" -version = "3.15.0" +version = "3.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a8a559c81686f576e8cd0290cd2a24a2a9ad80c98b3478856500fcbd7acd704" +checksum = "f0f2c9fc62d0beef6951ccffd757e241266a2c833136efbe35af6cd2567dca5b" dependencies = [ "cfg-if", "fastrand", - "getrandom", "once_cell", "rustix", "windows-sys 0.59.0", ] +[[package]] +name = "terminal-prompt" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "572818b3472910acbd5dff46a3413715c18e934b071ab2ba464a7b2c2af16376" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "terminal_size" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5352447f921fda68cf61b4101566c0bdb5104eff6804d0678e5227580ab6a4e9" +dependencies = [ + "rustix", + "windows-sys 0.59.0", +] + [[package]] name = "textwrap" version = "0.16.1" @@ -4091,9 +5068,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "unicode-linebreak", - "unicode-width", + "unicode-width 0.1.14", ] +[[package]] +name = "thin-vec" +version = "0.2.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a38c90d48152c236a3ab59271da4f4ae63d678c5d7ad6b7714d7cb9760be5e4b" + [[package]] name = "thiserror" version = "1.0.69" @@ -4134,6 +5117,46 @@ dependencies = [ "syn 2.0.96", ] +[[package]] +name = "time" +version = "0.3.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +dependencies = [ + "deranged", + "itoa", + "num-conv", + "powerfmt", + "serde", + "time-core", + "time-macros", +] + +[[package]] +name = "time-core" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" + +[[package]] +name = "time-macros" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +dependencies = [ + "num-conv", + "time-core", +] + +[[package]] +name = "tiny-keccak" +version = "2.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2c9d3793400a45f954c52e73d068316d76b6f4e36977e3fcebb13a2721e80237" +dependencies = [ + "crunchy", +] + [[package]] name = "tinystr" version = "0.7.6" @@ -4210,6 +5233,41 @@ dependencies = [ "tungstenite", ] +[[package]] +name = "toml" +version = "0.8.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a1ed1f98e3fdc28d6d910e6737ae6ab1a93bf1985935a1193e68f93eeb68d24e" +dependencies = [ + "indexmap 2.7.1", + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit", +] + +[[package]] +name = "toml_datetime" +version = "0.6.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0dd7358ecb8fc2f8d014bf86f6f638ce72ba252a2c3a2572f2a795f1d23efb41" +dependencies = [ + "serde", +] + +[[package]] +name = "toml_edit" +version = "0.22.23" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "02a8b472d1a3d7c18e2d61a489aee3453fd9031c33e4f55bd533f4a7adca1bee" +dependencies = [ + "indexmap 2.7.1", + "serde", + "serde_spanned", + "toml_datetime", + "winnow 0.7.0", +] + [[package]] name = "tower" version = "0.5.2" @@ -4310,12 +5368,30 @@ version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6af6ae20167a9ece4bcb41af5b80f8a1f1df981f6391189ce00fd257af04126a" +[[package]] +name = "typeid" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0e13db2e0ccd5e14a544e8a246ba2312cd25223f616442d7f2cb0e3db614236e" + [[package]] name = "typenum" version = "1.17.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" +[[package]] +name = "ucd-trie" +version = "0.1.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2896d95c02a80c6d6a5d6e953d479f5ddf2dfdb6a244441010e373ac0fb88971" + +[[package]] +name = "unicode-bom" +version = "2.0.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7eec5d1121208364f6793f7d2e222bf75a915c19557537745b195b253dd64217" + [[package]] name = "unicode-id" version = "0.3.5" @@ -4340,6 +5416,15 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3b09c83c3c29d37506a3e260c08c03743a6bb66a9cd432c6934ab501a190571f" +[[package]] +name = "unicode-normalization" +version = "0.1.24" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5033c97c4262335cded6d6fc3e5c18ab755e1a3dc96376350f3d8e9f009ad956" +dependencies = [ + "tinyvec", +] + [[package]] name = "unicode-segmentation" version = "1.12.0" @@ -4352,6 +5437,12 @@ version = "0.1.14" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af" +[[package]] +name = "unicode-width" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fc81956842c57dac11422a97c3b8195a1ff727f06e85c84ed2e8aa277c9a0fd" + [[package]] name = "unicode-xid" version = "0.2.6" @@ -4405,6 +5496,12 @@ version = "1.12.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b3758f5e68192bb96cc8f9b7e2c2cfdabb435499a28499a42f8f984092adad4b" +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + [[package]] name = "version_check" version = "0.9.5" @@ -4904,6 +6001,24 @@ version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" +[[package]] +name = "winnow" +version = "0.6.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e90edd2ac1aa278a5c4599b1d89cf03074b610800f866d4026dc199d7929a28" +dependencies = [ + "memchr", +] + +[[package]] +name = "winnow" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e49d2d35d3fad69b39b94139037ecfb4f359f08958b9c11e7315ce770462419" +dependencies = [ + "memchr", +] + [[package]] name = "winsafe" version = "0.0.19" diff --git a/Cargo.toml b/Cargo.toml index 03c5f551..87abd2e1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -88,6 +88,7 @@ base64ct = { version = "1.6.0", features = ["alloc"] } swc = "10.0" swc_common = "5.0" shlex = "1.3.0" +cargo-generate = "0.22" [dev-dependencies] insta = { version = "1.40.0", features = ["yaml"] } diff --git a/README.md b/README.md index 34c6b2e7..4fd2a6ab 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,7 @@ For setting up your project, have a look at the [examples](https://github.com/le ## Dependencies -The dependencies for [sass](https://sass-lang.com/install), [wasm-opt](https://github.com/WebAssembly/binaryen) and -[cargo-generate](https://github.com/cargo-generate/cargo-generate#installation) are automatically installed in a cache directory -when they are used if they are not already installed and found by [which](https://crates.io/crates/which). +The dependencies for [sass](https://sass-lang.com/install) and [wasm-opt](https://github.com/WebAssembly/binaryen) are automatically installed in a cache directory when they are used if they are not already installed and found by [which](https://crates.io/crates/which). Different versions of the dependencies might accumulate in this directory, so feel free to delete it. | OS | Example | @@ -334,7 +332,6 @@ Note when using directories: Internally the versions of the external tools called by `cargo-leptos` are hardcoded. Use these environment variables to override the versions `cargo-leptos` should use (e.g. `LEPTOS_SASS_VERSION=1.69.5`): -- LEPTOS_CARGO_GENERATE_VERSION - LEPTOS_TAILWIND_VERSION - LEPTOS_SASS_VERSION - LEPTOS_WASM_OPT_VERSION diff --git a/src/command/new.rs b/src/command/new.rs index d07c6cee..99d71875 100644 --- a/src/command/new.rs +++ b/src/command/new.rs @@ -1,10 +1,7 @@ use crate::ext::anyhow::{Context, Result}; +use cargo_generate::{generate, GenerateArgs, TemplatePath}; use clap::Args; -use tokio::process::Command; - -use crate::ext::exe::Exe; - // A subset of the cargo-generate commands available. // See: https://github.com/cargo-generate/cargo-generate/blob/main/src/args.rs @@ -51,77 +48,46 @@ pub struct NewCommand { } impl NewCommand { - pub async fn run(&self) -> Result<()> { - let args = self.to_args(); - let exe = Exe::CargoGenerate.get().await.dot()?; + pub fn run(self) -> Result<()> { + let args = GenerateArgs { + template_path: TemplatePath { + git: absolute_git_url(self.git), + branch: self.branch.clone(), + tag: self.tag.clone(), + path: self.path.clone(), + ..Default::default() + }, + name: self.name.clone(), + force: self.force, + verbose: self.verbose, + init: self.init, + ..Default::default() + }; + + generate(args).dot()?; - let mut process = Command::new(exe) - .arg("generate") - .args(&args) - .spawn() - .context("Could not spawn cargo-generate command (verify that it is installed)")?; - process.wait().await.dot()?; Ok(()) } - - pub fn to_args(&self) -> Vec { - let mut args = vec![]; - opt_push(&mut args, "git", &absolute_git_url(&self.git)); - opt_push(&mut args, "branch", &self.branch); - opt_push(&mut args, "tag", &self.tag); - opt_push(&mut args, "path", &self.path); - opt_push(&mut args, "name", &self.name); - bool_push(&mut args, "force", self.force); - bool_push(&mut args, "verbose", self.verbose); - bool_push(&mut args, "init", self.init); - args - } -} - -fn bool_push(args: &mut Vec, name: &str, set: bool) { - if set { - args.push(format!("--{name}")) - } -} - -fn opt_push(args: &mut Vec, name: &str, arg: &Option) { - if let Some(arg) = arg { - args.push(format!("--{name}")); - args.push(arg.clone()); - } } /// Workaround to support short `new --git leptos-rs/start` command when behind Git proxy. /// See https://github.com/cargo-generate/cargo-generate/issues/752. -fn absolute_git_url(url: &Option) -> Option { - match url { - Some(url) => match url.as_str() { - // leptos-rs official templates - // NB: The alternate workarounds enable an even shorter `cargo leptos new --git start-{{trunk | actix | axum | ..}}` command syntax - "start-trunk" => Some("https://github.com/leptos-rs/start-trunk".to_string()), - "leptos-rs/start-trunk" => Some("https://github.com/leptos-rs/start-trunk".to_string()), - - "start-actix" => Some("https://github.com/leptos-rs/start".to_string()), - "leptos-rs/start" => Some("https://github.com/leptos-rs/start".to_string()), - "leptos-rs/start-actix" => Some("https://github.com/leptos-rs/start".to_string()), - - "start-axum" => Some("https://github.com/leptos-rs/start-axum".to_string()), - "leptos-rs/start-axum" => Some("https://github.com/leptos-rs/start-axum".to_string()), - - "start-axum-workspace" => { - Some("https://github.com/leptos-rs/start-axum-workspace".to_string()) - } - "leptos-rs/start-axum-workspace" => { - Some("https://github.com/leptos-rs/start-axum-workspace".to_string()) - } - "start-aws" => Some("https://github.com/leptos-rs/start-aws".to_string()), - "leptos-rs/start-aws" => Some("https://github.com/leptos-rs/start-aws".to_string()), - - "start-spin" => Some("https://github.com/leptos-rs/start-spin".to_string()), - "leptos-rs/start-spin" => Some("https://github.com/leptos-rs/start-spin".to_string()), +fn absolute_git_url(url: Option) -> Option { + url.map(|url| match url.as_str() { + "start-trunk" | "leptos-rs/start-trunk" => format_leptos_starter_url("start-trunk"), + "start-actix" | "leptos-rs/start" | "leptos-rs/start-actix" => { + format_leptos_starter_url("start") + } + "start-axum" | "leptos-rs/start-axum" => format_leptos_starter_url("start-axum"), + "start-axum-workspace" | "leptos-rs/start-axum-workspace" => { + format_leptos_starter_url("start-axum-workspace") + } + "start-aws" | "leptos-rs/start-aws" => format_leptos_starter_url("start-aws"), + "start-spin" | "leptos-rs/start-spin" => format_leptos_starter_url("start-spin"), + _ => url, + }) +} - _ => Some(url.to_string()), - }, - None => None, - } +fn format_leptos_starter_url(repo: &str) -> String { + format!("https://github.com/leptos-rs/{repo}") } diff --git a/src/config/dotenvs.rs b/src/config/dotenvs.rs index 11005192..4bd8e015 100644 --- a/src/config/dotenvs.rs +++ b/src/config/dotenvs.rs @@ -61,7 +61,6 @@ fn overlay(conf: &mut ProjectConfig, envs: impl Iterator {} exe::ENV_VAR_LEPTOS_SASS_VERSION => {} - exe::ENV_VAR_LEPTOS_CARGO_GENERATE_VERSION => {} exe::ENV_VAR_LEPTOS_WASM_OPT_VERSION => {} _ if key.starts_with("LEPTOS_") => { log::warn!("Env {key} is not used by cargo-leptos") diff --git a/src/ext/exe.rs b/src/ext/exe.rs index 3f18b246..4f256bd6 100644 --- a/src/ext/exe.rs +++ b/src/ext/exe.rs @@ -36,7 +36,6 @@ lazy_static::lazy_static! { static ref ON_STARTUP_DEBUG_ONCE: Once = Once::new(); } -pub const ENV_VAR_LEPTOS_CARGO_GENERATE_VERSION: &str = "LEPTOS_CARGO_GENERATE_VERSION"; pub const ENV_VAR_LEPTOS_TAILWIND_VERSION: &str = "LEPTOS_TAILWIND_VERSION"; pub const ENV_VAR_LEPTOS_SASS_VERSION: &str = "LEPTOS_SASS_VERSION"; pub const ENV_VAR_LEPTOS_WASM_OPT_VERSION: &str = "LEPTOS_WASM_OPT_VERSION"; @@ -212,7 +211,6 @@ fn get_cache_dir() -> Result { #[derive(Debug, Hash, Eq, PartialEq)] pub enum Exe { - CargoGenerate, Sass, WasmOpt, Tailwind, @@ -244,15 +242,6 @@ impl Exe { let (target_os, target_arch) = os_arch().unwrap(); let exe = match self { - // There's a problem with upgrading cargo-generate because the tar file cannot be extracted - // due to missing support for https://github.com/alexcrichton/tar-rs/pull/298 - // The tar extracts ok, but contains a folder `GNUSparseFile.0` which contains a file `cargo-generate` - // that has not been fully extracted. - // let command = &CommandCargoGenerate as &dyn Command; - Exe::CargoGenerate => CommandCargoGenerate - .exe_meta(target_os, target_arch) - .await - .dot()?, Exe::Sass => CommandSass.exe_meta(target_os, target_arch).await.dot()?, Exe::WasmOpt => CommandWasmOpt .exe_meta(target_os, target_arch) @@ -270,7 +259,6 @@ impl Exe { /// Tailwind uses the 'vMaj.Min.Pat' format. /// WASM opt uses 'version_NNN' format. -/// Cargo-generate has the 'vX.Y.Z' format /// We generally want to keep the suffix intact, /// as it carries classifiers, etc, but strip non-ascii /// digits from the prefix. @@ -309,7 +297,6 @@ use async_trait::async_trait; struct CommandTailwind; struct CommandWasmOpt; struct CommandSass; -struct CommandCargoGenerate; #[async_trait] impl Command for CommandTailwind { @@ -544,71 +531,6 @@ impl Command for CommandSass { } } -#[async_trait] -impl Command for CommandCargoGenerate { - fn name(&self) -> &'static str { - "cargo-generate" - } - fn default_version(&self) -> &'static str { - "v0.17.3" - } - fn env_var_version_name(&self) -> &'static str { - ENV_VAR_LEPTOS_CARGO_GENERATE_VERSION - } - fn github_owner(&self) -> &'static str { - "cargo-generate" - } - fn github_repo(&self) -> &'static str { - "cargo-generate" - } - - fn download_url(&self, target_os: &str, target_arch: &str, version: &str) -> Result { - let is_musl_env = is_linux_musl_env(); - - let target = if is_musl_env { - match (target_os, target_arch) { - ("linux", "aarch64") => "aarch64-unknown-linux-musl", - ("linux", "x86_64") => "x86_64-unknown-linux-musl", - _ => bail!("No cargo-generate tar binary found for linux-musl {target_arch}"), - } - } else { - match (target_os, target_arch) { - ("macos", "aarch64") => "aarch64-apple-darwin", - ("linux", "aarch64") => "aarch64-unknown-linux-gnu", - ("macos", "x86_64") => "x86_64-apple-darwin", - ("windows", "x86_64") => "x86_64-pc-windows-msvc", - ("linux", "x86_64") => "x86_64-unknown-linux-gnu", - _ => bail!("No cargo-generate tar binary found for {target_os} {target_arch}"), - } - }; - - Ok(format!( - "https://github.com/{}/{}/releases/download/{}/cargo-generate-{}-{}.tar.gz", - self.github_owner(), - self.github_repo(), - version, - version, - target - )) - } - - fn executable_name( - &self, - target_os: &str, - _target_arch: &str, - _version: Option<&str>, - ) -> Result { - Ok(match target_os { - "windows" => "cargo-generate.exe".to_string(), - _ => "cargo-generate".to_string(), - }) - } - - fn manual_install_instructions(&self) -> String { - "Try manually installing cargo-generate: https://github.com/cargo-generate/cargo-generate#installation".to_string() - } -} - #[async_trait] /// Template trait, implementors should only fill in /// the command-specific logic. Handles caching, latest diff --git a/src/ext/tests.rs b/src/ext/tests.rs index 6d059fc4..f1a3ee0b 100644 --- a/src/ext/tests.rs +++ b/src/ext/tests.rs @@ -26,18 +26,6 @@ async fn download_tailwind() { assert!(e.exists(), "{:#?}\nFiles: \n{}", meta, ls(&dir)) } -#[tokio::test] -async fn download_cargo_generate() { - let dir = TempDir::new().unwrap(); - let meta = Exe::CargoGenerate.meta().await.unwrap(); - let e = meta.with_cache_dir(dir.path()).await; - - assert!(e.is_ok(), "{e:#?}\n{:#?}\nFiles: \n {}", meta, ls(&dir)); - - let e = e.unwrap(); - assert!(e.exists(), "{:#?}\nFiles: \n{}", meta, ls(&dir)); -} - #[tokio::test] async fn download_wasmopt() { let dir = TempDir::new().unwrap(); diff --git a/src/lib.rs b/src/lib.rs index f2888051..4e25765f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -24,8 +24,8 @@ pub async fn run(args: Cli) -> Result<()> { let verbose = args.opts().map(|o| o.verbose).unwrap_or(0); logger::setup(verbose, &args.log); - if let New(new) = &args.command { - return new.run().await; + if let New(new) = args.command { + return new.run(); } let manifest_path = args From aa78d85b653979a104302c136c729a89baeb552e Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Sun, 2 Feb 2025 21:59:30 -0500 Subject: [PATCH 2/8] Handle wasm-opt with library instead of binary --- Cargo.lock | 173 +++++++++++++++++++++++++++++++++++++++++- Cargo.toml | 1 + README.md | 3 +- src/compile/front.rs | 24 ++---- src/config/dotenvs.rs | 1 - src/ext/exe.rs | 76 ------------------- src/ext/tests.rs | 12 --- 7 files changed, 178 insertions(+), 112 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6c206fe4..ebad4ac9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -520,7 +520,7 @@ dependencies = [ "fs-err", "git2", "gix-config", - "heck", + "heck 0.5.0", "home", "ignore", "indexmap 2.7.1", @@ -589,6 +589,7 @@ dependencies = [ "temp-dir", "tokio", "wasm-bindgen-cli-support", + "wasm-opt", "which", "zip", ] @@ -697,7 +698,7 @@ version = "4.5.24" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54b755194d6389280185988721fffba69495eed5ee9feeee9a599b53db80318c" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.96", @@ -709,6 +710,16 @@ version = "0.7.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f46ad14479a25103f283c0f10005961cf086d8dc42205bb44c46ac563475dca6" +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width 0.1.14", +] + [[package]] name = "colorchoice" version = "1.0.3" @@ -892,6 +903,65 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "cxx" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fc894913dccfed0f84106062c284fa021c3ba70cb1d78797d6f5165d4492e45" +dependencies = [ + "cc", + "cxxbridge-cmd", + "cxxbridge-flags", + "cxxbridge-macro", + "foldhash", + "link-cplusplus", +] + +[[package]] +name = "cxx-build" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "503b2bfb6b3e8ce7f95d865a67419451832083d3186958290cee6c53e39dfcfe" +dependencies = [ + "cc", + "codespan-reporting", + "proc-macro2", + "quote", + "scratch", + "syn 2.0.96", +] + +[[package]] +name = "cxxbridge-cmd" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0d2cb64a95b4b5a381971482235c4db2e0208302a962acdbe314db03cbbe2fb" +dependencies = [ + "clap", + "codespan-reporting", + "proc-macro2", + "quote", + "syn 2.0.96", +] + +[[package]] +name = "cxxbridge-flags" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f797b0206463c9c2a68ed605ab28892cca784f1ef066050f4942e3de26ad885" + +[[package]] +name = "cxxbridge-macro" +version = "1.0.137" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e79010a2093848e65a3e0f7062d3f02fb2ef27f866416dfe436fccfa73d3bb59" +dependencies = [ + "proc-macro2", + "quote", + "rustversion", + "syn 2.0.96", +] + [[package]] name = "darling" version = "0.20.10" @@ -1268,6 +1338,12 @@ version = "1.0.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" +[[package]] +name = "foldhash" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a0d2fde1f7b3d48b8395d5f2de76c18a528bd6a9cdde438df747bfcba3e05d6f" + [[package]] name = "form_urlencoded" version = "1.2.1" @@ -1702,6 +1778,12 @@ version = "0.15.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bf151400ff0baff5465007dd2f3e717f3fe502074ca563069ce3a6629d07b289" +[[package]] +name = "heck" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95505c38b4572b2d910cecb0281560f54b440a19336cbbcb27bf6ce6adc6f5a8" + [[package]] name = "heck" version = "0.5.0" @@ -2133,7 +2215,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1d57a3e447e24c22647738e4607f1df1e0ec6f72e16182c4cd199f647cdfb0e4" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.96", @@ -2416,6 +2498,15 @@ dependencies = [ "syn 1.0.109", ] +[[package]] +name = "link-cplusplus" +version = "1.0.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9d240c6f7e1ba3a28b0249f774e6a9dd0175054b52dfbb61b16eb8505c3785c9" +dependencies = [ + "cc", +] + [[package]] name = "linked-hash-map" version = "0.5.6" @@ -3665,6 +3756,12 @@ version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" +[[package]] +name = "scratch" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a3cf7c11c38cb994f3d40e8a8cde3bbd1f72a435e4c49e85d6553d8312306152" + [[package]] name = "seahash" version = "4.1.0" @@ -3992,6 +4089,25 @@ version = "0.11.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7da8b5736845d9f2fcb837ea5d9e2628564b3b043a70948a3f0b778838c5fb4f" +[[package]] +name = "strum" +version = "0.24.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "063e6045c0e62079840579a7e47a355ae92f60eb74daaf156fb1e84ba164e63f" + +[[package]] +name = "strum_macros" +version = "0.24.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59" +dependencies = [ + "heck 0.4.1", + "proc-macro2", + "quote", + "rustversion", + "syn 1.0.109", +] + [[package]] name = "subtle" version = "2.6.1" @@ -5041,6 +5157,15 @@ dependencies = [ "windows-sys 0.59.0", ] +[[package]] +name = "termcolor" +version = "1.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] + [[package]] name = "terminal-prompt" version = "0.2.3" @@ -5547,7 +5672,7 @@ version = "0.22.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "439ad39ff894c43c9649fa724cdde9a6fc50b855d517ef071a93e5df82fe51d3" dependencies = [ - "heck", + "heck 0.5.0", "proc-macro2", "quote", "syn 2.0.96", @@ -5728,6 +5853,46 @@ dependencies = [ "leb128", ] +[[package]] +name = "wasm-opt" +version = "0.116.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2fd87a4c135535ffed86123b6fb0f0a5a0bc89e50416c942c5f0662c645f679c" +dependencies = [ + "anyhow", + "libc", + "strum", + "strum_macros", + "tempfile", + "thiserror 1.0.69", + "wasm-opt-cxx-sys", + "wasm-opt-sys", +] + +[[package]] +name = "wasm-opt-cxx-sys" +version = "0.116.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c57b28207aa724318fcec6575fe74803c23f6f266fce10cbc9f3f116762f12e" +dependencies = [ + "anyhow", + "cxx", + "cxx-build", + "wasm-opt-sys", +] + +[[package]] +name = "wasm-opt-sys" +version = "0.116.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a1cce564dc768dacbdb718fc29df2dba80bd21cb47d8f77ae7e3d95ceb98cbe" +dependencies = [ + "anyhow", + "cc", + "cxx", + "cxx-build", +] + [[package]] name = "wasmparser" version = "0.214.0" diff --git a/Cargo.toml b/Cargo.toml index 87abd2e1..20afcbb7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -89,6 +89,7 @@ swc = "10.0" swc_common = "5.0" shlex = "1.3.0" cargo-generate = "0.22" +wasm-opt = "0.116.1" [dev-dependencies] insta = { version = "1.40.0", features = ["yaml"] } diff --git a/README.md b/README.md index 4fd2a6ab..812b6d2e 100644 --- a/README.md +++ b/README.md @@ -64,7 +64,7 @@ For setting up your project, have a look at the [examples](https://github.com/le ## Dependencies -The dependencies for [sass](https://sass-lang.com/install) and [wasm-opt](https://github.com/WebAssembly/binaryen) are automatically installed in a cache directory when they are used if they are not already installed and found by [which](https://crates.io/crates/which). +The dependency for [sass](https://sass-lang.com/install) is automatically installed in a cache directory when they are used if they are not already installed and found by [which](https://crates.io/crates/which). Different versions of the dependencies might accumulate in this directory, so feel free to delete it. | OS | Example | @@ -334,7 +334,6 @@ override the versions `cargo-leptos` should use (e.g. `LEPTOS_SASS_VERSION=1.69. - LEPTOS_TAILWIND_VERSION - LEPTOS_SASS_VERSION -- LEPTOS_WASM_OPT_VERSION ## End-to-end testing diff --git a/src/compile/front.rs b/src/compile/front.rs index cfabec12..d759f883 100644 --- a/src/compile/front.rs +++ b/src/compile/front.rs @@ -4,12 +4,10 @@ use crate::ext::sync::{wait_interruptible, CommandResult}; use crate::ext::{fs, PathBufExt}; use crate::signal::{Interrupt, Outcome, Product}; use crate::{ - ext::{ - anyhow::{Context, Result}, - exe::Exe, - }, + ext::anyhow::{Context, Result}, logger::GRAY, }; +use anyhow::Ok; use camino::Utf8Path; use std::sync::Arc; use swc::config::IsModule; @@ -19,6 +17,7 @@ use swc_common::{FileName, SourceMap, GLOBALS}; use tokio::process::Child; use tokio::{process::Command, sync::broadcast, task::JoinHandle}; use wasm_bindgen_cli_support::Bindgen; +use wasm_opt::OptimizationOptions; pub async fn front( proj: &Arc, @@ -153,7 +152,7 @@ async fn bindgen(proj: &Project) -> Result> { .dot()?; if proj.release { - match optimize(&wasm_file.dest, interrupt).await.dot()? { + match optimize(&wasm_file.dest, interrupt).dot()? { CommandResult::Interrupted => return Ok(Outcome::Stopped), CommandResult::Failure(_) => return Ok(Outcome::Failed), _ => {} @@ -193,18 +192,9 @@ async fn bindgen(proj: &Project) -> Result> { Ok(Outcome::Success(Product::Front)) } -async fn optimize( - file: &Utf8Path, - interrupt: broadcast::Receiver<()>, -) -> Result> { - let wasm_opt = Exe::WasmOpt.get().await.dot()?; - - let args = [file.as_str(), "-Oz", "-o", file.as_str()]; - let process = Command::new(wasm_opt) - .args(args) - .spawn() - .context("Could not spawn command")?; - wait_interruptible("wasm-opt", process, interrupt).await +fn optimize(file: &Utf8Path, _interrupt: broadcast::Receiver<()>) -> Result> { + let _ = OptimizationOptions::new_optimize_for_size_aggressively().run(file, file)?; + Ok(CommandResult::Success(())) } fn minify>(js: JS) -> Result { diff --git a/src/config/dotenvs.rs b/src/config/dotenvs.rs index 4bd8e015..d0c4f729 100644 --- a/src/config/dotenvs.rs +++ b/src/config/dotenvs.rs @@ -61,7 +61,6 @@ fn overlay(conf: &mut ProjectConfig, envs: impl Iterator {} exe::ENV_VAR_LEPTOS_SASS_VERSION => {} - exe::ENV_VAR_LEPTOS_WASM_OPT_VERSION => {} _ if key.starts_with("LEPTOS_") => { log::warn!("Env {key} is not used by cargo-leptos") } diff --git a/src/ext/exe.rs b/src/ext/exe.rs index 4f256bd6..6e852e02 100644 --- a/src/ext/exe.rs +++ b/src/ext/exe.rs @@ -38,7 +38,6 @@ lazy_static::lazy_static! { pub const ENV_VAR_LEPTOS_TAILWIND_VERSION: &str = "LEPTOS_TAILWIND_VERSION"; pub const ENV_VAR_LEPTOS_SASS_VERSION: &str = "LEPTOS_SASS_VERSION"; -pub const ENV_VAR_LEPTOS_WASM_OPT_VERSION: &str = "LEPTOS_WASM_OPT_VERSION"; impl ExeMeta { #[allow(clippy::wrong_self_convention)] @@ -212,7 +211,6 @@ fn get_cache_dir() -> Result { #[derive(Debug, Hash, Eq, PartialEq)] pub enum Exe { Sass, - WasmOpt, Tailwind, } @@ -243,10 +241,6 @@ impl Exe { let exe = match self { Exe::Sass => CommandSass.exe_meta(target_os, target_arch).await.dot()?, - Exe::WasmOpt => CommandWasmOpt - .exe_meta(target_os, target_arch) - .await - .dot()?, Exe::Tailwind => CommandTailwind .exe_meta(target_os, target_arch) .await @@ -295,7 +289,6 @@ fn normalize_version(ver_string: &str) -> Option { use async_trait::async_trait; struct CommandTailwind; -struct CommandWasmOpt; struct CommandSass; #[async_trait] @@ -383,75 +376,6 @@ impl Command for CommandTailwind { } } -#[async_trait] -impl Command for CommandWasmOpt { - fn name(&self) -> &'static str { - "wasm-opt" - } - fn default_version(&self) -> &'static str { - "version_117" - } - fn env_var_version_name(&self) -> &'static str { - ENV_VAR_LEPTOS_WASM_OPT_VERSION - } - fn github_owner(&self) -> &'static str { - "WebAssembly" - } - fn github_repo(&self) -> &'static str { - "binaryen" - } - - fn download_url(&self, target_os: &str, target_arch: &str, version: &str) -> Result { - let target = match (target_os, target_arch) { - ("linux", "aarch64") => "aarch64-linux", - ("linux", "x86_64") => "x86_64-linux", - ("windows", _) => "x86_64-windows", - ("macos", "aarch64") => "arm64-macos", - ("macos", "x86_64") => "x86_64-macos", - _ => { - bail!("No wasm-opt tar binary found for {target_os} {target_arch}") - } - }; - - Ok(format!( - "https://github.com/{}/{}/releases/download/{}/binaryen-{}-{}.tar.gz", - self.github_owner(), - self.github_repo(), - version, - version, - target - )) - } - - fn executable_name( - &self, - target_os: &str, - _target_arch: &str, - version: Option<&str>, - ) -> Result { - if version.is_none() { - bail!("Version is required for WASM Opt, none provided") - }; - - Ok(match target_os { - "windows" => format!( - "binaryen-{}/bin/{}.exe", - version.unwrap_or_default(), - self.name() - ), - _ => format!( - "binaryen-{}/bin/{}", - version.unwrap_or_default(), - self.name() - ), - }) - } - - fn manual_install_instructions(&self) -> String { - "Try manually installing binaryen: https://github.com/WebAssembly/binaryen".to_string() - } -} - #[async_trait] impl Command for CommandSass { fn name(&self) -> &'static str { diff --git a/src/ext/tests.rs b/src/ext/tests.rs index f1a3ee0b..e8adf60f 100644 --- a/src/ext/tests.rs +++ b/src/ext/tests.rs @@ -26,18 +26,6 @@ async fn download_tailwind() { assert!(e.exists(), "{:#?}\nFiles: \n{}", meta, ls(&dir)) } -#[tokio::test] -async fn download_wasmopt() { - let dir = TempDir::new().unwrap(); - let meta = Exe::WasmOpt.meta().await.unwrap(); - let e = meta.with_cache_dir(dir.path()).await; - - assert!(e.is_ok(), "{e:#?}\n{:#?}\nFiles: \n {}", meta, ls(&dir)); - - let e = e.unwrap(); - assert!(e.exists(), "{:#?}\nFiles: \n{}", meta, ls(&dir)); -} - fn ls(dir: &TempDir) -> String { Utf8PathBuf::from_path_buf(dir.path().to_path_buf()) .unwrap() From e6f7cc57aa6c8c42b786d36280d5bfbd9f484952 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Sun, 2 Feb 2025 22:52:35 -0500 Subject: [PATCH 3/8] Clippy --- Cargo.toml | 2 +- src/compile/front.rs | 16 ++++++---------- src/compile/tailwind.rs | 2 +- src/ext/exe.rs | 2 +- 4 files changed, 9 insertions(+), 13 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 20afcbb7..a0d7c9fd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,7 +31,7 @@ categories = ["development-tools", "wasm", "web-programming"] keywords = ["leptos"] version = "0.2.27" edition = "2021" -rust-version = "1.71" +rust-version = "1.82.0" authors = ["Henrik Akesson", "Greg Johnston", "Ben Wishovich"] [package.metadata.wix] diff --git a/src/compile/front.rs b/src/compile/front.rs index d759f883..3b27f840 100644 --- a/src/compile/front.rs +++ b/src/compile/front.rs @@ -15,7 +15,7 @@ use swc::JsMinifyExtras; use swc::{config::JsMinifyOptions, try_with_handler, BoolOrDataConfig}; use swc_common::{FileName, SourceMap, GLOBALS}; use tokio::process::Child; -use tokio::{process::Command, sync::broadcast, task::JoinHandle}; +use tokio::{process::Command, task::JoinHandle}; use wasm_bindgen_cli_support::Bindgen; use wasm_opt::OptimizationOptions; @@ -105,7 +105,6 @@ pub fn build_cargo_front_cmd( async fn bindgen(proj: &Project) -> Result> { let wasm_file = &proj.lib.wasm_file; - let interrupt = Interrupt::subscribe_any(); log::info!("Front generating JS/WASM with wasm-bindgen"); @@ -152,11 +151,7 @@ async fn bindgen(proj: &Project) -> Result> { .dot()?; if proj.release { - match optimize(&wasm_file.dest, interrupt).dot()? { - CommandResult::Interrupted => return Ok(Outcome::Stopped), - CommandResult::Failure(_) => return Ok(Outcome::Failed), - _ => {} - } + optimize(&wasm_file.dest)?; } let wasm_optimize_end_time = tokio::time::Instant::now(); @@ -192,9 +187,10 @@ async fn bindgen(proj: &Project) -> Result> { Ok(Outcome::Success(Product::Front)) } -fn optimize(file: &Utf8Path, _interrupt: broadcast::Receiver<()>) -> Result> { - let _ = OptimizationOptions::new_optimize_for_size_aggressively().run(file, file)?; - Ok(CommandResult::Success(())) +fn optimize(file: &Utf8Path) -> Result<()> { + OptimizationOptions::new_optimize_for_size_aggressively() + .run(file, file) + .dot() } fn minify>(js: JS) -> Result { diff --git a/src/compile/tailwind.rs b/src/compile/tailwind.rs index d3d18493..75cc3c2e 100644 --- a/src/compile/tailwind.rs +++ b/src/compile/tailwind.rs @@ -18,7 +18,7 @@ pub async fn compile_tailwind(proj: &Project, tw_conf: &TailwindConfig) -> Resul create_default_tailwind_config(tw_conf).await?; } - let (line, process) = tailwind_process(&proj, "tailwindcss", tw_conf).await?; + let (line, process) = tailwind_process(proj, "tailwindcss", tw_conf).await?; match wait_piped_interruptible("Tailwind", process, Interrupt::subscribe_any()).await? { CommandResult::Success(output) => { diff --git a/src/ext/exe.rs b/src/ext/exe.rs index 6e852e02..5f5b9691 100644 --- a/src/ext/exe.rs +++ b/src/ext/exe.rs @@ -74,7 +74,7 @@ pub struct ExeCache<'a> { meta: &'a ExeMeta, } -impl<'a> ExeCache<'a> { +impl ExeCache<'_> { fn exe_in_cache(&self) -> Result { let exe_path = self.exe_dir.join(PathBuf::from(&self.meta.exe)); From 6ed80ae601e854acd00c549d6dafc5868c357927 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Sun, 2 Feb 2025 23:34:45 -0500 Subject: [PATCH 4/8] Simplify version check --- src/ext/exe.rs | 55 +++++++++++++++++++++++++------------------------- 1 file changed, 27 insertions(+), 28 deletions(-) diff --git a/src/ext/exe.rs b/src/ext/exe.rs index 5f5b9691..2a1395d3 100644 --- a/src/ext/exe.rs +++ b/src/ext/exe.rs @@ -3,6 +3,7 @@ use crate::{ logger::GRAY, }; use bytes::Bytes; +use core::str; use std::{ fs::{self, File}, io::{Cursor, Write}, @@ -252,36 +253,40 @@ impl Exe { } /// Tailwind uses the 'vMaj.Min.Pat' format. -/// WASM opt uses 'version_NNN' format. /// We generally want to keep the suffix intact, /// as it carries classifiers, etc, but strip non-ascii /// digits from the prefix. #[inline] -fn sanitize_version_prefix(ver_string: &str) -> String { - ver_string - .chars() - .skip_while(|c| !c.is_ascii_digit() || *c == '_') - .collect::() +fn sanitize_version_prefix<'a>(ver_string: &'a str) -> Result<&'a str> { + if let [b'v', rest @ ..] = ver_string.as_bytes() { + str::from_utf8(rest).dot() + } else { + Ok(ver_string) + } } /// Attempts to convert a non-semver version string to a semver one. -/// E.g. WASM Opt uses `version_112`, which is not semver even if /// we strip the prefix, treat it as `112.0.0` fn normalize_version(ver_string: &str) -> Option { - let ver_string = sanitize_version_prefix(ver_string); - match Version::parse(&ver_string) { - Ok(v) => Some(v), - Err(_) => match &ver_string.parse::() { - Ok(num) => Some(Version::new(*num, 0, 0)), - Err(_) => match Version::parse(format!("{ver_string}.0").as_str()) { - Ok(v) => Some(v), - Err(e) => { - log::error!("Command failed to normalize version {ver_string}: {e}"); - None - } - }, - }, - } + sanitize_version_prefix(ver_string) + .ok() + .and_then(|ver_string| { + let version = Version::parse(ver_string) + .ok() + .or_else(|| { + ver_string + .parse::() + .map(|num| Version::new(num, 0, 0)) + .ok() + }) + .or_else(|| Version::parse(format!("{ver_string}.0").as_str()).ok()); + + if version.is_none() { + log::error!("Command failed to normalize version: {ver_string}"); + } + + version + }) } // fallback to this crate until rust stable includes async traits @@ -688,19 +693,13 @@ mod tests { #[test] fn test_sanitize_version_prefix() { - let version = sanitize_version_prefix("v1.2.3"); - assert_eq!(version, "1.2.3"); - assert!(Version::parse(&version).is_ok()); - let version = sanitize_version_prefix("version_1.2.3"); + let version = sanitize_version_prefix("v1.2.3").expect("Could not sanitize \"v1.2.3\"."); assert_eq!(version, "1.2.3"); assert!(Version::parse(&version).is_ok()); } #[test] fn test_normalize_version() { - let version = normalize_version("version_112"); - assert!(version.is_some_and(|v| { v.major == 112 && v.minor == 0 && v.patch == 0 })); - let version = normalize_version("v3.3.3"); assert!(version.is_some_and(|v| { v.major == 3 && v.minor == 3 && v.patch == 3 })); From 64b862cf97a0164006952bd213aae5172142993d Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Sun, 2 Feb 2025 23:58:33 -0500 Subject: [PATCH 5/8] Remove unnecessary clones from new command --- src/command/new.rs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/command/new.rs b/src/command/new.rs index 99d71875..5e3a05b4 100644 --- a/src/command/new.rs +++ b/src/command/new.rs @@ -49,18 +49,28 @@ pub struct NewCommand { impl NewCommand { pub fn run(self) -> Result<()> { + let Self { + git, + branch, + tag, + path, + name, + force, + verbose, + init, + } = self; let args = GenerateArgs { template_path: TemplatePath { - git: absolute_git_url(self.git), - branch: self.branch.clone(), - tag: self.tag.clone(), - path: self.path.clone(), + git: absolute_git_url(git), + branch, + tag, + path, ..Default::default() }, - name: self.name.clone(), - force: self.force, - verbose: self.verbose, - init: self.init, + name, + force, + verbose, + init, ..Default::default() }; From 3990ebac9b748eb2b87a4ca68375fe360ba527f7 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Sun, 2 Feb 2025 23:59:53 -0500 Subject: [PATCH 6/8] Use more appropriate panic for new command --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 4e25765f..57177642 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -72,11 +72,11 @@ pub async fn run(args: Cli) -> Result<()> { let _monitor = Interrupt::run_ctrl_c_monitor(); use Commands::{Build, EndToEnd, New, Serve, Test, Watch}; match args.command { - New(_) => panic!(), Build(_) => command::build_all(&config).await, Serve(_) => command::serve(&config.current_project()?).await, Test(_) => command::test_all(&config).await, EndToEnd(_) => command::end2end_all(&config).await, Watch(_) => command::watch(&config.current_project()?).await, + New(_) => unreachable!(), } } From fa057df985aa95109f4f716da612862846fcdc20 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Mon, 3 Feb 2025 00:02:23 -0500 Subject: [PATCH 7/8] Add unreachable message --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 57177642..b8ed560d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -77,6 +77,6 @@ pub async fn run(args: Cli) -> Result<()> { Test(_) => command::test_all(&config).await, EndToEnd(_) => command::end2end_all(&config).await, Watch(_) => command::watch(&config.current_project()?).await, - New(_) => unreachable!(), + New(_) => unreachable!(r#""new" command should have already been run"#), } } From 1a5b29538dd0f023f4334660d269fd67bd20d660 Mon Sep 17 00:00:00 2001 From: SleeplessOne1917 <28871516+SleeplessOne1917@users.noreply.github.com> Date: Mon, 10 Feb 2025 21:17:18 -0500 Subject: [PATCH 8/8] Use std instead of core to use str --- src/ext/exe.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ext/exe.rs b/src/ext/exe.rs index 2a1395d3..c9b1a027 100644 --- a/src/ext/exe.rs +++ b/src/ext/exe.rs @@ -3,11 +3,11 @@ use crate::{ logger::GRAY, }; use bytes::Bytes; -use core::str; use std::{ fs::{self, File}, io::{Cursor, Write}, path::{Path, PathBuf}, + str, sync::Once, };