feat: commit code
This commit is contained in:
1 parent
91a8ce3169
commit
5fb1b3e20b
4 files changed
+79
-2
No files matched your search
+6
-1
@@ -9,10 +9,12 @@ license = "MIT/Apache-2.0"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
|
|
||||||
# cli core
|
# cli core
|
||||||
clap = {version = "3.0.14", features = ["derive"]}
|
clap = {version = "3.0.14", features = ["derive"]}
|
||||||
thiserror = "1.0.30"
|
thiserror = "1.0.30"
|
||||||
wasm-bindgen-cli-support = "0.2.79"
|
wasm-bindgen-cli-support = "0.2.79"
|
||||||
|
|
||||||
# features
|
# features
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
fern = { version = "0.6.0", features = ["colored"] }
|
fern = { version = "0.6.0", features = ["colored"] }
|
||||||
@@ -37,7 +39,10 @@ hyper = "0.14.17"
|
|||||||
axum = { version = "0.4.5", features = ["ws", "headers"] }
|
axum = { version = "0.4.5", features = ["ws", "headers"] }
|
||||||
tower-http = { version = "0.2.2", features = ["fs", "trace"] }
|
tower-http = { version = "0.2.2", features = ["fs", "trace"] }
|
||||||
headers = "0.3.7"
|
headers = "0.3.7"
|
||||||
# hyper = { version = "0.14.11", features = ["full"] }
|
|
||||||
|
# tools download
|
||||||
|
dirs = "4.0.0"
|
||||||
|
reqwest = { version = "0.11", features = ["json"] }
|
||||||
|
|
||||||
[[bin]]
|
[[bin]]
|
||||||
path = "src/main.rs"
|
path = "src/main.rs"
|
||||||
|
|||||||
@@ -36,4 +36,6 @@ script = []
|
|||||||
|
|
||||||
# Javascript code file
|
# Javascript code file
|
||||||
# serve: [dev-server] only
|
# serve: [dev-server] only
|
||||||
script = []
|
script = []
|
||||||
|
|
||||||
|
[web.tools]
|
||||||
@@ -5,6 +5,7 @@ pub mod config;
|
|||||||
pub mod create;
|
pub mod create;
|
||||||
pub mod serve;
|
pub mod serve;
|
||||||
pub mod translate;
|
pub mod translate;
|
||||||
|
pub mod tools;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
cfg::{ConfigOptsBuild, ConfigOptsServe},
|
cfg::{ConfigOptsBuild, ConfigOptsServe},
|
||||||
|
|||||||
@@ -0,0 +1,69 @@
|
|||||||
|
use std::path::PathBuf;
|
||||||
|
|
||||||
|
pub enum Tool {
|
||||||
|
WasmOpt,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn app_path() {
|
||||||
|
let data_local = dirs::data_local_dir().unwrap();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Tool {
|
||||||
|
pub fn name(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
Self::WasmOpt => "wasm-opt",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn bin_path(&self) -> &str {
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
match self {
|
||||||
|
Self::WasmOpt => "bin/wasm-opt.exe",
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
match self {
|
||||||
|
Self::WasmOpt => "bin/wasm-opt",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn target_platform(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
Self::WasmOpt => {
|
||||||
|
if cfg!(target_os = "windows") {
|
||||||
|
"windows"
|
||||||
|
} else if cfg!(target_os = "macos") {
|
||||||
|
"macos"
|
||||||
|
} else if cfg!(target_os = "linux") {
|
||||||
|
"linux"
|
||||||
|
} else {
|
||||||
|
panic!("unsupported platformm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn download_url(&self) -> String {
|
||||||
|
match self {
|
||||||
|
Self::WasmOpt => {
|
||||||
|
format!(
|
||||||
|
"https://github.com/WebAssembly/binaryen/releases/download/version_105/binaryen-version_105-x86_64-{target}.tar.gz",
|
||||||
|
target = self.target_platform()
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn download_package(&self) {
|
||||||
|
|
||||||
|
let download_dir = dirs::download_dir().unwrap();
|
||||||
|
let download_url = self.download_url();
|
||||||
|
|
||||||
|
let resp = reqwest::get(download_url).await.unwrap();
|
||||||
|
|
||||||
|
resp.
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in new issue
Block a user