Permalink
Browse files

optimize app installation and app generation (startup is faster)

  • Loading branch information...
lancejpollard committed Oct 5, 2012
1 parent ca1c429 commit 02c6d40e2431bfe468814697a5dc107699b9f0bd
Showing with 636 additions and 623 deletions.
  1. +3 −3 bin/install
  2. +5 −0 bin/tower
  3. +7 −5 index.js
  4. +31 −30 package.json
  5. +1 −1 packages/tower-application/server/assets.coffee
  6. +6 −6 packages/tower-command/server.coffee
  7. +11 −2 packages/tower-command/server/command.coffee
  8. +1 −1 packages/tower-command/server/console.coffee
  9. +12 −17 packages/tower-command/server/info.coffee
  10. +0 −1 packages/tower-command/server/new.coffee
  11. +2 −2 packages/tower-controller/server.coffee
  12. +2 −1 packages/tower-controller/server/caching.coffee
  13. +2 −0 packages/tower-controller/server/flash.coffee
  14. +2 −0 packages/tower-controller/server/net.coffee
  15. +2 −0 packages/tower-controller/server/renderers.coffee
  16. +2 −0 packages/tower-controller/server/sockets.coffee
  17. +2 −0 packages/tower-controller/shared/errors.coffee
  18. +2 −0 packages/tower-controller/shared/helpers.coffee
  19. +2 −0 packages/tower-controller/shared/rendering.coffee
  20. +2 −0 packages/tower-controller/shared/responder.coffee
  21. +2 −0 packages/tower-controller/shared/testHelper.coffee
  22. +17 −15 packages/tower-generator/server.coffee
  23. +44 −40 packages/tower-generator/server/actions.coffee
  24. +2 −0 packages/tower-generator/server/configuration.coffee
  25. +36 −37 packages/tower-generator/server/generator.coffee
  26. +161 −162 packages/tower-generator/server/generators/tower/app/appGenerator.coffee
  27. +0 −1 packages/tower-generator/server/generators/tower/app/templates/server.js
  28. +8 −9 packages/tower-generator/server/generators/tower/assets/assetsGenerator.coffee
  29. +14 −15 packages/tower-generator/server/generators/tower/controller/controllerGenerator.coffee
  30. +5 −6 packages/tower-generator/server/generators/tower/helper/helperGenerator.coffee
  31. +5 −6 packages/tower-generator/server/generators/tower/mailer/mailerGenerator.coffee
  32. +12 −13 packages/tower-generator/server/generators/tower/model/modelGenerator.coffee
  33. +8 −9 packages/tower-generator/server/generators/tower/scaffold/scaffoldGenerator.coffee
  34. +9 −10 packages/tower-generator/server/generators/tower/service/serviceGenerator.coffee
  35. +18 −19 packages/tower-generator/server/generators/tower/template/templateGenerator.coffee
  36. +12 −13 packages/tower-generator/server/generators/tower/view/viewGenerator.coffee
  37. +1 −5 packages/tower-generator/server/helpers.coffee
  38. +4 −4 packages/tower-generator/server/resources.coffee
  39. +2 −0 packages/tower-generator/server/shell.coffee
  40. +1 −0 packages/tower-generator/server/tst.coffee
  41. +1 −1 packages/tower-model/shared/cursor/serialization.coffee
  42. +1 −1 packages/tower-model/shared/metadata.coffee
  43. +1 −1 packages/tower-model/shared/relation.coffee
  44. +17 −0 packages/tower-support/client.coffee
  45. +30 −12 packages/tower-support/server.coffee
  46. +0 −27 packages/tower-support/shared.coffee
  47. +1 −1 packages/tower-support/shared/array.coffee
  48. +16 −8 packages/tower-support/shared/class.coffee
  49. +5 −8 packages/tower-support/shared/format.coffee
  50. +1 −3 packages/tower-support/shared/number.coffee
  51. +4 −6 packages/tower-support/shared/object.coffee
  52. +1 −3 packages/tower-support/shared/regexp.coffee
  53. +1 −30 packages/tower-support/shared/shared.coffee
  54. +12 −12 packages/tower-support/shared/string.coffee
  55. +3 −3 packages/tower-support/shared/url.coffee
  56. +6 −5 packages/tower-tasks/tasks/index.coffee
  57. +2 −2 packages/tower-view/shared/form.coffee
  58. +5 −5 packages/tower-view/shared/form/field.coffee
  59. +1 −1 packages/tower-view/shared/helpers/renderingHelper.coffee
  60. +2 −0 packages/tower-view/shared/view.coffee
  61. +1 −1 packages/tower/client.coffee
  62. +39 −30 packages/tower/server.coffee
  63. +1 −0 test/cases/command/server/newCommandTest.coffee
  64. +2 −3 test/cases/issues/shared/issue105Test.coffee
  65. +24 −26 test/cases/support/shared/stringTest.coffee
  66. +1 −1 test/mocha.opts
