2016-01-31 08:30:14 -05:00
|
|
|
/*
|
|
|
|
* Paper.js - The Swiss Army Knife of Vector Graphics Scripting.
|
|
|
|
* http://paperjs.org/
|
|
|
|
*
|
2020-05-23 16:24:42 -04:00
|
|
|
* Copyright (c) 2011 - 2020, Jürg Lehni & Jonathan Puckey
|
|
|
|
* http://juerglehni.com/ & https://puckey.studio/
|
2016-01-31 08:30:14 -05:00
|
|
|
*
|
|
|
|
* Distributed under the MIT license. See LICENSE file for details.
|
|
|
|
*
|
|
|
|
* All rights reserved.
|
|
|
|
*/
|
|
|
|
|
|
|
|
var gulp = require('gulp'),
|
2017-04-20 06:50:09 -04:00
|
|
|
path = require('path'),
|
|
|
|
fs = require('fs'),
|
|
|
|
del = require('del'),
|
2016-07-09 13:48:02 -04:00
|
|
|
run = require('run-sequence'),
|
2017-04-20 06:50:09 -04:00
|
|
|
git = require('gulp-git-streamed'),
|
2016-01-31 08:30:14 -05:00
|
|
|
shell = require('gulp-shell'),
|
2017-04-20 06:50:09 -04:00
|
|
|
merge = require('merge-stream'),
|
|
|
|
rename = require('gulp-rename'),
|
|
|
|
jsonEditor = require('gulp-json-editor'),
|
2016-07-09 14:56:58 -04:00
|
|
|
options = require('../utils/options.js');
|
2016-01-31 08:30:14 -05:00
|
|
|
|
2017-04-19 16:07:46 -04:00
|
|
|
var packages = ['paper-jsdom', 'paper-jsdom-canvas'],
|
2017-04-20 06:50:09 -04:00
|
|
|
sitePath = path.resolve('../paperjs.org'),
|
|
|
|
referencePath = sitePath + '/content/08-Reference',
|
|
|
|
downloadPath = sitePath + '/content/11-Download',
|
2017-04-20 12:16:21 -04:00
|
|
|
assetPath = sitePath + '/assets/js',
|
2017-04-20 06:50:09 -04:00
|
|
|
releaseMessage = null,
|
2017-04-19 16:07:46 -04:00
|
|
|
jsonOptions = {
|
|
|
|
end_with_newline: true
|
|
|
|
};
|
2017-04-19 13:53:39 -04:00
|
|
|
|
2019-06-22 07:14:16 -04:00
|
|
|
gulp.task('publish', function(callback) {
|
2016-07-09 13:48:02 -04:00
|
|
|
if (options.branch !== 'develop') {
|
|
|
|
throw new Error('Publishing is only allowed on the develop branch.');
|
|
|
|
}
|
2017-04-22 14:01:34 -04:00
|
|
|
// publish:website comes before publish:release, so paperjs.zip file is gone
|
|
|
|
// before npm publish:
|
2019-06-22 08:40:54 -04:00
|
|
|
run(
|
2018-12-03 08:29:13 -05:00
|
|
|
'publish:json',
|
|
|
|
'publish:dist',
|
2019-06-05 18:15:23 -04:00
|
|
|
'publish:packages',
|
2016-07-09 13:48:02 -04:00
|
|
|
'publish:commit',
|
2017-04-20 06:50:09 -04:00
|
|
|
'publish:website',
|
2017-04-22 14:01:34 -04:00
|
|
|
'publish:release',
|
2019-06-22 07:14:16 -04:00
|
|
|
'publish:load',
|
|
|
|
callback
|
2016-07-09 13:48:02 -04:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
2016-07-09 14:56:58 -04:00
|
|
|
gulp.task('publish:version', function() {
|
2016-07-09 17:49:11 -04:00
|
|
|
// Reset the version value since we're executing this on the develop branch,
|
2016-07-09 15:20:47 -04:00
|
|
|
// but we don't wan the published version suffixed with '-develop'.
|
2016-07-09 14:56:58 -04:00
|
|
|
options.resetVersion();
|
2017-04-20 06:50:09 -04:00
|
|
|
releaseMessage = 'Release version ' + options.version;
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('publish:json', ['publish:version'], function() {
|
2017-04-19 13:53:39 -04:00
|
|
|
return gulp.src(['package.json'])
|
|
|
|
.pipe(jsonEditor({
|
|
|
|
version: options.version
|
|
|
|
}, jsonOptions))
|
2016-07-09 13:48:02 -04:00
|
|
|
.pipe(gulp.dest('.'));
|
2016-01-31 08:30:14 -05:00
|
|
|
});
|
|
|
|
|
2017-04-20 06:50:09 -04:00
|
|
|
gulp.task('publish:dist', ['zip']);
|
|
|
|
|
|
|
|
gulp.task('publish:commit', ['publish:version'], function() {
|
|
|
|
return gulp.src('.')
|
|
|
|
.pipe(git.checkout('develop'))
|
|
|
|
.pipe(git.add())
|
|
|
|
.pipe(git.commit(releaseMessage))
|
|
|
|
.pipe(git.tag('v' + options.version, releaseMessage));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('publish:release', function() {
|
|
|
|
return gulp.src('.')
|
|
|
|
.pipe(git.checkout('master'))
|
|
|
|
.pipe(git.merge('develop', { args: '-X theirs' }))
|
|
|
|
.pipe(git.push('origin', ['master', 'develop'], { args: '--tags' }))
|
|
|
|
.pipe(shell('npm publish'));
|
|
|
|
});
|
|
|
|
|
2019-06-22 08:40:54 -04:00
|
|
|
gulp.task('publish:packages',
|
|
|
|
packages.map(function(name) {
|
2019-06-22 07:14:16 -04:00
|
|
|
return 'publish:packages:' + name;
|
|
|
|
})
|
2019-06-22 08:40:54 -04:00
|
|
|
);
|
2017-04-19 16:07:46 -04:00
|
|
|
|
|
|
|
packages.forEach(function(name) {
|
2017-04-20 06:50:09 -04:00
|
|
|
gulp.task('publish:packages:' + name, ['publish:version'], function() {
|
|
|
|
var path = 'packages/' + name,
|
2017-04-19 16:07:46 -04:00
|
|
|
opts = { cwd: path };
|
2018-10-17 10:49:04 -04:00
|
|
|
return gulp.src(['package.json'], opts)
|
2017-04-19 16:07:46 -04:00
|
|
|
.pipe(jsonEditor({
|
|
|
|
version: options.version,
|
|
|
|
dependencies: {
|
|
|
|
paper: options.version
|
|
|
|
}
|
|
|
|
}, jsonOptions))
|
|
|
|
.pipe(gulp.dest(path))
|
|
|
|
.pipe(git.add(opts))
|
2017-04-20 06:50:09 -04:00
|
|
|
.pipe(git.commit(releaseMessage, opts))
|
|
|
|
.pipe(git.tag('v' + options.version, releaseMessage, opts))
|
2017-04-19 16:07:46 -04:00
|
|
|
.pipe(git.push('origin', 'master', { args: '--tags', cwd: path }))
|
|
|
|
.pipe(shell('npm publish', opts));
|
|
|
|
});
|
2017-04-19 13:53:39 -04:00
|
|
|
});
|
|
|
|
|
2019-06-22 07:14:16 -04:00
|
|
|
gulp.task('publish:website', function(callback) {
|
2017-04-20 06:50:09 -04:00
|
|
|
if (fs.lstatSync(sitePath).isDirectory()) {
|
2019-06-22 08:40:54 -04:00
|
|
|
run(
|
2017-04-20 06:50:09 -04:00
|
|
|
'publish:website:build',
|
2019-06-22 07:14:16 -04:00
|
|
|
'publish:website:push',
|
|
|
|
callback
|
2017-04-20 06:50:09 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2017-04-21 06:54:40 -04:00
|
|
|
gulp.task('publish:website:build', [
|
|
|
|
'publish:website:json', 'publish:website:docs',
|
|
|
|
'publish:website:zip', 'publish:website:assets'
|
|
|
|
]);
|
|
|
|
|
|
|
|
gulp.task('publish:website:json', ['publish:version'], function() {
|
|
|
|
return gulp.src([sitePath + '/package.json'])
|
|
|
|
.pipe(jsonEditor({
|
|
|
|
version: options.version
|
|
|
|
}, jsonOptions))
|
|
|
|
.pipe(gulp.dest(sitePath));
|
|
|
|
});
|
2016-07-09 13:48:02 -04:00
|
|
|
|
2017-04-20 06:50:09 -04:00
|
|
|
gulp.task('publish:website:docs:clean', function() {
|
|
|
|
return del([ referencePath + '/*' ], { force: true });
|
2016-07-09 13:48:02 -04:00
|
|
|
});
|
|
|
|
|
2017-04-20 06:50:09 -04:00
|
|
|
gulp.task('publish:website:docs',
|
|
|
|
['publish:version', 'publish:website:docs:clean', 'docs:server'],
|
|
|
|
function() {
|
|
|
|
return gulp.src('dist/serverdocs/**')
|
|
|
|
.pipe(gulp.dest(referencePath));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('publish:website:zip', ['publish:version'], function() {
|
|
|
|
return gulp.src('dist/paperjs.zip')
|
|
|
|
.pipe(rename({ suffix: '-v' + options.version }))
|
|
|
|
.pipe(gulp.dest(downloadPath));
|
|
|
|
});
|
|
|
|
|
2017-04-20 13:51:45 -04:00
|
|
|
gulp.task('publish:website:assets', function() {
|
|
|
|
// Always delete the old asset first, in case it's a symlink which Gulp
|
|
|
|
// doesn't handle well.
|
|
|
|
fs.unlinkSync(assetPath + '/paper.js');
|
2017-04-20 12:16:21 -04:00
|
|
|
return gulp.src('dist/paper-full.js')
|
|
|
|
.pipe(rename({ basename: 'paper' }))
|
|
|
|
.pipe(gulp.dest(assetPath));
|
|
|
|
});
|
|
|
|
|
2017-04-20 06:50:09 -04:00
|
|
|
gulp.task('publish:website:push', ['publish:version'], function() {
|
|
|
|
var opts = { cwd: sitePath };
|
|
|
|
return gulp.src(sitePath)
|
|
|
|
.pipe(git.add(opts))
|
|
|
|
.pipe(git.commit(releaseMessage, opts))
|
|
|
|
.pipe(git.tag('v' + options.version, releaseMessage, opts))
|
|
|
|
.pipe(git.push('origin', 'master', { args: '--tags', cwd: sitePath }));
|
2016-01-31 08:30:14 -05:00
|
|
|
});
|
2016-07-09 13:48:02 -04:00
|
|
|
|
|
|
|
gulp.task('publish:load', ['load'], function() {
|
|
|
|
return gulp.src('dist')
|
2016-07-09 15:20:47 -04:00
|
|
|
.pipe(git.checkout('develop'))
|
2016-07-09 13:48:02 -04:00
|
|
|
.pipe(git.add())
|
2016-07-09 14:56:58 -04:00
|
|
|
.pipe(git.commit('Switch back to load.js versions on develop branch.'))
|
2016-07-09 13:48:02 -04:00
|
|
|
.pipe(git.push('origin', 'develop'));
|
|
|
|
});
|