Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: be more tolerant when detecting Android Studio IDE on OSX #252

Merged
merged 3 commits into from
Apr 29, 2024

Conversation

Nthalk
Copy link
Contributor

@Nthalk Nthalk commented Mar 19, 2024

The Android Studio location on OSX uses non universal locations, "/Applications" for Android Studio installed standalone (or modern Jetbrains Toolbox), and a "~/Applications/JetBrains Toolbox/" for JetBrains toolbox installs (which mine did not install into).

Using the standard installers, I've ended up with my Toolbox in "/Applications" and my Android Studio in "~/Applications", which is the exact opposite of what ides.js expects. I'm not sure if I'm rocking a more modern setup (on my new-ish M1), but I do think we should try our best to support this variation.

This PR addresses this by detecting the first of four paths that resolve:

"/Applications/Android Studio.app"
"$HOME/Applications/Android Studio.app"
"/Applications/JetBrains Toolbox/Android Studio.app"
"$HOME/Applications/JetBrains Toolbox/Android Studio.app"

However, this requires removing the escaping, as utils.fileExists performs double escaping, yet the utils.generatePlistBuddyCommand requires it, so escaping was placed after dir resolution, and before command generation.

This CAN fail, if a user's home directory has characters in it that require escaping, but... Wow, I mean those people are probably used to headaches.

Nthalk added 2 commits March 19, 2024 14:55
OSX can install applications system wide, or for certain users. And what is chosen is not always known up front.

On my system, I had the reverse of what was expected, my sdk was installed in ~, and when I installed the Jetbrains Toolbox, I installed it into /.

The current source, expects the opposite, without a good reason or explanation of why this is preferred.

This PR allows the locations of both the tool box and the android sdk to exist in either.

Additionally, this PR addresses that Node 20.9 at least, will not resolve an escaped space in `path.join`, and instead fail, as it is escaping the directory fragments.

However, the command execution DOES require escaping of that part.

Test-Plan:

1. Run envinfo previously:
```
➤ npx envinfo --ides

  IDEs:
    IntelliJ: 2023.3.5
    Vim: 9.0 - /usr/bin/vim
    Xcode: 15.3/15E204a - /usr/bin/xcodebuild

```
2. Apply fixes

3. run envinfo
```
➤ npm run start

> [email protected] start
> node -r esm src/cli.js
...
  IDEs:
    Android Studio: 2023.2 AI-232.10300.40.2321.11567975
    IntelliJ: 2023.3.5
    Vim: 9.0 - /usr/bin/vim
    Xcode: 15.3/15E204a - /usr/bin/xcodebuild
...
```

4. Run tests
```
➤ npm run test

> [email protected] test
> jest --env=node && eslint src && prettier -l src/**/*.js

 PASS  __tests__/scopedPackages.test.js
 PASS  __tests__/duplicates.test.js
 PASS  __tests__/envinfo.test.js
 PASS  __tests__/utils.test.js

Test Suites: 4 passed, 4 total
Tests:       51 passed, 51 total
Snapshots:   13 passed, 13 total
Time:        0.449s, estimated 1s
Ran all test suites.
```
@Nthalk Nthalk changed the title Be more tolerant when detecting Android Studio IDE on OSX fix: be more tolerant when detecting Android Studio IDE on OSX Mar 19, 2024
@matej-podzemny
Copy link

Yes! BIG APPROVE! 🚀 we need this one to get into production ASAP

@Nthalk
Copy link
Contributor Author

Nthalk commented Apr 24, 2024

@gengjiawen ?

@gengjiawen
Copy link
Collaborator

Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants