gulpfile.js 66 KB

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