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: {
|
2013-07-11 23:02:18 +04:00
|
|
|
adminAssets: './core/client/assets',
|
2013-06-25 15:43:15 +04:00
|
|
|
build: buildDirectory,
|
|
|
|
nightlyBuild: path.join(buildDirectory, 'nightly'),
|
2013-07-11 18:05:10 +04:00
|
|
|
weeklyBuild: path.join(buildDirectory, 'weekly'),
|
2013-06-25 15:43:15 +04:00
|
|
|
buildBuild: path.join(buildDirectory, 'build'),
|
|
|
|
dist: distDirectory,
|
|
|
|
nightlyDist: path.join(distDirectory, 'nightly'),
|
2013-07-11 18:05:10 +04:00
|
|
|
weeklyDist: path.join(distDirectory, 'weekly'),
|
2013-06-25 15:43:15 +04:00
|
|
|
buildDist: path.join(distDirectory, 'build')
|
|
|
|
},
|
2013-07-11 18:24:33 +04:00
|
|
|
buildType: 'Build',
|
2013-06-25 15:43:15 +04:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
|
|
|
|
// JSLint all the things!
|
2013-07-31 12:21:22 +04:00
|
|
|
jslint: {
|
2013-07-11 23:02:18 +04:00
|
|
|
server: {
|
2013-06-25 15:43:15 +04:00
|
|
|
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",
|
2013-07-11 23:02:18 +04:00
|
|
|
"core/*.js",
|
|
|
|
"core/server/**/*.js"
|
2013-06-25 16:38:41 +04:00
|
|
|
]
|
2013-07-11 23:02:18 +04:00
|
|
|
}
|
2013-06-25 15:43:15 +04:00
|
|
|
},
|
2013-07-11 23:02:18 +04:00
|
|
|
client: {
|
2013-06-25 15:43:15 +04:00
|
|
|
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: {
|
2013-07-11 23:02:18 +04:00
|
|
|
src: "core/client/**/*.js"
|
|
|
|
},
|
|
|
|
exclude: [
|
|
|
|
"core/client/assets/**/*.js",
|
|
|
|
"core/client/tpl/**/*.js"
|
|
|
|
]
|
|
|
|
},
|
|
|
|
shared: {
|
|
|
|
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: [
|
|
|
|
"core/shared/**/*.js"
|
|
|
|
]
|
2013-07-24 07:25:08 +04:00
|
|
|
},
|
|
|
|
exclude: [
|
|
|
|
"core/shared/vendor/**/*.js"
|
|
|
|
]
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-07-10 02:54:57 +04:00
|
|
|
mochacli: {
|
2013-06-25 15:43:15 +04:00
|
|
|
options: {
|
|
|
|
ui: "bdd",
|
|
|
|
reporter: "spec"
|
2013-05-26 21:17:46 +04:00
|
|
|
},
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
all: {
|
2013-07-31 11:33:28 +04:00
|
|
|
src: ['core/test/unit/**/*_spec.js']
|
2013-06-25 15:43:15 +04:00
|
|
|
},
|
2013-05-25 20:48:15 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
api: {
|
2013-07-31 11:33:28 +04:00
|
|
|
src: ['core/test/unit/**/api*_spec.js']
|
2013-06-25 15:43:15 +04:00
|
|
|
},
|
2013-05-25 20:55:23 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
perm: {
|
2013-07-31 11:33:28 +04:00
|
|
|
src: ['core/test/unit/**/permissions_spec.js']
|
2013-06-25 15:43:15 +04:00
|
|
|
}
|
|
|
|
},
|
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-02 03:45:02 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
handlebars: {
|
|
|
|
core: {
|
|
|
|
options: {
|
|
|
|
namespace: "JST",
|
|
|
|
processName: function (filename) {
|
2013-07-12 00:00:41 +04:00
|
|
|
filename = filename.replace('core/client/tpl/', '');
|
2013-06-25 15:43:15 +04:00
|
|
|
return filename.replace('.hbs', '');
|
|
|
|
}
|
2013-06-02 03:45:02 +04:00
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
files: {
|
2013-07-11 23:02:18 +04:00
|
|
|
"core/client/tpl/hbs-tpl.js": "core/client/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",
|
2013-07-07 19:50:50 +04:00
|
|
|
"index.js",
|
2013-06-25 22:10:33 +04:00
|
|
|
"core/ghost.js",
|
2013-07-11 23:02:18 +04:00
|
|
|
"core/server/**/*.js",
|
2013-06-25 22:10:33 +04:00
|
|
|
"core/shared/**/*.js",
|
2013-07-11 23:02:18 +04:00
|
|
|
"core/client/**/*.js"
|
|
|
|
],
|
|
|
|
"except": [
|
|
|
|
"!core/client/assets/**/*.js",
|
|
|
|
"!core/client/tpl/**/*.js"
|
2013-06-25 22:10:33 +04:00
|
|
|
]
|
|
|
|
}
|
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-07-11 23:02:18 +04:00
|
|
|
files: 'core/client/tpl/**/*.hbs',
|
2013-06-25 15:43:15 +04:00
|
|
|
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/**',
|
2013-07-11 23:02:18 +04:00
|
|
|
'!core/server/data/*.db',
|
2013-06-25 15:43:15 +04:00
|
|
|
'!.sass*',
|
|
|
|
'!.af*',
|
|
|
|
'!.git*',
|
|
|
|
'!.groc*',
|
|
|
|
'!.travis.yml'
|
|
|
|
],
|
|
|
|
dest: "<%= paths.nightlyBuild %>/<%= pkg.version %>/"
|
|
|
|
}]
|
2013-06-10 17:52:04 +04:00
|
|
|
},
|
2013-07-11 18:05:10 +04:00
|
|
|
weekly: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
src: [
|
|
|
|
'**',
|
|
|
|
'!node_modules/**',
|
2013-07-11 23:02:18 +04:00
|
|
|
'!core/server/data/*.db',
|
2013-07-11 18:05:10 +04:00
|
|
|
'!.sass*',
|
|
|
|
'!.af*',
|
|
|
|
'!.git*',
|
|
|
|
'!.groc*',
|
|
|
|
'!.travis.yml'
|
|
|
|
],
|
|
|
|
dest: "<%= paths.weeklyBuild %>/<%= pkg.version %>/"
|
|
|
|
}]
|
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
build: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
|
|
|
src: [
|
|
|
|
'**',
|
|
|
|
'!node_modules/**',
|
2013-07-11 23:02:18 +04:00
|
|
|
'!core/server/data/*.db',
|
2013-06-25 15:43:15 +04:00
|
|
|
'!.sass*',
|
|
|
|
'!.af*',
|
|
|
|
'!.git*',
|
|
|
|
'!.groc*',
|
2013-07-11 23:02:18 +04:00
|
|
|
'!.iml*',
|
2013-06-25 15:43:15 +04:00
|
|
|
'!.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-07-11 18:05:10 +04:00
|
|
|
weekly: {
|
|
|
|
options: {
|
|
|
|
archive: "<%= paths.weeklyDist %>/Ghost-Weekly-<%= pkg.version %>.zip"
|
|
|
|
},
|
|
|
|
expand: true,
|
|
|
|
cwd: "<%= paths.weeklyBuild %>/<%= pkg.version %>/",
|
|
|
|
src: ["**"]
|
|
|
|
},
|
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: {
|
2013-07-11 18:24:33 +04:00
|
|
|
tagName: '%VERSION%',
|
|
|
|
commitMessage: '<%= buildType %> Release %VERSION%',
|
|
|
|
tagMessage: '<%= buildType %> Release %VERSION%',
|
2013-07-10 04:45:57 +04:00
|
|
|
pushTo: "origin build"
|
2013-07-02 00:58:47 +04:00
|
|
|
}
|
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");
|
2013-07-10 02:54:57 +04:00
|
|
|
grunt.loadNpmTasks("grunt-mocha-cli");
|
2013-06-25 15:43:15 +04:00
|
|
|
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');
|
|
|
|
});
|
|
|
|
|
2013-07-11 18:24:33 +04:00
|
|
|
grunt.registerTask('setCurrentBuildType', function (type) {
|
|
|
|
cfg.buildType = type;
|
|
|
|
});
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
// 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
|
2013-07-10 02:54:57 +04:00
|
|
|
grunt.registerTask("test-api", ["mochacli:api"]);
|
2013-06-25 15:43:15 +04:00
|
|
|
|
|
|
|
// Run permisisons tests only
|
2013-07-10 02:54:57 +04:00
|
|
|
grunt.registerTask("test-p", ["mochacli:perm"]);
|
2013-06-25 15:43:15 +04:00
|
|
|
|
|
|
|
// Run tests and lint code
|
2013-07-10 02:54:57 +04:00
|
|
|
grunt.registerTask("validate", ["jslint", "mochacli:all"]);
|
2013-06-25 15:43:15 +04:00
|
|
|
|
|
|
|
// Generate Docs
|
|
|
|
grunt.registerTask("docs", ["groc"]);
|
|
|
|
|
|
|
|
/* Nightly builds
|
2013-07-11 18:05:10 +04:00
|
|
|
* - Do our standard build steps (sass, handlebars, etc)
|
|
|
|
* - Bump patch version in package.json, commit, tag and push
|
|
|
|
* - Copy files to build-folder/#/#{version} directory
|
2013-06-25 15:43:15 +04:00
|
|
|
* - Clean out unnecessary files (travis, .git*, .af*, .groc*)
|
|
|
|
* - Zip files in build folder to dist-folder/#{version} directory
|
|
|
|
*/
|
|
|
|
grunt.registerTask("nightly", [
|
2013-07-11 18:24:33 +04:00
|
|
|
"setCurrentBuildType:Nightly",
|
2013-06-25 15:43:15 +04:00
|
|
|
"shell:bourbon",
|
|
|
|
"sass:admin",
|
|
|
|
"handlebars",
|
2013-07-09 22:56:19 +04:00
|
|
|
"bump:build",
|
2013-06-25 15:43:15 +04:00
|
|
|
"updateCurrentPackageInfo",
|
|
|
|
"copy:nightly",
|
|
|
|
"compress:nightly"
|
2013-07-11 18:05:10 +04:00
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask("weekly", [
|
2013-07-11 18:24:33 +04:00
|
|
|
"setCurrentBuildType:Weekly",
|
2013-07-11 18:05:10 +04:00
|
|
|
"shell:bourbon",
|
|
|
|
"sass:admin",
|
|
|
|
"handlebars",
|
|
|
|
"bump:build",
|
|
|
|
"updateCurrentPackageInfo",
|
|
|
|
"copy:weekly",
|
|
|
|
"compress:weekly"
|
2013-06-25 15:43:15 +04:00
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask("build", [
|
|
|
|
"shell:bourbon",
|
|
|
|
"sass:admin",
|
|
|
|
"handlebars",
|
|
|
|
"copy:build",
|
|
|
|
"compress:build"
|
|
|
|
]);
|
|
|
|
|
|
|
|
// When you just say "grunt"
|
|
|
|
grunt.registerTask("default", ['sass:admin', 'handlebars']);
|
|
|
|
};
|
|
|
|
|
2013-06-27 07:52:56 +04:00
|
|
|
module.exports = configureGrunt;
|