-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update to tauri v2 stable (#806)
* feat: update to tauri v2 stable - removed the --alpha, --beta, --rc flag - added a --version option to change tauri version - default to v2 stable * update ci * fix eq helper usage * fix test * not using handlebars * clippy * fix linux build * format * missing comma * fix template * fix template usage again * -t is already taken * fmt * fix no_bundle_flag
- Loading branch information
1 parent
04d1d5a
commit 1130b7b
Showing
61 changed files
with
221 additions
and
172 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"create-tauri-app": minor | ||
"create-tauri-app-js": minor | ||
--- | ||
|
||
Update to v2 stable, meaning the `--alpha`, `--beta`, `--rc` flags are removed, and added a `--tauri-version [1|2]` option to change the Tauri version (defaults to latest stable - v2). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,45 @@ | |
// SPDX-License-Identifier: Apache-2.0 | ||
// SPDX-License-Identifier: MIT | ||
|
||
use std::ffi::OsString; | ||
use std::{ffi::OsString, fmt::Display, str::FromStr}; | ||
|
||
use pico_args::Arguments; | ||
|
||
use crate::{package_manager::PackageManager, template::Template, utils::colors::*}; | ||
|
||
#[derive(Debug, Copy, Clone, Default, PartialEq, Eq)] | ||
pub enum TauriVersion { | ||
V1, | ||
#[default] | ||
V2, | ||
} | ||
|
||
impl TauriVersion { | ||
pub fn all() -> &'static [TauriVersion] { | ||
&[TauriVersion::V1, TauriVersion::V2] | ||
} | ||
} | ||
|
||
impl Display for TauriVersion { | ||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { | ||
match self { | ||
Self::V1 => write!(f, "1"), | ||
Self::V2 => write!(f, "2"), | ||
} | ||
} | ||
} | ||
|
||
impl FromStr for TauriVersion { | ||
type Err = &'static str; | ||
fn from_str(s: &str) -> Result<Self, Self::Err> { | ||
match s { | ||
"1" => Ok(Self::V1), | ||
"2" => Ok(Self::V1), | ||
_ => Err("unknown Tauri version"), | ||
} | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct Args { | ||
pub project_name: Option<String>, | ||
|
@@ -16,7 +49,7 @@ pub struct Args { | |
pub identifier: Option<String>, | ||
pub skip: bool, | ||
pub force: bool, | ||
pub rc: bool, | ||
pub tauri_version: TauriVersion, | ||
} | ||
|
||
impl Default for Args { | ||
|
@@ -28,7 +61,7 @@ impl Default for Args { | |
template: Some(Template::Vanilla), | ||
skip: false, | ||
force: false, | ||
rc: false, | ||
tauri_version: TauriVersion::default(), | ||
} | ||
} | ||
} | ||
|
@@ -55,7 +88,7 @@ pub fn parse(argv: Vec<OsString>, bin_name: Option<String>) -> anyhow::Result<Ar | |
{GREEN}--identifier <identifier>{RESET} Specify a unique identifier for your application | ||
{GREEN}-y{RESET}, {GREEN}--yes{RESET} Skip prompts and use defaults where applicable | ||
{GREEN}-f{RESET}, {GREEN}--force{RESET} Force create the directory even if it is not empty. | ||
{GREEN}--rc{RESET} Bootstraps a project using [email protected]. | ||
{GREEN}--tauri-version [1 | 2]{RESET} Bootstrap a project using the provided Tauri version. Defaults to the latest stable release. | ||
{GREEN}-h{RESET}, {GREEN}--help{RESET} Prints help information | ||
{GREEN}-v{RESET}, {GREEN}--version{RESET} Prints version information | ||
"#, | ||
|
@@ -83,27 +116,14 @@ pub fn parse(argv: Vec<OsString>, bin_name: Option<String>) -> anyhow::Result<Ar | |
std::process::exit(0); | ||
} | ||
|
||
// pargs.contains() consume the flag so we have to bind the bool to a variable. | ||
let rc = if pargs.contains("--alpha") { | ||
eprintln!( | ||
"{BOLD}{YELLOW}warning{RESET}: The `{GREEN}--alpha{RESET}` option is now an alias for `{GREEN}--rc{RESET}` and may be removed in the future." | ||
); | ||
true | ||
} else if pargs.contains("--beta") { | ||
eprintln!( | ||
"{BOLD}{YELLOW}warning{RESET}: The `{GREEN}--beta{RESET}` option is now an alias for `{GREEN}--rc{RESET}` and may be removed in the future." | ||
); | ||
true | ||
} else { | ||
pargs.contains("--rc") | ||
}; | ||
let tauri_version: Option<TauriVersion> = pargs.opt_value_from_str("--tauri-version")?; | ||
|
||
let args = Args { | ||
manager: pargs.opt_value_from_str(["-m", "--manager"])?, | ||
template: pargs.opt_value_from_str(["-t", "--template"])?, | ||
skip: pargs.contains(["-y", "--yes"]), | ||
force: pargs.contains(["-f", "--force"]), | ||
rc, | ||
tauri_version: tauri_version.unwrap_or_default(), | ||
identifier: pargs.opt_value_from_str("--identifier")?, | ||
project_name: pargs.opt_free_from_str()?, | ||
}; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.