gulpfile.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462
  1. var gulp = require('gulp'),
  2. //var deleted = require('gulp-deleted');
  3. del = require('del'),
  4. uglify = require('gulp-tm-uglify'),
  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'),
  11. JSFtp = require('jsftp'),
  12. gutil = require('gulp-util'),
  13. fs = require("fs");
  14. var assetRev = require('gulp-tm-asset-rev');
  15. var apps = [
  16. {"folder": "o2_lib", "tasks": ["move", "clean"]},
  17. {"folder": "o2_core", "tasks": ["move", "min", "clean", "watch"]},
  18. {"folder": "x_component_ANN", "tasks": ["move", "min", "clean", "watch"]},
  19. {"folder": "x_component_AppCenter", "tasks": ["move", "min", "clean", "watch"]},
  20. {"folder": "x_component_AppMarket", "tasks": ["move", "min", "clean", "watch"]},
  21. {"folder": "x_component_Attendance", "tasks": ["move", "min", "clean", "watch"]},
  22. {"folder": "x_component_BAM", "tasks": ["move", "min", "clean", "watch"]},
  23. {"folder": "x_component_Calendar", "tasks": ["move", "min", "clean", "watch"]},
  24. {"folder": "x_component_Chat", "tasks": ["move", "min", "clean", "watch"]},
  25. {"folder": "x_component_cms_Column", "tasks": ["move", "min", "clean", "watch"]},
  26. {"folder": "x_component_cms_ColumnManager", "tasks": ["move", "min", "clean", "watch"]},
  27. {"folder": "x_component_cms_DictionaryDesigner", "tasks": ["move", "min", "clean", "watch"]},
  28. {"folder": "x_component_cms_Document", "tasks": ["move", "min", "clean", "watch"]},
  29. {"folder": "x_component_cms_FormDesigner", "tasks": ["move", "min", "clean", "watch"]},
  30. {"folder": "x_component_cms_Index", "tasks": ["move", "min", "clean", "watch"]},
  31. {"folder": "x_component_cms_Module", "tasks": ["move", "min", "clean", "watch"]},
  32. {"folder": "x_component_cms_QueryViewDesigner", "tasks": ["move", "min", "clean", "watch"]},
  33. {"folder": "x_component_cms_ScriptDesigner", "tasks": ["move", "min", "clean", "watch"]},
  34. {"folder": "x_component_cms_ViewDesigner", "tasks": ["move", "min", "clean", "watch"]},
  35. {"folder": "x_component_cms_Xform", "tasks": ["move", "min", "clean", "watch"]},
  36. {"folder": "x_component_Collect", "tasks": ["move", "min", "clean", "watch"]},
  37. {"folder": "x_component_Common", "tasks": ["move", "min", "clean", "watch"]},
  38. {"folder": "x_component_Console", "tasks": ["move", "min", "clean", "watch"]},
  39. {"folder": "x_component_ControlPanel", "tasks": ["move", "min", "clean", "watch"]},
  40. {"folder": "x_component_CRM", "tasks": ["move", "min", "clean", "watch"]},
  41. {"folder": "x_component_Deployment", "tasks": ["move", "min", "clean", "watch"]},
  42. {"folder": "x_component_DesignCenter", "tasks": ["move", "min", "clean", "watch"]},
  43. {"folder": "x_component_Empty", "tasks": ["move", "min", "clean", "watch"]},
  44. {"folder": "x_component_Execution", "tasks": ["move", "min", "clean", "watch"]},
  45. {"folder": "x_component_ExeManager", "tasks": ["move", "min", "clean", "watch"]},
  46. {"folder": "x_component_FaceSet", "tasks": ["move", "min", "clean", "watch"]},
  47. {"folder": "x_component_File", "tasks": ["move", "min", "clean", "watch"]},
  48. {"folder": "x_component_Forum", "tasks": ["move", "min", "clean", "watch"]},
  49. {"folder": "x_component_ForumCategory", "tasks": ["move", "min", "clean", "watch"]},
  50. {"folder": "x_component_ForumDocument", "tasks": ["move", "min", "clean", "watch"]},
  51. {"folder": "x_component_ForumPerson", "tasks": ["move", "min", "clean", "watch"]},
  52. {"folder": "x_component_ForumSearch", "tasks": ["move", "min", "clean", "watch"]},
  53. {"folder": "x_component_ForumSection", "tasks": ["move", "min", "clean", "watch"]},
  54. {"folder": "x_component_HotArticle", "tasks": ["move", "min", "clean", "watch"]},
  55. {"folder": "x_component_IM", "tasks": ["move", "min", "clean", "watch"]},
  56. {"folder": "x_component_LogViewer", "tasks": ["move", "min", "clean", "watch"]},
  57. {"folder": "x_component_Meeting", "tasks": ["move", "min", "clean", "watch"]},
  58. {"folder": "x_component_Message", "tasks": ["move", "min", "clean", "watch"]},
  59. {"folder": "x_component_Minder", "tasks": ["move", "min", "clean", "watch"]},
  60. {"folder": "x_component_MinderEditor", "tasks": ["move", "min", "clean", "watch"]},
  61. {"folder": "x_component_Note", "tasks": ["move", "min", "clean", "watch"]},
  62. {"folder": "x_component_OKR", "tasks": ["move", "min", "clean", "watch"]},
  63. {"folder": "x_component_OnlineMeeting", "tasks": ["move", "min", "clean", "watch"]},
  64. {"folder": "x_component_OnlineMeetingRoom", "tasks": ["move", "min", "clean", "watch"]},
  65. {"folder": "x_component_Org", "tasks": ["move", "min", "clean", "watch"]},
  66. {"folder": "x_component_portal_PageDesigner", "tasks": ["move", "min", "clean", "watch"]},
  67. {"folder": "x_component_portal_Portal", "tasks": ["move", "min", "clean", "watch"]},
  68. {"folder": "x_component_portal_PortalExplorer", "tasks": ["move", "min", "clean", "watch"]},
  69. {"folder": "x_component_portal_PortalManager", "tasks": ["move", "min", "clean", "watch"]},
  70. {"folder": "x_component_portal_ScriptDesigner", "tasks": ["move", "min", "clean", "watch"]},
  71. {"folder": "x_component_portal_WidgetDesigner", "tasks": ["move", "min", "clean", "watch"]},
  72. {"folder": "x_component_process_Application", "tasks": ["move", "min", "clean", "watch"]},
  73. {"folder": "x_component_process_ApplicationExplorer", "tasks": ["move", "min", "clean", "watch"]},
  74. {"folder": "x_component_process_ApplicationExplorer1", "tasks": ["move", "min", "clean", "watch"]},
  75. {"folder": "x_component_process_DictionaryDesigner", "tasks": ["move", "min", "clean", "watch"]},
  76. {"folder": "x_component_process_FormDesigner", "tasks": ["move", "min", "clean", "watch"]},
  77. {"folder": "x_component_process_ProcessDesigner", "tasks": ["move", "min", "clean", "watch"]},
  78. {"folder": "x_component_process_ProcessManager", "tasks": ["move", "min", "clean", "watch"]},
  79. // {"folder": "x_component_process_ProjectionDesigner", "tasks": ["move", "min", "clean", "watch"]},
  80. {"folder": "x_component_process_ScriptDesigner", "tasks": ["move", "min", "clean", "watch"]},
  81. {"folder": "x_component_process_StatDesigner", "tasks": ["move", "min", "clean", "watch"]},
  82. {"folder": "x_component_process_TaskCenter", "tasks": ["move", "min", "clean", "watch"]},
  83. {"folder": "x_component_process_ViewDesigner", "tasks": ["move", "min", "clean", "watch"]},
  84. {"folder": "x_component_process_Work", "tasks": ["move", "min", "clean", "watch"]},
  85. {"folder": "x_component_process_Xform", "tasks": ["move", "min", "clean", "watch"]},
  86. {"folder": "x_component_process_Xform2", "tasks": ["move", "min", "clean", "watch"]},
  87. {"folder": "x_component_Profile", "tasks": ["move", "min", "clean", "watch"]},
  88. {"folder": "x_component_query_Query", "tasks": ["move", "min", "clean", "watch"]},
  89. {"folder": "x_component_query_QueryExplorer", "tasks": ["move", "min", "clean", "watch"]},
  90. {"folder": "x_component_query_QueryManager", "tasks": ["move", "min", "clean", "watch"]},
  91. {"folder": "x_component_query_StatDesigner", "tasks": ["move", "min", "clean", "watch"]},
  92. {"folder": "x_component_query_ViewDesigner", "tasks": ["move", "min", "clean", "watch"]},
  93. {"folder": "x_component_query_TableDesigner", "tasks": ["move", "min", "clean", "watch"]},
  94. {"folder": "x_component_query_StatementDesigner", "tasks": ["move", "min", "clean", "watch"]},
  95. {"folder": "x_component_Report", "tasks": ["move", "min", "clean", "watch"]},
  96. {"folder": "x_component_ReportDocument", "tasks": ["move", "min", "clean", "watch"]},
  97. {"folder": "x_component_ReportMinder", "tasks": ["move", "min", "clean", "watch"]},
  98. {"folder": "x_component_ScriptEditor", "tasks": ["move", "min", "clean", "watch"]},
  99. {"folder": "x_component_Search", "tasks": ["move", "min", "clean", "watch"]},
  100. {"folder": "x_component_SelecterTest", "tasks": ["move", "min", "clean", "watch"]},
  101. {"folder": "x_component_Selector", "tasks": ["move", "min", "clean", "watch"]},
  102. {"folder": "x_component_service_AgentDesigner", "tasks": ["move", "min", "clean", "watch"]},
  103. {"folder": "x_component_service_InvokeDesigner", "tasks": ["move", "min", "clean", "watch"]},
  104. {"folder": "x_component_service_ServiceManager", "tasks": ["move", "min", "clean", "watch"]},
  105. {"folder": "x_component_Setting", "tasks": ["move", "min", "clean", "watch"]},
  106. {"folder": "x_component_SmartOfficeRoom", "tasks": ["move", "min", "clean", "watch"]},
  107. {"folder": "x_component_Snake", "tasks": ["move", "min", "clean", "watch"]},
  108. {"folder": "x_component_Strategy", "tasks": ["move", "min", "clean", "watch"]},
  109. {"folder": "x_component_Template", "tasks": ["move", "min", "clean", "watch"]},
  110. {"folder": "x_component_TeamWork", "tasks": ["move", "min", "clean", "watch"]},
  111. {"folder": "x_component_Weixin", "tasks": ["move", "min", "clean", "watch"]},
  112. {"folder": "x_desktop", "tasks": ["move", "min", "clean", "watch"]}
  113. ];
  114. var uploadOptions = {
  115. 'location': 'E:/o2server/servers/webServer/',
  116. 'host': 'dev.o2oa.net',
  117. 'user': 'xadmin',
  118. 'pass': 'o2No.one',
  119. "remotePath": "/"
  120. };
  121. // var uploadOptions = {
  122. // 'location': 'E:/o2server/servers/webServer/',
  123. // 'host': '10.217.243.23',
  124. // "port": "8022",
  125. // 'user': 'lande',
  126. // 'pass': 'Zone2009',
  127. // "remotePath": "/data/o2server/servers/webServer/"
  128. // };
  129. var options = minimist(process.argv.slice(2), {//upload: local ftp or sftp
  130. string: ["upload", "location", "host", "user", "pass", "port", "remotePath"]
  131. });
  132. options.upload = options.upload || "";
  133. options.location = options.location || uploadOptions.location;
  134. options.host = options.host || uploadOptions.host;
  135. options.user = options.user || uploadOptions.user;
  136. options.pass = options.pass || uploadOptions.pass;
  137. options.port = options.port || uploadOptions.port;
  138. options.remotePath = options.remotePath || uploadOptions.remotePath;
  139. console.log(options.host);
  140. console.log(options.user);
  141. console.log(options.pass);
  142. console.log(options.port);
  143. console.log(options.remotePath);
  144. var minTasks = [];
  145. var moveTasks = [];
  146. var watchTasks = [];
  147. var cleanTasks = [];
  148. function getMinTask(path){
  149. return function(){
  150. var src = 'source/'+path+'/**/*.js';
  151. var dest = 'dest/'+path+'/';
  152. return gulp.src(src)
  153. .pipe(changed(dest))
  154. .pipe(uglify())
  155. .pipe(rename({ extname: '.min.js' }))
  156. .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+path+'/')))
  157. .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
  158. host: options.host,
  159. user: options.user || 'anonymous',
  160. pass: options.pass || '@anonymous',
  161. port: options.port || 21,
  162. remotePath: (options.remotePath || '/')+path
  163. })))
  164. .pipe(gulpif((options.upload=='sftp'&&options.host!=''), sftp({
  165. host: options.host,
  166. user: options.user || 'anonymous',
  167. pass: options.pass || null,
  168. port: options.port || 22,
  169. remotePath: (options.remotePath || '/')+path
  170. })))
  171. .pipe(gulp.dest(dest))
  172. .pipe(gutil.noop());
  173. }
  174. }
  175. function getMoveTask(path){
  176. return function(){
  177. var src = 'source/'+path+'/**/*';
  178. var dest = 'dest/'+path+'/';
  179. return gulp.src(src)
  180. .pipe(changed(dest))
  181. .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+path+'/')))
  182. .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
  183. host: options.host,
  184. user: options.user || 'anonymous',
  185. pass: options.pass || '@anonymous',
  186. port: options.port || 21,
  187. remotePath: (options.remotePath || '/')+path
  188. })))
  189. .pipe(gulpif((options.upload=='sftp'&&options.host!=''), sftp({
  190. host: options.host,
  191. user: options.user || 'anonymous',
  192. pass: options.pass || null,
  193. port: options.port || 22,
  194. remotePath: (options.remotePath || '/')+path
  195. })))
  196. .pipe(gulp.dest(dest))
  197. .pipe(gutil.noop());
  198. }
  199. }
  200. function getCleanTask(path){
  201. return function(cb){
  202. var dest = 'dest/'+path+'/';
  203. del(dest, cb);
  204. }
  205. }
  206. function cleanRemoteFtp(f, cb){
  207. var file = options.remotePath+f;
  208. var ftp = new JSFtp({
  209. host: options.host,
  210. user: options.user || 'anonymous',
  211. pass: options.pass || null,
  212. port: options.port || 21
  213. });
  214. ftp.raw('dele '+file, function(err) {
  215. if (err){ cb(); return; }
  216. if (file.substring(file.length-3).toLowerCase()==".js"){
  217. file = file.replace('.js', ".min.js");
  218. ftp.raw('dele '+file, function(err) {
  219. if (err){ cb(); return; }
  220. if (file.indexOf("/")!=-1){
  221. var p = file.substring(0, file.lastIndexOf("/"));
  222. ftp.raw('rmd '+p, function(err) {
  223. if (err){ cb(); return; }
  224. ftp.raw.quit();
  225. cb();
  226. });
  227. }
  228. });
  229. }else{
  230. if (file.indexOf("/")!=-1){
  231. var pPath = file.substring(0, file.lastIndexOf("/"));
  232. ftp.raw('rmd '+pPath, function(err) {
  233. if (err){ cb(); return; }
  234. ftp.raw.quit();
  235. cb();
  236. });
  237. }
  238. }
  239. });
  240. }
  241. function cleanRemoteLocal(f, cb){
  242. var file = options.location+f;
  243. del(file, {force: true, dryRun: true}, function(){
  244. if (file.substring(file.length-3).toLowerCase()==".js"){
  245. var minfile = file.replace('.js', ".min.js");
  246. del(minfile, {force: true, dryRun: true}, function(){
  247. var p = file.substring(0, file.lastIndexOf("/"));
  248. fs.rmdir(p,function(err){
  249. if(err){}
  250. cb();
  251. })
  252. });
  253. }else{
  254. var p = file.substring(0, file.lastIndexOf("/"));
  255. fs.rmdir(p,function(err){
  256. if(err){}
  257. cb();
  258. })
  259. }
  260. });
  261. }
  262. function getCleanRemoteTask(path){
  263. return function(cb){
  264. if (options.upload){
  265. var file = path.replace(/\\/g, "/");
  266. file = file.substring(file.indexOf("source/")+7);
  267. if (options.upload=='local'&&options.location!='') cleanRemoteLocal(file, cb);
  268. if (options.upload=='ftp'&&options.host!='') cleanRemoteFtp(file, cb);
  269. }else{
  270. if (cb) cb();
  271. }
  272. }
  273. }
  274. function getWatchTask(path, min){
  275. return function(cb){
  276. var moveTask = "move:"+path;
  277. var minTask = "min:"+path;
  278. var cleanTask = "clean:"+path;
  279. if (min) gulp.watch('source/'+path+'/**/*.js', {"events": ['add','change']}, gulp.parallel(minTask));
  280. gulp.watch('source/'+path+'/**/*', {"events": ['addDir', 'add','change']}, gulp.parallel(moveTask));
  281. // gulp.watch('source/'+path+'/**/*', {"events": ['unlinkDir']}, function(file){
  282. // console.log("into unlinkDir watch ......."+file);
  283. // });
  284. watcher = gulp.watch('source/'+path+'/**/*', {delay:500});
  285. watcher.on('unlink', function(file, stats){
  286. console.log("into unlink watch ......."+file);
  287. gulp.task("cleanRemote", getCleanRemoteTask(file))
  288. gulp.series(gulp.parallel(cleanTask, "cleanRemote"), gulp.parallel(minTask, moveTask))();
  289. });
  290. // watcher.on('unlinkDir', function(file, stats){
  291. // console.log("into unlinkDir watch ......."+file);
  292. // // gulp.task("cleanRemoteDir", getCleanRemoteTask(file))
  293. // // gulp.series(gulp.parallel(cleanTask, "cleanRemoteDir"), gulp.parallel(minTask, moveTask))();
  294. // });
  295. }
  296. }
  297. apps.map(function(app){
  298. var taskName = "";
  299. if (app.tasks.indexOf("min")!==-1){
  300. taskName = "min:"+app.folder;
  301. minTasks.push(taskName);
  302. gulp.task(taskName, getMinTask(app.folder));
  303. }
  304. if (app.tasks.indexOf("move")!==-1){
  305. taskName = "move:"+app.folder;
  306. moveTasks.push(taskName);
  307. gulp.task(taskName, getMoveTask(app.folder));
  308. }
  309. if (app.tasks.indexOf("clean")!==-1){
  310. taskName = "clean:"+app.folder;
  311. cleanTasks.push(taskName);
  312. gulp.task(taskName, getCleanTask(app.folder));
  313. }
  314. if (app.tasks.indexOf("watch")!==-1){
  315. taskName = "watch:"+app.folder;
  316. watchTasks.push(taskName);
  317. gulp.task(taskName, getWatchTask(app.folder, (app.tasks.indexOf("min")!==-1)));
  318. }
  319. if (app.tasks.indexOf("min")!==-1 && app.tasks.indexOf("move")!==-1){
  320. gulp.task(app.folder, gulp.parallel("min:"+app.folder, "move:"+app.folder));
  321. }else if (app.tasks.indexOf("min")==-1 && app.tasks.indexOf("move")!==-1){
  322. gulp.task(app.folder, gulp.parallel("move:"+app.folder));
  323. }else if (app.tasks.indexOf("min")!==-1 && app.tasks.indexOf("move")==-1){
  324. gulp.task(app.folder, gulp.parallel("min:"+app.folder));
  325. }
  326. });
  327. gulp.task("index", function(){
  328. var src = ['source/favicon.ico', 'source/index.html'];
  329. var dest = "dest"
  330. return gulp.src(src)
  331. .pipe(changed(dest))
  332. .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+'/')))
  333. .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
  334. host: options.host,
  335. user: options.user || 'anonymous',
  336. pass: options.pass || '@anonymous',
  337. port: options.port || 21,
  338. remotePath: (options.remotePath || '/')
  339. })))
  340. .pipe(gulpif((options.upload=='sftp'&&options.host!=''), ftp({
  341. host: options.host,
  342. user: options.user || 'anonymous',
  343. pass: options.pass || null,
  344. port: options.port || 22,
  345. remotePath: (options.remotePath || '/')
  346. })))
  347. .pipe(gulp.dest(dest))
  348. .pipe(gutil.noop());
  349. });
  350. gulp.task("clean", gulp.series(cleanTasks));
  351. gulp.task("sync", gulp.series(
  352. gulp.series(cleanTasks),
  353. gulp.parallel(minTasks, moveTasks, 'index')
  354. ));
  355. gulp.task("watch", gulp.parallel(watchTasks));
  356. gulp.task("git_clean", function(cb){
  357. var dest = 'D:/O2/github/huqi1980/o2oa/o2web/source/';
  358. del(dest, {dryRun: true, force: true}, cb);
  359. });
  360. gulp.task("git_dest", function(){
  361. var dest = "D:/O2/github/huqi1980/o2oa/o2web/source";
  362. return gulp.src("source/**/*")
  363. .pipe(changed(dest))
  364. .pipe(gulp.dest(dest))
  365. });
  366. gulp.task("git", gulp.series('git_clean', 'git_dest'));
  367. gulp.task("o2:new-v:html", function () {
  368. var path = "x_desktop";
  369. var src = 'source/x_desktop/*.html';
  370. var dest = 'dest/x_desktop/';
  371. return gulp.src(src)
  372. .pipe(assetRev())
  373. .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+path+'/')))
  374. .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
  375. host: options.host,
  376. user: options.user || 'anonymous',
  377. pass: options.pass || '@anonymous',
  378. port: options.port || 21,
  379. remotePath: (options.remotePath || '/')+path
  380. })))
  381. .pipe(gulpif((options.upload=='sftp'&&options.host!=''), sftp({
  382. host: options.host,
  383. user: options.user || 'anonymous',
  384. pass: options.pass || null,
  385. port: options.port || 22,
  386. remotePath: (options.remotePath || '/')+path
  387. })))
  388. .pipe(gulp.dest(dest))
  389. .pipe(gutil.noop());
  390. });
  391. gulp.task("o2:new-v:o2", function () {
  392. var path = "o2_core";
  393. var src = 'source/o2_core/o2.js';
  394. var dest = 'dest/o2_core/';
  395. return gulp.src(src)
  396. .pipe(assetRev())
  397. .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+path+'/')))
  398. .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
  399. host: options.host,
  400. user: options.user || 'anonymous',
  401. pass: options.pass || '@anonymous',
  402. port: options.port || 21,
  403. remotePath: (options.remotePath || '/')+path
  404. })))
  405. .pipe(gulpif((options.upload=='sftp'&&options.host!=''), sftp({
  406. host: options.host,
  407. user: options.user || 'anonymous',
  408. pass: options.pass || null,
  409. port: options.port || 22,
  410. remotePath: (options.remotePath || '/')+path
  411. })))
  412. .pipe(gulp.dest(dest))
  413. .pipe(uglify())
  414. .pipe(rename({ extname: '.min.js' }))
  415. .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+path+'/')))
  416. .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
  417. host: options.host,
  418. user: options.user || 'anonymous',
  419. pass: options.pass || '@anonymous',
  420. port: options.port || 21,
  421. remotePath: (options.remotePath || '/')+path
  422. })))
  423. .pipe(gulpif((options.upload=='sftp'&&options.host!=''), sftp({
  424. host: options.host,
  425. user: options.user || 'anonymous',
  426. pass: options.pass || null,
  427. port: options.port || 22,
  428. remotePath: (options.remotePath || '/')+path
  429. })))
  430. .pipe(gulp.dest(dest))
  431. .pipe(gutil.noop());
  432. });
  433. gulp.task("o2:new-v", gulp.parallel("o2:new-v:o2", "o2:new-v:html"));
  434. gulp.task("default", gulp.series("clean", gulp.parallel(minTasks, moveTasks, 'index'), "o2:new-v"));