Nodeclipse / nodeclipse

Nodeclipse-1 : Eclipse plugin for Node.js, PhantomJS development (Nodeclipse core plugin); Maven and Gradle (with Android) plugins
https://nodeclipse.github.io/
158 stars 78 forks source link

a new project template for Express 4 (connect middleware is now splitted into several modules) #162

Closed paulvi closed 10 years ago

paulvi commented 10 years ago

discussion started in #161

As far as I remember, Express 4 has other way to create new project

dwwaddell commented 10 years ago

A common option in creating a project is the "-e" which uses ejs instead of Jade: express --help Usage: express [options] [dir] Options: -h, --help output usage information -V, --version output the version number -e, --ejs add ejs engine support (defaults to jade) --hbs add handlebars engine support -H, --hogan add hogan.js engine support -c, --css add stylesheet support (less|stylus|compass) (defaults to plain css) -f, --force force on non-empty directory

paulvi commented 10 years ago

From http://expressjs.com/guide.html "Using express(1) to generate an app"

$ npm install -g express-generator

then it is identical to what was before

the option is not mentioned at http://expressjs.com/guide.html

--hbs add handlebars engine support

paulvi commented 10 years ago

Related code

https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.ui/src/org/nodeclipse/ui/wizards/ExpressProjectWizard.java

https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.ui/src/org/nodeclipse/ui/wizards/ExpressProjectWizardPage.java

ghost commented 10 years ago

Thank's @PaulVI: I was curious to understand how the 3.2.6 express project generator is working. About express 4.9.0 - is it possible to provide express-generator npm module within Nodeclipse to be run with options from IDE in order to create a new express 4 project in Nodeclipse?

paulvi commented 10 years ago

As I see now, no changes are needed, but user needs to insure that he/she has run

$ npm install -g express-generator

so that he generated newer 4.x version

(When I was looking at express 3 months before, there was a mess with new express-generator using different executable name and syntax. Now it looks like version compatible).

ghost commented 10 years ago

Some simple hack like firing a $ express -V and parsing the return value should be enough to verify the module was installed globally and that it's version number is supported by the IDE.

If it was not installed (or if the version number was too old/recent may be?) then IDE notifies user the npm module should be (re)installed first.

On a larger scale, I think using express-generator like this would make a lot of sense in a longer run has it would reduce the maintenance burden on Nodeclipse: next time upgrading express in Nodeclipse would be about upgrading express-generator from NPM — hopefully...

paulvi commented 10 years ago

Things get blurred when looking at existing code https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.ui/src/org/nodeclipse/ui/preferences/PreferenceInitializer.java#L105-109

There is hidden EXPRESS_VERSION preference, but I don't really follow logic. It was written by @tomotaro1065 more than a ear ago.

Making it all straight need some time (about half a day), but I don't plan to spend time for Express that I don't use. At least alone... If we can agree to push it out together, I would sign up, even if you won't code.

ghost commented 10 years ago

I would not change the existing one but add a brand new Express 4 project type and Run As procedures.

I mean: creating Express 3 project should remain an option as some dev out there would still need it for a while.

Therefore we have two options:

1 - select Express version from the project creation panel then fork to a version specific project generation procedure depending on the selected Express version,

2 - leave the existing one untouched only to add a brand new project type for Express 4 that would fork to a new project generation procedure directly from menu selection.

For myself I would prefer that latter one as we don't know how long 3.x will survive (easier to get rid of it when the time will come if they remain unbound) and because it works around the usual legacy issues like this EXPRESS_VERSION constant like value initialized we don't know how / where.

As I said above there is a more subtle way to find out current express version nowadays — the main issue being about interacting with a shell from Java code, in my understanding.

I'm not a Java developer so coding it myself would not really make much sense but I could help other ways — just let me know how.

paulvi commented 10 years ago

First, I don't like creating GUI solution for some specific versions of specific frameworks.

FYI, some parts would be like executing from command line, see https://github.com/Nodeclipse/nodeclipse-1/blob/master/org.nodeclipse.ui/src/org/nodeclipse/ui/preferences/PreferenceInitializer.java#L176-190

paulvi commented 10 years ago

As answered on http://stackoverflow.com/questions/26007228/how-to-update-express-js-template-in-nodeclipse 2 steps are enough:

  1. get latest express-generator installed

    npm install -g express-generator

it would add express executable with the same params but for 4.x version of express

2 .Then Eclipse Nodeclipse preferences should be updated, e.g.

C:\Users\yourusername\AppData\Roaming\npm\node_modules\express-generator\bin\express