From 87535abcb2b6443000292dcdf2762742ef5ee103 Mon Sep 17 00:00:00 2001 From: Jason Tsai Date: Thu, 16 May 2024 15:00:34 +0800 Subject: [PATCH 01/22] fix(android): allows and escape kotlin only keyword as identifier --- src/config/app/domain.rs | 17 +------ src/templating/init.rs | 44 +++++++++++++++++++ .../MainActivity.kt.hbs | 3 +- 3 files changed, 48 insertions(+), 16 deletions(-) diff --git a/src/config/app/domain.rs b/src/config/app/domain.rs index 03d6ad95..4d1dca27 100644 --- a/src/config/app/domain.rs +++ b/src/config/app/domain.rs @@ -3,9 +3,8 @@ use std::error::Error; use std::fmt; static RESERVED_PACKAGE_NAMES: [&str; 2] = ["kotlin", "java"]; -static RESERVED_KEYWORDS: [&str; 63] = [ +static RESERVED_JAVA_KEYWORDS: [&str; 50] = [ "abstract", - "as", "assert", "boolean", "break", @@ -22,26 +21,20 @@ static RESERVED_KEYWORDS: [&str; 63] = [ "else", "enum", "extends", - "false", "final", "finally", "float", "for", - "fun", "goto", "if", "implements", "import", "instanceof", - "in", "int", "interface", - "is", "long", "native", "new", - "null", - "object", "package", "private", "protected", @@ -57,15 +50,9 @@ static RESERVED_KEYWORDS: [&str; 63] = [ "throw", "throws", "transient", - "true", "try", - "typealias", - "typeof", - "val", - "var", "void", "volatile", - "when", "while", ]; @@ -129,7 +116,7 @@ pub fn check_domain_syntax(domain_name: &str) -> Result<(), DomainError> { if label.is_empty() { return Err(DomainError::EmptyLabel); } - if RESERVED_KEYWORDS.contains(&label) { + if RESERVED_JAVA_KEYWORDS.contains(&label) { return Err(DomainError::ReservedKeyword { keyword: label.to_owned(), }); diff --git a/src/templating/init.rs b/src/templating/init.rs index b903b29f..85bb8e64 100644 --- a/src/templating/init.rs +++ b/src/templating/init.rs @@ -122,6 +122,46 @@ fn reverse_domain_snake_case( .map_err(Into::into) } +fn reverse_domain_escape_kotlin_keyword( + helper: &Helper, + _: &Handlebars, + _: &Context, + _: &mut RenderContext, + out: &mut dyn Output, +) -> HelperResult { + let rev_domain = util::reverse_domain(get_str(helper)); + dbg!(&rev_domain); + let result = rev_domain + .split('.') + .map(|s| { + let should_escaped_words: &[&str] = &[ + "as", + "false", + "fun", + "in", + "is", + "null", + "object", + "true", + "typealias", + "typeof", + "val", + "var", + "when", + ]; + if should_escaped_words.contains(&s) { + dbg!("escaped", &s); + format!("`{}`", s) + } else { + dbg!("not escaped", &s); + s.to_string() + } + }) + .collect::>() + .join("."); + out.write(&result).map_err(Into::into) +} + fn app_root(ctx: &Context) -> Result<&str, RenderErrorReason> { let app_root = ctx .data() @@ -219,6 +259,10 @@ pub fn init(config: Option<&Config>) -> Bicycle { "reverse-domain-snake-case", Box::new(reverse_domain_snake_case), ); + helpers.insert( + "reverse-domain-escape-kotlin-keyword", + Box::new(reverse_domain_escape_kotlin_keyword), + ); helpers.insert("dot-to-slash", Box::new(dot_to_slash)); if config.is_some() { // don't mix these up or very bad things will happen to all of us diff --git a/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs b/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs index 6d307960..279e7412 100644 --- a/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs +++ b/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs @@ -1,3 +1,4 @@ -package {{reverse-domain app.domain}}.{{snake-case app.name}} +package {{reverse-domain-escape-kotlin-keyword app.domain}}.{{snake-case app.name}} + class MainActivity : WryActivity() From 94dfd9a01ec57eae87da39c1ae461a87aeac7c72 Mon Sep 17 00:00:00 2001 From: Jason Tsai Date: Thu, 16 May 2024 23:13:39 +0800 Subject: [PATCH 02/22] fix: add android_identifier_escape_kotlin_keyword method --- src/config/app/mod.rs | 15 ++++++++ src/reserved_names/mod.rs | 16 +++++++++ src/templating/init.rs | 34 ++++--------------- .../MainActivity.kt.hbs | 3 +- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/src/config/app/mod.rs b/src/config/app/mod.rs index e6328f9c..754b2cff 100644 --- a/src/config/app/mod.rs +++ b/src/config/app/mod.rs @@ -222,6 +222,21 @@ impl App { .join(".") } + pub fn android_identifier_escape_kotlin_keyword(&self) -> String { + let identifier = format!("{}.{}", self.reverse_domain(), self.name_snake()); + identifier + .split('.') + .map(|s| { + if crate::reserved_names::KOTLIN_ONLY_KEYWORDS.contains(&s) { + format!("`{}`", s) + } else { + s.to_string() + } + }) + .collect::>() + .join(".") + } + pub fn manifest_path(&self) -> PathBuf { self.root_dir().join("Cargo.toml") } diff --git a/src/reserved_names/mod.rs b/src/reserved_names/mod.rs index c7d5d67c..e6cf673a 100644 --- a/src/reserved_names/mod.rs +++ b/src/reserved_names/mod.rs @@ -19,6 +19,22 @@ pub static WINDOWS: &[&str] = &[ pub static ARTIFACTS: &[&str] = &["deps", "examples", "build", "incremental"]; +pub static KOTLIN_ONLY_KEYWORDS: &[&str] = &[ + "as", + "false", + "fun", + "in", + "is", + "null", + "object", + "true", + "typealias", + "typeof", + "val", + "var", + "when", +]; + pub fn in_keywords(s: impl AsRef) -> bool { KEYWORDS.contains(&s.as_ref()) } diff --git a/src/templating/init.rs b/src/templating/init.rs index 85bb8e64..fe7eff7c 100644 --- a/src/templating/init.rs +++ b/src/templating/init.rs @@ -6,6 +6,7 @@ use crate::{ Bicycle, EscapeFn, HelperDef, JsonMap, }, config::{app, Config}, + reserved_names::KOTLIN_ONLY_KEYWORDS, util::{self, Git}, }; use std::collections::HashMap; @@ -122,44 +123,26 @@ fn reverse_domain_snake_case( .map_err(Into::into) } -fn reverse_domain_escape_kotlin_keyword( +fn escape_kotlin_keyword( helper: &Helper, _: &Handlebars, _: &Context, _: &mut RenderContext, out: &mut dyn Output, ) -> HelperResult { - let rev_domain = util::reverse_domain(get_str(helper)); - dbg!(&rev_domain); - let result = rev_domain + let escaped_result = get_str(helper) .split('.') .map(|s| { - let should_escaped_words: &[&str] = &[ - "as", - "false", - "fun", - "in", - "is", - "null", - "object", - "true", - "typealias", - "typeof", - "val", - "var", - "when", - ]; - if should_escaped_words.contains(&s) { - dbg!("escaped", &s); + if KOTLIN_ONLY_KEYWORDS.contains(&s) { format!("`{}`", s) } else { - dbg!("not escaped", &s); s.to_string() } }) .collect::>() .join("."); - out.write(&result).map_err(Into::into) + + out.write(&escaped_result).map_err(Into::into) } fn app_root(ctx: &Context) -> Result<&str, RenderErrorReason> { @@ -259,10 +242,7 @@ pub fn init(config: Option<&Config>) -> Bicycle { "reverse-domain-snake-case", Box::new(reverse_domain_snake_case), ); - helpers.insert( - "reverse-domain-escape-kotlin-keyword", - Box::new(reverse_domain_escape_kotlin_keyword), - ); + helpers.insert("escape-kotlin-keyword", Box::new(escape_kotlin_keyword)); helpers.insert("dot-to-slash", Box::new(dot_to_slash)); if config.is_some() { // don't mix these up or very bad things will happen to all of us diff --git a/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs b/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs index 279e7412..af602320 100644 --- a/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs +++ b/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs @@ -1,4 +1,3 @@ -package {{reverse-domain-escape-kotlin-keyword app.domain}}.{{snake-case app.name}} - +package {{escape-kotlin-keyword (reverse-domain app.domain)}}.{{escape-kotlin-keyword (snake-case app.name)}} class MainActivity : WryActivity() From e6db09b5fda2b838f3b6f026d365caac1a4db3c4 Mon Sep 17 00:00:00 2001 From: Jason Tsai Date: Thu, 16 May 2024 23:19:28 +0800 Subject: [PATCH 03/22] chore: add changelog --- .changes/android-kotlin-keyword-as-ident.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changes/android-kotlin-keyword-as-ident.md diff --git a/.changes/android-kotlin-keyword-as-ident.md b/.changes/android-kotlin-keyword-as-ident.md new file mode 100644 index 00000000..1ebcf519 --- /dev/null +++ b/.changes/android-kotlin-keyword-as-ident.md @@ -0,0 +1,5 @@ +--- +"cargo-mobile2": "patch" +--- + +On Android, allows using Kotlin keywords as identifiers and escape them in templates. From c02ff9274ef69c338c5af534ac6e9dbd0b34810f Mon Sep 17 00:00:00 2001 From: Lucas Nogueira Date: Thu, 23 May 2024 07:25:56 -0300 Subject: [PATCH 04/22] mod must be public to be used in tauri --- src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index d87b6ac5..7e1a5851 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -13,7 +13,7 @@ pub mod init; pub mod opts; pub mod os; mod project; -mod reserved_names; +pub mod reserved_names; pub mod target; mod templating; pub mod update; From 7ac11a004a3eb1bc19b70b6af44cbe1a586274e0 Mon Sep 17 00:00:00 2001 From: Hampus Lidin Date: Thu, 23 May 2024 03:17:36 +0200 Subject: [PATCH 05/22] Fix build errors for iOS (#272) --- src/apple/cli.rs | 6 +++--- src/apple/project.rs | 2 +- templates/platforms/xcode/project.yml.hbs | 3 ++- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/apple/cli.rs b/src/apple/cli.rs index acb1244d..3c03bad5 100644 --- a/src/apple/cli.rs +++ b/src/apple/cli.rs @@ -464,11 +464,11 @@ impl Exec for Input { target_env.insert(cflags.as_ref(), isysroot.as_ref()); target_env.insert(cxxflags.as_ref(), isysroot.as_ref()); target_env.insert(objc_include_path.as_ref(), include_dir.as_ref()); - // Prevents linker errors in build scripts and proc macros: - // https://github.com/signalapp/libsignal-client/commit/02899cac643a14b2ced7c058cc15a836a2165b6d - target_env.insert("LIBRARY_PATH", library_path.as_ref()); let target = if macos { + // Prevents linker errors in build scripts and proc macros: + // https://github.com/signalapp/libsignal-client/commit/02899cac643a14b2ced7c058cc15a836a2165b6d + target_env.insert("LIBRARY_PATH", library_path.as_ref()); &macos_target } else { Target::for_arch(&arch).ok_or_else(|| Error::ArchInvalid { diff --git a/src/apple/project.rs b/src/apple/project.rs index bc41c2f1..c52e0704 100644 --- a/src/apple/project.rs +++ b/src/apple/project.rs @@ -194,7 +194,7 @@ pub fn gen( // often necessary. println!("Generating Xcode project..."); let project_yml_path = dest.join("project.yml"); - duct::cmd("xcodegen", ["generate", "--spec"]) + duct::cmd("xcodegen", ["generate", "--no-env", "--spec"]) .before_spawn(move |cmd| { cmd.arg(&project_yml_path); Ok(()) diff --git a/templates/platforms/xcode/project.yml.hbs b/templates/platforms/xcode/project.yml.hbs index 57676289..88141db6 100644 --- a/templates/platforms/xcode/project.yml.hbs +++ b/templates/platforms/xcode/project.yml.hbs @@ -115,8 +115,9 @@ targets: discoveredDependencyFile: {{this.discovered-dependency-file}}{{/if}} {{~/each}}{{/if}} - script: |- + PATH=${PATH}:${HOME:?}/.cargo/bin CARGO_APPLE=`which cargo-apple` - ${CARGO_APPLE} xcode-script -v --platform ${PLATFORM_DISPLAY_NAME:?} --sdk-root ${SDKROOT:?} --framework-search-paths "${FRAMEWORK_SEARCH_PATHS:?}" --header-search-paths "${HEADER_SEARCH_PATHS:?}" --gcc-preprocessor-definitions "${GCC_PREPROCESSOR_DEFINITIONS:?}" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?} ${FEATURES} + ${CARGO_APPLE} xcode-script -v --platform "${PLATFORM_DISPLAY_NAME:?}" --sdk-root ${SDKROOT:?} --framework-search-paths "${FRAMEWORK_SEARCH_PATHS:?}" --header-search-paths "${HEADER_SEARCH_PATHS:?}" --gcc-preprocessor-definitions "${GCC_PREPROCESSOR_DEFINITIONS:?}" --configuration ${CONFIGURATION:?} ${FORCE_COLOR} ${ARCHS:?} ${FEATURES} name: Build Rust Code basedOnDependencyAnalysis: false outputFiles: From b230e0ad06b1201cec62ddae0a505134e3cad2db Mon Sep 17 00:00:00 2001 From: Jason Tsai Date: Fri, 24 May 2024 19:41:00 +0800 Subject: [PATCH 06/22] refactor!: use config.domain as package name and bundle id (#330) * fix(android): use tauri.config.json > identifier as package name * chore: add changelog * rename `domain` to `identifier` * rename domain mod * lint --------- Co-authored-by: Lucas Nogueira --- .changes/use-tauri-identifier.md | 9 +++ src/android/device.rs | 18 +----- src/apple/device/simctl/run.rs | 3 +- src/config/app/{domain.rs => identifier.rs} | 60 +++++++++---------- src/config/app/mod.rs | 34 +++++------ src/config/app/raw.rs | 48 ++++++++------- src/templating/fancy.rs | 2 +- src/util/prompt.rs | 4 +- templates/apps/wry/Cargo.toml.hbs | 6 +- .../MainActivity.kt.hbs | 2 +- templates/apps/wry/src/lib.rs.hbs | 3 +- .../android-studio/app/build.gradle.kts.hbs | 4 +- templates/platforms/xcode/project.yml.hbs | 4 +- 13 files changed, 98 insertions(+), 99 deletions(-) create mode 100644 .changes/use-tauri-identifier.md rename src/config/app/{domain.rs => identifier.rs} (63%) diff --git a/.changes/use-tauri-identifier.md b/.changes/use-tauri-identifier.md new file mode 100644 index 00000000..588a133c --- /dev/null +++ b/.changes/use-tauri-identifier.md @@ -0,0 +1,9 @@ +--- +"cargo-mobile2": minor +--- + +Use `config.identifier` as the package name in Android and bundle ID in iOS. + +**BREAKING CHANGE:** + - In `Config`, renamed field `domain` to `identifier`. + - In `App`, renamed method `reverse_domain` to `reverse_identifier`. diff --git a/src/android/device.rs b/src/android/device.rs index 39cc2920..60c2229a 100644 --- a/src/android/device.rs +++ b/src/android/device.rs @@ -359,12 +359,7 @@ impl<'a> Device<'a> { self.install_apk(config, env, profile) .map_err(RunError::ApkInstallFailed)?; } - let activity = format!( - "{}.{}/{}", - config.app().reverse_domain(), - config.app().name_snake(), - activity - ); + let activity = format!("{}/{}", config.app().reverse_identifier(), activity); self.adb(env) .before_spawn(move |cmd| { cmd.args(["shell", "am", "start", "-n", &activity]); @@ -391,16 +386,7 @@ impl<'a> Device<'a> { let stdout = loop { let cmd = duct::cmd( env.platform_tools_path().join("adb"), - [ - "shell", - "pidof", - "-s", - &format!( - "{}.{}", - config.app().reverse_domain(), - config.app().name_snake(), - ), - ], + ["shell", "pidof", "-s", &config.app().reverse_identifier()], ) .vars(env.explicit_env()) .stderr_capture() diff --git a/src/apple/device/simctl/run.rs b/src/apple/device/simctl/run.rs index 26f5685f..8d83dc38 100644 --- a/src/apple/device/simctl/run.rs +++ b/src/apple/device/simctl/run.rs @@ -45,8 +45,7 @@ pub fn run( handle.wait().map_err(RunError::DeployFailed)?; - let app_id = format!("{}.{}", config.app().reverse_domain(), config.app().name()); - + let app_id = config.app().reverse_identifier(); let mut launcher_cmd = duct::cmd("xcrun", ["simctl", "launch", id, &app_id]) .vars(env.explicit_env()) .dup_stdio(); diff --git a/src/config/app/domain.rs b/src/config/app/identifier.rs similarity index 63% rename from src/config/app/domain.rs rename to src/config/app/identifier.rs index 4d1dca27..ce9f79c8 100644 --- a/src/config/app/domain.rs +++ b/src/config/app/identifier.rs @@ -57,7 +57,7 @@ static RESERVED_JAVA_KEYWORDS: [&str; 50] = [ ]; #[derive(Debug)] -pub enum DomainError { +pub enum IdentifierError { Empty, NotAsciiAlphanumeric { bad_chars: Vec }, StartsWithDigit { label: String }, @@ -67,15 +67,15 @@ pub enum DomainError { EmptyLabel, } -impl Error for DomainError {} +impl Error for IdentifierError {} -impl fmt::Display for DomainError { +impl fmt::Display for IdentifierError { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - Self::Empty => write!(f, "Domain can't be empty."), + Self::Empty => write!(f, "Identifier can't be empty."), Self::NotAsciiAlphanumeric { bad_chars } => write!( f, - "{} characters were used in domain, but only ASCII letters and numbers are allowed.", + "{} characters were used in identifier, but only ASCII letters and numbers are allowed.", list_display( &bad_chars .iter() @@ -85,7 +85,7 @@ impl fmt::Display for DomainError { ), Self::ReservedPackageName { package_name } => write!( f, - "\"{}\" is a reserved package name in this project and can't be used as a top-level domain.", + "\"{}\" is a reserved package name in this project and can't be used as a top-level identifier.", package_name ), Self::ReservedKeyword { keyword } => write!( @@ -98,31 +98,31 @@ impl fmt::Display for DomainError { "\"{}\" label starts with a digit, which is not allowed in java/kotlin packages.", label ), - Self::StartsOrEndsWithADot => write!(f, "Domain can't start or end with a dot."), + Self::StartsOrEndsWithADot => write!(f, "Identifier can't start or end with a dot."), Self::EmptyLabel => write!(f, "Labels can't be empty."), } } } -pub fn check_domain_syntax(domain_name: &str) -> Result<(), DomainError> { - if domain_name.is_empty() { - return Err(DomainError::Empty); +pub fn check_identifier_syntax(identifier_name: &str) -> Result<(), IdentifierError> { + if identifier_name.is_empty() { + return Err(IdentifierError::Empty); } - if domain_name.starts_with('.') || domain_name.ends_with('.') { - return Err(DomainError::StartsOrEndsWithADot); + if identifier_name.starts_with('.') || identifier_name.ends_with('.') { + return Err(IdentifierError::StartsOrEndsWithADot); } - let labels = domain_name.split('.'); + let labels = identifier_name.split('.'); for label in labels { if label.is_empty() { - return Err(DomainError::EmptyLabel); + return Err(IdentifierError::EmptyLabel); } if RESERVED_JAVA_KEYWORDS.contains(&label) { - return Err(DomainError::ReservedKeyword { + return Err(IdentifierError::ReservedKeyword { keyword: label.to_owned(), }); } if label.chars().next().unwrap().is_ascii_digit() { - return Err(DomainError::StartsWithDigit { + return Err(IdentifierError::StartsWithDigit { label: label.to_owned(), }); } @@ -133,12 +133,12 @@ pub fn check_domain_syntax(domain_name: &str) -> Result<(), DomainError> { } } if !bad_chars.is_empty() { - return Err(DomainError::NotAsciiAlphanumeric { bad_chars }); + return Err(IdentifierError::NotAsciiAlphanumeric { bad_chars }); } } for pkg_name in RESERVED_PACKAGE_NAMES.iter() { - if domain_name.ends_with(pkg_name) { - return Err(DomainError::ReservedPackageName { + if identifier_name.ends_with(pkg_name) { + return Err(IdentifierError::ReservedPackageName { package_name: pkg_name.to_string(), }); } @@ -159,22 +159,22 @@ mod test { case("java.test"), case("synchronized2.com") )] - fn test_check_domain_syntax_correct(input: &str) { - check_domain_syntax(input).unwrap(); + fn test_check_identifier_syntax_correct(input: &str) { + check_identifier_syntax(input).unwrap(); } #[rstest(input, error, - case("ラスト.テスト", DomainError::NotAsciiAlphanumeric { bad_chars: vec!['ラ', 'ス', 'ト'] }), - case("test.digits.87", DomainError::StartsWithDigit { label: String::from("87") }), - case("", DomainError::Empty {}), - case(".bad.dot.syntax", DomainError::StartsOrEndsWithADot {}), - case("com.kotlin", DomainError::ReservedPackageName { package_name: String::from("kotlin") }), - case("some.domain.catch.com", DomainError::ReservedKeyword { keyword: String::from("catch") }), - case("com..empty.label", DomainError::EmptyLabel) + case("ラスト.テスト", IdentifierError::NotAsciiAlphanumeric { bad_chars: vec!['ラ', 'ス', 'ト'] }), + case("test.digits.87", IdentifierError::StartsWithDigit { label: String::from("87") }), + case("", IdentifierError::Empty {}), + case(".bad.dot.syntax", IdentifierError::StartsOrEndsWithADot {}), + case("com.kotlin", IdentifierError::ReservedPackageName { package_name: String::from("kotlin") }), + case("some.identifier.catch.com", IdentifierError::ReservedKeyword { keyword: String::from("catch") }), + case("com..empty.label", IdentifierError::EmptyLabel) )] - fn test_check_domain_syntax_error(input: &str, error: DomainError) { + fn test_check_identifier_syntax_error(input: &str, error: IdentifierError) { assert_eq!( - check_domain_syntax(input).unwrap_err().to_string(), + check_identifier_syntax(input).unwrap_err().to_string(), error.to_string() ) } diff --git a/src/config/app/mod.rs b/src/config/app/mod.rs index 754b2cff..11a027b3 100644 --- a/src/config/app/mod.rs +++ b/src/config/app/mod.rs @@ -1,5 +1,5 @@ mod common_email_providers; -pub mod domain; +pub mod identifier; pub mod lib_name; pub mod name; mod raw; @@ -35,10 +35,10 @@ pub enum Error { NameInvalid(name::Invalid), #[error("app.lib_name invalid: {0}")] LibNameInvalid(lib_name::Invalid), - #[error("`app.domain` {domain} isn't valid: {cause}")] - DomainInvalid { - domain: String, - cause: domain::DomainError, + #[error("`app.identifier` {identifier} isn't valid: {cause}")] + IdentifierInvalid { + identifier: String, + cause: identifier::IdentifierError, }, #[error("`app.asset-dir` {asset_dir} couldn't be normalized: {cause}")] AssetDirNormalizationFailed { @@ -67,7 +67,7 @@ pub struct App { name: String, lib_name: Option, stylized_name: String, - domain: String, + identifier: String, asset_dir: PathBuf, #[serde(skip)] template_pack: Pack, @@ -82,7 +82,7 @@ impl Debug for App { .field("root_dir", &self.root_dir) .field("name", &self.name) .field("stylized_name", &self.stylized_name) - .field("domain", &self.domain) + .field("identifier", &self.identifier) .field("asset_dir", &self.asset_dir) .field("template_pack", &self.template_pack) .finish() @@ -102,14 +102,14 @@ impl App { let stylized_name = raw.stylized_name.unwrap_or_else(|| name.clone()); - let domain = { - let domain = raw.domain; - domain::check_domain_syntax(&domain) - .map_err(|cause| Error::DomainInvalid { - domain: domain.clone(), + let identifier = { + let identifier = raw.identifier; + identifier::check_identifier_syntax(&identifier) + .map_err(|cause| Error::IdentifierInvalid { + identifier: identifier.clone(), cause, }) - .map(|()| domain) + .map(|()| identifier) }?; if raw.asset_dir.as_deref() == Some(DEFAULT_ASSET_DIR) { @@ -156,7 +156,7 @@ impl App { name, lib_name, stylized_name, - domain, + identifier, asset_dir, template_pack, target_dir_resolver: None, @@ -213,8 +213,8 @@ impl App { &self.stylized_name } - pub fn reverse_domain(&self) -> String { - self.domain + pub fn reverse_identifier(&self) -> String { + self.identifier .clone() .split('.') .rev() @@ -223,7 +223,7 @@ impl App { } pub fn android_identifier_escape_kotlin_keyword(&self) -> String { - let identifier = format!("{}.{}", self.reverse_domain(), self.name_snake()); + let identifier = self.reverse_identifier(); identifier .split('.') .map(|s| { diff --git a/src/config/app/raw.rs b/src/config/app/raw.rs index 651f9d02..ccd21ee0 100644 --- a/src/config/app/raw.rs +++ b/src/config/app/raw.rs @@ -1,4 +1,4 @@ -use super::{common_email_providers::COMMON_EMAIL_PROVIDERS, domain, name}; +use super::{common_email_providers::COMMON_EMAIL_PROVIDERS, identifier, name}; use crate::{ templating, util::{cli::TextWrapper, prompt, Git}, @@ -14,31 +14,32 @@ use std::{ }; #[derive(Debug)] -enum DefaultDomainError { +enum DefaultIdentifierError { FailedToGetGitEmailAddr(#[allow(unused)] std::io::Error), FailedToParseEmailAddr, } -fn default_domain(_wrapper: &TextWrapper) -> Result, DefaultDomainError> { +fn default_identifier(_wrapper: &TextWrapper) -> Result, DefaultIdentifierError> { let email = Git::new(".".as_ref()) .user_email() - .map_err(DefaultDomainError::FailedToGetGitEmailAddr)?; - let domain = email + .map_err(DefaultIdentifierError::FailedToGetGitEmailAddr)?; + let identifier = email .trim() .split('@') .last() - .ok_or(DefaultDomainError::FailedToParseEmailAddr)?; + .ok_or(DefaultIdentifierError::FailedToParseEmailAddr)?; Ok( - if !COMMON_EMAIL_PROVIDERS.contains(&domain) && domain::check_domain_syntax(domain).is_ok() + if !COMMON_EMAIL_PROVIDERS.contains(&identifier) + && identifier::check_identifier_syntax(identifier).is_ok() { #[cfg(not(feature = "brainium"))] - if domain == "brainiumstudios.com" { + if identifier == "brainiumstudios.com" { crate::util::cli::Report::action_request( "You have a Brainium email address, but you're using a non-Brainium installation of cargo-mobile2!", "If that's not intentional, run `cargo install --force --git https://github.com/tauri-apps/cargo-mobile2 --features brainium`", ).print(_wrapper); } - Some(domain.to_owned()) + Some(identifier.to_owned()) } else { None }, @@ -74,7 +75,7 @@ impl Display for DefaultsError { struct Defaults { name: Option, stylized_name: String, - domain: String, + identifier: String, } impl Defaults { @@ -89,7 +90,7 @@ impl Defaults { Ok(Self { name: name::transliterate(&dir_name.to_kebab_case()), stylized_name: dir_name.to_title_case(), - domain: default_domain(wrapper) + identifier: default_identifier(wrapper) .ok() .flatten() .unwrap_or_else(|| "example.com".to_owned()), @@ -117,7 +118,7 @@ pub enum PromptError { DefaultsFailed(DefaultsError), NamePromptFailed(io::Error), StylizedNamePromptFailed(io::Error), - DomainPromptFailed(io::Error), + IdentifierPromptFailed(io::Error), ListTemplatePacksFailed(templating::ListError), TemplatePackPromptFailed(io::Error), } @@ -130,7 +131,9 @@ impl Display for PromptError { Self::StylizedNamePromptFailed(err) => { write!(f, "Failed to prompt for stylized name: {}", err) } - Self::DomainPromptFailed(err) => write!(f, "Failed to prompt for domain: {}", err), + Self::IdentifierPromptFailed(err) => { + write!(f, "Failed to prompt for identifier: {}", err) + } Self::ListTemplatePacksFailed(err) => write!(f, "{}", err), Self::TemplatePackPromptFailed(err) => { write!(f, "Failed to prompt for template pack: {}", err) @@ -145,7 +148,7 @@ pub struct Raw { pub name: String, pub lib_name: Option, pub stylized_name: Option, - pub domain: String, + pub identifier: String, pub asset_dir: Option, pub template_pack: Option, } @@ -157,7 +160,7 @@ impl Raw { name: defaults.name.ok_or_else(|| DetectError::NameNotDetected)?, lib_name: None, stylized_name: Some(defaults.stylized_name), - domain: defaults.domain, + identifier: defaults.identifier, asset_dir: None, template_pack: Some(super::DEFAULT_TEMPLATE_PACK.to_owned()) .filter(|pack| pack != super::IMPLIED_TEMPLATE_PACK), @@ -168,14 +171,14 @@ impl Raw { let defaults = Defaults::new(wrapper).map_err(PromptError::DefaultsFailed)?; let (name, default_stylized) = Self::prompt_name(wrapper, &defaults)?; let stylized_name = Self::prompt_stylized_name(&name, default_stylized)?; - let domain = Self::prompt_domain(wrapper, &defaults)?; + let identifier = Self::prompt_identifier(wrapper, &defaults)?; let template_pack = Some(Self::prompt_template_pack(wrapper)?) .filter(|pack| pack != super::IMPLIED_TEMPLATE_PACK); Ok(Self { name, lib_name: None, stylized_name: Some(stylized_name), - domain, + identifier, asset_dir: None, template_pack, }) @@ -231,11 +234,14 @@ impl Raw { .map_err(PromptError::StylizedNamePromptFailed) } - fn prompt_domain(wrapper: &TextWrapper, defaults: &Defaults) -> Result { + fn prompt_identifier( + wrapper: &TextWrapper, + defaults: &Defaults, + ) -> Result { Ok(loop { - let response = prompt::default("Domain", Some(&defaults.domain), None) - .map_err(PromptError::DomainPromptFailed)?; - match domain::check_domain_syntax(response.as_str()) { + let response = prompt::default("Identifier", Some(&defaults.identifier), None) + .map_err(PromptError::IdentifierPromptFailed)?; + match identifier::check_identifier_syntax(response.as_str()) { Ok(_) => break response, Err(err) => { println!( diff --git a/src/templating/fancy.rs b/src/templating/fancy.rs index 810e28c0..cb207ffe 100644 --- a/src/templating/fancy.rs +++ b/src/templating/fancy.rs @@ -68,7 +68,7 @@ impl FancyPack { .map(|p| p.join(&raw.path)) .unwrap_or(raw.path.clone()); - let real_path = util::expand_home(&raw_path).map_err(FancyPackParseError::NoHomeDir)?; + let real_path = util::expand_home(raw_path).map_err(FancyPackParseError::NoHomeDir)?; let this = Self { path: real_path, base: raw diff --git a/src/util/prompt.rs b/src/util/prompt.rs index 3f9d3f34..782614f6 100644 --- a/src/util/prompt.rs +++ b/src/util/prompt.rs @@ -9,8 +9,8 @@ pub fn minimal(msg: impl Display) -> io::Result { print!("{}: ", msg); io::stdout().flush()?; io::stdin().read_line(&mut input)?; - input = input.trim().to_owned(); - Ok(input) + + Ok(input.trim().to_owned()) } pub fn default( diff --git a/templates/apps/wry/Cargo.toml.hbs b/templates/apps/wry/Cargo.toml.hbs index 7abfa8c2..ceba0e1a 100644 --- a/templates/apps/wry/Cargo.toml.hbs +++ b/templates/apps/wry/Cargo.toml.hbs @@ -12,7 +12,7 @@ name = "{{app.name}}-desktop" path = "gen/bin/desktop.rs" [package.metadata.cargo-android] -app-activity-name = "{{reverse-domain app.domain}}.{{snake-case app.name}}.MainActivity" +app-activity-name = "{{reverse-domain app.identifier}}.MainActivity" app-dependencies = [ "androidx.webkit:webkit:1.6.1", "androidx.appcompat:appcompat:1.6.1", @@ -25,9 +25,9 @@ app-theme-parent = "Theme.MaterialComponents.DayNight.DarkActionBar" vulkan-validation = false [package.metadata.cargo-android.env-vars] -WRY_ANDROID_PACKAGE = "{{reverse-domain app.domain}}.{{snake-case app.name}}" +WRY_ANDROID_PACKAGE = "{{reverse-domain app.identifier}}" WRY_ANDROID_LIBRARY = "{{snake-case app.name}}" -WRY_ANDROID_KOTLIN_FILES_OUT_DIR = "/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}" +WRY_ANDROID_KOTLIN_FILES_OUT_DIR = "/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.identifier)}}" [package.metadata.cargo-apple.ios] frameworks = [ "WebKit" ] diff --git a/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs b/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs index af602320..a3cd150d 100644 --- a/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs +++ b/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs @@ -1,3 +1,3 @@ -package {{escape-kotlin-keyword (reverse-domain app.domain)}}.{{escape-kotlin-keyword (snake-case app.name)}} +package {{escape-kotlin-keyword app.identifier}} class MainActivity : WryActivity() diff --git a/templates/apps/wry/src/lib.rs.hbs b/templates/apps/wry/src/lib.rs.hbs index a722f682..0c73b53b 100644 --- a/templates/apps/wry/src/lib.rs.hbs +++ b/templates/apps/wry/src/lib.rs.hbs @@ -42,8 +42,7 @@ pub extern "C" fn start_app() { #[cfg(target_os = "android")] { tao::android_binding!( - {{reverse-domain-snake-case app.domain}}, - {{snake-case app.name}}, + {{reverse-domain-snake-case app.identifier}}, WryActivity, wry::android_setup, // pass the wry::android_setup function to tao which will invoke when the event loop is created _start_app diff --git a/templates/platforms/android-studio/app/build.gradle.kts.hbs b/templates/platforms/android-studio/app/build.gradle.kts.hbs index 50d35b72..558c210a 100644 --- a/templates/platforms/android-studio/app/build.gradle.kts.hbs +++ b/templates/platforms/android-studio/app/build.gradle.kts.hbs @@ -5,11 +5,11 @@ plugins { } android { - namespace="{{reverse-domain app.domain}}.{{snake-case app.name}}"{{#if has-asset-packs}} + namespace="{{reverse-domain app.identifier}}"{{#if has-asset-packs}} assetPacks += mutableSetOf({{quote-and-join-colon-prefix asset-packs}}){{/if}} compileSdk = 33 defaultConfig { - applicationId = "{{reverse-domain app.domain}}.{{snake-case app.name}}" + applicationId = "{{reverse-domain app.identifier}}" minSdk = {{android.min-sdk-version}} targetSdk = 33 versionCode = 1 diff --git a/templates/platforms/xcode/project.yml.hbs b/templates/platforms/xcode/project.yml.hbs index 88141db6..231ae0ae 100644 --- a/templates/platforms/xcode/project.yml.hbs +++ b/templates/platforms/xcode/project.yml.hbs @@ -1,6 +1,6 @@ name: {{app.name}} options: - bundleIdPrefix: {{reverse-domain app.domain}} + bundleIdPrefix: {{reverse-domain app.identifier}} deploymentTarget: iOS: {{apple.ios-version}} macOS: {{apple.macos-version}} @@ -12,7 +12,7 @@ settingGroups: app: base: PRODUCT_NAME: {{app.stylized-name}} - PRODUCT_BUNDLE_IDENTIFIER: {{reverse-domain app.domain}}.{{app.name}} + PRODUCT_BUNDLE_IDENTIFIER: {{reverse-domain app.identifier}} {{#if apple.development-team}} DEVELOPMENT_TEAM: {{apple.development-team}} {{/if}} From be55f47ce97225eda8f5e14284833f553e51a9a8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:42:22 -0300 Subject: [PATCH 07/22] fix(deps): update rust crate textwrap to v0.16.1 (#329) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b4388a18..184ba8e6 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -199,7 +199,7 @@ dependencies = [ "serde", "serde_json", "structopt", - "textwrap 0.16.0", + "textwrap 0.16.1", "thiserror", "toml", "ureq", @@ -1526,9 +1526,9 @@ dependencies = [ [[package]] name = "textwrap" -version = "0.16.0" +version = "0.16.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "222a222a5bfe1bba4a77b45ec488a741b3cb8872e5e499451fd7d0129c9c7c3d" +checksum = "23d434d3f8967a09480fb04132ebe0a3e088c173e6d0ee7897abbdf4eab0f8b9" dependencies = [ "smawk", "terminal_size", From 4c76db14a67eb686c5905b8ba2184a13367fa070 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:42:34 -0300 Subject: [PATCH 08/22] fix(deps): update rust crate os_pipe to v1.1.5 (#325) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 184ba8e6..9f2f7296 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -953,12 +953,12 @@ dependencies = [ [[package]] name = "os_pipe" -version = "1.1.4" +version = "1.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0ae859aa07428ca9a929b936690f8b12dc5f11dd8c6992a18ca93919f28bc177" +checksum = "57119c3b893986491ec9aa85056780d3a0f3cf4da7cc09dd3650dbd6c6738fb9" dependencies = [ "libc", - "windows-sys 0.48.0", + "windows-sys 0.52.0", ] [[package]] From d29629e092937004ec5db33861ef06fe2fdc3e62 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:42:41 -0300 Subject: [PATCH 09/22] fix(deps): update rust crate libc to v0.2.155 (#324) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f2f7296..bafa0e69 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -800,9 +800,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.153" +version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9c198f91728a82281a64e1f4f9eeb25d82cb32a5de251c6bd1b5154d63a8e7bd" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" [[package]] name = "linux-raw-sys" From 5d932c409c9ddb50daa48cae5de56e8197eac6d6 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:42:48 -0300 Subject: [PATCH 10/22] fix(deps): update rust crate ignore to v0.4.22 (#323) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 58 +++++++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index bafa0e69..78fc8add 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -306,6 +306,31 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crossbeam-deque" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "613f8cc01fe9cf1a3eb3d7f488fd2fa8388403e97039e2f73692932e291a770d" +dependencies = [ + "crossbeam-epoch", + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-epoch" +version = "0.9.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b82ac4a3c2ca9c3460964f020e1402edd5753411d7737aa39c3714ad1b5420e" +dependencies = [ + "crossbeam-utils", +] + +[[package]] +name = "crossbeam-utils" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22ec99545bb0ed0ea7bb9b8e1e9122ea386ff8a48c0922e43f36d45ab09e0e80" + [[package]] name = "crypto-common" version = "0.1.6" @@ -449,12 +474,6 @@ dependencies = [ "miniz_oxide", ] -[[package]] -name = "fnv" -version = "1.0.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" - [[package]] name = "foreign-types" version = "0.3.2" @@ -613,15 +632,15 @@ checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" [[package]] name = "globset" -version = "0.4.13" +version = "0.4.14" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759c97c1e17c55525b57192c06a267cda0ac5210b222d6b82189a2338fa1c13d" +checksum = "57da3b9b5b85bd66f31093f8c408b90a74431672542466497dcbdfdc02034be1" dependencies = [ "aho-corasick", "bstr", - "fnv", "log", - "regex", + "regex-automata", + "regex-syntax", ] [[package]] @@ -730,17 +749,16 @@ dependencies = [ [[package]] name = "ignore" -version = "0.4.20" +version = "0.4.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbe7873dab538a9a44ad79ede1faf5f30d49f9a5c883ddbab48bce81b64b7492" +checksum = "b46810df39e66e925525d6e38ce1e7f6e1d208f72dc39757880fcb66e2c58af1" dependencies = [ + "crossbeam-deque", "globset", - "lazy_static", "log", "memchr", - "regex", + "regex-automata", "same-file", - "thread_local", "walkdir", "winapi-util", ] @@ -1556,16 +1574,6 @@ dependencies = [ "syn 2.0.53", ] -[[package]] -name = "thread_local" -version = "1.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdd6f064ccff2d6567adcb3873ca630700f00b5ad3f060c25b5dcfd9a4ce152" -dependencies = [ - "cfg-if", - "once_cell", -] - [[package]] name = "tinyvec" version = "1.6.0" From 55983b30c3932b3b376b4aba142ca2b19e819f2c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:43:12 -0300 Subject: [PATCH 11/22] fix(deps): update rust crate deunicode to v1.6.0 (#321) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 78fc8add..6eae9796 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -353,9 +353,9 @@ dependencies = [ [[package]] name = "deunicode" -version = "1.4.1" +version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a1abaf4d861455be59f64fd2b55606cb151fce304ede7165f410243ce96bde6" +checksum = "339544cc9e2c4dc3fc7149fd630c5f22263a4fdf18a98afd0075784968b5cf00" [[package]] name = "digest" From 49033d3a81e4a22ded2f2486ef58cab1380f83a9 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:43:19 -0300 Subject: [PATCH 12/22] fix(deps): update rust crate core-foundation to v0.9.4 (#320) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 6eae9796..1f55296b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -274,9 +274,9 @@ checksum = "c2459377285ad874054d797f3ccebf984978aa39129f6eafde5cdc8315b612f8" [[package]] name = "core-foundation" -version = "0.9.3" +version = "0.9.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" dependencies = [ "core-foundation-sys", "libc", @@ -284,9 +284,9 @@ dependencies = [ [[package]] name = "core-foundation-sys" -version = "0.8.4" +version = "0.8.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" [[package]] name = "cpufeatures" From 518f539ad6d1eab6097460274d3b6fa65895918f Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:47:40 -0300 Subject: [PATCH 13/22] chore(deps): update rust crate serde to v1.0.202 (#311) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1f55296b..8ef9b231 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1331,18 +1331,18 @@ checksum = "836fa6a3e1e547f9a2c4040802ec865b5d85f4014efe00555d7090a3dcaa1090" [[package]] name = "serde" -version = "1.0.189" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e422a44e74ad4001bdc8eede9a4570ab52f71190e9c076d14369f38b9200537" +checksum = "226b61a0d411b2ba5ff6d7f73a476ac4f8bb900373459cd00fab8512828ba395" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.189" +version = "1.0.202" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e48d1f918009ce3145511378cf68d613e3b3d9137d67272562080d68a2b32d5" +checksum = "6048858004bcff69094cd972ed40a32500f153bd3be9f716b2eed2e8217c4838" dependencies = [ "proc-macro2", "quote", From 0db5c92cd8112af79ce2a8a789dc224ec6ed9358 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:47:49 -0300 Subject: [PATCH 14/22] chore(deps): update rust crate embed-resource to v2.4.2 (#317) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8ef9b231..f8e42225 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -393,11 +393,12 @@ checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" [[package]] name = "embed-resource" -version = "2.4.0" +version = "2.4.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f54cc3e827ee1c3812239a9a41dede7b4d7d5d5464faa32d71bd7cba28ce2cb2" +checksum = "c6985554d0688b687c5cb73898a34fbe3ad6c24c58c238a4d91d5e840670ee9d" dependencies = [ "cc", + "memchr", "rustc_version", "toml", "vswhom", @@ -842,9 +843,9 @@ checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c" [[package]] name = "memchr" -version = "2.6.4" +version = "2.7.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" +checksum = "6c8640c5d730cb13ebd907d8d04b52f55ac9a2eec55b440c8892f40d56c76c1d" [[package]] name = "minimal-lexical" @@ -2088,9 +2089,9 @@ dependencies = [ [[package]] name = "winreg" -version = "0.51.0" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "937f3df7948156640f46aacef17a70db0de5917bda9c92b0f751f3a955b588fc" +checksum = "a277a57398d4bfa075df44f501a17cfdf8542d224f0d36095a2adc7aee4ef0a5" dependencies = [ "cfg-if", "windows-sys 0.48.0", From 043e74c0294cc820480d919ffff00206d987719c Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:48:01 -0300 Subject: [PATCH 15/22] chore(deps): update rust crate serde_json to v1.0.117 (#318) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f8e42225..8cfb7409 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1352,9 +1352,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.107" +version = "1.0.117" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6b420ce6e3d8bd882e9b243c6eed35dbc9a6110c9769e74b584e0d68d1f20c65" +checksum = "455182ea6142b14f93f4bc5320a2b31c1f266b66a4a5c858b013302a5d8cbfc3" dependencies = [ "itoa", "ryu", From c530bbcab01a4f1601c9b750a88fe2ac607c935a Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:48:20 -0300 Subject: [PATCH 16/22] chore(deps): update rust crate thiserror to v1.0.61 (#319) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8cfb7409..b14b0fab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1557,18 +1557,18 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297" +checksum = "c546c80d6be4bc6a00c0f01730c08df82eaa7a7a61f11d656526506112cc1709" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.58" +version = "1.0.61" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7" +checksum = "46c3384250002a6d5af4d114f2845d37b57521033f30d5c3f46c4d70e1197533" dependencies = [ "proc-macro2", "quote", From 41b41475b461b5d367c86231d291c0ac21113dd1 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:52:24 -0300 Subject: [PATCH 17/22] fix(deps): update rust crate duct to v0.13.7 (#322) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b14b0fab..f5a7b60d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -369,9 +369,9 @@ dependencies = [ [[package]] name = "duct" -version = "0.13.6" +version = "0.13.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37ae3fc31835f74c2a7ceda3aeede378b0ae2e74c8f1c36559fcc9ae2a4e7d3e" +checksum = "e4ab5718d1224b63252cd0c6f74f6480f9ffeb117438a2e0f5cf6d9a4798929c" dependencies = [ "libc", "once_cell", From 9d6ef3a5e94dce0c36a494b5d17e554e2ac53455 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:53:20 -0300 Subject: [PATCH 18/22] fix(deps): update rust crate toml to v0.8.13 (#332) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index f5a7b60d..a764ad11 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1363,9 +1363,9 @@ dependencies = [ [[package]] name = "serde_spanned" -version = "0.6.4" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12022b835073e5b11e90a14f86838ceb1c8fb0325b72416845c487ac0fa95e80" +checksum = "79e674e01f999af37c49f70a6ede167a8a60b2503e56c5599532a65baa5969a0" dependencies = [ "serde", ] @@ -1592,9 +1592,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" [[package]] name = "toml" -version = "0.8.8" +version = "0.8.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1a195ec8c9da26928f773888e0742ca3ca1040c6cd859c919c9f59c1954ab35" +checksum = "a4e43f8cc456c9704c851ae29c67e17ef65d2c30017c17a9765b89c382dc8bba" dependencies = [ "indexmap", "serde", @@ -1605,18 +1605,18 @@ dependencies = [ [[package]] name = "toml_datetime" -version = "0.6.5" +version = "0.6.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3550f4e9685620ac18a50ed434eb3aec30db8ba93b0287467bca5826ea25baf1" +checksum = "4badfd56924ae69bcc9039335b2e017639ce3f9b001c393c1b2d1ef846ce2cbf" dependencies = [ "serde", ] [[package]] name = "toml_edit" -version = "0.21.0" +version = "0.22.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d34d383cd00a163b4a5b85053df514d45bc330f6de7737edfe0a93311d1eaa03" +checksum = "c127785850e8c20836d49732ae6abfa47616e60bf9d9f57c43c250361a9db96c" dependencies = [ "indexmap", "serde", @@ -2080,9 +2080,9 @@ checksum = "bec47e5bfd1bff0eeaf6d8b485cc1074891a197ab4225d504cb7a1ab88b02bf0" [[package]] name = "winnow" -version = "0.5.19" +version = "0.6.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "829846f3e3db426d4cee4510841b71a8e58aa2a76b1132579487ae430ccd9c7b" +checksum = "c3c52e9c97a68071b23e836c9380edae937f17b9c4667bd021973efc689f618d" dependencies = [ "memchr", ] From ffab8bb4d1db8c0fcd11f93e2f708b8008a1675b Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:53:33 -0300 Subject: [PATCH 19/22] fix(deps): update rust crate ureq to v2.9.7 (#333) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- Cargo.lock | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a764ad11..9f6bca8c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -112,6 +112,12 @@ version = "0.21.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9ba43ea6f343b788c8764558649e08df62f86c6ef251fdaeb1ffd010a9ae50a2" +[[package]] +name = "base64" +version = "0.22.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" + [[package]] name = "base64ct" version = "1.6.0" @@ -998,7 +1004,7 @@ version = "3.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1b8fcc794035347fb64beda2d3b462595dd2753e3f268d89c5aae77e8cf2c310" dependencies = [ - "base64", + "base64 0.21.4", "serde", ] @@ -1248,9 +1254,9 @@ dependencies = [ [[package]] name = "rustls" -version = "0.22.3" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99008d7ad0bbbea527ec27bddbc0e432c5b87d8175178cee68d2eec9c4a1813c" +checksum = "bf4ef73721ac7bcd79b2b315da7779d8fc09718c6b3d2d1b2d94850eb8c18432" dependencies = [ "log", "ring", @@ -1684,11 +1690,11 @@ checksum = "8ecb6da28b8a351d773b68d5825ac39017e680750f980f3a1a85cd8dd28a47c1" [[package]] name = "ureq" -version = "2.9.6" +version = "2.9.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "11f214ce18d8b2cbe84ed3aa6486ed3f5b285cf8d8fbdbce9f3f767a724adc35" +checksum = "d11a831e3c0b56e438a28308e7c810799e3c118417f342d30ecec080105395cd" dependencies = [ - "base64", + "base64 0.22.1", "flate2", "log", "native-tls", From e798b0772fd9f191243dcc83deefa25740b740e3 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 24 May 2024 08:59:43 -0300 Subject: [PATCH 20/22] publish new versions (#301) Co-authored-by: lucasfernog --- .changes/bevy-init.md | 5 ----- .changes/use-tauri-identifier.md | 9 --------- .changes/windows-rs-0.56.md | 5 ----- .changes/wry-crash-linux.md | 5 ----- CHANGELOG.md | 12 ++++++++++++ Cargo.lock | 2 +- Cargo.toml | 2 +- 7 files changed, 14 insertions(+), 26 deletions(-) delete mode 100644 .changes/bevy-init.md delete mode 100644 .changes/use-tauri-identifier.md delete mode 100644 .changes/windows-rs-0.56.md delete mode 100644 .changes/wry-crash-linux.md diff --git a/.changes/bevy-init.md b/.changes/bevy-init.md deleted file mode 100644 index bbb73677..00000000 --- a/.changes/bevy-init.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"cargo-mobile2": "patch" ---- - -Fix creating a new `bevy` project. diff --git a/.changes/use-tauri-identifier.md b/.changes/use-tauri-identifier.md deleted file mode 100644 index 588a133c..00000000 --- a/.changes/use-tauri-identifier.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -"cargo-mobile2": minor ---- - -Use `config.identifier` as the package name in Android and bundle ID in iOS. - -**BREAKING CHANGE:** - - In `Config`, renamed field `domain` to `identifier`. - - In `App`, renamed method `reverse_domain` to `reverse_identifier`. diff --git a/.changes/windows-rs-0.56.md b/.changes/windows-rs-0.56.md deleted file mode 100644 index e917341c..00000000 --- a/.changes/windows-rs-0.56.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"cargo-mobile2": "patch" ---- - -Update `windows` crate to `0.56` diff --git a/.changes/wry-crash-linux.md b/.changes/wry-crash-linux.md deleted file mode 100644 index 96a4a9af..00000000 --- a/.changes/wry-crash-linux.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -"cargo-mobile2": "patch" ---- - -Fix `wry` template crashing on Linux. diff --git a/CHANGELOG.md b/CHANGELOG.md index b4a9e093..d42f5558 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Changelog +## \[0.12.0] + +- [`adb2846`](https://github.com/tauri-apps/cargo-mobile2/commit/adb2846ab60642b3cc0a950e60c8c0f9c05f6cb5)([#297](https://github.com/tauri-apps/cargo-mobile2/pull/297)) Fix creating a new `bevy` project. +- [`29921ff`](https://github.com/tauri-apps/cargo-mobile2/commit/29921ff025ebed31546e33dc82696dc0c8fce2e0)([#330](https://github.com/tauri-apps/cargo-mobile2/pull/330)) Use `config.identifier` as the package name in Android and bundle ID in iOS. + + **BREAKING CHANGE:** + + - In `Config`, renamed field `domain` to `identifier`. + - In `App`, renamed method `reverse_domain` to `reverse_identifier`. +- [`525d51f`](https://github.com/tauri-apps/cargo-mobile2/commit/525d51fc61e9461bd5468124554fc12d7382333f)([#305](https://github.com/tauri-apps/cargo-mobile2/pull/305)) Update `windows` crate to `0.56` +- [`2beb485`](https://github.com/tauri-apps/cargo-mobile2/commit/2beb485387e67fc14cc2b714cb457726e4cd1d77)([#298](https://github.com/tauri-apps/cargo-mobile2/pull/298)) Fix `wry` template crashing on Linux. + ## \[0.11.1] - [`cb4ed53`](https://github.com/tauri-apps/cargo-mobile2/commit/cb4ed53069f404a0eed9988b7a0dd0e29509572e)([#300](https://github.com/tauri-apps/cargo-mobile2/pull/300)) Fix `.gitignore` generated with wrong formatting. diff --git a/Cargo.lock b/Cargo.lock index 9f6bca8c..c9ebf7d3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -179,7 +179,7 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "cargo-mobile2" -version = "0.11.1" +version = "0.12.0" dependencies = [ "colored", "core-foundation", diff --git a/Cargo.toml b/Cargo.toml index 38586fcf..e5dabda9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cargo-mobile2" -version = "0.11.1" +version = "0.12.0" authors = [ "Tauri Programme within The Commons Conservancy", "Brainium Studios LLC", From 6c1fcd42aca7082fd0fd19f507568b687480cde3 Mon Sep 17 00:00:00 2001 From: Jason Tsai Date: Mon, 27 May 2024 11:29:59 +0800 Subject: [PATCH 21/22] fix: add `true` `false` `null` to java keywords --- src/config/app/identifier.rs | 6 +++++- src/reserved_names/mod.rs | 3 --- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/config/app/identifier.rs b/src/config/app/identifier.rs index ce9f79c8..f02e3ba0 100644 --- a/src/config/app/identifier.rs +++ b/src/config/app/identifier.rs @@ -3,7 +3,8 @@ use std::error::Error; use std::fmt; static RESERVED_PACKAGE_NAMES: [&str; 2] = ["kotlin", "java"]; -static RESERVED_JAVA_KEYWORDS: [&str; 50] = [ +// https://docs.oracle.com/javase/tutorial/java/nutsandbolts/_keywords.html +static RESERVED_JAVA_KEYWORDS: [&str; 53] = [ "abstract", "assert", "boolean", @@ -21,6 +22,7 @@ static RESERVED_JAVA_KEYWORDS: [&str; 50] = [ "else", "enum", "extends", + "false", "final", "finally", "float", @@ -35,6 +37,7 @@ static RESERVED_JAVA_KEYWORDS: [&str; 50] = [ "long", "native", "new", + "null", "package", "private", "protected", @@ -50,6 +53,7 @@ static RESERVED_JAVA_KEYWORDS: [&str; 50] = [ "throw", "throws", "transient", + "true", "try", "void", "volatile", diff --git a/src/reserved_names/mod.rs b/src/reserved_names/mod.rs index e6cf673a..de63ed39 100644 --- a/src/reserved_names/mod.rs +++ b/src/reserved_names/mod.rs @@ -21,13 +21,10 @@ pub static ARTIFACTS: &[&str] = &["deps", "examples", "build", "incremental"]; pub static KOTLIN_ONLY_KEYWORDS: &[&str] = &[ "as", - "false", "fun", "in", "is", - "null", "object", - "true", "typealias", "typeof", "val", From d0dc86a6485c044d751e832726113827f7577f3c Mon Sep 17 00:00:00 2001 From: Jason Tsai Date: Mon, 27 May 2024 12:55:41 +0800 Subject: [PATCH 22/22] fix: wry template package name should reverse --- src/config/app/mod.rs | 3 +-- .../{{snake-case app.name}}/MainActivity.kt.hbs | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/config/app/mod.rs b/src/config/app/mod.rs index 11a027b3..25564abf 100644 --- a/src/config/app/mod.rs +++ b/src/config/app/mod.rs @@ -223,8 +223,7 @@ impl App { } pub fn android_identifier_escape_kotlin_keyword(&self) -> String { - let identifier = self.reverse_identifier(); - identifier + self.reverse_identifier() .split('.') .map(|s| { if crate::reserved_names::KOTLIN_ONLY_KEYWORDS.contains(&s) { diff --git a/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs b/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs index a3cd150d..b202442e 100644 --- a/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs +++ b/templates/apps/wry/gen/android/app/src/main/kotlin/{{dot-to-slash (reverse-domain app.domain)}}/{{snake-case app.name}}/MainActivity.kt.hbs @@ -1,3 +1,3 @@ -package {{escape-kotlin-keyword app.identifier}} +package {{escape-kotlin-keyword (reverse-domain app.identifier)}} class MainActivity : WryActivity()