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

Ship yarn with hyper #381

Merged
merged 13 commits into from
Aug 14, 2017
Merged

Ship yarn with hyper #381

merged 13 commits into from
Aug 14, 2017

Conversation

sheerun
Copy link
Contributor

@sheerun sheerun commented Jul 24, 2016

This is a step towards #282 and makes sure hyperterm always
installs with the same npm version it shipped with.

It also drops dependency on system's node.

@sheerun sheerun mentioned this pull request Jul 24, 2016
@rauchg
Copy link
Member

rauchg commented Jul 24, 2016

That's really sweet. I wonder how much bigger it makes our compressed builds / startup time ?

@leo
Copy link
Contributor

leo commented Jul 25, 2016

Keep this in mind.

@sheerun
Copy link
Contributor Author

sheerun commented Jul 25, 2016

It doesn't mater as you embed npm, and have can fix working version if you need.

Spawning a new process simply doesn't work because there's no node installed in electron app..

@rauchg
Copy link
Member

rauchg commented Jul 26, 2016

I would love for @othiym23 to re-visit that decision. It's kind of a bummer that we need to ask the user to install node to use npm as an API :(

@sindresorhus
Copy link
Contributor

Spawning a new process simply doesn't work because there's no node installed in electron app..

You can. Just spawn process.execPath with the ELECTRON_RUN_AS_NODE environment variable, and it will use the embedded Node.js.

childProcess.execSync(process.execPath, ['npm', 'install'], {env: {ELECTRON_RUN_AS_NODE: true}});

@sheerun
Copy link
Contributor Author

sheerun commented Jul 27, 2016

I tried to implement it as @sindresorhus proposed, but for some reason electron refuses to exit when running npm with it. Here's how to reproduce:

export CWD=$(pwd) && (cd ~/.hyperterm_plugins && ELECTRON_RUN_AS_NODE=1 $CWD/node_modules/electron-prebuilt/dist/Electron.app/Contents/MacOS/Electron $CWD/node_modules/.bin/npm install --verbose)

For now it's blocking me, so any help would be appreciated..

@sheerun sheerun force-pushed the embednpm branch 2 times, most recently from e16afd8 to e436b9c Compare July 27, 2016 17:25
@rauchg
Copy link
Member

rauchg commented Jul 27, 2016

@sheerun seems like something we should be reporting to the electron team. This is looking very good btw, thanks @sindresorhus

@timothyis timothyis added the 👩‍🔬 Status: In Progress Issue or PR is currently active and work is in progress label Jul 29, 2016
@rauchg
Copy link
Member

rauchg commented Sep 19, 2016

@sheerun I'd love to merge this. Do you have any news about whether the issue with exiting was fixed? Or any workarounds?

@sheerun
Copy link
Contributor Author

sheerun commented Sep 19, 2016

The issue to fix is here: electron/electron#4944

With newest electron it kinda works, but takes 30 seconds to exit.

The best I can do is to rebase, catch.

@sheerun
Copy link
Contributor Author

sheerun commented Oct 23, 2016

@leo @rauchg I've replaced npm with yarn and it runs like wonder. It's good to merge.

There's issue with CI build as xo doesn't recognize queue package as dependency (it is). Maybe that's something @sindresorhus could check..

@matheuss
Copy link
Member

@sheerun queue is on the wrong package.json 😅 You need to move it to app/package.json 😄

@sheerun
Copy link
Contributor Author

sheerun commented Oct 23, 2016

@matheuss Is yarn on correct one?

@sheerun
Copy link
Contributor Author

sheerun commented Oct 23, 2016

Anyway, I fixed the issue with build. Ready for review and merge..

@sheerun
Copy link
Contributor Author

sheerun commented Nov 20, 2016

@matheuss This is no longer in-progress. This is done.

@matheuss
Copy link
Member

@sheerun thanks for the ping 😄

Is yarn on correct one?

Nope, you need to move it to the other one 👌

Could you please rebase to fix the merge conflicts? I'll make sure to discuss it with the team 👌

@sheerun
Copy link
Contributor Author

sheerun commented Nov 20, 2016

@matheuss @rauchg Done. I hope I've rebased it the last time... :)

@rauchg
Copy link
Member

rauchg commented Nov 21, 2016

This is fantastic!

On Sun, Nov 20, 2016 at 5:09 PM Adam Stankiewicz notifications@github.com
wrote:

