Skip to content

Commit

Permalink
fine-tuned installation
Browse files Browse the repository at this point in the history
  • Loading branch information
lancejpollard committed Sep 13, 2012
1 parent 5bc58cf commit 7a3b21e
Show file tree
Hide file tree
Showing 7 changed files with 92 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
@@ -1,7 +1,7 @@
language: node_js
node_js:
- 0.8
install: npm install ; npm install git://github.com/viatropos/coffeecup.git --force ; npm install git://github.com/viatropos/coffee-script.git --force ; npm install mongodb
install: npm install ; npm run-script install-dev
#before_script:
# - "export DISPLAY=:99.0"
# - "sh -e /etc/init.d/xvfb start"
Expand Down
3 changes: 2 additions & 1 deletion Makefile
Expand Up @@ -29,7 +29,8 @@ whitespace:
cake clean

install:
npm install -g .
npm install
npm install-dev

watch:
grunt start --config ./grunt.coffee
Expand Down
37 changes: 37 additions & 0 deletions bin/dependencies
@@ -0,0 +1,37 @@
#!/usr/bin/env node

// process.env.NODE_PATH.split(':'), process.config.variables.node_prefix
// global npm on windows: C:\Program Files (x86)\nodejs\node_modules\
// global node on windows: process.execPath == C:\Program Files (x86)\nodejs\node.exe
// if process.cwd().match(dirname(process.execPath)) then maybe assume it's npm install -g
var fs = require('fs');
var path = require('path');

// @todo normalize install/global directories in a more robust way, for comparison.
var normalize = function(directory) {
return directory.split(path.sep).slice(0, 3).join(path.sep);
}

// '/usr/local/lib/node_modules/tower' => '/usr/local'
// 'C:\Program Files (x86)\nodejs\node_modules\tower' => 'C:\Program Files (x86)\nodejs'
var installDirectory = normalize(process.cwd());
// '/usr/local/Cellar/node/0.8.2/bin'
var globalDirectory = normalize(path.dirname(process.execPath));

var packageJSON = JSON.parse(fs.readFileSync('package.json', 'utf-8'));
var dependencies;

if (installDirectory === globalDirectory) {
// if you're installing it globally, only include bare minimum.
dependencies = Object.keys(packageJSON['globalDependencies']);
} else {
// otherwise install like normal.
dependencies = Object.keys(packageJSON['localDependencies']);
}

// if it's installed from the git repo, then also install the test dependencies.
if (fs.existsSync('.gitignore')) {
dependencies = dependencies.concat(Object.keys(packageJSON['testDependencies']));
}

process.stdout.write(dependencies.join(' '));
7 changes: 7 additions & 0 deletions grunt.coffee
Expand Up @@ -95,6 +95,9 @@ module.exports = (grunt) ->
packageJSON:
files: ['packages/**/package.json', 'packages/tower-generator/server/generators/**/templates/**/*']
tasks: ['copy:packageJSON']
mainPackageJSON:
files: ['package.json']
tasks: ['injectTestDependencies:packageJSON']
build:
client: {}
uploadToGithub:
Expand All @@ -105,6 +108,9 @@ module.exports = (grunt) ->
client: {}
bundleTests:
client: {}
injectTestDependencies:
packageJSON:
src: ['package.json']

#jshint:
# options:
Expand Down Expand Up @@ -168,6 +174,7 @@ module.exports = (grunt) ->
grunt.registerTask 'default', 'coffee:all copy:packageJSON build:client copy:clientForTests coffee:tests concat:tests'
grunt.registerTask 'start', 'default watch'
grunt.registerTask 'dist', 'build uploadToGithub'
grunt.registerTask ''

