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] embed hpm #2375

Merged
merged 39 commits into from Jan 9, 2018

Conversation

@chabou
Copy link
Collaborator

commented Oct 18, 2017

This PR has PR #2342 already merged into it.

Next steps:

  • Prevent Hyper CLI to create a new instance of Hyper if it is already launched. It should act the same way that launching Hyper twice by icon.
    • macOS (new tab)
    • Windows (new window)
    • Linux (new window)
  • Test it on Linux
  • Test it on Windows
    • Cmd
    • PowerShell
    • GitBash/CygWin
    • WSL ⚠️ we can only launch Hyper and not install/uninstall/list plugins due to Env var problem: see microsoft/WSL#1494

Bonus:

  • hyper <path> should open Hyper in this path
    • macOS
    • Windows
    • Linux
    • Check if path exists

Screencast:
hyper-cli

chabou added some commits Oct 9, 2017

Merge branch 'add_cli_cmd' into embed_hpm
* add_cli_cmd:
  Fix path for linux

@chabou chabou added this to the 2.0.0 milestone Oct 18, 2017

chabou added some commits Oct 18, 2017

Merge branch 'add_cli_cmd' into embed_hpm
* add_cli_cmd:
  Add Windows compatibility

@chabou chabou referenced this pull request Nov 2, 2017

Closed

[Hyper-cli] Add cli cmd #2342

chabou added some commits Nov 2, 2017

@chabou

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 4, 2017

One cool side effect is that Hyper CLI is our open <path> in new tab feature (on macOS):
hyper-cli-openinnewtab

But the more important thing is: THIS PR IS READY TO MERGE 🎉 🎉 🎉

@chabou chabou referenced this pull request Nov 8, 2017

Open

No man page included #99

@peterfraedrich

This comment has been minimized.

Copy link

commented Nov 9, 2017

I've submitted a PR for hpm that deprecates the use of npm-name and adds authenticated proxy support.
Link To PR

@Stanzilla

This comment has been minimized.

Copy link
Collaborator

commented Nov 19, 2017

I can't add reviewers but I nominate @albinekb :)

@htkoca

This comment has been minimized.

Copy link

commented Nov 26, 2017

Instead of going to the path in the first argument, can it be a command? hyper cd /path rather than just /path . This will allow cd to handle path existence (which it is designed to do), and also allow other applications to run things in hyper (such as an SFTP program opening a SSH connection in hyper)

