strongloop / loopback-sandbox

A repository for reproducing LoopBack community issues.
10 stars 186 forks source link

Add selfupdate script #2

Closed superkhau closed 9 years ago

superkhau commented 9 years ago
bajtos commented 9 years ago

I am not a big fan of Makefiles in Node projects, because they don't work on Windows. AFAIK, shelljs should make it super easy to write shell-like scripts in Node.

Also the convention is to add targets like selfupdate to package.json, so that one can run npm run selfupdate.

Last but not least, I'd like to see a command that will add all modifications to git index. This is the final user experience I have in my mind:

$ npm run selfupdate
$ git commit -m 'Update to loopback template x.y.z'
$ git push
bajtos commented 9 years ago

when asked for the application name, press

Please print this help message from the update script. Most people don't read docs :)

$ npm run selfupdate
Rebuilding the example. When asked for the application name, press <enter>

Another thing to consider: store the version of generator-loopback and loopback-workspace that generated the app. That's out of scope of this PR though.

superkhau commented 9 years ago

Please print this help message from the update script. Most people don't read docs :)

Good idea. Added. ;)

superkhau commented 9 years ago

@bajtos I'm having trouble executing slc loopback using shelljs (or even `child_process.exec for that matter) due to the yeoman prompt. Here is a gist: https://gist.github.com/superkhau/696826a05035c7c5e1b8

Basically gets stuck and you can't "press enter" to accept the value. Do you have a solution around this? I'm going to fall back to modifying the Makefile with the smaller items you proposed.

superkhau commented 9 years ago

Anyways, the current experience is pretty close to what you're saying:

$ make
$ git commit -m 'Update to loopback template x.y.z'
$ git push

is pretty close to:

$ npm run selfupdate
$ git commit -m 'Update to loopback template x.y.z'
$ git push

I am blocked on using shelljs (or child_process.exec for that matter) until we can figure out how to get "non-interactive" mode working with those libraries (ie. can't press when prompted in shelljs).

The two other things we need to decide are:

@bajtos @raymondfeng @ritch Thoughts?

bajtos commented 9 years ago

@superkhau Based on your comments, since the effort required to rework the Makefile to shelljs script is non-trivial, it is OK to stick to Makefile. Let's not spend too much time on this.

superkhau commented 9 years ago

@bajtos TY, merging.

superkhau commented 9 years ago

Wrong button. ;p