From 951cff9bda0e1efafd6dd7b5a13592cab668778b Mon Sep 17 00:00:00 2001 From: Matt Gilman Date: Wed, 13 May 2015 18:57:51 -0400 Subject: [PATCH] NIFI-592: - Automating deployment of website changes. --- nifi-site/Gruntfile.js | 100 ++++++++++++++++++++++++++++++++++++++++- nifi-site/package.json | 3 +- 2 files changed, 100 insertions(+), 3 deletions(-) diff --git a/nifi-site/Gruntfile.js b/nifi-site/Gruntfile.js index 2a3a5ba65d..782f5e4853 100644 --- a/nifi-site/Gruntfile.js +++ b/nifi-site/Gruntfile.js @@ -1,6 +1,13 @@ +/* global module */ + module.exports = function (grunt) { // Project configuration. grunt.initConfig({ + config: { + svn: { + url: 'https://svn.apache.org/repos/asf/incubator/nifi/site/trunk' + } + }, pkg: grunt.file.readJSON('package.json'), clean: { options: { @@ -9,7 +16,8 @@ module.exports = function (grunt) { js: ['dist/js/'], css: ['dist/css/'], assets: ['dist/assets/*'], - generated: ['dist/docs'] + generated: ['dist/docs'], + all: ['dist'] }, assemble: { options: { @@ -115,6 +123,51 @@ module.exports = function (grunt) { }] } }, + prompt: { + username: { + options: { + questions: [{ + config: 'config.svn.username', + type: 'input', + message: 'Enter SVN username if different from current user:' + }] + } + }, + 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', + message: 'SVN password:' + }], + then: function () { + grunt.task.run('exec:commit'); + } + } + } + }, exec: { generateDocs: { command: 'mvn clean package', @@ -127,6 +180,44 @@ module.exports = function (grunt) { cwd: '../nifi/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api', stdout: true, stderr: true + }, + checkout: { + command: function() { + var url = grunt.config('config.svn.url'); + var username = grunt.config('config.svn.username'); + if (username === '') { + return 'svn checkout ' + url + ' --trust-server-cert --non-interactive dist'; + } else { + return 'svn checkout --username ' + username + ' ' + url + ' --trust-server-cert --non-interactive dist'; + } + }, + stdout: true, + stderr: true + }, + status: { + cwd: 'dist', + command: 'svn status', + stdout: true, + stderr: true + }, + diff: { + cwd: 'dist', + command: 'svn diff', + stdout: true, + stderr: true + }, + 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'); + if (username === '') { + return 'svn commit --password "' + password + '" -m "' + message + '" --trust-server-cert --non-interactive .'; + } else { + return 'svn commit --username ' + username + ' --password "' + password + '" -m "' + message + '" --trust-server-cert --non-interactive .'; + } + } } }, replace: { @@ -196,11 +287,16 @@ module.exports = function (grunt) { grunt.loadNpmTasks('grunt-contrib-watch'); grunt.loadNpmTasks('grunt-exec'); grunt.loadNpmTasks('grunt-text-replace'); + grunt.loadNpmTasks('grunt-prompt'); grunt.registerTask('img', ['newer:copy']); grunt.registerTask('css', ['clean:css', 'compass']); grunt.registerTask('js', ['clean:js', 'concat']); grunt.registerTask('generate-docs', ['clean:generated', 'exec:generateDocs', 'exec:generateRestApiDocs', 'copy:generated', 'replace:addGoogleAnalytics', 'replace:moveTearDrop', 'replace:removeVersion']); - grunt.registerTask('default', ['clean', 'assemble', 'css', 'js', 'img', 'generate-docs', 'copy:dist']); + + grunt.registerTask('build', ['assemble', 'css', 'js', 'img', 'generate-docs', 'copy:dist']); + grunt.registerTask('deploy', ['clean:all', 'prompt:username', 'exec:checkout', 'build', 'exec:status', 'prompt:commit']); grunt.registerTask('dev', ['default', 'watch']); + + grunt.registerTask('default', ['clean:all', 'build']); }; diff --git a/nifi-site/package.json b/nifi-site/package.json index f2ad8ca9f1..dbd8ab52ec 100644 --- a/nifi-site/package.json +++ b/nifi-site/package.json @@ -1,6 +1,6 @@ { "name": "apache-nifi-site", - "version": "0.0.2-incubating", + "version": "0.1.0-incubating", "description": "The artifacts for the Apache NiFi site.", "private": "true", "repository": { @@ -17,6 +17,7 @@ "grunt-contrib-watch": "^0.6.1", "grunt-exec": "^0.4.6", "grunt-newer": "^1.1.0", + "grunt-prompt": "^1.3.0", "grunt-text-replace": "^0.4.0" }, "licenses": [