2013-05-14 19:04:22 +04:00
|
|
|
(function () {
|
|
|
|
"use strict";
|
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
var path = require('path'),
|
|
|
|
buildDirectory = path.resolve(process.cwd(), '../build'),
|
|
|
|
distDirectory = path.resolve(process.cwd(), '../dist'),
|
|
|
|
configureGrunt = function (grunt) {
|
|
|
|
|
|
|
|
var cfg = {
|
|
|
|
// Common paths to be used by tasks
|
|
|
|
paths: {
|
2013-06-15 22:31:49 +04:00
|
|
|
adminAssets: './core/admin/assets',
|
2013-06-10 17:52:04 +04:00
|
|
|
build: buildDirectory,
|
|
|
|
nightlyBuild: path.join(buildDirectory, 'nightly'),
|
|
|
|
dist: distDirectory,
|
|
|
|
nightlyDist: path.join(distDirectory, 'nightly')
|
2013-05-25 20:48:15 +04:00
|
|
|
},
|
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
|
|
|
|
// JSLint all the things!
|
|
|
|
jslint: {
|
|
|
|
directives: {
|
|
|
|
node: true,
|
|
|
|
browser: true,
|
|
|
|
nomen: true,
|
|
|
|
todo: true,
|
|
|
|
unparam: true
|
|
|
|
},
|
|
|
|
files: [
|
|
|
|
// Lint files in the root, including Gruntfile.js
|
|
|
|
"*.js",
|
|
|
|
// Lint core files, but not libs
|
|
|
|
["core/**/*.js", "!**/assets/lib/**/*.js", "!**/assets/tmpl/*.js"]
|
|
|
|
]
|
2013-05-26 21:17:46 +04:00
|
|
|
},
|
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
mochaTest: {
|
|
|
|
options: {
|
|
|
|
ui: "bdd",
|
|
|
|
reporter: "spec"
|
|
|
|
},
|
2013-05-25 20:48:15 +04:00
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
all: {
|
|
|
|
src: ['core/test/**/*_spec.js']
|
|
|
|
},
|
2013-05-25 20:55:23 +04:00
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
api: {
|
|
|
|
src: ['core/test/**/api*_spec.js']
|
2013-06-15 02:12:04 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
perm: {
|
|
|
|
src: ['core/test/**/permissions_spec.js']
|
2013-06-10 17:52:04 +04:00
|
|
|
}
|
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
// Compile all the SASS!
|
|
|
|
sass: {
|
|
|
|
admin: {
|
|
|
|
files: {
|
2013-06-15 22:31:49 +04:00
|
|
|
'<%= paths.adminAssets %>/css/screen.css': '<%= paths.adminAssets %>/sass/screen.scss'
|
2013-06-10 17:52:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
shell: {
|
|
|
|
bourbon: {
|
2013-06-15 22:31:49 +04:00
|
|
|
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-10 17:52:04 +04:00
|
|
|
commitNightly: {
|
|
|
|
command: 'git commit package.json -m "Nightly build <%= pkg.version %>"'
|
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
tagNightly: {
|
|
|
|
command: 'git tag <%= pkg.version %> -a -m "Nightly build <%= pkg.version %>"'
|
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
pushMaster: {
|
|
|
|
command: 'git push origin master'
|
2013-06-02 03:45:02 +04:00
|
|
|
},
|
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
pushMasterTags: {
|
|
|
|
command: 'git push origin master --tags'
|
2013-06-02 03:45:02 +04:00
|
|
|
}
|
2013-06-10 17:52:04 +04:00
|
|
|
},
|
2013-06-02 03:45:02 +04:00
|
|
|
|
|
|
|
handlebars: {
|
2013-06-10 17:52:04 +04:00
|
|
|
core: {
|
|
|
|
options: {
|
|
|
|
namespace: "JST",
|
|
|
|
processName: function (filename) {
|
|
|
|
filename = filename.replace('./core/admin/assets/tmpl/', '');
|
|
|
|
return filename.replace('.hbs', '');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
files: {
|
2013-06-15 22:31:49 +04:00
|
|
|
"<%= paths.adminAssets %>/tmpl/hbs-tmpl.js": "<%= paths.adminAssets %>/tmpl/**/*.hbs"
|
2013-06-10 17:52:04 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2013-05-14 19:04:22 +04:00
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
watch: {
|
|
|
|
handlebars: {
|
2013-06-15 22:31:49 +04:00
|
|
|
files: '<%= paths.adminAssets %>/tmpl/**/*.hbs',
|
2013-06-10 17:52:04 +04:00
|
|
|
tasks: ['handlebars']
|
2013-06-15 22:31:49 +04:00
|
|
|
},
|
|
|
|
sass: {
|
|
|
|
files: '<%= paths.adminAssets %>/sass/**/*',
|
|
|
|
tasks: ['sass:admin']
|
2013-06-10 17:52:04 +04:00
|
|
|
}
|
|
|
|
},
|
2013-05-20 08:22:00 +04:00
|
|
|
|
2013-06-10 17:52:04 +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-02 03:45:02 +04:00
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
zip: {
|
|
|
|
nightly: {
|
|
|
|
cwd: "<%= paths.nightlyBuild %>/<%= pkg.version %>/",
|
|
|
|
src: ["<%= paths.nightlyBuild %>/<%= pkg.version %>/**"],
|
|
|
|
dest: "<%= paths.nightlyDist %>/Ghost-Nightly-<%= pkg.version %>.zip"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
grunt.initConfig(cfg);
|
|
|
|
|
|
|
|
grunt.loadNpmTasks("grunt-jslint");
|
|
|
|
grunt.loadNpmTasks("grunt-mocha-test");
|
|
|
|
grunt.loadNpmTasks("grunt-shell");
|
|
|
|
grunt.loadNpmTasks("grunt-bump");
|
|
|
|
grunt.loadNpmTasks("grunt-zip");
|
|
|
|
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-copy");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-watch");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-sass");
|
|
|
|
grunt.loadNpmTasks("grunt-contrib-handlebars");
|
|
|
|
|
|
|
|
// Update the package information after changes
|
|
|
|
grunt.registerTask('updateCurrentPackageInfo', function () {
|
|
|
|
cfg.pkg = grunt.file.readJSON('package.json');
|
|
|
|
});
|
|
|
|
|
|
|
|
// Prepare the project for development
|
|
|
|
// TODO: Git submodule init/update (https://github.com/jaubourg/grunt-update-submodules)?
|
2013-06-15 22:31:49 +04:00
|
|
|
grunt.registerTask("init", ["shell:bourbon", "sass:admin", 'handlebars']);
|
2013-06-10 17:52:04 +04:00
|
|
|
|
|
|
|
// Run API tests only
|
|
|
|
grunt.registerTask("test-api", ["mochaTest:api"]);
|
|
|
|
|
2013-06-15 02:12:04 +04:00
|
|
|
// Run permisisons tests only
|
|
|
|
grunt.registerTask("test-p", ["mochaTest:perm"]);
|
|
|
|
|
2013-06-10 17:52:04 +04:00
|
|
|
// Run tests and lint code
|
|
|
|
grunt.registerTask("validate", ["jslint", "mochaTest:all"]);
|
|
|
|
|
|
|
|
/* Nightly builds
|
2013-06-15 22:31:49 +04:00
|
|
|
* - Bump patch version in package.json,
|
2013-06-10 17:52:04 +04:00
|
|
|
* - 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", [
|
|
|
|
"sass:admin",
|
|
|
|
"handlebars",
|
|
|
|
"validate",
|
|
|
|
"bump",
|
|
|
|
"updateCurrentPackageInfo",
|
|
|
|
"copy:nightly",
|
2013-06-15 02:12:04 +04:00
|
|
|
"zip:nightly"
|
2013-06-10 17:52:04 +04:00
|
|
|
/* Caution: shit gets real below here */
|
|
|
|
//"shell:commitNightly",
|
|
|
|
//"shell:tagNightly",
|
|
|
|
//"shell:pushMaster",
|
|
|
|
//"shell:pushMasterTags"
|
|
|
|
]);
|
|
|
|
|
|
|
|
// When you just say "grunt"
|
2013-06-15 22:31:49 +04:00
|
|
|
grunt.registerTask("default", ['sass:admin', 'handlebars']);
|
2013-06-10 17:52:04 +04:00
|
|
|
};
|
2013-05-13 23:18:20 +04:00
|
|
|
|
2013-05-14 19:04:22 +04:00
|
|
|
module.exports = configureGrunt;
|
2013-05-12 17:40:59 +04:00
|
|
|
|
2013-05-14 19:04:22 +04:00
|
|
|
}());
|