@matheuss https://github.com/matheuss @rauchg
https://github.com/rauchg Done. I hope I've rebased it the last time...
:)


You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
#381 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAy8Us6bM5zNRj3eHTzAU1UIsqEwQ6kks5rAKkVgaJpZM4JTiip
.

@chabou chabou removed the 👩‍🔬 Status: In Progress Issue or PR is currently active and work is in progress label Jun 18, 2017
@chabou
Copy link
Collaborator

chabou commented Jun 18, 2017

It is finished! It only needs some testing on Windows/Linux! But I'm struggling with Win10 installation on BootCamp 😞

@chabou chabou mentioned this pull request Jun 18, 2017
@albinekb
Copy link
Contributor

albinekb commented Jun 18, 2017

the app/bin/yarn-standalone.js should be built in the build step, it shouldn't be checked into git

but ok for now, i can PR that

@chabou chabou added the 👩‍🔬 Status: In Progress Issue or PR is currently active and work is in progress label Jun 18, 2017
@chabou
Copy link
Collaborator

chabou commented Jun 18, 2017

Why? I consider yarn as an external program. If it was written in C++, we wouldn't want to compile it by ourself. What are the pros to not have this external dependency "compiled" and versioned in our git?

@chabou
Copy link
Collaborator

chabou commented Jun 24, 2017

Problem with production build on Windows solved (bad yarn.lock file).
Tested on Mac and Windows (dev and prod build).

Need a test on Linux

@chabou chabou removed the 👩‍🔬 Status: In Progress Issue or PR is currently active and work is in progress label Jun 24, 2017
@chabou
Copy link
Collaborator

chabou commented Jun 26, 2017

Tested.

Ready to be merged

app/plugins.js Outdated

cp.exec(fullcmd, {
cwd: path,
env,
Copy link
Contributor

@ppot ppot Jun 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What happend when isDev === true since you are forcing env to be production

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This production flag is for yarn. See https://yarnpkg.com/lang/en/docs/cli/install/#toc-yarn-install-production
No side effect to Hyper.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok!

app/plugins.js Outdated
cwd: path,
env,
shell: true,
timeout: 1000 * 60 * 5,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add comment for // 5min

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ms('5m') will be better. Thank you to have pointed this

app/plugins.js Outdated
}
function yarn(args, cb) {
spawnQueue.push(end => {
const fullcmd = [process.execPath, yarnPath].concat(args).join(' ');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fullcmd ? Simply use cmd or command

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will

app/plugins.js Outdated
@@ -228,46 +223,47 @@ function toDependencies(plugins) {
}

function install(fn) {
const {shell: cfgShell, npmRegistry} = exports.getDecoratedConfig();
const yarnPath = resolve(__dirname, '..', 'bin', 'yarn-standalone.js');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarnPath is not used elsewhere then inside yarn function. Better to move it inside function scope.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will move it (envconst too)

app/plugins.js Outdated
timeout: 1000 * 60 * 5,
stdio: ['ignore', 'ignore', 'inherit']
}, err => {
console.log('Done!');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Be more specific. What is Done! ? Plugins installation? Plugins update?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need this log.

const shellEnv = require('shell-env');
const queue = require('queue');

const spawnQueue = queue({concurrency: 1});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spawnQueue or yarnQueue

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spawnQueue is better.

@chabou
Copy link
Collaborator

chabou commented Jun 28, 2017

We should test plugins update too.

@chabou
Copy link
Collaborator

chabou commented Jun 28, 2017

Plugins update is ok!

@chabou chabou mentioned this pull request Jul 4, 2017
2 tasks
@Stanzilla
Copy link
Collaborator

  1. Close Hyper
  2. Edit config file by hand to add a new plugin
  3. Launch Hyper

For me it first errors that it can't load the new plugin, then the plugin "update" kicks in, which then installs the new plugin and then everything is fine. I just think that first error should be something we should avoid.

@chabou
Copy link
Collaborator

chabou commented Aug 12, 2017

@Stanzilla this error is currently shown without my PR.
It could be better handled but it should be another PR.

@chabou chabou merged commit cd1b8cd into vercel:master Aug 14, 2017
@chabou
Copy link
Collaborator

chabou commented Aug 14, 2017

FTR:
yarn v0.24.6 is embedded and extraResources feature of electron-builder is used to ship it in our bundle.

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.

None yet