grunt.registerTask 'uploadToGithub', ->
taskComplete = @async()
Expand Down
60 changes: 21 additions & 39 deletions package.json
Expand Up @@ -52,60 +52,42 @@
"tower": "./bin/tower"
},
"dependencies": {
"underscore": ">= 1.3.3",
"underscore.string": ">= 2.0.0",
"mime": ">= 1.2.4",
"qs": ">= 0.3.1",
"async": ">= 0.1.12",
"underscore.logger": ">= 0.3.1",
"mint": ">= 0.3.4",
"ejs": ">= 0.6.1",
"pathfinder": ">= 0.1.5",
"commander": ">= 0.4.0",
"express": "2.x",
"socket.io": ">= 0.8.7",
"useragent": ">= 1.0.5",
"URIjs": ">= 1.4.2",
"moment": ">= 1.5.1",
"node-uuid": ">= 1.3.0",
"geolib": ">= 0.0.1",
"validator": ">= 0.4.5",
"accounting": ">= 0.3.2",
"inflection": ">= 1.2.0",
"superagent": ">= 0.4.0",
"ember-metal-node": ">= 0.9.7",
"ember-runtime-node": ">= 0.9.7",
"ember-states-node": ">= 0.9.7",
"wrench": ">= 1.3.8",
"temp": "~0.4.0",
"knox": "0.0.11",
"gm": "~1.4.1",
"nodemailer": "~0.3.21",
"coffee-script": ">= 1.3.3"
"underscore": ">= 1.3.3"
},
"devDependencies": {
"cli-table": ">= 0.0.1",
"findit": ">= 0.1.1",
"stylus": ">= 0.17.0",
"ejs": ">= 0.6.1",
"gzip": ">= 0.1.0",
"knox": "0.0.11",
"mongodb": ">= 0.9.9-8",
"fibers": "~0.6.8",
"chokidar": "~0.4.0"
},
"testDependencies": {
"nodemailer": "~0.3.21",
"stylus": ">= 0.29.0",
"uglify-js": ">= 1.1.1",
"mocha": ">= 0.8.1",
"chai": ">= 0.3.3",
"sinon": ">= 1.3.1",
"gzip": ">= 0.1.0",
"mongodb": ">= 0.9.9-8",
"eco": ">= 0.1.0",
"mustache": ">= 0.4.0",
"jade": ">= 0.22.0",
"kue": ">= 0.3.4",
"socket.io-client": ">= 0.9.5",
"fibers": "~0.6.8",
"chokidar": "~0.4.0",
"kue": ">= 0.3.4"
},
"globalDependencies": {
"hook.io": "~0.8.10"
},
"localDependencies": {
"socket.io": ">= 0.8.7",
"socket.io-client": ">= 0.9.5"
},
"scripts": {
"test": "make test",
"start": "grunt start --config ./grunt.coffee",
"docs": "codo"
"docs": "codo",
"postinstall": "npm install $(./bin/dependencies)",
"install-dev": "npm install nodemailer stylus uglify-js mocha chai sinon eco mustache jade kue"
}
}
}
Expand Up @@ -35,17 +35,19 @@
"npm": ">= 1"
},
"dependencies": {
"underscore": ">= 0.0.1",
"underscore.string": ">= 0.0.1",
"mongodb": ">= 0.9.9-7",
"mint": ">= 0.3.0",
"npm": ">= 1.1.32",
"socket.io": ">= 0.8.7",
"socket.io-client": ">= 0.9.5",
"tower": ">= 0.4.1",
"coffee-script": ">= 1.3.3",
"coffeecup": ">= 0.3.0"
},
"optionalDependencies": {
"nodemailer": "~0.3.21"
},
"devDependencies": {
"stylus": ">= 0.17.0",
"stylus": ">= 0.29.0",
"less": ">= 1.2.2",
"uglify-js": ">= 1.1.1",
"pathfinder": ">= 0.3.0",
Expand Down
18 changes: 18 additions & 0 deletions packages/tower-tasks/tasks/index.coffee
Expand Up @@ -63,6 +63,24 @@ module.exports = (grunt) ->
fs.writeFileSync "public/javascripts/templates.js", string
taskDone()

grunt.registerMultiTask 'injectTestDependencies', 'Modify files in place', ->
done = @async()
files = grunt.file.expandFiles(@file.src)

iterator = (filePath, next) =>
process.nextTick ->
packageJSON = JSON.parse(fs.readFileSync(filePath, 'utf-8'))

if testDependencies = packageJSON['testDependencies']
packageJSON['scripts']['install-dev'] = "npm install #{Object.keys(testDependencies).join(' ')}"
process.nextTick ->
fs.writeFileSync(filePath, JSON.stringify(packageJSON, null, 2))
next()
else
next()

async.forEachSeries files, iterator, done

grunt.registerMultiTask 'copy', 'Copy files to destination folder and replace @VERSION with pkg.version', ->
replaceVersion = (source) ->
source.replace /@VERSION/g, grunt.config('pkg.version')
Expand Down

0 comments on commit 7a3b21e

Please sign in to comment.