diff --git a/.gitignore b/.gitignore index 6c5f6ef..c6038a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,8 @@ +/.vscode/ + /target -/dummy -/dummy2 -/proj \ No newline at end of file +choco/tools/grill.exe +*.nupkg + +/testing_cmd \ No newline at end of file diff --git a/Cargo.lock b/Cargo.lock index 9c3ce92..a23d83f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,6 +2,21 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "addr2line" +version = "0.17.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9ecd88a8c8378ca913a680cd98f0f13ac67383d35993f86c90a70e3f137816b" +dependencies = [ + "gimli", +] + +[[package]] +name = "adler" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" + [[package]] name = "aho-corasick" version = "0.7.18" @@ -13,9 +28,12 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.53" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "94a45b455c14666b85fc40a019e8ab9eb75e3a124e05494f5397122bc9eb06e0" +checksum = "bb07d2053ccdbe10e2af2995a2f116c1330396493dc1269f6a91d0ae82e19704" +dependencies = [ + "backtrace", +] [[package]] name = "atty" @@ -30,9 +48,24 @@ dependencies = [ [[package]] name = "autocfg" -version = "1.0.1" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "backtrace" +version = "0.3.66" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" +checksum = "cab84319d616cfb654d03394f38ab7e6f0919e181b1b57e1fd15e7fb4077d9a7" +dependencies = [ + "addr2line", + "cc", + "cfg-if", + "libc", + "miniz_oxide", + "object", + "rustc-demangle", +] [[package]] name = "base64" @@ -48,21 +81,21 @@ checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" [[package]] name = "bumpalo" -version = "3.8.0" +version = "3.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f1e260c3a9040a7c19a12468758f4c16f31a81a1fe087482be9570ec864bb6c" +checksum = "37ccbd214614c6783386c1af30caf03192f17891059cecc394b4fb119e363de3" [[package]] name = "bytes" -version = "1.1.0" +version = "1.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c4872d67bab6358e59559027aa3b9157c53d9358c51423c17554809a8858e0f8" +checksum = "f0b3de4a0c5e67e16066a0715723abd91edc2f9001d09c46e1dca929351e130e" [[package]] name = "cc" -version = "1.0.72" +version = "1.0.73" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "22a9137b95ea06864e018375b72adfb7db6e6f68cfc8df5a04d00288050485ee" +checksum = "2fff2a6927b3bb87f9595d67196a70493f627687a71d87a0d692242c33f58c11" dependencies = [ "jobserver", ] @@ -73,34 +106,31 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" -[[package]] -name = "chrono" -version = "0.4.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" -dependencies = [ - "libc", - "num-integer", - "num-traits", - "time", - "winapi", -] - [[package]] name = "clap" -version = "3.0.10" +version = "3.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a30c3bf9ff12dfe5dae53f0a96e0febcd18420d1c0e7fad77796d9d5c4b5375" +checksum = "44bbe24bbd31a185bc2c4f7c2abe80bea13a20d57ee4e55be70ac512bdc76417" dependencies = [ "atty", "bitflags", + "clap_lex", "indexmap", - "os_str_bytes", + "once_cell", "strsim", "termcolor", "textwrap", ] +[[package]] +name = "clap_lex" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5" +dependencies = [ + "os_str_bytes", +] + [[package]] name = "console" version = "0.15.0" @@ -118,9 +148,9 @@ dependencies = [ [[package]] name = "core-foundation" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6888e10551bb93e424d8df1d07f1a8b4fceb0001a3a4b048bfc47554946f47b3" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" dependencies = [ "core-foundation-sys", "libc", @@ -132,25 +162,13 @@ version = "0.8.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc" -[[package]] -name = "derivative" -version = "2.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcc3dd5e9e9c0b295d6e1e4d811fb6f157d5ffd784b8d202fc62eac8035a770b" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] - [[package]] name = "dialoguer" -version = "0.9.0" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61579ada4ec0c6031cfac3f86fdba0d195a7ebeb5e36693bd53cb5999a25beeb" +checksum = "a92e7e37ecef6857fdc0c0c5d42fd5b0938e46590c2183cc92dd310a6d078eb1" dependencies = [ "console", - "lazy_static", "tempfile", "zeroize", ] @@ -166,9 +184,9 @@ dependencies = [ [[package]] name = "dirs-sys" -version = "0.3.6" +version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03d86534ed367a67548dc68113a0f5db55432fdfbb6e6f9d77704397d95d5780" +checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6" dependencies = [ "libc", "redox_users", @@ -177,9 +195,9 @@ dependencies = [ [[package]] name = "either" -version = "1.6.1" +version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e78d4f1cc4ae33bbfc157ed5d5a5ef3bc29227303d595861deb238fcec4e9457" +checksum = "90e5c1c8368803113bf0c9584fc495a58b86dc8a29edbf8fe877d21d9507e797" [[package]] name = "encode_unicode" @@ -189,9 +207,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.30" +version = "0.8.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7896dc8abb250ffdda33912550faa54c88ec8b998dec0b2c55ab224921ce11df" +checksum = "9852635589dc9f9ea1b6fe9f05b50ef208c85c834a562f0c6abb1c475736ec2b" dependencies = [ "cfg-if", ] @@ -209,6 +227,15 @@ dependencies = [ "termcolor", ] +[[package]] +name = "fastrand" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a407cfaa3385c4ae6b23e84623d48c2798d06e3e6a1878f7f59f17b3f86499" +dependencies = [ + "instant", +] + [[package]] name = "fnv" version = "1.0.7" @@ -242,42 +269,42 @@ dependencies = [ [[package]] name = "futures-channel" -version = "0.3.18" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fc8cd39e3dbf865f7340dce6a2d401d24fd37c6fe6c4f0ee0de8bfca2252d27" +checksum = "c3083ce4b914124575708913bca19bfe887522d6e2e6d0952943f5eac4a74010" dependencies = [ "futures-core", ] [[package]] name = "futures-core" -version = "0.3.18" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "629316e42fe7c2a0b9a65b47d159ceaa5453ab14e8f0a3c5eedbb8cd55b4a445" +checksum = "0c09fd04b7e4073ac7156a9539b57a484a8ea920f79c7c675d05d289ab6110d3" [[package]] name = "futures-io" -version = "0.3.19" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1f9d34af5a1aac6fb380f735fe510746c38067c5bf16c7fd250280503c971b2" +checksum = "fc4045962a5a5e935ee2fdedaa4e08284547402885ab326734432bed5d12966b" [[package]] name = "futures-sink" -version = "0.3.18" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "996c6442437b62d21a32cd9906f9c41e7dc1e19a9579843fad948696769305af" +checksum = "21163e139fa306126e6eedaf49ecdb4588f939600f0b1e770f4205ee4b7fa868" [[package]] name = "futures-task" -version = "0.3.18" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dabf1872aaab32c886832f2276d2f5399887e2bd613698a02359e4ea83f8de12" +checksum = "57c66a976bf5909d801bbef33416c41372779507e7a6b3a5e25e4749c58f776a" [[package]] name = "futures-util" -version = "0.3.18" +version = "0.3.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41d22213122356472061ac0f1ab2cee28d2bac8491410fd68c2af53d1cedb83e" +checksum = "d8b7abd5d659d9b90c8cba917f6ec750a74e2dc23902ef9cd4cc8c8b22e6036a" dependencies = [ "futures-core", "futures-io", @@ -290,20 +317,26 @@ dependencies = [ [[package]] name = "getrandom" -version = "0.2.3" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7fcd999463524c52659517fe2cea98493cfe485d10565e7b0fb07dbba7ad2753" +checksum = "4eb1a864a501629691edf6c15a593b7a51eebaa1e8468e9ddc623de7c9b58ec6" dependencies = [ "cfg-if", "libc", "wasi", ] +[[package]] +name = "gimli" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22030e2c5a68ec659fde1e949a745124b48e6fa8b045b7ed5bd1fe4ccc5c4e5d" + [[package]] name = "git2" -version = "0.13.25" +version = "0.15.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f29229cc1b24c0e6062f6e742aa3e256492a5323365e5ed3413599f8a5eff7d6" +checksum = "2994bee4a3a6a51eb90c218523be382fd7ea09b16380b9312e9dbe955ff7c7d1" dependencies = [ "bitflags", "libc", @@ -321,14 +354,14 @@ dependencies = [ "anyhow", "clap", "console", - "derivative", "dialoguer", "dirs", + "either", "env_logger", "git2", - "indexmap", "indicatif", "itertools", + "lazy_static", "log", "maplit", "multi_log", @@ -344,9 +377,9 @@ dependencies = [ [[package]] name = "h2" -version = "0.3.10" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c9de88456263e249e241fcd211d3954e2c9b0ef7ccfc235a444eb367cae3689" +checksum = "37a82c6d637fc9515a4694bbf1cb2457b79d81ce52b3108bdeea58b07dd34a57" dependencies = [ "bytes", "fnv", @@ -363,9 +396,9 @@ dependencies = [ [[package]] name = "hashbrown" -version = "0.11.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] name = "hermit-abi" @@ -378,20 +411,20 @@ dependencies = [ [[package]] name = "http" -version = "0.2.5" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" +checksum = "75f43d41e26995c17e71ee126451dd3941010b0514a81a9d11f3b341debc2399" dependencies = [ "bytes", "fnv", - "itoa 0.4.8", + "itoa", ] [[package]] name = "http-body" -version = "0.4.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1ff4f84919677303da5f147645dbea6b1881f368d03ac84e1dc09031ebd7b2c6" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" dependencies = [ "bytes", "http", @@ -400,9 +433,9 @@ dependencies = [ [[package]] name = "httparse" -version = "1.5.1" +version = "1.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "acd94fdbe1d4ff688b67b04eee2e17bd50995534a61539e45adfefb45e5e5503" +checksum = "496ce29bb5a52785b44e0f7ca2847ae0bb839c9bd28f69acac9b99d461c0c04c" [[package]] name = "httpdate" @@ -418,9 +451,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "hyper" -version = "0.14.16" +version = "0.14.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b7ec3e62bdc98a2f0393a5048e4c30ef659440ea6e0e572965103e72bd836f55" +checksum = "02c929dc5c39e335a03c405292728118860721b10190d98c2a0f0efd5baafbac" dependencies = [ "bytes", "futures-channel", @@ -431,7 +464,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa 0.4.8", + "itoa", "pin-project-lite", "socket2", "tokio", @@ -466,9 +499,9 @@ dependencies = [ [[package]] name = "indexmap" -version = "1.8.0" +version = "1.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "282a6247722caba404c065016bbfa522806e51714c34f5dfc3e4a3a46fcb4223" +checksum = "10a35a97730320ffe8e2d410b5d3b69279b98d2c14bdb8b70ea89ecf7888d41e" dependencies = [ "autocfg", "hashbrown", @@ -476,21 +509,29 @@ dependencies = [ [[package]] name = "indicatif" -version = "0.17.0-beta.1" +version = "0.17.0-rc.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "500f7e5a63596852b9bf7583fe86f9ad08e0df9b4eb58d12e9729071cb4952ca" +checksum = "4017d0ce94b8e91e29d2c78ed891e57e5ec3dc4371820a9d96abab4af09eb8ad" dependencies = [ "console", - "lazy_static", "number_prefix", - "regex", + "unicode-width", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", ] [[package]] name = "ipnet" -version = "2.3.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68f2d64f2edebec4ce84ad108148e67e1064789bee435edc5b60ad398714a3a9" +checksum = "879d54834c8c76457ef4293a689b2a8c59b076067ad77b15efafbb05f92a592b" [[package]] name = "itertools" @@ -503,15 +544,9 @@ dependencies = [ [[package]] name = "itoa" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" - -[[package]] -name = "itoa" -version = "1.0.1" +version = "1.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" +checksum = "112c678d4050afce233f4f2852bb2eb519230b3cf12f33585275537d7e41578d" [[package]] name = "jobserver" @@ -524,9 +559,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.55" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7cc9ffccd38c451a86bf13657df244e9c3f37493cce8e5e21e940963777acc84" +checksum = "258451ab10b34f8af53416d1fdab72c22e805f0c92a1136d59470ec0b11138b2" dependencies = [ "wasm-bindgen", ] @@ -539,15 +574,15 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.111" +version = "0.2.126" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e167738f1866a7ec625567bae89ca0d44477232a4f7c52b1c7f2adc2c98804f" +checksum = "349d5a591cd28b49e1d1037471617a32ddcda5731b99419008085f72d5a53836" [[package]] name = "libgit2-sys" -version = "0.12.26+1.3.0" +version = "0.14.0+1.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e1c899248e606fbfe68dcb31d8b0176ebab833b103824af31bddf4b7457494" +checksum = "47a00859c70c8a4f7218e6d1cc32875c4b55f6799445b842b0d8ed5e4c3d959b" dependencies = [ "cc", "libc", @@ -573,9 +608,9 @@ dependencies = [ [[package]] name = "libz-sys" -version = "1.1.3" +version = "1.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "de5435b8549c16d423ed0c03dbaafe57cf6c3344744f1242520d59c9d8ecec66" +checksum = "9702761c3935f8cc2f101793272e202c72b99da8f4224a19ddcf1279a6450bbf" dependencies = [ "cc", "libc", @@ -585,9 +620,9 @@ dependencies = [ [[package]] name = "log" -version = "0.4.14" +version = "0.4.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "51b9bbe6c47d51fc3e1a9b945965946b4c44142ab8792c50835a980d362c2710" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" dependencies = [ "cfg-if", ] @@ -606,9 +641,9 @@ checksum = "a3e378b66a060d48947b590737b30a1be76706c8dd7b8ba0f2fe3989c68a853f" [[package]] name = "memchr" -version = "2.4.1" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "308cc39be01b73d0d18f82a0e7b2a3df85245f84af96fdddc5d202d27e47b86a" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" [[package]] name = "mime" @@ -617,25 +652,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2a60c7ce501c71e03a9c9c0d35b861413ae925bd979cc7a4e30d060069aaac8d" [[package]] -name = "mio" -version = "0.7.14" +name = "miniz_oxide" +version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8067b404fe97c70829f082dec8bcf4f71225d7eaea1d8645349cb76fa06205cc" +checksum = "6f5c75688da582b8ffc1f1799e9db273f32133c49e048f614d22ec3256773ccc" dependencies = [ - "libc", - "log", - "miow", - "ntapi", - "winapi", + "adler", ] [[package]] -name = "miow" -version = "0.3.7" +name = "mio" +version = "0.8.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" +checksum = "57ee1c23c7c63b0c9250c339ffdc69255f110b298b901b9f6c82547b7b87caaf" dependencies = [ - "winapi", + "libc", + "log", + "wasi", + "windows-sys", ] [[package]] @@ -649,9 +683,9 @@ dependencies = [ [[package]] name = "native-tls" -version = "0.2.8" +version = "0.2.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48ba9f7719b5a0f42f338907614285fb5fd70e53858141f69898a1fb7203b24d" +checksum = "fd7e2f3618557f980e0b17e8856252eee3c97fa12c54dff0ca290fb6266ca4a9" dependencies = [ "lazy_static", "libc", @@ -666,80 +700,82 @@ dependencies = [ ] [[package]] -name = "ntapi" -version = "0.3.6" +name = "num_cpus" +version = "1.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" +checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" dependencies = [ - "winapi", + "hermit-abi", + "libc", ] [[package]] -name = "num-integer" -version = "0.1.44" +name = "num_threads" +version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +checksum = "2819ce041d2ee131036f4fc9d6ae7ae125a3a40e97ba64d04fe799ad9dabbb44" dependencies = [ - "autocfg", - "num-traits", + "libc", ] [[package]] -name = "num-traits" -version = "0.2.14" +name = "number_prefix" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" -dependencies = [ - "autocfg", -] +checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" [[package]] -name = "num_cpus" -version = "1.13.1" +name = "object" +version = "0.29.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "19e64526ebdee182341572e50e9ad03965aa510cd94427a4549448f285e957a1" +checksum = "21158b2c33aa6d4561f1c0a6ea283ca92bc54802a93b263e910746d679a7eb53" dependencies = [ - "hermit-abi", - "libc", + "memchr", ] -[[package]] -name = "number_prefix" -version = "0.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830b246a0e5f20af87141b25c173cd1b609bd7779a4617d6ec582abaf90870f3" - [[package]] name = "once_cell" -version = "1.8.0" +version = "1.13.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "692fcb63b64b1758029e0a96ee63e049ce8c5948587f2f7208df04625e5f6b56" +checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1" [[package]] name = "openssl" -version = "0.10.38" +version = "0.10.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0c7ae222234c30df141154f159066c5093ff73b63204dcda7121eb082fc56a95" +checksum = "618febf65336490dfcf20b73f885f5651a0c89c64c2d4a8c3662585a70bf5bd0" dependencies = [ "bitflags", "cfg-if", "foreign-types", "libc", "once_cell", + "openssl-macros", "openssl-sys", ] +[[package]] +name = "openssl-macros" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b501e44f11665960c7e7fcf062c7d96a14ade4aa98116c004b2e37b5be7d736c" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] + [[package]] name = "openssl-probe" -version = "0.1.4" +version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "28988d872ab76095a6e6ac88d99b54fd267702734fd7ffe610ca27f533ddb95a" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" [[package]] name = "openssl-sys" -version = "0.9.72" +version = "0.9.75" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7e46109c383602735fa0a2e48dd2b7c892b048e1bf69e5c3b1d804b7d9c203cb" +checksum = "e5f9bd0c2710541a3cda73d6f9ac4f1b240de4ae261065d309dbe73d9dceb42f" dependencies = [ "autocfg", "cc", @@ -750,12 +786,9 @@ dependencies = [ [[package]] name = "os_str_bytes" -version = "6.0.0" +version = "6.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64" -dependencies = [ - "memchr", -] +checksum = "648001efe5d5c0102d8cea768e348da85d90af8ba91f0bea908f157951493cd4" [[package]] name = "percent-encoding" @@ -765,9 +798,9 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e" [[package]] name = "pin-project-lite" -version = "0.2.7" +version = "0.2.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d31d11c69a6b52a174b42bdc0c30e5e11670f90788b2c471c31c1d17d449443" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" [[package]] name = "pin-utils" @@ -777,107 +810,62 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "pkg-config" -version = "0.3.24" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58893f751c9b0412871a09abd62ecd2a00298c6c83befa223ef98c52aef40cbe" - -[[package]] -name = "ppv-lite86" -version = "0.2.15" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ed0cfbc8191465bed66e1718596ee0b0b35d5ee1f41c5df2189d0fe8bde535ba" +checksum = "1df8c4ec4b0627e53bdf214615ad287367e482558cf84b109250b37464dc03ae" [[package]] name = "proc-macro2" -version = "1.0.33" +version = "1.0.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb37d2df5df740e582f28f8560cf425f52bb267d872fe58358eadb554909f07a" +checksum = "c278e965f1d8cf32d6e0e96de3d3e79712178ae67986d9cf9151f51e95aac89b" dependencies = [ - "unicode-xid", + "unicode-ident", ] [[package]] name = "psm" -version = "0.1.16" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cd136ff4382c4753fc061cb9e4712ab2af263376b95bbd5bd8cd50c020b78e69" +checksum = "f446d0a6efba22928558c4fb4ce0b3fd6c89b0061343e390bf01a703742b8125" dependencies = [ "cc", ] [[package]] name = "quote" -version = "1.0.10" +version = "1.0.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" +checksum = "3bcdf212e9776fbcb2d23ab029360416bb1706b1aea2d1a5ba002727cbcab804" dependencies = [ "proc-macro2", ] -[[package]] -name = "rand" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e7573632e6454cf6b99d7aac4ccca54be06da05aca2ef7423d22d27d4d4bcd8" -dependencies = [ - "libc", - "rand_chacha", - "rand_core", - "rand_hc", -] - -[[package]] -name = "rand_chacha" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88" -dependencies = [ - "ppv-lite86", - "rand_core", -] - -[[package]] -name = "rand_core" -version = "0.6.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34f1408f55294453790c48b2f1ebbb1c5b4b7563eb1f418bcfcfdbb06ebb4e7" -dependencies = [ - "getrandom", -] - -[[package]] -name = "rand_hc" -version = "0.3.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d51e9f596de227fda2ea6c84607f5558e196eeaf43c986b724ba4fb8fdf497e7" -dependencies = [ - "rand_core", -] - [[package]] name = "redox_syscall" -version = "0.2.10" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8383f39639269cde97d255a32bdb68c047337295414940c68bdd30c2e13203ff" +checksum = "534cfe58d6a18cc17120fbf4635d53d14691c1fe4d951064df9bd326178d7d5a" dependencies = [ "bitflags", ] [[package]] name = "redox_users" -version = "0.4.0" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "528532f3d801c87aec9def2add9ca802fe569e44a544afe633765267840abe64" +checksum = "b033d837a7cf162d7993aded9304e30a83213c648b6e389db233191f891e5c2b" dependencies = [ "getrandom", "redox_syscall", + "thiserror", ] [[package]] name = "regex" -version = "1.5.4" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d07a8629359eb56f1e2fb1652bb04212c072a87ba68546a04065d525673ac461" +checksum = "4c4eb3267174b8c6c2f654116623910a0fef09c4753f8dd83db29c48a0df988b" dependencies = [ "aho-corasick", "memchr", @@ -886,9 +874,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.6.25" +version = "0.6.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b" +checksum = "a3f87b73ce11b1619a3c6332f45341e0047173771e8b8b73f87bfeefb7b56244" [[package]] name = "remove_dir_all" @@ -901,9 +889,9 @@ dependencies = [ [[package]] name = "reqwest" -version = "0.11.9" +version = "0.11.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87f242f1488a539a79bac6dbe7c8609ae43b7914b7736210f239a37cccb32525" +checksum = "b75aa69a3f06bbcc66ede33af2af253c6f7a86b1ca0033f60c580a27074fbf92" dependencies = [ "base64", "bytes", @@ -928,6 +916,7 @@ dependencies = [ "serde_urlencoded", "tokio", "tokio-native-tls", + "tower-service", "url", "wasm-bindgen", "wasm-bindgen-futures", @@ -937,34 +926,40 @@ dependencies = [ [[package]] name = "rm_rf" -version = "0.6.1" +version = "0.6.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b76a2cc4e96dea40afd3a45baf51a2e36a1f8bf61405cf88a2b15367f68c658" +checksum = "3443b7a35aa12ed2e99edfc0ecbefe6a53b4848305cc83e29981dfa1aea1f71e" dependencies = [ "stacker", ] +[[package]] +name = "rustc-demangle" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7ef03e0a2b150c7a90d01faf6254c9c48a41e95fb2a8c2ac1c6f0d2b9aefc342" + [[package]] name = "ryu" -version = "1.0.9" +version = "1.0.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73b4b750c782965c211b42f022f59af1fbceabdd026623714f104152f1ec149f" +checksum = "f3f6f92acf49d1b98f7a81226834412ada05458b7364277387724a237f062695" [[package]] name = "schannel" -version = "0.1.19" +version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" +checksum = "88d6731146462ea25d9244b2ed5fd1d716d25c52e4d54aa4fb0f3c4e9854dbe2" dependencies = [ "lazy_static", - "winapi", + "windows-sys", ] [[package]] name = "security-framework" -version = "2.4.2" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "525bc1abfda2e1998d152c45cf13e696f76d0a4972310b22fac1658b05df7c87" +checksum = "2dc14f172faf8a0194a3aded622712b0de276821addc574fa54fc0a1167e10dc" dependencies = [ "bitflags", "core-foundation", @@ -975,9 +970,9 @@ dependencies = [ [[package]] name = "security-framework-sys" -version = "2.4.2" +version = "2.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a9dd14d83160b528b7bfd66439110573efcfbe281b17fc2ca9f39f550d619c7e" +checksum = "0160a13a177a45bfb43ce71c01580998474f556ad854dcbca936dd2841a5c556" dependencies = [ "core-foundation-sys", "libc", @@ -985,27 +980,27 @@ dependencies = [ [[package]] name = "semver" -version = "1.0.4" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" +checksum = "a2333e6df6d6598f2b1974829f853c2b4c5f4a6e503c10af918081aa6f8564e1" dependencies = [ "serde", ] [[package]] name = "serde" -version = "1.0.135" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2cf9235533494ea2ddcdb794665461814781c53f19d87b76e571a1c35acbad2b" +checksum = "fc855a42c7967b7c369eb5860f7164ef1f6f81c20c7cc1141f2a604e18723b03" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.135" +version = "1.0.140" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8dcde03d87d4c973c04be249e7d8f0b35db1c848c487bd43032808e59dd8328d" +checksum = "6f2122636b9fe3b81f1cb25099fcf2d3f542cdb1d45940d56c713158884a05da" dependencies = [ "proc-macro2", "quote", @@ -1014,49 +1009,52 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.78" +version = "1.0.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d23c1ba4cf0efd44be32017709280b32d1cea5c3f1275c3b6d9e8bc54f758085" +checksum = "82c2c1fdcd807d1098552c5b9a36e425e42e9fbd7c6a37a8425f390f781f7fa7" dependencies = [ - "itoa 1.0.1", + "itoa", "ryu", "serde", ] [[package]] name = "serde_urlencoded" -version = "0.7.0" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" dependencies = [ "form_urlencoded", - "itoa 0.4.8", + "itoa", "ryu", "serde", ] [[package]] name = "simplelog" -version = "0.11.2" +version = "0.12.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c1348164456f72ca0116e4538bdaabb0ddb622c7d9f16387c725af3e96d6001c" +checksum = "48dfff04aade74dd495b007c831cd6f4e0cee19c344dd9dc0884c0289b70a786" dependencies = [ - "chrono", "log", "termcolor", + "time", ] [[package]] name = "slab" -version = "0.4.5" +version = "0.4.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9def91fd1e018fe007022791f865d0ccc9b3a0d5001e01aabb8b40e46000afb5" +checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +dependencies = [ + "autocfg", +] [[package]] name = "socket2" -version = "0.4.2" +version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5dc90fe6c7be1a323296982db1836d1ea9e47b6839496dde9a541bc496df3516" +checksum = "66d72b759436ae32898a2af0a14218dbf55efde3feeb170eb623637db85ee1e0" dependencies = [ "libc", "winapi", @@ -1064,9 +1062,9 @@ dependencies = [ [[package]] name = "stacker" -version = "0.1.14" +version = "0.1.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "90939d5171a4420b3ff5fbc8954d641e7377335454c259dcb80786f3f21dc9b4" +checksum = "c886bd4480155fd3ef527d45e9ac8dd7118a898a46530b7b94c3e21866259fce" dependencies = [ "cc", "cfg-if", @@ -1083,24 +1081,24 @@ checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" [[package]] name = "syn" -version = "1.0.82" +version = "1.0.98" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8daf5dd0bb60cbd4137b1b587d2fc0ae729bc07cf01cd70b36a1ed5ade3b9d59" +checksum = "c50aef8a904de4c23c788f104b7dddc7d6f79c647c7c8ce4cc8f73eb0ca773dd" dependencies = [ "proc-macro2", "quote", - "unicode-xid", + "unicode-ident", ] [[package]] name = "tempfile" -version = "3.2.0" +version = "3.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dac1c663cfc93810f88aed9b8941d48cabf856a1b111c29a40439018d870eb22" +checksum = "5cdb1ef4eaeeaddc8fbd371e5017057064af0911902ef36b39801f67cc6d79e4" dependencies = [ "cfg-if", + "fastrand", "libc", - "rand", "redox_syscall", "remove_dir_all", "winapi", @@ -1108,9 +1106,9 @@ dependencies = [ [[package]] name = "termcolor" -version = "1.1.2" +version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dfed899f0eb03f32ee8c6a0aabdb8a7949659e3466561fc0adf54e26d88c5f4" +checksum = "bab24d30b911b2376f3a13cc2cd443142f0c81dda04c118693e35b3835757755" dependencies = [ "winapi-util", ] @@ -1127,25 +1125,53 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.14.2" +version = "0.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb" + +[[package]] +name = "thiserror" +version = "1.0.31" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0066c8d12af8b5acd21e00547c3797fde4e8677254a7ee429176ccebbe93dd80" +checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a" +dependencies = [ + "thiserror-impl", +] + +[[package]] +name = "thiserror-impl" +version = "1.0.31" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a" +dependencies = [ + "proc-macro2", + "quote", + "syn", +] [[package]] name = "time" -version = "0.1.43" +version = "0.3.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ca8a50ef2360fbd1eeb0ecd46795a87a19024eb4b53c5dc916ca1fd95fe62438" +checksum = "db76ff9fa4b1458b3c7f077f3ff9887394058460d21e634355b273aaf11eea45" dependencies = [ + "itoa", "libc", - "winapi", + "num_threads", + "time-macros", ] +[[package]] +name = "time-macros" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42657b1a6f4d817cda8e7a0ace261fe0cc946cf3a80314390b22cc61ae080792" + [[package]] name = "tinyvec" -version = "1.5.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c1c1d5a42b6245520c249549ec267180beaffcc0615401ac8e31853d4b6d8d2" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" dependencies = [ "tinyvec_macros", ] @@ -1158,9 +1184,9 @@ checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" [[package]] name = "tokio" -version = "1.14.0" +version = "1.20.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70e992e41e0d2fb9f755b37446f20900f64446ef54874f40a60c78f021ac6144" +checksum = "7a8325f63a7d4774dd041e363b2409ed1c5cbbd0f867795e661df066b2b0a581" dependencies = [ "autocfg", "bytes", @@ -1168,7 +1194,9 @@ dependencies = [ "memchr", "mio", "num_cpus", + "once_cell", "pin-project-lite", + "socket2", "winapi", ] @@ -1184,38 +1212,38 @@ dependencies = [ [[package]] name = "tokio-util" -version = "0.6.9" +version = "0.7.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e99e1983e5d376cd8eb4b66604d2e99e79f5bd988c3055891dcd8c9e2604cc0" +checksum = "cc463cd8deddc3770d20f9852143d50bf6094e640b485cb2e189a2099085ff45" dependencies = [ "bytes", "futures-core", "futures-sink", - "log", "pin-project-lite", "tokio", + "tracing", ] [[package]] name = "toml" -version = "0.5.8" +version = "0.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a31142970826733df8241ef35dc040ef98c679ab14d7c3e54d827099b3acecaa" +checksum = "8d82e1a7758622a465f8cee077614c73484dac5b836c02ff6a40d5d1010324d7" dependencies = [ "serde", ] [[package]] name = "tower-service" -version = "0.3.1" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "360dfd1d6d30e05fda32ace2c8c70e9c0a9da713275777f5a4dbb8a1893930c6" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" [[package]] name = "tracing" -version = "0.1.29" +version = "0.1.35" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "375a639232caf30edfc78e8d89b2d4c375515393e7af7e16f01cd96917fb2105" +checksum = "a400e31aa60b9d44a52a8ee0343b5b18566b03a8321e0d321f695cf56e940160" dependencies = [ "cfg-if", "pin-project-lite", @@ -1224,11 +1252,11 @@ dependencies = [ [[package]] name = "tracing-core" -version = "0.1.21" +version = "0.1.28" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f4ed65637b8390770814083d20756f87bfa2c21bf2f110babdc5438351746e4" +checksum = "7b7358be39f2f274f322d2aaed611acc57f382e8eb1e5b48cb9ae30933495ce7" dependencies = [ - "lazy_static", + "once_cell", ] [[package]] @@ -1239,15 +1267,21 @@ checksum = "59547bce71d9c38b83d9c0e92b6066c4253371f15005def0c30d9657f50c7642" [[package]] name = "unicode-bidi" -version = "0.3.7" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1a01404663e3db436ed2746d9fefef640d868edae3cceb81c3b8d5732fda678f" +checksum = "099b7128301d285f79ddd55b9a83d5e6b9e97c92e0ea0daebee7263e932de992" + +[[package]] +name = "unicode-ident" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "15c61ba63f9235225a22310255a29b806b907c9b8c964bcbd0a2c70f3f2deea7" [[package]] name = "unicode-normalization" -version = "0.1.19" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d54590932941a9e9266f0832deed84ebe1bf2e4c9e4a3554d393d18f5e854bf9" +checksum = "854cbdc4f7bc6ae19c820d44abdc3277ac3e1b2b93db20a636825d9322fb60e6" dependencies = [ "tinyvec", ] @@ -1258,12 +1292,6 @@ version = "0.1.9" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3ed742d4ea2bd1176e236172c8429aaf54486e7ac098db29ffe6529e0ce50973" -[[package]] -name = "unicode-xid" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" - [[package]] name = "url" version = "2.2.2" @@ -1295,15 +1323,15 @@ dependencies = [ [[package]] name = "wasi" -version = "0.10.2+wasi-snapshot-preview1" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.78" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce" +checksum = "fc7652e3f6c4706c8d9cd54832c4a4ccb9b5336e2c3bd154d5cccfbf1c1f5f7d" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1311,13 +1339,13 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.78" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a317bf8f9fba2476b4b2c85ef4c4af8ff39c3c7f0cdfeed4f82c34a880aa837b" +checksum = "662cd44805586bd52971b9586b1df85cdbbd9112e4ef4d8f41559c334dc6ac3f" dependencies = [ "bumpalo", - "lazy_static", "log", + "once_cell", "proc-macro2", "quote", "syn", @@ -1326,9 +1354,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.28" +version = "0.4.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e8d7523cb1f2a4c96c1317ca690031b714a51cc14e05f712446691f413f5d39" +checksum = "fa76fb221a1f8acddf5b54ace85912606980ad661ac7a503b4570ffd3a624dad" dependencies = [ "cfg-if", "js-sys", @@ -1338,9 +1366,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.78" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d56146e7c495528bf6587663bea13a8eb588d39b36b679d83972e1a2dbbdacf9" +checksum = "b260f13d3012071dfb1512849c033b1925038373aea48ced3012c09df952c602" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1348,9 +1376,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.78" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7803e0eea25835f8abdc585cd3021b3deb11543c6fe226dcd30b228857c5c5ab" +checksum = "5be8e654bdd9b79216c2929ab90721aa82faf65c48cdf08bdc4e7f51357b80da" dependencies = [ "proc-macro2", "quote", @@ -1361,15 +1389,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.78" +version = "0.2.82" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0237232789cf037d5480773fe568aac745bfe2afbc11a863e97901780a6b47cc" +checksum = "6598dd0bd3c7d51095ff6531a5b23e02acdc81804e30d8f07afb77b7215a140a" [[package]] name = "web-sys" -version = "0.3.55" +version = "0.3.59" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38eb105f1c59d9eaa6b5cdc92b859d85b926e82cb2e0945cd0c9259faa6fe9fb" +checksum = "ed055ab27f941423197eb86b2035720b1a3ce40504df082cac2ecc6ed73335a1" dependencies = [ "js-sys", "wasm-bindgen", @@ -1406,17 +1434,60 @@ version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" +[[package]] +name = "windows-sys" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ea04155a16a59f9eab786fe12a4a450e75cdb175f9e0d80da1e17db09f55b8d2" +dependencies = [ + "windows_aarch64_msvc", + "windows_i686_gnu", + "windows_i686_msvc", + "windows_x86_64_gnu", + "windows_x86_64_msvc", +] + +[[package]] +name = "windows_aarch64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9bb8c3fd39ade2d67e9874ac4f3db21f0d710bee00fe7cab16949ec184eeaa47" + +[[package]] +name = "windows_i686_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180e6ccf01daf4c426b846dfc66db1fc518f074baa793aa7d9b9aaeffad6a3b6" + +[[package]] +name = "windows_i686_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2e7917148b2812d1eeafaeb22a97e4813dfa60a3f8f78ebe204bcc88f12f024" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4dcd171b8776c41b97521e5da127a2d86ad280114807d0b2ab1e462bc764d9e1" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.36.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c811ca4a8c853ef420abd8592ba53ddbbac90410fab6903b3e79972a631f7680" + [[package]] name = "winreg" -version = "0.7.0" +version = "0.10.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" dependencies = [ "winapi", ] [[package]] name = "zeroize" -version = "1.4.3" +version = "1.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d68d9dcec5f9b43a30d38c49f91dfedfaac384cb8f085faca366c26207dd1619" +checksum = "c394b5bd0c6f669e7275d9c20aa90ae064cb22e75a1cad54e1b34088034b149f" diff --git a/Cargo.toml b/Cargo.toml index 9eda6bf..6b3e29d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -8,17 +8,17 @@ description = "A package manager for the Beef Programming Language" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -anyhow = "1.0.53" -clap = "3.0.10" +anyhow = { version = "1.0.53", features = ["backtrace"] } +clap = { version = "3.0.10", features = ["cargo"] } console = "0.15.0" -derivative = "2.2.0" -dialoguer = "0.9" +dialoguer = "0.10.2" +either = "1.8.0" env_logger = "0.9.0" dirs = "4.0.0" -git2 = "0.13.25" -indexmap = "1.8.0" +git2 = "0.15.0" indicatif = "0.17.0-beta.1" itertools = "0.10.3" +lazy_static = "1.4.0" log = "0.4.14" maplit = "1.0.2" multi_log = "0.1.2" @@ -27,6 +27,6 @@ rm_rf = "0.6.1" semver = { version = "1.0.4", features = ["serde"] } serde = { version = "1.0.133", features = ["derive"] } serde_json = "1.0.75" -simplelog = "0.11.2" +simplelog = "0.12.0" toml = "0.5.8" url = { version = "2.2.2", features = ["serde"] } diff --git a/README.md b/README.md index 8887e9b..01e86df 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,8 @@ Browse packages and manage your own at https://grillpm.vercel.app/ # Getting started -Download the [latest release of the CLI](https://github.com/RogueMacro/grill/releases/latest). +Download the latest release of the CLI from either [GitHub Releases](https://github.com/RogueMacro/grill/releases/latest) or [Chocolatey](https://community.chocolatey.org/packages/grill/0.1.0). + Add a `Package.toml` manifest file in the root directory of your project. Here is an example manifest: diff --git a/chocopkg/grill.nuspec b/choco/grill.nuspec similarity index 94% rename from chocopkg/grill.nuspec rename to choco/grill.nuspec index 3665dda..f401fc0 100644 --- a/chocopkg/grill.nuspec +++ b/choco/grill.nuspec @@ -34,10 +34,14 @@ This is a nuspec. It mostly adheres to https://docs.nuget.org/create/Nuspec-Refe - grill (Install) + grill William Moe Tetlie - https://github.com/roguemacro/grill + https://grillpm.vercel.app/ + https://github.com/roguemacro/grill/ + https://github.com/roguemacro/grill/issues/ + + @@ -49,7 +53,7 @@ This is a nuspec. It mostly adheres to https://docs.nuget.org/create/Nuspec-Refe - grill,package-management,beef,beeflang + grill package-manager beef beeflang A package manager for the Beef Programming Language A package manager for the Beef Programming Language diff --git a/choco/tools/LICENSE.txt b/choco/tools/LICENSE.txt new file mode 100644 index 0000000..a28fa47 --- /dev/null +++ b/choco/tools/LICENSE.txt @@ -0,0 +1,674 @@ + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/choco/tools/VERIFICATION.txt b/choco/tools/VERIFICATION.txt new file mode 100644 index 0000000..7940ca1 --- /dev/null +++ b/choco/tools/VERIFICATION.txt @@ -0,0 +1,11 @@ +Grill is made by RogueMacro (https://github.com/RogueMacro/grill). + +Verification steps: + +- Ensure you have Git and Cargo installed +- Run `git clone https://github.com/RogueMacro/grill.git` +- Switch to the tag of the released version. For instance: + `git checkout 0.1.3` +- Run `cargo build --release` +- Verify that the checksum of the exe (found at target/release/grill.exe) matches + the checksum shown on the package page of the community repository. \ No newline at end of file diff --git a/chocopkg/_TODO.txt b/chocopkg/_TODO.txt deleted file mode 100644 index 50bca03..0000000 --- a/chocopkg/_TODO.txt +++ /dev/null @@ -1,131 +0,0 @@ -TODO - -1. Determine Package Use: - - Organization? Internal Use? - You are not subject to distribution - rights when you keep everything internal. Put the binaries directly - into the tools directory (as long as total nupkg size is under 1GB). - When bigger, look to use from a share or download binaries from an - internal location. Embedded binaries makes for the most reliable use - of Chocolatey. Use `$fileLocation` (`$file`/`$file64`) and - `Install-ChocolateyInstallPackage`/`Get-ChocolateyUnzip` in - tools\chocolateyInstall.ps1. - - You can also choose to download from internal urls, see the next - section, but ignore whether you have distribution rights or not, it - doesn't apply. Under no circumstances should download from the - internet, it is completely unreliable. See - https://docs.chocolatey.org/en-us/community-repository/community-packages-disclaimer - to understand the limitations of a publicly available repository. - - Community Repository? - Have Distribution Rights? - If you are the software vendor OR the software EXPLICITLY allows - redistribution and the total nupkg size will be under 200MB, you - have the option to embed the binaries directly into the package to - provide the most reliable install experience. Put the binaries - directly into the tools folder, use `$fileLocation` (`$file`/ - `$file64`) and `Install-ChocolateyInstallPackage`/ - `Get-ChocolateyUnzip` in tools\chocolateyInstall.ps1. Additionally, - fill out the LICENSE and VERIFICATION file (see 3 below and those - files for specifics). - - NOTE: You can choose to download binaries at runtime, but be sure - the download location will remain stable. See the next section. - - Do Not Have Distribution Rights? - - Note: Packages built this way cannot be 100% reliable, but it's a - constraint of publicly available packages and there is little - that can be done to change that. See - https://docs.chocolatey.org/en-us/community-repository/community-packages-disclaimer - to better understand the limitations of a publicly available - repository. - Download Location is Publicly Available? - You will need to download the runtime files from their official - location at runtime. Use `$url`/`$url64` and - `Install-ChocolateyPackage`/`Install-ChocolateyZipPackage` in - tools\chocolateyInstall.ps1. - Download Location is Not Publicly Available? - Stop here, you can't push this to the community repository. You - can ask the vendor for permission to embed, then include a PDF of - that signed permission directly in the package. Otherwise you - will need to seek alternate locations to non-publicly host the - package. - Download Location Is Same For All Versions? - You still need to point to those urls, but you may wish to set up - something like Automatic Updater (AU) so that when a new version - of the software becomes available, the new package version - automatically gets pushed up to the community repository. See - https://docs.chocolatey.org/en-us/create/automatic-packages#automatic-updater-au - -2. Determine Package Type: - -- Installer Package - contains an installer (everything in template is - geared towards this type of package) -- Zip Package - downloads or embeds and unpacks archives, may unpack - and run an installer using `Install-ChocolateyInstallPackage` as a - secondary step. -- Portable Package - Contains runtime binaries (or unpacks them as a - zip package) - cannot require administrative permissions to install - or use -- Config Package - sets config like files, registry keys, etc -- Extension Package - Packages that add PowerShell functions to - Chocolatey - https://docs.chocolatey.org/en-us/features/extensions -- Template Package - Packages that add templates like this for `choco - new -t=name` - https://docs.chocolatey.org/en-us/guides/create/create-custom-package-templates -- Other - there are other types of packages as well, these are the main - package types seen in the wild - -3. Fill out the package contents: - -- tools\chocolateyBeforeModify.ps1 - remove if you have no processes - or services to shut down before upgrade/uninstall -- tools\LICENSE.txt / tools\VERIFICATION.txt - Remove if you are not - embedding binaries. Keep and fill out if you are embedding binaries - in the package AND pushing to the community repository, even if you - are the author of software. The file becomes easier to fill out - (does not require changes each version) if you are the software - vendor. If you are building packages for internal use (organization, - etc), you don't need these files as you are not subject to - distribution rights internally. -- tools\chocolateyUninstall.ps1 - remove if autouninstaller can - automatically uninstall and you have nothing additional to do during - uninstall -- Readme.txt - delete this file once you have read over and used - anything you've needed from here -- nuspec - fill this out, then clean out all the comments (you may wish - to leave the headers for the package vs software metadata) -- tools\chocolateyInstall.ps1 - instructions in next section. - -4. ChocolateyInstall.ps1: - -- For embedded binaries - use `$fileLocation` (`$file`/`$file64`) and - `Install-ChocolateyInstallPackage`/ `Get-ChocolateyUnzip`. -- Downloading binaries at runtime - use `$url`/`$url64` and - `Install-ChocolateyPackage` / `Install-ChocolateyZipPackage`. -- Other needs (creating files, setting registry keys), use regular - PowerShell to do so or see if there is a function already defined: - https://docs.chocolatey.org/en-us/create/functions -- There may also be functions available in extension packages, see - https://community.chocolatey.org/packages?q=id%3A.extension for examples and - availability. -- Clean out the comments and sections you are not using. - -5. Test the package to ensure install/uninstall work appropriately. - There is a test environment you can use for this - - https://github.com/chocolatey/chocolatey-test-environment - -6. Learn more about Chocolatey packaging - go through the workshop at - https://github.com/chocolatey/chocolatey-workshop - You will learn about - - General packaging - - Customizing package behavior at runtime (package parameters) - - Extension packages - - Custom packaging templates - - Setting up an internal Chocolatey.Server repository - - Adding and using internal repositories - - Reporting - - Advanced packaging techniques when installers are not friendly to - automation - -7. Delete this file. diff --git a/chocopkg/grill.0.1.0.nupkg b/chocopkg/grill.0.1.0.nupkg deleted file mode 100644 index 4af1356..0000000 Binary files a/chocopkg/grill.0.1.0.nupkg and /dev/null differ diff --git a/chocopkg/tools/LICENSE.txt b/chocopkg/tools/LICENSE.txt deleted file mode 100644 index 0333b2c..0000000 --- a/chocopkg/tools/LICENSE.txt +++ /dev/null @@ -1,11 +0,0 @@ - -Note: Include this file if including binaries you have the right to distribute. -Otherwise delete. this file. - -===DELETE ABOVE THIS LINE AND THIS LINE=== - -From: - -LICENSE - - diff --git a/chocopkg/tools/VERIFICATION.txt b/chocopkg/tools/VERIFICATION.txt deleted file mode 100644 index 775ebe7..0000000 --- a/chocopkg/tools/VERIFICATION.txt +++ /dev/null @@ -1,13 +0,0 @@ - -Note: Include this file if including binaries you have the right to distribute. -Otherwise delete. this file. If you are the software author, you can change this -mention you are the author of the software. - -===DELETE ABOVE THIS LINE AND THIS LINE=== - -VERIFICATION -Verification is intended to assist the Chocolatey moderators and community -in verifying that this package's contents are trustworthy. - - - \ No newline at end of file diff --git a/chocopkg/tools/chocolateyinstall.ps1 b/chocopkg/tools/chocolateyinstall.ps1 deleted file mode 100644 index 0f5e71c..0000000 --- a/chocopkg/tools/chocolateyinstall.ps1 +++ /dev/null @@ -1,45 +0,0 @@ - -$ErrorActionPreference = 'Stop'; -$toolsDir = "$(Split-Path -parent $MyInvocation.MyCommand.Definition)" -$url = '' -$url64 = '' - -$packageArgs = @{ - packageName = $env:ChocolateyPackageName - unzipLocation = $toolsDir - fileType = 'MSI' - url = $url - url64bit = $url64 - file = "$toolsDir/grill-$env:ChocolateyPackageVersion-x86_64.msi" - - softwareName = 'grill*' - - checksum = '63922845B733D041275F41CF286C27AE96575607E028FB40AFE974F150674FED' - checksumType = 'sha256' - checksum64 = '' - checksumType64 = 'sha256' - - silentArgs = "/qn /norestart /l*v `"$($env:TEMP)\$($packageName).$($env:chocolateyPackageVersion).MsiInstall.log`"" - validExitCodes = @(0, 3010, 1641) -} - -Install-ChocolateyInstallPackage @packageArgs - - - - - - - - - - - - - - - - - - - diff --git a/chocopkg/tools/grill-0.1.0-x86_64.msi b/chocopkg/tools/grill-0.1.0-x86_64.msi deleted file mode 100644 index 0ae4c71..0000000 Binary files a/chocopkg/tools/grill-0.1.0-x86_64.msi and /dev/null differ diff --git a/src/beef.rs b/src/beef.rs index ab71209..01e1923 100644 --- a/src/beef.rs +++ b/src/beef.rs @@ -1,8 +1,10 @@ use std::{ collections::{HashMap, HashSet}, - path::PathBuf, + fs, + path::{Path, PathBuf}, }; +use anyhow::{Context, Result}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] @@ -15,6 +17,7 @@ pub struct BeefSpace { pub projects: HashMap, #[serde(default)] pub workspace_folders: HashMap>, + pub workspace: Workspace, #[serde(flatten)] pub other: HashMap, @@ -27,12 +30,13 @@ impl Default for BeefSpace { locked: Default::default(), projects: Default::default(), workspace_folders: Default::default(), + workspace: Default::default(), other: Default::default(), } } } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Default)] #[serde(rename_all = "PascalCase")] pub struct ProjectEntry { pub path: PathBuf, @@ -41,13 +45,10 @@ pub struct ProjectEntry { pub other: HashMap, } -impl Default for ProjectEntry { - fn default() -> Self { - Self { - path: Default::default(), - other: Default::default(), - } - } +#[derive(Serialize, Deserialize, Debug, Default)] +#[serde(rename_all = "PascalCase")] +pub struct Workspace { + pub startup_project: String, } #[derive(Serialize, Deserialize, Debug)] @@ -59,13 +60,68 @@ pub struct BeefProj { pub project: Project, #[serde(flatten)] - pub other: HashMap, + other: HashMap, + + #[serde(skip)] + path: PathBuf, } -#[derive(Serialize, Deserialize, Debug)] +impl BeefProj { + pub fn new

(name: String, path: &P) -> BeefProj + where + P: AsRef, + { + let startup_object = format!("{}.Program", name); + + Self { + file_version: 1, + dependencies: Default::default(), + project: Project { + name, + target_type: String::from("BeefConsoleApplication"), + startup_object, + ..Default::default() + }, + other: Default::default(), + path: path.as_ref().to_path_buf(), + } + } + + pub fn from_file

(path: &P) -> Result + where + P: AsRef, + { + let mut proj: Self = toml::from_str(&fs::read_to_string(&path)?).with_context(|| { + format!("Failed to read project file '{}'", path.as_ref().display()) + })?; + proj.path = path.as_ref().to_path_buf(); + Ok(proj) + } + + pub fn save(&self) -> Result<()> { + fs::write(&self.path, toml::to_string(&self)?) + .with_context(|| format!("Failed to write project file: '{}'", self.path.display())) + } + + pub fn path

(&mut self, path: &P) -> &mut Self + where + P: AsRef, + { + self.path = path.as_ref().to_path_buf(); + self + } +} + +#[derive(Serialize, Deserialize, Debug, Default)] #[serde(rename_all = "PascalCase")] pub struct Project { pub name: String, + #[serde(default)] + pub target_type: String, + #[serde(default)] + pub startup_object: String, + #[serde(default)] + pub processor_macros: HashSet, #[serde(flatten)] pub other: HashMap, diff --git a/src/commands.rs b/src/commands.rs index e458d0e..01fbaaa 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -1,8 +1,9 @@ +pub mod init; pub mod install; pub mod list; pub mod login; pub mod make; +pub mod new; pub mod publish; pub mod purge; -pub mod remove; -pub mod update_index; +pub mod update; diff --git a/src/commands/init.rs b/src/commands/init.rs new file mode 100644 index 0000000..1af6773 --- /dev/null +++ b/src/commands/init.rs @@ -0,0 +1,30 @@ +use std::{fs, path::Path}; + +use crate::{beef::BeefProj, prelude::*}; + +pub fn cli() -> App { + App::new("init") + .about("Initialize an existing beef workspace with grill") + .arg( + Arg::new("path") + .long("path") + .value_name("PATH") + .default_value("."), + ) +} + +pub fn exec(args: &ArgMatches) -> Result<()> { + let path = Path::new(args.value_of("path").unwrap()); + let proj_path = path.join("BeefProj.toml"); + let name = if proj_path.exists() { + BeefProj::from_file(&proj_path)?.project.name + } else { + fs::canonicalize(std::env::current_dir()?.join(path))? + .file_name() + .context("Invalid filename")? + .to_string_lossy() + .to_string() + }; + + crate::ops::init::init(path, &name) +} diff --git a/src/commands/install.rs b/src/commands/install.rs index c4e2b54..5235e32 100644 --- a/src/commands/install.rs +++ b/src/commands/install.rs @@ -49,7 +49,7 @@ pub fn exec(args: &ArgMatches) -> Result<()> { let cli_progress = ProgressBar::new(1) .with_style( ProgressStyle::default_bar() - .template("{prefix:>12.bright.green} {msg} [{bar:40}]") + .template("{prefix:>12.bright.green} {msg} [{bar:40}]")? .progress_chars("=> "), ) .with_prefix("Installing") @@ -86,11 +86,11 @@ pub fn exec(args: &ArgMatches) -> Result<()> { let mut pkg = url.host().ok_or(anyhow!("No host in url"))?.to_string(); pkg.push_str(&url.path().replace("/", "-").replace(".git", "")); - let manifest_path = paths::tmp().join(crate::paths::PACKAGE_FILE); + let manifest_path = paths::tmp().join(crate::paths::MANIFEST_FILENAME); let mut already_installed_prompt = "This package is already installed, do you want to update it?".to_owned(); let has_manifest = if let Ok(file) = fs::read_to_string(manifest_path) { - let manifest: Manifest = toml::from_str(&file)?; + let manifest = Manifest::from_file(&file)?; pkg = manifest.package.name; let pkg_path = paths::beeflib(&pkg); diff --git a/src/commands/list.rs b/src/commands/list.rs index eab8481..31896ad 100644 --- a/src/commands/list.rs +++ b/src/commands/list.rs @@ -14,7 +14,7 @@ pub fn exec(args: &ArgMatches) -> Result<()> { let dir = if args.is_present("themes") { paths::themes() } else { - paths::pkgs() + paths::pkgs(".") }; for entry in fs::read_dir(dir)? { diff --git a/src/commands/make.rs b/src/commands/make.rs index 9bda203..647a299 100644 --- a/src/commands/make.rs +++ b/src/commands/make.rs @@ -4,7 +4,7 @@ use crate::prelude::*; pub fn cli() -> App { App::new("make") - .about("Installs the neccessary dependencies and makes a workspace") + .about("Install the neccessary dependencies and make a workspace") .arg( Arg::new("path") .long("path") @@ -13,9 +13,25 @@ pub fn cli() -> App { .help("Path to the workspace"), ) .arg(Arg::new("quiet").long("quiet").short('q')) + .arg( + Arg::new("fix-pkg") + .long("fix") + .value_name("PACKAGE") + .help("Run make for an installed package") + .conflicts_with("path"), + ) } pub fn exec(args: &ArgMatches) -> Result<()> { - let path = PathBuf::from(args.value_of("path").unwrap()); - crate::ops::make(&path, args.is_present("quiet")) + if let Some(pkg) = args.value_of("fix-pkg") { + let pkg_path = crate::paths::pkg(args.value_of("path").unwrap(), pkg); + if !pkg_path.exists() { + bail!("Package '{}' is not installed. Did you include the right version? I.e. Dummy-1.2.3", pkg) + } + log::debug!("Fixing {}", pkg); + crate::ops::install::prepare_pkg(&pkg_path, None) + } else { + let path = PathBuf::from(args.value_of("path").unwrap()); + crate::ops::make(&path, args.is_present("quiet")) + } } diff --git a/src/commands/new.rs b/src/commands/new.rs new file mode 100644 index 0000000..1d2a1c6 --- /dev/null +++ b/src/commands/new.rs @@ -0,0 +1,69 @@ +use std::{fs, path::Path}; + +use crate::{beef::BeefProj, prelude::*}; + +pub fn cli() -> App { + App::new("new") + .about("Create a new workspace and project") + .arg(Arg::new("path").value_name("PATH").default_value(".")) + .arg( + Arg::new("lib") + .long("lib") + .help("Set project to be a library"), + ) + .arg( + Arg::new("gui") + .long("gui") + .help("Set project to be a GUI application"), + ) +} + +pub fn exec(args: &ArgMatches) -> Result<()> { + let path = Path::new(args.value_of("path").unwrap()); + if !path.exists() { + fs::create_dir(path)?; + } + + let name = fs::canonicalize(std::env::current_dir()?.join(path))? + .file_name() + .context("Invalid filename")? + .to_string_lossy() + .to_string(); + + fs::create_dir(path.join("src"))?; + fs::write( + path.join("src").join("Program.bf"), + format!( + "\ +using System; + +namespace {} +{{ + class Program + {{ + public static int Main(String[] args) + {{ + return 0; + }} + }} +}} + ", + name + ), + )?; + + crate::ops::init::init(&path, &name)?; + crate::ops::make::make(&path, false)?; + + if args.is_present("lib") { + let mut proj = BeefProj::from_file(&path.join("BeefProj.toml"))?; + proj.project.target_type = String::from("BeefLib"); + proj.save()?; + } else if args.is_present("gui") { + let mut proj = BeefProj::from_file(&path.join("BeefProj.toml"))?; + proj.project.target_type = String::from("BeefGUIApplication"); + proj.save()?; + } + + Ok(()) +} diff --git a/src/commands/publish.rs b/src/commands/publish.rs index 3a8b4e7..1edf9f3 100644 --- a/src/commands/publish.rs +++ b/src/commands/publish.rs @@ -1,15 +1,21 @@ -use std::fs; +use std::{collections::HashMap, fs}; use console::style; use dialoguer::{theme::ColorfulTheme, Confirm, Select}; use git2::{Oid, Repository}; +use semver::VersionReq; use serde_json::json; -use crate::{index, manifest::Manifest, paths, prelude::*}; +use crate::{ + index, + manifest::{self, Manifest}, + paths, + prelude::*, +}; pub fn cli() -> App { App::new("publish") - .about("Publishes the current package version") + .about("Publish the current package version") .arg( Arg::new("rev") .short('r') @@ -18,12 +24,18 @@ pub fn cli() -> App { } pub fn exec(args: &ArgMatches) -> Result<()> { - let access_token = fs::read_to_string(paths::token())?; - let manifest = Manifest::from_pkg("./")?; - let package = manifest.package.name; + let token_path = paths::token(); + if !token_path.exists() { + log::info!("You have to log in to use this command. Run `grill login` first."); + return Ok(()); + } + + let access_token = fs::read_to_string(token_path)?; + let manifest = Manifest::from_pkg(".")?; + let package = manifest.package.name.clone(); let version = manifest.package.version.to_string(); - let repo = Repository::open(".")?; + let repo = Repository::open(".").context("Failed to open repository")?; let commit = if let Some(rev) = args.value_of("rev") { let commit = repo .find_commit(Oid::from_str(rev)?) @@ -37,35 +49,76 @@ pub fn exec(args: &ArgMatches) -> Result<()> { }; let rev = commit.id().to_string(); + let is_dirty = repo + .describe(git2::DescribeOptions::new().describe_all())? + .format(Some( + git2::DescribeFormatOptions::new().dirty_suffix("-dirty"), + ))? + .ends_with("-dirty"); + println!("{:>12} {}", style("Package").bright().yellow(), package); println!("{:>12} {}", style("Version").bright().yellow(), version); println!("{:>12} {}", style("Commit").bright().yellow(), style(&rev)); + + if is_dirty { + print!("{:>12}", style("(dirty)").bright().red()); + } else { + print!("{:>12}", ""); + } + if let Some(msg) = commit.message() { println!( - "{:>14} {} {}", + " {} {} {}", style('"').italic(), msg.trim(), style('"').italic(), ); + } else { + println!(); } println!(); + let prompt = if is_dirty { + "You have uncommitted changes. Do you still want to continue?" + } else { + "Publish?" + }; + if Confirm::with_theme(&ColorfulTheme::default()) - .with_prompt("Continue?") + .with_prompt(prompt) .interact()? { println!(); index::update(true, true)?; let index = index::parse(false, false)?; + + let mut deps: HashMap = manifest + .simple_deps() + .map(|(k, v)| (k.clone(), v.clone())) + .collect(); + + for (_, feature) in manifest.features.optional.iter() { + if let manifest::Feature::Project(path) = feature { + let feature_manifest = Manifest::from_pkg(&path)?; + deps.extend( + feature_manifest + .simple_deps() + .map(|(k, v)| (k.clone(), v.clone())), + ); + } + } + let mut body = json!({ "access_token": access_token, "package": package.clone(), "metadata": json!({ "version": version.clone(), "revision": rev, - "dependencies": manifest.dependencies + "dependencies": deps, + "description": manifest.package.description }) }); + if !index.contains_key(&package) { let remote_urls: Vec = repo .remotes()? @@ -91,10 +144,7 @@ pub fn exec(args: &ArgMatches) -> Result<()> { ); } - let res = reqwest::blocking::Client::new() - .post("http://grillpm.vercel.app/api/publish") - .json(&body) - .send()?; + let res = crate::web::api("publish", &body)?; if let Err(err) = res.error_for_status_ref() { let body = res diff --git a/src/commands/purge.rs b/src/commands/purge.rs index 9a2d228..d52fa70 100644 --- a/src/commands/purge.rs +++ b/src/commands/purge.rs @@ -3,17 +3,34 @@ use std::fs; use crate::prelude::*; pub fn cli() -> App { - App::new("purge").about("Deletes all installed packages") + App::new("purge").about("Delete all installed packages") } pub fn exec(_: &ArgMatches) -> Result<()> { - let path = crate::paths::pkgs(); + let path = crate::paths::pkgs("."); let count = fs::read_dir(&path)?.count(); + + if count == 0 { + println!("No packages in cache"); + return Ok(()); + } + + if !dialoguer::Confirm::new() + .with_prompt(format!( + "Are you sure you want to delete {} packages?", + count + )) + .interact()? + { + return Ok(()); + } + rm_rf::remove(&path)?; println!( "{:>12} {} packages", console::style("Deleted").bright().red(), count ); + Ok(()) } diff --git a/src/commands/remove.rs b/src/commands/remove.rs deleted file mode 100644 index aa5f181..0000000 --- a/src/commands/remove.rs +++ /dev/null @@ -1,14 +0,0 @@ -use crate::{paths, prelude::*}; - -pub fn cli() -> App { - App::new("remove") - .about("Remove a package") - .arg(Arg::new("pkg").required(true)) -} - -pub fn exec(args: &ArgMatches) -> Result<()> { - let pkg = args.value_of("pkg").unwrap(); - let path = paths::pkg(pkg); - rm_rf::ensure_removed(path)?; - Ok(()) -} diff --git a/src/commands/update.rs b/src/commands/update.rs new file mode 100644 index 0000000..c87c8f9 --- /dev/null +++ b/src/commands/update.rs @@ -0,0 +1,119 @@ +use std::path::Path; + +use crate::{ + index, + lock::{self, Lock}, + prelude::*, +}; +use console::style; + +pub fn cli() -> App { + App::new("update") + .about("Update dependencies to the latest version") + .arg(Arg::new("quiet").long("quiet").short('q')) + // .arg( + // Arg::new("grill") + // .long("grill") + // .help("not yet implemented") + // .conflicts_with("index"), + // ) + .arg( + Arg::new("index") + .long("index") + .help("Update the package index") + .conflicts_with("grill"), + ) +} + +pub fn exec(args: &ArgMatches) -> Result<()> { + if args.is_present("grill") { + todo!() + } else if args.is_present("index") { + index::update(!args.is_present("quiet"), false) + } else { + index::update(!args.is_present("quiet"), false)?; + + let lock_path = Path::new(".").join(crate::paths::LOCK_FILENAME); + let old_lock = if lock_path.exists() { + Some(lock::read(lock_path)?) + } else { + None + }; + + let lock = lock::generate(Path::new("."), true, false)?; + + if !args.is_present("quiet") { + if let Some(old_lock) = old_lock { + print_altered_deps(&old_lock, &lock); + } else { + for (dep, versions) in lock { + for version in versions { + println!( + "{:>12} {} v{}", + style("Added").bright().cyan(), + dep, + version + ); + } + } + } + } + + Ok(()) + } +} + +fn print_altered_deps(old_lock: &Lock, new_lock: &Lock) { + for (dep, versions) in new_lock { + for version in versions { + if old_lock.get(dep).map_or(true, |old_versions| { + !old_versions.iter().any(|v| v.major == version.major) + }) { + println!( + "{:>12} {} v{}", + style("Added").bright().cyan(), + dep, + version + ); + } + } + } + + for (dep, new_versions) in new_lock { + for new_version in new_versions { + if let Some(old_version) = old_lock.get(dep).and_then(|old_versions| { + if let Some(old_version) = old_versions + .iter() + .find(|&v| v.major == new_version.major && v != new_version) + { + Some(old_version) + } else { + None + } + }) { + println!( + "{:>12} {} v{} -> v{}", + style("Updated").bright().green(), + dep, + old_version, + new_version + ); + } + } + } + + for (dep, versions) in old_lock { + for version in versions { + if !new_lock.get(dep).map_or(false, |new_versions| { + new_versions.iter().any(|v| v.major == version.major) + }) { + println!( + "{:>12} {} v{}", + style("Removed").bright().red(), + dep, + version + ); + } + } + } +} diff --git a/src/commands/update_index.rs b/src/commands/update_index.rs deleted file mode 100644 index b0f3b63..0000000 --- a/src/commands/update_index.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::prelude::*; - -pub fn cli() -> App { - App::new("update-index") - .about("Updates the local registry with the latest packages and versions") - .arg(Arg::new("quiet").long("quiet").short('q')) -} - -pub fn exec(args: &ArgMatches) -> Result<()> { - crate::index::update(!args.is_present("quiet"), false) -} diff --git a/src/index.rs b/src/index.rs index d896ea4..3a676f9 100644 --- a/src/index.rs +++ b/src/index.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, fs}; +use std::{collections::HashMap, fs, time::Duration}; use anyhow::{Context, Result}; use git2::Repository; @@ -24,7 +24,9 @@ pub struct VersionMetadata { } pub fn update(with_spinner: bool, clear_after: bool) -> Result<()> { - rm_rf::ensure_removed(paths::tmp())?; + log::trace!("Updating index"); + + rm_rf::ensure_removed(paths::tmp()).context("Failed to remove tmp folder")?; let spinner = ProgressBar::new_spinner(); if with_spinner { @@ -32,11 +34,13 @@ pub fn update(with_spinner: bool, clear_after: bool) -> Result<()> { "{:>10} index", console::style("Updating").bright().cyan() )); - spinner.enable_steady_tick(100); + spinner.enable_steady_tick(Duration::from_millis(100)); } - Repository::clone("https://github.com/RogueMacro/grill-index", paths::tmp())?; - fs::copy(paths::tmp().join("index.toml"), paths::index())?; + Repository::clone("https://github.com/RogueMacro/grill-index", paths::tmp()) + .context("Failed to clone repository")?; + fs::copy(paths::tmp().join("index.toml"), paths::index()) + .context("Failed to move index file")?; if with_spinner { if clear_after { @@ -53,6 +57,8 @@ pub fn update(with_spinner: bool, clear_after: bool) -> Result<()> { } pub fn parse(with_spinner: bool, clear_after: bool) -> Result { + log::trace!("Parsing index"); + let path = paths::index(); toml::from_str::(&fs::read_to_string(&path)?).or_else(|err| { update(with_spinner, clear_after)?; diff --git a/src/lib.rs b/src/lib.rs index 498944c..67494e2 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -2,24 +2,28 @@ pub mod beef; pub mod commands; pub mod index; pub mod lock; +pub mod log; pub mod manifest; pub mod ops; pub mod paths; pub mod resolver; -// pub mod log; +pub mod web; use prelude::App; pub fn cli() -> App { App::new("grill") + .about(clap::crate_description!()) + .version(clap::crate_version!()) + .subcommand(commands::init::cli()) .subcommand(commands::install::cli()) .subcommand(commands::list::cli()) .subcommand(commands::login::cli()) .subcommand(commands::make::cli()) + .subcommand(commands::new::cli()) .subcommand(commands::publish::cli()) .subcommand(commands::purge::cli()) - .subcommand(commands::remove::cli()) - .subcommand(commands::update_index::cli()) + .subcommand(commands::update::cli()) } pub mod prelude { diff --git a/src/lock.rs b/src/lock.rs index bbfb29d..1625c4e 100644 --- a/src/lock.rs +++ b/src/lock.rs @@ -4,62 +4,105 @@ use std::{ path::Path, }; -use anyhow::Result; -use semver::{Version, VersionReq}; +use anyhow::{Context, Result}; +use semver::Version; use crate::{manifest::Manifest, resolver::resolve}; pub type Lock = HashMap>; +pub fn read

(path: P) -> Result +where + P: AsRef, +{ + Ok( + toml::from_str(&fs::read_to_string(path.as_ref()).with_context(|| { + format!( + "Failed to read lock file: {}", + path.as_ref().to_string_lossy() + ) + })?) + .context("Failed to deserialize lock file")?, + ) +} + +pub fn write

(path: P, lock: &Lock) -> Result<()> +where + P: AsRef, +{ + Ok(fs::write( + path, + toml::to_string(lock).context("Failed to serialize lock")?, + ) + .context("Failed to write lock file")?) +} + pub fn validate(pkg_path: &Path) -> Result { - let deps = Manifest::from_pkg(pkg_path)?.dependencies; + let manifest = Manifest::from_pkg(pkg_path)?; - let file_path = pkg_path.join(crate::paths::LOCK_FILE); + let file_path = pkg_path.join(crate::paths::LOCK_FILENAME); if !file_path.exists() { return Ok(false); } - let lock: Lock = toml::from_str(&fs::read_to_string(file_path)?)?; - Ok(validate_lock(&deps, &lock)) + let lock: Lock = self::read(file_path)?; + Ok(validate_lock(&manifest, &lock)) } -fn validate_lock(deps: &HashMap, lock: &Lock) -> bool { - log::trace!("Validation lock"); - log::trace!("Dependencies: {:#?}", deps); - log::trace!("Lock: {:#?}", lock); +fn validate_lock(manifest: &Manifest, lock: &Lock) -> bool { + log::trace!("Validating lock"); - if deps.len() != lock.len() { - log::trace!("Length doesn't match"); - return false; + for (dep, req) in manifest.simple_deps() { + if !lock.get(dep).map_or(false, |locked_versions| { + locked_versions.iter().any(|v| req.matches(v)) + }) { + log::trace!("Invalid lock: No match for {} {}", dep, req); + return false; + } } - for (dep, req) in deps { - if !lock - .get(dep) - .map_or(false, |vset| vset.iter().any(|v| req.matches(v))) - { - log::error!("No match for {} {} in vset {:?}", dep, req, lock.get(dep)); - return false; + for (dep, versions) in lock { + for v1 in versions.iter() { + for v2 in versions.iter() { + if v1.major == v2.major && v1 != v2 { + log::trace!( + "Invalid lock: {} v{} is incompatible with {} v{}", + dep, + v1, + dep, + v2 + ); + return false; + } + } } } true } -pub fn generate(pkg_path: &Path) -> Result { - let manifest = Manifest::from_pkg(pkg_path)?; +pub fn generate(pkg_path: &Path, write_lock: bool, try_keep_lock: bool) -> Result { + let manifest = Manifest::from_pkg(pkg_path).context("Failed to read manifest")?; - let lock_path = pkg_path.join(crate::paths::LOCK_FILE); - let previous_lock = if lock_path.exists() { - Some(toml::from_str(&fs::read_to_string(lock_path)?)?) + let lock_path = pkg_path.join(crate::paths::LOCK_FILENAME); + let previous_lock = if try_keep_lock && lock_path.exists() { + let lock = self::read(lock_path)?; + if validate_lock(&manifest, &lock) { + Some(lock) + } else { + None + } } else { None }; - let resolved = resolve(&manifest, previous_lock.as_ref())?; + let index = crate::index::parse(false, false)?; + + let lock = resolve(&manifest, previous_lock.as_ref(), &index)?; - let lock_file = toml::to_string(&resolved)?; - fs::write(pkg_path.join(crate::paths::LOCK_FILE), lock_file)?; + if write_lock { + self::write(pkg_path.join(crate::paths::LOCK_FILENAME), &lock)?; + } - Ok(resolved) + Ok(lock) } diff --git a/src/log.rs b/src/log.rs index ef2d29a..5983b12 100644 --- a/src/log.rs +++ b/src/log.rs @@ -1,32 +1,60 @@ -use std::{cell::RefCell, io::BufWriter}; +use std::fs::File; -use indicatif::ProgressBar; +use anyhow::Result; +use indicatif::MultiProgress; +use lazy_static::lazy_static; -thread_local! { - static PROGRESS_BAR: RefCell> = RefCell::new(None); +use crate::paths; + +lazy_static! { + static ref PROGRESS_BAR: MultiProgress = MultiProgress::new(); +} + +pub fn init() -> Result<()> { + let console_logger = Box::new(ConsoleLogger::new()); + let file_logger = simplelog::WriteLogger::new( + log::LevelFilter::max(), + Default::default(), + File::create(paths::home().join("log.txt"))?, + ); + multi_log::MultiLogger::init(vec![console_logger, file_logger], log::Level::max()) + .map_err(anyhow::Error::from) +} + +pub fn get_multi_progress() -> &'static MultiProgress { + &PROGRESS_BAR } -struct Logger { - logger: env_logger::Logger, +struct ConsoleLogger { + inner: env_logger::Logger, } -impl Logger { +impl ConsoleLogger { pub fn new() -> Self { - let buf = BufWriter::new(Vec::new()); - let logger = env_logger::builder().target(Target::Pipe(buf)).init(); + Self { + inner: env_logger::builder() + .format_timestamp(None) + .format_target(false) + .filter_level(log::LevelFilter::Info) + .build(), + } } } -impl log::Log for Logger { +impl log::Log for ConsoleLogger { fn enabled(&self, metadata: &log::Metadata) -> bool { - self.logger.enabled(metadata) + self.inner.enabled(metadata) } fn log(&self, record: &log::Record) { - self.logger.log(record) + if self.inner.matches(record) { + get_multi_progress().suspend(|| { + self.inner.log(record); + }); + } } fn flush(&self) { - self.logger.flush() + self.inner.flush(); } } diff --git a/src/main.rs b/src/main.rs index ef565db..d38b703 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,58 +1,50 @@ -use std::fs::File; - use anyhow::{bail, Result}; use grill::paths; fn main() -> Result<()> { - let console_logger = Box::new( - env_logger::builder() - .format_timestamp(None) - .format_target(false) - .build(), - ); - let file_logger = simplelog::WriteLogger::new( - log::LevelFilter::max(), - Default::default(), - File::create(paths::home().join("log.txt"))?, - ); - multi_log::MultiLogger::init(vec![console_logger, file_logger], log::Level::Trace)?; - - let result = run(); - let removed = rm_rf::ensure_removed(paths::tmp()); + grill::log::init()?; + + rm_rf::ensure_removed(paths::tmp())?; + + let result = { + let args = grill::cli().get_matches(); + match args.subcommand() { + Some((cmd, args)) => match cmd { + "init" => grill::commands::init::exec(args), + "install" => grill::commands::install::exec(args), + "list" => grill::commands::list::exec(args), + "login" => grill::commands::login::exec(args), + "make" => grill::commands::make::exec(args), + "new" => grill::commands::new::exec(args), + "publish" => grill::commands::publish::exec(args), + "purge" => grill::commands::purge::exec(args), + "update" => grill::commands::update::exec(args), + _ => bail!("Unkown command: {}", cmd), + }, + None => { + grill::cli().print_help()?; + Ok(()) + } + } + }; if let Err(err) = result { println!(); - if let Some(source) = err.source() { - log::error!("{}\n\nCaused by:\n {}", err, source); + + if let Some(src) = err.source() { + log::error!("{}\n\nCaused by:\n {}", err, src); } else { log::error!("{}", err); } + + log::trace!("Backtrace: {}", err.backtrace()); + println!(); } - removed?; + if !cfg!(debug_assertions) { + rm_rf::ensure_removed(paths::tmp())?; + } Ok(()) } - -fn run() -> Result<()> { - let args = grill::cli().get_matches(); - - match args.subcommand() { - Some((cmd, args)) => match cmd { - "install" => grill::commands::install::exec(args), - "list" => grill::commands::list::exec(args), - "login" => grill::commands::login::exec(args), - "make" => grill::commands::make::exec(args), - "publish" => grill::commands::publish::exec(args), - "purge" => grill::commands::purge::exec(args), - "remove" => grill::commands::remove::exec(args), - "update-index" => grill::commands::update_index::exec(args), - _ => bail!("Unkown command: {}", cmd), - }, - None => { - grill::cli().print_help()?; - Ok(()) - } - } -} diff --git a/src/manifest.rs b/src/manifest.rs index a8370da..c34f971 100644 --- a/src/manifest.rs +++ b/src/manifest.rs @@ -1,32 +1,134 @@ -use std::{collections::HashMap, path::Path}; +use std::{ + collections::{HashMap, HashSet}, + path::{Path, PathBuf}, +}; use anyhow::Context; use semver::{Version, VersionReq}; use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "PascalCase")] pub struct Manifest { pub package: Package, #[serde(default)] - pub dependencies: HashMap, + pub dependencies: HashMap, + #[serde(default)] + pub features: Features, } impl Manifest { pub fn from_pkg

(path: P) -> anyhow::Result + where + P: AsRef, + { + Self::from_file(path.as_ref().join(crate::paths::MANIFEST_FILENAME)) + } + + pub fn from_file

(path: P) -> anyhow::Result where P: AsRef, { let path = path.as_ref(); let manifest = toml::from_str( - &std::fs::read_to_string(path.join(crate::paths::PACKAGE_FILE)) - .context(format!("No manifest found at in '{}'", path.display()))?, + &std::fs::read_to_string(path) + .with_context(|| format!("Failed to read manifest at '{}'", path.display()))?, )?; Ok(manifest) } + + /// Get simple dependencies with requirements. + /// Ignores git dependencies. + pub fn simple_deps(&self) -> impl Iterator { + self.dependencies.iter().filter_map(|(key, val)| { + if let Dependency::Simple(req) = val { + Some((key, req)) + } else { + None + } + }) + } + + pub fn git_deps(&self) -> impl Iterator { + self.dependencies.iter().filter_map(|(key, val)| { + if let Dependency::Git(git_dep) = val { + Some((key, git_dep)) + } else { + None + } + }) + } + + pub fn local_deps(&self) -> impl Iterator { + self.dependencies.iter().filter_map(|(key, val)| { + if let Dependency::Local(local) = val { + Some((key, local)) + } else { + None + } + }) + } } #[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "PascalCase")] pub struct Package { pub name: String, pub version: Version, + pub description: String, + #[serde(default = "bool_true")] + pub corlib: bool, +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(untagged)] +pub enum Dependency { + Simple(VersionReq), + Advanced(AdvancedDependency), + Git(GitDependency), + Local(LocalDependency), +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "PascalCase", deny_unknown_fields)] +pub struct AdvancedDependency { + #[serde(rename = "Version")] + pub req: VersionReq, + #[serde(default)] + pub features: HashSet, + #[serde(default = "bool_true")] + pub default_features: bool, +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "PascalCase", deny_unknown_fields)] +pub struct GitDependency { + pub git: url::Url, + pub rev: String, +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(rename_all = "PascalCase", deny_unknown_fields)] +pub struct LocalDependency { + pub path: PathBuf, +} + +#[derive(Serialize, Deserialize, Debug, Default)] +#[serde(rename_all = "PascalCase")] +pub struct Features { + #[serde(default)] + pub default: Vec, + #[serde(flatten)] + pub optional: HashMap, +} + +#[derive(Serialize, Deserialize, Debug)] +#[serde(untagged)] +pub enum Feature { + Project(String), + List(Vec), +} + +fn bool_true() -> bool { + true } diff --git a/src/ops.rs b/src/ops.rs index 375dbeb..516e170 100644 --- a/src/ops.rs +++ b/src/ops.rs @@ -1,3 +1,4 @@ +pub mod init; pub mod install; pub mod make; diff --git a/src/ops/init.rs b/src/ops/init.rs new file mode 100644 index 0000000..67730eb --- /dev/null +++ b/src/ops/init.rs @@ -0,0 +1,25 @@ +use std::{fs, path::Path}; + +use anyhow::{bail, Result}; + +pub fn init(path: &Path, name: &str) -> Result<()> { + let manifest_path = path.join(crate::paths::MANIFEST_FILENAME); + + if manifest_path.exists() { + bail!("Already initialized") + } + + fs::write( + manifest_path, + format!( + "\ +[Package] +Name = \"{}\" +Version = \"0.1.0\" +Description = \"\" +", + name + ), + )?; + Ok(()) +} diff --git a/src/ops/install.rs b/src/ops/install.rs index 0c979c9..bc977e5 100644 --- a/src/ops/install.rs +++ b/src/ops/install.rs @@ -1,21 +1,32 @@ -use std::{collections::HashMap, fs, path::PathBuf}; +use std::{ + collections::HashMap, + fs, + path::{Path, PathBuf}, + time::Duration, +}; use anyhow::Context; -use git2::Repository; -use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; +use indicatif::{ProgressBar, ProgressStyle}; use reqwest::Url; use semver::Version; use crate::{ beef, index::{self, Index}, + manifest::Manifest, paths, prelude::*, }; -pub fn install(pkg: S, version: &Version, index: Option<&Index>) -> Result +pub fn install( + pkg: S, + version: &Version, + index: Option<&Index>, + progress_callback: C, +) -> Result where S: AsRef, + C: FnMut(git2::Progress<'_>), { let pkg = pkg.as_ref(); @@ -39,63 +50,172 @@ where .with_context(|| format!("{} is not a version of '{}'", version, pkg))?; let ident = format!("{}-{}", pkg, version); - let path = paths::pkg(&ident); + let path = paths::pkg(".", &ident); if path.exists() { return Ok(path); } - let path = install_git(&entry.url, Some(&metadata.rev), Some(&ident))?; + let (path, _) = install_git( + &entry.url, + Some(&metadata.rev), + Some(&ident), + progress_callback, + )?; Ok(path) } -pub fn install_git(url: &Url, rev: Option<&str>, pkg_ident: Option<&String>) -> Result { +/// Returns the path to the installed package and the revision +/// that was checked out. +pub fn install_git( + url: &Url, + rev: Option<&str>, + pkg_ident: Option<&String>, + mut progress_callback: C, +) -> Result<(PathBuf, String)> +where + C: FnMut(git2::Progress<'_>), +{ rm_rf::ensure_removed(paths::tmp())?; - let repo = Repository::clone(url.as_str(), &paths::tmp())?; - if let Some(rev) = rev { - let (object, reference) = repo.revparse_ext(&rev)?; + + // let repo = Repository::init(&paths::tmp())?; + // let mut remote = repo.remote("origin", url.as_str())?; + let checkout_rev; + { + let mut callbacks = git2::RemoteCallbacks::new(); + callbacks.transfer_progress(|p| { + progress_callback(p); + true + }); + + // remote.download::( + // &[], + // Some(git2::FetchOptions::new().remote_callbacks(callbacks)), + // )?; + + // log::trace!( + // "Downloaded from remote: {}", + // remote.url().unwrap_or("Url unavailable") + // ); + let mut fo = git2::FetchOptions::new(); + fo.remote_callbacks(callbacks); + let repo = git2::build::RepoBuilder::new() + .fetch_options(fo) + .clone(url.as_str(), &paths::tmp())?; + + let head = repo + .find_commit(repo.head().unwrap().target().unwrap())? + .id() + .to_string(); + + // drop(remote); + + checkout_rev = rev.map(str::to_owned).unwrap_or(head.to_string()); + + let (object, reference) = repo.revparse_ext(&checkout_rev)?; repo.checkout_tree(&object, None)?; match reference { Some(gref) => repo.set_head(gref.name().with_context(|| "Invalid gref name")?), None => repo.set_head_detached(object.id()), }?; - } - // Dropping the repository gives us access to the directory - drop(repo); + // Dropping the repository gives us access to the directory + } - let path = pkg_ident.map(|ident| paths::pkg(ident)).unwrap_or_else(|| { - let mut pkg = url - .host() - .ok_or(anyhow!("No host in url")) - .unwrap() - .to_string(); - pkg.push_str(&url.path().replace("/", "-").replace(".git", "")); - paths::pkg(&pkg) - }); + let path = pkg_ident + .map(|ident| paths::pkg(".", ident)) + .unwrap_or_else(|| { + let mut pkg = url.host().unwrap().to_string(); + pkg.push_str(&url.path().replace("/", "-").replace(".git", "")); + pkg = format!("{}-{}", pkg, checkout_rev); + paths::pkg(".", &pkg) + }); if path.exists() { - bail!("Package already installed") + return Ok((path, checkout_rev)); } - fs::rename(paths::tmp(), &path).context("Failed to move package")?; + fs::rename(paths::tmp(), &path).context("Failed to move tmp folder")?; - if let Some(ident) = pkg_ident { - let proj_file_path = path.join("BeefProj.toml"); - let mut proj_file: beef::BeefProj = - toml::from_str(&fs::read_to_string(&proj_file_path)?) - .with_context(|| format!("Failed to read project file of package '{}'", ident))?; + if pkg_ident.is_some() { + prepare_pkg(&path, pkg_ident.map(String::as_str))?; + } + + Ok((path, checkout_rev)) +} + +pub fn prepare_pkg(path: &Path, ident: Option<&str>) -> Result<()> { + let ident = ident.map(str::to_owned).unwrap_or( + path.file_name() + .context("Invalid file name for package path")? + .to_string_lossy() + .to_string(), + ); - proj_file.project.name = ident.to_owned(); + let proj_file_path = path.join("BeefProj.toml"); + let mut proj_file = beef::BeefProj::from_file(&proj_file_path)?; - fs::write(&proj_file_path, toml::to_string(&proj_file)?) - .context("Failed to write project file")?; + proj_file.project.name = ident.clone(); + proj_file + .dependencies + .insert(String::from("corlib"), String::from("*")); + + let manifest = Manifest::from_pkg(&path)?; + + for (feature_name, feature_project) in + manifest + .features + .optional + .iter() + .filter_map(|(feature_name, feature)| { + if let crate::manifest::Feature::Project(project) = feature { + Some((feature_name, project)) + } else { + None + } + }) + { + let feature_proj_path = path.join(feature_project).join("BeefProj.toml"); + let mut feature_proj_file = beef::BeefProj::from_file(&feature_proj_path)?; + feature_proj_file.project.name = format!("{}/{}", ident, feature_name); + feature_proj_file.save()?; } - if path.join(paths::PACKAGE_FILE).exists() { - crate::ops::make(&path, true)?; + for feature_project in manifest.features.optional.iter().filter_map(|(_, f)| { + if let crate::manifest::Feature::Project(project) = f { + Some(project) + } else { + None + } + }) { + let feature_project_path = path.join(feature_project); + if !feature_project_path.join(paths::MANIFEST_FILENAME).exists() { + continue; + } + + let feature_manifest = Manifest::from_pkg(&feature_project_path)?; + + let feature_proj_file_path = feature_project_path.join("BeefProj.toml"); + let mut feature_proj = beef::BeefProj::from_file(&feature_proj_file_path)?; + feature_proj.dependencies.clear(); + feature_proj + .dependencies + .insert(String::from("corlib"), String::from("*")); + + for (_, dep) in feature_manifest.local_deps() { + let dep_proj_path = feature_project_path.join(&dep.path).join("BeefProj.toml"); + let dep_proj_file = beef::BeefProj::from_file(&dep_proj_path)?; + + feature_proj + .dependencies + .insert(dep_proj_file.project.name, String::from("*")); + } + + feature_proj.save()?; } - Ok(path) + proj_file.save()?; + + Ok(()) } pub fn install_multiple( @@ -118,11 +238,11 @@ where let mut paths = HashMap::new(); if with_progress { - let progress = MultiProgress::new(); + let progress = crate::log::get_multi_progress(); let install_progress = progress.add( ProgressBar::new_spinner().with_style( ProgressStyle::default_spinner() - .template("{spinner:>11}> {msg}") + .template("{spinner:>11}> {msg}")? .tick_chars("=\\|/==="), ), ); @@ -130,18 +250,18 @@ where ProgressBar::new(pkgs.len() as u64) .with_style( ProgressStyle::default_bar() - .template("{prefix:>12.bright.cyan} [{bar:40}] {pos}/{len}") + .template("{prefix:>12.bright.cyan} [{bar:40}] {pos}/{len}")? .progress_chars("=> "), ) .with_prefix("Fetching"), ); - install_progress.enable_steady_tick(150); + install_progress.enable_steady_tick(Duration::from_millis(150)); fetch_progress.tick(); for (pkg, version) in pkgs.iter() { install_progress.set_message(format!("{} v{}", pkg, version)); - let path = install(pkg, version, Some(index))?; + let path = install(pkg, version, Some(index), |_| {})?; paths.insert(pkg.clone(), path); install_progress.println(format!( @@ -162,7 +282,7 @@ where progress.clear()?; } else { for (pkg, version) in pkgs.iter() { - let path = install(pkg, version, Some(index))?; + let path = install(pkg, version, Some(index), |_| {})?; paths.insert(pkg.clone(), path); if let Some(on_install) = &on_install { on_install(pkg, version); diff --git a/src/ops/make.rs b/src/ops/make.rs index c37c6ce..e0f3efb 100644 --- a/src/ops/make.rs +++ b/src/ops/make.rs @@ -1,18 +1,18 @@ use std::{ collections::{HashMap, HashSet}, fs, - path::Path, + path::{Path, PathBuf}, + time::Duration, }; -use anyhow::Context; use console::Emoji; +use either::{self, Either}; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; +use semver::Version; use crate::{ - beef, - index::{self}, - lock::{self, Lock}, - manifest::Manifest, + beef, index, lock, + manifest::{self, Manifest}, prelude::*, }; @@ -20,7 +20,7 @@ const COMPASS: Emoji = Emoji("🧭 ", ""); const LOOKING_GLASS: Emoji = Emoji("🔍 ", ""); const TRUCK: Emoji = Emoji("🚚 ", ""); const PACKAGE: Emoji = Emoji("📦 ", ""); -const BEEF: Emoji = Emoji("🥩 ", ""); +const SPAGHETTI: Emoji = Emoji("🍝 ", ""); pub fn make(path: &Path, silent: bool) -> Result<()> { let manifest = Manifest::from_pkg(&path)?; @@ -34,7 +34,7 @@ pub fn make(path: &Path, silent: bool) -> Result<()> { ); } - let multi = MultiProgress::new(); + let multi = crate::log::get_multi_progress(); let index = make_step( &multi, @@ -60,12 +60,9 @@ pub fn make(path: &Path, silent: bool) -> Result<()> { silent, |_, _| { if !lock::validate(&path)? { - lock::generate(&path) + lock::generate(&path, false, true) } else { - let lock: Lock = - toml::from_str(&fs::read_to_string(path.join(crate::paths::LOCK_FILE))?) - .context("Invalid lock")?; - Ok(lock) + lock::read(path.join(crate::paths::LOCK_FILENAME)) } }, )?; @@ -82,7 +79,7 @@ pub fn make(path: &Path, silent: bool) -> Result<()> { let progress = multi.add( ProgressBar::new(1).with_style( ProgressStyle::default_bar() - .template("{prefix:>12.bright.cyan} [{bar:11}]") + .template("{prefix:>12} [{bar:11}] {msg:.bright.grey}")? .progress_chars("=> "), ), ); @@ -92,31 +89,82 @@ pub fn make(path: &Path, silent: bool) -> Result<()> { .map(|(_, versions)| versions.len()) .sum::() as u64, ); - progress.set_style( - ProgressStyle::default_bar() - .template("{msg:>12} [{bar:11}]") - .progress_chars("=> "), - ); - progress.set_message(format!("{} / {}", 0, progress.length())); + progress.set_prefix(format!( + "{} / {}", + 0, + progress.length().ok_or(anyhow!("No progress length"))? + )); } let mut pkgs = HashMap::new(); for (pkg, versions) in lock { for version in versions { - let path = crate::ops::install(&pkg, &version, Some(&index))?; - pkgs.insert(format!("{}-{}", pkg, version), path); + progress.set_message(format!("{} 0%", pkg)); + let path = + crate::ops::install(&pkg, &version, Some(&index), |install_progress| { + progress.set_message(format!( + "{} {}% ({}/{}) {}", + pkg, + ((install_progress.received_objects() + + install_progress.indexed_objects()) + as f32 + / (install_progress.total_objects() * 2) as f32 + * 100f32) + .round(), + install_progress.received_objects(), + install_progress.total_objects(), + install_progress.indexed_objects() + )) + })?; + + pkgs.insert((pkg.clone(), either::Left(version)), path); if !silent { progress.inc(1); - progress.set_message(format!( + progress.set_prefix(format!( "{} / {}", progress.position(), - progress.length() + progress.length().ok_or(anyhow!("No progress length"))? )); } } } + for (name, dep) in manifest.git_deps() { + progress.set_message(format!("{} 0%", name)); + let (path, rev) = crate::ops::install_git( + &dep.git, + Some(&dep.rev), + Some(name), + |install_progress| { + progress.set_message(format!( + "{} {}% ({}/{}) {}", + name, + ((install_progress.received_objects() + + install_progress.indexed_objects()) + as f32 + / (install_progress.total_objects() * 2) as f32 + * 100f32) + .round(), + install_progress.received_objects(), + install_progress.total_objects(), + install_progress.indexed_objects() + )) + }, + )?; + + pkgs.insert((name.clone(), either::Right(rev)), path); + + if !silent { + progress.inc(1); + progress.set_prefix(format!( + "{} / {}", + progress.position(), + progress.length().ok_or(anyhow!("No progress length"))? + )); + } + } + progress.finish_and_clear(); Ok(pkgs) }, @@ -133,29 +181,25 @@ pub fn make(path: &Path, silent: bool) -> Result<()> { |_, _| { let ws_file_path = path.join("BeefSpace.toml"); let proj_file_path = path.join("BeefProj.toml"); - let mut ws: beef::BeefSpace = toml::from_str(&fs::read_to_string(&ws_file_path)?)?; - let mut proj: beef::BeefProj = toml::from_str(&fs::read_to_string(&proj_file_path)?)?; - if !ws.workspace_folders.contains_key("Packages") { - ws.workspace_folders - .insert(String::from("Packages"), HashSet::new()); - } + let mut ws = if ws_file_path.exists() { + toml::from_str(&fs::read_to_string(&ws_file_path)?)? + } else { + beef::BeefSpace::default() + }; - ws.workspace_folders - .get_mut("Packages") - .unwrap() - .retain(|pkg| { - if !pkgs.contains_key(pkg) { - ws.projects.remove(pkg); - false - } else { - true - } - }); + let mut proj = if proj_file_path.exists() { + beef::BeefProj::from_file(&proj_file_path)? + } else { + beef::BeefProj::new(manifest.package.name.clone(), &proj_file_path) + }; + proj.project.name = manifest.package.name.clone(); + proj.save()?; - proj.dependencies - .retain(|pkg, _| manifest.dependencies.contains_key(pkg) && pkg != "corlib"); + let mut ws_package_folder = HashSet::new(); + ws.workspace.startup_project = proj.project.name.clone(); + ws.projects.clear(); ws.projects.insert( String::from("corlib"), beef::ProjectEntry { @@ -163,43 +207,44 @@ pub fn make(path: &Path, silent: bool) -> Result<()> { ..Default::default() }, ); + + ws.locked.clear(); ws.locked.insert(String::from("corlib")); - proj.dependencies - .insert(String::from("corlib"), String::from("*")); - - for (ident, path) in pkgs { - ws.projects.insert( - ident.clone(), - beef::ProjectEntry { - path, - ..Default::default() - }, - ); - ws.locked.insert(ident.clone()); + connect( + &manifest.package.name, + Some(&either::Left(manifest.package.version)), + path, + &pkgs, + &mut ws, + &mut ws_package_folder, + false, + )?; - ws.workspace_folders - .get_mut("Packages") - .unwrap() - .insert(ident.clone()); + ws.projects.get_mut(&manifest.package.name).unwrap().path = ".".into(); - if manifest - .dependencies - .contains_key(ident.rsplit_once('-').unwrap().0) - { - proj.dependencies.insert(ident, String::from("*")); - } + for ((pkg_name, pkg_version), pkg_path) in pkgs.iter() { + connect( + pkg_name, + Some(pkg_version), + pkg_path, + &pkgs, + &mut ws, + &mut ws_package_folder, + true, + )?; } + ws.workspace_folders + .insert(String::from("Packages"), ws_package_folder); fs::write(&ws_file_path, toml::to_string(&ws)?)?; - fs::write(&proj_file_path, toml::to_string(&proj)?)?; Ok(()) }, )?; if !silent { - println!("\n{:>13}{}Enjoy your meal!", " ", BEEF); + println!("\n{:>13}{}Enjoy your spaghetti!", " ", SPAGHETTI); } Ok(()) @@ -219,7 +264,7 @@ where F: FnOnce(&MultiProgress, &ProgressBar) -> Result, { let spinner_style = ProgressStyle::default_spinner() - .template("{msg} {spinner}") + .template("{msg} {spinner}")? .tick_chars("⠁⠂⠄⡀⢀⠠⠐⠈✔"); let progress = multi.insert( step as usize - 1, @@ -233,7 +278,7 @@ where .with_style(spinner_style), ); if !silent { - progress.enable_steady_tick(100); + progress.enable_steady_tick(Duration::from_millis(100)); } let result = func(multi, &progress)?; @@ -249,3 +294,184 @@ where Ok(result) } + +fn connect( + pkg_name: &str, + pkg_version: Option<&Either>, + pkg_path: &Path, + pkgs: &HashMap<(String, Either), PathBuf>, + ws: &mut beef::BeefSpace, + ws_package_folder: &mut HashSet, + is_pkg: bool, +) -> Result { + let manifest = Manifest::from_pkg(&pkg_path)?; + let mut proj = beef::BeefProj::from_file(&pkg_path.join("BeefProj.toml"))?; + proj.dependencies.clear(); + proj.dependencies + .insert(String::from("corlib"), String::from("*")); + + let pkg_ident = if let Some(pkg_version) = pkg_version { + match pkg_version { + either::Left(v) => format!("{}-{}", pkg_name, v), + either::Right(rev) => format!("{}-{}", pkg_name, rev), + } + } else { + pkg_name.to_owned() + }; + + 'dep_loop: for (name, dep) in manifest.dependencies.iter() { + if let manifest::Dependency::Local(local) = dep { + let dep_path = pkg_path.join(&local.path); + let dep_manifest = Manifest::from_pkg(&dep_path)?; + + let dep_ident = if std::fs::canonicalize(&dep_path)?.starts_with(pkg_path) { + // We are a root package + connect( + &format!("{}/{}", pkg_name, name), + None, + &dep_path, + pkgs, + ws, + ws_package_folder, + true, + )? + } else { + // We are a package inside a package + connect( + name, + Some(&either::Left(dep_manifest.package.version)), + &dep_path, + pkgs, + ws, + ws_package_folder, + true, + )? + }; + + proj.dependencies.insert(dep_ident, String::from("*")); + + continue; + } + + for ((pkg, version), path) in pkgs.iter() { + if pkg == name { + let mut features = None; + let mut default_features = false; + let add = match version { + either::Left(version) => { + if let manifest::Dependency::Simple(req) = dep { + req.matches(&version) + } else if let manifest::Dependency::Advanced(dep) = dep { + features = Some(&dep.features); + default_features = dep.default_features; + dep.req.matches(&version) + } else { + false + } + } + either::Right(rev) => { + if let manifest::Dependency::Git(dep) = dep { + &dep.rev == rev + } else { + false + } + } + }; + + if add { + let ident = match version { + either::Left(v) => format!("{}-{}", pkg, v), + either::Right(rev) => format!("{}-{}", pkg, rev), + }; + proj.dependencies.insert(ident, String::from("*")); + + if let Some(features) = features { + let dep_manifest = Manifest::from_pkg(path)?; + + let features: Box> = if default_features { + Box::new(features.iter().chain(dep_manifest.features.default.iter())) + } else { + Box::new(features.iter()) + }; + + for feature in features { + let feature_idents = + enable_feature(path, &feature, ws, ws_package_folder, pkgs)?; + proj.dependencies + .extend(feature_idents.into_iter().map(|i| (i, String::from("*")))); + } + } + + continue 'dep_loop; + } + } + } + + log::error!("{} missing dependency {}", pkg_name, name); + } + + if is_pkg { + ws.projects.insert( + pkg_ident.clone(), + beef::ProjectEntry { + path: pkg_path.to_path_buf(), + ..Default::default() + }, + ); + ws.locked.insert(pkg_ident.clone()); + ws_package_folder.insert(pkg_ident.clone()); + } else { + ws.projects.insert( + pkg_name.to_owned(), + beef::ProjectEntry { + path: pkg_path.to_path_buf(), + ..Default::default() + }, + ); + } + + proj.save()?; + + Ok(pkg_ident) +} + +fn enable_feature( + path: &Path, + feature: &str, + ws: &mut beef::BeefSpace, + ws_package_folder: &mut HashSet, + pkgs: &HashMap<(String, Either), PathBuf>, +) -> Result> { + let manifest = Manifest::from_pkg(path)?; + + if !manifest.features.optional.contains_key(feature) { + bail!("Unkown feature '{}' for {}", feature, manifest.package.name); + } + + let mut idents = Vec::new(); + match manifest.features.optional.get(feature).unwrap() { + manifest::Feature::List(sub_features) => { + for sub_feature in sub_features { + enable_feature(path, sub_feature, ws, ws_package_folder, pkgs)?; + } + } + manifest::Feature::Project(feature_path) => { + let ident = format!( + "{}-{}/{}", + manifest.package.name, manifest.package.version, feature + ); + connect( + &ident, + None, + &path.join(feature_path), + pkgs, + ws, + ws_package_folder, + true, + )?; + idents.push(ident); + } + } + + Ok(idents) +} diff --git a/src/paths.rs b/src/paths.rs index 65f3b0c..9ae9f59 100644 --- a/src/paths.rs +++ b/src/paths.rs @@ -3,18 +3,21 @@ use std::{ path::{Path, PathBuf}, }; -pub const PACKAGE_FILE: &'static str = "Package.toml"; -pub const LOCK_FILE: &'static str = "Package.lock"; +pub const MANIFEST_FILENAME: &'static str = "Package.toml"; +pub const LOCK_FILENAME: &'static str = "Package.lock"; -pub fn pkg

(pkg: P) -> PathBuf +pub fn pkg

(ws: &P, pkg: &P) -> PathBuf where - P: AsRef, + P: AsRef + ?Sized, { - pkgs().join(pkg) + pkgs(ws).join(pkg) } -pub fn pkgs() -> PathBuf { - ensure_exists(home().join("pkg")) +pub fn pkgs

(ws: &P) -> PathBuf +where + P: AsRef + ?Sized, +{ + ensure_exists(ws.as_ref().join("pkg")) } pub fn tmp() -> PathBuf { @@ -30,7 +33,7 @@ pub fn token() -> PathBuf { } pub fn home() -> PathBuf { - dirs::home_dir().unwrap().join(".grill") + ensure_exists(dirs::home_dir().unwrap().join(".grill")) } pub fn beeflibs() -> PathBuf { diff --git a/src/resolver.rs b/src/resolver.rs index a223e9f..78ea8df 100644 --- a/src/resolver.rs +++ b/src/resolver.rs @@ -1,135 +1,233 @@ -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; -use anyhow::{bail, Context, Result}; -use indexmap::IndexSet; +use anyhow::{anyhow, Result}; use itertools::Itertools; use semver::{Version, VersionReq}; use crate::{ - index::{self, Index}, + index::Index, lock::Lock, - manifest::Manifest, + manifest::{self, Manifest}, }; -pub fn resolve( - manifest: &Manifest, - lock: Option<&Lock>, -) -> Result>> { - let mut activated = HashMap::new(); - if let Some(lock) = lock { - activated.extend(lock.iter().filter_map(|(pkg, versions)| { - manifest.dependencies.get(pkg).and_then(|req| { - if versions.iter().any(|version| req.matches(version)) { - Some((pkg.as_str(), versions.clone())) - } else { - None - } - }) - })); - } +pub fn resolve(manifest: &Manifest, lock: Option<&Lock>, index: &Index) -> Result { + log::trace!( + "Resolving dependency tree{}", + if lock.is_some() { " with lock" } else { "" } + ); - let index = index::parse(false, false)?; - activate_deps( - &manifest.dependencies, - &mut activated, - &index, - &mut IndexSet::new(), - )?; - - Ok(activated - .into_iter() - .map(|(k, v)| (k.to_owned(), v)) - .collect()) -} - -fn activate<'a>( - dep: &'a str, - req: &VersionReq, - activated: &mut HashMap<&'a str, HashSet>, - index: &'a Index, - conflicts: &mut IndexSet<(&'a str, Version)>, -) -> Result { - let mut local_conflicts = IndexSet::new(); - - 'version_loop: for (version, metadata) in index - .get(dep) - .with_context(|| format!("Package not found: '{}'", dep))? - .versions + // Add the root dependencies. + let mut candidates: Vec = manifest + .dependencies .iter() - .filter(|(version, _)| { - req.matches(&version) && !conflicts.contains(&(dep, (*version).clone())) + .filter_map(|(name, dep)| { + if let manifest::Dependency::Simple(req) = dep { + Some(Candidate::new(name, req, index, lock)) + } else if let manifest::Dependency::Advanced(adv_dep) = dep { + Some(Candidate::new(name, &adv_dep.req, index, lock)) + } else { + None + } }) - .sorted_unstable_by(|(v1, _), (v2, _)| v2.cmp(&v1)) - { - if let Some(versions) = activated.get(dep) { - for v in versions.iter() { - if v.major == version.major && v.minor != version.minor { - local_conflicts.insert((dep, v.clone())); - continue 'version_loop; + .collect(); + + // We should not remove any candidates before this index. + let root_candidates_len = candidates.len(); + let mut i = 0; + let mut failed = false; + let mut complete = false; + + while !complete { + while let Some(mut candidate) = candidates.get(i).and_then(|v| Some(v.clone())) { + let mut next_version = None; + // The available versions are sorted so that the top element + // is always the latest version. + while let Some(version) = candidate.available_versions.pop() { + if !candidates + .iter() + .enumerate() + .filter(|&(idx, c)| c.version.is_some() && idx != i) + .any(|(_, i_candidate)| { + let i_version = i_candidate.version.as_ref().unwrap(); + // Two versions are conflicting if they have the same major version, + // but a different minor versions. I.e. '1.2.x' is conflicting with '1.3.x'. + // Different major versions for the same dependency is allowed. + // This is for convenience when using libraries together, + // as different versions can't be mixed. + let is_conflicting = i_candidate.name == candidate.name + && i_version.major == version.major + && i_version != &version; + + if is_conflicting { + log::trace!("Conflicting with: {} v{}", i_candidate.name, i_version); + } + + is_conflicting + }) + { + // This version matches the requirements and does not + // come into conflict with any previously selected versions. + next_version = Some(version); + break; } } + + if let Some(next_version) = next_version { + let deps = &index + .get(&candidate.name) + .unwrap() + .versions + .get(&next_version) + .unwrap() + .deps; + + candidates.extend( + deps.iter() + .map(|(dep, req)| Candidate::new(dep, req, index, lock)), + ); + + // "Commit" this candidate to the list of candidates. + // Will update the selected versions and the available versions left. + candidate.version = Some(next_version.clone()); + candidates[i] = candidate; + + i += 1; + } else { + if i >= root_candidates_len { + // There were conflicts while selecting a version for this dependency + // so we invalidate the rest of the candidates by removing them. + // This is important as the dependency tree might change when we + // backtrack, leaving unused dependencies. + candidates.truncate(i); + } else if i == 0 { + // There was no more versions left for the first + // dependency that satisfies the requirements. + failed = true; + break; + } else { + // We can't remove a root dependency so we just + // unset the version and make sure it is ready for + // picking another version. + candidates[i].version = None; + candidates[i].update_available_versions(index, lock); + } + + i -= 1; + } + } + + // All combinations have been tried. + // This manifest can't be resolved. + if failed { + break; } - activated - .entry(dep) - .or_insert(HashSet::new()) - .insert(version.clone()); + // When conflicts arise and we remove the invalidated candidates, + // some of the previous dependencies might not get re-iterated so + // that their dependencies are added as candidates again. + // We go over the candidate list again to make sure all dependencies + // are present and if not, we add the missing dependencies and restart + // resolution loop. + let mut missing_dependencies = Vec::new(); + for candidate in &candidates { + let deps = &index + .get(&candidate.name) + .unwrap() + .versions + .get(candidate.version.as_ref().unwrap()) + .unwrap() + .deps; - if activate_deps(&metadata.deps, activated, index, conflicts).is_err() { - if let Some(activated_versions) = activated.get_mut(dep) { - activated_versions.remove(&version); + for (dep, req) in deps { + if !candidates + .iter() + .filter(|&c| &c.name == dep) + .any(|c| req.matches(c.version.as_ref().unwrap())) + { + missing_dependencies.push((dep, req)); + } } - continue 'version_loop; } - return Ok(version.clone()); + if missing_dependencies.is_empty() { + // All dependencies are present so the resolution is ready, + // so we stop the resolution loop. + complete = true; + } else { + // We need to resolve the missing dependencies. + // The resolution loop will continue automatically. + log::trace!("{:?}", missing_dependencies); + candidates.extend( + missing_dependencies + .iter() + .map(|(dep, req)| Candidate::new(dep, req, index, lock)), + ); + } } - conflicts.extend(local_conflicts); + if failed { + log::trace!("Resolution failed"); + Err(anyhow!("Failed to resolve dependencies")) + } else { + let mut lock = Lock::new(); + lock.reserve(candidates.len()); + for candidate in candidates { + lock.entry(candidate.name) + .or_insert_with(|| HashSet::new()) + .insert(candidate.version.unwrap()); + } - bail!("No version satisfying requirement {} of {}", req, dep) + Ok(lock) + } } -fn activate_deps<'a>( - deps: &'a HashMap, - activated: &mut HashMap<&'a str, HashSet>, - index: &'a Index, - conflicts: &mut IndexSet<(&'a str, Version)>, -) -> Result<()> { - let mut i = 0; - let mut retry = true; - let mut result = Ok(()); - 'retry_loop: while i < 2 && retry { - i += 1; - retry = false; - result = Ok(()); - for (dep, req) in deps.iter() { - let conflicts_before = conflicts.len(); - if let Err(err) = activate(dep, req, activated, index, conflicts) { - let conflicts_after = conflicts.len(); - if conflicts_after > conflicts_before { - retry = true; - let conflicting = conflicts.last().unwrap(); - if let Some(activated_versions) = activated.get_mut(conflicting.0) { - activated_versions.remove(&conflicting.1); - } - } +#[derive(Clone)] +struct Candidate { + name: String, + req: VersionReq, + version: Option, + available_versions: Vec, +} - result = Err(err); - continue 'retry_loop; - } - } +impl Candidate { + pub fn new(name: &str, req: &VersionReq, index: &Index, lock: Option<&Lock>) -> Self { + let mut candidate = Self { + name: name.to_owned(), + req: req.clone(), + version: None, + available_versions: Vec::new(), + }; + candidate.update_available_versions(index, lock); + candidate } - result + pub fn update_available_versions(&mut self, index: &Index, lock: Option<&Lock>) { + self.available_versions.clear(); + if let Some(entry) = index.get(&self.name) { + self.available_versions.extend( + entry + .versions + .keys() + .filter(|v| self.req.matches(v)) + .map(|v| v.clone()) + .sorted_unstable_by(|v1, v2| v1.cmp(&v2)), + ); + } + + if let Some(version) = lock + .and_then(|lock| lock.get(&self.name)) + .and_then(|locked_versions| locked_versions.iter().find(|&v| self.req.matches(v))) + { + // Push the locked version to the top so it gets tried first. + self.available_versions.push(version.clone()); + } + } } #[cfg(test)] mod tests { - use std::{collections::HashMap, str::FromStr}; + use std::str::FromStr; - use indexmap::IndexSet; - use itertools::Itertools; use maplit::hashmap; use semver::{Version, VersionReq}; @@ -140,213 +238,77 @@ mod tests { #[test] fn basic() { - for _ in 0..1000 { - let index: Index = hashmap! { - String::from("a") => IndexEntry { - url: url::Url::parse("http://localhost").unwrap(), - versions: hashmap! { - Version::from_str("0.1.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("c") => VersionReq::from_str("=0.1.0").unwrap() - } - }, - Version::from_str("0.1.1").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("c") => VersionReq::from_str("=0.1.0").unwrap() - } - }, - Version::from_str("0.2.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("c") => VersionReq::from_str("0.2").unwrap() - } + let (manifest, index) = get_test_data(); + + simplelog::TermLogger::init( + log::LevelFilter::Debug, + Default::default(), + simplelog::TerminalMode::Stdout, + simplelog::ColorChoice::Auto, + ) + .unwrap(); + + super::resolve(&manifest, None, &index).unwrap(); + } + + fn get_test_data() -> (Manifest, Index) { + let index: Index = hashmap! { + String::from("b") => IndexEntry { + url: url::Url::parse("http://localhost").unwrap(), + versions: hashmap! { + Version::from_str("1.0.0").unwrap() => VersionMetadata { + rev: String::new(), + deps: hashmap! { + String::from("d") => VersionReq::from_str("=1.0").unwrap(), } - } - }, - String::from("b") => IndexEntry { - url: url::Url::parse("http://localhost").unwrap(), - versions: hashmap! { - Version::from_str("0.1.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("c") => VersionReq::from_str("=0.1.1").unwrap(), - String::from("d") => VersionReq::from_str("0.2").unwrap(), - } - }, - Version::from_str("0.1.1").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("c") => VersionReq::from_str("=0.1.1").unwrap(), - String::from("d") => VersionReq::from_str("0.2").unwrap(), - } - }, - Version::from_str("0.2.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("c") => VersionReq::from_str("=0.1.1").unwrap(), - String::from("d") => VersionReq::from_str("0.2").unwrap(), - } - }, - Version::from_str("0.3.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("c") => VersionReq::from_str("0.2").unwrap(), - String::from("d") => VersionReq::from_str("0.2").unwrap(), - } - }, - } - }, - String::from("c") => IndexEntry { - url: url::Url::parse("http://localhost").unwrap(), - versions: hashmap! { - Version::from_str("0.1.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("d") => VersionReq::from_str("0.1").unwrap(), - String::from("e") => VersionReq::from_str("0.1").unwrap(), - } - }, - Version::from_str("0.1.1").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("d") => VersionReq::from_str("0.1").unwrap(), - String::from("e") => VersionReq::from_str("0.1").unwrap(), - } - }, - Version::from_str("0.2.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("d") => VersionReq::from_str("0.1").unwrap(), - String::from("e") => VersionReq::from_str("0.1").unwrap(), - } - }, - Version::from_str("0.3.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("d") => VersionReq::from_str("0.2").unwrap(), - String::from("e") => VersionReq::from_str("0.1").unwrap(), - } - }, - Version::from_str("0.4.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("d") => VersionReq::from_str("0.2").unwrap(), - String::from("e") => VersionReq::from_str("0.1").unwrap(), - } - }, - } - }, - String::from("d") => IndexEntry { - url: url::Url::parse("http://localhost").unwrap(), - versions: hashmap! { - Version::from_str("0.1.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("e") => VersionReq::from_str("0.1").unwrap(), - } - }, - Version::from_str("0.1.1").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("e") => VersionReq::from_str("0.2").unwrap(), - } - }, - Version::from_str("0.2.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("e") => VersionReq::from_str("0.2").unwrap(), - } - }, - Version::from_str("0.2.1").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("e") => VersionReq::from_str("0.2").unwrap(), - } - }, - Version::from_str("0.2.2").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! { - String::from("e") => VersionReq::from_str("0.2").unwrap(), - } - }, - } - }, - String::from("e") => IndexEntry { - url: url::Url::parse("http://localhost").unwrap(), - versions: hashmap! { - Version::from_str("0.1.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! {} - }, - Version::from_str("0.1.1").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! {} - }, - Version::from_str("0.1.2").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! {} - }, - Version::from_str("0.2.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! {} - }, - Version::from_str("1.0.0").unwrap() => VersionMetadata { - rev: String::new(), - deps: hashmap! {} - }, - } - }, - }; - - let manifest = Manifest { - package: Package { - name: String::from("test"), - version: Version::new(0, 1, 0), - }, - dependencies: hashmap! { - String::from("c") => VersionReq::from_str("0.1").unwrap(), - String::from("d") => VersionReq::from_str("0.1").unwrap(), - String::from("e") => VersionReq::from_str("1.0").unwrap(), - }, - }; - - let mut activated = HashMap::new(); - let result = super::activate_deps( - &manifest.dependencies, - &mut activated, - &index, - &mut IndexSet::new(), - ); + }, + } + }, + String::from("c") => IndexEntry { + url: url::Url::parse("http://localhost").unwrap(), + versions: hashmap! { + Version::from_str("1.0.0").unwrap() => VersionMetadata { + rev: String::new(), + deps: hashmap! {} + }, + Version::from_str("1.1.0").unwrap() => VersionMetadata { + rev: String::new(), + deps: hashmap! { + String::from("d") => VersionReq::from_str("1.1").unwrap(), + } + }, + } + }, + String::from("d") => IndexEntry { + url: url::Url::parse("http://localhost").unwrap(), + versions: hashmap! { + Version::from_str("1.0.0").unwrap() => VersionMetadata { + rev: String::new(), + deps: hashmap! {} + }, + Version::from_str("1.1.0").unwrap() => VersionMetadata { + rev: String::new(), + deps: hashmap! {} + }, + } + }, + }; - assert!(result.is_ok(), "Activation failed!"); - - println!("{:#?}", activated); - - // The latest compatible version is not always selected. - // TODO: Fix - // let expected = hashmap! { - // "c" => HashSet::from_iter([Version::new(0, 1, 1)]), - // "d" => HashSet::from_iter([Version::new(0, 1, 0)]), - // "e" => HashSet::from_iter([Version::new(1, 0, 0), Version::new(0, 1, 2)]), - // }; - // assert!( - // activated.len() == expected.len() - // && activated.iter().all(|(k, v)| { - // if !expected.contains_key(k) { - // false - // } else { - // let expected_v = expected.get(k).unwrap(); - // expected_v.is_subset(v) && v.is_subset(expected_v) - // } - // }) - // ); - - assert!(activated.values().all(|vset| vset - .iter() - .map(|v| Version::new(v.major, v.minor, 0)) - .all_unique())); - } + let manifest = Manifest { + package: Package { + name: String::from("a"), + version: Version::new(1, 0, 0), + description: String::from(""), + corlib: true, + }, + dependencies: hashmap! { + String::from("b") => crate::manifest::Dependency::Simple(VersionReq::from_str("1.0").unwrap()), + String::from("c") => crate::manifest::Dependency::Simple(VersionReq::from_str("1.0").unwrap()), + String::from("d") => crate::manifest::Dependency::Simple(VersionReq::from_str("1.0").unwrap()), + }, + features: Default::default(), + }; + + (manifest, index) } } diff --git a/src/web.rs b/src/web.rs new file mode 100644 index 0000000..95867c4 --- /dev/null +++ b/src/web.rs @@ -0,0 +1,16 @@ +use reqwest::blocking::{Client, Response}; +use serde::Serialize; + +pub const API_BASE: &'static str = "http://grillpm.vercel.app/api"; + +pub fn api(sub: S, body: &B) -> anyhow::Result +where + S: AsRef, + B: Serialize, +{ + Client::new() + .post(format!("{}/{}", API_BASE, sub.as_ref())) + .json(body) + .send() + .map_err(anyhow::Error::msg) +}