mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-03-11 02:12:21 -05:00
commit
1b16518e40
2 changed files with 53 additions and 109 deletions
161
Gruntfile.js
161
Gruntfile.js
|
@ -1,3 +1,7 @@
|
||||||
|
// # Gruntfile - Task automation for Ghost
|
||||||
|
// Run various tasks when developing for and working with Ghost
|
||||||
|
// Run `grunt --help` or visit https://github.com/TryGhost/Ghost/wiki/Grunt-Toolkit/ for usage instructions
|
||||||
|
|
||||||
var path = require('path'),
|
var path = require('path'),
|
||||||
when = require('when'),
|
when = require('when'),
|
||||||
semver = require('semver'),
|
semver = require('semver'),
|
||||||
|
@ -8,6 +12,9 @@ var path = require('path'),
|
||||||
distDirectory = path.resolve(process.cwd(), '.dist'),
|
distDirectory = path.resolve(process.cwd(), '.dist'),
|
||||||
config = require('./core/server/config'),
|
config = require('./core/server/config'),
|
||||||
|
|
||||||
|
|
||||||
|
// ## Build File Patterns
|
||||||
|
// a list of files and paterns to process and exclude when running builds & releases
|
||||||
buildGlob = [
|
buildGlob = [
|
||||||
'**',
|
'**',
|
||||||
'!docs/**',
|
'!docs/**',
|
||||||
|
@ -37,6 +44,8 @@ var path = require('path'),
|
||||||
'!*.html'
|
'!*.html'
|
||||||
],
|
],
|
||||||
|
|
||||||
|
// ## Grunt configuration
|
||||||
|
|
||||||
configureGrunt = function (grunt) {
|
configureGrunt = function (grunt) {
|
||||||
|
|
||||||
// load all grunt tasks
|
// load all grunt tasks
|
||||||
|
@ -47,17 +56,14 @@ var path = require('path'),
|
||||||
paths: {
|
paths: {
|
||||||
adminAssets: './core/client/assets',
|
adminAssets: './core/client/assets',
|
||||||
build: buildDirectory,
|
build: buildDirectory,
|
||||||
nightlyBuild: path.join(buildDirectory, 'nightly'),
|
|
||||||
weeklyBuild: path.join(buildDirectory, 'weekly'),
|
|
||||||
releaseBuild: path.join(buildDirectory, 'release'),
|
releaseBuild: path.join(buildDirectory, 'release'),
|
||||||
dist: distDirectory,
|
dist: distDirectory,
|
||||||
nightlyDist: path.join(distDirectory, 'nightly'),
|
|
||||||
weeklyDist: path.join(distDirectory, 'weekly'),
|
|
||||||
releaseDist: path.join(distDirectory, 'release')
|
releaseDist: path.join(distDirectory, 'release')
|
||||||
},
|
},
|
||||||
buildType: 'Build',
|
buildType: 'Build',
|
||||||
pkg: grunt.file.readJSON('package.json'),
|
pkg: grunt.file.readJSON('package.json'),
|
||||||
|
|
||||||
|
// ### Config for grunt-contrib-watch
|
||||||
// Watch files and livereload in the browser during development
|
// Watch files and livereload in the browser during development
|
||||||
watch: {
|
watch: {
|
||||||
handlebars: {
|
handlebars: {
|
||||||
|
@ -104,6 +110,7 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### Config for grunt-express-server
|
||||||
// Start our server in development
|
// Start our server in development
|
||||||
express: {
|
express: {
|
||||||
options: {
|
options: {
|
||||||
|
@ -123,6 +130,7 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### Config for grunt-jslint
|
||||||
// JSLint all the things!
|
// JSLint all the things!
|
||||||
jslint: {
|
jslint: {
|
||||||
server: {
|
server: {
|
||||||
|
@ -191,6 +199,8 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### Config for grunt-mocha-cli
|
||||||
|
// Run mocha unit tests
|
||||||
mochacli: {
|
mochacli: {
|
||||||
options: {
|
options: {
|
||||||
ui: 'bdd',
|
ui: 'bdd',
|
||||||
|
@ -238,6 +248,7 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### Config for grunt-contrib-sass
|
||||||
// Compile all the SASS!
|
// Compile all the SASS!
|
||||||
sass: {
|
sass: {
|
||||||
admin: {
|
admin: {
|
||||||
|
@ -255,10 +266,14 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### config for grunt-shell
|
||||||
|
// command line tools
|
||||||
shell: {
|
shell: {
|
||||||
|
// install bourbon
|
||||||
bourbon: {
|
bourbon: {
|
||||||
command: 'bourbon install --path <%= paths.adminAssets %>/sass/modules/'
|
command: 'bourbon install --path <%= paths.adminAssets %>/sass/modules/'
|
||||||
},
|
},
|
||||||
|
// generate coverage report
|
||||||
coverage: {
|
coverage: {
|
||||||
command: function () {
|
command: function () {
|
||||||
// will work on windows only if mocha is globally installed
|
// will work on windows only if mocha is globally installed
|
||||||
|
@ -271,6 +286,8 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### Config for grunt-contrib-handlebars
|
||||||
|
// Compile templates for admin client
|
||||||
handlebars: {
|
handlebars: {
|
||||||
core: {
|
core: {
|
||||||
options: {
|
options: {
|
||||||
|
@ -286,6 +303,8 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### Config for grunt-groc
|
||||||
|
// Generate documentation from code
|
||||||
groc: {
|
groc: {
|
||||||
docs: {
|
docs: {
|
||||||
options: {
|
options: {
|
||||||
|
@ -307,6 +326,8 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### Config for grunt-contrib-clean
|
||||||
|
// Clean up files as part of other tasks
|
||||||
clean: {
|
clean: {
|
||||||
release: {
|
release: {
|
||||||
src: ['<%= paths.releaseBuild %>/**']
|
src: ['<%= paths.releaseBuild %>/**']
|
||||||
|
@ -316,21 +337,9 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### Config for grunt-contrib-copy
|
||||||
|
// Prepare files for builds / releases
|
||||||
copy: {
|
copy: {
|
||||||
nightly: {
|
|
||||||
files: [{
|
|
||||||
expand: true,
|
|
||||||
src: buildGlob,
|
|
||||||
dest: '<%= paths.nightlyBuild %>/<%= pkg.version %>/'
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
weekly: {
|
|
||||||
files: [{
|
|
||||||
expand: true,
|
|
||||||
src: buildGlob,
|
|
||||||
dest: '<%= paths.weeklyBuild %>/<%= pkg.version %>/'
|
|
||||||
}]
|
|
||||||
},
|
|
||||||
release: {
|
release: {
|
||||||
files: [{
|
files: [{
|
||||||
expand: true,
|
expand: true,
|
||||||
|
@ -340,23 +349,9 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### Config for grunt-contrib-compress
|
||||||
|
// Zip up builds / releases
|
||||||
compress: {
|
compress: {
|
||||||
nightly: {
|
|
||||||
options: {
|
|
||||||
archive: '<%= paths.nightlyDist %>/Ghost-Nightly-<%= pkg.version %>.zip'
|
|
||||||
},
|
|
||||||
expand: true,
|
|
||||||
cwd: '<%= paths.nightlyBuild %>/<%= pkg.version %>/',
|
|
||||||
src: ['**']
|
|
||||||
},
|
|
||||||
weekly: {
|
|
||||||
options: {
|
|
||||||
archive: '<%= paths.weeklyDist %>/Ghost-Weekly-<%= pkg.version %>.zip'
|
|
||||||
},
|
|
||||||
expand: true,
|
|
||||||
cwd: '<%= paths.weeklyBuild %>/<%= pkg.version %>/',
|
|
||||||
src: ['**']
|
|
||||||
},
|
|
||||||
release: {
|
release: {
|
||||||
options: {
|
options: {
|
||||||
archive: '<%= paths.releaseDist %>/Ghost-<%= pkg.version %>.zip'
|
archive: '<%= paths.releaseDist %>/Ghost-<%= pkg.version %>.zip'
|
||||||
|
@ -367,15 +362,8 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
bump: {
|
// ### Config for grunt-contrib-concat
|
||||||
options: {
|
// concatenate multiple JS files into a single file ready for use
|
||||||
tagName: '%VERSION%',
|
|
||||||
commitMessage: '<%= buildType %> Release %VERSION%',
|
|
||||||
tagMessage: '<%= buildType %> Release %VERSION%',
|
|
||||||
pushTo: 'origin build'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
concat: {
|
concat: {
|
||||||
dev: {
|
dev: {
|
||||||
files: {
|
files: {
|
||||||
|
@ -482,6 +470,8 @@ var path = require('path'),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ### Config for grunt-contrib-uglify
|
||||||
|
// minify javascript file for production
|
||||||
uglify: {
|
uglify: {
|
||||||
prod: {
|
prod: {
|
||||||
files: {
|
files: {
|
||||||
|
@ -493,6 +483,9 @@ var path = require('path'),
|
||||||
|
|
||||||
grunt.initConfig(cfg);
|
grunt.initConfig(cfg);
|
||||||
|
|
||||||
|
|
||||||
|
// ## Custom Tasks
|
||||||
|
|
||||||
grunt.registerTask('setTestEnv', 'Use "testing" Ghost config; unless we are running on travis (then show queries for debugging)', function () {
|
grunt.registerTask('setTestEnv', 'Use "testing" Ghost config; unless we are running on travis (then show queries for debugging)', function () {
|
||||||
process.env.NODE_ENV = process.env.TRAVIS ? 'travis-' + process.env.DB : 'testing';
|
process.env.NODE_ENV = process.env.TRAVIS ? 'travis-' + process.env.DB : 'testing';
|
||||||
cfg.express.test.options.node_env = process.env.NODE_ENV;
|
cfg.express.test.options.node_env = process.env.NODE_ENV;
|
||||||
|
@ -505,14 +498,6 @@ var path = require('path'),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
grunt.registerTask('updateCurrentPackageInfo', 'Update the package information after changes', function () {
|
|
||||||
cfg.pkg = grunt.file.readJSON('package.json');
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.registerTask('setCurrentBuildType', function (type) {
|
|
||||||
cfg.buildType = type;
|
|
||||||
});
|
|
||||||
|
|
||||||
grunt.registerTask('spawn-casperjs', function () {
|
grunt.registerTask('spawn-casperjs', function () {
|
||||||
var done = this.async(),
|
var done = this.async(),
|
||||||
options = ['host', 'noPort', 'port', 'email', 'password'],
|
options = ['host', 'noPort', 'port', 'email', 'password'],
|
||||||
|
@ -790,54 +775,6 @@ var path = require('path'),
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
// ## Tools for packaging builds - these can be weeklies, nightlies or releases
|
|
||||||
|
|
||||||
/* These tools are currently unused
|
|
||||||
grunt.registerTask('nightly',
|
|
||||||
'Nightly builds\n' +
|
|
||||||
' - Do our standard build steps (sass, handlebars, etc)\n' +
|
|
||||||
' - Bump patch version in package.json, commit, tag and push\n' +
|
|
||||||
' - Generate changelog for the past 14 releases\n' +
|
|
||||||
' - Copy files to build-folder/#/#{version} directory\n' +
|
|
||||||
' - Clean out unnecessary files (travis, .git*, .af*, .groc*)\n' +
|
|
||||||
' - Zip files in build folder to dist-folder/#{version} directory',
|
|
||||||
[
|
|
||||||
'setCurrentBuildType:Nightly',
|
|
||||||
'shell:bourbon',
|
|
||||||
'sass:compress',
|
|
||||||
'handlebars',
|
|
||||||
'concat',
|
|
||||||
'uglify',
|
|
||||||
'bump:build',
|
|
||||||
'updateCurrentPackageInfo',
|
|
||||||
'changelog',
|
|
||||||
'copy:nightly',
|
|
||||||
'compress:nightly'
|
|
||||||
]);
|
|
||||||
|
|
||||||
grunt.registerTask('weekly',
|
|
||||||
'Weekly builds\n' +
|
|
||||||
' - Do our standard build steps (sass, handlebars, etc)\n' +
|
|
||||||
' - Bump patch version in package.json, commit, tag and push\n' +
|
|
||||||
' - Generate changelog for the past 14 releases\n' +
|
|
||||||
' - Copy files to build-folder/#/#{version} directory\n' +
|
|
||||||
' - Clean out unnecessary files (travis, .git*, .af*, .groc*)\n' +
|
|
||||||
' - Zip files in build folder to dist-folder/#{version} directory',
|
|
||||||
[
|
|
||||||
'setCurrentBuildType:Weekly',
|
|
||||||
'shell:bourbon',
|
|
||||||
'sass:compress',
|
|
||||||
'handlebars',
|
|
||||||
'concat',
|
|
||||||
'uglify',
|
|
||||||
'bump:build',
|
|
||||||
'updateCurrentPackageInfo',
|
|
||||||
'changelog',
|
|
||||||
'copy:weekly',
|
|
||||||
'compress:weekly'
|
|
||||||
]);
|
|
||||||
*/
|
|
||||||
|
|
||||||
grunt.registerTask('release',
|
grunt.registerTask('release',
|
||||||
'Release task - creates a final built zip\n' +
|
'Release task - creates a final built zip\n' +
|
||||||
' - Do our standard build steps (sass, handlebars, etc)\n' +
|
' - Do our standard build steps (sass, handlebars, etc)\n' +
|
||||||
|
@ -867,31 +804,39 @@ var path = require('path'),
|
||||||
'watch'
|
'watch'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
// ### Find out more about grunt task usage
|
||||||
|
|
||||||
// ## Running the test suites
|
grunt.registerTask('help',
|
||||||
|
'Outputs help information if you type `grunt help` instead of `grunt --help`',
|
||||||
|
function () {
|
||||||
|
console.log('Type `grunt --help` to get the details of available grunt tasks, or alternatively visit https://github.com/TryGhost/Ghost/wiki/Grunt-Toolkit');
|
||||||
|
});
|
||||||
|
|
||||||
grunt.registerTask('test-unit', 'Run unit tests', ['clean:test', 'setTestEnv', 'loadConfig', 'mochacli:unit']);
|
|
||||||
|
|
||||||
grunt.registerTask('test-integration', 'Run integration tests', ['clean:test', 'setTestEnv', 'loadConfig', 'mochacli:integration']);
|
// ### Running the test suites
|
||||||
|
|
||||||
grunt.registerTask('test-functional', 'Run casperjs tests only', ['clean:test', 'setTestEnv', 'loadConfig', 'express:test', 'spawn-casperjs', 'express:test:stop']);
|
grunt.registerTask('test-unit', 'Run unit tests (mocha)', ['clean:test', 'setTestEnv', 'loadConfig', 'mochacli:unit']);
|
||||||
|
|
||||||
grunt.registerTask('test-api', 'Run functional api tests only', ['clean:test', 'setTestEnv', 'loadConfig', 'express:test', 'mochacli:api', 'express:test:stop']);
|
grunt.registerTask('test-integration', 'Run integration tests (mocha + db access)', ['clean:test', 'setTestEnv', 'loadConfig', 'mochacli:integration']);
|
||||||
|
|
||||||
|
grunt.registerTask('test-functional', 'Run functional interface tests (CasperJS)', ['clean:test', 'setTestEnv', 'loadConfig', 'express:test', 'spawn-casperjs', 'express:test:stop']);
|
||||||
|
|
||||||
|
grunt.registerTask('test-api', 'Run functional api tests (mocha)', ['clean:test', 'setTestEnv', 'loadConfig', 'express:test', 'mochacli:api', 'express:test:stop']);
|
||||||
|
|
||||||
grunt.registerTask('validate', 'Run tests and lint code', ['jslint', 'test-unit', 'test-api', 'test-integration', 'test-functional']);
|
grunt.registerTask('validate', 'Run tests and lint code', ['jslint', 'test-unit', 'test-api', 'test-integration', 'test-functional']);
|
||||||
|
|
||||||
|
|
||||||
// ## Coverage report for Unit and Integration Tests
|
// ### Coverage report for Unit and Integration Tests
|
||||||
|
|
||||||
grunt.registerTask('test-coverage', 'Generate unit and integration tests coverage report', ['clean:test', 'setTestEnv', 'loadConfig', 'express:test', 'shell:coverage']);
|
grunt.registerTask('test-coverage', 'Generate unit and integration (mocha) tests coverage report', ['clean:test', 'setTestEnv', 'loadConfig', 'express:test', 'shell:coverage']);
|
||||||
|
|
||||||
|
|
||||||
// ## Documentation
|
// ### Documentation
|
||||||
|
|
||||||
grunt.registerTask('docs', 'Generate Docs', ['groc']);
|
grunt.registerTask('docs', 'Generate Docs', ['groc']);
|
||||||
|
|
||||||
|
|
||||||
// ## Tools for building assets
|
// ### Tools for building assets
|
||||||
|
|
||||||
grunt.registerTask('init', 'Prepare the project for development', ['shell:bourbon', 'default']);
|
grunt.registerTask('init', 'Prepare the project for development', ['shell:bourbon', 'default']);
|
||||||
|
|
||||||
|
|
|
@ -60,7 +60,6 @@
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"blanket": "~1.1.5",
|
"blanket": "~1.1.5",
|
||||||
"grunt": "~0.4.1",
|
"grunt": "~0.4.1",
|
||||||
"grunt-bump": "~0.0.11",
|
|
||||||
"grunt-contrib-clean": "~0.5.0",
|
"grunt-contrib-clean": "~0.5.0",
|
||||||
"grunt-contrib-compress": "~0.5.2",
|
"grunt-contrib-compress": "~0.5.2",
|
||||||
"grunt-contrib-concat": "~0.3.0",
|
"grunt-contrib-concat": "~0.3.0",
|
||||||
|
|
Loading…
Add table
Reference in a new issue