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

Hyper CLI #2288

Closed
albinekb opened this issue Sep 26, 2017 · 13 comments
Closed

Hyper CLI #2288

albinekb opened this issue Sep 26, 2017 · 13 comments
Labels
❣️ Priority: High Issue is of High priority v2

Comments

@albinekb
Copy link
Contributor

As started in #282, we will in 2.0 have a way to manage hyper via the CLI.

@albinekb albinekb added ❣️ Priority: High Issue is of High priority v2 labels Sep 26, 2017
@albinekb albinekb mentioned this issue Sep 26, 2017
8 tasks
@chabou
Copy link
Contributor

chabou commented Oct 8, 2017

I spent some time to figure out how to do this. And here are my thoughts.
Any feedback will be warmly welcomed (cc @rauchg @albinekb @leo)

TL;DR Embedding hpm is pretty obvious and straight-forward. The most difficult part is to add a launch script that is in user PATH.

How VSCode works?

vscode is a good exemple because this is an Electron app that have a code command to install/uninstall/list plugins or launch app for a given directory/file.

Javascript CLI-Tool

After an amd-boostraping in src/cli.js (copied to "$VSCODE_PATH/resources/app/out/cli.js" at build time), it executes the real CLI entry point: src/vs/code/node/cli.ts

This entry point is responsible to parse args and to intercept/deal with some options like --help/--version or to launch app for a given directory/file. If option concern plugin management, it calls src/vs/code/node/cliProcessMain.js.

Shell command

How shell can execute this javascript file "$VSCODE_PATH/resources/app/out/cli.js"?
For every platform, there is a script that mainly resolve paths and launch Electron as node on this file.
resources/(darwin|windows|linux)/code.(sh|cmd)

The right command is moved at build time to /Resources/app/bin/

Path

How these scripts can be found by shell? vscode uses different mechanisms.

macOS

At run time, when user executes the dedicated command in vscode, it installs code command in PATH. To do this, it makes a symlink: /usr/local/bin/code -> /Applications/Visual Studio Code.app/Contents/Resources/app/bin/code here: src/vs/workbench/parts/cli/electron-browser/cli.contribution.ts

Windows

At installation time (InstallShield), app/bin is added to Path: build/win32/code.iss#L785

Debian

At installation time, app/bin is symlinked to /usr/bin/:
debian resources/linux/debian/postinst.template#L8
rpm resources/linux/rpm/code.spec.template#L32

How to achieve that in Hyper?

CLI tool

We should the same as vscode: a javascript standalone tool, launched by a cmd/sh script.

Path

I didn't find how to modify user PATH in a postinstall step with electron-builder.
On macOS, we are distributing zipped app. We need to add symlink at runtime. We could do the same on Linux.
On Windows, we could maybe add the right registry key with the same way that we add Windows context menu entry: app/index.js#L33

@chabou
Copy link
Contributor

chabou commented Oct 8, 2017

Due to directory organization on Windows, we should unlink old path and link new path after each update.

@albinekb
Copy link
Contributor Author

albinekb commented Oct 8, 2017

Sounds like a plan @chabou 👍

@markozxuu
Copy link

@chabou I like it 👍

@leo
Copy link
Contributor

leo commented Oct 9, 2017

Looks good to me! Thanks @chabou ❤️

But to be clear, the command will be called hyper and the official name for the binary (when referring to it in descriptions will be "Hyper CLI").

What I'm not sure on is whether or not we should also release the CLI on npm. But I don't think that makes any sense. Because even if people want to use it outside of Hyper, they can just do that, because it's in the PATH.

However, it might make sense when it comes to keeping it updated. I could imagine that some people might want to have a fresher version of Hyper CLI than the one their Hyper comes with. But all in all, I don't think that's a great idea since other versions of Hyper might support different configurations, etc. - so having a independently updated CLI doesn't sound good to me.

So feel free to add any additional opinions on that, but I think we should only have it inside Hyper (like @chabou suggested - no npm package).

@chabou
Copy link
Contributor

chabou commented Oct 9, 2017

@leo I'm totally agree with you and thank you for your clarification about hyper and "Hyper CLI".

As explained, we'll need to ship different boostrap script that depend on platform.
vscode use a gulp task to copy/rename files.

Until now, we have managed to not have a build script and to only depend on electron-builder. But I think that this time is over 😞 I didn't figure out how to copy/move some files, with electron-builder depending on targeted platform. Any idea?

If we need a build script:
Gulp do to much thing that we don't need, imo. What do you think about using RunJS? Minimalist, simple and javascript

@leo
Copy link
Contributor

leo commented Oct 9, 2017

That's easy!

Options like these (look close, there are several different ones on this page - one of them will definitely work) allow us to copy files over to a directory of our choice in the bundle.

May be specified in the platform options (e.g. in the mac).

I used this property in my electron-next-skeleton example project... 😊

@chabou
Copy link
Contributor

chabou commented Oct 9, 2017

OMG... How could I miss this 😱 ??!!

Thanks for your input @leo ❤️

@chabou chabou mentioned this issue Oct 9, 2017
@elijahgagne
Copy link

Any chance the Hyper CLI will let you create new tabs in Hyper that are started with arbitrary shells/arguments?

@albinekb
Copy link
Contributor Author

That sounds like a great idea @elijahgagne, not in the first release but after that I don't see a reason not to. PR's welcome 🤗

@chabou
Copy link
Contributor

chabou commented Jan 4, 2018

Great idea yes.

With first release it will only be possible to create new tab with a specified path:
#2375

@chabou
Copy link
Contributor

chabou commented Jan 23, 2018

Fixed by #2375

@chabou chabou closed this as completed Jan 23, 2018
@albinekb
Copy link
Contributor Author

albinekb commented Jan 23, 2018

Awesome work with the CLI! This issue is resolved. Let's open new ones for future development of it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
❣️ Priority: High Issue is of High priority v2
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants