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'),
|
||||
when = require('when'),
|
||||
semver = require('semver'),
|
||||
|
@ -8,6 +12,9 @@ var path = require('path'),
|
|||
distDirectory = path.resolve(process.cwd(), '.dist'),
|
||||
config = require('./core/server/config'),
|
||||
|
||||
|
||||
// ## Build File Patterns
|
||||
// a list of files and paterns to process and exclude when running builds & releases
|
||||
buildGlob = [
|
||||
'**',
|
||||
'!docs/**',
|
||||
|
@ -37,6 +44,8 @@ var path = require('path'),
|
|||
'!*.html'
|
||||
],
|
||||
|
||||
// ## Grunt configuration
|
||||
|
||||
configureGrunt = function (grunt) {
|
||||
|
||||
// load all grunt tasks
|
||||
|
@ -47,17 +56,14 @@ var path = require('path'),
|
|||
paths: {
|
||||
adminAssets: './core/client/assets',
|
||||
build: buildDirectory,
|
||||
nightlyBuild: path.join(buildDirectory, 'nightly'),
|
||||
weeklyBuild: path.join(buildDirectory, 'weekly'),
|
||||
releaseBuild: path.join(buildDirectory, 'release'),
|
||||
dist: distDirectory,
|
||||
nightlyDist: path.join(distDirectory, 'nightly'),
|
||||
weeklyDist: path.join(distDirectory, 'weekly'),
|
||||
releaseDist: path.join(distDirectory, 'release')
|
||||
},
|
||||
buildType: 'Build',
|
||||
pkg: grunt.file.readJSON('package.json'),
|
||||
|
||||
// ### Config for grunt-contrib-watch
|
||||
// Watch files and livereload in the browser during development
|
||||
watch: {
|
||||
handlebars: {
|
||||
|
@ -104,6 +110,7 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
// ### Config for grunt-express-server
|
||||
// Start our server in development
|
||||
express: {
|
||||
options: {
|
||||
|
@ -123,6 +130,7 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
// ### Config for grunt-jslint
|
||||
// JSLint all the things!
|
||||
jslint: {
|
||||
server: {
|
||||
|
@ -191,6 +199,8 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
// ### Config for grunt-mocha-cli
|
||||
// Run mocha unit tests
|
||||
mochacli: {
|
||||
options: {
|
||||
ui: 'bdd',
|
||||
|
@ -238,6 +248,7 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
// ### Config for grunt-contrib-sass
|
||||
// Compile all the SASS!
|
||||
sass: {
|
||||
admin: {
|
||||
|
@ -255,10 +266,14 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
// ### config for grunt-shell
|
||||
// command line tools
|
||||
shell: {
|
||||
// install bourbon
|
||||
bourbon: {
|
||||
command: 'bourbon install --path <%= paths.adminAssets %>/sass/modules/'
|
||||
},
|
||||
// generate coverage report
|
||||
coverage: {
|
||||
command: function () {
|
||||
// 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: {
|
||||
core: {
|
||||
options: {
|
||||
|
@ -286,6 +303,8 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
// ### Config for grunt-groc
|
||||
// Generate documentation from code
|
||||
groc: {
|
||||
docs: {
|
||||
options: {
|
||||
|
@ -307,6 +326,8 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
// ### Config for grunt-contrib-clean
|
||||
// Clean up files as part of other tasks
|
||||
clean: {
|
||||
release: {
|
||||
src: ['<%= paths.releaseBuild %>/**']
|
||||
|
@ -316,21 +337,9 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
// ### Config for grunt-contrib-copy
|
||||
// Prepare files for builds / releases
|
||||
copy: {
|
||||
nightly: {
|
||||
files: [{
|
||||
expand: true,
|
||||
src: buildGlob,
|
||||
dest: '<%= paths.nightlyBuild %>/<%= pkg.version %>/'
|
||||
}]
|
||||
},
|
||||
weekly: {
|
||||
files: [{
|
||||
expand: true,
|
||||
src: buildGlob,
|
||||
dest: '<%= paths.weeklyBuild %>/<%= pkg.version %>/'
|
||||
}]
|
||||
},
|
||||
release: {
|
||||
files: [{
|
||||
expand: true,
|
||||
|
@ -340,23 +349,9 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
// ### Config for grunt-contrib-compress
|
||||
// Zip up builds / releases
|
||||
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: {
|
||||
options: {
|
||||
archive: '<%= paths.releaseDist %>/Ghost-<%= pkg.version %>.zip'
|
||||
|
@ -367,15 +362,8 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
bump: {
|
||||
options: {
|
||||
tagName: '%VERSION%',
|
||||
commitMessage: '<%= buildType %> Release %VERSION%',
|
||||
tagMessage: '<%= buildType %> Release %VERSION%',
|
||||
pushTo: 'origin build'
|
||||
}
|
||||
},
|
||||
|
||||
// ### Config for grunt-contrib-concat
|
||||
// concatenate multiple JS files into a single file ready for use
|
||||
concat: {
|
||||
dev: {
|
||||
files: {
|
||||
|
@ -482,6 +470,8 @@ var path = require('path'),
|
|||
}
|
||||
},
|
||||
|
||||
// ### Config for grunt-contrib-uglify
|
||||
// minify javascript file for production
|
||||
uglify: {
|
||||
prod: {
|
||||
files: {
|
||||
|
@ -493,6 +483,9 @@ var path = require('path'),
|
|||
|
||||
grunt.initConfig(cfg);
|
||||
|
||||
|
||||
// ## Custom Tasks
|
||||
|
||||
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';
|
||||
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 () {
|
||||
var done = this.async(),
|
||||
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',
|
||||
'Release task - creates a final built zip\n' +
|
||||
' - Do our standard build steps (sass, handlebars, etc)\n' +
|
||||
|
@ -867,31 +804,39 @@ var path = require('path'),
|
|||
'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']);
|
||||
|
||||
|
||||
// ## 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']);
|
||||
|
||||
|
||||
// ## Tools for building assets
|
||||
// ### Tools for building assets
|
||||
|
||||
grunt.registerTask('init', 'Prepare the project for development', ['shell:bourbon', 'default']);
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@
|
|||
"devDependencies": {
|
||||
"blanket": "~1.1.5",
|
||||
"grunt": "~0.4.1",
|
||||
"grunt-bump": "~0.0.11",
|
||||
"grunt-contrib-clean": "~0.5.0",
|
||||
"grunt-contrib-compress": "~0.5.2",
|
||||
"grunt-contrib-concat": "~0.3.0",
|
||||
|
|
Loading…
Add table
Reference in a new issue