1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
|
var bower = require('gulp-bower');
var config = require('./config');
var common = require('./common');
var gulp = require('gulp');
var fs = require('fs-extra');
var markdown = require('gulp-markdown');
var replace = require('gulp-replace');
var rsync = require('gulp-rsync');
var gutil = require('gulp-util');
var _ = require('lodash');
var args = require('yargs').argv;
var git = require('gulp-git');
var addsrc = require('gulp-add-src');
var stagingBasePath = config.paths.staging.cdn;
var version = config.version;
var host = config.cdnHost;
var permalink = config.permalink;
var stagingPath = stagingBasePath + '/' + version;
var testPath = process.cwd() + '/' + stagingPath + '/test';
gulp.task('clean:cdn', function() {
fs.removeSync(stagingBasePath);
});
gulp.task('cdn:stage-bower_components', function() {
return bower({
directory: stagingPath,
forceLatest: true,
cmd: 'install'
});
});
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('stage:cdn', [ 'clean:cdn', 'cdn:stage-bower_components', 'cdn:stage-vaadin-components' ]);
gulp.task('upload:cdn', ['stage:cdn'], function() {
common.checkArguments(['cdnUsername', 'cdnDestination']);
gutil.log('Uploading to cdn (rsync): ' + stagingPath + ' -> '+ args.cdnUsername + '@' + host + ':' + args.cdnDestination + version);
return gulp.src(stagingPath)
.pipe(rsync({
username: args.cdnUsername,
hostname: host,
root: stagingPath,
emptyDirectories: false,
recursive: true,
clean: true,
silent: true,
destination: args.cdnDestination + version
}));
});
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();
});
} else {
done();
}
});
gulp.task('cdn-test:clean', function() {
fs.removeSync(stagingPath + '/test');
});
gulp.task('cdn-test:install-dependencies', function() {
return bower({
directory: stagingPath,
cmd: 'install'
}, [['web-component-tester#2.2.6']]);
});
config.components.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)=("|')(.*?)(web-component-tester)\//mg, '$1=$2../../web-component-tester/'))
.pipe(gulp.dest(testPath + '/' + n + '/test/'));
done();
});
});
});
gulp.task('cdn-test:stage', _.map(config.components, function (n) {
return 'cdn-test:stage:' + n;
}));
gulp.task('verify:cdn', ['cdn-test:stage'], function(done) {
if(args.autoRevert) {
common.checkArguments(['cdnUsername', 'cdnDestination']);
}
// use unique browser combination because bower,cdn,zip verifications are run
// at the same time and TeamCity test results will get mixed up if same browsers are used.
common.testSauce(
['target/cdn/' + version + '/test/**/index.html'],
['Windows 7/firefox@36'],
'vaadin-components / cdn.vaadin.com / ' + version,
function(err) {
common.autoRevert(err, function() {
gutil.log('Deleting folder ' + args.cdnDestination + version);
require('node-ssh-exec')({
host: host,
username: args.cdnUsername,
privateKey: config.paths.privateKey()
}, 'rm -rf ' + args.cdnDestination + version, function (error, response) {
if (error) {
throw error;
}
gutil.log(response);
done(err);
});
}, done)});
});
|