viatropos/tower — pull request #329 by viatropos (2012-10-05 10:46:37+00:00)
Title: Optimize global installation and app generation

Global installation should be significantly faster (more than 2x) because most of the modules aren't needed just for the command line when generating a new app.

Also, when generating an app I started tinkering with only requiring the absolute minimum of modules for the app to run. It brought startup time from about 200-250ms to 50-75ms. It may have been much higher before too, I think I started measuring after removing some things. It can still go further, but we basically would need to only require the exact methods we're using in the commands (so only the bare minimum of underscore helpers and such). Adding underscore and underscore.string already bring it up to 30ms to give you a feel for it.

Also notice that if you type `node -v` in the terminal, the result appears almost instant. However, if you type `tower -v`, or any other node module, there is a noticeable (but very slight) delay, even if you were to log at the beginning of the script (`./bin/tower`). So it can't be _instant_ instant, but close.

Later I will bundle the client `./vendor` assets into the npm install so when generating an app it uses the exact versions and doesn't have to download them. It's setup to use [bower](https://github.com/twitter/bower) now, but we should wait to add that as a requirement (if at all).

It should be quick speed up the `tower server` and `tower generate` commands too but I may wait on those. Ideally `tower server` will instantly respond with `"Tower server started on port x"`, where it just loads a plain express server with no middleware, then later appends the middleware (and if you visit a url before it's loaded it will eager load and you'll just wait the instant until the app finishes loading, but that will be hardly noticeable).

Same with the console, it should return the prompt as fast as possible, where it will then lazily load the rest of the app as you're typing so by the time you finish typing everything's loaded so it feels super fast.

Trying to make installation fast and smooth.