1 Star 0 Fork 3.7K

茶花烙/O2OA

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
gulpfile.js 51.69 KB
一键复制 编辑 原始数据 按行查看 历史
tommy 提交于 2023-05-05 11:02 . 修改打包的json文件路径
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292
var gulp = require('gulp'),
gutil = require('gulp-util'),
del = require('del'),
fs = require("fs"),
minimist = require('minimist'),
targz = require('targz'),
slog = require('single-line-log').stdout,
dateFormat = require('dateformat'),
progress = require('progress-stream'),
request = require("request"),
//uglify = require('gulp-tm-uglify'),
uglify = require('gulp-uglify-es').default,
rename = require('gulp-rename'),
changed = require('gulp-changed'),
gulpif = require('gulp-if'),
http = require('http');
const ora = require('ora');
concat = require('gulp-concat');
var fg = require('fast-glob');
var logger = require('gulp-logger');
var assetRev = require('gulp-tm-asset-rev');
const os = require('os');
var through2 = require('through2');
var path = require('path');
//var sourceMap = require('gulp-sourcemaps');
var git = require('gulp-git');
//var downloadHost = "download.o2oa.net";
// var downloadHost = "release.o2oa.net";
// var protocol = "http";
// var commonUrl = "/build/commons.tar.gz";
// var jvmUrls = {
// "all": "/build/jvm.tar.gz",
// "linux": "/build/linux.tar.gz",
// "aix": "/build/aix.tar.gz",
// "arm": "/build/arm.tar.gz",
// "macos": "/build/macos.tar.gz",
// "risc": "/build/risc.tar.gz",
// "raspberrypi": "/build/raspberrypi.tar.gz",
// "windows": "/build/windows.tar.gz"
// };
var supportedLanguage = ["zh-cn", "en"];
var downloadHost = "git.o2oa.net";
var protocol = "https";
var commonUrl = "/o2oa/evn-o2server-commons/-/archive/7.3/evn-o2server-commons-7.3.tar.gz?path=commons";
var jvmUrls = {
"all": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm",
"linux_java11": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm/linux_java11",
"aix_java11": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm/aix_java11",
"arm_java11": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm/arm_java11",
"macos_java11": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm/macos_java11",
"risc_java11": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm/risc_java11",
"mips_java11": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm/mips_java11",
"raspi_java11": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm/raspi_java11",
"windows_java11": "/o2oa/evn-o2server-jvm/-/archive/master/evn-o2server-jvm-master.tar.gz?path=jvm/windows_java11"
};
var scripts = {
"all": ["o2server/*.sh", "o2server/*.jar", "o2server/*.html", "o2server/*.bat", "o2server/version.o2"],
"linux": ["o2server/*linux*", "o2server/*.jar", "o2server/*.html", "o2server/version.o2"],
"aix": ["o2server/*aix*", "o2server/*.jar", "o2server/*.html", "o2server/version.o2"],
"arm": ["o2server/*arm*", "o2server/*.jar", "o2server/*.html", "o2server/version.o2"],
"macos": ["o2server/*macos*", "o2server/*.jar", "o2server/*.html", "o2server/version.o2"],
"risc": ["o2server/*risc*", "o2server/*.jar", "o2server/*.html", "o2server/version.o2"],
"mips": ["o2server/*mips*", "o2server/*.jar", "o2server/*.html", "o2server/version.o2"],
"raspi": ["o2server/*raspi*", "o2server/*.jar", "o2server/*.html", "o2server/version.o2"],
"windows": ["o2server/*windows*", "o2server/*.jar", "o2server/*.html", "o2server/version.o2"]
};
var o_options = minimist(process.argv.slice(2), {//upload: local ftp or sftp
string: ["e", "lp", "w", "m", "d"]
});
var options = {};
options.ev = o_options.e || "all";
options.lp = o_options.lp || "zh-cn";
options.webSite = o_options.w || "https://www.o2oa.net";
options.mirrorSite = o_options.m || "http://mirror1.o2oa.net";
options.downloadSite = o_options.d || "https://download.o2oa.net";
var jvmUrl = jvmUrls[options.ev];
var scriptSource = scripts[options.ev];
function ProgressBar(description, bar_length){
this.description = description || 'Progress';
this.length = bar_length || 50;
this.render = function (opts){
var percent = (opts.completed / opts.total).toFixed(4);
var cell_num = Math.floor(percent * this.length);
var speed = "";
if (opts.time){
speed = (opts.completed/1024/1024)/(opts.time/1000);
speed = speed.toFixed(2);
speed = speed+"M/S";
}
var count = "";
if (opts.count){
count = "["+opts.count+"/"+opts.total+"]"
}
var cell = '';
for (var i=0;i<cell_num;i++) { cell += '>'; }
var empty = '';
for (var i=0;i<this.length-cell_num;i++) { empty += '='; }
if (opts.completed <= opts.total){
var d = new Date();
var cmdText = "["+dateFormat(d, "HH:MM:ss")+"]"+" "+this.description + ': ' + cell + empty + ' ' + (100*percent).toFixed(2) + '% '+speed+count;
slog(cmdText);
}
};
}
function downloadFile_progress(path, filename, headcb, progresscb, cb){
var dest = `o2server/${filename}`;
let stream = fs.createWriteStream(dest);
var options = { url:protocol+"://"+downloadHost+path };
var fileHost = downloadHost;
var filePath = path;
stream.on('finish', () => {
//gutil.log("download", ":", gutil.colors.green(filename), " completed!");
cb();
});
stream.on('error', (err) => {
gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), err);
});
var req = http.request({
host:fileHost,
path:filePath,
method:'HEAD'
},function (res){
if (res.statusCode == 200) {
res.setEncoding(null);
var time = 0;
var l = res.headers['content-length'];
var str = progress({
length: l,
time: 100 /* ms */
});
headcb(l);
str.on('progress', function(progress) {
if (pb){
progresscb(progress);
pb.render({ completed: currentLength, total: totalLength, time: time+=100 });
}
});
request.get(options).pipe(str).pipe(stream);
} else {
downloadFile(path, filename, headcb, progresscb, cb)
//gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), "statusCode:"+res.statusCode);
}
})
req.on('error', (e) => {
downloadFile(path, filename, headcb, progresscb, cb)
//gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), e);
});
req.end();
// }
//});
}
function downloadFile(path, filename, headcb, progresscb, cb){
var dest = `o2server/${filename}`;
const spinner = ora({
'prefixText': 'Downloading '+filename+' ...',
'spinner': {
interval: 80, // Optional
frames: ['','','','','','','','','','']
}
}).start();
let stream = fs.createWriteStream(dest);
var options = { url:protocol+"://"+downloadHost+path };
var fileHost = downloadHost;
var filePath = path;
stream.on('finish', () => {
//gutil.log("download", ":", gutil.colors.green(filename), " completed!");
spinner.stop();
spinner.succeed(filename + ' Downloaded!');
cb();
});
stream.on('error', (err) => {
gutil.log(gutil.colors.red("download error"), ":", gutil.colors.red(filename), err);
});
request.get(options).pipe(stream);
}
var commonsLength = 0;
var jvmLenght = 0;
var totalLength = 0;
var currentLength = 0;
var commonsCurrentLength = 0;
var jvmCurrentLength = 0;
var pb = null;
function initProgress(){
if (commonsLength && jvmLenght){
totalLength = +commonsLength + jvmLenght;
var t = (totalLength/1024/1024).toFixed(2);
pb = new ProgressBar('total: '+t+"M", 50);
}
}
function download_commons_and_jvm(cb){
gutil.log(gutil.colors.green("begin download commons and jvm"));
console.log(`---------------------------------------------------------------------
. Start to download the dependencies needed for compilation ...
---------------------------------------------------------------------`);
var downloader = new Promise((resolve, reject) => {
var commonLoaded = false;
var jvmLoaded = false;
downloadFile_progress(commonUrl, "commons_git.tar.gz", (length)=>{
commonsLength = +length;
initProgress();
}, (progress)=>{
commonsCurrentLength = progress.transferred;
currentLength = +commonsCurrentLength+jvmCurrentLength;
}, ()=>{
commonLoaded = true;
if (jvmLoaded && commonLoaded) resolve();
});
// var jvmName = jvmUrl.substr(jvmUrl.lastIndexOf("/"+1, jvmUrl.length));
// console.log(jvmName);
// console.log(jvmUrl);
downloadFile_progress(jvmUrl, "jvm_git.tar.gz", (length)=>{
jvmLenght = +length;
initProgress();
}, (progress)=>{
jvmCurrentLength = progress.transferred;
currentLength = +commonsCurrentLength+jvmCurrentLength;
}, ()=>{
jvmLoaded = true;
if (jvmLoaded && commonLoaded) resolve();
});
});
downloader.then(()=>{
//console.log();
gutil.log(gutil.colors.green("download commons and jvm completed"));
cb();
});
}
function decompress_commons_and_jvm(cb){
console.log(`---------------------------------------------------------------------
. Start to decompress the dependencies needed for compilation ...
---------------------------------------------------------------------`);
gutil.log(gutil.colors.green("begin decompress commons and jvm"));
var count =0;
var decompressor = new Promise((resolve, reject) => {
var commonUnziped = false;
var jvmUnziped = false;
targz.decompress({
src: 'o2server/commons_git.tar.gz',
dest: 'o2server/tmp',
tar: {map: function(header){
count++;
var d = new Date();
slog("["+dateFormat(d, "HH:MM:ss")+"] " + count +" "+ header.name+" ...");
//gutil.log(gutil.colors.cyan(header.name), gutil.colors.yellow("..."));
}}
}, function(err){
if(err) {
gutil.log(gutil.colors.red("decompress error"), ":", gutil.colors.red("common.tar.gz "), err);
} else {
commonUnziped = true;
if (jvmUnziped && commonUnziped) resolve();
}
});
targz.decompress({
src: 'o2server/jvm_git.tar.gz',
dest: 'o2server/tmp',
tar: {map: function(header){
count++;
var d = new Date();
slog("["+dateFormat(d, "HH:MM:ss")+"] " + count +" "+ header.name+" ...");
//slog(count +" "+ header.name+" ...");
//gutil.log(gutil.colors.cyan(header.name), gutil.colors.yellow("..."));
}}
}, function(err){
if(err) {
gutil.log(gutil.colors.red("decompress error"), ":", gutil.colors.red("jvm.tar.gz "), err);
} else {
jvmUnziped = true;
if (jvmUnziped && commonUnziped) resolve();
}
});
});
decompressor.then(()=>{
gutil.log(gutil.colors.green("decompress commons and jvm completed. " + count+" files"));
cb();
});
}
function move_commons(){
console.log(`---------------------------------------------------------------------
. move commons files to o2server/commons ...
---------------------------------------------------------------------`);
return gulp.src("o2server/tmp/evn-o2server-commons-7.3-commons/commons/**/*")
.pipe(gulp.dest("o2server/commons/"));
}
function move_jvm(){
console.log(`---------------------------------------------------------------------
. move jvm files to o2server/jvm ...
---------------------------------------------------------------------`);
var path;
if (options.ev=="all"){
path = "o2server/tmp/evn-o2server-jvm-master-jvm/jvm/**/*"
}else{
path = "o2server/tmp/evn-o2server-jvm-master-jvm-"+options.ev+"/jvm/**/*"
}
return gulp.src(path)
.pipe(gulp.dest("o2server/jvm/"));
}
async function clear_commons_git(cb) {
var dest = ['o2server/tmp/evn-o2server-commons-7.3-commons/', 'o2server/commons_git.tar.gz'];
await del(dest, {force: true});
cb();
}
async function clear_jvm_git(cb){
//var path;
// if (options.ev=="all"){
// path = "o2server/tmp/evn-o2server-jvm-master-jvm/"
// }else{
// path = "o2server/tmp/evn-o2server-jvm-master-jvm-"+options.ev+"/"
// }
await del(['o2server/tmp/', 'o2server/jvm_git.tar.gz'], { force: true });
cb();
}
var moduleFolder = [];
async function build_web_module() {
var dest = 'target/o2server/servers/webServer/';
var srcPath = 'o2web/source';
const fp = fs.promises;
return fp.readdir(srcPath).then((files)=>{
let statP = [];
files.forEach((file) => {
let p = path.resolve(srcPath, file)
statP.push(fp.stat(p).then((s)=>{
if (s.isDirectory()){
var pkgPath = path.resolve(srcPath, p, 'package.json');
if (fs.existsSync(pkgPath)){
var pkg = require(pkgPath);
if (pkg.scripts['o2-build']){
moduleFolder.push(file);
}
}
}
}));
});
const shelljs = require('shelljs');
return Promise.all(statP).then(()=>{
// var tasks = [];
moduleFolder.forEach((f)=>{
shelljs.config.verbose = true;
shelljs.exec('npm install && npm run o2-build', {cwd: path.resolve(srcPath, f)});
});
});
});
}
function build_web_minimize(cb) {
console.log(`---------------------------------------------------------------------
. Start compiling the web ...
---------------------------------------------------------------------`);
var dest = 'target/o2server/servers/webServer/';
var src_min = ['o2web/source/**/*.js', '!o2web/source/o2_core/o2.js', '!**/*.spec.js', '!**/test/**', '!o2web/source/o2_lib/**/*'];
moduleFolder.forEach((f)=>{
src_min.push('!o2web/source/'+f+'/**/*');
})
var entries = fg.sync(src_min, { dot: false});
var size = entries.length;
var pb = new ProgressBar('', 50);
var doCount = 0;
var stream = gulp.src(src_min);
stream.on("end", ()=>{console.log();});
return stream.pipe(uglify())
.pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest(dest))
.pipe(logger(function(){
doCount++;
if (doCount <= size){pb.render({ completed: doCount, total: size, count: doCount})};
}))
.pipe(gutil.noop());
}
function build_web_move() {
var dest = 'target/o2server/servers/webServer/';
var src_move = ['o2web/source/**/*', '!o2web/source/o2_core/o2.js', '!**/*.spec.js', '!**/test/**'];
moduleFolder.forEach((f)=>{
src_move.push('!o2web/source/'+f+'/**/*');
})
var entries = fg.sync(src_move, { dot: false});
var size = entries.length;
var pb = new ProgressBar('', 50);
var doCount = 0;
var stream = gulp.src(src_move);
stream.on("end", ()=>{console.log();});
return stream.pipe(gulp.dest(dest))
.pipe(logger(function(){
doCount++;
if (doCount <= size) {pb.render({ completed: doCount, total: size, count: doCount})};
}))
.pipe(gutil.noop());
}
exports.build_web_move = build_web_move;
function build_concat_o2(){
var src = [
'o2web/source/o2_core/polyfill.js',
'o2web/source/o2_lib/mootools/mootools-1.6.0_all.js',
'o2web/source/o2_lib/mootools/plugin/mBox.js',
'o2web/source/o2_core/o2.js'
];
var dest = 'target/o2server/servers/webServer/o2_core/';
return gulp.src(src, {sourcemaps: true})
//.pipe(sourceMap.init())
.pipe(concat('o2.js'))
.pipe(gulp.dest(dest))
.pipe(concat('o2.min.js'))
.pipe(uglify())
//.pipe(rename({ extname: '.min.js' }))
//.pipe(sourceMap.write(""))
.pipe(gulp.dest(dest, {sourcemaps: '.'}))
}
function build_concat_base(){
var src = [
'o2web/source/x_desktop/js/base.js',
'o2web/source/o2_core/o2/xScript/PageEnvironment.js',
'o2web/source/o2_core/o2/framework.js',
'o2web/source/x_desktop/js/base_loader.js'
];
var dest = 'target/o2server/servers/webServer/x_desktop/js/';
return gulp.src(src, {sourcemaps: true})
//.pipe(sourceMap.init())
.pipe(concat('base.js'))
.pipe(gulp.dest(dest))
.pipe(concat('base.min.js'))
.pipe(uglify())
//.pipe(rename({ extname: '.min.js' }))
//.pipe(sourceMap.write(""))
.pipe(gulp.dest(dest, {sourcemaps: '.'}));
}
function build_concat_desktop(){
let path = "o2_core";
var src = [
'o2web/source/'+path+'/o2/widget/Common.js',
'o2web/source/'+path+'/o2/widget/Dialog.js',
'o2web/source/'+path+'/o2/widget/UUID.js',
'o2web/source/'+path+'/o2/xDesktop/Common.js',
'o2web/source/'+path+'/o2/xDesktop/Actions/RestActions.js',
'o2web/source/'+path+'/o2/xAction/RestActions.js',
'o2web/source/'+path+'/o2/xDesktop/Access.js',
'o2web/source/'+path+'/o2/xDesktop/Dialog.js',
'o2web/source/'+path+'/o2/xDesktop/Menu.js',
'o2web/source/'+path+'/o2/xDesktop/UserData.js',
'o2web/source/x_component_Template/MPopupForm.js',
'o2web/source/'+path+'/o2/xDesktop/Authentication.js',
'o2web/source/'+path+'/o2/xDesktop/Dialog.js',
'o2web/source/'+path+'/o2/xDesktop/Window.js',
'o2web/source/x_component_Common/Main.js'
];
var dest = 'target/o2server/servers/webServer/o2_core/o2/xDesktop/';
return gulp.src(src, {sourcemaps: true})
//.pipe(sourceMap.init())
.pipe(concat('$all.js'))
.pipe(gulp.dest(dest))
.pipe(concat('$all.min.js'))
.pipe(uglify())
//.pipe(rename({ extname: '.min.js' }))
//.pipe(sourceMap.write(""))
.pipe(gulp.dest(dest, {sourcemaps: '.'}))
}
function build_concat_xform(){
let path = "x_component_process_Xform";
var src = [
'o2web/source/o2_core/o2/widget/AttachmentController.js',
'o2web/source/o2_core/o2/xScript/Macro.js',
'o2web/source/o2_core/o2/widget/Tab.js',
'o2web/source/o2_core/o2/widget/O2Identity.js',
'o2web/source/' + path + '/Form.js',
'o2web/source/' + path + '/$Module.js',
'o2web/source/' + path + '/$Input.js',
'o2web/source/' + path + '/Div.js',
'o2web/source/' + path + '/Combox.js',
'o2web/source/' + path + '/DatagridMobile.js',
'o2web/source/' + path + '/DatagridPC.js',
'o2web/source/' + path + '/Textfield.js',
'o2web/source/' + path + '/Personfield.js',
'o2web/source/' + path + '/Button.js',
'o2web/source/' + path + '/ViewSelector.js',
'o2web/source/' + path + '/*.js',
'o2web/source/x_component_process_Work/Processor.js',
'!o2web/source/' + path + '/Documenteditor.js ',
'!o2web/source/' + path + '/Office.js',
'!o2web/source/' + path + '/WpsOffice.js',
'!o2web/source/' + path + '/WpsOffice2.js',
'!o2web/source/' + path + '/YozoOffice.js',
'!o2web/source/' + path + '/IWebOffice.js',
'!o2web/source/' + path + '/OnlyOffice.js',
'!o2web/source/' + path + '/TinyMCEEditor.js'
];
var dest = 'target/o2server/servers/webServer/'+path+'/';
return gulp.src(src, {sourcemaps: true})
//.pipe(sourceMap.init())
.pipe(concat('$all.js'))
.pipe(gulp.dest(dest))
.pipe(concat('$all.min.js'))
.pipe(uglify())
//.pipe(rename({ extname: '.min.js' }))
//.pipe(sourceMap.write(""))
.pipe(gulp.dest(dest, {sourcemaps: '.'}))
}
function build_concat_cms_xform(){
let processPath = "x_component_process_Xform";
let path = "x_component_cms_Xform";
var src = [
'o2web/source/o2_core/o2/widget/AttachmentController.js',
// 'source/o2_core/o2/xScript/CMSEnvironment.js',
'o2web/source/o2_core/o2/xScript/CMSMacro.js',
'o2web/source/o2_core/o2/widget/Tab.js',
'o2web/source/o2_core/o2/widget/O2Identity.js',
'o2web/source/' + processPath + '/Form.js',
'o2web/source/' + processPath + '/$Module.js',
'o2web/source/' + processPath + '/$Input.js',
'o2web/source/' + processPath + '/Div.js',
//'source/' + processPath + '/Combox.js',
'o2web/source/' + processPath + '/DatagridMobile.js',
'o2web/source/' + processPath + '/DatagridPC.js',
'o2web/source/' + processPath + '/Textfield.js',
//'source/' + processPath + '/Personfield.js',
'o2web/source/' + processPath + '/Button.js',
//'source/' + processPath + '/ViewSelector.js',
'o2web/source/' + processPath + '/Org.js',
// 'source/' + processPath + '/*.js',
'o2web/source/' + processPath + '/Actionbar.js',
//'source/' + processPath + '/Address.js',
'o2web/source/' + processPath + '/Attachment.js',
'o2web/source/' + processPath + '/Calendar.js',
'o2web/source/' + processPath + '/Checkbox.js',
'o2web/source/' + processPath + '/Datagrid.js',
'o2web/source/' + processPath + '/Htmleditor.js',
//'source/' + processPath + '/Iframe.js',
'o2web/source/' + processPath + '/Label.js',
'o2web/source/' + processPath + '/Number.js',
'o2web/source/' + processPath + '/Common.js',
'o2web/source/' + processPath + '/Image.js',
'o2web/source/' + processPath + '/ImageClipper.js',
'o2web/source/' + processPath + '/Html.js',
'o2web/source/' + processPath + '/Radio.js',
'o2web/source/' + processPath + '/Select.js',
//'source/' + processPath + '/Stat.js',
//'source/' + processPath + '/Statement.js',
//'source/' + processPath + '/StatementSelector.js',
//'source/' + processPath + '/Subform.js',
'o2web/source/' + processPath + '/Tab.js',
'o2web/source/' + processPath + '/Table.js',
'o2web/source/' + processPath + '/Textarea.js',
//'source/' + processPath + '/Tree.js',
//'source/' + processPath + '/View.js',
// 'source/x_component_process_Work/Processor.js',
// '!source/' + processPath + '/Office.js'
'o2web/source/o2_core/o2/widget/SimpleToolbar.js',
'o2web/source/' + path + '/ModuleImplements.js',
'o2web/source/' + path + '/Package.js',
'o2web/source/' + path + '/Form.js',
//'source/' + path + '/widget/Comment.js',
'o2web/source/' + path + '/widget/Log.js',
'o2web/source/' + path + '/Org.js',
'o2web/source/' + path + '/Author.js',
'o2web/source/' + path + '/Reader.js',
'o2web/source/' + path + '/Textfield.js',
'o2web/source/' + path + '/Actionbar.js',
'o2web/source/' + path + '/Attachment.js',
'o2web/source/' + path + '/Button.js',
'o2web/source/' + path + '/Calendar.js',
'o2web/source/' + path + '/Checkbox.js',
'o2web/source/' + path + '/Datagrid.js',
'o2web/source/' + path + '/Htmleditor.js',
'o2web/source/' + path + '/ImageClipper.js',
'o2web/source/' + path + '/Label.js',
'o2web/source/' + path + '/Number.js',
'o2web/source/' + path + '/Radio.js',
'o2web/source/' + path + '/Select.js',
'o2web/source/' + path + '/Tab.js',
'o2web/source/' + path + '/Table.js',
'o2web/source/' + path + '/Textarea.js'
//'source/' + path + '/Personfield.js',
//'source/' + path + '/Readerfield.js',
//'source/' + path + '/Authorfield.js',
//'source/' + path + '/Orgfield.js',
// 'source/' + path + '/*.js',
// '!source/' + path + '/Office.js'
];
var dest = 'target/o2server/servers/webServer/'+path+'/';
return gulp.src(src, {sourcemaps: true})
//.pipe(sourceMap.init())
.pipe(concat('$all.js'))
.pipe(gulp.dest(dest))
.pipe(concat('$all.min.js'))
.pipe(uglify())
//.pipe(rename({ extname: '.min.js' }))
//.pipe(sourceMap.write(""))
.pipe(gulp.dest(dest, {sourcemaps: '.'}))
}
function build_bundle(){
let path = "o2_core";
var src = [
'o2web/source/o2_core/polyfill.js',
'o2web/source/o2_lib/mootools/mootools-1.6.0_all.js',
'o2web/source/o2_lib/mootools/plugin/mBox.js',
'o2web/source/o2_core/o2.js',
'o2web/source/x_desktop/js/base.js',
'o2web/source/x_desktop/js/base_loader.js',
'o2web/source/o2_core/o2/xScript/PageEnvironment.js',
"o2web/source/o2_core/o2/framework.js"
];
var dest = 'target/o2server/servers/webServer/'+path+'/';
return gulp.src(src, {sourcemaps: true})
//.pipe(sourceMap.init())
.pipe(concat('bundle.js'))
.pipe(gulp.dest(dest))
.pipe(concat('bundle.min.js'))
.pipe(uglify())
//.pipe(rename({ extname: '.min.js' }))
//.pipe(sourceMap.write(""))
.pipe(gulp.dest(dest, {sourcemaps: '.'}))
}
function concat_Actions(){
return through2.obj(function (file, enc, cb) {
if (file.isNull()) {
this.push(file);
return cb();
}
if (file.isStream()) {
this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
return cb();
}
var content = file.contents.toString();
var o = path.parse(file.path);
var name = o.name;
content = "var actionJson = "+content;
content = content+"\nif (!o2.xAction.RestActions.Action[\""+name+"\"]) o2.xAction.RestActions.Action[\""+name+"\"] = new Class({Extends: o2.xAction.RestActions.Action});";
content = content+"\no2.Actions.actions[\""+name+"\"] = new o2.xAction.RestActions.Action[\""+name+"\"](\""+name+"\", actionJson);";
file.contents = new Buffer.from(content);
this.push(file);
cb();
});
}
function concat_Style(){
return through2.obj(function (file, enc, cb) {
if (file.isNull()) {
this.push(file);
return cb();
}
if (file.isStream()) {
this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
return cb();
}
var content = file.contents.toString();
var name = file.path.replace(process.cwd(), "").replace(/\\/g, "/")
name = ".."+name.substring(name.indexOf("/source")+7);
content = "var csskey = encodeURIComponent(\""+name+"\");\no2.widget.css[csskey]="+content;
file.contents = new Buffer.from(content);
this.push(file);
cb();
});
}
function build_concat_basework_style(){
return gulp.src([
"o2web/source/x_component_process_Work/$Main/default/css.wcss",
"o2web/source/x_component_process_Xform/$Form/default/css.wcss",
"o2web/source/o2_core/o2/widget/$Tab/mobileForm/css.wcss",
"o2web/source/o2_core/o2/widget/$Menu/tab/css.wcss",
"o2web/source/o2_core/o2/widget/$Tab/form/css.wcss",
"o2web/source/x_component_process_Xform/$Form/default/doc.wcss",
"o2web/source/o2_core/o2/widget/$Toolbar/documentEdit/css.wcss",
"o2web/source/o2_core/o2/widget/$Toolbar/documentEdit_side/css.wcss",
"o2web/source/x_component_process_Xform/$Form/default/css.wcss"
])
.pipe(concat_Style())
.pipe(concat('js/base_work_style_temp.js'))
.pipe(gulp.dest('o2web/source/x_desktop/'));
}
function build_concat_basework_action(){
return gulp.src([
"o2web/source/o2_core/o2/xAction/services/x_organization_assemble_authentication.json",
"o2web/source/o2_core/o2/xAction/services/x_processplatform_assemble_surface.json",
"o2web/source/o2_core/o2/xAction/services/x_organization_assemble_control.json",
"o2web/source/o2_core/o2/xAction/services/x_query_assemble_surface.json",
"o2web/source/o2_core/o2/xAction/services/x_cms_assemble_control.json",
"o2web/source/o2_core/o2/xAction/services/x_program_center.json",
"o2web/source/o2_core/o2/xAction/services/x_organization_assemble_personal.json"
])
.pipe(concat_Actions())
.pipe(concat('js/base_work_actions_temp.js'))
.pipe(gulp.dest('o2web/source/x_desktop/'));
}
function build_concat_basework_clean(cb) {
var dest = [
'o2web/source/x_desktop/js/base_work_actions_temp.js',
'o2web/source/x_desktop/js/base_work_style_temp.js'
];
return del(dest, cb);
}
function build_concat_lp(cb) {
var lpTasks = [];
supportedLanguage.forEach(function(lp){
var src = [
'o2web/source/o2_core/o2/lp/'+(lp)+'.js',
'o2web/source/x_component_process_Work/lp/'+(lp)+'.js',
'o2web/source/x_component_process_Xform/lp/'+(lp)+'.js',
'o2web/source/x_component_Selector/lp/'+(lp)+'.js',
'o2web/source/x_component_Template/lp/'+(lp)+'.js',
'o2web/source/x_component_portal_Portal/lp/'+(lp)+'.js',
'o2web/source/x_component_cms_Document/lp/'+(lp)+'.js',
'o2web/source/x_component_cms_Xform/lp/'+(lp)+'.js',
];
var dest = 'target/o2server/servers/webServer/x_desktop/js/';
// lpTasks["build_concat_lp_"+lp] = function(){
// return
// };
var stream = gulp.src(src, {"allowEmpty": true, sourcemaps: true});
lpTasks.push(new Promise((resolve)=>{
stream.on("end", ()=>{ resolve(); });
}));
//.pipe(sourceMap.init())
stream.pipe(concat('base_lp_' + lp + '.js'))
.pipe(gulp.dest(dest))
.pipe(concat('base_lp_' + lp + '.min.js'))
.pipe(uglify())
//.pipe(rename({ extname: '.min.js' }))
// .pipe(sourceMap.write(""))
.pipe(gulp.dest(dest, {sourcemaps: '.' }));
});
return Promise.all(lpTasks);
//var build_concat_lp = gulp.parallel( Object.values(lpTasks) );
// return gulp.parallel(lpTasks);
}
function build_concat_basework_body() {
var src = [
'o2web/source/x_desktop/js/base_concat_head.js',
//'o2web/source/o2_core/o2/lp/'+(options.lp || 'zh-cn')+'.js',
'o2web/source/x_desktop/js/base_work_style_temp.js',
'o2web/source/o2_core/o2/widget/Common.js',
'o2web/source/o2_core/o2/widget/Dialog.js',
'o2web/source/o2_core/o2/widget/UUID.js',
'o2web/source/o2_core/o2/widget/Menu.js',
'o2web/source/o2_core/o2/widget/Toolbar.js',
'o2web/source/o2_core/o2/xDesktop/Common.js',
'o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js',
'o2web/source/o2_core/o2/xAction/RestActions.js',
'o2web/source/o2_core/o2/xDesktop/Access.js',
'o2web/source/o2_core/o2/xDesktop/Dialog.js',
'o2web/source/o2_core/o2/xDesktop/Menu.js',
'o2web/source/o2_core/o2/xDesktop/UserData.js',
'o2web/source/x_component_Template/MPopupForm.js',
'o2web/source/o2_core/o2/xDesktop/Authentication.js',
'o2web/source/o2_core/o2/xDesktop/Dialog.js',
'o2web/source/o2_core/o2/xDesktop/Window.js',
'o2web/source/x_component_Common/Main.js',
// 'o2web/source/o2_core/o2/lp/'+(options.lp || 'zh-cn')+'.js',
// 'o2web/source/x_component_process_Work/lp/'+(options.lp || 'zh-cn')+'.js',
// 'o2web/source/x_component_process_Xform/lp/'+(options.lp || 'zh-cn')+'.js',
// 'o2web/source/x_component_Selector/lp/'+(options.lp || 'zh-cn')+'.js',
'o2web/source/x_component_process_Work/Main.js',
'o2web/source/x_component_Selector/package.js',
'o2web/source/x_component_Selector/Person.js',
'o2web/source/x_component_Selector/Identity.js',
'o2web/source/x_component_Selector/Unit.js',
'o2web/source/x_component_Selector/IdentityWidthDuty.js',
'o2web/source/x_component_Selector/IdentityWidthDutyCategoryByUnit.js',
'o2web/source/x_component_Selector/UnitWithType.js',
'o2web/source/o2_core/o2/xScript/Actions/UnitActions.js',
'o2web/source/o2_core/o2/xScript/Actions/ScriptActions.js',
'o2web/source/o2_core/o2/xScript/Actions/CMSScriptActions.js',
'o2web/source/o2_core/o2/xScript/Actions/PortalScriptActions.js',
'o2web/source/o2_core/o2/xScript/Environment.js',
'o2web/source/x_component_Template/MTooltips.js',
'o2web/source/x_component_Template/MSelector.js',
'o2web/source/o2_core/o2/xAction/services/x_organization_assemble_authentication.js',
'o2web/source/o2_core/o2/xAction/services/x_processplatform_assemble_surface.js',
'o2web/source/o2_core/o2/xAction/services/x_cms_assemble_control.js',
'o2web/source/o2_core/o2/xAction/services/x_organization_assemble_control.js',
'o2web/source/o2_core/o2/xAction/services/x_query_assemble_surface.js',
'o2web/source/o2_core/o2/xAction/services/x_organization_assemble_personal.js',
'o2web/source/x_desktop/js/base_work_actions_temp.js',
'o2web/source/x_desktop/js/base.js',
'o2web/source/x_desktop/js/base_loader.js'
];
var dest = 'target/o2server/servers/webServer/x_desktop/js/';
return gulp.src(src, {sourcemaps: true})
//.pipe(sourceMap.init())
.pipe(concat('base_work.js'))
.pipe(gulp.dest(dest))
.pipe(concat('base_work.min.js'))
.pipe(uglify())
//.pipe(rename({ extname: '.min.js' }))
//.pipe(sourceMap.write(""))
.pipe(gulp.dest(dest, {sourcemaps: '.'}));
}
function build_concat_baseportal_style(){
return gulp.src([
"o2web/source/x_component_process_Work/$Main/default/css.wcss",
"o2web/source/x_component_portal_Portal/$Main/default/css.wcss",
"o2web/source/x_component_process_Xform/$Form/default/css.wcss",
"o2web/source/o2_core/o2/widget/$Tab/mobileForm/css.wcss",
"o2web/source/o2_core/o2/widget/$Menu/tab/css.wcss",
])
.pipe(concat_Style())
.pipe(concat('js/base_portal_style_temp.js'))
.pipe(gulp.dest('o2web/source/x_desktop/'));
}
function build_concat_baseportal_action(){
return gulp.src([
"o2web/source/o2_core/o2/xAction/services/x_organization_assemble_authentication.json",
"o2web/source/o2_core/o2/xAction/services/x_portal_assemble_surface.json",
"o2web/source/o2_core/o2/xAction/services/x_processplatform_assemble_surface.json",
"o2web/source/o2_core/o2/xAction/services/x_organization_assemble_control.json",
"o2web/source/o2_core/o2/xAction/services/x_query_assemble_surface.json",
"o2web/source/o2_core/o2/xAction/services/x_cms_assemble_control.json",
"o2web/source/o2_core/o2/xAction/services/x_program_center.json",
"o2web/source/o2_core/o2/xAction/services/x_organization_assemble_personal.json"
])
.pipe(concat_Actions())
.pipe(concat('js/base_portal_actions_temp.js'))
.pipe(gulp.dest('o2web/source/x_desktop/'));
}
function build_concat_baseportal_clean(cb) {
var dest = [
'o2web/source/x_desktop/js/base_portal_actions_temp.js',
'o2web/source/x_desktop/js/base_portal_style_temp.js'
];
return del(dest, cb);
}
function build_concat_baseportal_body() {
var src = [
'o2web/source/x_desktop/js/base_concat_head.js',
//'o2web/source/o2_core/o2/lp/'+(options.lp || 'zh-cn')+'.js',
'o2web/source/x_desktop/js/base_portal_style_temp.js',
'o2web/source/o2_core/o2/widget/Common.js',
'o2web/source/o2_core/o2/widget/Dialog.js',
'o2web/source/o2_core/o2/widget/UUID.js',
'o2web/source/o2_core/o2/widget/Menu.js',
'o2web/source/o2_core/o2/widget/Toolbar.js',
'o2web/source/o2_core/o2/xDesktop/Common.js',
'o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js',
'o2web/source/o2_core/o2/xAction/RestActions.js',
'o2web/source/o2_core/o2/xDesktop/Access.js',
'o2web/source/o2_core/o2/xDesktop/Dialog.js',
'o2web/source/o2_core/o2/xDesktop/Menu.js',
'o2web/source/o2_core/o2/xDesktop/UserData.js',
'o2web/source/x_component_Template/MPopupForm.js',
'o2web/source/o2_core/o2/xDesktop/Authentication.js',
'o2web/source/o2_core/o2/xDesktop/Window.js',
'o2web/source/x_component_Common/Main.js',
// 'o2web/source/x_component_process_Work/lp/'+(options.lp || 'zh-cn')+'.js',
// 'o2web/source/x_component_portal_Portal/lp/'+(options.lp || 'zh-cn')+'.js',
// 'o2web/source/x_component_process_Xform/lp/'+(options.lp || 'zh-cn')+'.js',
// 'o2web/source/x_component_Selector/lp/'+(options.lp || 'zh-cn')+'.js',
'o2web/source/x_component_portal_Portal/Main.js',
'o2web/source/x_component_Selector/package.js',
'o2web/source/x_component_Selector/Person.js',
'o2web/source/x_component_Selector/Identity.js',
'o2web/source/x_component_Selector/Unit.js',
'o2web/source/x_component_Selector/IdentityWidthDuty.js',
'o2web/source/x_component_Selector/IdentityWidthDutyCategoryByUnit.js',
'o2web/source/x_component_Selector/UnitWithType.js',
'o2web/source/o2_core/o2/xScript/Actions/UnitActions.js',
'o2web/source/o2_core/o2/xScript/Actions/ScriptActions.js',
'o2web/source/o2_core/o2/xScript/Actions/CMSScriptActions.js',
'o2web/source/o2_core/o2/xScript/Actions/PortalScriptActions.js',
'o2web/source/o2_core/o2/xScript/PageEnvironment.js',
'o2web/source/o2_core/o2/xAction/services/x_organization_assemble_authentication.js',
'o2web/source/o2_core/o2/xAction/services/x_processplatform_assemble_surface.js',
'o2web/source/o2_core/o2/xAction/services/x_cms_assemble_control.js',
'o2web/source/o2_core/o2/xAction/services/x_organization_assemble_control.js',
'o2web/source/o2_core/o2/xAction/services/x_query_assemble_surface.js',
'o2web/source/o2_core/o2/xAction/services/x_organization_assemble_personal.js',
'o2web/source/x_desktop/js/base_portal_actions_temp.js',
'o2web/source/x_desktop/js/base.js',
'o2web/source/x_desktop/js/base_loader.js'
];
var dest = 'target/o2server/servers/webServer/x_desktop/js/';
return gulp.src(src, {sourcemaps: true})
//.pipe(sourceMap.init())
.pipe(concat('base_portal.js'))
.pipe(gulp.dest(dest))
.pipe(concat('base_portal.min.js'))
.pipe(uglify())
//.pipe(rename({ extname: '.min.js' }))
//.pipe(sourceMap.write(""))
.pipe(gulp.dest(dest, {sourcemaps: '.'}));
}
function build_concat_basedocument_style(){
return gulp.src([
"o2web/source/x_component_cms_Document/$Main/default/css.wcss",
"o2web/source/x_component_cms_Xform/$Form/default/css.wcss",
"o2web/source/o2_core/o2/widget/$AttachmentController/default/css.wcss"
])
.pipe(concat_Style())
.pipe(concat('js/base_document_style_temp.js'))
.pipe(gulp.dest('o2web/source/x_desktop/'));
}
function build_concat_basedocument_action(){
return gulp.src([
"o2web/source/o2_core/o2/xAction/services/x_organization_assemble_authentication.json",
"o2web/source/o2_core/o2/xAction/services/x_organization_assemble_control.json",
"o2web/source/o2_core/o2/xAction/services/x_cms_assemble_control.json",
"o2web/source/o2_core/o2/xAction/services/x_program_center.json",
"o2web/source/o2_core/o2/xAction/services/x_organization_assemble_personal.json"
])
.pipe(concat_Actions())
.pipe(concat('js/base_document_actions_temp.js'))
.pipe(gulp.dest('o2web/source/x_desktop/'));
}
function build_concat_basedocument_clean(cb) {
var dest = [
'o2web/source/x_desktop/js/base_document_actions_temp.js',
'o2web/source/x_desktop/js/base_document_style_temp.js'
];
return del(dest, cb);
}
function build_concat_basedocument_body() {
var src = [
'o2web/source/x_desktop/js/base_concat_head.js',
//'o2web/source/o2_core/o2/lp/'+(options.lp || 'zh-cn')+'.js',
'o2web/source/x_desktop/js/base_document_style_temp.js',
'o2web/source/o2_core/o2/widget/Common.js',
'o2web/source/o2_core/o2/widget/Dialog.js',
'o2web/source/o2_core/o2/widget/UUID.js',
'o2web/source/o2_core/o2/widget/Menu.js',
'o2web/source/o2_core/o2/widget/Mask.js',
'o2web/source/o2_core/o2/xDesktop/Common.js',
'o2web/source/o2_core/o2/xDesktop/Actions/RestActions.js',
'o2web/source/o2_core/o2/xAction/RestActions.js',
'o2web/source/o2_core/o2/xDesktop/Access.js',
'o2web/source/o2_core/o2/xDesktop/Dialog.js',
'o2web/source/o2_core/o2/xDesktop/Menu.js',
'o2web/source/o2_core/o2/xDesktop/UserData.js',
'o2web/source/x_component_Template/MPopupForm.js',
'o2web/source/o2_core/o2/xDesktop/Authentication.js',
'o2web/source/o2_core/o2/xDesktop/Window.js',
'o2web/source/x_component_Common/Main.js',
// 'o2web/source/x_component_cms_Document/lp/'+(options.lp || 'zh-cn')+'.js',
// 'o2web/source/x_component_process_Xform/lp/'+(options.lp || 'zh-cn')+'.js',
// 'o2web/source/x_component_Selector/lp/'+(options.lp || 'zh-cn')+'.js',
// 'o2web/source/x_component_cms_Xform/lp/'+(options.lp || 'zh-cn')+'.js',
'o2web/source/x_component_cms_Document/Main.js',
'o2web/source/x_component_Selector/package.js',
'o2web/source/o2_core/o2/xScript/Actions/UnitActions.js',
'o2web/source/o2_core/o2/xScript/Actions/CMSScriptActions.js',
'o2web/source/o2_core/o2/xScript/CMSEnvironment.js',
'o2web/source/o2_core/o2/xAction/services/x_organization_assemble_authentication.js',
'o2web/source/o2_core/o2/xAction/services/x_cms_assemble_control.js',
'o2web/source/o2_core/o2/xAction/services/x_organization_assemble_control.js',
'o2web/source/o2_core/o2/xAction/services/x_organization_assemble_personal.js',
'o2web/source/x_desktop/js/base_document_actions_temp.js',
'o2web/source/x_desktop/js/base.js',
'o2web/source/x_desktop/js/base_loader.js'
];
var dest = 'target/o2server/servers/webServer/x_desktop/js/';
return gulp.src(src, {sourcemaps: true})
//.pipe(sourceMap.init())
.pipe(concat('base_document.js'))
.pipe(gulp.dest(dest))
.pipe(concat('base_document.min.js'))
.pipe(uglify())
//.pipe(rename({ extname: '.min.js' }))
//.pipe(sourceMap.write(""))
.pipe(gulp.dest(dest, {sourcemaps: '.'}));
}
exports.build_concat = gulp.parallel(
build_concat_o2,
build_concat_base,
build_concat_desktop,
build_concat_xform,
build_concat_cms_xform,
build_bundle,
build_concat_lp,
gulp.series(build_concat_basework_style, build_concat_basework_action, build_concat_basework_body,build_concat_basework_clean),
gulp.series(build_concat_baseportal_style, build_concat_baseportal_action, build_concat_baseportal_body,build_concat_baseportal_clean),
gulp.series(build_concat_basedocument_style, build_concat_basedocument_action, build_concat_basedocument_body,build_concat_basedocument_clean)
);
function getGitV(){
var tagPromise = new Promise(function(s, f){
git.exec({args : 'describe --tag'}, function (err, stdout) {
if (err){
f(err);
}
var v = stdout.substring(0, stdout.lastIndexOf("-"));
s(v);
});
});
var revPromise = new Promise(function(s, f){
git.exec({args : 'rev-parse --short HEAD'}, function (err, hash) {
if (err){
f(err);
}
s(hash.trim());
});
});
return Promise.all([tagPromise,revPromise])
}
function build_web_v_html() {
var src = 'o2web/source/x_desktop/*.html';
var dest = 'target/o2server/servers/webServer/x_desktop/';
return getGitV().then(function(arr){
return gulp.src(src)
.pipe(assetRev({"verConnecter": arr[0], "md5": arr[1]}))
.pipe(gulp.dest(dest))
.pipe(gutil.noop());
}, function(){
return gulp.src(src)
.pipe(assetRev())
.pipe(gulp.dest(dest))
.pipe(gutil.noop());
});
}
function build_web_api() {
var src = 'o2web/api/**/*';
var dest = 'target/o2server/servers/webServer/api/';
return gulp.src(src)
.pipe(gulp.dest(dest))
}
function build_doc(){
return getGitV().then(function(arr){
return (shell.task('jsdoc -c o2web/jsdoc.conf.json -q version='+arr[0]+'-'+arr[1]+''))();
}, function(){
return (shell.task('jsdoc -c o2web/jsdoc.conf.json -q version='))();
});
}
exports.build_api = gulp.series(build_doc, build_web_api);
function build_web_v_o2() {
var src = [
'target/o2server/servers/webServer/o2_core/o2.js',
'target/o2server/servers/webServer/o2_core/o2.min.js'
];
var dest = 'target/o2server/servers/webServer/o2_core/';
return getGitV().then(function(arr){
return gulp.src(src)
.pipe(assetRev({"verConnecter": arr[0], "md5": arr[1], "replace": true}))
//.pipe(gulp.dest(dest))
// .pipe(uglify())
// .pipe(rename({ extname: '.min.js' }))
.pipe(gulp.dest(dest))
.pipe(gutil.noop());
}, function(){
return gulp.src(src)
.pipe(assetRev())
.pipe(gutil.noop());
});
}
async function clear_build(cb) {
console.log(`---------------------------------------------------------------------
. clear old build ...
---------------------------------------------------------------------`);
var dest = 'target';
await del(dest, {force: true});
cb();
}
async function clear_deploy(cb) {
console.log(`---------------------------------------------------------------------
. clear old deploy ...
---------------------------------------------------------------------`);
var dest = ["target/o2server/store/", "target/o2server/commons/", "target/o2server/jvm/", "target/o2server/configSample/", "target/o2server/localSample/", "target/o2server/servers/"];
dest = dest.concat(["target/o2server/*.sh", "target/o2server/*.jar", "target/o2server/*.html", "target/o2server/*.bat", "target/o2server/version.o2"]);
await del(dest, {force: true});
cb();
}
exports.clear_build = clear_build;
exports.clear_deploy = clear_deploy;
function deploy_server(){
console.log(`---------------------------------------------------------------------
. deploy to target ...
---------------------------------------------------------------------`);
var source = ["o2server/*store/**/*", "o2server/*commons/**/*", "o2server/*jvm/**/*", "o2server/*configSample/**/*", "o2server/*localSample/**/*"];
source = source.concat(scriptSource);
console.log(source)
var dest = "target/o2server/"
var entries = fg.sync(source, { dot: false});
var size = entries.length;
var pb = new ProgressBar('', 50);
var doCount = 0;
var stream = gulp.src(source);
stream.on("end", ()=>{console.log();});
return stream.pipe(gulp.dest(dest))
.pipe(logger(function(){
doCount++;
if (doCount <= size) {pb.render({ completed: doCount, total: size, count: doCount})};
}));
}
//exports.preperation = gulp.series(download_commons_and_jvm, decompress_commons_and_jvm, move_commons, move_jvm);
exports.preperation = gulp.series(download_commons_and_jvm, decompress_commons_and_jvm, move_commons, move_jvm, clear_commons_git, clear_jvm_git);
var shell = require('gulp-shell')
const shelljs = require("shelljs");
exports.build_server = function(){
console.log(`---------------------------------------------------------------------
. Start compiling the server ...
---------------------------------------------------------------------`);
return (shell.task('npm run build_server_script'))();
};
function chmod_jvm(){
return (shell.task('chmod 777 -R target/o2server/jvm'))();
}
function chmod_commons(){
return (shell.task('chmod 777 -R target/o2server/commons'))();
}
function chmod_sh(){
return (shell.task('chmod 777 target/o2server/*.sh'))();
}
function chmod_servers(){
return (shell.task('chmod 777 -R target/o2server/servers'))();
}
exports.build_web = gulp.series(
build_web_module,
build_web_minimize,
build_web_move,
gulp.parallel(
build_concat_o2,
build_concat_base,
build_concat_desktop,
build_concat_xform,
build_concat_cms_xform,
build_concat_lp,
gulp.series(build_concat_basework_style, build_concat_basework_action, build_concat_basework_body,build_concat_basework_clean),
gulp.series(build_concat_baseportal_style, build_concat_baseportal_action, build_concat_baseportal_body,build_concat_baseportal_clean),
gulp.series(build_concat_basedocument_style, build_concat_basedocument_action, build_concat_basedocument_body,build_concat_basedocument_clean),
build_bundle
),
build_web_v_html,
build_web_v_o2,
//gulp.series(build_doc, build_web_api)
);
if (os.platform().indexOf("win")==-1){
exports.deploy = gulp.series(deploy_server, chmod_jvm, chmod_commons, chmod_sh, chmod_servers);
}else{
exports.deploy = gulp.series(deploy_server);
}
function createHistoryJsonFile(url, fileName, host){
const fp = fs.promises;
return new Promise(function(resolve){
request.get({'url': url}, function(error, response, body) {
if (!error && response.statusCode == 200) {
const historyJsons = JSON.parse(body);
fp.readFile(path.resolve(process.cwd(), 'download-pro.json'), 'utf8').then(function(str){
const downloadJson = JSON.parse(str);
downloadJson.windows.url = host+downloadJson.windows.url;
downloadJson.linux.url = host+downloadJson.linux.url
downloadJson.macos.url = host+downloadJson.macos.url
downloadJson.aix.url = host+downloadJson.aix.url
downloadJson.raspi.url = host+downloadJson.raspi.url
downloadJson.mips.url = host+downloadJson.mips.url
downloadJson.arm.url = host+downloadJson.arm.url
let append = true;
for (var i=0; i<historyJsons.length; i++){
var o = historyJsons[i];
if (o.title == downloadJson.title){
historyJsons.splice(i, 1, downloadJson)
append = false;
break;
}
}
if (append){
historyJsons.unshift(downloadJson);
}
const jsonStr = JSON.stringify(historyJsons, null, '\t');
fp.writeFile(path.resolve(process.cwd(), fileName), jsonStr).then(()=>{resolve();});
});
}
});
});
}
async function createHistroyJson(cb) {
const host = options.webSite;
const mirrorHost = options.mirrorSite;
const downloadHost = options.downloadSite
if (host) {
const url = host + "/website/history.json?t=" + (new Date()).getTime();
const mirrorUrl = mirrorHost + "/download/download-history.json?t=" + (new Date()).getTime();
var doneWebSite = false;
var doneMirror = false;
var check = function () {
if (doneWebSite && doneMirror) cb();
};
await createHistoryJsonFile(url, 'history.json', downloadHost);
await createHistoryJsonFile(mirrorUrl, 'download-history.json', mirrorHost);
}
cb();
}
exports.build_historyJson = createHistroyJson;
// /exports.build_module = build_web_module;
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/chahualao/O2OA.git
git@gitee.com:chahualao/O2OA.git
chahualao
O2OA
O2OA
master

搜索帮助