summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSauli Tähkäpää <sauli@vaadin.com>2017-03-30 09:18:45 +0300
committerSauli Tähkäpää <sauli@vaadin.com>2017-03-30 09:18:45 +0300
commit241f09c125631361f93c81e2f3744947f034749b (patch)
treeb1254c0d1511345652a5c83be10d98dea64e3113
parent1f264fc17b1232063a455174c3d8d40aaad2f203 (diff)
parentb9793d789cb238af598c930d1620ef9748d9b0ec (diff)
downloadvaadin-core-241f09c125631361f93c81e2f3744947f034749b.tar.gz
vaadin-core-241f09c125631361f93c81e2f3744947f034749b.zip
Merge branch 'new-deployment'
-rw-r--r--gulpfile.js3
-rw-r--r--package.json6
-rw-r--r--tasks/cdn.js57
3 files changed, 61 insertions, 5 deletions
diff --git a/gulpfile.js b/gulpfile.js
index 312593b..9a87eff 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -2,7 +2,6 @@
var gulp = require('gulp');
require('require-dir')('./tasks');
var args = require('yargs').argv;
-var git = require('gulp-git');
gulp.task('default', function() {
console.log('\n Use:\n gulp <stage|deploy[:cdn]>|<zip>\n');
@@ -10,4 +9,4 @@ gulp.task('default', function() {
gulp.task('clean', ['clean:cdn', 'clean:zip']);
-gulp.task('deploy', ['deploy:cdn']);
+gulp.task('deploy', ['deploy:cdn']); \ No newline at end of file
diff --git a/package.json b/package.json
index d874638..8f14e6d 100644
--- a/package.json
+++ b/package.json
@@ -6,10 +6,10 @@
"license": "Apache-2.0",
"dependencies": {
"bower": "latest",
- "fs-extra": "latest",
- "gulp": "latest",
+ "fs-extra": "2.0.x",
+ "gulp": "^3.9.1",
"gulp-add-src": "latest",
- "gulp-git": "latest",
+ "gulp-git": "1.14.x",
"gulp-json-editor": "latest",
"gulp-markdown": "^1.0.0",
"gulp-modify": "^0.1.1",
diff --git a/tasks/cdn.js b/tasks/cdn.js
index a2bb3a7..237a6a2 100644
--- a/tasks/cdn.js
+++ b/tasks/cdn.js
@@ -8,6 +8,7 @@ var modify = require('gulp-modify');
var rsync = require('gulp-rsync');
var gutil = require('gulp-util');
var args = require('yargs').argv;
+var git = require('gulp-git');
var stagingBasePath = config.paths.staging.cdn;
var version = config.version;
@@ -91,3 +92,59 @@ gulp.task('deploy:cdn', ['upload:cdn'], function(done) {
done();
}
});
+
+/* Above are the old tasks to publish the vaadin-core-elements package, below the tasks to publish a single element from a specific tag/branch. Sorry about the poor naming :-) */
+
+gulp.task('cdn:arguments', function(done) {
+ common.checkArguments(['element', 'tag']);
+ args.folder = args.tag.replace(/^v/g, '');
+ stagingPath = path.join(process.cwd(), stagingBasePath, args.element, args.folder);
+ done();
+});
+
+gulp.task('cdn:clone', ['clean:cdn', 'cdn:arguments'], function(done) {
+ git.clone('https://github.com/vaadin/' + args.element, {args: '-b ' + args.tag + ' ./target/cdn/' + args.element + '/' + args.folder }, function (err) {
+ if (err) throw err;
+ done();
+ });
+});
+
+gulp.task('cdn:install', ['cdn:arguments', 'cdn:clone'], function() {
+ return bower({
+ cwd: stagingPath,
+ forceLatest: true,
+ cmd: 'install'
+ });
+});
+
+gulp.task('cdn:stage', ['cdn:arguments', 'cdn:install'], function() {
+ return gulp.src([stagingPath + '/**/*.html', '!**/bower_components/**'])
+ .pipe(modify({
+ fileModifier: function(file, contents) {
+ // magic regex trying to change import paths from:
+ // ../foo/foo.html to bower_components/foo/foo.html
+ // ../../foo/foo.html to ../bower_components/foo/foo.html
+ // ../my-element.html stays as it is.
+ contents = contents.replace(new RegExp(/([href|src].+)((\.\.\/)((?!bower_components|\.\.).+\/.+))/g), '$1bower_components/$4');
+ return contents;
+ }
+ }))
+ .pipe(gulp.dest(stagingPath));
+});
+
+gulp.task('cdn:upload', ['cdn:stage'], function() {
+ common.checkArguments(['cdnUsername', 'cdnDestination']);
+ var destination = path.join(args.cdnDestination, args.element, args.folder);
+ gutil.log('Uploading to cdn (rsync): ' + stagingPath + ' -> ' + args.cdnUsername + '@' + host + ':' + destination);
+ return gulp.src(stagingPath)
+ .pipe(rsync({
+ username: args.cdnUsername,
+ hostname: host,
+ root: stagingPath,
+ emptyDirectories: false,
+ recursive: true,
+ clean: true,
+ silent: true,
+ destination: destination
+ }));
+});