2015-05-13 18:57:51 -04:00
|
|
|
/* global module */
|
|
|
|
|
2015-02-02 23:21:21 -05:00
|
|
|
module.exports = function (grunt) {
|
|
|
|
// Project configuration.
|
|
|
|
grunt.initConfig({
|
2015-05-13 18:57:51 -04:00
|
|
|
config: {
|
|
|
|
svn: {
|
|
|
|
url: 'https://svn.apache.org/repos/asf/incubator/nifi/site/trunk'
|
|
|
|
}
|
|
|
|
},
|
2015-02-02 23:21:21 -05:00
|
|
|
pkg: grunt.file.readJSON('package.json'),
|
|
|
|
clean: {
|
|
|
|
options: {
|
|
|
|
force: true
|
|
|
|
},
|
|
|
|
js: ['dist/js/'],
|
|
|
|
css: ['dist/css/'],
|
2015-05-05 16:11:29 -04:00
|
|
|
assets: ['dist/assets/*'],
|
2015-05-13 18:57:51 -04:00
|
|
|
generated: ['dist/docs'],
|
|
|
|
all: ['dist']
|
2015-02-02 23:21:21 -05:00
|
|
|
},
|
|
|
|
assemble: {
|
|
|
|
options: {
|
|
|
|
partials: 'src/includes/*.hbs',
|
|
|
|
layout: 'src/layouts/html.hbs',
|
|
|
|
flatten: true
|
|
|
|
},
|
|
|
|
html: {
|
|
|
|
files: {
|
|
|
|
'dist/': ['src/pages/html/*.hbs']
|
|
|
|
}
|
|
|
|
},
|
|
|
|
markdown: {
|
|
|
|
options: {
|
|
|
|
layout: 'src/layouts/markdown.hbs'
|
|
|
|
},
|
|
|
|
files: {
|
|
|
|
'dist/': ['src/pages/markdown/*.md']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
compass: {
|
|
|
|
dist: {
|
|
|
|
options: {
|
|
|
|
config: 'config.rb'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
concat: {
|
|
|
|
options: {
|
|
|
|
separator: ';'
|
|
|
|
},
|
|
|
|
foundation: {
|
|
|
|
src: [
|
|
|
|
'bower_components/foundation/js/foundation/foundation.js',
|
2015-02-05 23:33:19 -05:00
|
|
|
'bower_components/foundation/js/foundation/foundation.topbar.js',
|
|
|
|
'bower_components/foundation/js/foundation/foundation.reveal.js'
|
2015-02-02 23:21:21 -05:00
|
|
|
],
|
|
|
|
dest: 'dist/assets/js/foundation.js'
|
|
|
|
},
|
|
|
|
modernizr: {
|
|
|
|
src: [
|
|
|
|
'bower_components/modernizr/modernizr.js'
|
|
|
|
],
|
|
|
|
dest: 'dist/assets/js/modernizr.js'
|
|
|
|
},
|
|
|
|
nifi: {
|
|
|
|
src: [
|
|
|
|
'src/js/app.js'
|
|
|
|
],
|
|
|
|
dest: 'dist/js/app.js'
|
|
|
|
}
|
|
|
|
},
|
|
|
|
copy: {
|
2015-05-29 08:16:11 -04:00
|
|
|
// generated: {
|
|
|
|
// files: [{
|
|
|
|
// expand: true,
|
|
|
|
// cwd: '../nifi/nifi-docs/target/generated-docs',
|
|
|
|
// src: ['*.html', 'images/*'],
|
|
|
|
// dest: 'dist/docs/'
|
|
|
|
// }, {
|
|
|
|
// expand: true,
|
|
|
|
// cwd: '../nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api',
|
|
|
|
// src: ['target/nifi-web-api-*/docs/rest-api/index.html', 'target/nifi-web-api-*/docs/rest-api/images/*'],
|
|
|
|
// dest: 'dist/docs/',
|
|
|
|
// rename: function (dest, src) {
|
|
|
|
// var path = require('path');
|
|
|
|
//
|
|
|
|
// if (src.indexOf('images') > 0) {
|
|
|
|
// return path.join(dest, 'rest-api/images', path.basename(src));
|
|
|
|
// } else {
|
|
|
|
// return path.join(dest, 'rest-api', path.basename(src));
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
// }]
|
|
|
|
// },
|
2015-02-02 23:21:21 -05:00
|
|
|
dist: {
|
|
|
|
files: [{
|
2015-05-05 16:11:29 -04:00
|
|
|
expand: true,
|
|
|
|
cwd: 'src/images/',
|
|
|
|
src: ['**/*.{png,jpg,gif,svg,ico}'],
|
|
|
|
dest: 'dist/images/'
|
|
|
|
}, {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'bower_components/jquery/dist',
|
|
|
|
src: ['jquery.min.js'],
|
|
|
|
dest: 'dist/assets/js/'
|
|
|
|
}, {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'bower_components/webfontloader',
|
|
|
|
src: ['webfontloader.js'],
|
|
|
|
dest: 'dist/assets/js/'
|
|
|
|
}, {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'bower_components/font-awesome/css',
|
|
|
|
src: ['font-awesome.min.css'],
|
|
|
|
dest: 'dist/assets/stylesheets/'
|
|
|
|
}, {
|
|
|
|
expand: true,
|
|
|
|
cwd: 'bower_components/font-awesome',
|
|
|
|
src: ['fonts/*'],
|
|
|
|
dest: 'dist/assets/'
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
},
|
2015-05-13 18:57:51 -04:00
|
|
|
prompt: {
|
|
|
|
username: {
|
|
|
|
options: {
|
|
|
|
questions: [{
|
|
|
|
config: 'config.svn.username',
|
|
|
|
type: 'input',
|
2015-05-14 08:07:32 -04:00
|
|
|
message: 'Enter SVN username (if different from current or configured user):'
|
2015-05-13 18:57:51 -04:00
|
|
|
}]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
commit: {
|
|
|
|
options: {
|
|
|
|
questions: [{
|
|
|
|
config: 'config.svn.commit.confirmation',
|
|
|
|
type: 'list',
|
|
|
|
choices: ['Show diff', 'Commit', 'Abort'],
|
|
|
|
message: 'Commit the changes listed above?'
|
|
|
|
}],
|
|
|
|
then: function (results) {
|
|
|
|
if (results['config.svn.commit.confirmation'] === 'Commit') {
|
|
|
|
grunt.task.run('prompt:message');
|
|
|
|
} else if (results['config.svn.commit.confirmation'] === 'Show diff') {
|
|
|
|
grunt.task.run('exec:diff');
|
|
|
|
grunt.task.run('prompt:commit');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
message: {
|
|
|
|
options: {
|
|
|
|
questions: [{
|
|
|
|
config: 'config.svn.commit.message',
|
|
|
|
type: 'input',
|
|
|
|
message: 'Commit message:'
|
|
|
|
}, {
|
|
|
|
config: 'config.svn.password',
|
|
|
|
type: 'password',
|
2015-05-14 08:07:32 -04:00
|
|
|
message: 'SVN password (if different from configured):'
|
2015-05-13 18:57:51 -04:00
|
|
|
}],
|
|
|
|
then: function () {
|
2015-05-20 10:19:46 -04:00
|
|
|
grunt.task.run('exec:add');
|
2015-05-13 18:57:51 -04:00
|
|
|
grunt.task.run('exec:commit');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2015-05-05 16:11:29 -04:00
|
|
|
exec: {
|
|
|
|
generateDocs: {
|
|
|
|
command: 'mvn clean package',
|
|
|
|
cwd: '../nifi/nifi-docs',
|
|
|
|
stdout: true,
|
|
|
|
stderr: true
|
|
|
|
},
|
|
|
|
generateRestApiDocs: {
|
|
|
|
command: 'mvn clean package -DskipTests',
|
|
|
|
cwd: '../nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api',
|
|
|
|
stdout: true,
|
|
|
|
stderr: true
|
2015-05-13 18:57:51 -04:00
|
|
|
},
|
|
|
|
checkout: {
|
|
|
|
command: function() {
|
|
|
|
var url = grunt.config('config.svn.url');
|
|
|
|
var username = grunt.config('config.svn.username');
|
2015-05-14 08:07:32 -04:00
|
|
|
var command = 'svn checkout';
|
|
|
|
if (username !== '') {
|
|
|
|
command += (' --username ' + username);
|
2015-05-13 18:57:51 -04:00
|
|
|
}
|
2015-05-14 08:07:32 -04:00
|
|
|
return command + ' ' + url + ' --trust-server-cert --non-interactive dist';
|
2015-05-13 18:57:51 -04:00
|
|
|
},
|
|
|
|
stdout: true,
|
|
|
|
stderr: true
|
|
|
|
},
|
|
|
|
status: {
|
|
|
|
cwd: 'dist',
|
|
|
|
command: 'svn status',
|
|
|
|
stdout: true,
|
|
|
|
stderr: true
|
|
|
|
},
|
|
|
|
diff: {
|
|
|
|
cwd: 'dist',
|
|
|
|
command: 'svn diff',
|
|
|
|
stdout: true,
|
|
|
|
stderr: true
|
|
|
|
},
|
2015-05-20 10:19:46 -04:00
|
|
|
add: {
|
|
|
|
cwd: 'dist',
|
|
|
|
command: 'svn add --force .',
|
|
|
|
stdout: true,
|
|
|
|
stderr: true
|
|
|
|
},
|
2015-05-13 18:57:51 -04:00
|
|
|
commit: {
|
|
|
|
cwd: 'dist',
|
|
|
|
command: function() {
|
|
|
|
var username = grunt.config('config.svn.username');
|
|
|
|
var password = grunt.config('config.svn.password');
|
|
|
|
var message = grunt.config('config.svn.commit.message');
|
2015-05-14 08:07:32 -04:00
|
|
|
var command = 'svn commit';
|
|
|
|
if (username !== '') {
|
|
|
|
command += (' --username ' + username);
|
2015-05-13 18:57:51 -04:00
|
|
|
}
|
2015-05-14 08:07:32 -04:00
|
|
|
if (password !== '') {
|
|
|
|
command += (' --password ' + password);
|
|
|
|
}
|
|
|
|
return command + ' -m "' + message + '" --trust-server-cert --non-interactive .';
|
2015-05-13 18:57:51 -04:00
|
|
|
}
|
2015-02-02 23:21:21 -05:00
|
|
|
}
|
|
|
|
},
|
2015-05-06 10:04:18 -04:00
|
|
|
replace: {
|
|
|
|
addGoogleAnalytics: {
|
|
|
|
src: ['dist/docs/*.html', 'dist/docs/rest-api/index.html'],
|
|
|
|
overwrite: true,
|
|
|
|
replacements: [{
|
|
|
|
from: /<\/head>/g,
|
|
|
|
to: "<script>\n" +
|
|
|
|
"(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){\n" +
|
|
|
|
"(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),\n" +
|
|
|
|
"m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)\n" +
|
|
|
|
"})(window,document,'script','//www.google-analytics.com/analytics.js','ga');\n" +
|
|
|
|
"ga('create', 'UA-57264262-1', 'auto');\n" +
|
|
|
|
"ga('send', 'pageview');\n" +
|
|
|
|
"</script>\n" +
|
|
|
|
"</head>"
|
|
|
|
}]
|
2015-05-06 10:32:28 -04:00
|
|
|
},
|
|
|
|
moveTearDrop: {
|
|
|
|
src: ['dist/docs/rest-api/index.html'],
|
|
|
|
overwrite: true,
|
|
|
|
replacements: [{
|
|
|
|
from: /<img class="logo" src="images\/bgNifiLogo.png" alt="NiFi Logo"\/>/g,
|
|
|
|
to: '<img class="logo" src="images/bgNifiLogo.png" alt="NiFi Logo" style="float: right;"/>'
|
|
|
|
}]
|
|
|
|
},
|
|
|
|
removeVersion: {
|
|
|
|
src: ['dist/docs/rest-api/index.html'],
|
|
|
|
overwrite: true,
|
|
|
|
replacements: [{
|
|
|
|
from: /<div class="sub-title">.*<\/div>/g,
|
|
|
|
to: '<div class="sub-title">NiFi Rest Api</div>'
|
2015-05-20 10:19:46 -04:00
|
|
|
}, {
|
|
|
|
from: /<title>.*<\/title>/g,
|
|
|
|
to: '<title>NiFi Rest Api</title>'
|
2015-05-06 10:32:28 -04:00
|
|
|
}]
|
2015-05-06 10:04:18 -04:00
|
|
|
}
|
|
|
|
},
|
2015-02-02 23:21:21 -05:00
|
|
|
watch: {
|
2015-05-05 16:11:29 -04:00
|
|
|
grunt: {
|
|
|
|
files: ['Gruntfile.js'],
|
|
|
|
tasks: ['dev']
|
2015-02-02 23:21:21 -05:00
|
|
|
},
|
|
|
|
css: {
|
|
|
|
files: 'src/scss/*.scss',
|
|
|
|
tasks: ['css']
|
|
|
|
},
|
2015-05-05 16:11:29 -04:00
|
|
|
script: {
|
2015-02-02 23:21:21 -05:00
|
|
|
files: 'src/js/*.js',
|
|
|
|
tasks: ['js']
|
|
|
|
},
|
|
|
|
images: {
|
|
|
|
files: 'src/images/*.{png,jpg,gif,svg,ico}',
|
|
|
|
tasks: ['img']
|
|
|
|
},
|
|
|
|
assemble: {
|
|
|
|
files: ['src/{includes,layouts}/*.hbs', 'src/pages/{html,markdown}/*.{hbs,md}'],
|
|
|
|
tasks: ['assemble']
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
2015-05-05 16:11:29 -04:00
|
|
|
|
2015-02-02 23:21:21 -05:00
|
|
|
grunt.loadNpmTasks('grunt-newer');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-clean');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-copy');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-concat');
|
|
|
|
grunt.loadNpmTasks('assemble');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-compass');
|
|
|
|
grunt.loadNpmTasks('grunt-contrib-watch');
|
2015-05-05 16:11:29 -04:00
|
|
|
grunt.loadNpmTasks('grunt-exec');
|
2015-05-06 10:04:18 -04:00
|
|
|
grunt.loadNpmTasks('grunt-text-replace');
|
2015-05-13 18:57:51 -04:00
|
|
|
grunt.loadNpmTasks('grunt-prompt');
|
2015-05-05 16:11:29 -04:00
|
|
|
|
2015-02-02 23:21:21 -05:00
|
|
|
grunt.registerTask('img', ['newer:copy']);
|
|
|
|
grunt.registerTask('css', ['clean:css', 'compass']);
|
2015-05-05 16:11:29 -04:00
|
|
|
grunt.registerTask('js', ['clean:js', 'concat']);
|
2015-05-29 08:16:11 -04:00
|
|
|
// grunt.registerTask('generate-docs', ['clean:generated', 'exec:generateDocs', 'exec:generateRestApiDocs', 'copy:generated', 'replace:addGoogleAnalytics', 'replace:moveTearDrop', 'replace:removeVersion']);
|
2015-05-13 18:57:51 -04:00
|
|
|
|
2015-05-29 08:16:11 -04:00
|
|
|
grunt.registerTask('build', ['assemble', 'css', 'js', 'img', 'copy:dist']);
|
|
|
|
// grunt.registerTask('build', ['assemble', 'css', 'js', 'img', 'generate-docs', 'copy:dist']);
|
2015-05-13 18:57:51 -04:00
|
|
|
grunt.registerTask('deploy', ['clean:all', 'prompt:username', 'exec:checkout', 'build', 'exec:status', 'prompt:commit']);
|
2015-05-05 16:11:29 -04:00
|
|
|
grunt.registerTask('dev', ['default', 'watch']);
|
2015-05-13 18:57:51 -04:00
|
|
|
|
|
|
|
grunt.registerTask('default', ['clean:all', 'build']);
|
2015-02-02 23:21:21 -05:00
|
|
|
};
|