feat: commit code

This commit is contained in:
mrxiaozhuox committed 2022-03-14 22:39:15 +08:00
1 parent 140d7ad7ed
commit 2e83822d41
5 files changed
+17 -3

No files matched your search

+2 -2
View File
@@ -1,12 +1,12 @@
[application]
# dioxus project name
name = "{{project-name}}"
name = "dioxus-cli"
# default platfrom
# you can also use `dioxus serve/build --platform XXX` to use other platform
# value: web | desktop
default_platform = "{{default-platform}}"
default_platform = "desktop"
# Web `build` & `serve` dist path
out_dir = "dist"
-1
View File
@@ -5,7 +5,6 @@ pub mod config;
pub mod create;
pub mod serve;
pub mod translate;
pub mod tools;
pub mod tool;
use crate::{
+2
View File
@@ -1,3 +1,5 @@
use crate::tools;
use super::*;
/// Build the Rust WASM app and all of its assets.
+2
View File
@@ -1,5 +1,7 @@
pub mod builder;
pub mod server;
pub mod tools;
pub use builder::*;
pub mod cargo;
+11
View File
@@ -47,6 +47,8 @@ pub fn tools_path() -> PathBuf {
#[allow(clippy::should_implement_trait)]
impl Tool {
/// from str to tool enum
pub fn from_str(name: &str) -> Option<Self> {
match name {
"binaryen" => Some(Self::Binaryen),
@@ -54,18 +56,21 @@ impl Tool {
}
}
/// get current tool name str
pub fn name(&self) -> &str {
match self {
Self::Binaryen => "binaryen",
}
}
/// get tool bin dir path
pub fn bin_path(&self) -> &str {
match self {
Self::Binaryen => "bin",
}
}
/// get target platform
pub fn target_platform(&self) -> &str {
match self {
Self::Binaryen => {
@@ -82,6 +87,7 @@ impl Tool {
}
}
/// get tool package download url
pub fn download_url(&self) -> String {
match self {
Self::Binaryen => {
@@ -93,20 +99,24 @@ impl Tool {
}
}
/// get package extension name
pub fn extension(&self) -> &str {
match self {
Self::Binaryen => "tar.gz",
}
}
/// check tool state
pub fn is_installed(&self) -> bool {
tools_path().join(self.name()).is_dir()
}
/// get download temp path
pub fn temp_out_path(&self) -> PathBuf {
temp_path().join(format!("{}-tool.tmp", self.name()))
}
/// start to download package
pub async fn download_package(&self) -> anyhow::Result<PathBuf> {
let download_url = self.download_url();
let temp_out = self.temp_out_path();
@@ -125,6 +135,7 @@ impl Tool {
Ok(temp_out)
}
/// start to install package
pub async fn install_package(&self) -> anyhow::Result<()> {
let temp_path = self.temp_out_path();
let tool_path = tools_path();