Alternatively, use a flag argument. EX: `hyper --run "ls ~/". It might be out of scope with the current pull request though, but it's something to think about.

const args = require('args');
const chalk = require('chalk');
const opn = require('opn');
// const columnify = require('columnify');

This comment has been minimized.

Copy link
@albinekb

albinekb Nov 27, 2017

Contributor

remove

This comment has been minimized.

Copy link
@chabou

chabou Nov 27, 2017

Author Collaborator

It will be used by lsRemote

This comment has been minimized.

Copy link
@chabou

chabou Jan 9, 2018

Author Collaborator

fixed

return true;
}
let msg = chalk.red(`Error! Config file not found: ${api.configPath}\n`);
msg += 'Please launch Hyper and retry.';

This comment has been minimized.

Copy link
@albinekb

albinekb Nov 27, 2017

Contributor
const message = `
${chalk.red(`Error! Config file not found: ${api.configPath}`)}
Please launch Hyper and retry.
`

This comment has been minimized.

Copy link
@albinekb

albinekb Nov 27, 2017

Contributor

Should we add an issue to make the cli ask to create the file if it does not exists?

This comment has been minimized.

Copy link
@chabou

chabou Nov 27, 2017

Author Collaborator

Yes.
Config creation should remain an Hyper task. And yes, we should improve this automatic creation. But this is not a blocker. Most of case, config file will be present.

This comment has been minimized.

Copy link
@albinekb

albinekb Nov 27, 2017

Contributor

👌

reject(err);
return;
}
// C:\Users\<user>\AppData\Local\hyper\app-2.0.4\resources\bin

This comment has been minimized.

Copy link
@albinekb

albinekb Nov 27, 2017

Contributor

// C:\Users\<user>\AppData\Local\hyper\app-<version>\resources\bin

This comment has been minimized.

Copy link
@chabou

chabou Nov 27, 2017

Author Collaborator

I'll fix this

This comment has been minimized.

Copy link
@chabou

chabou Jan 9, 2018

Author Collaborator

fixed

cli/api.js Outdated
@@ -0,0 +1,112 @@
const fs = require('fs');
const os = require('os');
const npmName = () => Promise.resolve(); //require('npm-name');

This comment has been minimized.

Copy link
@albinekb

albinekb Nov 27, 2017

Contributor

🤔

This comment has been minimized.

Copy link
@chabou

chabou Nov 27, 2017

Author Collaborator

I hoped that this PR would have been merged sooner: dominictarr/rc#94

This comment has been minimized.

Copy link
@chabou

chabou Jan 9, 2018

Author Collaborator

fixed

process.exit(1);
});
/*
const lsRemote = () => {

This comment has been minimized.

Copy link
@albinekb

albinekb Nov 27, 2017

Contributor

Remove?

This comment has been minimized.

Copy link
@chabou

chabou Nov 27, 2017

Author Collaborator

It will be reactivated when NPM API request (URL and criteria) will be chosen.

This comment has been minimized.

Copy link
@chabou

chabou Jan 9, 2018

Author Collaborator

fixed

@chabou

This comment has been minimized.

Copy link
Collaborator Author

commented Nov 27, 2017

@htkoca thank you for your feedback. You're right. Passing command could be very usefull.

Imo, I prefer command as an option like your --run suggestion. Most of time, users will only want to open Hyper on a (default) location. I don't want to oblige them to add cd to their path.

@albinekb @rauchg @leo Thoughts ?

@chabou chabou referenced this pull request Jan 4, 2018

Closed

Hyper CLI #2288

@chabou

This comment has been minimized.

Copy link
Collaborator Author

commented Jan 9, 2018

For install, unsinstall, docs commands, hyper- prefix is added if not present.
For search and ls-remote commands, results are filtered to show only hyper- prefixed packages.

@albinekb
Copy link
Contributor

left a comment

Very nice work @chabou 🙏

@chabou chabou merged commit 5700690 into zeit:canary Jan 9, 2018

3 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

bgw added a commit to bgw/hyper that referenced this pull request Jan 12, 2018

Make CLI perform static analysis of config lazily
zeit#2375 adds a wrapper CLI tool that parses the ~/.hyper.js
configuration file. However, the static analysis logic can't possibly
handle every possible configuration file without executing it.

In my case, [my configuration file][0] defines a constant at the top,
which means that the `module.exports` definition isn't the first
statement. This breaks the parsing logic.

However, this static analysis is only necessary if one wishes to use the
CLI subcommands. They're not needed if one just wants to launch hyper.

Unfortunately, the existing implementation tries to read from the AST
immediately when `cli/api.js` is imported. This changes it to be lazy,
and uses memoization retain the same reference, allowing the AST to
still be mutated in-place.

[0]: https://github.com/bgw/dotfiles/blob/665e83fd7a13be675ad0ae984478d5b0de502ee1/hyper.js#L4
@@ -5,6 +5,9 @@ NAME="Hyper"
HYPER_PATH="$(dirname "$(dirname "$(dirname "$(realpath "$0")")")")"
ELECTRON="$HYPER_PATH/$NAME.exe"
if grep -q Microsoft /proc/version; then
echo "Warning! Due to WSL limitations, you can use CLI commands here. Please use Hyper CLI on cmd, PowerShell or GitBash/CygWin."

This comment has been minimized.

Copy link
@amckinlay

amckinlay Apr 26, 2018

What does this mean? Do you mean "you cannot use Hyper CLI here"?

This comment has been minimized.

Copy link
@Stanzilla

Stanzilla Apr 26, 2018

Collaborator

yeah just missing the 't

@amckinlay

This comment has been minimized.

Copy link

commented Apr 26, 2018

@chabou I left a comment about the language of the warning message in build/win/hyper.

As an aside, I wonder why my comment was on an outdated commit.

@chabou chabou deleted the chabou:embed_hpm branch Apr 27, 2018

@chabou

This comment has been minimized.

Copy link
Collaborator Author

commented Apr 27, 2018

Yes this is a typo.
Can you send a PR or open an issue if you can't?
Thank you 🙏

@Stanzilla Stanzilla referenced this pull request Apr 27, 2018

Merged

fix a typo #2945

@Stanzilla Stanzilla referenced this pull request Jan 23, 2019

Open

HyperCLI and WSL #3432

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.