diff --git a/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.h b/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.h index cb2cdd4a..a5cf6732 100644 --- a/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.h +++ b/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.h @@ -6,7 +6,7 @@ #ifdef RCT_NEW_ARCH_ENABLED #import "{{ self.config.project.tm.name() }}.h" -@interface {{ self.config.project.name_upper_camel() }} : NSObject <{{ self.config.project.codegen_filename() }}Spec> +@interface {{ self.config.project.name_upper_camel() }} : NSObject <{{ self.config.project.tm.spec_name() }}> #else #import diff --git a/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.java b/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.java index fffc7c89..02d2d901 100644 --- a/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.java +++ b/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.java @@ -11,7 +11,7 @@ import com.facebook.react.turbomodule.core.interfaces.CallInvokerHolder; @ReactModule(name = {{ module_class_name }}.NAME) -public class {{ module_class_name }} extends {{ self.config.project.codegen_filename() }}Spec { +public class {{ module_class_name }} extends {{ self.config.project.tm.spec_name() }} { public static final String NAME = "{{ name }}"; public {{ module_class_name }}(ReactApplicationContext reactContext) { diff --git a/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.mm b/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.mm index f422ce73..fffc3795 100644 --- a/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.mm +++ b/crates/ubrn_cli/src/codegen/templates/ModuleTemplate.mm @@ -1,5 +1,5 @@ {%- let module_name = self.config.project.name_upper_camel() %} -{%- let spec_jsi = self.config.project.codegen_filename()|fmt("{}JSI") %} +{%- let spec_jsi = self.config.project.tm.spec_name()|fmt("{}JSI") %} {%- let ns = self.config.project.cpp_namespace() %} {%- let uniffi_ns = "uniffi_generated" %} {%- let fn_prefix = "__hostFunction_{}"|format(module_name) -%} diff --git a/crates/ubrn_cli/src/codegen/templates/NativeCodegenTemplate.ts b/crates/ubrn_cli/src/codegen/templates/NativeCodegenTemplate.ts index 67028849..0b2e69be 100644 --- a/crates/ubrn_cli/src/codegen/templates/NativeCodegenTemplate.ts +++ b/crates/ubrn_cli/src/codegen/templates/NativeCodegenTemplate.ts @@ -7,4 +7,4 @@ export interface Spec extends TurboModule { cleanupRustCrate(): boolean; } -export default TurboModuleRegistry.getEnforcing('{{ self.config.project.tm.spec_name() }}'); +export default TurboModuleRegistry.getEnforcing('{{ self.config.project.name_upper_camel() }}'); diff --git a/crates/ubrn_cli/src/config/mod.rs b/crates/ubrn_cli/src/config/mod.rs index ae26ea4a..b8f6dea7 100644 --- a/crates/ubrn_cli/src/config/mod.rs +++ b/crates/ubrn_cli/src/config/mod.rs @@ -7,7 +7,6 @@ mod npm; use camino::{Utf8Path, Utf8PathBuf}; use globset::GlobSet; -use heck::ToUpperCamelCase; pub(crate) use npm::PackageJson; use serde::Deserialize; @@ -46,7 +45,7 @@ pub(crate) struct ProjectConfig { impl ProjectConfig { fn default_name() -> String { - workspace::package_json().trimmed_name() + workspace::package_json().raw_name() } fn default_repository() -> String { @@ -57,13 +56,7 @@ impl ProjectConfig { } fn trim_react_native(name: &str) -> String { - name.strip_prefix("RN") - .unwrap_or(name) - .replace("ReactNative", "") - .replace("react-native", "") - .trim_matches('-') - .trim_matches('_') - .to_string() + name.trim_matches('-').trim_matches('_').to_string() } impl ProjectConfig { @@ -74,7 +67,7 @@ impl ProjectConfig { impl ProjectConfig { fn name(&self) -> String { - self.name.clone() + trim_react_native(&self.name) } pub(crate) fn raw_name(&self) -> &str { @@ -181,7 +174,8 @@ impl TurboModulesConfig { fn default_spec_name() -> String { let package_json = workspace::package_json(); - trim_react_native(&package_json.codegen().name) + let codegen_name = &package_json.codegen().name; + trim_react_native(codegen_name) } } @@ -201,7 +195,7 @@ impl TurboModulesConfig { } pub(crate) fn spec_name(&self) -> String { - self.spec_name.to_upper_camel_case() + self.spec_name.clone() } pub(crate) fn name(&self) -> String { diff --git a/crates/ubrn_cli/src/config/npm.rs b/crates/ubrn_cli/src/config/npm.rs index 485c5a70..b42462d0 100644 --- a/crates/ubrn_cli/src/config/npm.rs +++ b/crates/ubrn_cli/src/config/npm.rs @@ -25,7 +25,7 @@ impl PackageJson { self.name.clone() } - pub(crate) fn trimmed_name(&self) -> String { + pub(crate) fn name(&self) -> String { trim_react_native(&self.name) } @@ -34,14 +34,7 @@ impl PackageJson { .android .java_package_name .clone() - .unwrap_or_else(|| { - format!( - "com.{}", - trim_react_native(&self.raw_name()) - .to_upper_camel_case() - .to_lowercase() - ) - }) + .unwrap_or_else(|| format!("com.{}", self.name().to_upper_camel_case().to_lowercase())) } pub(crate) fn repo(&self) -> &PackageJsonRepo { diff --git a/crates/ubrn_cli/src/ios.rs b/crates/ubrn_cli/src/ios.rs index fcfa88fc..abb7c05e 100644 --- a/crates/ubrn_cli/src/ios.rs +++ b/crates/ubrn_cli/src/ios.rs @@ -47,9 +47,7 @@ impl IOsConfig { fn default_framework_name() -> String { format!( "{}Framework", - workspace::package_json() - .trimmed_name() - .to_upper_camel_case() + workspace::package_json().name().to_upper_camel_case() ) }