Created
July 29, 2013 18:33
-
-
Save yoshuawuyts/6106527 to your computer and use it in GitHub Desktop.
When deploying to nodejitsu my tests were triggered, which I found odd. After examining the output, it seems as if sails lift -prod still triggers the develop tasks. Note: replaced all cookie values in output with {{}}
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
///////////////////////////////////////////////////////////////// | |
//////TABLE OF CONTENT/////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
// 1. Variables | |
// 2. Load modules | |
// 3. Build: Dir | |
// 4. Build: JS | |
// 5. Build: Styles | |
// 6. Build: Linker | |
// 7. Build: Concat | |
// 8. Test | |
// 9. Server | |
// 10.Tasks | |
///////////////////////////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
module.exports = function (grunt) { | |
///////////////////////////////////////////////////////////////// | |
//////1. VARIABLES/////////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
//CSS | |
var cssFilesToInject = [ | |
'linker/**/*.css' | |
]; | |
//JS | |
var jsFilesToInject = [ | |
//sails | |
'js/sails/socket.io.js', | |
'js/sails/sails.io.js', | |
'js/sails/app.js', | |
//angular | |
'js/controllers/*.js', | |
'js/directives/*.js', | |
'js/filters/*.js', | |
'js/services/*.js', | |
]; | |
// Modify css file injection paths to use | |
cssFilesToInject = cssFilesToInject.map(function (path) { | |
return '.tmp/public/' + path; | |
}); | |
// Modify js file injection paths to use | |
jsFilesToInject = jsFilesToInject.map(function (path) { | |
return '.tmp/public/' + path; | |
}); | |
///////////////////////////////////////////////////////////////// | |
//////2. lOAD MODULES//////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
// Get path to core grunt dependencies from Sails | |
var depsPath = grunt.option('gdsrc') || 'node_modules/sails/node_modules'; | |
grunt.loadTasks(depsPath + '/grunt-contrib-clean/tasks'); | |
grunt.loadTasks(depsPath + '/grunt-contrib-copy/tasks'); | |
grunt.loadTasks(depsPath + '/grunt-contrib-concat/tasks'); | |
grunt.loadTasks(depsPath + '/grunt-sails-linker/tasks'); | |
grunt.loadTasks(depsPath + '/grunt-contrib-watch/tasks'); | |
grunt.loadTasks(depsPath + '/grunt-contrib-uglify/tasks'); | |
grunt.loadTasks(depsPath + '/grunt-contrib-cssmin/tasks'); | |
// Load NPM modules | |
grunt.loadNpmTasks('grunt-contrib-stylus'); | |
grunt.loadNpmTasks('grunt-karma'); | |
grunt.loadNpmTasks('grunt-mocha-test'); | |
///////////////////////////////////////////////////////////////// | |
//////3. BUILD: DIR////////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
// Project configuration. | |
grunt.initConfig({ | |
pkg: grunt.file.readJSON('package.json'), | |
copy: { | |
dev: { | |
files: [ | |
{ | |
expand: true, | |
cwd: './assets', | |
src: ['**/*'], | |
dest: '.tmp/public' | |
} | |
] | |
}, | |
build: { | |
files: [ | |
{ | |
expand: true, | |
cwd: '.tmp/public', | |
src: ['**/*'], | |
dest: 'www' | |
} | |
] | |
} | |
}, | |
clean: { | |
dev: ['.tmp/public/**'], | |
build: ['www'] | |
}, | |
///////////////////////////////////////////////////////////////// | |
//////4. BUILD: JS/////////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
uglify: { | |
dist: { | |
src: ['.tmp/public/concat/production.js'], | |
dest: '.tmp/public/min/production.js' | |
} | |
}, | |
///////////////////////////////////////////////////////////////// | |
//////5. BUILD: STYLES/////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
stylus: { | |
compile: { | |
files: { | |
'.tmp/public/styles/stddr.css': ['assets/styles/index.styl'], // 1:1 compile | |
'.tmp/public/linker/styles/stddr.css': ['assets/styles/index.styl'], // compile and concat into single file | |
} | |
} | |
}, | |
cssmin: { | |
dist: { | |
src: ['.tmp/public/concat/production.css'], | |
dest: '.tmp/public/min/production.css' | |
} | |
}, | |
///////////////////////////////////////////////////////////////// | |
//////6. SAILS LINKER//////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
'sails-linker': { | |
devJs: { | |
options: { | |
startTag: '// SCRIPTS', | |
endTag: '// SCRIPTS END', | |
fileTmpl: 'script(type="text/javascript", src="%s")', | |
appRoot: '.tmp/public' | |
}, | |
files: { | |
'views/**/*.jade': jsFilesToInject | |
} | |
}, | |
prodJs: { | |
options: { | |
startTag: '// SCRIPTS', | |
endTag: '// SCRIPTS END', | |
fileTmpl: 'script(type="text/javascript", src="%s")', | |
appRoot: '.tmp/public' | |
}, | |
files: { | |
'views/**/*.jade': ['.tmp/public/min/production.js'] | |
} | |
}, | |
devStyles: { | |
options: { | |
startTag: '// STYLES', | |
endTag: '// STYLES END', | |
fileTmpl: 'link(rel="stylesheet", href="%s")', | |
appRoot: '.tmp/public' | |
}, | |
files: { | |
'views/**/*.jade': cssFilesToInject | |
} | |
}, | |
prodStyles: { | |
options: { | |
startTag: '// STYLES', | |
endTag: '// STYLES END', | |
fileTmpl: 'link(rel="stylesheet", href="%s")', | |
appRoot: '.tmp/public' | |
}, | |
files: { | |
'views/**/*.jade': ['.tmp/public/min/production.css'] | |
} | |
}, | |
}, | |
///////////////////////////////////////////////////////////////// | |
//////7. BUILD: CONCAT/////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
concat: { | |
js: { | |
src: jsFilesToInject, | |
dest: '.tmp/public/concat/production.js' | |
}, | |
css: { | |
src: cssFilesToInject, | |
dest: '.tmp/public/concat/production.css' | |
} | |
}, | |
///////////////////////////////////////////////////////////////// | |
//////8. Test//////////////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
karma: { | |
unit: { | |
configFile: 'karma.conf.js', | |
singleRun: true | |
} | |
}, | |
mochaTest: { | |
models: { | |
options: { | |
reporter: 'progress', | |
}, | |
src: ['test/models/*js'] | |
}, | |
policies: { | |
options: { | |
reporter: 'progress', | |
}, | |
src: ['test/policies/*.js'] | |
}, | |
controllers: { | |
options: { | |
reporter: 'progress', | |
}, | |
src: ['test/s-controllers/*.js'] | |
}, | |
}, | |
///////////////////////////////////////////////////////////////// | |
//////9. Server////////////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
watch: { | |
api: { | |
// API files to watch: | |
files: ['api/**/*'], | |
tasks: ['test'] | |
}, | |
js: { | |
// Assets to watch: | |
files: ['assets/js/**/*', 'assets/js/*'], | |
// When assets are changed: | |
tasks: ['compileAssets', 'linkAssets', 'test'] | |
} | |
}, | |
}); | |
// When API files are changed: | |
grunt.event.on('watch', function(action, filepath) { | |
grunt.log.writeln(filepath + ' has ' + action); | |
//Send a request to a development-only endpoint on the server | |
//which will reuptake the file that was changed. | |
var baseurl = grunt.option('baseurl') || grunt.option('http://localhost:'); | |
var gruntSignalRoute = grunt.option('signalpath') || grunt.option('1337'); | |
//var url = baseurl + gruntSignalRoute + '?action=' + action + '&filepath=' + filepath; | |
var url = 'http://localhost:1337/'; | |
require('http').get(url) | |
.on('error', function(e) { | |
console.error(filepath + ' has ' + action + ', but could not signal the Sails.js server: ' + e.message); | |
}); | |
}); | |
///////////////////////////////////////////////////////////////// | |
//////10. TASKS////////////////////////////////////////////////// | |
///////////////////////////////////////////////////////////////// | |
// When Sails is lifted: | |
grunt.registerTask('default', [ | |
'compileAssets', | |
'linkAssets', | |
'test', | |
'watch' | |
]); | |
grunt.registerTask('compileAssets', [ | |
'clean:dev', | |
'stylus', | |
'copy:dev' | |
]); | |
grunt.registerTask('linkAssets', [ | |
// Update link/script/template references in `assets` index.html | |
'sails-linker:devJs', | |
'sails-linker:devStyles' | |
]); | |
grunt.registerTask('test', [ | |
// 'karma', | |
'mochaTest' | |
]); | |
// Build the assets into a web accessible folder. | |
// (handy for phone gap apps, chrome extensions, etc.) | |
grunt.registerTask('build', [ | |
'compileAssets', | |
'linkAssets', | |
'clean:build', | |
'copy:build' | |
]); | |
// When sails is lifted in production | |
grunt.registerTask('prod', [ | |
'clean:dev', | |
'stylus', | |
'copy:dev', | |
'concat', | |
'uglify', | |
'cssmin', | |
'sails-linker:prodJs', | |
'sails-linker:prodStyles' | |
]); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
PS C:\Users\Yoshua\Documents\GitHub\stddr> sails lift -prod --verbose | |
verbose: Enabling CoffeeScript... | |
verbose: Enabling CoffeeScript... | |
verbose: Configuring app... | |
verbose: Using secret: 1b7a794c0a5004109ecd1b11fd2ebdbf in cookie parser | |
verbose: Using Express router... | |
verbose: Configuring express.static flat-file middleware... | |
verbose: Loading app Gruntfile... | |
verbose: Tracking new grunt child process... | |
verbose: Loading hook: request | |
verbose: Building middleware chain for view: 404 | |
verbose: Building middleware chain for view: 500 | |
verbose: Building middleware chain for view: includes / nav | |
verbose: Building middleware chain for view: layout | |
verbose: Building middleware chain for view: templates / landing | |
verbose: Building middleware chain for view: templates / root | |
verbose: Building middleware chain for view: ui / course | |
verbose: Building middleware chain for view: ui / home | |
verbose: Building middleware chain for view: ui / settings | |
verbose: Hook loaded successfully: views | |
verbose: Loading hook: controllers | |
verbose: Waiting to lift guard until all these events have fired :: [ 'router:after', 'hook:policies:bound' ] | |
verbose: Waiting to lift guard until all these events have fired :: [ 'router:after', | |
'hook:controllers:bound:actions', | |
'hook:policies:bound' ] | |
verbose: Building middleware registry... | |
verbose: Loading app controllers... | |
verbose: Loading hook: sockets | |
verbose: Loading hook: pubsub | |
verbose: Hook loaded successfully: pubsub | |
verbose: Loading hook: policies | |
verbose: Loading app policies... | |
verbose: Finished loading policy middleware logic. | |
verbose: Hook loaded successfully: policies | |
verbose: Loading hook: csrf | |
verbose: Hook loaded successfully: csrf | |
verbose: Loading hook: i18n | |
verbose: Hook loaded successfully: i18n | |
verbose: Loading hook: http | |
verbose: Hook loaded successfully: http | |
verbose: Configuring socket (ws://) server... | |
verbose: Hook loaded successfully: sockets | |
verbose: Hook loaded successfully: controllers | |
verbose: Starting ORM... | |
verbose: Hook loaded successfully: orm | |
verbose: Hooks loaded! | |
verbose: Instantiate middleware registry... | |
verbose: Loading router... | |
verbose: Binding route :: /* | |
verbose: Binding route :: /* | |
verbose: Binding policies :: | |
verbose: Loading app policies... | |
verbose: Finished loading policy middleware logic. | |
verbose: Hook loaded successfully: policies | |
verbose: Loading hook: csrf | |
verbose: Hook loaded successfully: csrf | |
verbose: Loading hook: i18n | |
verbose: Hook loaded successfully: i18n | |
verbose: Loading hook: http | |
verbose: Hook loaded successfully: http | |
verbose: Configuring socket (ws://) server... | |
verbose: Hook loaded successfully: sockets | |
verbose: Hook loaded successfully: controllers | |
verbose: Starting ORM... | |
verbose: Hook loaded successfully: orm | |
verbose: Hooks loaded! | |
verbose: Instantiate middleware registry... | |
verbose: Loading router... | |
verbose: Binding route :: /* | |
verbose: Binding route :: /* | |
verbose: Binding policies :: | |
{ '*': [ [Function: alwaysAllow] ] } | |
to controllers :: | |
{} | |
verbose: Applying policy :: [ [Function: alwaysAllow] ] to 404 | |
verbose: Applying policy (function alwaysAllow(req, res, next) { | |
next(); | |
}) to top-level controller middleware fn (404)... | |
verbose: Applying policy :: [ [Function: alwaysAllow] ] to 500 | |
verbose: Applying policy (function alwaysAllow(req, res, next) { | |
next(); | |
}) to top-level controller middleware fn (500)... | |
verbose: Applying policy :: [ [Function: alwaysAllow] ] to includes | |
verbose: Applying policy (function alwaysAllow(req, res, next) { | |
next(); | |
}) to controller's (includes) actions... | |
verbose: Applying policy :: [ [Function: alwaysAllow] ] to ui | |
verbose: Applying policy (function alwaysAllow(req, res, next) { | |
next(); | |
}) to controller's (ui) actions... | |
verbose: Policy-controller bindings complete! | |
verbose: Binding route :: /* | |
verbose: Binding route :: /* | |
verbose: Binding route :: / | |
verbose: Binding route :: / | |
verbose: Binding route :: /home | |
verbose: Binding route :: /home | |
verbose: Binding route :: /course | |
verbose: Binding route :: /course | |
verbose: Binding route :: /settings | |
verbose: Binding route :: /settings | |
verbose: Binding route :: get /csrfToken | |
verbose: Loading app services... | |
verbose: Waiting for all hooks to declare that they're ready... | |
verbose: Lifting guard-- all conditions satisfied. | |
verbose: Lifting guard-- all conditions satisfied. | |
verbose: Sails loaded successfully. | |
verbose: Starting app at C:\Users\Yoshua\Documents\GitHub\stddr... | |
verbose: Exposing global variables... | |
verbose: Running app bootstrap... | |
Sails.js <| | |
v0.9.3 |\ | |
/|.\ | |
/ || \ | |
,' |' \ | |
.-'.-==|/_--' | |
`--'-------' | |
__---___--___---___--___---___--___ | |
____---___--___---___--___---___--___-__ | |
info: Server lifted in `C:\Users\Yoshua\Documents\GitHub\stddr` | |
info: To see your app, visit http://localhost:1337 | |
info: To shut down Sails, press <CTRL> + C at any time. | |
debug: -------------------------------------------------------- | |
debug: :: Mon Jul 29 2013 20:20:08 GMT+0200 (W. Europe Daylight Time) | |
debug: | |
debug: Environment : development | |
debug: Port : 1337 | |
debug: -------------------------------------------------------- | |
verbose: Socket is trying to connect... | |
verbose: Generated new session for socket.... { headers: | |
{ host: 'localhost:1337', | |
connection: 'keep-alive', | |
'user-agent': 'Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/28.0.1500.72 Safa | |
ri/537.36', | |
accept: '*/*', | |
referer: 'http://localhost:1337/', | |
'accept-encoding': 'gzip,deflate,sdch', | |
'accept-language': 'en-US,en;q=0.8', | |
cookie: 'anchor-install-timezone=-120; anchorcms-install={{}}' }, | |
address: { address: '{{}}', port: {{}} }, | |
time: 'Mon Jul 29 2013 20:20:09 GMT+0200 (W. Europe Daylight Time)', | |
query: { t: '1375122008871' }, | |
url: '/socket.io/1/?t={{}}', | |
xdomain: false, | |
secure: undefined, | |
issued: {{}}, | |
cookie: | |
{ 'anchor-install-timezone': '-120', | |
'anchorcms-install': '{{}}', | |
'sails.sid': 's:{{}}' }, | |
sessionID: '{{}}', | |
session: { cookie: { httpOnly: true } } } | |
verbose: authorized | |
info: handshake authorized {{}} | |
verbose: Grunt :: Running "clean:dev" (clean) task | |
verbose: setting request GET /socket.io/1/websocket/{{}} | |
verbose: set heartbeat interval for client {{}} | |
verbose: client authorized for | |
verbose: websocket writing 1:: | |
verbose: A socket.io client ({{}}) connected successfully! | |
verbose: Grunt :: Cleaning ".tmp/public"... | |
verbose: Grunt :: OK | |
verbose: Grunt :: | |
Running "stylus:compile" (stylus) task | |
verbose: Grunt :: File .tmp\public\styles\stddr.css created. | |
verbose: Grunt :: File .tmp\public\linker\styles\stddr.css created. | |
verbose: Grunt :: | |
verbose: Grunt :: Running "copy:dev" (copy) task | |
Created 10 directories, copied 20 files | |
Running "sails-linker:devJs" (sails-linker) task | |
Running "sails-linker:devStyles" (sails-linker) task | |
Running "mochaTest:models" (mochaTest) task | |
0 passing (0 ms) | |
Running "mochaTest:policies" (mochaTest) task | |
0 passing (0 ms) | |
Running "mochaTest:controllers" (mochaTest) task | |
0 passing (0 ms) | |
verbose: Grunt :: | |
verbose: Grunt :: Running "watch" task | |
verbose: Grunt :: Waiting... | |
verbose: emitting heartbeat for client {{}} | |
verbose: websocket writing 2:: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment