aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@apache.org>2015-09-30 08:18:21 +0200
committerManolo Carrasco <manolo@apache.org>2015-09-30 08:18:21 +0200
commit85404f44f7e5c524b7edb86d2b5bbb4300bb6424 (patch)
tree7bfdc236bd751e6485f316e909f32515fd02b80b
parent75e39b939d3a171c5c26d2b9bd3afeb5345ae9b1 (diff)
downloadvaadin-core-85404f44f7e5c524b7edb86d2b5bbb4300bb6424.tar.gz
vaadin-core-85404f44f7e5c524b7edb86d2b5bbb4300bb6424.zip
Uploading docsite as a .zip file. Group all docsite related tasks in one file
-rw-r--r--tasks/cdn.js35
-rw-r--r--tasks/docsite.js87
2 files changed, 87 insertions, 35 deletions
diff --git a/tasks/cdn.js b/tasks/cdn.js
index 73d7420..6816ebf 100644
--- a/tasks/cdn.js
+++ b/tasks/cdn.js
@@ -88,41 +88,6 @@ gulp.task('cdn-test:install-dependencies', function() {
}, [['web-component-tester#2.2.6']]);
});
-gulp.task('cdn:docsite:bower_components', ['cdn:stage-bower_components'], function() {
- gutil.log('Copying bower components from ' + stagingPath + ' to ' + docPath + '/bower_components');
- return gulp.src([stagingPath + '/**'])
- .pipe(gulp.dest(docPath + '/bower_components'));
-});
-
-config.components.forEach(function (n) {
- gulp.task('cdn:docsite:' + n, ['cdn:docsite:bower_components'], function(done) {
- var componentDoc = docPath + '/' + n;
- var componentOrg = stagingPath + '/' + n + '/demo/**';
- gutil.log('Generating site documentation from ' + componentOrg + ' into ' + componentDoc);
- fs.mkdirsSync(componentDoc);
- return gulp.src(componentOrg)
- // Remove bad tags
- .pipe(replace(/^.*<(!doctype|\/?html|\/?head|\/?body|meta|title).*>.*\n/img, ''))
- // Uncomment metainfo
- .pipe(replace(/^.*<!--[ \n]+([\s\S]*?title:[\s\S]*?)[ \n]+-->.*\n/img, '---\n$1\n---\n'))
- // Remove Analytics
- .pipe(replace(/^.*<script.*?ga\.js[\"'].*?<\/script>\s*?\n?/img, ''))
- // Adjust location of the current component in bower_components (..)
- .pipe(replace(/(src|href)=("|')\.\.(\/\w)/mg, '$1=$2../bower_components/' + n + '$3'))
- // Adjust location of dependencies in bower_components (../..)
- .pipe(replace(/(src|href)=("|')(.*?)\.\.\/\.\.\//mg, '$1=$2../bower_components/'))
- // Remove the section with table-of-contents
- .pipe(replace(/^.*<section>[\s\S]*?table-of-contents[\s\S]*?<\/section>.*\n/im, ''))
- // Add ids to headers, so as site configures permalinks
- .pipe(replace(/<h(\d+)>(.*)(<\/h\d+>)/img, function($0, $1, $2, $3){
- var id = $2.trim().toLowerCase().replace(/[^\w]+/g,'_');
- return '<h' + $1 + ' id="' + id + '">' + $2 + $3;
- }))
-
- .pipe(gulp.dest(componentDoc));
- });
-});
-
config.components.forEach(function (n) {
gulp.task('cdn-test:stage:' + n, ['cdn-test:clean', 'cdn-test:install-dependencies'], function(done) {
fs.mkdirsSync(testPath);
diff --git a/tasks/docsite.js b/tasks/docsite.js
new file mode 100644
index 0000000..e8bee7d
--- /dev/null
+++ b/tasks/docsite.js
@@ -0,0 +1,87 @@
+var bower = require('gulp-bower');
+var config = require('./config');
+var common = require('./common');
+var gulp = require('gulp');
+var fs = require('fs-extra');
+var replace = require('gulp-replace');
+var rsync = require('gulp-rsync');
+var gutil = require('gulp-util');
+var zip = require('gulp-zip');
+var args = require('yargs').argv;
+
+
+var stagingBasePath = config.paths.staging.cdn;
+var docPath = config.paths.staging.doc;
+var version = config.version;
+var host = config.cdnHost;
+var permalink = config.permalink;
+var stagingPath = stagingBasePath + '/' + version;
+
+gulp.task('cdn:docsite:bower_components', ['cdn:stage-bower_components'], function() {
+ gutil.log('Copying bower components from ' + stagingPath + ' to ' + docPath + '/bower_components');
+ return gulp.src([stagingPath + '/**'])
+ .pipe(gulp.dest(docPath + '/bower_components'));
+});
+
+var doctasks = [];
+config.components.forEach(function (n) {
+ var task = 'cdn:docsite:' + n;
+ doctasks.push(task);
+ gulp.task(task, ['cdn:docsite:bower_components'], function(done) {
+ var componentDoc = docPath + '/' + n;
+ var componentOrg = stagingPath + '/' + n + '/demo/**';
+ gutil.log('Generating site documentation from ' + componentOrg + ' into ' + componentDoc);
+ fs.mkdirsSync(componentDoc);
+ return gulp.src(componentOrg)
+ // Remove bad tags
+ .pipe(replace(/^.*<(!doctype|\/?html|\/?head|\/?body|meta|title).*>.*\n/img, ''))
+ // Uncomment metainfo
+ .pipe(replace(/^.*<!--[ \n]+([\s\S]*?title:[\s\S]*?)[ \n]+-->.*\n/img, '---\n$1\n---\n'))
+ // Remove Analytics
+ .pipe(replace(/^.*<script.*?ga\.js[\"'].*?<\/script>\s*?\n?/img, ''))
+ // Adjust location of the current component in bower_components (..)
+ .pipe(replace(/(src|href)=("|')\.\.(\/\w)/mg, '$1=$2../bower_components/' + n + '$3'))
+ // Adjust location of dependencies in bower_components (../..)
+ .pipe(replace(/(src|href)=("|')(.*?)\.\.\/\.\.\//mg, '$1=$2../bower_components/'))
+ // Remove the section with table-of-contents
+ .pipe(replace(/^.*<section>[\s\S]*?table-of-contents[\s\S]*?<\/section>.*\n/im, ''))
+ // Add ids to headers, so as site configures permalinks
+ .pipe(replace(/<h(\d+)>(.*)(<\/h\d+>)/img, function($0, $1, $2, $3){
+ var id = $2.trim().toLowerCase().replace(/[^\w]+/g,'_');
+ return '<h' + $1 + ' id="' + id + '">' + $2 + $3;
+ }))
+
+ .pipe(gulp.dest(componentDoc));
+ });
+});
+
+gulp.task('cdn:docsite:zip', doctasks, function() {
+ var src = docPath + '/../**/*';
+ var root = 'target';
+ var file = 'docsite.zip';
+ gutil.log("Creating docsite zip " + docPath + " -> " + root + '/' + file);
+ return gulp.src(src)
+ .pipe(zip(file))
+ .pipe(gulp.dest(root));
+});
+
+gulp.task('cdn:docsite:upload', ['cdn:docsite:zip'], function(done) {
+ common.checkArguments(['cdnUsername', 'cdnDestination']);
+ var root = 'target';
+ var file = 'docsite.zip';
+
+ gutil.log('Uploading docsite (scp): ' + root + '/' + file + ' -> ' + args.cdnUsername + '@' + host + ':' + args.cdnDestination + version);
+
+ require('scp2').scp(root + '/' + file, {
+ host: host,
+ username: args.cdnUsername,
+ privateKey: config.paths.privateKey(),
+ path: args.cdnDestination + version
+ }, function(err) {
+ done(err);
+ })
+});
+
+gulp.task('cdn:docsite', ['cdn:docsite:upload']);
+
+