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