2013-06-25 15:43:15 +04:00
|
|
|
var path = require('path'),
|
2013-07-02 01:24:59 +04:00
|
|
|
buildDirectory = path.resolve(process.cwd(), '.build'),
|
|
|
|
distDirectory = path.resolve(process.cwd(), '.dist'),
|
2013-06-25 15:43:15 +04:00
|
|
|
configureGrunt = function (grunt) {
|
|
|
|
|
|
|
|
var cfg = {
|
|
|
|
// Common paths to be used by tasks
|
|
|
|
paths: {
|
|
|
|
adminAssets: './core/admin/assets',
|
|
|
|
build: buildDirectory,
|
|
|
|
nightlyBuild: path.join(buildDirectory, 'nightly'),
|
|
|
|
buildBuild: path.join(buildDirectory, 'build'),
|
|
|
|
dist: distDirectory,
|
|
|
|
nightlyDist: path.join(distDirectory, 'nightly'),
|
|
|
|
buildDist: path.join(distDirectory, 'build')
|
|
|
|
},
|
|
|
|
|
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
|
|
|
|
// JSLint all the things!
|
|
|
|
jslintm: {
|
|
|
|
node: {
|
|
|
|
directives: {
|
|
|
|
// node environment
|
|
|
|
node: true,
|
|
|
|
// browser environment
|
|
|
|
browser: false,
|
|
|
|
// allow dangling underscores in var names
|
|
|
|
nomen: true,
|
|
|
|
// allow to do statements
|
|
|
|
todo: true,
|
|
|
|
// allow unused parameters
|
|
|
|
unparam: true,
|
|
|
|
// don't require use strict pragma
|
|
|
|
sloppy: true
|
|
|
|
},
|
|
|
|
files: {
|
|
|
|
src: [
|
|
|
|
"*.js",
|
|
|
|
"core/**/*.js"
|
2013-06-25 16:38:41 +04:00
|
|
|
]
|
2013-06-10 17:52:04 +04:00
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
// Lint core files, but not libs, frontend or hbs files
|
|
|
|
exclude: [
|
|
|
|
"**/assets/lib/**/*.js",
|
|
|
|
"**/assets/js/**/*.js",
|
|
|
|
"**/assets/tpl/*.js"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
frontend: {
|
|
|
|
directives: {
|
|
|
|
// node environment
|
|
|
|
node: false,
|
|
|
|
// browser environment
|
|
|
|
browser: true,
|
|
|
|
// allow dangling underscores in var names
|
|
|
|
nomen: true,
|
|
|
|
// allow to do statements
|
|
|
|
todo: true,
|
|
|
|
// allow unused parameters
|
|
|
|
unparam: true
|
|
|
|
},
|
|
|
|
files: {
|
|
|
|
src: "**/assets/js/**/*.js"
|
2013-06-25 16:38:41 +04:00
|
|
|
}
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
mochaTest: {
|
|
|
|
options: {
|
|
|
|
ui: "bdd",
|
|
|
|
reporter: "spec"
|
2013-05-26 21:17:46 +04:00
|
|
|
},
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
all: {
|
|
|
|
src: ['core/test/**/*_spec.js']
|
|
|
|
},
|
2013-05-25 20:48:15 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
api: {
|
|
|
|
src: ['core/test/**/api*_spec.js']
|
|
|
|
},
|
2013-05-25 20:55:23 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
perm: {
|
|
|
|
src: ['core/test/**/permissions_spec.js']
|
|
|
|
}
|
|
|
|
},
|
2013-06-15 02:12:04 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
// Compile all the SASS!
|
|
|
|
sass: {
|
|
|
|
admin: {
|
|
|
|
files: {
|
|
|
|
'<%= paths.adminAssets %>/css/screen.css': '<%= paths.adminAssets %>/sass/screen.scss'
|
2013-06-10 17:52:04 +04:00
|
|
|
}
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
shell: {
|
|
|
|
bourbon: {
|
|
|
|
command: 'bourbon install --path <%= paths.adminAssets %>/sass/modules/'
|
2013-06-10 17:52:04 +04:00
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
commitNightly: {
|
|
|
|
command: 'git commit package.json -m "Nightly build <%= pkg.version %>"'
|
2013-06-10 17:52:04 +04:00
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
tagNightly: {
|
|
|
|
command: 'git tag <%= pkg.version %> -a -m "Nightly build <%= pkg.version %>"'
|
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
pushMaster: {
|
|
|
|
command: 'git push origin master'
|
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
pushMasterTags: {
|
|
|
|
command: 'git push origin master --tags'
|
|
|
|
}
|
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
handlebars: {
|
|
|
|
core: {
|
|
|
|
options: {
|
|
|
|
namespace: "JST",
|
|
|
|
processName: function (filename) {
|
|
|
|
filename = filename.replace('./core/admin/assets/tpl/', '');
|
|
|
|
return filename.replace('.hbs', '');
|
|
|
|
}
|
2013-06-02 03:45:02 +04:00
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
files: {
|
|
|
|
"<%= paths.adminAssets %>/tpl/hbs-tpl.js": "<%= paths.adminAssets %>/tpl/**/*.hbs"
|
2013-06-02 03:45:02 +04:00
|
|
|
}
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
groc: {
|
2013-06-25 22:10:33 +04:00
|
|
|
docs: {
|
|
|
|
options: {
|
|
|
|
"out": "./docs/",
|
|
|
|
"glob": [
|
|
|
|
"README.md",
|
|
|
|
"config.js",
|
|
|
|
"app.js",
|
|
|
|
"core/ghost.js",
|
|
|
|
"core/admin/assets/js/*.js",
|
|
|
|
"core/admin/assets/js/**/*.js",
|
|
|
|
"core/admin/controllers/*.js",
|
|
|
|
"core/frontend/**/*.js",
|
|
|
|
"core/lang/i18n.js",
|
|
|
|
"core/shared/**/*.js",
|
|
|
|
"core/shared/*.js",
|
|
|
|
"core/test/**/*.js",
|
|
|
|
"core/test/ghost.js"
|
|
|
|
]
|
|
|
|
}
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
watch: {
|
2013-06-02 03:45:02 +04:00
|
|
|
handlebars: {
|
2013-06-25 15:43:15 +04:00
|
|
|
files: '<%= paths.adminAssets %>/tpl/**/*.hbs',
|
|
|
|
tasks: ['handlebars']
|
2013-06-25 14:26:55 +04:00
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
sass: {
|
|
|
|
files: '<%= paths.adminAssets %>/sass/**/*',
|
|
|
|
tasks: ['sass:admin']
|
|
|
|
}
|
|
|
|
},
|
2013-05-14 19:04:22 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
copy: {
|
|
|
|
nightly: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
src: [
|
|
|
|
'**',
|
|
|
|
'!node_modules/**',
|
|
|
|
'!core/shared/data/*.db',
|
|
|
|
'!.sass*',
|
|
|
|
'!.af*',
|
|
|
|
'!.git*',
|
|
|
|
'!.groc*',
|
|
|
|
'!.travis.yml'
|
|
|
|
],
|
|
|
|
dest: "<%= paths.nightlyBuild %>/<%= pkg.version %>/"
|
|
|
|
}]
|
2013-06-10 17:52:04 +04:00
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
build: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
src: [
|
|
|
|
'**',
|
|
|
|
'!node_modules/**',
|
|
|
|
'!core/shared/data/*.db',
|
|
|
|
'!.sass*',
|
|
|
|
'!.af*',
|
|
|
|
'!.git*',
|
|
|
|
'!.groc*',
|
|
|
|
'!.travis.yml'
|
|
|
|
],
|
|
|
|
dest: "<%= paths.buildBuild %>/"
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
},
|
2013-05-20 08:22:00 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
compress: {
|
|
|
|
nightly: {
|
|
|
|
options: {
|
|
|
|
archive: "<%= paths.nightlyDist %>/Ghost-Nightly-<%= pkg.version %>.zip"
|
2013-06-19 01:25:32 +04:00
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
expand: true,
|
|
|
|
cwd: "<%= paths.nightlyBuild %>/<%= pkg.version %>/",
|
|
|
|
src: ["**"]
|
2013-06-10 17:52:04 +04:00
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
build: {
|
|
|
|
options: {
|
|
|
|
archive: "<%= paths.buildDist %>/Ghost-Build.zip"
|
2013-06-19 01:25:32 +04:00
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
expand: true,
|
|
|
|
cwd: "<%= paths.buildBuild %>/",
|
|
|
|
src: ["**"]
|
2013-06-10 17:52:04 +04:00
|
|
|
}
|
2013-07-02 00:58:47 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
bump: {
|
|
|
|
options: {
|
|
|
|
push: false
|
|
|
|
}
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
2013-06-10 17:52:04 +04:00
|
|
|
};
|
2013-05-13 23:18:20 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
grunt.initConfig(cfg);
|
|
|
|
|
|
|
|
grunt.loadNpmTasks("grunt-jslint");
|
|
|
|
grunt.loadNpmTasks("grunt-mocha-test");
|
|
|
|
grunt.loadNpmTasks("grunt-shell");
|
|
|
|
grunt.loadNpmTasks("grunt-bump");
|
|
|
|
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-compress");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-copy");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-watch");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-sass");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-handlebars");
|
|
|
|
grunt.loadNpmTasks('grunt-groc');
|
|
|
|
|
|
|
|
// Update the package information after changes
|
|
|
|
grunt.registerTask('updateCurrentPackageInfo', function () {
|
|
|
|
cfg.pkg = grunt.file.readJSON('package.json');
|
|
|
|
});
|
|
|
|
|
|
|
|
// jslintm aliased to jslint
|
|
|
|
grunt.registerTask("jslint", ["jslintm"]);
|
|
|
|
|
|
|
|
// Prepare the project for development
|
|
|
|
// TODO: Git submodule init/update (https://github.com/jaubourg/grunt-update-submodules)?
|
|
|
|
grunt.registerTask("init", ["shell:bourbon", "sass:admin", 'handlebars']);
|
|
|
|
|
|
|
|
// Run API tests only
|
|
|
|
grunt.registerTask("test-api", ["mochaTest:api"]);
|
|
|
|
|
|
|
|
// Run permisisons tests only
|
|
|
|
grunt.registerTask("test-p", ["mochaTest:perm"]);
|
|
|
|
|
|
|
|
// Run tests and lint code
|
|
|
|
grunt.registerTask("validate", ["jslint", "mochaTest:all"]);
|
|
|
|
|
|
|
|
// Generate Docs
|
|
|
|
grunt.registerTask("docs", ["groc"]);
|
|
|
|
|
|
|
|
/* Nightly builds
|
|
|
|
* - Bump patch version in package.json,
|
|
|
|
* - Copy files to build-folder/nightly/#{version} directory
|
|
|
|
* - Clean out unnecessary files (travis, .git*, .af*, .groc*)
|
|
|
|
* - Zip files in build folder to dist-folder/#{version} directory
|
|
|
|
* - git commit package.json -m "Nightly build #{version}"
|
|
|
|
* - git tag -a -m "Nightly build #{version}"
|
|
|
|
* - git push origin master
|
|
|
|
* - git push origin master --tags
|
|
|
|
* - TODO: POST to pubsubhubub to notify of new build?
|
|
|
|
*/
|
|
|
|
grunt.registerTask("nightly", [
|
|
|
|
"shell:bourbon",
|
|
|
|
"sass:admin",
|
|
|
|
"handlebars",
|
|
|
|
"validate",
|
|
|
|
"bump",
|
|
|
|
"updateCurrentPackageInfo",
|
|
|
|
"copy:nightly",
|
|
|
|
"compress:nightly"
|
|
|
|
/* Caution: shit gets real below here */
|
|
|
|
//"shell:commitNightly",
|
|
|
|
//"shell:tagNightly",
|
|
|
|
//"shell:pushMaster",
|
|
|
|
//"shell:pushMasterTags"
|
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask("build", [
|
|
|
|
"shell:bourbon",
|
|
|
|
"sass:admin",
|
|
|
|
"handlebars",
|
|
|
|
"copy:build",
|
|
|
|
"compress:build"
|
|
|
|
]);
|
|
|
|
|
|
|
|
// When you just say "grunt"
|
|
|
|
grunt.registerTask("default", ['sass:admin', 'handlebars']);
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = configureGrunt;
|