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

Provide upgrade tooling for 1.x => 2.x #147

Closed
anulman opened this issue Feb 27, 2017 · 28 comments
Closed

Provide upgrade tooling for 1.x => 2.x #147

anulman opened this issue Feb 27, 2017 · 28 comments
Milestone

Comments

@anulman
Copy link
Collaborator

anulman commented Feb 27, 2017

Upgrading from 1.x => 2.x will change two major expectations:

  1. electron.js should live in ember-electron/main.js (vs. main dir); and
  2. ember-electron config in package.json should be removed, and replaced with a JSON or JS file at ember-electron/.electron-forge, matching config spec from the electron-forge project
  3. Remove the main: electron.js line from your package.json

High-level, we ought to help users handle this with a blueprint. Options are as follows, please vote with the corresponding reaction emoji / comment with a comment:

  • 👍 With ember g ember-electron, detect a 1.x app by virtue of electron.js living in the top-level dir; move electron.js; and automatically migrate the right variables in package.json;
  • 🎉 Add ember g ember-electron upgrade, throw if it's not a 1.x app; move electron.js and automatically migrate the right variables in package.json; or
  • ❤️ With ember g ember-electron, detect a 1.x app by virtue of electron.js living in the top-level dir; warn user they are upgrading and link to instructions (and/or recommend using ember g ember-electron upgrade?)
FYI

Just ran through the flow with @kevingelion on master as of this writing; if you've got a 1.x project and would like to try running 2.x you can:

  1. rm -rf node_modules/
  2. switch ember-electron to point to github:felixrieseberg/ember-electron
  3. run npm install
  4. clone isleofcode/electron-forge, check out feat/make-platforms, npm install, then npm link it in your ember project folder
  5. run ember g ember-electron
@anulman
Copy link
Collaborator Author

anulman commented Feb 27, 2017

One note from a debug session with @kevingelion: if we move the electron.js on the user's behalf, it risks borking relative paths. If we do move the file for the user, we can theoretically inspect it and adjust relative requires accordingly; else we ought to at least throw a big warning

@pichfl
Copy link
Collaborator

pichfl commented Feb 27, 2017

I think it's wise to print a warning if we find a electron.js in the root. Automatically moving it comes with many risks and doing it manually forces the user to check for other problems as well.

Regarding the electron forge dependency: can't we link to the branch in package.json while in beta?

@anulman
Copy link
Collaborator Author

anulman commented Feb 27, 2017

@pichfl can you elaborate on perceived risks re: moving electron.js? Hoping we can air out likely scenarios as part of this decision.

Re: including in package.json: last time I tried that, it caused several problems with the forge install. That may have just been my env though; if you've had a different experience then that would be my preference too 👍

@pichfl
Copy link
Collaborator

pichfl commented Feb 27, 2017

Relative paths as a single string would be quite easy to detect, but how about stuff like path.join(__dirname, 'dist', 'something.icns') or similar, which is not that rare when you try to add and change a tray icon and other assets?

Re package.json: Will try when I'm back in the office.

@anulman
Copy link
Collaborator Author

anulman commented Feb 28, 2017

n.b. Updated items 2 & 3 in first msg per debugging with @kevingelion

@anulman
Copy link
Collaborator Author

anulman commented Mar 2, 2017

Note to self: we should also include a gitignore in ember-electron dir, to ignore contents of out

@anulman
Copy link
Collaborator Author

anulman commented Mar 2, 2017

Note to self: consider including compilerc in ember-electron dir; will need to include it in default package.json copy-files

@jacobq
Copy link
Collaborator

jacobq commented Mar 2, 2017

@anulman sorry to bother you, but I would like to try previewing the 2.x/master code and am getting stuck. Could you explain the "nvm link" step mentioned above? Is nvm required? (I don't have it installed.) On POSIX systems can a symbolic link be used instead, i.e. ln -s ../electron-forge .? I tried the latter but then ember g ember-electron seems to have gotten stuck on the Installing electron build tools step. The spinner has been going round and round for 30+ minutes but CPU, disk, and network interfaces all appear very idle. (Env is Debian Linux 4.9 x64, node v6.10.0, npm v3.10.10)

@anulman
Copy link
Collaborator Author

anulman commented Mar 2, 2017

@jacobq derp, that's supposed to be npm link. Fixed.

Also, electron build tools definitely take some time to install at first. 30+ minutes sounds longer than I've ever heard though. Can you let me / us know if using npm link works any better?

@weedgrease
Copy link

weedgrease commented Mar 2, 2017

yeah... that's probably my fault. sorry!

@jacobq clone electron-forge somewhere external:

git clone git@github.com:isleofcode/electron-forge.git
cd electron-forge/
git checkout feat/make-platforms
npm link
cd <ember-electron project>
npm link electron-forge

@anulman
Copy link
Collaborator Author

anulman commented Mar 2, 2017

@kevingelion did you mean npm install for that first npm link?

Also, the second npm link should probably be npm link path/to/cloned-electron-forge

@jacobq
Copy link
Collaborator

jacobq commented Mar 2, 2017

Ahh, thanks for the help guys. That explains why it wasn't working. (Though I feel a bit sheepish for never having used npm link before.) It looks like this command will modify my system (i.e. require root privileges). Is there any way to do it w/o that, such as modifying my PATH?

@weedgrease
Copy link

weedgrease commented Mar 2, 2017

@anulman the first npm link automatically runs the install scripts - nothing wrong with npm install && npm link, though.

regarding specifying the path, yeah it's probably a good habit to do. i only linked one instance of it so it automatically detects the path.

@jacobq might be worth using nvm since your links will be per version of node/npm you're using and would probably not require sudo permissions? personally have never seen that.

@anulman
Copy link
Collaborator Author

anulman commented Mar 2, 2017

@jacobq I've not seen the root privileges requirement before; could this be because you're using a global / sudo-installed version of node?

@jacobq
Copy link
Collaborator

jacobq commented Mar 2, 2017

@anulman that's probably why; my bad. I'll worry about fixing that later as it looks like it just wanted to write to a directory that's for node anyway. However, after going through all this I get the following error:

error macos-alias@0.2.11: The platform "linux" is incompatible with this module.
error Found incompatible module

Looks like this is upstream: electron/forge#136

@anulman
Copy link
Collaborator Author

anulman commented Mar 2, 2017

Indeed it does. Are you using yarn?

@jacobq
Copy link
Collaborator

jacobq commented Mar 2, 2017

@anulman Not on purpose, but I do have it installed on my system. I will try uninstalling it once (unless you know an easier / less drastic way).

@jacobq
Copy link
Collaborator

jacobq commented Mar 2, 2017

OK, uninstalling yarn allowed me to successfully re-generate the blueprint. Now I have two electron.js files though: the pre-existing one in the project root (which appears to still be run with ember electron) and a newly generated one in ember-electron/. Based on reading previous discussions I'm going to try moving the pre-existing one into that folder (overwriting the new one), adjusting paths, etc. as needed. Thanks again for your help.

@anulman
Copy link
Collaborator Author

anulman commented Mar 3, 2017

Nice! Glad to hear that worked out. One extra note (it burned me when making a demo app earlier): please make sure that .compilerc is included in your copy-files too

@pichfl
Copy link
Collaborator

pichfl commented Mar 7, 2017

If you want to use a local version of ember-electron, see my comment in #160

@debelop13
Copy link

Sorry for my question, but how can I switch ember-electron to point to github:felixrieseberg/ember-electron? Thanks

@pichfl
Copy link
Collaborator

pichfl commented Mar 7, 2017

npm install felixrieseberg/ember-electron

@jacobq
Copy link
Collaborator

jacobq commented Mar 7, 2017

@debelop13 you can also adjust your package.json's dependencies to use a format described here:
https://docs.npmjs.com/files/package.json#git-urls-as-dependencies

@anulman
Copy link
Collaborator Author

anulman commented Mar 10, 2017

Once #170 lands we should revisit this

@pichfl pichfl added this to the 2.0 milestone Mar 14, 2017
@parm-ameotech
Copy link

parm-ameotech commented Apr 5, 2017

error

I am using master of ember electron 2.0 but when I am building a package it is giving me very strange issue. Please help I am not sure how to fix it. I am using windows.

@anulman
Copy link
Collaborator Author

anulman commented Apr 5, 2017

Realized the notes in the top comment were a bit out of date; just updated them. @parm-ameotech are you coming from a 1.x app? If so, please confirm:

  • Have you moved your electron.js file to ember-electron/main.js?
  • Have you removed the main line from package.json?
  • Have you run ember g ember-electron, which installed deps like electron-prebuilt-compile into your package.json?
  • Have you moved all relevant config from your package.json to the generated .electron-forge file?

Thanks!

@parm-ameotech
Copy link

parm-ameotech commented Apr 11, 2017

@anulman Thanks! for the reply but I make it work on linux machine. I think its better to use linux rather than windows.

@debelop13
Copy link

debelop13 commented Apr 26, 2017

Hi!

Upgrading from 1.0 to 2.0 I have problems with ES6..

There are 'requires' in my ember project.. like - require("electron").electron.webFrame.setZoomLevelLimits(1, 1); -
And is giving this error - Property object of MemberExpression expected node to be of a type ["Expression"] -

I change it for:
import {webFrame} from 'electron';
electron.webFrame.setZoomLevelLimits(1, 1);

Then, build is successful but index.html is not showing, and in console i have this eror Uncaught Error: Cannot find module 'myproject/routes/index'

And I don't understand why..

SOLVED:

requireNode() instead of require()

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

No branches or pull requests

6 participants