Skip to content

Commit

Permalink
fix(cli): pnpm detection on mobile init and xcode-script (#9553)
Browse files Browse the repository at this point in the history
* fix(cli): pnpm detection on mobile init

* small outputFiles fix

* same check for xcode-script

* Discard changes to tooling/cli/node/index.js

* Discard changes to tooling/cli/node/index.d.ts

---------

Co-authored-by: Amr Bashir <amr.bashir2015@gmail.com>
  • Loading branch information
lucasfernog and amrbashir authored May 12, 2024
1 parent bd64982 commit 4a33bc6
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
6 changes: 6 additions & 0 deletions .changes/fix-pnpm-check.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"tauri-cli": patch:bug
"@tauri-apps/cli": patch:bug
---

Fixes `pnpm` detection when initializing and running a mobile project.
4 changes: 3 additions & 1 deletion tooling/cli/src/mobile/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,9 @@ pub fn exec(
if let Some(bin_stem) = bin_path.file_stem() {
let r = regex::Regex::new("(nodejs|node)\\-?([1-9]*)*$").unwrap();
if r.is_match(&bin_stem.to_string_lossy()) {
if let Some(npm_execpath) = var_os("npm_execpath") {
if var_os("PNPM_PACKAGE_NAME").is_some() {
return ("pnpm".into(), build_args);
} else if let Some(npm_execpath) = var_os("npm_execpath") {
let manager_stem = PathBuf::from(&npm_execpath)
.file_stem()
.unwrap()
Expand Down
2 changes: 1 addition & 1 deletion tooling/cli/src/mobile/ios/xcode_script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub fn command(options: Options) -> Result<()> {
}

// `xcode-script` is ran from the `gen/apple` folder when not using NPM.
if var_os("npm_lifecycle_event").is_none() {
if var_os("npm_lifecycle_event").is_none() && var_os("PNPM_PACKAGE_NAME").is_none() {
set_current_dir(current_dir()?.parent().unwrap().parent().unwrap()).unwrap();
}

Expand Down
7 changes: 5 additions & 2 deletions tooling/cli/src/mobile/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,12 +261,15 @@ fn read_options(identifier: &str) -> CliOptions {
let runtime = tokio::runtime::Runtime::new().unwrap();
let options = runtime
.block_on(async move {
let addr_path = temp_dir().join(format!("{identifier}-server-addr"));
let (tx, rx) = WsTransportClientBuilder::default()
.build(
format!(
"ws://{}",
read_to_string(temp_dir().join(format!("{identifier}-server-addr")))
.expect("missing addr file")
read_to_string(&addr_path).unwrap_or_else(|e| panic!(
"failed to read missing addr file {}: {e}",
addr_path.display()
))
)
.parse()
.unwrap(),
Expand Down
5 changes: 3 additions & 2 deletions tooling/cli/templates/mobile/ios/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,9 @@ targets:
name: Build Rust Code
basedOnDependencyAnalysis: false
outputFiles:
- $(SRCROOT)/target/aarch64-apple-ios/${CONFIGURATION}/deps/lib{{app.lib-name}}.a
- $(SRCROOT)/target/x86_64-apple-ios/${CONFIGURATION}/deps/lib{{app.lib-name}}.a
- $(SRCROOT)/Externals/x86_64/${CONFIGURATION}/lib{{app.lib-name}}.a
- $(SRCROOT)/Externals/arm64/${CONFIGURATION}/lib{{app.lib-name}}.a
- $(SRCROOT)/Externals/arm64-sim/${CONFIGURATION}/lib{{app.lib-name}}.a
{{~#if ios-post-compile-scripts}}
postCompileScripts:
{{~#each ios-post-compile-scripts}}{{#if this.path}}
Expand Down

0 comments on commit 4a33bc6

Please sign in to comment.