2013-09-24 14:46:30 +04:00
|
|
|
var path = require('path'),
|
|
|
|
when = require('when'),
|
|
|
|
semver = require('semver'),
|
|
|
|
fs = require('fs'),
|
|
|
|
_ = require('underscore'),
|
|
|
|
spawn = require("child_process").spawn,
|
2013-07-02 01:24:59 +04:00
|
|
|
buildDirectory = path.resolve(process.cwd(), '.build'),
|
2013-09-24 14:46:30 +04:00
|
|
|
distDirectory = path.resolve(process.cwd(), '.dist'),
|
|
|
|
configLoader = require('./core/config-loader.js'),
|
2013-09-13 11:24:28 +04:00
|
|
|
|
2013-09-18 22:45:21 +04:00
|
|
|
buildGlob = [
|
|
|
|
'**',
|
|
|
|
'!docs/**',
|
2013-10-11 19:31:47 +04:00
|
|
|
'!_site/**',
|
|
|
|
'!content/images/**',
|
|
|
|
'content/images/README.md',
|
|
|
|
'!content/themes/**',
|
|
|
|
'content/themes/casper/**',
|
|
|
|
'!content/plugins/**',
|
|
|
|
'content/plugins/README.md',
|
2013-09-18 22:45:21 +04:00
|
|
|
'!node_modules/**',
|
2013-10-11 19:31:47 +04:00
|
|
|
'!core/test/**',
|
|
|
|
'!core/client/assets/sass/**',
|
2013-09-18 22:45:21 +04:00
|
|
|
'!**/*.db*',
|
|
|
|
'!*.db*',
|
|
|
|
'!.sass*',
|
|
|
|
'!.af*',
|
|
|
|
'!.git*',
|
|
|
|
'!.groc*',
|
|
|
|
'!*.iml',
|
|
|
|
'!config.js',
|
2013-10-11 19:31:47 +04:00
|
|
|
'!CONTRIBUTING.md',
|
|
|
|
'!SECURITY.md',
|
2013-09-18 22:45:21 +04:00
|
|
|
'!.travis.yml'
|
|
|
|
],
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
configureGrunt = function (grunt) {
|
|
|
|
|
2013-08-17 22:39:02 +04:00
|
|
|
// load all grunt tasks
|
|
|
|
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
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-10-11 19:31:47 +04:00
|
|
|
buildDist: path.join(distDirectory, 'build'),
|
|
|
|
releaseDist: path.join(distDirectory, 'release')
|
2013-06-25 15:43:15 +04:00
|
|
|
},
|
2013-07-11 18:24:33 +04:00
|
|
|
buildType: 'Build',
|
2013-06-25 15:43:15 +04:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
|
2013-08-17 22:39:02 +04:00
|
|
|
// Watch files and livereload in the browser during development
|
|
|
|
watch: {
|
|
|
|
handlebars: {
|
|
|
|
files: ['core/client/tpl/**/*.hbs'],
|
|
|
|
tasks: ['handlebars']
|
|
|
|
},
|
|
|
|
sass: {
|
|
|
|
files: ['<%= paths.adminAssets %>/sass/**/*'],
|
|
|
|
tasks: ['sass:admin']
|
|
|
|
},
|
2013-09-14 06:15:30 +04:00
|
|
|
concat: {
|
|
|
|
files: [
|
|
|
|
'core/client/*.js',
|
|
|
|
'core/client/helpers/*.js',
|
|
|
|
'core/client/models/*.js',
|
|
|
|
'core/client/tpl/*.js',
|
|
|
|
'core/client/views/*.js'
|
|
|
|
],
|
|
|
|
tasks: ['concat']
|
|
|
|
},
|
2013-08-17 22:39:02 +04:00
|
|
|
livereload: {
|
|
|
|
files: [
|
|
|
|
// Theme CSS
|
|
|
|
'content/themes/casper/css/*.css',
|
|
|
|
// Theme JS
|
|
|
|
'content/themes/casper/js/*.js',
|
|
|
|
// Admin CSS
|
|
|
|
'<%= paths.adminAssets %>/css/*.css',
|
|
|
|
// Admin JS
|
2013-09-14 06:15:30 +04:00
|
|
|
'core/built/scripts/*.js'
|
2013-08-17 22:39:02 +04:00
|
|
|
],
|
|
|
|
options: {
|
|
|
|
livereload: true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
express: {
|
|
|
|
// Restart any time client or server js files change
|
|
|
|
files: ['core/server/**/*.js'],
|
|
|
|
tasks: ['express:dev'],
|
|
|
|
options: {
|
|
|
|
//Without this option specified express won't be reloaded
|
|
|
|
nospawn: true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Start our server in development
|
|
|
|
express: {
|
|
|
|
options: {
|
2013-09-24 14:46:30 +04:00
|
|
|
script: 'index.js'
|
2013-08-17 22:39:02 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
dev: {
|
|
|
|
options: {
|
|
|
|
//output: "Express server listening on address:.*$"
|
|
|
|
}
|
2013-08-29 14:04:33 +04:00
|
|
|
},
|
|
|
|
test: {
|
|
|
|
options: {
|
|
|
|
node_env: 'testing'
|
|
|
|
}
|
2013-08-17 22:39:02 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
// Open the site in a browser
|
|
|
|
open: {
|
|
|
|
server: {
|
|
|
|
// TODO: Load this port from config?
|
|
|
|
path: 'http://127.0.0.1:2368'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
// 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
|
2013-09-13 00:03:01 +04:00
|
|
|
sloppy: true
|
2013-06-25 15:43:15 +04:00
|
|
|
},
|
|
|
|
files: {
|
|
|
|
src: [
|
2013-09-24 14:46:30 +04:00
|
|
|
'*.js',
|
|
|
|
'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-09-24 14:46:30 +04:00
|
|
|
src: 'core/client/**/*.js'
|
2013-07-11 23:02:18 +04:00
|
|
|
},
|
|
|
|
exclude: [
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/client/assets/**/*.js',
|
|
|
|
'core/client/tpl/**/*.js'
|
2013-07-11 23:02:18 +04:00
|
|
|
]
|
|
|
|
},
|
|
|
|
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: [
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/shared/**/*.js'
|
2013-07-11 23:02:18 +04:00
|
|
|
]
|
2013-07-24 07:25:08 +04:00
|
|
|
},
|
|
|
|
exclude: [
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/shared/vendor/**/*.js'
|
2013-07-24 07:25:08 +04:00
|
|
|
]
|
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: {
|
2013-09-24 14:46:30 +04:00
|
|
|
ui: 'bdd',
|
2013-10-17 02:57:52 +04:00
|
|
|
reporter: 'spec',
|
|
|
|
timeout: '15000'
|
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-08-20 01:52:50 +04:00
|
|
|
client: {
|
|
|
|
src: ['core/test/unit/**/client*_spec.js']
|
|
|
|
},
|
|
|
|
|
|
|
|
server: {
|
|
|
|
src: ['core/test/unit/**/server*_spec.js']
|
|
|
|
},
|
|
|
|
|
|
|
|
shared: {
|
|
|
|
src: ['core/test/unit/**/shared*_spec.js']
|
2013-08-25 00:51:58 +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-08-03 19:11:16 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
migrate: {
|
|
|
|
src: [
|
|
|
|
'core/test/unit/**/export_spec.js',
|
|
|
|
'core/test/unit/**/import_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-09-27 19:02:35 +04:00
|
|
|
},
|
|
|
|
compress: {
|
|
|
|
options: {
|
|
|
|
style: 'compressed'
|
|
|
|
},
|
|
|
|
files: {
|
|
|
|
'<%= paths.adminAssets %>/css/screen.css': '<%= paths.adminAssets %>/sass/screen.scss'
|
|
|
|
}
|
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: {
|
2013-09-24 14:46:30 +04:00
|
|
|
namespace: 'JST',
|
2013-06-25 15:43:15 +04:00
|
|
|
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-09-24 14:46:30 +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: {
|
2013-09-24 14:46:30 +04:00
|
|
|
'out': './docs/',
|
|
|
|
'glob': [
|
|
|
|
'README.md',
|
|
|
|
'config.example.js',
|
|
|
|
'index.js',
|
|
|
|
'core/*.js',
|
|
|
|
'core/server/**/*.js',
|
|
|
|
'core/shared/**/*.js',
|
|
|
|
'core/client/**/*.js'
|
2013-07-11 23:02:18 +04:00
|
|
|
],
|
2013-09-24 14:46:30 +04:00
|
|
|
'except': [
|
|
|
|
'!core/**/vendor/**/*.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-09-18 22:56:39 +04:00
|
|
|
clean: {
|
|
|
|
build: {
|
2013-09-24 14:46:30 +04:00
|
|
|
src: ['<%= paths.buildBuild %>/**']
|
2013-10-15 07:39:52 +04:00
|
|
|
},
|
|
|
|
test: {
|
|
|
|
src: ['content/data/ghost-test.db']
|
2013-09-18 22:56:39 +04:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
copy: {
|
|
|
|
nightly: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
2013-09-18 22:45:21 +04:00
|
|
|
src: buildGlob,
|
2013-09-24 14:46:30 +04:00
|
|
|
dest: '<%= paths.nightlyBuild %>/<%= pkg.version %>/'
|
2013-06-25 15:43:15 +04:00
|
|
|
}]
|
2013-06-10 17:52:04 +04:00
|
|
|
},
|
2013-07-11 18:05:10 +04:00
|
|
|
weekly: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
2013-09-18 22:45:21 +04:00
|
|
|
src: buildGlob,
|
2013-09-24 14:46:30 +04:00
|
|
|
dest: '<%= paths.weeklyBuild %>/<%= pkg.version %>/'
|
2013-07-11 18:05:10 +04:00
|
|
|
}]
|
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
build: {
|
|
|
|
files: [{
|
|
|
|
expand: true,
|
2013-09-18 22:45:21 +04:00
|
|
|
src: buildGlob,
|
2013-09-24 14:46:30 +04:00
|
|
|
dest: '<%= paths.buildBuild %>/'
|
2013-06-25 15:43:15 +04:00
|
|
|
}]
|
|
|
|
}
|
|
|
|
},
|
2013-05-20 08:22:00 +04:00
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
compress: {
|
|
|
|
nightly: {
|
|
|
|
options: {
|
2013-09-24 14:46:30 +04:00
|
|
|
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,
|
2013-09-24 14:46:30 +04:00
|
|
|
cwd: '<%= paths.nightlyBuild %>/<%= pkg.version %>/',
|
|
|
|
src: ['**']
|
2013-06-10 17:52:04 +04:00
|
|
|
},
|
2013-07-11 18:05:10 +04:00
|
|
|
weekly: {
|
|
|
|
options: {
|
2013-09-24 14:46:30 +04:00
|
|
|
archive: '<%= paths.weeklyDist %>/Ghost-Weekly-<%= pkg.version %>.zip'
|
2013-07-11 18:05:10 +04:00
|
|
|
},
|
|
|
|
expand: true,
|
2013-09-24 14:46:30 +04:00
|
|
|
cwd: '<%= paths.weeklyBuild %>/<%= pkg.version %>/',
|
|
|
|
src: ['**']
|
2013-07-11 18:05:10 +04:00
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
build: {
|
|
|
|
options: {
|
2013-09-24 14:46:30 +04:00
|
|
|
archive: '<%= paths.buildDist %>/Ghost-Build.zip'
|
2013-06-19 01:25:32 +04:00
|
|
|
},
|
2013-06-25 15:43:15 +04:00
|
|
|
expand: true,
|
2013-09-24 14:46:30 +04:00
|
|
|
cwd: '<%= paths.buildBuild %>/',
|
|
|
|
src: ['**']
|
2013-10-11 19:31:47 +04:00
|
|
|
},
|
|
|
|
release: {
|
|
|
|
options: {
|
|
|
|
archive: '<%= paths.releaseDist %>/Ghost-<%= pkg.version %>.zip'
|
|
|
|
},
|
|
|
|
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-09-24 14:46:30 +04:00
|
|
|
pushTo: 'origin build'
|
2013-07-02 00:58:47 +04:00
|
|
|
}
|
2013-09-14 06:15:30 +04:00
|
|
|
},
|
|
|
|
|
|
|
|
concat: {
|
|
|
|
dev: {
|
|
|
|
files: {
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/built/scripts/vendor.js': [
|
|
|
|
'core/shared/vendor/jquery/jquery.js',
|
|
|
|
'core/shared/vendor/jquery/jquery-ui-1.10.3.custom.min.js',
|
|
|
|
'core/client/assets/lib/jquery-utils.js',
|
|
|
|
'core/client/assets/lib/uploader.js',
|
|
|
|
'core/shared/vendor/underscore.js',
|
|
|
|
'core/shared/vendor/backbone/backbone.js',
|
|
|
|
'core/shared/vendor/handlebars/handlebars-runtime.js',
|
|
|
|
'core/shared/vendor/moment.js',
|
|
|
|
|
|
|
|
'core/client/assets/vendor/icheck/jquery.icheck.min.js',
|
|
|
|
|
|
|
|
'core/shared/vendor/jquery/jquery.ui.widget.js',
|
|
|
|
'core/shared/vendor/jquery/jquery.iframe-transport.js',
|
|
|
|
'core/shared/vendor/jquery/jquery.fileupload.js',
|
|
|
|
|
|
|
|
'core/client/assets/vendor/codemirror/codemirror.js',
|
|
|
|
'core/client/assets/vendor/codemirror/addon/mode/overlay.js',
|
|
|
|
'core/client/assets/vendor/codemirror/mode/markdown/markdown.js',
|
|
|
|
'core/client/assets/vendor/codemirror/mode/gfm/gfm.js',
|
|
|
|
'core/client/assets/vendor/showdown/showdown.js',
|
|
|
|
'core/client/assets/vendor/showdown/extensions/ghostdown.js',
|
|
|
|
'core/shared/vendor/showdown/extensions/github.js',
|
|
|
|
'core/client/assets/vendor/shortcuts.js',
|
|
|
|
'core/client/assets/vendor/validator-client.js',
|
|
|
|
'core/client/assets/vendor/countable.js',
|
|
|
|
'core/client/assets/vendor/to-title-case.js',
|
|
|
|
'core/client/assets/vendor/packery.pkgd.min.js',
|
2013-10-08 19:39:07 +04:00
|
|
|
'core/client/assets/vendor/fastclick.js',
|
|
|
|
'core/client/assets/vendor/nprogress.js'
|
2013-09-14 06:15:30 +04:00
|
|
|
],
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/built/scripts/helpers.js': [
|
|
|
|
'core/client/init.js',
|
2013-09-14 06:15:30 +04:00
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/client/mobile-interactions.js',
|
|
|
|
'core/client/toggle.js',
|
|
|
|
'core/client/markdown-actions.js',
|
|
|
|
'core/client/helpers/index.js'
|
2013-09-14 06:15:30 +04:00
|
|
|
],
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/built/scripts/templates.js': [
|
|
|
|
'core/client/tpl/hbs-tpl.js'
|
2013-09-14 06:15:30 +04:00
|
|
|
],
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/built/scripts/models.js': [
|
|
|
|
'core/client/models/**/*.js'
|
2013-09-14 06:15:30 +04:00
|
|
|
],
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/built/scripts/views.js': [
|
|
|
|
'core/client/views/**/*.js',
|
|
|
|
'core/client/router.js'
|
2013-09-14 06:15:30 +04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
prod: {
|
|
|
|
files: {
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/built/scripts/ghost.js': [
|
|
|
|
'core/shared/vendor/jquery/jquery.js',
|
|
|
|
'core/shared/vendor/jquery/jquery-ui-1.10.3.custom.min.js',
|
|
|
|
'core/client/assets/lib/jquery-utils.js',
|
|
|
|
'core/client/assets/lib/uploader.js',
|
|
|
|
'core/shared/vendor/underscore.js',
|
|
|
|
'core/shared/vendor/backbone/backbone.js',
|
|
|
|
'core/shared/vendor/handlebars/handlebars-runtime.js',
|
|
|
|
'core/shared/vendor/moment.js',
|
|
|
|
|
|
|
|
'core/client/assets/vendor/icheck/jquery.icheck.min.js',
|
|
|
|
|
|
|
|
'core/shared/vendor/jquery/jquery.ui.widget.js',
|
|
|
|
'core/shared/vendor/jquery/jquery.iframe-transport.js',
|
|
|
|
'core/shared/vendor/jquery/jquery.fileupload.js',
|
|
|
|
|
|
|
|
'core/client/assets/vendor/codemirror/codemirror.js',
|
|
|
|
'core/client/assets/vendor/codemirror/addon/mode/overlay.js',
|
|
|
|
'core/client/assets/vendor/codemirror/mode/markdown/markdown.js',
|
|
|
|
'core/client/assets/vendor/codemirror/mode/gfm/gfm.js',
|
|
|
|
'core/client/assets/vendor/showdown/showdown.js',
|
|
|
|
'core/client/assets/vendor/showdown/extensions/ghostdown.js',
|
|
|
|
'core/shared/vendor/showdown/extensions/github.js',
|
|
|
|
'core/client/assets/vendor/shortcuts.js',
|
|
|
|
'core/client/assets/vendor/validator-client.js',
|
|
|
|
'core/client/assets/vendor/countable.js',
|
|
|
|
'core/client/assets/vendor/to-title-case.js',
|
|
|
|
'core/client/assets/vendor/packery.pkgd.min.js',
|
|
|
|
'core/client/assets/vendor/fastclick.js',
|
2013-10-15 14:18:57 +04:00
|
|
|
'core/client/assets/vendor/nprogress.js',
|
2013-09-24 14:46:30 +04:00
|
|
|
|
|
|
|
'core/client/init.js',
|
|
|
|
|
|
|
|
'core/client/mobile-interactions.js',
|
|
|
|
'core/client/toggle.js',
|
|
|
|
'core/client/markdown-actions.js',
|
|
|
|
'core/client/helpers/index.js',
|
|
|
|
|
|
|
|
'core/client/tpl/hbs-tpl.js',
|
|
|
|
|
|
|
|
'core/client/models/**/*.js',
|
|
|
|
|
|
|
|
'core/client/views/**/*.js',
|
|
|
|
|
|
|
|
'core/client/router.js'
|
2013-09-14 06:15:30 +04:00
|
|
|
]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
uglify: {
|
|
|
|
prod: {
|
|
|
|
files: {
|
2013-09-24 14:46:30 +04:00
|
|
|
'core/built/scripts/ghost.min.js': 'core/built/scripts/ghost.js'
|
2013-09-14 06:15:30 +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);
|
|
|
|
|
2013-09-13 18:12:38 +04:00
|
|
|
grunt.registerTask('setTestEnv', function () {
|
|
|
|
// Use 'testing' Ghost config; unless we are running on travis (then show queries for debugging)
|
|
|
|
process.env.NODE_ENV = process.env.TRAVIS ? 'travis' : 'testing';
|
|
|
|
});
|
|
|
|
|
2013-09-13 11:24:28 +04:00
|
|
|
grunt.registerTask('loadConfig', function () {
|
|
|
|
var done = this.async();
|
|
|
|
configLoader.loadConfig().then(function () {
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
// 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-08-27 01:28:41 +04:00
|
|
|
grunt.registerTask('spawn-casperjs', function () {
|
|
|
|
var done = this.async(),
|
|
|
|
options = ['host', 'noPort', 'port', 'email', 'password'],
|
2013-10-17 09:28:16 +04:00
|
|
|
args = ['test', 'admin/', 'frontend/', '--includes=base.js', '--verbose', '--log-level=debug', '--port=2369'];
|
2013-08-27 01:28:41 +04:00
|
|
|
|
|
|
|
// Forward parameters from grunt to casperjs
|
|
|
|
_.each(options, function processOption(option) {
|
|
|
|
if (grunt.option(option)) {
|
|
|
|
args.push('--' + option + '=' + grunt.option(option));
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
grunt.util.spawn({
|
|
|
|
cmd: 'casperjs',
|
|
|
|
args: args,
|
|
|
|
opts: {
|
|
|
|
cwd: path.resolve('core/test/functional'),
|
|
|
|
stdio: 'inherit'
|
|
|
|
}
|
|
|
|
}, function (error, result, code) {
|
|
|
|
if (error) {
|
|
|
|
grunt.fail.fatal(result.stdout);
|
|
|
|
}
|
|
|
|
grunt.log.writeln(result.stdout);
|
|
|
|
done();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-08-01 11:12:59 +04:00
|
|
|
/* Generate Changelog
|
|
|
|
* - Pulls changelog from git, excluding merges.
|
|
|
|
* - Uses first line of commit message. Includes committer name.
|
|
|
|
*/
|
|
|
|
grunt.registerTask("changelog", "Generate changelog from Git", function () {
|
|
|
|
// TODO: Break the contents of this task out into a separate module,
|
|
|
|
// put on npm. (@cgiffard)
|
|
|
|
|
|
|
|
var done = this.async();
|
|
|
|
|
|
|
|
function git(args, callback, depth) {
|
|
|
|
depth = depth || 0;
|
|
|
|
|
|
|
|
if (!depth) {
|
2013-09-24 14:46:30 +04:00
|
|
|
grunt.log.writeln('git ' + args.join(' '));
|
2013-08-01 11:12:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
var buffer = [];
|
2013-09-24 14:46:30 +04:00
|
|
|
spawn('git', args, {
|
2013-08-01 11:12:59 +04:00
|
|
|
// We can reasonably assume the gruntfile will be in the root of the repo.
|
|
|
|
cwd : __dirname,
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
stdio : ['ignore', 'pipe', process.stderr]
|
2013-08-01 11:12:59 +04:00
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
}).on('exit', function (code) {
|
2013-08-01 11:12:59 +04:00
|
|
|
|
|
|
|
// Process exited correctly but we got no output.
|
|
|
|
// Spawn again, but make sure we don't spiral out of control.
|
|
|
|
// Hack to work around an apparent node bug.
|
|
|
|
//
|
|
|
|
// Frustratingly, it's impossible to distinguish this
|
|
|
|
// bug from a genuine empty log.
|
|
|
|
|
|
|
|
if (!buffer.length && code === 0 && depth < 20) {
|
|
|
|
return setImmediate(function () {
|
|
|
|
git(args, callback, depth ? depth + 1 : 1);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (code === 0) {
|
2013-09-24 14:46:30 +04:00
|
|
|
return callback(buffer.join(''));
|
2013-08-01 11:12:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// We failed. Git returned a non-standard exit code.
|
|
|
|
grunt.log.error('Git returned a non-zero exit code.');
|
|
|
|
done(false);
|
|
|
|
|
|
|
|
// Push returned data into the buffer
|
2013-09-24 14:46:30 +04:00
|
|
|
}).stdout.on('data', buffer.push.bind(buffer));
|
2013-08-01 11:12:59 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Crazy function for getting around inconsistencies in tagging
|
|
|
|
function sortTags(a, b) {
|
|
|
|
a = a.tag;
|
|
|
|
b = b.tag;
|
|
|
|
|
|
|
|
// NOTE: Accounting for different tagging method for
|
|
|
|
// 0.2.1 and up.
|
|
|
|
|
|
|
|
// If we didn't have this issue I'd just pass rcompare
|
|
|
|
// into sort directly. Could be something to think about
|
|
|
|
// in future.
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
if (semver.rcompare(a, '0.2.0') < 0 ||
|
|
|
|
semver.rcompare(b, '0.2.0') < 0) {
|
2013-08-01 11:12:59 +04:00
|
|
|
|
|
|
|
return semver.rcompare(a, b);
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
a = a.split('-');
|
|
|
|
b = b.split('-');
|
2013-08-01 11:12:59 +04:00
|
|
|
|
|
|
|
if (semver.rcompare(a[0], b[0]) !== 0) {
|
|
|
|
return semver.rcompare(a[0], b[0]);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Using this janky looking integerising-method
|
|
|
|
// because it's faster and doesn't result in NaN, which
|
|
|
|
// breaks sorting
|
2013-09-13 00:03:01 +04:00
|
|
|
/*jslint bitwise: true */
|
2013-08-01 11:12:59 +04:00
|
|
|
return (+b[1] | 0) - (+a[1] | 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Gets tags in master branch, sorts them with semver,
|
|
|
|
function getTags(callback) {
|
2013-09-24 14:46:30 +04:00
|
|
|
git(['show-ref', '--tags'], function (results) {
|
2013-08-01 11:12:59 +04:00
|
|
|
results = results
|
|
|
|
.split(/\n+/)
|
|
|
|
.filter(function (tag) {
|
|
|
|
return tag.length && tag.match(/\/\d+\.\d+/);
|
|
|
|
})
|
|
|
|
.map(function (tag) {
|
|
|
|
return {
|
2013-09-24 14:46:30 +04:00
|
|
|
'tag': tag.split(/tags\//).pop().trim(),
|
|
|
|
'ref': tag.split(/\s+/).shift().trim()
|
2013-08-01 11:12:59 +04:00
|
|
|
};
|
|
|
|
})
|
|
|
|
.sort(sortTags);
|
|
|
|
|
|
|
|
callback(results);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Parses log to extract commit data.
|
|
|
|
function parseLog(data) {
|
|
|
|
var commits = [],
|
|
|
|
commitRegex =
|
|
|
|
new RegExp(
|
2013-09-24 14:46:30 +04:00
|
|
|
'\\n*[|\\*\\s]*commit\\s+([a-f0-9]+)' +
|
|
|
|
'\\n[|\\*\\s]*Author:\\s+([^<\\n]+)<([^>\\n]+)>' +
|
|
|
|
'\\n[|\\*\\s]*Date:\\s+([^\\n]+)' +
|
|
|
|
'\\n+[|\\*\\s]*[ ]{4}([^\\n]+)',
|
|
|
|
'ig'
|
2013-08-01 11:12:59 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
// Using String.prototype.replace as a kind of poor-man's substitute
|
|
|
|
// for a streaming parser.
|
|
|
|
data.replace(
|
|
|
|
commitRegex,
|
|
|
|
function (wholeCommit, hash, author, email, date, message) {
|
|
|
|
|
|
|
|
// The author name and commit message may have trailing space.
|
|
|
|
author = author.trim();
|
|
|
|
message = message.trim();
|
|
|
|
|
|
|
|
// Reformat date to make it parse-able by JS
|
|
|
|
date =
|
|
|
|
date.replace(
|
|
|
|
/^(\w+)\s(\w+)\s(\d+)\s([\d\:]+)\s(\d+)\s([\+\-\d]+)$/,
|
2013-09-24 14:46:30 +04:00
|
|
|
'$1, $2 $3 $5 $4 $6'
|
2013-08-01 11:12:59 +04:00
|
|
|
);
|
|
|
|
|
|
|
|
commits.push({
|
2013-09-24 14:46:30 +04:00
|
|
|
'hash': hash,
|
|
|
|
'author': author,
|
|
|
|
'email': email,
|
|
|
|
'date': date,
|
|
|
|
'parsedDate': new Date(Date.parse(date)),
|
|
|
|
'message': message
|
2013-08-01 11:12:59 +04:00
|
|
|
});
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
);
|
|
|
|
|
|
|
|
return commits;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Gets git log for specified range.
|
|
|
|
function getLog(to, from, callback) {
|
2013-09-24 14:46:30 +04:00
|
|
|
var range = from && to ? from + '..' + to : '',
|
|
|
|
args = [ 'log', 'master', '--no-color', '--no-merges', '--graph' ];
|
2013-08-01 11:12:59 +04:00
|
|
|
|
|
|
|
if (range) {
|
|
|
|
args.push(range);
|
|
|
|
}
|
|
|
|
|
|
|
|
git(args, function (data) {
|
|
|
|
callback(parseLog(data));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run the job
|
|
|
|
getTags(function (tags) {
|
2013-09-24 14:46:30 +04:00
|
|
|
var logPath = path.join(__dirname, 'CHANGELOG.md'),
|
2013-08-01 11:12:59 +04:00
|
|
|
log = fs.createWriteStream(logPath),
|
|
|
|
commitCache = {};
|
|
|
|
|
|
|
|
function processTag(tag, callback) {
|
2013-09-24 14:46:30 +04:00
|
|
|
var buffer = '',
|
2013-08-01 11:12:59 +04:00
|
|
|
peek = tag[1];
|
|
|
|
|
|
|
|
tag = tag[0];
|
|
|
|
|
|
|
|
getLog(tag.tag, peek.tag, function (commits) {
|
|
|
|
|
|
|
|
// Use the comparison with HEAD to remove commits which
|
|
|
|
// haven't been included in a build/release yet.
|
|
|
|
|
|
|
|
if (tag.tag === "HEAD") {
|
|
|
|
commits.forEach(function (commit) {
|
|
|
|
commitCache[commit.hash] = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
return callback("");
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
buffer += '## Release ' + tag.tag + '\n';
|
2013-08-01 11:12:59 +04:00
|
|
|
|
|
|
|
commits = commits
|
|
|
|
.filter(function (commit) {
|
|
|
|
|
|
|
|
// Get rid of jenkins' release tagging commits
|
|
|
|
// Remove commits we've already spat out
|
|
|
|
return (
|
2013-09-24 14:46:30 +04:00
|
|
|
commit.author !== 'TryGhost-Jenkins' &&
|
2013-08-01 11:12:59 +04:00
|
|
|
!commitCache[commit.hash]
|
|
|
|
);
|
|
|
|
})
|
|
|
|
.map(function (commit) {
|
2013-09-24 14:46:30 +04:00
|
|
|
buffer += '\n* ' + commit.message + ' (_' + commit.author + '_)';
|
2013-08-01 11:12:59 +04:00
|
|
|
commitCache[commit.hash] = true;
|
|
|
|
});
|
|
|
|
|
|
|
|
if (!commits.length) {
|
|
|
|
buffer += "\nNo changes were made in this build.\n";
|
|
|
|
}
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
callback(buffer + '\n');
|
2013-08-01 11:12:59 +04:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// Get two weeks' worth of tags
|
2013-09-24 14:46:30 +04:00
|
|
|
tags.unshift({'tag': 'HEAD'});
|
2013-08-01 11:12:59 +04:00
|
|
|
|
|
|
|
tags =
|
|
|
|
tags
|
|
|
|
.slice(0, 14)
|
|
|
|
.map(function (tag, index) {
|
|
|
|
return [
|
|
|
|
tag,
|
|
|
|
tags[index + 1] || tags[index]
|
|
|
|
];
|
|
|
|
});
|
|
|
|
|
2013-09-24 14:46:30 +04:00
|
|
|
log.write('# Ghost Changelog\n\n');
|
|
|
|
log.write('_Showing ' + tags.length + ' releases._\n');
|
2013-08-01 11:12:59 +04:00
|
|
|
|
|
|
|
when.reduce(tags,
|
|
|
|
function (prev, tag, idx) {
|
|
|
|
return when.promise(function (resolve) {
|
|
|
|
processTag(tag, function (releaseData) {
|
2013-09-24 14:46:30 +04:00
|
|
|
resolve(prev + '\n' + releaseData);
|
2013-08-01 11:12:59 +04:00
|
|
|
});
|
|
|
|
});
|
2013-09-24 14:46:30 +04:00
|
|
|
}, '')
|
2013-08-01 11:12:59 +04:00
|
|
|
.then(function (reducedChangelog) {
|
|
|
|
log.write(reducedChangelog);
|
|
|
|
log.close();
|
|
|
|
done(true);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2013-06-25 15:43:15 +04:00
|
|
|
/* 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
|
2013-08-01 11:12:59 +04:00
|
|
|
* - Generate changelog for the past 14 releases
|
2013-07-11 18:05:10 +04:00
|
|
|
* - 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-09-27 19:02:35 +04:00
|
|
|
"setCurrentBuildType:Nightly",
|
|
|
|
"shell:bourbon",
|
|
|
|
"sass:compress",
|
|
|
|
"handlebars",
|
|
|
|
"concat",
|
|
|
|
"uglify",
|
|
|
|
"bump:build",
|
|
|
|
"updateCurrentPackageInfo",
|
|
|
|
"changelog",
|
|
|
|
"copy:nightly",
|
|
|
|
"compress:nightly"
|
2013-07-11 18:05:10 +04:00
|
|
|
]);
|
|
|
|
|
|
|
|
grunt.registerTask("weekly", [
|
2013-09-27 19:02:35 +04:00
|
|
|
"setCurrentBuildType:Weekly",
|
|
|
|
"shell:bourbon",
|
|
|
|
"sass:compress",
|
|
|
|
"handlebars",
|
|
|
|
"concat",
|
|
|
|
"uglify",
|
|
|
|
"bump:build",
|
|
|
|
"updateCurrentPackageInfo",
|
|
|
|
"changelog",
|
|
|
|
"copy:weekly",
|
|
|
|
"compress:weekly"
|
2013-06-25 15:43:15 +04:00
|
|
|
]);
|
|
|
|
|
2013-09-27 19:02:35 +04:00
|
|
|
grunt.registerTask("build", [
|
|
|
|
"shell:bourbon",
|
|
|
|
"sass:compress",
|
|
|
|
"handlebars",
|
|
|
|
"concat",
|
|
|
|
"uglify",
|
|
|
|
"changelog",
|
|
|
|
"clean:build",
|
|
|
|
"copy:build",
|
|
|
|
"compress:build"
|
2013-06-25 15:43:15 +04:00
|
|
|
]);
|
|
|
|
|
2013-10-11 19:31:47 +04:00
|
|
|
grunt.registerTask('release', [
|
|
|
|
'shell:bourbon',
|
|
|
|
'sass:admin',
|
|
|
|
'handlebars',
|
|
|
|
'concat',
|
|
|
|
'uglify',
|
|
|
|
'changelog',
|
|
|
|
'clean:build',
|
|
|
|
'copy:build',
|
|
|
|
'compress:release'
|
|
|
|
]);
|
|
|
|
|
2013-08-17 22:39:02 +04:00
|
|
|
// Dev Mode; watch files and restart server on changes
|
2013-09-27 19:02:35 +04:00
|
|
|
grunt.registerTask("dev", [
|
|
|
|
"sass:admin",
|
|
|
|
"handlebars",
|
|
|
|
"concat",
|
|
|
|
"express:dev",
|
|
|
|
"open",
|
|
|
|
"watch"
|
2013-08-17 22:39:02 +04:00
|
|
|
]);
|
|
|
|
|
2013-09-13 18:12:38 +04:00
|
|
|
// Prepare the project for development
|
|
|
|
// TODO: Git submodule init/update (https://github.com/jaubourg/grunt-update-submodules)?
|
2013-09-24 14:46:30 +04:00
|
|
|
grunt.registerTask('init', ['shell:bourbon', 'default']);
|
2013-09-13 18:12:38 +04:00
|
|
|
|
2013-09-13 11:24:28 +04:00
|
|
|
// Run unit tests
|
2013-10-15 07:39:52 +04:00
|
|
|
grunt.registerTask('test-unit', ['clean:test', 'setTestEnv', 'loadConfig', 'express:test', 'mochacli:all']);
|
2013-09-13 18:12:38 +04:00
|
|
|
|
|
|
|
// Run casperjs tests only
|
2013-10-15 07:39:52 +04:00
|
|
|
grunt.registerTask('test-functional', ['clean:test', 'setTestEnv', 'express:test', 'spawn-casperjs']);
|
2013-09-13 18:12:38 +04:00
|
|
|
|
|
|
|
// Run tests and lint code
|
2013-09-24 14:46:30 +04:00
|
|
|
grunt.registerTask('validate', ['jslint', 'test-unit', 'test-functional']);
|
2013-09-13 18:12:38 +04:00
|
|
|
|
|
|
|
// Generate Docs
|
2013-09-24 14:46:30 +04:00
|
|
|
grunt.registerTask('docs', ['groc']);
|
2013-09-13 18:12:38 +04:00
|
|
|
|
2013-09-14 06:15:30 +04:00
|
|
|
// TODO: Production build task that minifies with uglify:prod
|
|
|
|
|
2013-09-27 19:02:35 +04:00
|
|
|
grunt.registerTask("prod", ['sass:compress', 'handlebars', 'concat', "uglify"]);
|
2013-09-17 03:44:45 +04:00
|
|
|
|
2013-09-27 19:02:35 +04:00
|
|
|
// When you just say "grunt"
|
|
|
|
grunt.registerTask("default", ['sass:compress', 'handlebars', 'concat']);
|
2013-06-25 15:43:15 +04:00
|
|
|
};
|
|
|
|
|
2013-06-27 07:52:56 +04:00
|
|
|
module.exports = configureGrunt;
|