View
@@ -106,8 +106,8 @@ var isMac = process.platform == 'darwin';
var isWindows = process.platform == 'win32';
var isLinux = process.platform == 'linux';
-if (command == 'dependencies2') {
- var packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
+if (command == 'dependencies') {
+ var packageJSON = JSON.parse(fs.readFileSync(path.join(__dirname, '..', 'package.json'), 'utf-8'));
var dependencies = [];
var testDependencies = Object.keys(packageJSON['testDependencies']);
@@ -128,7 +128,7 @@ if (command == 'dependencies2') {
if (isGlobal || isGlobalLink) {
// if you're installing it globally, only include bare minimum.
dependencies = dependencies.concat(globalDependencies);
- } else if (isLocalLink) {
+ } else if (!isLocalLink) {
// otherwise install like normal.
dependencies = dependencies.concat(localDependencies);
}
View
@@ -1,9 +1,14 @@
#!/usr/bin/env node
+process.env.TOWER_COMMAND = process.argv[2];
+
var fs = require('fs');
var path = require('path');
var script = path.join(process.cwd(), 'scripts' , 'tower');
+if (process.env.TOWER_COMMAND == '-v')
+ process.env.TOWER_COMMAND = 'new'
+
if (fs.existsSync(script)) {
require(script);
} else {
View
@@ -1,11 +1,13 @@
var fs = require('fs');
var path = require('path');
-try {
- require('./coffee-inheritance.js');
-} catch (e) {
- //if (process.env.DEBUG)
- console.log(e);
+if (process.env.TOWER_COMMAND != 'new') {
+ try {
+ require('./coffee-inheritance.js');
+ } catch (e) {
+ //if (process.env.DEBUG)
+ console.log(e);
+ }
}
// node path resolution was broken before
View
@@ -57,39 +57,16 @@
"tower": "./bin/tower"
},
"dependencies": {
- "underscore": ">= 1.3.3",
+ "underscore": "~1.3.3",
"underscore.string": ">= 2.x",
- "underscore.logger": ">= 0.3.1",
- "mime": ">= 1.2.4",
- "qs": ">= 0.3.1",
- "async": ">= 0.1.12",
- "mint": ">= 0.3.4",
- "pathfinder": ">= 0.1.5",
- "commander": ">= 0.4.0",
- "express": "3.x",
- "URIjs": ">= 1.4.2",
- "moment": ">= 1.7.0",
- "node-uuid": ">= 1.3.0",
- "geolib": ">= 1.1.8",
"superagent": ">= 0.9.4",
- "validator": ">= 0.4.5",
- "accounting": ">= 0.3.2",
- "inflection": ">= 1.2.0",
- "ember-metal-node": ">= 1.0.0-pre",
- "ember-runtime-node": ">= 1.0.0-pre",
- "ember-states-node": ">= 1.0.0-pre",
- "coffee-script": ">= 1.3.3",
+ "inflection": ">= 1.2.3",
"wrench": ">= 1.3.8",
- "useragent": ">= 1.0.5",
- "gm": "~1.4.1",
- "temp": "~0.4.0",
- "crc": "~0.2.0",
- "ansi": "~0.1.2",
- "connect": ">= 2.4.6",
- "fresh": ">= 0.1.0",
"which": ">= 1.0.5",
+ "ansi": "~0.1.2",
"term-css": "~1.0.0",
- "grunt-contrib-less": "~0.3.0"
+ "pathfinder": ">= 0.0.1",
+ "commander": ">= 0.4.0"
},
"devDependencies": {
"findit": ">= 0.1.1",
@@ -119,8 +96,32 @@
"cheerio": ">= 0.10.0",
"colors": "~0.6.0-1"
},
- "globalDependencies": {},
- "localDependencies": {},
+ "globalDependencies": {
+ },
+ "localDependencies": {
+ "mime": ">= 1.2.4",
+ "async": ">= 0.1.12",
+ "mint": ">= 0.3.4",
+ "qs": ">= 0.3.1",
+ "crc": "~0.2.0",
+ "express": "3.x",
+ "URIjs": ">= 1.4.2",
+ "moment": ">= 1.7.0",
+ "node-uuid": ">= 1.3.0",
+ "geolib": ">= 1.1.8",
+ "validator": ">= 0.4.5",
+ "accounting": ">= 0.3.2",
+ "ember-metal-node": ">= 1.0.0-pre",
+ "ember-runtime-node": ">= 1.0.0-pre",
+ "ember-states-node": ">= 1.0.0-pre",
+ "coffee-script": ">= 1.3.3",
+ "useragent": ">= 1.0.5",
+ "gm": "~1.4.1",
+ "temp": "~0.4.0",
+ "connect": ">= 2.4.6",
+ "fresh": ">= 0.1.0",
+ "grunt-contrib-less": "~0.3.0"
+ },
"scripts": {
"test": "make test",
"start": "grunt start --config ./grunt.coffee",
@@ -38,7 +38,7 @@ Tower.ApplicationAssets =
content = ""
for path in paths
- content += File.read("public/#{type}#{path}#{extension}") + "\n\n"
+ content += fs.readFileSync("public/#{type}#{path}#{extension}", 'utf-8') + "\n\n"
fs.writeFileSync "public/#{type}/#{name}#{extension}", content
@@ -1,7 +1,7 @@
require './server/command'
-require './server/console'
-require './server/database'
-require './server/generate'
-require './server/info'
-require './server/new'
-require './server/server'
+#require './server/console'
+#require './server/database'
+#require './server/generate'
+#require './server/info'
+#require './server/new'
+#require './server/server'
@@ -1,8 +1,13 @@
+_ = Tower._
+
# @todo This should `require` the minimal amount of code possible,
# to execute as fast as possible.
#
# @module
Tower.Command =
+ load: (name) ->
+ require "./#{name}"
+
# Short names to invoke commands.
aliases:
c: 'console'
@@ -29,7 +34,11 @@ Tower.Command =
when 'exec'
@exec(argv[3])
else
- command = new Tower['Command' + _.camelize(command)](argv)
- command.run()
+ fn = Tower.Command.load(command)
+ if command == 'info'
+ fn(argv)
+ else
+ command = new Tower['Command' + _.camelize(command)](argv)
+ command.run()
module.exports = Tower.Command
@@ -60,7 +60,7 @@ class Tower.CommandConsole
client[Tower.namespace()] = app
client._r = (name) ->
(error, value) ->
- #args = Tower.SupportArray.args(arguments)
+ #args = _.args(arguments)
#error = args.shift()
if error
console.log(error)
@@ -1,10 +1,10 @@
-class Tower.CommandInfo
- constructor: (argv) ->
- @program = program = require('commander')
- program
- .version(Tower.version)
- .option('-v, --version')
- .option '-h, --help', '''
+module.exports = command = (argv) ->
+ program = require('commander')
+
+ program
+ .version(Tower.version)
+ .option('-v, --version')
+ .option '-h, --help', '''
\ \ Usage:
\ \ tower [command] [options]
\ \
@@ -18,15 +18,10 @@ class Tower.CommandInfo
\ \ -v, --version output version number
\ \
'''
- program.parse(argv)
+ program.parse(argv)
- program.help ||= program.rawArgs.length == 2
+ program.help ||= program.rawArgs.length == 2
- if program.help
- console.log program.options[program.options.length - 1].description
- process.exit()
-
- run: ->
-
-
-module.exports = Tower.CommandInfo
+ if program.help
+ console.log program.options[program.options.length - 1].description
+ process.exit()
@@ -71,7 +71,6 @@ command = (argv) ->
program.templateEngine = program.engine ||= if program.useJavascript then 'ejs' else 'coffee'
program.run = ->
- throw new Error('here')
Tower.Generator.run('app', program: program, appName: program.args[1])
program
@@ -1,3 +1,5 @@
+_ = Tower._
+
require './shared'
require './server/actions'
require './server/caching'
@@ -6,8 +8,6 @@ require './server/flash'
require './server/net'
require './server/sockets'
-_ = Tower._
-
Tower.Controller.include Tower.ControllerActions
Tower.Controller.include Tower.ControllerCaching
Tower.Controller.include Tower.ControllerEvents
@@ -1,6 +1,7 @@
+_ = Tower._
+
# @module
Tower.ControllerCaching =
-
etag: (content) ->
require('express/lib/utils').etag(content)
@@ -1,3 +1,5 @@
+_ = Tower._
+
Tower.ControllerFlash =
# Both send and recieve flash messages
flash: (type, msg) ->
@@ -1,3 +1,5 @@
+_ = Tower._
+
# @module
Tower.ControllerNet =
ip: Ember.computed(->
@@ -1,3 +1,5 @@
+_ = Tower._
+
Tower.Controller.addRenderers
text: (text, options, callback) ->
text = JSON.stringify(text) unless typeof(text) == 'string'
@@ -1,3 +1,5 @@
+_ = Tower._
+
# @module
Tower.ControllerSockets =
# @todo
@@ -1,3 +1,5 @@
+_ = Tower._
+
# @mixin
Tower.ControllerErrors =
ClassMethods:
@@ -1,3 +1,5 @@
+_ = Tower._
+
# @mixin
Tower.ControllerHelpers =
ClassMethods:
@@ -1,3 +1,5 @@
+_ = Tower._
+
# @mixin
Tower.ControllerRendering =
ClassMethods:
@@ -1,3 +1,5 @@
+_ = Tower._
+
# Don't need this for the client, @todo, remove for client.
class Tower.ControllerResponder
@respond: (controller, options, callback) ->
@@ -1,3 +1,5 @@
+_ = Tower._
+
# @todo Add method to mocha so you can both pass
# args to the test description and use those args in the test.
# @example
@@ -1,29 +1,31 @@
require './server/generator'
require './server/actions'
-require './server/configuration'
+#require './server/configuration'
require './server/helpers'
require './server/resources'
require './server/shell'
Tower.Generator.include Tower.GeneratorActions
-Tower.Generator.include Tower.GeneratorConfiguration
+#Tower.Generator.include Tower.GeneratorConfiguration
Tower.Generator.include Tower.GeneratorHelpers
Tower.Generator.include Tower.GeneratorResources
Tower.Generator.include Tower.GeneratorShell
Tower.GeneratorMocha = {}
require './server/generators/tower/app/appGenerator'
-require './server/generators/tower/model/modelGenerator'
-require './server/generators/tower/service/serviceGenerator'
-require './server/generators/tower/template/templateGenerator'
-require './server/generators/tower/view/viewGenerator'
-require './server/generators/tower/controller/controllerGenerator'
-require './server/generators/tower/helper/helperGenerator'
-require './server/generators/tower/assets/assetsGenerator'
-require './server/generators/tower/mailer/mailerGenerator'
-require './server/generators/tower/scaffold/scaffoldGenerator'
-require './server/generators/mocha/model/modelGenerator'
-require './server/generators/mocha/service/serviceGenerator'
-require './server/generators/mocha/controller/controllerGenerator'
-require './server/generators/library/libraryGenerator'
+
+unless Tower.isNew
+ require './server/generators/tower/model/modelGenerator'
+ require './server/generators/tower/service/serviceGenerator'
+ require './server/generators/tower/template/templateGenerator'
+ require './server/generators/tower/view/viewGenerator'
+ require './server/generators/tower/controller/controllerGenerator'
+ require './server/generators/tower/helper/helperGenerator'
+ require './server/generators/tower/assets/assetsGenerator'
+ require './server/generators/tower/mailer/mailerGenerator'
+ require './server/generators/tower/scaffold/scaffoldGenerator'
+ require './server/generators/mocha/model/modelGenerator'
+ require './server/generators/mocha/service/serviceGenerator'
+ require './server/generators/mocha/controller/controllerGenerator'
+ require './server/generators/library/libraryGenerator'
Oops, something went wrong.

0 comments on commit 02c6d40

Please sign in to comment.