bchatard / alfred-jetbrains

Alfred5 workflow to easily open your projects with your favorite JetBrains product.
MIT License
618 stars 49 forks source link

pstorm looks to be deprecated in new EAP #310

Closed PhilETaylor closed 1 year ago

PhilETaylor commented 1 year ago

FAQ

Describe the bug

in phpStorm 2023.1 EAP (without toolbox) it looks like the command line launcher pstorm is no longer a thing

To Reproduce

When you go to Tools -> Create Command Line Launcher you get:

ScreenShot-2023-03-01-20 49 28 Screenshot 2023-03-03 at 22 08 53

The link for online help goes to https://www.jetbrains.com/help/phpstorm/working-with-the-ide-features-from-command-line.html

I have added the following in my .zshrc (but including the whole .zshrc slows things down anyway https://github.com/bchatard/alfred-jetbrains/issues/271)

export PATH="/Applications/PhpStorm 2023.1 EAP.app/Contents/MacOS:$PATH"

Error on invoking this plugin with Alfred

Error: Unable to find bin for PhpStorm. Search for bin named: phpstorm, pstorm
    at getApplicationPath (file:///opt/homebrew/lib/node_modules/@bchatard/alfred-jetbrains/src/findProduct.js:128:11)
    at findProduct (file:///opt/homebrew/lib/node_modules/@bchatard/alfred-jetbrains/src/findProduct.js:172:31)
    at file:///opt/homebrew/lib/node_modules/@bchatard/alfred-jetbrains/src/index.js:16:17

- JetBrains - Open Project - v3 1.9.7 Alfred 5.0.6 darwin 22.4.0

Expected behavior

Alfred can no longer find phpStorm to launch

Alfred Version

5.06[2110]

Node Version

19.7.0

NPM Version

9.5.1

Jetbrains Product & Version

phpStorm 2023.1 EAP

Installation type

npm -i

OS

macOS 13.3 Beta 2

bchatard commented 1 year ago

Hi,

Putting path to new binaries location, solved the issue? About the sourcing of ~/.zshrc I notice slow startup only with heavy 3rd party module (like fig).

I will working on something more faster in few weeks/months, but will be for Alfred5+ only

PhilETaylor commented 1 year ago

I am already sourcing the .zshrc and accepting the 4 second delay (my causing, my zshrc does a lot :-))

The problem though is that your code:

if [[ -n "{query}" ]]; then
    QUERY="{query}"
    BIN=${jb_bin}
    PROJECT_NAME=${jb_project_name}

    source ~/.zshrc

    $(${BIN} "${QUERY}")

    echo ${PROJECT_NAME}
fi

runs AFTER the pstorm script filter which runs src/index.js

I have tried modifying the PATH also by changing the pstorm script filter to be

export PATH="/Applications/PhpStorm.app/Contents/MacOS:$PATH"
./node_modules/.bin/run-node src/index.js "$1" "PhpStorm"

and that did not work either

Im still unable to get this plugin to find the phpstorm binary

No idea where else to specifically state where the binary is

I even tried symlinking the binary into /usr/local/bin without success.

    0 lrwxr-xr-x@  1 phil        61 Mar 13 12:50 phpstorm -> /Applications/PhpStorm 2023.1 EAP.app/Contents/MacOS/phpstorm
    0 lrwxr-xr-x@  1 phil        61 Mar 13 12:51 pstorm -> /Applications/PhpStorm 2023.1 EAP.app/Contents/MacOS/phpstorm
Achieve777 commented 1 year ago

Yes, I tried the same operation as @PhilETaylor, but it didn't work either. There are still the same issues in the official version.

bchatard commented 1 year ago

I bump all available IDE to 2023.1 and no visible change. here with WebStorm (since PhpStorm is not yet available in 2023.1)

image

I use JetBrains Toolbox, configured like this

image

default settings when I install Toolbox few years ago (yes I haven't refresh my laptop since a while)

bchatard commented 1 year ago

hi,

take a look on latest release

PhilETaylor commented 1 year ago
Error: Can't find application path for PhpStorm.
    at getApplicationPath (file:///opt/homebrew/lib/node_modules/@bchatard/alfred-jetbrains/src/findProduct.js:165:9)
    at findProduct (file:///opt/homebrew/lib/node_modules/@bchatard/alfred-jetbrains/src/findProduct.js:175:31)
    at file:///opt/homebrew/lib/node_modules/@bchatard/alfred-jetbrains/src/index.js:16:17

- JetBrains - Open Project - v3 1.9.8 Alfred 5.1 darwin 22.5.0

PhilETaylor commented 1 year ago
$ which phpstorm
/Applications/PhpStorm 2023.1 EAP.app/Contents/MacOS/phpstorm
bchatard commented 1 year ago

Can you switch to regular version (EAP support is not "official")? And put the content of phpstorm?

PhilETaylor commented 1 year ago

I also have/had the standard regular version installed too

also note my default shell is zsh and not bash - no idea if that is an issue

 0 drwxr-xr-x@  3 phil     96 Apr  4 12:00 PhpStorm 2023.1 EAP.app
 0 drwxr-xr-x@  3 phil     96 Mar 29 22:03 PhpStorm.app
ScreenShot-2023-04-05-11 17 20
PhilETaylor commented 1 year ago

so a few other points

  1. I had an old /usr/local/bin/phpstorm - I have now deleted this
  2. debugging, I see that you are trying to look at the binary content of the phpstorm file and match a regex, this returns false for the toolbox and non toolbox case

If I change the RegExp for the non ToolBox case to JetBrains like

 // non Toolbox case
  const oldPattern = new RegExp("JetBrains");
  const oldMatch = oldPattern.exec(binContent);
  if (oldMatch && oldMatch.length === 1) {
    return oldMatch[1];
  }

THEN IT WORKS!!!

This is because phpstorm file is now a binary, and there is limited text in it - example:

ScreenShot-2023-04-05-11 33 28
PhilETaylor commented 1 year ago

I have no idea what's going on now. I have reinstalled from scratch and your original code works. hmm.....

edit..... ahhhh caching alfy.cache.get

PhilETaylor commented 1 year ago

ok ignore everything I said. It doesn't work. :( I need sleep and I'll try again

PhilETaylor commented 1 year ago

ok this works

  1. Install a fresh copy of your code and a fresh phpStorm (not EAP)
  2. add the path in findProduct.js
const path = `${process.env.PATH}:${toolboxScriptPath}:/Applications/PhpStorm.app/Contents/MacOS`;
  1. Change the RegEx
 const oldPattern = new RegExp("JetBrains");
  const oldMatch = oldPattern.exec(binContent);
  if (oldMatch && oldMatch.length === 1) {
    return oldMatch[1];
  }

and then it WORKS every time.

Bonus

Changing the path to have the EAP in it, also works and opens the EAP.

const path = `${process.env.PATH}:${toolboxScriptPath}:/Applications/PhpStorm 2023.1 EAP.app/Contents/MacOS`;
PhilETaylor commented 1 year ago

however... the new phpstorm binary holds the process open in Alfred, meaning that you can only launch one project because when you try to launch again using Alfred, to switch project, nothing happens - until you quit phpstorm, and then another phpstorm app opens with the second project magically like it was queued

It seems this new phpstorm binary acts totally different :(

bchatard commented 1 year ago

I have this, a helper script available globally

image

which contains link to "real bin"

image

I'm really curious about all this change...

PhilETaylor commented 1 year ago

That script appears to be "generated by toolbox"

Im not using toolbox to install/manage my phpStorm (why would anyone, its just overkill, uses resources that are not needed constantly running in the background)

bchatard commented 1 year ago

But did you generate script as mentioned in documentation?

PhilETaylor commented 1 year ago

Please read the opening post for this issue again.

You can no longer generate the script. phpStorm no longer has that option.

When you go to Tools -> Create command line launcher you get this popup

ScreenShot-2023-04-06-17 00 44

The "Online help" link goes to https://www.jetbrains.com/help/phpstorm/working-with-the-ide-features-from-command-line.html

The command line launcher script has been deprecated by phpStorm and is no longer generated or used.

bchatard commented 1 year ago

Ok, so for now I have no clean solution. Your solution works fine? Can you create a PR?

I'm currently working on a v2 which should fix this kind of issue

PhilETaylor commented 1 year ago

my solution works to launch phpStorm if its not yet open, but it cannot be used to switch projects if phpStorm is already open as the new binary just hangs until you close phpstorm, and once closed Alfred is then able to reopen it, meaning you cannot invoke phpStorm twice using your workflow, making the workflow pretty useless (Although, I rarely use your workflow now, as the new phpStorm UI has a great project switcher with cmd+o to launch the Recent Projects dialog

bchatard commented 1 year ago

Ok, maybe some additional parameters are needed to execute the process in background properly (like in toolbox script)

bchatard commented 1 year ago

I re-read the doc you mentioned in first comment, I will use open command from macOS to start ide

sangkyu-kim commented 1 year ago

My Intellij IDEA 2023.1 (New versions), got seems to be same issue.

bchatard commented 1 year ago

Hi,

If you are adventurous, you can try the v2 pre-release. Be careful, it's a pre-release, tested on Intel mac

Can be installed like this: npm install -g @bchatard/alfred-jetbrains@next

This should fix issue with 2023 version (tested with PyCharm, installed from dmg)

PhilETaylor commented 1 year ago

Absolutely flawless! (After I downgraded from EAP to Stable phpStorm)

🚀 Thanks!

Sign up for GitHub Sponsors, https://github.com/sponsors or add a donation/buy now button :)

bchatard commented 1 year ago

thanks for your feedback!

if you have time to send me (via an other issue), more feedback (speedier, search more accurate, macos version/chip etc) I really love it

bchatard commented 1 year ago

release v2 today