feat: v1.0.0
This commit is contained in:
439
Cargo.lock
generated
439
Cargo.lock
generated
@@ -60,6 +60,12 @@ dependencies = [
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "atomic-waker"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1505bd5d3d116872e7271a6d4e16d81d0c8570876c8de68093a09ac269d8aac0"
|
||||
|
||||
[[package]]
|
||||
name = "autocfg"
|
||||
version = "1.4.0"
|
||||
@@ -78,26 +84,20 @@ dependencies = [
|
||||
"miniz_oxide",
|
||||
"object",
|
||||
"rustc-demangle",
|
||||
"windows-targets 0.52.6",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.21.7"
|
||||
version = "0.22.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9d297deb1925b89f2ccc13d7635fa0714f12c87adce1c75356b39ca9b7178567"
|
||||
checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
version = "2.8.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1be3f42a67d6d345ecd59f675f3f012d6974981560836e938c22b424b85ce1be"
|
||||
checksum = "8f68f53c83ab957f72c32642f3868eec03eb974d1fb82e453128456482613d36"
|
||||
|
||||
[[package]]
|
||||
name = "block-buffer"
|
||||
@@ -122,9 +122,9 @@ checksum = "325918d6fe32f23b19878fe4b34794ae41fc19ddbe53b10571a4874d44ffd39b"
|
||||
|
||||
[[package]]
|
||||
name = "cc"
|
||||
version = "1.2.7"
|
||||
version = "1.2.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a012a0df96dd6d06ba9a1b29d6402d1a5d77c6befd2566afdc26e10603dc93d7"
|
||||
checksum = "13208fcbb66eaeffe09b99fffbe1af420f00a7b35aa99ad683dfc1aa76145229"
|
||||
dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
@@ -280,6 +280,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dff15bf788c671c1934e366d07e30c1814a8ef514e1af724a602e8a2fbe1b10"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -314,6 +315,7 @@ checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-io",
|
||||
"futures-sink",
|
||||
"futures-task",
|
||||
"memchr",
|
||||
"pin-project-lite",
|
||||
@@ -350,15 +352,15 @@ checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f"
|
||||
|
||||
[[package]]
|
||||
name = "h2"
|
||||
version = "0.3.26"
|
||||
version = "0.4.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8"
|
||||
checksum = "ccae279728d634d083c00f6099cb58f01cc99c145b84b8be2f6c74618d79922e"
|
||||
dependencies = [
|
||||
"atomic-waker",
|
||||
"bytes",
|
||||
"fnv",
|
||||
"futures-core",
|
||||
"futures-sink",
|
||||
"futures-util",
|
||||
"http",
|
||||
"indexmap",
|
||||
"slab",
|
||||
@@ -381,9 +383,9 @@ checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||
|
||||
[[package]]
|
||||
name = "http"
|
||||
version = "0.2.12"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1"
|
||||
checksum = "f16ca2af56261c99fba8bac40a10251ce8188205a4c448fbb745a2e4daa76fea"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"fnv",
|
||||
@@ -392,12 +394,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "http-body"
|
||||
version = "0.4.6"
|
||||
version = "1.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2"
|
||||
checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "http-body-util"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"pin-project-lite",
|
||||
]
|
||||
|
||||
@@ -407,47 +421,76 @@ version = "1.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7d71d3574edd2771538b901e6549113b4006ece66150fb69c0fb6d9a2adae946"
|
||||
|
||||
[[package]]
|
||||
name = "httpdate"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9"
|
||||
|
||||
[[package]]
|
||||
name = "hyper"
|
||||
version = "0.14.32"
|
||||
version = "1.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7"
|
||||
checksum = "256fb8d4bd6413123cc9d91832d78325c48ff41677595be797d90f42969beae0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"httparse",
|
||||
"httpdate",
|
||||
"itoa",
|
||||
"pin-project-lite",
|
||||
"smallvec",
|
||||
"tokio",
|
||||
"want",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-rustls"
|
||||
version = "0.27.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2"
|
||||
dependencies = [
|
||||
"futures-util",
|
||||
"http",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"rustls",
|
||||
"rustls-pki-types",
|
||||
"tokio",
|
||||
"tokio-rustls",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-tls"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "70206fc6890eaca9fde8a0bf71caa2ddfc9fe045ac9e5c70df101a7dbde866e0"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-util",
|
||||
"native-tls",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-util"
|
||||
version = "0.1.10"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df2dcfbe0677734ab2f3ffa7fa7bfd4706bfdc1ef393f2ee30184aed67e631b4"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"futures-channel",
|
||||
"futures-util",
|
||||
"http",
|
||||
"http-body",
|
||||
"hyper",
|
||||
"pin-project-lite",
|
||||
"socket2",
|
||||
"tokio",
|
||||
"tower-service",
|
||||
"tracing",
|
||||
"want",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "hyper-tls"
|
||||
version = "0.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905"
|
||||
dependencies = [
|
||||
"bytes",
|
||||
"hyper",
|
||||
"native-tls",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -613,9 +656,9 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
||||
|
||||
[[package]]
|
||||
name = "js-sys"
|
||||
version = "0.3.76"
|
||||
version = "0.3.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6717b6b5b077764fb5966237269cb3c64edddde4b14ce42647430a78ced9e7b7"
|
||||
checksum = "1cfaf33c695fc6e08064efbc1f72ec937429614f25eef83af942d0e227c3a28f"
|
||||
dependencies = [
|
||||
"once_cell",
|
||||
"wasm-bindgen",
|
||||
@@ -639,7 +682,7 @@ version = "0.1.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c0ff37bd590ca25063e35af745c343cb7a0271906fb7b37e4813e8f79f00268d"
|
||||
dependencies = [
|
||||
"bitflags 2.7.0",
|
||||
"bitflags",
|
||||
"libc",
|
||||
]
|
||||
|
||||
@@ -657,9 +700,9 @@ checksum = "4ee93343901ab17bd981295f2cf0026d4ad018c7c31ba84549a4ddbb47a45104"
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.22"
|
||||
version = "0.4.25"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24"
|
||||
checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
@@ -675,9 +718,9 @@ checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.2"
|
||||
version = "0.8.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4ffbe83022cedc1d264172192511ae958937694cd57ce297164951b8b3568394"
|
||||
checksum = "b8402cab7aefae129c6977bb0ff1b8fd9a04eb5b51efc50a70bea51cda0c7924"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
]
|
||||
@@ -731,7 +774,7 @@ version = "0.10.68"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5"
|
||||
dependencies = [
|
||||
"bitflags 2.7.0",
|
||||
"bitflags",
|
||||
"cfg-if",
|
||||
"foreign-types",
|
||||
"libc",
|
||||
@@ -795,9 +838,9 @@ checksum = "953ec861398dccce10c670dfeaf3ec4911ca479e9c02154b3a215178c5f566f2"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.92"
|
||||
version = "1.0.93"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37d3544b3f2748c54e147655edb5025752e2303145b5aefb3c3ea2c78b973bb0"
|
||||
checksum = "60946a68e5f9d28b0dc1c21bb8a97ee7d018a8b322fa57838ba31cc878e22d99"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
@@ -824,20 +867,24 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "reqwest"
|
||||
version = "0.11.27"
|
||||
version = "0.12.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dd67538700a17451e7cba03ac727fb961abb7607553461627b97de0b89cf4a62"
|
||||
checksum = "43e734407157c3c2034e0258f5e4473ddb361b1e85f95a66690d67264d7cd1da"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"bytes",
|
||||
"encoding_rs",
|
||||
"futures-channel",
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"h2",
|
||||
"http",
|
||||
"http-body",
|
||||
"http-body-util",
|
||||
"hyper",
|
||||
"hyper-rustls",
|
||||
"hyper-tls",
|
||||
"hyper-util",
|
||||
"ipnet",
|
||||
"js-sys",
|
||||
"log",
|
||||
@@ -854,17 +901,33 @@ dependencies = [
|
||||
"system-configuration",
|
||||
"tokio",
|
||||
"tokio-native-tls",
|
||||
"tower",
|
||||
"tower-service",
|
||||
"url",
|
||||
"wasm-bindgen",
|
||||
"wasm-bindgen-futures",
|
||||
"web-sys",
|
||||
"winreg",
|
||||
"windows-registry",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ring"
|
||||
version = "0.17.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c17fa4cb658e3583423e915b9f3acc01cceaee1860e33d59ebae66adc3a2dc0d"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"cfg-if",
|
||||
"getrandom",
|
||||
"libc",
|
||||
"spin",
|
||||
"untrusted",
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "runrs"
|
||||
version = "0.4.0"
|
||||
version = "1.0.0"
|
||||
dependencies = [
|
||||
"argh",
|
||||
"reqwest",
|
||||
@@ -904,7 +967,7 @@ version = "0.38.43"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a78891ee6bf2340288408954ac787aa063d8e8817e9f53abb37c695c6d834ef6"
|
||||
dependencies = [
|
||||
"bitflags 2.7.0",
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
@@ -912,12 +975,42 @@ dependencies = [
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pemfile"
|
||||
version = "1.0.4"
|
||||
name = "rustls"
|
||||
version = "0.23.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c74cae0a4cf6ccbbf5f359f08efdf8ee7e1dc532573bf0db71968cb56b1448c"
|
||||
checksum = "8f287924602bf649d949c63dc8ac8b235fa5387d394020705b80c4eb597ce5b8"
|
||||
dependencies = [
|
||||
"base64",
|
||||
"once_cell",
|
||||
"rustls-pki-types",
|
||||
"rustls-webpki",
|
||||
"subtle",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pemfile"
|
||||
version = "2.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dce314e5fee3f39953d46bb63bb8a46d40c2f8fb7cc5a3b6cab2bde9721d6e50"
|
||||
dependencies = [
|
||||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustls-pki-types"
|
||||
version = "1.10.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2bf47e6ff922db3825eb750c4e2ff784c6ff8fb9e13046ef6a1d1c5401b0b37"
|
||||
|
||||
[[package]]
|
||||
name = "rustls-webpki"
|
||||
version = "0.102.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "64ca1bc8749bd4cf37b5ce386cc146580777b4e8572c7b97baf22c83f444bee9"
|
||||
dependencies = [
|
||||
"ring",
|
||||
"rustls-pki-types",
|
||||
"untrusted",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -947,7 +1040,7 @@ version = "2.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "897b2245f0b511c87893af39b033e5ca9cce68824c4d7e7630b5a1d339658d02"
|
||||
dependencies = [
|
||||
"bitflags 2.7.0",
|
||||
"bitflags",
|
||||
"core-foundation",
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
@@ -1063,12 +1156,24 @@ dependencies = [
|
||||
"windows-sys 0.52.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "spin"
|
||||
version = "0.9.8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6980e8d7511241f8acf4aebddbb1ff938df5eebe98691418c4468d0b72a96a67"
|
||||
|
||||
[[package]]
|
||||
name = "stable_deref_trait"
|
||||
version = "1.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a8f112729512f8e442d81f95a8a7ddf2b7c6b8a1a6f509a95864142b30cab2d3"
|
||||
|
||||
[[package]]
|
||||
name = "subtle"
|
||||
version = "2.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.96"
|
||||
@@ -1082,9 +1187,12 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "sync_wrapper"
|
||||
version = "0.1.2"
|
||||
version = "1.0.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160"
|
||||
checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "synstructure"
|
||||
@@ -1099,20 +1207,20 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "system-configuration"
|
||||
version = "0.5.1"
|
||||
version = "0.6.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ba3a3adc5c275d719af8cb4272ea1c4a6d668a777f37e115f6d11ddbc1c8e0e7"
|
||||
checksum = "3c879d448e9d986b661742763247d3693ed13609438cf3d006f51f5368a5ba6b"
|
||||
dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"bitflags",
|
||||
"core-foundation",
|
||||
"system-configuration-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "system-configuration-sys"
|
||||
version = "0.5.0"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75fb188eb626b924683e3b95e3a48e63551fcfb51949de2f06a9d91dbee93c9"
|
||||
checksum = "8e1d1b10ced5ca923a1fcb8d03e96b8d3268065d724548c0211415ff6ac6bac4"
|
||||
dependencies = [
|
||||
"core-foundation-sys",
|
||||
"libc",
|
||||
@@ -1208,6 +1316,16 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-rustls"
|
||||
version = "0.26.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37"
|
||||
dependencies = [
|
||||
"rustls",
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tokio-util"
|
||||
version = "0.7.13"
|
||||
@@ -1221,6 +1339,27 @@ dependencies = [
|
||||
"tokio",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower"
|
||||
version = "0.5.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d039ad9159c98b70ecfd540b2573b97f7f52c3e8d9f8ad57a24b916a536975f9"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-util",
|
||||
"pin-project-lite",
|
||||
"sync_wrapper",
|
||||
"tokio",
|
||||
"tower-layer",
|
||||
"tower-service",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tower-layer"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "121c2a6cda46980bb0fcd1647ffaf6cd3fc79a013de288782836f6df9c48780e"
|
||||
|
||||
[[package]]
|
||||
name = "tower-service"
|
||||
version = "0.3.3"
|
||||
@@ -1264,6 +1403,12 @@ version = "1.0.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "adb9e6ca4f869e1180728b7950e35922a7fc6397f7b641499e8f3ef06e50dc83"
|
||||
|
||||
[[package]]
|
||||
name = "untrusted"
|
||||
version = "0.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1"
|
||||
|
||||
[[package]]
|
||||
name = "url"
|
||||
version = "2.5.4"
|
||||
@@ -1316,20 +1461,21 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen"
|
||||
version = "0.2.99"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a474f6281d1d70c17ae7aa6a613c87fce69a127e2624002df63dcb39d6cf6396"
|
||||
checksum = "1edc8929d7499fc4e8f0be2262a241556cfc54a0bea223790e71446f2aab1ef5"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"once_cell",
|
||||
"rustversion",
|
||||
"wasm-bindgen-macro",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-backend"
|
||||
version = "0.2.99"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "5f89bb38646b4f81674e8f5c3fb81b562be1fd936d84320f3264486418519c79"
|
||||
checksum = "2f0a0651a5c2bc21487bde11ee802ccaf4c51935d0d3d42a6101f98161700bc6"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"log",
|
||||
@@ -1341,9 +1487,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-futures"
|
||||
version = "0.4.49"
|
||||
version = "0.4.50"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "38176d9b44ea84e9184eff0bc34cc167ed044f816accfe5922e54d84cf48eca2"
|
||||
checksum = "555d470ec0bc3bb57890405e5d4322cc9ea83cebb085523ced7be4144dac1e61"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"js-sys",
|
||||
@@ -1354,9 +1500,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro"
|
||||
version = "0.2.99"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2cc6181fd9a7492eef6fef1f33961e3695e4579b9872a6f7c83aee556666d4fe"
|
||||
checksum = "7fe63fc6d09ed3792bd0897b314f53de8e16568c2b3f7982f468c0bf9bd0b407"
|
||||
dependencies = [
|
||||
"quote",
|
||||
"wasm-bindgen-macro-support",
|
||||
@@ -1364,9 +1510,9 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-macro-support"
|
||||
version = "0.2.99"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "30d7a95b763d3c45903ed6c81f156801839e5ee968bb07e534c44df0fcd330c2"
|
||||
checksum = "8ae87ea40c9f689fc23f209965b6fb8a99ad69aeeb0231408be24920604395de"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@@ -1377,15 +1523,18 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "wasm-bindgen-shared"
|
||||
version = "0.2.99"
|
||||
version = "0.2.100"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "943aab3fdaaa029a6e0271b35ea10b72b943135afe9bffca82384098ad0e06a6"
|
||||
checksum = "1a05d73b933a847d6cccdda8f838a22ff101ad9bf93e33684f39c1f5f0eece3d"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "web-sys"
|
||||
version = "0.3.76"
|
||||
version = "0.3.77"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "04dd7223427d52553d3702c004d3b2fe07c148165faa56313cb00211e31c12bc"
|
||||
checksum = "33b6dd2ef9186f1f2072e409e99cd22a975331a6b3591b12c764e0e55c60d5d2"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"wasm-bindgen",
|
||||
@@ -1414,12 +1563,33 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.48.0"
|
||||
name = "windows-registry"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9"
|
||||
checksum = "e400001bb720a623c1c69032f8e3e4cf09984deec740f007dd2b03ec864804b0"
|
||||
dependencies = [
|
||||
"windows-targets 0.48.5",
|
||||
"windows-result",
|
||||
"windows-strings",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-result"
|
||||
version = "0.2.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1d1043d8214f791817bab27572aaa8af63732e11bf84aa21a45a78d6c317ae0e"
|
||||
dependencies = [
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-strings"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4cd9b125c486025df0eabcb585e62173c6c9eddcec5d117d3b6e8c30e2ee4d10"
|
||||
dependencies = [
|
||||
"windows-result",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1428,7 +1598,7 @@ version = "0.52.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "282be5f36a8ce781fad8c8ae18fa3f9beff57ec1b52cb3de0789201425d9a33d"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1437,22 +1607,7 @@ version = "0.59.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
|
||||
dependencies = [
|
||||
"windows-targets 0.52.6",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-targets"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9a2fa6e2155d7247be68c096456083145c183cbbbc2764150dda45a87197940c"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.48.5",
|
||||
"windows_aarch64_msvc 0.48.5",
|
||||
"windows_i686_gnu 0.48.5",
|
||||
"windows_i686_msvc 0.48.5",
|
||||
"windows_x86_64_gnu 0.48.5",
|
||||
"windows_x86_64_gnullvm 0.48.5",
|
||||
"windows_x86_64_msvc 0.48.5",
|
||||
"windows-targets",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -1461,46 +1616,28 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9b724f72796e036ab90c1021d4780d4d3d648aca59e491e6b98e725b84e99973"
|
||||
dependencies = [
|
||||
"windows_aarch64_gnullvm 0.52.6",
|
||||
"windows_aarch64_msvc 0.52.6",
|
||||
"windows_i686_gnu 0.52.6",
|
||||
"windows_aarch64_gnullvm",
|
||||
"windows_aarch64_msvc",
|
||||
"windows_i686_gnu",
|
||||
"windows_i686_gnullvm",
|
||||
"windows_i686_msvc 0.52.6",
|
||||
"windows_x86_64_gnu 0.52.6",
|
||||
"windows_x86_64_gnullvm 0.52.6",
|
||||
"windows_x86_64_msvc 0.52.6",
|
||||
"windows_i686_msvc",
|
||||
"windows_x86_64_gnu",
|
||||
"windows_x86_64_gnullvm",
|
||||
"windows_x86_64_msvc",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2b38e32f0abccf9987a4e3079dfb67dcd799fb61361e53e2882c3cbaf0d905d8"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a4622180e7a0ec044bb555404c800bc9fd9ec262ec147edd5989ccd0c02cd3"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc35310971f3b2dbbf3f0690a219f40e2d9afcf64f9ab7cc1be722937c26b4bc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_aarch64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "09ec2a7bb152e2252b53fa7803150007879548bc709c039df7627cabbd05d469"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a75915e7def60c94dcef72200b9a8e58e5091744960da64ec734a6c6e9b3743e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_gnu"
|
||||
version = "0.52.6"
|
||||
@@ -1513,64 +1650,30 @@ version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0eee52d38c090b3caa76c563b86c3a4bd71ef1a819287c19d586d7334ae8ed66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8f55c233f70c4b27f66c523580f78f1004e8b5a8b659e05a4eb49d4166cca406"
|
||||
|
||||
[[package]]
|
||||
name = "windows_i686_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "240948bc05c5e7c6dabba28bf89d89ffce3e303022809e73deaefe4f6ec56c66"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "53d40abd2583d23e4718fddf1ebec84dbff8381c07cae67ff7768bbf19c6718e"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnu"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "147a5c80aabfbf0c7d901cb5895d1de30ef2907eb21fbbab29ca94c5b08b1a78"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b7b52767868a23d5bab768e390dc5f5c55825b6d30b86c844ff2dc7414044cc"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_gnullvm"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "24d5b23dc417412679681396f2b49f3de8c1473deb516bd34410872eff51ed0d"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.48.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed94fce61571a4006852b7389a063ab983c02eb1bb37b47f8272ce92d06d9538"
|
||||
|
||||
[[package]]
|
||||
name = "windows_x86_64_msvc"
|
||||
version = "0.52.6"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||
|
||||
[[package]]
|
||||
name = "winreg"
|
||||
version = "0.50.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "524e57b2c537c0f9b1e69f1965311ec12182b4122e45035b1508cd24d2adadb1"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-sys 0.48.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "write16"
|
||||
version = "1.0.0"
|
||||
@@ -1628,6 +1731,12 @@ dependencies = [
|
||||
"synstructure",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "zeroize"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ced3678a2879b30306d323f4542626697a464a97c0a07c9aebf7ebca65cd4dde"
|
||||
|
||||
[[package]]
|
||||
name = "zerovec"
|
||||
version = "0.10.4"
|
||||
|
||||
14
Cargo.toml
14
Cargo.toml
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "runrs"
|
||||
version = "0.4.0"
|
||||
version = "1.0.0"
|
||||
edition = "2018"
|
||||
license = "MIT/Apache-2.0"
|
||||
description = "A Tool for Run Rust Scripts"
|
||||
@@ -16,9 +16,9 @@ switch-ts-lang = []
|
||||
switch-dart-lang = []
|
||||
|
||||
[dependencies]
|
||||
reqwest = { version = "0.11.14", features = ["blocking"] }
|
||||
rust_util = "0.6.41"
|
||||
sha256 = "1.0.3"
|
||||
serde = { version = "1.0.193", features = ["derive"] }
|
||||
serde_json = "1.0.125"
|
||||
argh = "0.1.13"
|
||||
reqwest = { version = "0.12", features = ["blocking"] }
|
||||
rust_util = "0.6"
|
||||
sha256 = "1.0"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
argh = "0.1"
|
||||
|
||||
20
src/help.rs
Normal file
20
src/help.rs
Normal file
@@ -0,0 +1,20 @@
|
||||
pub fn print_help() {
|
||||
let help = get_help()
|
||||
.replace("{CARGO_PKG_NAME}", env!("CARGO_PKG_NAME"))
|
||||
.replace("{CARGO_PKG_VERSION}", env!("CARGO_PKG_VERSION"))
|
||||
.replace("{CARGO_PKG_DESCRIPTION}", env!("CARGO_PKG_DESCRIPTION"));
|
||||
println!("{}", help);
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
fn get_help() -> &'static str {
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
return include_str!("script.help.rust.txt");
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
return include_str!("script.help.go.txt");
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
return include_str!("script.help.ts.txt");
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
return include_str!("script.help.dart.txt");
|
||||
panic!("Unknown feature assigned.");
|
||||
}
|
||||
@@ -1,54 +1,39 @@
|
||||
use crate::util;
|
||||
use crate::util::ScriptMeta;
|
||||
use std::collections::BTreeMap;
|
||||
use std::fs;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use crate::util::{SCRIPT_DOT_EXT, SCRIPT_HYPHEN_EXT};
|
||||
use rust_util::util_os::get_user_home;
|
||||
pub fn install_scripts(arguments: &[String]) {
|
||||
if arguments.is_empty() {
|
||||
failure_and_exit!("No scripts assigned.");
|
||||
}
|
||||
let script_meta_map = util::fetch_script_meta_or_die();
|
||||
for (i, script_name) in arguments.iter().enumerate() {
|
||||
information!(
|
||||
"Installing script: {} [ {} / {} ]",
|
||||
script_name,
|
||||
(i + 1),
|
||||
arguments.len()
|
||||
);
|
||||
install_script(script_name, &script_meta_map);
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
const SCRIPT_PATTERN: &str =
|
||||
"https://git.hatter.ink/rust-scripts/scriptbase/raw/branch/main/$NAME/src/main.rs";
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
const SCRIPT_PATTERN: &str =
|
||||
"https://git.hatter.ink/hatter/go-scripts/raw/branch/main/$NAME/main.go";
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
const SCRIPT_PATTERN: &str =
|
||||
"https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/$NAME/main.ts";
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
const SCRIPT_PATTERN: &str =
|
||||
"https://git.hatter.ink/hatter/dart-scripts/raw/branch/main/$NAME/main.dart";
|
||||
|
||||
pub fn install_script(script_name: &str) {
|
||||
let normalized_script_name = if script_name.ends_with(SCRIPT_DOT_EXT) {
|
||||
script_name
|
||||
.chars()
|
||||
.take(script_name.len() - SCRIPT_DOT_EXT.len())
|
||||
.collect::<String>()
|
||||
+ SCRIPT_HYPHEN_EXT
|
||||
} else if script_name.ends_with(SCRIPT_HYPHEN_EXT) {
|
||||
script_name.to_string()
|
||||
} else {
|
||||
failure!("Invalid script name: {}", script_name);
|
||||
return;
|
||||
pub fn install_script(script_name: &str, script_meta_map: &BTreeMap<String, ScriptMeta>) {
|
||||
let script_meta = match script_meta_map.get(script_name) {
|
||||
None => {
|
||||
failure!("Script not found: {}", script_name);
|
||||
return;
|
||||
}
|
||||
Some(script_meta) => script_meta,
|
||||
};
|
||||
|
||||
let script_file_name = normalized_script_name
|
||||
.chars()
|
||||
.take(normalized_script_name.len() - SCRIPT_HYPHEN_EXT.len())
|
||||
.collect::<String>()
|
||||
+ SCRIPT_DOT_EXT;
|
||||
let user_home = get_user_home().expect("Get user home failed!");
|
||||
let output_file_name = PathBuf::from(&user_home)
|
||||
.join("bin")
|
||||
.join(&script_file_name);
|
||||
if output_file_name.exists() {
|
||||
warning!("Script file: {} exists", output_file_name.to_string_lossy());
|
||||
}
|
||||
|
||||
let script_url = SCRIPT_PATTERN.replace("$NAME", &normalized_script_name);
|
||||
let script_url = &script_meta.script_full_url;
|
||||
information!("Script URL: {}", &script_url);
|
||||
|
||||
let get_script_response_result = reqwest::blocking::get(&script_url);
|
||||
let get_script_response_result = reqwest::blocking::get(script_url);
|
||||
debugging!("Get script response: {:#?}", &get_script_response_result);
|
||||
|
||||
let get_script_response = match get_script_response_result {
|
||||
@@ -66,16 +51,22 @@ pub fn install_script(script_name: &str) {
|
||||
failure!("Get script failed: {}", get_script_response_status);
|
||||
return;
|
||||
}
|
||||
|
||||
let text = match get_script_response.text() {
|
||||
let remote_script_content = match get_script_response.text() {
|
||||
Err(e) => {
|
||||
failure!("Get script: {} failed: {}", &script_url, e);
|
||||
return;
|
||||
}
|
||||
Ok(text) => text,
|
||||
Ok(remote_script_content) => remote_script_content,
|
||||
};
|
||||
let user_home = util::get_user_home_or_die();
|
||||
let output_file_name = PathBuf::from(&user_home)
|
||||
.join("bin")
|
||||
.join(&script_meta.script_name);
|
||||
if output_file_name.exists() {
|
||||
warning!("Script file: {} exists", output_file_name.to_string_lossy());
|
||||
}
|
||||
if let Ok(script_content) = fs::read_to_string(&output_file_name) {
|
||||
if text == script_content {
|
||||
if remote_script_content == script_content {
|
||||
success!(
|
||||
"File is extract same, skip write file: {}",
|
||||
output_file_name.to_string_lossy()
|
||||
@@ -83,7 +74,7 @@ pub fn install_script(script_name: &str) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if let Err(e) = fs::write(&output_file_name, text) {
|
||||
if let Err(e) = fs::write(&output_file_name, remote_script_content) {
|
||||
failure!(
|
||||
"Write script: {} failed: {}",
|
||||
output_file_name.to_string_lossy(),
|
||||
|
||||
74
src/list.rs
74
src/list.rs
@@ -1,60 +1,22 @@
|
||||
use rust_util::util_os::get_user_home;
|
||||
use serde::Deserialize;
|
||||
use std::collections::BTreeMap;
|
||||
use crate::util;
|
||||
use std::fs;
|
||||
use std::path::PathBuf;
|
||||
use crate::util::{SCRIPT_DOT_EXT, SCRIPT_HYPHEN_EXT};
|
||||
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
const FILE_META: &str = "https://git.hatter.ink/rust-scripts/scriptbase/raw/branch/main/script-meta.json";
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
const FILE_META: &str = "https://git.hatter.ink/hatter/go-scripts/raw/branch/main/script-meta.json";
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
const FILE_META: &str = "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/script-meta.json";
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
const FILE_META: &str = "https://git.hatter.ink/hatter/dart-scripts/raw/branch/main/script-meta.json";
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct ScriptMeta {
|
||||
script_name: String,
|
||||
script_length: u64,
|
||||
script_sha256: String,
|
||||
}
|
||||
|
||||
pub fn list_scripts(filter: Option<&String>) {
|
||||
debugging!("Loading URL: {}", FILE_META);
|
||||
let response = reqwest::blocking::get(FILE_META).unwrap_or_else(|e| {
|
||||
failure_and_exit!("Get file-meta.json failed: {}", e);
|
||||
});
|
||||
debugging!("Load response: {}", response.status().as_u16());
|
||||
if response.status().as_u16() != 200 {
|
||||
failure_and_exit!("Get file-meta.json failed, status: {}", response.status().as_u16());
|
||||
}
|
||||
let text = response.text().unwrap_or_else(|e| {
|
||||
failure_and_exit!("Get file-meta.json failed: {}", e);
|
||||
});
|
||||
debugging!("Response text: {}", &text);
|
||||
|
||||
let user_home = get_user_home().expect("Get user home failed!");
|
||||
let script_meta_map: BTreeMap<String, ScriptMeta> = serde_json::from_str(&text).expect("Parse script-meta.json failed.");
|
||||
let script_meta_map = util::fetch_script_meta_or_die();
|
||||
|
||||
let mut messages = vec![];
|
||||
for (_, script_meta) in &script_meta_map {
|
||||
for script_meta in script_meta_map.values() {
|
||||
let script_name = &script_meta.script_name;
|
||||
let real_script_name = if script_name.ends_with(SCRIPT_HYPHEN_EXT) {
|
||||
script_name.chars().take(script_name.len() - SCRIPT_HYPHEN_EXT.len()).collect::<String>() + SCRIPT_DOT_EXT
|
||||
} else {
|
||||
script_name.to_string()
|
||||
};
|
||||
|
||||
if let Some(filter) = filter {
|
||||
if !real_script_name.contains(filter) {
|
||||
if !script_name.contains(filter) {
|
||||
// NOT CONTAINS `filter`, SKIP
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let full_script_path = PathBuf::from(&user_home).join("bin").join(&real_script_name);
|
||||
let user_home = util::get_user_home_or_die();
|
||||
let full_script_path = PathBuf::from(&user_home).join("bin").join(script_name);
|
||||
let is_script_exists = full_script_path.is_file();
|
||||
let script_sha256 = if is_script_exists {
|
||||
let script_content = fs::read(&full_script_path).unwrap_or(vec![]);
|
||||
@@ -64,18 +26,26 @@ pub fn list_scripts(filter: Option<&String>) {
|
||||
};
|
||||
let is_script_matches = script_sha256 == script_meta.script_sha256;
|
||||
let script_size = rust_util::util_size::get_display_size(script_meta.script_length as i64);
|
||||
let padding_length = 40 - real_script_name.len();
|
||||
messages.push(format!("- {} {} {} {}",
|
||||
iff!(is_script_exists, iff!(is_script_matches, "✅", "✔️ "), "➖"),
|
||||
real_script_name,
|
||||
".".repeat(iff!(padding_length < 1, 1, padding_length)),
|
||||
script_size,
|
||||
let padding_length = 40 - script_name.len();
|
||||
messages.push(format!(
|
||||
"- {} {} {} {}",
|
||||
iff!(is_script_exists, iff!(is_script_matches, "✅", "✔️ "), "➖"),
|
||||
script_name,
|
||||
".".repeat(iff!(padding_length < 1, 1, padding_length)),
|
||||
script_size,
|
||||
));
|
||||
}
|
||||
if filter.is_some() {
|
||||
messages.insert(0, format!("Total {} script(s), found {} script(s):", script_meta_map.len(), messages.len()));
|
||||
messages.insert(
|
||||
0,
|
||||
format!(
|
||||
"Total {} script(s), found {} script(s):",
|
||||
script_meta_map.len(),
|
||||
messages.len()
|
||||
),
|
||||
);
|
||||
} else {
|
||||
messages.insert(0, format!("Found {} script(s):", script_meta_map.len()));
|
||||
}
|
||||
success!("{}", messages.join("\n"));
|
||||
}
|
||||
}
|
||||
|
||||
90
src/main.rs
90
src/main.rs
@@ -3,36 +3,19 @@ extern crate rust_util;
|
||||
|
||||
use argh::FromArgs;
|
||||
use rust_util::util_os::get_user_home;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
use std::{env, fs};
|
||||
use std::env;
|
||||
|
||||
use crate::install::install_script;
|
||||
use crate::list::list_scripts;
|
||||
use crate::util::{
|
||||
build_script_command, get_run_script_bin_name, read_file_and_digest, run_script_command,
|
||||
};
|
||||
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
mod help_dart;
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
mod help_go;
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
mod help_ts;
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
mod help_rs;
|
||||
mod help;
|
||||
mod install;
|
||||
mod list;
|
||||
mod template;
|
||||
mod util;
|
||||
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
const CMD_NAME: &str = "runrs";
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
const CMD_NAME: &str = "rungo";
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
const CMD_NAME: &str = "runts";
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
const CMD_NAME: &str = "rundart";
|
||||
|
||||
#[derive(FromArgs, PartialEq, Debug)]
|
||||
/// Run script
|
||||
struct RunScriptArgs {
|
||||
@@ -60,22 +43,20 @@ fn main() {
|
||||
let rs_args: RunScriptArgs = argh::from_env();
|
||||
// println!("{:#?}", rs_args);
|
||||
|
||||
let cmd_name = util::get_cmd_name();
|
||||
let cmd_version = env!("CARGO_PKG_VERSION");
|
||||
if env::args().len() == 1 {
|
||||
failure_and_exit!(
|
||||
"{} v{}, need arguments, `{} -h` or `{} --help-message` for help",
|
||||
CMD_NAME,
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
CMD_NAME,
|
||||
CMD_NAME,
|
||||
"{cmd_name} v{cmd_version}, need arguments, `{cmd_name} -h` or `{cmd_name} --help-message` for help"
|
||||
);
|
||||
}
|
||||
|
||||
if rs_args.help_message {
|
||||
print_help();
|
||||
help::print_help();
|
||||
return;
|
||||
}
|
||||
if rs_args.template {
|
||||
print_template(&rs_args.output);
|
||||
template::print_template(&rs_args.output);
|
||||
return;
|
||||
}
|
||||
if rs_args.list {
|
||||
@@ -83,18 +64,7 @@ fn main() {
|
||||
return;
|
||||
}
|
||||
if rs_args.install {
|
||||
if rs_args.arguments.is_empty() {
|
||||
failure_and_exit!("No scripts assigned.");
|
||||
}
|
||||
for (i, script_name) in rs_args.arguments.iter().enumerate() {
|
||||
information!(
|
||||
"Installing script: {} [ {} / {} ]",
|
||||
script_name,
|
||||
(i + 1),
|
||||
rs_args.arguments.len()
|
||||
);
|
||||
install_script(script_name);
|
||||
}
|
||||
install::install_scripts(&rs_args.arguments);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -129,48 +99,6 @@ fn main() {
|
||||
run_script_command(script_file, &cache_script_bin_name, &mut run_script_cmd)
|
||||
}
|
||||
|
||||
fn print_help() {
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
help_rs::print_help();
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
help_go::print_help();
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
help_ts::print_help();
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
help_dart::print_help();
|
||||
}
|
||||
|
||||
fn print_template(output: &Option<String>) {
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
let script = include_str!("script.template.rs");
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
let script = include_str!("script.template.go");
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
let script = include_str!("script.template.ts");
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
let script = include_str!("script.template.dart");
|
||||
match output {
|
||||
None => {
|
||||
println!("{}", script);
|
||||
}
|
||||
Some(output_file) => {
|
||||
if fs::metadata(output_file).is_ok() {
|
||||
failure!("Output script file exists: {}", output_file);
|
||||
} else {
|
||||
match fs::write(output_file, script) {
|
||||
Ok(_) => {
|
||||
success!("Write script file success: {}", output_file);
|
||||
let _ = fs::set_permissions(&output_file, PermissionsExt::from_mode(0o755));
|
||||
}
|
||||
Err(e) => {
|
||||
failure!("Write script file: {}, failed: {}", output_file, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn get_cache_script_bin_name(user_home: &str, script_sha256: &str) -> String {
|
||||
#[cfg(target_os = "macos")]
|
||||
let cache_script_bin_name = format!(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
pub fn print_help() {
|
||||
println!(r##"rundart v{} - A Tool for Run dart Scripts
|
||||
rundart v{CARGO_PKG_VERSION} - A Tool for Run dart Scripts
|
||||
|
||||
Show help:
|
||||
$ rundart -h|--help
|
||||
@@ -12,8 +11,3 @@ $ rundart -l|--list
|
||||
|
||||
Install script:
|
||||
$ rundart -i|--install <script.dart>
|
||||
|
||||
"##,
|
||||
env!("CARGO_PKG_VERSION")
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
pub fn print_help() {
|
||||
println!(r##"rungo v{} - A Tool for Run Go Scripts
|
||||
rungo v{CARGO_PKG_VERSION} - A Tool for Run Go Scripts
|
||||
|
||||
Show help:
|
||||
$ rungo -h|--help
|
||||
@@ -14,8 +13,3 @@ Install script:
|
||||
$ rungo -i|--install <script.go>
|
||||
|
||||
Powered by gorun, know more reference: https://github.com/erning/gorun
|
||||
|
||||
"##,
|
||||
env!("CARGO_PKG_VERSION")
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
pub fn print_help() {
|
||||
println!(r##"{} v{} - {}
|
||||
runrs v{CARGO_PKG_VERSION} - {CARGO_PKG_DESCRIPTION}
|
||||
|
||||
Show help:
|
||||
$ runrs -h|--help
|
||||
@@ -31,9 +30,3 @@ Environment variables:
|
||||
│ RUNRS_MAX_SCRIPT_LEN │ Max script length, default 1MB │
|
||||
└──────────────────────┴────────────────────────────────────────────────┘
|
||||
> Type `bool`: `true`, `yes`, `on` or `1` for true, otherwise false
|
||||
"##,
|
||||
env!("CARGO_PKG_NAME"),
|
||||
env!("CARGO_PKG_VERSION"),
|
||||
env!("CARGO_PKG_DESCRIPTION")
|
||||
);
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
pub fn print_help() {
|
||||
println!(r##"runts v{} - A Tool for Run TS Scripts
|
||||
runts v{CARGO_PKG_VERSION} - A Tool for Run TS Scripts
|
||||
|
||||
Show help:
|
||||
$ runts -h|--help
|
||||
@@ -12,8 +11,3 @@ $ runts -l|--list
|
||||
|
||||
Install script:
|
||||
$ runts -i|--install <script.ts>
|
||||
|
||||
"##,
|
||||
env!("CARGO_PKG_VERSION")
|
||||
);
|
||||
}
|
||||
39
src/template.rs
Normal file
39
src/template.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use std::fs;
|
||||
use std::os::unix::fs::PermissionsExt;
|
||||
|
||||
pub fn print_template(output: &Option<String>) {
|
||||
let script = get_script_template();
|
||||
match output {
|
||||
None => {
|
||||
println!("{}", script);
|
||||
}
|
||||
Some(output_file) => {
|
||||
if fs::metadata(output_file).is_ok() {
|
||||
failure!("Output script file exists: {}", output_file);
|
||||
} else {
|
||||
match fs::write(output_file, script) {
|
||||
Ok(_) => {
|
||||
success!("Write script file success: {}", output_file);
|
||||
let _ = fs::set_permissions(output_file, PermissionsExt::from_mode(0o755));
|
||||
}
|
||||
Err(e) => {
|
||||
failure!("Write script file: {}, failed: {}", output_file, e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
fn get_script_template() -> &'static str {
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
return include_str!("script.template.rs");
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
return include_str!("script.template.go");
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
return include_str!("script.template.ts");
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
return include_str!("script.template.dart");
|
||||
panic!("Unknown feature assigned.");
|
||||
}
|
||||
164
src/util.rs
164
src/util.rs
@@ -1,36 +1,92 @@
|
||||
use rust_util::util_cmd;
|
||||
use rust_util::util_env::is_env_on;
|
||||
use rust_util::util_os::get_user_home;
|
||||
use serde::Deserialize;
|
||||
use std::collections::BTreeMap;
|
||||
use std::path::PathBuf;
|
||||
use std::process::Command;
|
||||
use std::time::SystemTime;
|
||||
use std::{env, fs, process};
|
||||
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
pub const SCRIPT_HYPHEN_EXT: &str = "-rs";
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
pub const SCRIPT_HYPHEN_EXT: &str = "-go";
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
pub const SCRIPT_HYPHEN_EXT: &str = "-ts";
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
pub const SCRIPT_HYPHEN_EXT: &str = "-dart";
|
||||
#[allow(dead_code)]
|
||||
#[derive(Deserialize)]
|
||||
pub struct ScriptMeta {
|
||||
pub script_name: String,
|
||||
pub script_length: u64,
|
||||
pub script_sha256: String,
|
||||
pub script_full_url: String,
|
||||
pub single_script_file: Option<bool>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
pub const SCRIPT_DOT_EXT: &str = ".rs";
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
pub const SCRIPT_DOT_EXT: &str = ".go";
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
pub const SCRIPT_DOT_EXT: &str = ".ts";
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
pub const SCRIPT_DOT_EXT: &str = ".dart";
|
||||
#[allow(unreachable_code)]
|
||||
pub fn get_script_meta_url() -> &'static str {
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
return "https://git.hatter.ink/rust-scripts/scriptbase/raw/branch/main/script-meta-v2.json";
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
return "https://git.hatter.ink/hatter/go-scripts/raw/branch/main/script-meta-v2.json";
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
return "https://git.hatter.ink/hatter/ts-scripts/raw/branch/main/script-meta-v2.json";
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
return "https://git.hatter.ink/hatter/dart-scripts/raw/branch/main/script-meta-v2.json";
|
||||
panic!("Unknown feature assigned.");
|
||||
}
|
||||
|
||||
#[allow(unreachable_code)]
|
||||
pub fn get_cmd_name() -> &'static str {
|
||||
#[cfg(feature = "switch-rust-lang")]
|
||||
return "runrs";
|
||||
#[cfg(feature = "switch-go-lang")]
|
||||
return "rungo";
|
||||
#[cfg(feature = "switch-ts-lang")]
|
||||
return "runts";
|
||||
#[cfg(feature = "switch-dart-lang")]
|
||||
return "rundart";
|
||||
panic!("Unknown feature assigned.");
|
||||
}
|
||||
|
||||
pub fn build_script_command(rust_script: PathBuf, script_file: &str, script_sha256: &str, cache_script_bin_name: &str) -> Command {
|
||||
pub fn fetch_script_meta_or_die() -> BTreeMap<String, ScriptMeta> {
|
||||
let file_meta_url = get_script_meta_url();
|
||||
debugging!("Loading URL: {}", file_meta_url);
|
||||
let response = reqwest::blocking::get(file_meta_url).unwrap_or_else(|e| {
|
||||
failure_and_exit!("Get file-meta.json failed: {}", e);
|
||||
});
|
||||
debugging!("Load response: {}", response.status().as_u16());
|
||||
if response.status().as_u16() != 200 {
|
||||
failure_and_exit!(
|
||||
"Get file-meta.json failed, status: {}",
|
||||
response.status().as_u16()
|
||||
);
|
||||
}
|
||||
let text = response.text().unwrap_or_else(|e| {
|
||||
failure_and_exit!("Get file-meta.json failed: {}", e);
|
||||
});
|
||||
debugging!("Response text: {}", &text);
|
||||
|
||||
let script_meta_map: BTreeMap<String, ScriptMeta> =
|
||||
serde_json::from_str(&text).expect("Parse script-meta.json failed.");
|
||||
script_meta_map
|
||||
}
|
||||
|
||||
pub fn get_user_home_or_die() -> String {
|
||||
get_user_home().expect("Get user home failed!")
|
||||
}
|
||||
|
||||
pub fn build_script_command(
|
||||
rust_script: PathBuf,
|
||||
script_file: &str,
|
||||
script_sha256: &str,
|
||||
cache_script_bin_name: &str,
|
||||
) -> Command {
|
||||
let skip_cache = is_env_on("RUNRS_SKIP_CACHE");
|
||||
let rebuild = is_env_on("RUNRS_REBUILD");
|
||||
let cache_script_bin_name_exists = fs::metadata(&cache_script_bin_name).is_ok();
|
||||
debugging!("Bin name: {} {}exists", cache_script_bin_name, iff!(cache_script_bin_name_exists, "", "not "));
|
||||
let cache_script_bin_name_exists = fs::metadata(cache_script_bin_name).is_ok();
|
||||
debugging!(
|
||||
"Bin name: {} {}exists",
|
||||
cache_script_bin_name,
|
||||
iff!(cache_script_bin_name_exists, "", "not ")
|
||||
);
|
||||
if !rebuild && !skip_cache && cache_script_bin_name_exists {
|
||||
Command::new(&cache_script_bin_name)
|
||||
Command::new(cache_script_bin_name)
|
||||
} else {
|
||||
let mut cmd = Command::new(rust_script);
|
||||
if !is_env_on("RUNRS_SILENT_BUILD") {
|
||||
@@ -40,37 +96,52 @@ pub fn build_script_command(rust_script: PathBuf, script_file: &str, script_sha2
|
||||
if rebuild {
|
||||
cmd.arg("--force");
|
||||
}
|
||||
cmd.args(&["--bin-name", &script_sha256, script_file]);
|
||||
cmd.args(["--bin-name", script_sha256, script_file]);
|
||||
cmd
|
||||
}
|
||||
}
|
||||
|
||||
pub fn run_script_command(script_file: &str, cache_script_bin_name: &str, mut run_script_cmd: &mut Command) -> ! {
|
||||
pub fn run_script_command(
|
||||
script_file: &str,
|
||||
cache_script_bin_name: &str,
|
||||
run_script_cmd: &mut Command,
|
||||
) -> ! {
|
||||
debugging!("Run command: {:?}", run_script_cmd);
|
||||
let run_command_start = SystemTime::now();
|
||||
match util_cmd::run_command_and_wait(&mut run_script_cmd) {
|
||||
match util_cmd::run_command_and_wait(run_script_cmd) {
|
||||
Err(e) => failure_and_exit!("Run rust-script failed: {}", e),
|
||||
Ok(exit_status) => {
|
||||
write_script_file_to_src(script_file, cache_script_bin_name);
|
||||
if let Ok(run_command_cost) = SystemTime::now().duration_since(run_command_start) {
|
||||
debugging!("Run command cost: {}ms", run_command_cost.as_millis());
|
||||
}
|
||||
process::exit(exit_status.code().unwrap_or_else(|| 0))
|
||||
process::exit(exit_status.code().unwrap_or(0))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn write_script_file_to_src(script_file: &str, cache_script_bin_name: &str) {
|
||||
if let Ok(Some(canonicalized_script_file)) = PathBuf::from(script_file)
|
||||
.canonicalize().map(|f| f.to_str().map(|f| f.to_string())) {
|
||||
.canonicalize()
|
||||
.map(|f| f.to_str().map(|f| f.to_string()))
|
||||
{
|
||||
let cache_script_bin_name_src = format!("{}.src", cache_script_bin_name);
|
||||
let src_content = fs::read_to_string(&cache_script_bin_name_src).ok();
|
||||
if src_content.as_ref().map(|c| c.contains(&canonicalized_script_file)).unwrap_or_else(|| false) {
|
||||
if src_content
|
||||
.as_ref()
|
||||
.map(|c| c.contains(&canonicalized_script_file))
|
||||
.unwrap_or_else(|| false)
|
||||
{
|
||||
return;
|
||||
}
|
||||
let new_src_content = src_content.unwrap_or_else(|| "".to_string()) + &format!("{}\n", canonicalized_script_file);
|
||||
if let Ok(_) = fs::write(&cache_script_bin_name_src, &new_src_content) {
|
||||
debugging!("Add {} to {}", canonicalized_script_file, cache_script_bin_name_src);
|
||||
let new_src_content = src_content.unwrap_or_else(|| "".to_string())
|
||||
+ &format!("{}\n", canonicalized_script_file);
|
||||
if fs::write(&cache_script_bin_name_src, &new_src_content).is_ok() {
|
||||
debugging!(
|
||||
"Add {} to {}",
|
||||
canonicalized_script_file,
|
||||
cache_script_bin_name_src
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -87,13 +158,20 @@ pub fn get_run_script_bin_name(home: &str) -> PathBuf {
|
||||
if !rust_script.exists() {
|
||||
warning!("rust-script not found, install it...");
|
||||
let mut cargo_install_rust_script = Command::new("cargo");
|
||||
cargo_install_rust_script.args(&["install", "--git", "https://git.hatter.ink/hatter/runrs", "rust-script"]);
|
||||
cargo_install_rust_script.args([
|
||||
"install",
|
||||
"--git",
|
||||
"https://git.hatter.ink/hatter/runrs",
|
||||
"rust-script",
|
||||
]);
|
||||
debugging!("Run command: {:?}", cargo_install_rust_script);
|
||||
match util_cmd::run_command_and_wait(&mut cargo_install_rust_script) {
|
||||
Err(e) => failure_and_exit!("Install rust-script failed: {}", e),
|
||||
Ok(exist_status) => if !exist_status.success() {
|
||||
failure!("Install rust-script not success: {}", exist_status);
|
||||
},
|
||||
Ok(exist_status) => {
|
||||
if !exist_status.success() {
|
||||
failure!("Install rust-script not success: {}", exist_status);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rust_script
|
||||
@@ -102,19 +180,21 @@ pub fn get_run_script_bin_name(home: &str) -> PathBuf {
|
||||
pub fn read_file_and_digest(script_file: &str) -> (String, String) {
|
||||
let default_max_script_len = 1024 * 1024;
|
||||
let max_script_len: u64 = env::var("RUNRS_MAX_SCRIPT_LEN")
|
||||
.map(|len| len.parse().unwrap_or_else(|_| default_max_script_len)).unwrap_or_else(|_| default_max_script_len);
|
||||
.map(|len| len.parse().unwrap_or(default_max_script_len))
|
||||
.unwrap_or(default_max_script_len);
|
||||
match fs::metadata(script_file) {
|
||||
Err(_) => failure_and_exit!("Script file not exists: {}", script_file),
|
||||
Ok(metadata) => if metadata.is_dir() {
|
||||
failure_and_exit!("Assigned input is dir: {}", script_file);
|
||||
} else if metadata.len() > max_script_len {
|
||||
failure_and_exit!("Script file: {} too large: {}", script_file, metadata.len());
|
||||
Ok(metadata) => {
|
||||
if metadata.is_dir() {
|
||||
failure_and_exit!("Assigned input is dir: {}", script_file);
|
||||
} else if metadata.len() > max_script_len {
|
||||
failure_and_exit!("Script file: {} too large: {}", script_file, metadata.len());
|
||||
}
|
||||
}
|
||||
}
|
||||
let script_content = fs::read_to_string(script_file).unwrap_or_else(|e|
|
||||
failure_and_exit!("Read file: {}, failed: {}", script_file, e)
|
||||
);
|
||||
let script_content = fs::read_to_string(script_file)
|
||||
.unwrap_or_else(|e| failure_and_exit!("Read file: {}, failed: {}", script_file, e));
|
||||
let script_sha256 = sha256::digest(script_content.as_str());
|
||||
|
||||
(script_content, script_sha256)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user