diff options
Diffstat (limited to 'tasks')
-rw-r--r-- | tasks/cdn.js | 43 | ||||
-rw-r--r-- | tasks/common.js | 11 | ||||
-rw-r--r-- | tasks/config.js | 2 | ||||
-rw-r--r-- | tasks/docsite.js | 20 | ||||
-rw-r--r-- | tasks/zip.js | 65 |
5 files changed, 73 insertions, 68 deletions
diff --git a/tasks/cdn.js b/tasks/cdn.js index d1a8526..9ff994a 100644 --- a/tasks/cdn.js +++ b/tasks/cdn.js @@ -5,6 +5,7 @@ var gulp = require('gulp'); var fs = require('fs-extra'); var markdown = require('gulp-markdown'); var replace = require('gulp-replace'); +var modify = require('gulp-modify'); var rsync = require('gulp-rsync'); var gutil = require('gulp-util'); var _ = require('lodash'); @@ -31,14 +32,22 @@ gulp.task('cdn:stage-bower_components', function() { }); }); -gulp.task('cdn:stage-vaadin-components', function() { - return gulp.src(['LICENSE.html', 'ga.js', 'vaadin-components.html', 'demo/*', 'apidoc/*'], {base:"."}) - .pipe(replace('https://cdn.vaadin.com/vaadin-components/latest/', '../../')) - .pipe(addsrc('README.md')) - .pipe(gulp.dest(stagingPath + "/vaadin-components")); +gulp.task('cdn:stage-vaadin-elements', function() { + return gulp.src(['LICENSE.html', 'README.md', 'ga.js', 'vaadin-elements.html', 'demo/*', 'apidoc/*'], {base:"."}) + .pipe(modify({ + fileModifier: function(file, contents) { + if (/README.md/.test(file.path)) { + contents = contents.replace(/\/latest\//mg, '/' + version + '/') + } else { + contents.replace('https://cdn.vaadin.com/vaadin-elements/latest/', '../../'); + } + return contents; + } + })) + .pipe(gulp.dest(stagingPath + "/vaadin-elements")); }); -gulp.task('stage:cdn', [ 'clean:cdn', 'cdn:stage-bower_components', 'cdn:stage-vaadin-components' ]); +gulp.task('stage:cdn', [ 'clean:cdn', 'cdn:stage-bower_components', 'cdn:stage-vaadin-elements' ]); gulp.task('upload:cdn', ['stage:cdn'], function() { common.checkArguments(['cdnUsername', 'cdnDestination']); @@ -60,17 +69,7 @@ gulp.task('deploy:cdn', ['upload:cdn'], function(done) { if (permalink) { var cmd = 'rm -f ' + args.cdnDestination + permalink + '; ln -s ' + version + ' ' + args.cdnDestination + permalink + '; ls -l ' + args.cdnDestination; gutil.log('Deploying CDN : ssh ' + args.cdnUsername + '@' + host + ' ' + cmd); - require('node-ssh-exec')({ - host: host, - username: args.cdnUsername, - privateKey: config.paths.privateKey() - }, cmd, function (error, response) { - if (error) { - throw error; - } - gutil.log(response); - done(); - }); + common.ssh(args.cdnUsername, host, cmd, done); } else { done(); } @@ -87,13 +86,13 @@ gulp.task('cdn-test:install-dependencies', function() { }, [['web-component-tester#2.2.6']]); }); -config.components.forEach(function (n) { +config.elements.forEach(function (n) { gulp.task('cdn-test:stage:' + n, ['cdn-test:clean', 'cdn-test:install-dependencies'], function(done) { fs.mkdirsSync(testPath); return git.clone('https://github.com/vaadin/' + n, {cwd: testPath}, function (err) { gulp.src(testPath + '/' + n + '/test/**') - .pipe(replace(/(src|href)=("|')(.*?)\.\.\/\.\.\/(bower_components|node_modules)\/(.*?)\//mg, '$1=$2https://cdn.vaadin.com/vaadin-components/'+ version + '/$5/')) - .pipe(replace(/(src|href)=("|')(.*?)\.\.\//mg, '$1=$2https://cdn.vaadin.com/vaadin-components/'+ version +'/' + n + '/')) + .pipe(replace(/(src|href)=("|')(.*?)\.\.\/\.\.\/(bower_components|node_modules)\/(.*?)\//mg, '$1=$2https://cdn.vaadin.com/vaadin-elements/'+ version + '/$5/')) + .pipe(replace(/(src|href)=("|')(.*?)\.\.\//mg, '$1=$2https://cdn.vaadin.com/vaadin-elements/'+ version +'/' + n + '/')) .pipe(replace(/(src|href)=("|')(.*?)(web-component-tester)\//mg, '$1=$2../../web-component-tester/')) .pipe(gulp.dest(testPath + '/' + n + '/test/')); done(); @@ -101,7 +100,7 @@ config.components.forEach(function (n) { }); }); -gulp.task('cdn-test:stage', _.map(config.components, function (n) { +gulp.task('cdn-test:stage', _.map(config.elements, function (n) { return 'cdn-test:stage:' + n; })); @@ -115,7 +114,7 @@ gulp.task('verify:cdn', ['cdn-test:stage'], function(done) { common.testSauce( ['target/cdn/' + version + '/test/**/index.html'], ['Windows 7/firefox@36'], - 'vaadin-components / cdn.vaadin.com / ' + version, + 'vaadin-elements / cdn.vaadin.com / ' + version, function(err) { common.autoRevert(err, function() { gutil.log('Deleting folder ' + args.cdnDestination + version); diff --git a/tasks/common.js b/tasks/common.js index d4ba658..316d245 100644 --- a/tasks/common.js +++ b/tasks/common.js @@ -3,6 +3,7 @@ var chalk = require('chalk'); var wct = require('web-component-tester').test; var _ = require('lodash'); var gutil = require('gulp-util'); +var config = require('./config'); function cleanDone(done) { return function(error) { @@ -40,9 +41,19 @@ function test(options, done) { wct(options, cleanDone(done)); } +function ssh(user, host, command, done) { + gutil.log('SSH: ' + host + ' -> ' + command); + require('node-ssh-exec')({ + host: host, + username: user, + privateKey: config.paths.privateKey() + }, command, done); +} + module.exports = { localAddress: localAddress, test: test, + ssh: ssh, checkArguments: checkArguments, testSauce: function(suites, browsers, build, done) { diff --git a/tasks/config.js b/tasks/config.js index 83560f0..3b618ea 100644 --- a/tasks/config.js +++ b/tasks/config.js @@ -4,7 +4,7 @@ var fs = require('fs'); var userhome = process.env.HOME || process.env.HOMEPATH || process.env.USERPROFILE; module.exports = { - components: ['vaadin-grid'], + elements: ['vaadin-grid'], version: args.version || 'master', permalink: args.version ? 'latest' : '', toolsHost: args.toolsHostname || 'tools.vaadin.com', diff --git a/tasks/docsite.js b/tasks/docsite.js index b5f9cad..2526f8d 100644 --- a/tasks/docsite.js +++ b/tasks/docsite.js @@ -41,22 +41,22 @@ gulp.task('cdn:docsite:bower_components', ['cdn:stage-bower_components'], functi .pipe(gulp.dest(docPath + '/bower_components')); }); -gulp.task('cdn:docsite:components', function() { +gulp.task('cdn:docsite:elements', function() { return gulp.src('doc/*') .pipe(gulp.dest(docPath)); }); -var doctasks = ['cdn:docsite:components']; -config.components.forEach(function (n) { +var doctasks = ['cdn:docsite:elements']; +config.elements.forEach(function (n) { var task = 'cdn:docsite:' + n; doctasks.push(task); gulp.task(task, ['cdn:docsite:bower_components'], function(done) { - var componentDocsite = docPath + '/' + n; - var componentDemo = stagingPath + '/' + n + '/demo/**'; + var elementDocsite = docPath + '/' + n; + var elementDemo = stagingPath + '/' + n + '/demo/**'; - gutil.log('Generating site documentation from ' + componentDemo + ' into ' + componentDocsite); - fs.mkdirsSync(componentDocsite); - return gulp.src([componentDemo, '!**/*-embed.html']) + gutil.log('Generating site documentation from ' + elementDemo + ' into ' + elementDocsite); + fs.mkdirsSync(elementDocsite); + return gulp.src([elementDemo, '!**/*-embed.html']) // Remove bad tags .pipe(replace(/^.*<(!doctype|\/?html|\/?head|\/?body|meta|title).*>.*\n/img, '')) // Uncomment metainfo, and enclose all the example in {% raw %} ... {% endraw %} to avoid liquid conflicts @@ -78,7 +78,7 @@ config.components.forEach(function (n) { // Remove webcomponents polyfill since it's added at top of the site .pipe(replace(/^.*<script.*?\/webcomponents.*\.js[\"'].*?<\/script>\s*?\n?/img, '')) // embed files are displayed as iframe, we don't remove above fragments like body or polyfill - .pipe(addsrc(componentDemo + '/*-embed.html')) + .pipe(addsrc(elementDemo + '/*-embed.html')) // Remove Analytics .pipe(replace(/^.*<script.*?ga\.js[\"'].*?<\/script>\s*?\n?/img, '')) // Adjust bowerComponents variable in common.html @@ -91,7 +91,7 @@ config.components.forEach(function (n) { .pipe(replace(/^.*<link.*demo.css.*\n/im, '')) // Remove table of contents .pipe(replace(/^.*table-of-contents.html.*\n/im, '')) - .pipe(gulp.dest(componentDocsite)); + .pipe(gulp.dest(elementDocsite)); }); }); diff --git a/tasks/zip.js b/tasks/zip.js index f649d98..2900275 100644 --- a/tasks/zip.js +++ b/tasks/zip.js @@ -14,10 +14,10 @@ var zip = require('gulp-zip'); var stagingPath = config.paths.staging.zip; var version = config.version; var host = config.zipHost; -var filename = 'vaadin-components-' + version + '.zip'; +var user = args.zipUsername; +var filename = 'vaadin-elements-' + version + '.zip'; var majorMinorVersion = version.replace(/(\d+\.\d+)(\.|-)(.*)/, '$1'); - gulp.task('clean:zip', function() { fs.removeSync(stagingPath); }); @@ -28,44 +28,40 @@ gulp.task('stage:zip', ['clean:zip', 'stage:cdn'], function() { .pipe(gulp.dest(stagingPath)); }); -gulp.task('zip:upload', ['stage:zip'], function(done) { +function computeDestination() { common.checkArguments(['zipUsername', 'zipDestination']); - var path = args.zipDestination + majorMinorVersion + '/' + version + '/' + filename; - - gutil.log('Uploading zip package (scp): ' + stagingPath + '/' + filename + ' -> ' + args.zipUsername + '@' + host + ':' + path); + var path = majorMinorVersion != version ? majorMinorVersion + '/' + version : version; + path = args.zipDestination + path + '/' + filename; + return path; +} - require('scp2').scp(stagingPath + '/' + filename, { +gulp.task('zip:upload', ['stage:zip'], function(done) { + done(); + return; + var src = stagingPath + '/' + filename; + var dst = computeDestination(); + gutil.log('Uploading zip package (scp): ' + src + ' -> ' + user + '@' + host + ':' + dst); + require('scp2').scp(src, { host: host, - username: args.zipUsername, + username: user, privateKey: config.paths.privateKey(), - path: path + path: dst }, function(err) { done(err); }) }); -function ssh(command, done) { - gutil.log('SSH: ' + host + ' -> ' + command); - - require('node-ssh-exec')({ - host: host, - username: args.zipUsername, - privateKey: config.paths.privateKey() - }, command, - function (err) { - done(err); - }); -} - gulp.task('zip:update-references', ['zip:upload'], function(done) { - common.checkArguments(['zipUsername', 'zipDestination']); - + var dst = computeDestination(); + var latest = '/var/www/vaadin/download/elements/latest/vaadin-elements-latest.zip'; + var cmd = 'rm -f ' + latest + '; ln -s ' + dst + ' ' + latest; + common.ssh(user, host, cmd); if(args.release) { - ssh("sed -i '1i components/" + majorMinorVersion + '/' + version + "' " + args.zipDestination + 'VERSIONS', done); + common.ssh(user, host, "sed -i '1i elements/" + majorMinorVersion + '/' + version + "' " + args.zipDestination + 'VERSIONS', done); } else if(args.preRelease) { - ssh("sed -i '1i components/" + majorMinorVersion + '/' + version + "' " + args.zipDestination + 'PRERELEASES', done); + common.ssh(user, host, "sed -i '1i elements/" + majorMinorVersion + '/' + version + "' " + args.zipDestination + 'PRERELEASES', done); } else { - ssh('echo components/' + majorMinorVersion + '/' + version + ' > ' + args.zipDestination + 'SNAPSHOT', done); + common.ssh(user, host, 'echo elements/' + majorMinorVersion + '/' + version + ' > ' + args.zipDestination + 'SNAPSHOT', done); } }); @@ -76,7 +72,7 @@ gulp.task('zip-test:clean', function() { }); gulp.task('zip-test:download', ['zip-test:clean'], function() { - var url = args.zipUrl || 'https://vaadin.com/download/components'; + var url = args.zipUrl || 'https://vaadin.com/download/elements'; return download(url + '/' + majorMinorVersion +'/' + version + '/' + filename) .pipe(gulp.dest(stagingPath + '/test')); }); @@ -97,9 +93,9 @@ gulp.task('zip-test:install-wct', ['zip-test:download'], function() { // TODO: Haven't been fixed for the new project structure. Once the tests are in use, // apply similar changes as in cdn.js -config.components.forEach(function (n) { +config.elements.forEach(function (n) { gulp.task('zip-test:stage:' + n, ['zip-test:download'], function() { - return gulp.src('vaadin-components/' + n + '/test/**/*') + return gulp.src('vaadin-elements/' + n + '/test/**/*') .pipe(replace(/(src|href)=("|')(.*?)\.\.\/\.\.\/\.\.\/\.\.\/(bower_components|node_modules)\//mg, '$1=$2../../$3')) .pipe(replace(/(src|href)=("|')(.*?)\.\.\/\.\.\/\.\.\/(bower_components|node_modules)\//mg, '$1=$2../../$3')) .pipe(replace(/(src|href)=("|')(.*?)\.\.\/(vaadin-)/mg, '$1=$2../../' + n + '/$3$4')) @@ -107,7 +103,7 @@ config.components.forEach(function (n) { }); }); -gulp.task('zip-test:stage', _.map(config.components, function(n) { +gulp.task('zip-test:stage', _.map(config.elements, function(n) { return 'zip-test:stage:'+n; })); @@ -119,7 +115,7 @@ gulp.task('verify:zip', ['zip-test:unzip', 'zip-test:install-wct', 'zip-test:sta common.testSauce( ['target/zip/test/test/**/index.html'], ['Windows 7/internet explorer@11'], - 'vaadin-components / vaadin.com / ' + version, + 'vaadin-elements / vaadin.com / ' + version, function(err) { common.autoRevert(err, function() { var path = args.zipDestination + majorMinorVersion + '/' + version; @@ -127,12 +123,11 @@ gulp.task('verify:zip', ['zip-test:unzip', 'zip-test:install-wct', 'zip-test:sta gutil.log('Deleting package ' + path); // remove the version from VERSIONS - ssh('grep -v "components/' + majorMinorVersion + '/' + version + '" ' + + common.ssh(user, host, 'grep -v "elements/' + majorMinorVersion + '/' + version + '" ' + args.zipDestination + 'VERSIONS > temp && mv temp ' + args.zipDestination + 'VERSIONS', function(error) { if(error) done(error); - // remove the package - ssh('rm -rf ' + path, done); + common.ssh(user, host, 'rm -rf ' + path, done); }); }, done); }); |