gulpfile.js 66 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554
  1. var gulp = require('gulp'),
  2. del = require('del'),
  3. // uglify = require('gulp-uglify-es').default,
  4. uglify = require('gulp-terser'),
  5. rename = require('gulp-rename'),
  6. changed = require('gulp-changed'),
  7. gulpif = require('gulp-if'),
  8. minimist = require('minimist'),
  9. ftp = require('gulp-ftp'),
  10. sftp = require('gulp-sftp-up4'),
  11. JSFtp = require('jsftp'),
  12. gutil = require('gulp-util'),
  13. fs = require("fs"),
  14. concat = require('gulp-concat'),
  15. shell = require('gulp-shell');
  16. var through2 = require('through2');
  17. var path = require('path');
  18. var nodePath = path;
  19. var git = require('gulp-git');
  20. var assetRev = require('gulp-o2oa-asset-rev');
  21. var apps = require('./gulpapps.js');
  22. const sourcemaps = require('gulp-sourcemaps');
  23. var {generate} = require('@o2oa/language-tools');
  24. var ftpconfig;
  25. try{
  26. ftpconfig = require('./gulpconfig.js');
  27. }catch(e){
  28. ftpconfig = {
  29. "dev": {
  30. 'upload': '',
  31. 'location': 'E:/o2server/servers/webServer/',
  32. 'host': '',
  33. 'user': '',
  34. 'pass': '',
  35. "port": 22,
  36. "remotePath": "/data/o2server/servers/webServer/",
  37. "dest": "dest"
  38. }
  39. };
  40. }
  41. var supportedLanguage = ["zh-cn", "en", "es"];
  42. var o_options = minimist(process.argv.slice(2), {//upload: local ftp or sftp
  43. string: ["ev", "upload", "location", "host", "user", "pass", "port", "remotePath", "dest", "src", "lp"]
  44. });
  45. function getEvOptions(ev){
  46. options.ev = ev;
  47. return (ftpconfig[ev]) || {
  48. 'location': '',
  49. 'host': '',
  50. 'user': '',
  51. 'pass': '',
  52. "port": null,
  53. "remotePath": "",
  54. "dest": "dest",
  55. "upload": ""
  56. }
  57. }
  58. function setOptions(op1, op2){
  59. if (!op2) op2 = {};
  60. options.upload = op1.upload || op2.upload || "";
  61. options.location = op1.location || op2.location || "";
  62. options.host = op1.host || op2.host || "";
  63. options.user = op1.user || op2.user || "";
  64. options.pass = op1.pass || op2.pass || "";
  65. options.port = op1.port || op2.port || "";
  66. options.remotePath = op1.remotePath || op2.remotePath || "";
  67. options.dest = op1.dest || op2.dest || "dest";
  68. options.lp = op1.lp || op2.lp || "zh-cn";
  69. options.src = op1.src || op2.src || "";
  70. }
  71. var options = {};
  72. setOptions(o_options, getEvOptions(o_options.ev));
  73. var appTasks = [];
  74. function setTaskName(task, name){
  75. Object.defineProperty(task, 'name', {
  76. value: name
  77. });
  78. return task;
  79. }
  80. function createLanguagePackTask(path){
  81. let component;
  82. if (ftpconfig && ftpconfig.languagePack && ftpconfig.languagePack.accessKeys){
  83. const lps = ftpconfig.languagePack.lps, keys = ftpconfig.languagePack.accessKeys["baidu-translate"];
  84. const name = path+" : LanguagePack";
  85. const task = function(cb){
  86. if (path.startsWith('x_component_')){
  87. component = path.substring('x_component_'.length).replace('_', '.');
  88. generate(component, lps, keys).then(()=>{
  89. cb();
  90. });
  91. }else if(path==='o2_core') {
  92. component = 'o2_core';
  93. generate(component, lps, keys).then(()=>{
  94. cb();
  95. });
  96. }else{
  97. cb();
  98. }
  99. }
  100. return setTaskName(task, name);
  101. }else{
  102. return function nothing(cb){cb();};
  103. }
  104. }
  105. function createDefaultTask(path, isMin, thisOptions) {
  106. var pkgPath = nodePath.resolve('source', path, 'package.json');
  107. if (fs.existsSync(pkgPath)){
  108. var pkg = require(pkgPath);
  109. if (pkg.scripts['o2-deploy']){
  110. const shellTask = shell.task('npm run o2-deploy', {cwd: nodePath.resolve('source', path), verbose:true});
  111. const task = function(){
  112. var option = thisOptions || options;
  113. var dest = ['dest/' + path + '/**/*'];
  114. return gulp.src(dest)
  115. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  116. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  117. host: option.host,
  118. user: option.user || 'anonymous',
  119. pass: option.pass || '@anonymous',
  120. port: option.port || 21,
  121. remotePath: (option.remotePath || '/') + path
  122. })))
  123. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  124. host: option.host,
  125. user: option.user || 'anonymous',
  126. pass: option.pass || null,
  127. port: option.port || 22,
  128. remotePath: (option.remotePath || '/') + path
  129. })))
  130. .pipe(gutil.noop());
  131. }
  132. return gulp.series(
  133. setTaskName(shellTask, path+' : build'),
  134. setTaskName(task, path+' : deploy'),
  135. )
  136. }
  137. }
  138. const task = function (){
  139. var option = thisOptions || options;
  140. var src;
  141. var dest = option.dest+'/' + path + '/';
  142. let ev = option.ev
  143. var evList = Object.keys(ftpconfig).map((i)=>{ return (i==ev) ? "*"+i : i; });
  144. if (isMin){
  145. var src_min = ['source/' + path + '/**/*.js', '!**/*.spec.js', '!**/test/**'];
  146. var src_move = ['source/' + path + '/**/*', '!**/*.spec.js', '!**/test/**'];
  147. gutil.log("Move-Uglify", ":", gutil.colors.green(gutil.colors.blue(path), gutil.colors.white('->'), dest));
  148. return gulp.src(src_min)
  149. .pipe(changed(dest))
  150. .pipe(uglify())
  151. .pipe(rename({ extname: '.min.js' }))
  152. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  153. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  154. host: option.host,
  155. user: option.user || 'anonymous',
  156. pass: option.pass || '@anonymous',
  157. port: option.port || 21,
  158. remotePath: (option.remotePath || '/') + path
  159. })))
  160. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  161. host: option.host,
  162. user: option.user || 'anonymous',
  163. pass: option.pass || null,
  164. port: option.port || 22,
  165. remotePath: (option.remotePath || '/') + path
  166. })))
  167. .pipe(gulpif((option.ev == "dev" || option.ev == "pro") ,gulp.dest(dest)))
  168. .pipe(gulp.src(src_move))
  169. .pipe(changed(dest))
  170. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  171. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  172. host: option.host,
  173. user: option.user || 'anonymous',
  174. pass: option.pass || '@anonymous',
  175. port: option.port || 21,
  176. remotePath: (option.remotePath || '/') + path
  177. })))
  178. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  179. host: option.host,
  180. user: option.user || 'anonymous',
  181. pass: option.pass || null,
  182. port: option.port || 22,
  183. remotePath: (option.remotePath || '/') + path
  184. })))
  185. .pipe(gulp.dest(dest))
  186. .pipe(gutil.noop());
  187. }else{
  188. src = ['source/' + path + '/**/*', '!**/*.spec.js', '!**/test/**'];
  189. gutil.log("Move", ":", gutil.colors.green(gutil.colors.blue(path), gutil.colors.white('->'), dest));
  190. return gulp.src(src)
  191. .pipe(changed(dest))
  192. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  193. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  194. host: option.host,
  195. user: option.user || 'anonymous',
  196. pass: option.pass || '@anonymous',
  197. port: option.port || 21,
  198. remotePath: (option.remotePath || '/') + path
  199. })))
  200. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  201. host: option.host,
  202. user: option.user || 'anonymous',
  203. pass: option.pass || null,
  204. port: option.port || 22,
  205. remotePath: (option.remotePath || '/') + path
  206. })))
  207. .pipe(gulp.dest(dest))
  208. .pipe(gutil.noop());
  209. }
  210. }
  211. return setTaskName(task, path+' : task');
  212. }
  213. function createXFormConcatTask(path, isMin, thisOptions) {
  214. return function process_Xform_concat(){
  215. var option = thisOptions || options;
  216. var src = [
  217. 'source/o2_core/o2/widget/AttachmentController.js',
  218. 'source/o2_core/o2/xScript/Macro.js',
  219. 'source/o2_core/o2/widget/Tab.js',
  220. 'source/o2_core/o2/widget/O2Identity.js',
  221. 'source/' + path + '/Form.js',
  222. 'source/' + path + '/$Module.js',
  223. 'source/' + path + '/$Input.js',
  224. 'source/' + path + '/$Selector.js',
  225. 'source/' + path + '/Div.js',
  226. 'source/' + path + '/Combox.js',
  227. 'source/' + path + '/DatagridMobile.js',
  228. 'source/' + path + '/DatagridPC.js',
  229. 'source/' + path + '/DatatablePC.js',
  230. 'source/' + path + '/DatatableMobile.js',
  231. 'source/' + path + '/Textfield.js',
  232. 'source/' + path + '/Personfield.js',
  233. 'source/' + path + '/Button.js',
  234. 'source/' + path + '/ViewSelector.js',
  235. 'source/' + path + '/*.js',
  236. 'source/x_component_process_Work/Processor.js',
  237. //'source/x_component_process_Work/Flow.js',
  238. '!source/' + path + '/Documenteditor.js ',
  239. '!source/' + path + '/Office.js',
  240. '!source/' + path + '/WpsOffice.js',
  241. '!source/' + path + '/WpsOffice2.js',
  242. '!source/' + path + '/YozoOffice.js',
  243. '!source/' + path + '/OnlyOffice.js',
  244. '!source/' + path + '/OfficeOnline.js',
  245. '!source/' + path + '/TinyMCEEditor.js'
  246. ];
  247. var dest = option.dest+'/' + path + '/';
  248. return gulp.src(src)
  249. .pipe(concat('$all.js'))
  250. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  251. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  252. host: option.host,
  253. user: option.user || 'anonymous',
  254. pass: option.pass || '@anonymous',
  255. port: option.port || 21,
  256. remotePath: (option.remotePath || '/') + path
  257. })))
  258. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  259. host: option.host,
  260. user: option.user || 'anonymous',
  261. pass: option.pass || null,
  262. port: option.port || 22,
  263. remotePath: (option.remotePath || '/') + path
  264. })))
  265. .pipe(gulp.dest(dest))
  266. .pipe(sourcemaps.init())
  267. .pipe(concat('$all.min.js'))
  268. .pipe(uglify())
  269. .pipe(sourcemaps.write("./"))
  270. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  271. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  272. host: option.host,
  273. user: option.user || 'anonymous',
  274. pass: option.pass || '@anonymous',
  275. port: option.port || 21,
  276. remotePath: (option.remotePath || '/') + path
  277. })))
  278. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  279. host: option.host,
  280. user: option.user || 'anonymous',
  281. pass: option.pass || null,
  282. port: option.port || 22,
  283. remotePath: (option.remotePath || '/') + path
  284. })))
  285. .pipe(gulp.dest(dest))
  286. };
  287. }
  288. function createCMSXFormConcatTask(path, isMin, thisOptions) {
  289. return function cms_xform_concat(){
  290. var processPath = "x_component_process_Xform";
  291. var option = thisOptions || options;
  292. var src = [
  293. 'source/o2_core/o2/widget/AttachmentController.js',
  294. // 'source/o2_core/o2/xScript/CMSEnvironment.js',
  295. 'source/o2_core/o2/xScript/CMSMacro.js',
  296. 'source/o2_core/o2/widget/Tab.js',
  297. 'source/o2_core/o2/widget/O2Identity.js',
  298. 'source/o2_core/o2/widget/ImageLazyLoader.js',
  299. 'source/o2_core/o2/widget/ImageViewer.js',
  300. 'source/' + processPath + '/Form.js',
  301. 'source/' + processPath + '/$Module.js',
  302. 'source/' + processPath + '/$Input.js',
  303. 'source/' + processPath + '/$Selector.js',
  304. 'source/' + processPath + '/Div.js',
  305. //'source/' + processPath + '/Combox.js',
  306. 'source/' + processPath + '/DatagridMobile.js',
  307. 'source/' + processPath + '/DatagridPC.js',
  308. 'source/' + processPath + '/DatatablePC.js',
  309. 'source/' + processPath + '/DatatableMobile.js',
  310. 'source/' + processPath + '/Textfield.js',
  311. //'source/' + processPath + '/Personfield.js',
  312. 'source/' + processPath + '/Button.js',
  313. //'source/' + processPath + '/ViewSelector.js',
  314. 'source/' + processPath + '/Org.js',
  315. // 'source/' + processPath + '/*.js',
  316. 'source/' + processPath + '/Actionbar.js',
  317. //'source/' + processPath + '/Address.js',
  318. 'source/' + processPath + '/Attachment.js',
  319. 'source/' + processPath + '/Calendar.js',
  320. 'source/' + processPath + '/Checkbox.js',
  321. 'source/' + processPath + '/Datagrid.js',
  322. 'source/' + processPath + '/Datatable.js',
  323. 'source/' + processPath + '/Datatemplate.js',
  324. 'source/' + processPath + '/Htmleditor.js',
  325. //'source/' + processPath + '/Iframe.js',
  326. 'source/' + processPath + '/Label.js',
  327. 'source/' + processPath + '/Number.js',
  328. 'source/' + processPath + '/Currency.js',
  329. 'source/' + processPath + '/Common.js',
  330. 'source/' + processPath + '/Image.js',
  331. 'source/' + processPath + '/ImageClipper.js',
  332. 'source/' + processPath + '/WritingBoard.js',
  333. 'source/' + processPath + '/Html.js',
  334. 'source/' + processPath + '/Radio.js',
  335. 'source/' + processPath + '/Select.js',
  336. //'source/' + processPath + '/Stat.js',
  337. //'source/' + processPath + '/Statement.js',
  338. //'source/' + processPath + '/StatementSelector.js',
  339. //'source/' + processPath + '/Subform.js',
  340. 'source/' + processPath + '/Tab.js',
  341. 'source/' + processPath + '/Table.js',
  342. 'source/' + processPath + '/Textarea.js',
  343. 'source/' + processPath + '/$ElModule.js',
  344. 'source/' + processPath + '/$Elinput.js',
  345. 'source/' + processPath + '/Elcascader.js',
  346. 'source/' + processPath + '/Elradio.js',
  347. 'source/' + processPath + '/Elcheckbox.js',
  348. 'source/' + processPath + '/Elcommon.js',
  349. 'source/' + processPath + '/Elcontainer.js',
  350. 'source/' + processPath + '/Elicon.js',
  351. 'source/' + processPath + '/Elinput.js',
  352. 'source/' + processPath + '/Elnumber.js',
  353. 'source/' + processPath + '/Elselect.js',
  354. 'source/' + processPath + '/Elslider.js',
  355. 'source/' + processPath + '/Elswitch.js',
  356. 'source/' + processPath + '/Elautocomplete.js',
  357. 'source/' + processPath + '/Elbutton.js',
  358. 'source/' + processPath + '/Eltime.js',
  359. 'source/' + processPath + '/Eldate.js',
  360. 'source/' + processPath + '/Eldatetime.js',
  361. 'source/' + processPath + '/Elrate.js',
  362. 'source/' + processPath + '/Elcolorpicker.js',
  363. 'source/' + processPath + '/Eltree.js',
  364. 'source/' + processPath + '/Eldropdown.js',
  365. 'source/' + processPath + '/Elcarousel.js',
  366. 'source/' + processPath + '/OOInput.js',
  367. 'source/' + processPath + '/OOSelect.js',
  368. 'source/' + processPath + '/OOCheckGroup.js',
  369. 'source/' + processPath + '/OORadioGroup.js',
  370. 'source/' + processPath + '/OODatetime.js',
  371. 'source/' + processPath + '/OOButton.js',
  372. 'source/' + processPath + '/OOTextarea.js',
  373. //'source/' + processPath + '/Tree.js',
  374. //'source/' + processPath + '/View.js',
  375. // 'source/x_component_process_Work/Processor.js',
  376. // '!source/' + processPath + '/Office.js'
  377. 'source/o2_core/o2/widget/SimpleToolbar.js',
  378. 'source/' + path + '/ModuleImplements.js',
  379. 'source/' + path + '/Package.js',
  380. 'source/' + path + '/Form.js',
  381. //'source/' + path + '/widget/Comment.js',
  382. 'source/' + path + '/widget/Log.js',
  383. 'source/' + path + '/Org.js',
  384. 'source/' + path + '/Author.js',
  385. 'source/' + path + '/Reader.js',
  386. 'source/' + path + '/Textfield.js',
  387. 'source/' + path + '/Actionbar.js',
  388. 'source/' + path + '/Attachment.js',
  389. 'source/' + path + '/Button.js',
  390. 'source/' + path + '/Calendar.js',
  391. 'source/' + path + '/Checkbox.js',
  392. 'source/' + path + '/Datagrid.js',
  393. 'source/' + path + '/Datatable.js',
  394. 'source/' + path + '/Datatemplate.js',
  395. 'source/' + path + '/Htmleditor.js',
  396. 'source/' + path + '/ImageClipper.js',
  397. 'source/' + path + '/WritingBoard.js',
  398. 'source/' + path + '/Label.js',
  399. 'source/' + path + '/Number.js',
  400. 'source/' + path + '/Currency.js',
  401. 'source/' + path + '/Radio.js',
  402. 'source/' + path + '/Select.js',
  403. 'source/' + path + '/Tab.js',
  404. 'source/' + path + '/Table.js',
  405. 'source/' + path + '/Textarea.js',
  406. 'source/' + path + '/Elcascader.js',
  407. 'source/' + path + '/Elradio.js',
  408. 'source/' + path + '/Elcheckbox.js',
  409. 'source/' + path + '/Elcommon.js',
  410. 'source/' + path + '/Elcontainer.js',
  411. 'source/' + path + '/Elicon.js',
  412. 'source/' + path + '/Elinput.js',
  413. 'source/' + path + '/Elnumber.js',
  414. 'source/' + path + '/Elselect.js',
  415. 'source/' + path + '/Elslider.js',
  416. 'source/' + path + '/Elswitch.js',
  417. 'source/' + path + '/Elautocomplete.js',
  418. 'source/' + path + '/Elbutton.js',
  419. 'source/' + path + '/Eltime.js',
  420. 'source/' + path + '/Eldate.js',
  421. 'source/' + path + '/Eldatetime.js',
  422. 'source/' + path + '/Elrate.js',
  423. 'source/' + path + '/Elcolorpicker.js',
  424. 'source/' + path + '/Eltree.js',
  425. 'source/' + path + '/Eldropdown.js',
  426. 'source/' + path + '/Elcarousel.js',
  427. //'source/' + path + '/Personfield.js',
  428. //'source/' + path + '/Readerfield.js',
  429. //'source/' + path + '/Authorfield.js',
  430. //'source/' + path + '/Orgfield.js',
  431. // 'source/' + path + '/*.js',
  432. // '!source/' + path + '/Office.js'
  433. ];
  434. var dest = option.dest+'/' + path + '/';
  435. return gulp.src(src)
  436. .pipe(concat('$all.js'))
  437. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  438. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  439. host: option.host,
  440. user: option.user || 'anonymous',
  441. pass: option.pass || '@anonymous',
  442. port: option.port || 21,
  443. remotePath: (option.remotePath || '/') + path
  444. })))
  445. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  446. host: option.host,
  447. user: option.user || 'anonymous',
  448. pass: option.pass || null,
  449. port: option.port || 22,
  450. remotePath: (option.remotePath || '/') + path
  451. })))
  452. .pipe(gulp.dest(dest))
  453. .pipe(sourcemaps.init())
  454. .pipe(concat('$all.min.js'))
  455. .pipe(uglify())
  456. .pipe(sourcemaps.write("./"))
  457. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  458. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  459. host: option.host,
  460. user: option.user || 'anonymous',
  461. pass: option.pass || '@anonymous',
  462. port: option.port || 21,
  463. remotePath: (option.remotePath || '/') + path
  464. })))
  465. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  466. host: option.host,
  467. user: option.user || 'anonymous',
  468. pass: option.pass || null,
  469. port: option.port || 22,
  470. remotePath: (option.remotePath || '/') + path
  471. })))
  472. .pipe(gulp.dest(dest))
  473. }
  474. }
  475. function createO2ConcatTask(path, isMin, thisOptions) {
  476. function o2_core_concat(){
  477. var option = thisOptions || options;
  478. var src = [
  479. 'source/' + path + '/polyfill.js',
  480. 'source/o2_lib/mootools/mootools-1.6.0_all.js',
  481. 'source/o2_lib/mootools/plugin/mBox.js',
  482. 'source/' + path + '/o2.js'
  483. ];
  484. var dest = option.dest+'/' + path + '/';
  485. return gulp.src(src)
  486. .pipe(concat('o2.js'))
  487. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  488. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  489. host: option.host,
  490. user: option.user || 'anonymous',
  491. pass: option.pass || '@anonymous',
  492. port: option.port || 21,
  493. remotePath: (option.remotePath || '/') + path
  494. })))
  495. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  496. host: option.host,
  497. user: option.user || 'anonymous',
  498. pass: option.pass || null,
  499. port: option.port || 22,
  500. remotePath: (option.remotePath || '/') + path
  501. })))
  502. .pipe(gulp.dest(dest))
  503. .pipe(sourcemaps.init())
  504. .pipe(concat('o2.min.js'))
  505. .pipe(uglify())
  506. .pipe(sourcemaps.write("./"))
  507. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  508. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  509. host: option.host,
  510. user: option.user || 'anonymous',
  511. pass: option.pass || '@anonymous',
  512. port: option.port || 21,
  513. remotePath: (option.remotePath || '/') + path
  514. })))
  515. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  516. host: option.host,
  517. user: option.user || 'anonymous',
  518. pass: option.pass || null,
  519. port: option.port || 22,
  520. remotePath: (option.remotePath || '/') + path
  521. })))
  522. .pipe(gulp.dest(dest))
  523. }
  524. function o2_core_xDesktop_concat(){
  525. var option = thisOptions || options;
  526. var src = [
  527. 'source/'+path+'/o2/widget/Common.js',
  528. 'source/'+path+'/o2/widget/Dialog.js',
  529. 'source/'+path+'/o2/widget/UUID.js',
  530. 'source/'+path+'/o2/xDesktop/Common.js',
  531. 'source/'+path+'/o2/xDesktop/Actions/RestActions.js',
  532. 'source/'+path+'/o2/xAction/RestActions.js',
  533. 'source/'+path+'/o2/xDesktop/Access.js',
  534. 'source/'+path+'/o2/xDesktop/Dialog.js',
  535. 'source/'+path+'/o2/xDesktop/Menu.js',
  536. 'source/'+path+'/o2/xDesktop/UserData.js',
  537. 'source/x_component_Template/MPopupForm.js',
  538. 'source/'+path+'/o2/xDesktop/Authentication.js',
  539. 'source/'+path+'/o2/xDesktop/Dialog.js',
  540. 'source/'+path+'/o2/xDesktop/Window.js',
  541. 'source/x_component_Common/Main.js'
  542. ];
  543. var dest = option.dest+'/' + path + '/o2/xDesktop/';
  544. return gulp.src(src)
  545. .pipe(concat('$all.js'))
  546. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/o2/xDesktop/')))
  547. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  548. host: option.host,
  549. user: option.user || 'anonymous',
  550. pass: option.pass || '@anonymous',
  551. port: option.port || 21,
  552. remotePath: (option.remotePath || '/') + path+"/o2/xDesktop/"
  553. })))
  554. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  555. host: option.host,
  556. user: option.user || 'anonymous',
  557. pass: option.pass || null,
  558. port: option.port || 22,
  559. remotePath: (option.remotePath || '/') + path+"/o2/xDesktop/"
  560. })))
  561. .pipe(gulp.dest(dest))
  562. .pipe(sourcemaps.init())
  563. .pipe(concat('$all.min.js'))
  564. .pipe(uglify())
  565. .pipe(sourcemaps.write("./"))
  566. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/o2/xDesktop/')))
  567. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  568. host: option.host,
  569. user: option.user || 'anonymous',
  570. pass: option.pass || '@anonymous',
  571. port: option.port || 21,
  572. remotePath: (option.remotePath || '/') + path+"/o2/xDesktop/"
  573. })))
  574. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  575. host: option.host,
  576. user: option.user || 'anonymous',
  577. pass: option.pass || null,
  578. port: option.port || 22,
  579. remotePath: (option.remotePath || '/') + path+"/o2/xDesktop/"
  580. })))
  581. .pipe(gulp.dest(dest));
  582. }
  583. function o2_core_bundle(){
  584. var option = thisOptions || options;
  585. var src = [
  586. 'source/' + path + '/polyfill.js',
  587. 'source/o2_lib/mootools/mootools-1.6.0_all.js',
  588. 'source/o2_lib/mootools/plugin/mBox.js',
  589. 'source/' + path + '/o2.js',
  590. 'source/x_desktop/js/base.js',
  591. 'source/x_desktop/js/base_loader.js',
  592. 'source/o2_core/o2/xScript/PageEnvironment.js',
  593. "source/o2_core/o2/framework.js"
  594. ];
  595. var dest = option.dest+'/' + path + '/';
  596. return gulp.src(src)
  597. .pipe(concat('bundle.js'))
  598. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  599. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  600. host: option.host,
  601. user: option.user || 'anonymous',
  602. pass: option.pass || '@anonymous',
  603. port: option.port || 21,
  604. remotePath: (option.remotePath || '/') + path
  605. })))
  606. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  607. host: option.host,
  608. user: option.user || 'anonymous',
  609. pass: option.pass || null,
  610. port: option.port || 22,
  611. remotePath: (option.remotePath || '/') + path
  612. })))
  613. .pipe(gulp.dest(dest))
  614. .pipe(sourcemaps.init())
  615. .pipe(concat('bundle.min.js'))
  616. .pipe(uglify())
  617. .pipe(sourcemaps.write("./"))
  618. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  619. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  620. host: option.host,
  621. user: option.user || 'anonymous',
  622. pass: option.pass || '@anonymous',
  623. port: option.port || 21,
  624. remotePath: (option.remotePath || '/') + path
  625. })))
  626. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  627. host: option.host,
  628. user: option.user || 'anonymous',
  629. pass: option.pass || null,
  630. port: option.port || 22,
  631. remotePath: (option.remotePath || '/') + path
  632. })))
  633. .pipe(gulp.dest(dest))
  634. }
  635. return [o2_core_concat, o2_core_xDesktop_concat, o2_core_bundle];
  636. }
  637. function concat_Actions(){
  638. return through2.obj(function (file, enc, cb) {
  639. debugger;
  640. if (file.isNull()) {
  641. this.push(file);
  642. return cb();
  643. }
  644. if (file.isStream()) {
  645. this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
  646. return cb();
  647. }
  648. var content = file.contents.toString();
  649. var o = path.parse(file.path);
  650. var name = o.name;
  651. content = "var actionJson = "+content;
  652. content = content+"\nif (!o2.xAction.RestActions.Action[\""+name+"\"]) o2.xAction.RestActions.Action[\""+name+"\"] = new Class({Extends: o2.xAction.RestActions.Action});";
  653. content = content+"\no2.Actions.actions[\""+name+"\"] = new o2.xAction.RestActions.Action[\""+name+"\"](\""+name+"\", actionJson);";
  654. file.contents = new Buffer.from(content);
  655. this.push(file);
  656. cb();
  657. });
  658. }
  659. function concat_Style(){
  660. return through2.obj(function (file, enc, cb) {
  661. if (file.isNull()) {
  662. this.push(file);
  663. return cb();
  664. }
  665. if (file.isStream()) {
  666. this.emit('error', new gutil.PluginError(PLUGIN_NAME, 'Streaming not supported'));
  667. return cb();
  668. }
  669. var content = file.contents.toString();
  670. var name = file.path.replace(process.cwd(), "").replace(/\\/g, "/")
  671. name = ".."+name.substring(name.indexOf("/source")+7);
  672. content = "var csskey = encodeURIComponent(\""+name+"\");\no2.widget.css[csskey]="+content;
  673. file.contents = new Buffer.from(content);
  674. this.push(file);
  675. cb();
  676. });
  677. }
  678. function createBaseWorkConcatStyleTask(path){
  679. const task = function(){
  680. return gulp.src([
  681. "source/x_component_process_Work/$Main/default/css.wcss",
  682. "source/x_component_process_Xform/$Form/default/css.wcss",
  683. "source/o2_core/o2/widget/$Tab/mobileForm/css.wcss",
  684. "source/o2_core/o2/widget/$Menu/tab/css.wcss",
  685. "source/o2_core/o2/widget/$Tab/form/css.wcss",
  686. "source/x_component_process_Xform/$Form/default/doc.wcss",
  687. "source/o2_core/o2/widget/$Toolbar/documentEdit/css.wcss",
  688. "source/o2_core/o2/widget/$Toolbar/documentEdit_side/css.wcss"
  689. ])
  690. .pipe(concat_Style())
  691. .pipe(concat('js/base_work_style_temp.js'))
  692. .pipe(gulp.dest('source/x_desktop/'));
  693. }
  694. return setTaskName(task, path+".base_work : style");
  695. }
  696. function createBaseWorkConcatActionTask(path){
  697. const task = function(){
  698. return gulp.src([
  699. "source/o2_core/o2/xAction/services/x_organization_assemble_authentication.json",
  700. "source/o2_core/o2/xAction/services/x_processplatform_assemble_surface.json",
  701. "source/o2_core/o2/xAction/services/x_organization_assemble_control.json",
  702. "source/o2_core/o2/xAction/services/x_query_assemble_surface.json",
  703. "source/o2_core/o2/xAction/services/x_cms_assemble_control.json",
  704. "source/o2_core/o2/xAction/services/x_program_center.json",
  705. "source/o2_core/o2/xAction/services/x_organization_assemble_personal.json"
  706. ])
  707. .pipe(concat_Actions())
  708. .pipe(concat('js/base_work_actions_temp.js'))
  709. .pipe(gulp.dest('source/x_desktop/'))
  710. }
  711. return setTaskName(task, path+".base_work : action")
  712. }
  713. function createBaseWorkConcatDelTempTask(path) {
  714. const task = function(cb){
  715. var dest = [
  716. 'source/'+path+'/js/base_work_actions_temp.js',
  717. 'source/'+path+'/js/base_work_style_temp.js'
  718. ];
  719. return del(dest, cb);
  720. }
  721. return setTaskName(task, path+".base_work : clean");
  722. }
  723. function createBaseWorkConcatBodyTask(path, isMin, thisOptions) {
  724. const task = function(){
  725. var option = thisOptions || options;
  726. var src = [
  727. 'source/' + path + '/js/base_concat_head.js',
  728. // 'source/o2_core/o2/lp/'+(option.lp || 'zh-cn')+'.js',
  729. // 'source/x_component_process_Work/lp/'+(option.lp || 'zh-cn')+'.js',
  730. // 'source/x_component_process_Xform/lp/'+(option.lp || 'zh-cn')+'.js',
  731. // 'source/x_component_Selector/lp/'+(option.lp || 'zh-cn')+'.js',
  732. 'source/' + path + '/js/base_work_style_temp.js',
  733. 'source/o2_core/o2/widget/Common.js',
  734. 'source/o2_core/o2/widget/Dialog.js',
  735. 'source/o2_core/o2/widget/UUID.js',
  736. 'source/o2_core/o2/widget/Menu.js',
  737. 'source/o2_core/o2/widget/Toolbar.js',
  738. 'source/o2_core/o2/xDesktop/Common.js',
  739. 'source/o2_core/o2/xDesktop/Actions/RestActions.js',
  740. 'source/o2_core/o2/xAction/RestActions.js',
  741. 'source/o2_core/o2/xDesktop/Access.js',
  742. 'source/o2_core/o2/xDesktop/Dialog.js',
  743. 'source/o2_core/o2/xDesktop/Menu.js',
  744. 'source/o2_core/o2/xDesktop/UserData.js',
  745. 'source/x_component_Template/MPopupForm.js',
  746. 'source/o2_core/o2/xDesktop/Authentication.js',
  747. 'source/o2_core/o2/xDesktop/Window.js',
  748. 'source/x_component_Common/Main.js',
  749. 'source/x_component_process_Work/Main.js',
  750. 'source/x_component_Selector/package.js',
  751. 'source/x_component_Selector/Person.js',
  752. 'source/x_component_Selector/Identity.js',
  753. 'source/x_component_Selector/Unit.js',
  754. 'source/x_component_Selector/IdentityWidthDuty.js',
  755. 'source/x_component_Selector/IdentityWidthDutyCategoryByUnit.js',
  756. 'source/x_component_Selector/UnitWithType.js',
  757. 'source/o2_core/o2/xScript/Actions/UnitActions.js',
  758. 'source/o2_core/o2/xScript/Actions/ScriptActions.js',
  759. 'source/o2_core/o2/xScript/Actions/CMSScriptActions.js',
  760. 'source/o2_core/o2/xScript/Actions/PortalScriptActions.js',
  761. 'source/o2_core/o2/xScript/Environment.js',
  762. 'source/x_component_Template/MTooltips.js',
  763. 'source/x_component_Template/MSelector.js',
  764. 'source/o2_core/o2/xAction/services/x_organization_assemble_authentication.js',
  765. 'source/o2_core/o2/xAction/services/x_processplatform_assemble_surface.js',
  766. 'source/o2_core/o2/xAction/services/x_cms_assemble_control.js',
  767. 'source/o2_core/o2/xAction/services/x_organization_assemble_control.js',
  768. 'source/o2_core/o2/xAction/services/x_query_assemble_surface.js',
  769. 'source/o2_core/o2/xAction/services/x_organization_assemble_personal.js',
  770. 'source/' + path + '/js/base_work_actions_temp.js',
  771. 'source/' + path + '/js/base.js',
  772. 'source/' + path + '/js/base_loader.js'
  773. ];
  774. var dest = option.dest+'/' + path + '/';
  775. return gulp.src(src)
  776. .pipe(concat('js/base_work.js'))
  777. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  778. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  779. host: option.host,
  780. user: option.user || 'anonymous',
  781. pass: option.pass || '@anonymous',
  782. port: option.port || 21,
  783. remotePath: (option.remotePath || '/') + path
  784. })))
  785. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  786. host: option.host,
  787. user: option.user || 'anonymous',
  788. pass: option.pass || null,
  789. port: option.port || 22,
  790. remotePath: (option.remotePath || '/') + path
  791. })))
  792. .pipe(gulp.dest(dest))
  793. .pipe(sourcemaps.init())
  794. .pipe(concat('js/base_work.min.js'))
  795. .pipe(uglify())
  796. .pipe(sourcemaps.write("./"))
  797. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  798. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  799. host: option.host,
  800. user: option.user || 'anonymous',
  801. pass: option.pass || '@anonymous',
  802. port: option.port || 21,
  803. remotePath: (option.remotePath || '/') + path
  804. })))
  805. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  806. host: option.host,
  807. user: option.user || 'anonymous',
  808. pass: option.pass || null,
  809. port: option.port || 22,
  810. remotePath: (option.remotePath || '/') + path
  811. })))
  812. .pipe(gulp.dest(dest))
  813. }
  814. return setTaskName(task, path+".base_work : concat");
  815. }
  816. function createBaseWorkConcatLanguageTask(path, thisOptions, language){
  817. const task = function(){
  818. var option = thisOptions || options;
  819. var src = [
  820. 'source/o2_core/o2/lp/'+(language)+'.js',
  821. 'source/x_component_process_Work/lp/'+(language)+'.js',
  822. 'source/x_component_process_Xform/lp/'+(language)+'.js',
  823. 'source/x_component_Selector/lp/'+(language)+'.js',
  824. 'source/x_component_Template/lp/'+(language)+'.js',
  825. 'source/x_component_portal_Portal/lp/'+(language)+'.js',
  826. 'source/x_component_cms_Document/lp/'+(language)+'.js',
  827. 'source/x_component_cms_Xform/lp/'+(language)+'.js',
  828. ];
  829. var dest = option.dest+'/' + path + '/';
  830. return gulp.src(src, {allowEmpty: true})
  831. .pipe(concat('js/base_lp_'+language+'.js'))
  832. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  833. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  834. host: option.host,
  835. user: option.user || 'anonymous',
  836. pass: option.pass || '@anonymous',
  837. port: option.port || 21,
  838. remotePath: (option.remotePath || '/') + path
  839. })))
  840. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  841. host: option.host,
  842. user: option.user || 'anonymous',
  843. pass: option.pass || null,
  844. port: option.port || 22,
  845. remotePath: (option.remotePath || '/') + path
  846. })))
  847. .pipe(gulp.dest(dest))
  848. .pipe(uglify())
  849. .pipe(concat('js/base_lp_'+language+'.min.js'))
  850. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  851. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  852. host: option.host,
  853. user: option.user || 'anonymous',
  854. pass: option.pass || '@anonymous',
  855. port: option.port || 21,
  856. remotePath: (option.remotePath || '/') + path
  857. })))
  858. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  859. host: option.host,
  860. user: option.user || 'anonymous',
  861. pass: option.pass || null,
  862. port: option.port || 22,
  863. remotePath: (option.remotePath || '/') + path
  864. })))
  865. .pipe(gulp.dest(dest))
  866. }
  867. return setTaskName(task, path+".base_lp : "+language);
  868. }
  869. function createBaseWorkConcatTask(path, isMin, thisOptions){
  870. return gulp.series(
  871. createBaseWorkConcatActionTask(path),
  872. createBaseWorkConcatStyleTask(path),
  873. createBaseWorkConcatBodyTask(path, isMin, thisOptions),
  874. createBaseWorkConcatDelTempTask(path)
  875. );
  876. }
  877. function createBasePortalConcatStyleTask(path){
  878. const task = function(){
  879. return gulp.src([
  880. "source/x_component_process_Work/$Main/default/css.wcss",
  881. "source/x_component_portal_Portal/$Main/default/css.wcss",
  882. "source/x_component_process_Xform/$Form/default/css.wcss",
  883. "source/o2_core/o2/widget/$Tab/mobileForm/css.wcss",
  884. "source/o2_core/o2/widget/$Menu/tab/css.wcss"
  885. ])
  886. .pipe(concat_Style())
  887. .pipe(concat('js/base_portal_style_temp.js'))
  888. .pipe(gulp.dest('source/x_desktop/'))
  889. }
  890. return setTaskName(task, path+".base_portal : style");
  891. }
  892. function createBasePortalConcatActionTask(path){
  893. const task = function(){
  894. return gulp.src([
  895. "source/o2_core/o2/xAction/services/x_organization_assemble_authentication.json",
  896. "source/o2_core/o2/xAction/services/x_portal_assemble_surface.json",
  897. "source/o2_core/o2/xAction/services/x_processplatform_assemble_surface.json",
  898. "source/o2_core/o2/xAction/services/x_organization_assemble_control.json",
  899. "source/o2_core/o2/xAction/services/x_query_assemble_surface.json",
  900. "source/o2_core/o2/xAction/services/x_cms_assemble_control.json",
  901. "source/o2_core/o2/xAction/services/x_program_center.json",
  902. "source/o2_core/o2/xAction/services/x_organization_assemble_personal.json"
  903. ])
  904. .pipe(concat_Actions())
  905. .pipe(concat('js/base_portal_actions_temp.js'))
  906. .pipe(gulp.dest('source/x_desktop/'))
  907. }
  908. return setTaskName(task, path+".base_portal : action");
  909. }
  910. function createBasePortalConcatDelTempTask(path) {
  911. const task = function(cb){
  912. var dest = [
  913. 'source/'+path+'/js/base_portal_actions_temp.js',
  914. 'source/'+path+'/js/base_portal_style_temp.js'
  915. ];
  916. return del(dest, cb);
  917. }
  918. return setTaskName(task, path+".base_portal : clean");
  919. }
  920. function createBasePortalConcatBodyTask(path, isMin, thisOptions) {
  921. const task = function(){
  922. var option = thisOptions || options;
  923. var src = [
  924. 'source/' + path + '/js/base_concat_head.js',
  925. //'source/o2_core/o2/lp/'+(option.lp || 'zh-cn')+'.js',
  926. 'source/' + path + '/js/base_portal_style_temp.js',
  927. 'source/o2_core/o2/widget/Common.js',
  928. 'source/o2_core/o2/widget/Dialog.js',
  929. 'source/o2_core/o2/widget/UUID.js',
  930. 'source/o2_core/o2/widget/Menu.js',
  931. 'source/o2_core/o2/widget/Toolbar.js',
  932. 'source/o2_core/o2/xDesktop/Common.js',
  933. 'source/o2_core/o2/xDesktop/Actions/RestActions.js',
  934. 'source/o2_core/o2/xAction/RestActions.js',
  935. 'source/o2_core/o2/xDesktop/Access.js',
  936. 'source/o2_core/o2/xDesktop/Dialog.js',
  937. 'source/o2_core/o2/xDesktop/Menu.js',
  938. 'source/o2_core/o2/xDesktop/UserData.js',
  939. 'source/x_component_Template/MPopupForm.js',
  940. 'source/o2_core/o2/xDesktop/Authentication.js',
  941. 'source/o2_core/o2/xDesktop/Window.js',
  942. 'source/x_component_Common/Main.js',
  943. // 'source/x_component_process_Work/lp/'+(option.lp || 'zh-cn')+'.js',
  944. // 'source/x_component_portal_Portal/lp/'+(option.lp || 'zh-cn')+'.js',
  945. // 'source/x_component_process_Xform/lp/'+(option.lp || 'zh-cn')+'.js',
  946. // 'source/x_component_Selector/lp/'+(option.lp || 'zh-cn')+'.js',
  947. 'source/x_component_portal_Portal/Main.js',
  948. 'source/x_component_Selector/package.js',
  949. 'source/x_component_Selector/Person.js',
  950. 'source/x_component_Selector/Identity.js',
  951. 'source/x_component_Selector/Unit.js',
  952. 'source/x_component_Selector/IdentityWidthDuty.js',
  953. 'source/x_component_Selector/IdentityWidthDutyCategoryByUnit.js',
  954. 'source/x_component_Selector/UnitWithType.js',
  955. 'source/o2_core/o2/xScript/Actions/UnitActions.js',
  956. 'source/o2_core/o2/xScript/Actions/ScriptActions.js',
  957. 'source/o2_core/o2/xScript/Actions/CMSScriptActions.js',
  958. 'source/o2_core/o2/xScript/Actions/PortalScriptActions.js',
  959. 'source/o2_core/o2/xScript/PageEnvironment.js',
  960. 'source/o2_core/o2/xAction/services/x_organization_assemble_authentication.js',
  961. 'source/o2_core/o2/xAction/services/x_processplatform_assemble_surface.js',
  962. 'source/o2_core/o2/xAction/services/x_cms_assemble_control.js',
  963. 'source/o2_core/o2/xAction/services/x_organization_assemble_control.js',
  964. 'source/o2_core/o2/xAction/services/x_query_assemble_surface.js',
  965. 'source/o2_core/o2/xAction/services/x_organization_assemble_personal.js',
  966. 'source/' + path + '/js/base_portal_actions_temp.js',
  967. 'source/' + path + '/js/base.js',
  968. 'source/' + path + '/js/base_loader.js'
  969. ];
  970. var dest = option.dest+'/' + path + '/';
  971. return gulp.src(src)
  972. .pipe(concat('js/base_portal.js'))
  973. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  974. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  975. host: option.host,
  976. user: option.user || 'anonymous',
  977. pass: option.pass || '@anonymous',
  978. port: option.port || 21,
  979. remotePath: (option.remotePath || '/') + path
  980. })))
  981. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  982. host: option.host,
  983. user: option.user || 'anonymous',
  984. pass: option.pass || null,
  985. port: option.port || 22,
  986. remotePath: (option.remotePath || '/') + path
  987. })))
  988. .pipe(gulp.dest(dest))
  989. .pipe(sourcemaps.init())
  990. .pipe(concat('js/base_portal.min.js'))
  991. .pipe(uglify())
  992. .pipe(sourcemaps.write("./"))
  993. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  994. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  995. host: option.host,
  996. user: option.user || 'anonymous',
  997. pass: option.pass || '@anonymous',
  998. port: option.port || 21,
  999. remotePath: (option.remotePath || '/') + path
  1000. })))
  1001. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  1002. host: option.host,
  1003. user: option.user || 'anonymous',
  1004. pass: option.pass || null,
  1005. port: option.port || 22,
  1006. remotePath: (option.remotePath || '/') + path
  1007. })))
  1008. .pipe(gulp.dest(dest))
  1009. }
  1010. return setTaskName(task, path+".base_portal : concat");
  1011. }
  1012. function createBasePortalConcatTask(path, isMin, thisOptions){
  1013. return gulp.series(
  1014. createBasePortalConcatActionTask(path),
  1015. createBasePortalConcatStyleTask(path),
  1016. createBasePortalConcatBodyTask(path, isMin, thisOptions),
  1017. createBasePortalConcatDelTempTask(path)
  1018. );
  1019. }
  1020. function createBaseDocumentConcatActionTask(path){
  1021. const task = function(){
  1022. return gulp.src([
  1023. "source/o2_core/o2/xAction/services/x_organization_assemble_authentication.json",
  1024. "source/o2_core/o2/xAction/services/x_organization_assemble_control.json",
  1025. "source/o2_core/o2/xAction/services/x_cms_assemble_control.json",
  1026. "source/o2_core/o2/xAction/services/x_program_center.json",
  1027. "source/o2_core/o2/xAction/services/x_organization_assemble_personal.json"
  1028. ])
  1029. .pipe(concat_Actions())
  1030. .pipe(concat('js/base_document_actions_temp.js'))
  1031. .pipe(gulp.dest('source/x_desktop/'))
  1032. }
  1033. return setTaskName(task, path+".base_document : action");
  1034. }
  1035. function createBaseDocumentConcatStyleTask(path){
  1036. const task = function(){
  1037. return gulp.src([
  1038. "source/x_component_cms_Document/$Main/default/css.wcss",
  1039. "source/x_component_cms_Xform/$Form/default/css.wcss",
  1040. "source/o2_core/o2/widget/$AttachmentController/default/css.wcss"
  1041. ])
  1042. .pipe(concat_Style())
  1043. .pipe(concat('js/base_document_style_temp.js'))
  1044. .pipe(gulp.dest('source/x_desktop/'))
  1045. }
  1046. return setTaskName(task, path+".base_document : style");
  1047. }
  1048. function createBaseDocumentConcatBodyTask(path, isMin, thisOptions) {
  1049. const task = function(){
  1050. var option = thisOptions || options;
  1051. var src = [
  1052. 'source/' + path + '/js/base_concat_head.js',
  1053. //'source/o2_core/o2/lp/'+(option.lp || 'zh-cn')+'.js',
  1054. 'source/' + path + '/js/base_document_style_temp.js',
  1055. 'source/o2_core/o2/widget/Common.js',
  1056. 'source/o2_core/o2/widget/Dialog.js',
  1057. 'source/o2_core/o2/widget/UUID.js',
  1058. 'source/o2_core/o2/widget/Menu.js',
  1059. 'source/o2_core/o2/widget/Mask.js',
  1060. 'source/o2_core/o2/xDesktop/Common.js',
  1061. 'source/o2_core/o2/xDesktop/Actions/RestActions.js',
  1062. 'source/o2_core/o2/xAction/RestActions.js',
  1063. 'source/o2_core/o2/xDesktop/Access.js',
  1064. 'source/o2_core/o2/xDesktop/Dialog.js',
  1065. 'source/o2_core/o2/xDesktop/Menu.js',
  1066. 'source/o2_core/o2/xDesktop/UserData.js',
  1067. 'source/x_component_Template/MPopupForm.js',
  1068. 'source/o2_core/o2/xDesktop/Authentication.js',
  1069. 'source/o2_core/o2/xDesktop/Window.js',
  1070. 'source/x_component_Common/Main.js',
  1071. // 'source/x_component_cms_Document/lp/'+(option.lp || 'zh-cn')+'.js',
  1072. // 'source/x_component_process_Xform/lp/'+(option.lp || 'zh-cn')+'.js',
  1073. // 'source/x_component_Selector/lp/'+(option.lp || 'zh-cn')+'.js',
  1074. // 'source/x_component_cms_Xform/lp/'+(option.lp || 'zh-cn')+'.js',
  1075. 'source/x_component_cms_Document/Main.js',
  1076. 'source/x_component_Selector/package.js',
  1077. 'source/o2_core/o2/xScript/Actions/UnitActions.js',
  1078. 'source/o2_core/o2/xScript/Actions/CMSScriptActions.js',
  1079. 'source/o2_core/o2/xScript/CMSEnvironment.js',
  1080. 'source/o2_core/o2/xAction/services/x_organization_assemble_authentication.js',
  1081. 'source/o2_core/o2/xAction/services/x_cms_assemble_control.js',
  1082. 'source/o2_core/o2/xAction/services/x_organization_assemble_control.js',
  1083. 'source/o2_core/o2/xAction/services/x_organization_assemble_personal.js',
  1084. 'source/' + path + '/js/base_document_actions_temp.js',
  1085. 'source/' + path + '/js/base.js',
  1086. 'source/' + path + '/js/base_loader.js'
  1087. ];
  1088. var dest = option.dest+'/' + path + '/';
  1089. return gulp.src(src)
  1090. .pipe(concat('js/base_document.js'))
  1091. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  1092. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  1093. host: option.host,
  1094. user: option.user || 'anonymous',
  1095. pass: option.pass || '@anonymous',
  1096. port: option.port || 21,
  1097. remotePath: (option.remotePath || '/') + path
  1098. })))
  1099. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  1100. host: option.host,
  1101. user: option.user || 'anonymous',
  1102. pass: option.pass || null,
  1103. port: option.port || 22,
  1104. remotePath: (option.remotePath || '/') + path
  1105. })))
  1106. .pipe(gulp.dest(dest))
  1107. .pipe(sourcemaps.init())
  1108. .pipe(concat('js/base_document.min.js'))
  1109. .pipe(uglify())
  1110. .pipe(sourcemaps.write("./"))
  1111. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  1112. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  1113. host: option.host,
  1114. user: option.user || 'anonymous',
  1115. pass: option.pass || '@anonymous',
  1116. port: option.port || 21,
  1117. remotePath: (option.remotePath || '/') + path
  1118. })))
  1119. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  1120. host: option.host,
  1121. user: option.user || 'anonymous',
  1122. pass: option.pass || null,
  1123. port: option.port || 22,
  1124. remotePath: (option.remotePath || '/') + path
  1125. })))
  1126. .pipe(gulp.dest(dest))
  1127. }
  1128. return setTaskName(task, path+".base_document : concat");
  1129. }
  1130. function createBaseDocumentConcatDelTempTask(path) {
  1131. const task = function(cb){
  1132. var dest = [
  1133. 'source/'+path+'/js/base_document_actions_temp.js',
  1134. 'source/'+path+'/js/base_document_style_temp.js'
  1135. ];
  1136. return del(dest, cb);
  1137. }
  1138. return setTaskName(task, path+".base_document : clean")
  1139. }
  1140. function createBaseDocumentConcatTask(path, isMin, thisOptions){
  1141. return gulp.series(
  1142. createBaseDocumentConcatActionTask(path),
  1143. createBaseDocumentConcatStyleTask(path),
  1144. createBaseDocumentConcatBodyTask(path, isMin, thisOptions),
  1145. createBaseDocumentConcatDelTempTask(path)
  1146. )
  1147. }
  1148. function createBaseConcatTask(path, isMin, thisOptions){
  1149. const task = function(){
  1150. var option = thisOptions || options;
  1151. var src = [
  1152. 'source/' + path + '/js/base.js',
  1153. 'source/o2_core/o2/xScript/PageEnvironment.js',
  1154. 'source/o2_core/o2/framework.js',
  1155. 'source/' + path + '/js/base_loader.js'
  1156. ];
  1157. var dest = option.dest+'/' + path + '/';
  1158. return gulp.src(src)
  1159. .pipe(concat('js/base.js'))
  1160. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  1161. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  1162. host: option.host,
  1163. user: option.user || 'anonymous',
  1164. pass: option.pass || '@anonymous',
  1165. port: option.port || 21,
  1166. remotePath: (option.remotePath || '/') + path
  1167. })))
  1168. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  1169. host: option.host,
  1170. user: option.user || 'anonymous',
  1171. pass: option.pass || null,
  1172. port: option.port || 22,
  1173. remotePath: (option.remotePath || '/') + path
  1174. })))
  1175. .pipe(gulp.dest(dest))
  1176. .pipe(sourcemaps.init())
  1177. .pipe(concat('js/base.min.js'))
  1178. .pipe(uglify())
  1179. .pipe(sourcemaps.write("./"))
  1180. .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
  1181. .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
  1182. host: option.host,
  1183. user: option.user || 'anonymous',
  1184. pass: option.pass || '@anonymous',
  1185. port: option.port || 21,
  1186. remotePath: (option.remotePath || '/') + path
  1187. })))
  1188. .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
  1189. host: option.host,
  1190. user: option.user || 'anonymous',
  1191. pass: option.pass || null,
  1192. port: option.port || 22,
  1193. remotePath: (option.remotePath || '/') + path
  1194. })))
  1195. .pipe(gulp.dest(dest))
  1196. }
  1197. return setTaskName(task, path+".base")
  1198. }
  1199. var lpTasks = [];
  1200. function getAppTask(path, isMin, thisOptions) {
  1201. switch (path){
  1202. case 'x_component_process_Xform':
  1203. return gulp.series(
  1204. createLanguagePackTask(path),
  1205. createDefaultTask(path, isMin, thisOptions),
  1206. createXFormConcatTask(path, isMin, thisOptions)
  1207. );
  1208. case 'x_component_cms_Xform':
  1209. return gulp.series(
  1210. createLanguagePackTask(path),
  1211. createDefaultTask(path, isMin, thisOptions),
  1212. createCMSXFormConcatTask(path, isMin, thisOptions)
  1213. );
  1214. case 'o2_core':
  1215. return gulp.series(
  1216. createLanguagePackTask(path),
  1217. createDefaultTask(path, isMin, thisOptions),
  1218. createO2ConcatTask(path, isMin, thisOptions)
  1219. );
  1220. case 'x_desktop':
  1221. const tasks = supportedLanguage.map(function(lp){
  1222. return createBaseWorkConcatLanguageTask(path, thisOptions, lp);
  1223. });
  1224. return gulp.series(
  1225. createDefaultTask(path, isMin, thisOptions),
  1226. ...tasks,
  1227. createBaseWorkConcatTask(path, isMin, thisOptions),
  1228. createBasePortalConcatTask(path, isMin, thisOptions),
  1229. createBaseDocumentConcatTask(path, isMin, thisOptions),
  1230. createBaseConcatTask(path, isMin, thisOptions)
  1231. );
  1232. default:
  1233. return gulp.series(
  1234. createLanguagePackTask(path),
  1235. createDefaultTask(path, isMin, thisOptions)
  1236. );
  1237. }
  1238. }
  1239. apps.map(function (app) {
  1240. var taskName;
  1241. var isMin = (app.tasks.indexOf("min")!==-1);
  1242. taskName = app.folder;
  1243. appTasks.push(taskName);
  1244. gulp.task(taskName, getAppTask(app.folder, isMin));
  1245. });
  1246. function getCleanTask(path) {
  1247. return function (cb) {
  1248. const p = path || '/';
  1249. if (p){
  1250. var dest = (path=="/") ? options.dest+"/" : options.dest+'/' + path + '/';
  1251. gutil.log("Clean", ":", gutil.colors.red(dest));
  1252. del.sync(dest, cb);
  1253. cb();
  1254. }else{
  1255. cb();
  1256. }
  1257. }
  1258. }
  1259. function cleanRemoteFtp(f, cb) {
  1260. var file = options.remotePath + f;
  1261. var ftp = new JSFtp({
  1262. host: options.host,
  1263. user: options.user || 'anonymous',
  1264. pass: options.pass || null,
  1265. port: options.port || 21
  1266. });
  1267. ftp.raw('dele ' + file, function (err) {
  1268. if (err) { cb(); return; }
  1269. if (file.substring(file.length - 3).toLowerCase() == ".js") {
  1270. file = file.replace('.js', ".min.js");
  1271. ftp.raw('dele ' + file, function (err) {
  1272. if (err) { cb(); return; }
  1273. if (file.indexOf("/") != -1) {
  1274. var p = file.substring(0, file.lastIndexOf("/"));
  1275. ftp.raw('rmd ' + p, function (err) {
  1276. if (err) { cb(); return; }
  1277. ftp.raw.quit();
  1278. cb();
  1279. });
  1280. }
  1281. });
  1282. } else {
  1283. if (file.indexOf("/") != -1) {
  1284. var pPath = file.substring(0, file.lastIndexOf("/"));
  1285. ftp.raw('rmd ' + pPath, function (err) {
  1286. if (err) { cb(); return; }
  1287. ftp.raw.quit();
  1288. cb();
  1289. });
  1290. }
  1291. }
  1292. });
  1293. }
  1294. function cleanRemoteLocal(f, cb) {
  1295. var file = options.location + f;
  1296. del(file, { force: true, dryRun: true }, function () {
  1297. if (file.substring(file.length - 3).toLowerCase() == ".js") {
  1298. var minfile = file.replace('.js', ".min.js");
  1299. del(minfile, { force: true, dryRun: true }, function () {
  1300. var p = file.substring(0, file.lastIndexOf("/"));
  1301. fs.rmdir(p, function (err) {
  1302. if (err) { }
  1303. cb();
  1304. })
  1305. });
  1306. } else {
  1307. var p = file.substring(0, file.lastIndexOf("/"));
  1308. fs.rmdir(p, function (err) {
  1309. if (err) { }
  1310. cb();
  1311. })
  1312. }
  1313. });
  1314. }
  1315. function getCleanRemoteTask(path) {
  1316. return function (cb) {
  1317. if (options.upload) {
  1318. var file = path.replace(/\\/g, "/");
  1319. file = file.substring(file.indexOf("source/") + 7);
  1320. if (options.upload == 'local' && options.location != '') cleanRemoteLocal(file, cb);
  1321. if (options.upload == 'ftp' && options.host != '') cleanRemoteFtp(file, cb);
  1322. } else {
  1323. if (cb) cb();
  1324. }
  1325. }
  1326. }
  1327. function getWatchTask(path) {
  1328. var lpFiles = supportedLanguage.filter(function(l){
  1329. return l !== "zh-cn";
  1330. }).join("|");
  1331. return (path) ? function (cb) {
  1332. gutil.log("watch", ":", gutil.colors.green(path, "is watching ..."));
  1333. gulp.watch(['source/' + path + '/**/*', "!./**/test/**", '!**/lp/('+lpFiles+').js'], { "events": ['addDir', 'add', 'change'] }, gulp.parallel([path]));
  1334. } : function(cb){cb();};
  1335. }
  1336. gulp.task("clean", getCleanTask(options.src))
  1337. gulp.task("watch", getWatchTask(options.src));
  1338. function index() {
  1339. var src = ['source/favicon.ico', 'source/index.html'];
  1340. var dest = options.dest;
  1341. return gulp.src(src)
  1342. .pipe(changed(dest))
  1343. .pipe(gulpif((options.upload == 'local' && options.location != ''), gulp.dest(options.location + '/')))
  1344. .pipe(gulpif((options.upload == 'ftp' && options.host != ''), ftp({
  1345. host: options.host,
  1346. user: options.user || 'anonymous',
  1347. pass: options.pass || '@anonymous',
  1348. port: options.port || 21,
  1349. remotePath: (options.remotePath || '/')
  1350. })))
  1351. .pipe(gulpif((options.upload == 'sftp' && options.host != ''), ftp({
  1352. host: options.host,
  1353. user: options.user || 'anonymous',
  1354. pass: options.pass || null,
  1355. port: options.port || 22,
  1356. remotePath: (options.remotePath || '/')
  1357. })))
  1358. .pipe(gulp.dest(dest))
  1359. .pipe(gutil.noop());
  1360. }
  1361. function getGitV(){
  1362. var tagPromise = new Promise(function(s){
  1363. git.exec({args : 'describe --tag'}, function (err, stdout) {
  1364. var v = stdout.substring(0, stdout.lastIndexOf("-"));
  1365. s(v);
  1366. });
  1367. });
  1368. var revPromise = new Promise(function(s){
  1369. git.exec({args : 'rev-parse --short HEAD'}, function (err, hash) {
  1370. s(hash.trim());
  1371. });
  1372. });
  1373. return Promise.all([tagPromise,revPromise])
  1374. }
  1375. function o2_version_html(){
  1376. var path = "x_desktop";
  1377. var src = 'source/x_desktop/*.html';
  1378. var dest = options.dest + '/x_desktop/';
  1379. return getGitV().then(function(arr) {
  1380. return gulp.src(src)
  1381. .pipe(assetRev({"verConnecter": arr[0], "md5": arr[1]}))
  1382. .pipe(gulpif((options.upload == 'local' && options.location != ''), gulp.dest(options.location + path + '/')))
  1383. .pipe(gulpif((options.upload == 'ftp' && options.host != ''), ftp({
  1384. host: options.host,
  1385. user: options.user || 'anonymous',
  1386. pass: options.pass || '@anonymous',
  1387. port: options.port || 21,
  1388. remotePath: (options.remotePath || '/') + path
  1389. })))
  1390. .pipe(gulpif((options.upload == 'sftp' && options.host != ''), sftp({
  1391. host: options.host,
  1392. user: options.user || 'anonymous',
  1393. pass: options.pass || null,
  1394. port: options.port || 22,
  1395. remotePath: (options.remotePath || '/') + path
  1396. })))
  1397. .pipe(gulp.dest(dest))
  1398. .pipe(gutil.noop());
  1399. });
  1400. }
  1401. function o2_version_o2(){
  1402. var path = "o2_core";
  1403. var src = options.dest +'/o2_core/o2.js';
  1404. var dest = options.dest +'/o2_core/';
  1405. return getGitV().then(function(arr){
  1406. var v = arr[0]+"-"+arr[1];
  1407. return gulp.src(src)
  1408. .pipe(assetRev({"verConnecter": arr[0], "md5": arr[1], "replace": true}))
  1409. .pipe(gulpif((options.upload == 'local' && options.location != ''), gulp.dest(options.location + path + '/')))
  1410. .pipe(gulpif((options.upload == 'ftp' && options.host != ''), ftp({
  1411. host: options.host,
  1412. user: options.user || 'anonymous',
  1413. pass: options.pass || '@anonymous',
  1414. port: options.port || 21,
  1415. remotePath: (options.remotePath || '/') + path
  1416. })))
  1417. .pipe(gulpif((options.upload == 'sftp' && options.host != ''), sftp({
  1418. host: options.host,
  1419. user: options.user || 'anonymous',
  1420. pass: options.pass || null,
  1421. port: options.port || 22,
  1422. remotePath: (options.remotePath || '/') + path
  1423. })))
  1424. .pipe(gulp.dest(dest))
  1425. .pipe(uglify())
  1426. .pipe(rename({ extname: '.min.js' }))
  1427. .pipe(gulpif((options.upload == 'local' && options.location != ''), gulp.dest(options.location + path + '/')))
  1428. .pipe(gulpif((options.upload == 'ftp' && options.host != ''), ftp({
  1429. host: options.host,
  1430. user: options.user || 'anonymous',
  1431. pass: options.pass || '@anonymous',
  1432. port: options.port || 21,
  1433. remotePath: (options.remotePath || '/') + path
  1434. })))
  1435. .pipe(gulpif((options.upload == 'sftp' && options.host != ''), sftp({
  1436. host: options.host,
  1437. user: options.user || 'anonymous',
  1438. pass: options.pass || null,
  1439. port: options.port || 22,
  1440. remotePath: (options.remotePath || '/') + path
  1441. })))
  1442. .pipe(gulp.dest(dest))
  1443. .pipe(gutil.noop());
  1444. });
  1445. }
  1446. const version = gulp.parallel(o2_version_o2, o2_version_html);
  1447. exports.o2_version = version;
  1448. function build(){
  1449. options.ev = "p";
  1450. options.upload = o_options.upload || "";
  1451. options.location = o_options.location || uploadOptions.location;
  1452. options.host = o_options.host || uploadOptions.host;
  1453. options.user = o_options.user || uploadOptions.user;
  1454. options.pass = o_options.pass || uploadOptions.pass;
  1455. options.port = o_options.port || uploadOptions.port;
  1456. options.remotePath = o_options.remotePath || uploadOptions.remotePath;
  1457. options.dest = o_options.dest || uploadOptions.dest || "dest";
  1458. };
  1459. exports.default = gulp.series("clean", gulp.parallel(appTasks, index), version);