kasper / phoenix

A lightweight macOS window and app manager scriptable with JavaScript
https://kasper.github.io/phoenix/
Other
4.39k stars 127 forks source link

REPL/CLI/Interactive Console #53

Open jasonm23 opened 8 years ago

jasonm23 commented 8 years ago

It would be nice if there was a REPL/CLI/Interactive Console to assist people who are getting to grips with the api.

Any feelings about this? @kasper

kasper commented 8 years ago

Definitely an interesting idea! I’m not sure how hard or easy this would be to implement...

jasonm23 commented 8 years ago

I'd like to have a crack at it, hopefully I'll have some time this weekend.

kasper commented 8 years ago

Ok, nice! Let me know what you discover.

kasper commented 8 years ago

This will probably require a completely different CLI-binary and creating a new context that can read from the standard input and write to the standard output interactively. This would obviously mean splitting the core into a separate framework to avoid duplicated code. I would guess implementing this would need quit a bit of work.

jasonm23 commented 8 years ago

I was thinking this might be do-able using a socket, didn't get time over the last couple of weekends, hopefully the christmas period will gift me some spare time ;)

tjbo commented 8 years ago

i think react native uses a socket to chrome web dev tools for this sort of thing.

alswl commented 8 years ago

Amazing idea, when I use awesome in Linux, I love the console.

metakirby5 commented 8 years ago

Just wanted to chime in and say that I implemented a REPL as a modal, if anyone is interested:

https://github.com/metakirby5/.dots/blob/master/osx/.phoenix.js#L1046

Usage

kasper commented 7 years ago

I think I’ll add a small socket server to Phoenix that will listen and consume data as a stream. It can then evaluate that into the current context and return the last value generated. Then, I can write a small bash script and include it in the app bundle that will act as an interactive console client.

This should also make #140 possible.

mafredri commented 6 years ago

I just updated to 2.6.1 and noticed that the Phoenix JSContext is picked up by the web inspector now:

screen shot 2018-04-09 at 9 41 08

This is basiically a REPL :). The only reason I noticed it is that I have the option set to automatically launch them:

screen shot 2018-04-09 at 9 43 29

Maybe this could be used or improved? For example, I noticed my config isn't available in the inspector.

Then again, maybe not suitable as an official REPL since it requires enabling Safari developer options, etc.

kasper commented 6 years ago

I noticed that too, but for some reason I was only able to get it to show up in debug builds. I was thinking of writing a Wiki page about it, if I could get it working properly.

mafredri commented 6 years ago

Interesting, I just pulled in mine from brew cask and it popped up 😅.

kasper commented 6 years ago

Maybe it was just conflicting since I had the older release build running or then something has been fixed in the newer app bundle and it only works in 2.6.1. 😄

kasper commented 6 years ago

Yes, it indeed seems to work out of the box with 2.6.1! 🎉

mafredri commented 6 years ago

Super sweet!

I now noticed that the reason I can't access my config is because I use webpack, so everything has it's own scope. But I can enter debugger; statements in my code and have Phoenix pause there, pretty neat!

One thing missing is being able to view the config as a source file though. And it would be super awesome to get source maps working. If you have any ideas I'm all ears, otherwise I might try to hack around a bit this weekend 😄.

PS. Do you think there might be any security implications from always exposing the context, considering that Phoenix has accessibility access, etc?

alswl commented 6 years ago

@jasonm23 Congratulations, phoenix is on Github trending today.

image

kasper commented 6 years ago

Wrote a short tutorial in the Wiki about how to use the Web Inspector to debug Phoenix. https://github.com/kasper/phoenix/wiki/Attaching-to-Web-Inspector-for-Debugging/

jasonm23 commented 2 years ago

I was trying to do this today, but after building and running the Debug release from source, I only see this in Safari > Develop > machine-name ...

Screenshot 2022-07-11 at 08 49 46

I've tried:

Is there anything I need to do?

kasper commented 2 years ago

@jasonm23 Ah, I think I forgot to add com.apple.security.get-task-allow to the debug entitlements (https://github.com/kasper/phoenix/blob/master/Phoenix/PhoenixDebug.entitlements) when I was refactoring. That needs to be fixed. Good catch!

jasonm23 commented 2 years ago

Cool I'll try adding it locally to get moving

jasonm23 commented 2 years ago

My debug entitlements now look like this...

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>com.apple.security.cs.disable-library-validation</key>
    <true/>
    <key>com.apple.security.get-task-allow</key>
    <true/>
</dict>
</plist>

Am I doing it right? Safari still doesn't see JSContext

kasper commented 2 years ago

@jasonm23 It should be right, maybe Apple has introduced some other entitlements as well? 🤔 I need to test it out.

jasonm23 commented 2 years ago

Thank you

jasonm23 commented 2 years ago

I'll try rebooting.. https://developer.apple.com/forums/thread/67689

jasonm23 commented 2 years ago

Got some downtime, reboot didn't fix anything :(