[gulp] add publish task
This commit is contained in:
34
gulpfile.js
34
gulpfile.js
@@ -5,6 +5,9 @@ const gulpClean = require('gulp-clean');
|
||||
const Config = require('./config.json');
|
||||
const packageInfo = require('./package.json');
|
||||
const {Sdk, Haxe, Project, FlashPlayer} = require('gulp-haxetool');
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const through = require('through2');
|
||||
const dateformat = require('dateformat');
|
||||
const argv = require('yargs').argv;
|
||||
|
||||
@@ -27,7 +30,7 @@ exports.generate = function generate() {
|
||||
});
|
||||
};
|
||||
|
||||
exports.levels = function () {
|
||||
exports.levels = function levels() {
|
||||
return gulp.src("./src/common/level/*").pipe(foreach(function (stream, file) {
|
||||
const type = file.path.substr(file.path.lastIndexOf("/") + 1);
|
||||
gulp.src("./src/common/level/" + type + "/*").pipe(foreach(function (stream, file) {
|
||||
@@ -155,6 +158,33 @@ const server = new Project(
|
||||
module.exports.generate
|
||||
).bind(module, gulp);
|
||||
|
||||
/**
|
||||
* publish
|
||||
*/
|
||||
exports.publish = function publish() {
|
||||
const packages = [];
|
||||
return gulp.src('target/client/@(android|archive|debian)/*')
|
||||
.pipe(through.obj(function (file, enc, cb) {
|
||||
const path = file.path.replace(file.base + '/', '');
|
||||
packages.push({
|
||||
type: path.split('/').shift(),
|
||||
path: path,
|
||||
filename: path.split('/').pop(),
|
||||
url: `${Config.PublishUrl}/${path}`,
|
||||
});
|
||||
this.push(file);
|
||||
cb(null);
|
||||
}))
|
||||
.pipe(gulp.dest(Config.PublishDir))
|
||||
.on('end', function () {
|
||||
fs.writeFileSync(path.join(Config.PublishDir, 'packages.json'), JSON.stringify({
|
||||
'name': packageInfo.name,
|
||||
'version': packageInfo.version,
|
||||
'packages': packages,
|
||||
}, null, 4));
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* default
|
||||
*/
|
||||
@@ -166,6 +196,7 @@ module.exports.default = gulp.series(
|
||||
module.exports['client:html5:build'],
|
||||
module.exports['client:linux:build'],
|
||||
module.exports['client:linux:deb'],
|
||||
module.exports['client:linux:archive'],
|
||||
module.exports['client:android:build'],
|
||||
|
||||
module.exports['editor:flash:build'],
|
||||
@@ -173,4 +204,5 @@ module.exports.default = gulp.series(
|
||||
module.exports['editor:html5:build'],
|
||||
|
||||
module.exports['server:neko:build'],
|
||||
exports.publish,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user