|
@@ -13,15 +13,10 @@ use tokio::io::AsyncWriteExt;
|
|
|
|
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
#[derive(Debug, PartialEq, Eq)]
|
|
pub enum Tool {
|
|
pub enum Tool {
|
|
- Binaryen,
|
|
|
|
Sass,
|
|
Sass,
|
|
Tailwind,
|
|
Tailwind,
|
|
}
|
|
}
|
|
|
|
|
|
-// pub fn tool_list() -> Vec<&'static str> {
|
|
|
|
-// vec!["binaryen", "sass", "tailwindcss"]
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
pub fn app_path() -> PathBuf {
|
|
pub fn app_path() -> PathBuf {
|
|
let data_local = dirs::data_local_dir().unwrap();
|
|
let data_local = dirs::data_local_dir().unwrap();
|
|
let dioxus_dir = data_local.join("dioxus");
|
|
let dioxus_dir = data_local.join("dioxus");
|
|
@@ -70,7 +65,6 @@ impl Tool {
|
|
/// from str to tool enum
|
|
/// 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),
|
|
|
|
"sass" => Some(Self::Sass),
|
|
"sass" => Some(Self::Sass),
|
|
"tailwindcss" => Some(Self::Tailwind),
|
|
"tailwindcss" => Some(Self::Tailwind),
|
|
_ => None,
|
|
_ => None,
|
|
@@ -80,7 +74,6 @@ impl Tool {
|
|
/// get current tool name str
|
|
/// get current tool name str
|
|
pub fn name(&self) -> &str {
|
|
pub fn name(&self) -> &str {
|
|
match self {
|
|
match self {
|
|
- Self::Binaryen => "binaryen",
|
|
|
|
Self::Sass => "sass",
|
|
Self::Sass => "sass",
|
|
Self::Tailwind => "tailwindcss",
|
|
Self::Tailwind => "tailwindcss",
|
|
}
|
|
}
|
|
@@ -89,7 +82,6 @@ impl Tool {
|
|
/// get tool bin dir path
|
|
/// 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::Sass => ".",
|
|
Self::Sass => ".",
|
|
Self::Tailwind => ".",
|
|
Self::Tailwind => ".",
|
|
}
|
|
}
|
|
@@ -98,17 +90,6 @@ impl Tool {
|
|
/// get target platform
|
|
/// get target platform
|
|
pub fn target_platform(&self) -> &str {
|
|
pub fn target_platform(&self) -> &str {
|
|
match self {
|
|
match self {
|
|
- Self::Binaryen => {
|
|
|
|
- if cfg!(target_os = "windows") {
|
|
|
|
- "windows"
|
|
|
|
- } else if cfg!(target_os = "macos") {
|
|
|
|
- "macos"
|
|
|
|
- } else if cfg!(target_os = "linux") {
|
|
|
|
- "linux"
|
|
|
|
- } else {
|
|
|
|
- panic!("unsupported platformm");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
Self::Sass => {
|
|
Self::Sass => {
|
|
if cfg!(target_os = "windows") {
|
|
if cfg!(target_os = "windows") {
|
|
"windows"
|
|
"windows"
|
|
@@ -137,7 +118,6 @@ impl Tool {
|
|
/// get tool version
|
|
/// get tool version
|
|
pub fn tool_version(&self) -> &str {
|
|
pub fn tool_version(&self) -> &str {
|
|
match self {
|
|
match self {
|
|
- Self::Binaryen => "version_105",
|
|
|
|
Self::Sass => "1.51.0",
|
|
Self::Sass => "1.51.0",
|
|
Self::Tailwind => "v3.1.6",
|
|
Self::Tailwind => "v3.1.6",
|
|
}
|
|
}
|
|
@@ -146,13 +126,6 @@ impl Tool {
|
|
/// get tool package download url
|
|
/// get tool package download url
|
|
pub fn download_url(&self) -> String {
|
|
pub fn download_url(&self) -> String {
|
|
match self {
|
|
match self {
|
|
- Self::Binaryen => {
|
|
|
|
- format!(
|
|
|
|
- "https://github.com/WebAssembly/binaryen/releases/download/{version}/binaryen-{version}-x86_64-{target}.tar.gz",
|
|
|
|
- version = self.tool_version(),
|
|
|
|
- target = self.target_platform()
|
|
|
|
- )
|
|
|
|
- }
|
|
|
|
Self::Sass => {
|
|
Self::Sass => {
|
|
format!(
|
|
format!(
|
|
"https://github.com/sass/dart-sass/releases/download/{version}/dart-sass-{version}-{target}-x64.{extension}",
|
|
"https://github.com/sass/dart-sass/releases/download/{version}/dart-sass-{version}-{target}-x64.{extension}",
|
|
@@ -179,7 +152,6 @@ impl Tool {
|
|
/// get package extension name
|
|
/// get package extension name
|
|
pub fn extension(&self) -> &str {
|
|
pub fn extension(&self) -> &str {
|
|
match self {
|
|
match self {
|
|
- Self::Binaryen => "tar.gz",
|
|
|
|
Self::Sass => {
|
|
Self::Sass => {
|
|
if cfg!(target_os = "windows") {
|
|
if cfg!(target_os = "windows") {
|
|
"zip"
|
|
"zip"
|
|
@@ -226,7 +198,6 @@ impl Tool {
|
|
let tool_path = tools_path();
|
|
let tool_path = tools_path();
|
|
|
|
|
|
let dir_name = match self {
|
|
let dir_name = match self {
|
|
- Self::Binaryen => format!("binaryen-{}", self.tool_version()),
|
|
|
|
Self::Sass => "dart-sass".to_string(),
|
|
Self::Sass => "dart-sass".to_string(),
|
|
Self::Tailwind => self.name().to_string(),
|
|
Self::Tailwind => self.name().to_string(),
|
|
};
|
|
};
|
|
@@ -281,13 +252,6 @@ impl Tool {
|
|
let bin_path = tools_path().join(self.name()).join(self.bin_path());
|
|
let bin_path = tools_path().join(self.name()).join(self.bin_path());
|
|
|
|
|
|
let command_file = match self {
|
|
let command_file = match self {
|
|
- Tool::Binaryen => {
|
|
|
|
- if cfg!(target_os = "windows") {
|
|
|
|
- format!("{}.exe", command)
|
|
|
|
- } else {
|
|
|
|
- command.to_string()
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
Tool::Sass => {
|
|
Tool::Sass => {
|
|
if cfg!(target_os = "windows") {
|
|
if cfg!(target_os = "windows") {
|
|
format!("{}.bat", command)
|
|
format!("{}.bat", command)
|