|
|
@@ -1,5 +1,5 @@
|
|
|
var gulp = require('gulp'),
|
|
|
-//var deleted = require('gulp-deleted');
|
|
|
+ //var deleted = require('gulp-deleted');
|
|
|
del = require('del'),
|
|
|
uglify = require('gulp-tm-uglify'),
|
|
|
rename = require('gulp-rename'),
|
|
|
@@ -11,114 +11,28 @@ var gulp = require('gulp'),
|
|
|
JSFtp = require('jsftp'),
|
|
|
gutil = require('gulp-util'),
|
|
|
fs = require("fs");
|
|
|
+var through2 = require('through2');
|
|
|
+
|
|
|
var assetRev = require('gulp-tm-asset-rev');
|
|
|
-var ftpconfig = require('./ftpconfig.js');
|
|
|
-
|
|
|
-var apps = [
|
|
|
- {"folder": "o2_lib", "tasks": ["move", "clean"]},
|
|
|
- {"folder": "o2_core", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ANN", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_AppCenter", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_AppMarket", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Attendance", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_BAM", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Calendar", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Chat", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_Column", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_ColumnManager", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_DictionaryDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_Document", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_FormDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_Index", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_Module", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_QueryViewDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_ScriptDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_ViewDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_cms_Xform", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Collect", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Common", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Console", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ControlPanel", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_CRM", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Deployment", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_DesignCenter", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Empty", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Execution", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ExeManager", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_FaceSet", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_File", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Forum", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ForumCategory", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ForumDocument", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ForumPerson", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ForumSearch", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ForumSection", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_HotArticle", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_IM", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_LogViewer", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Meeting", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Message", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Minder", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_MinderEditor", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Note", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_OKR", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_OnlineMeeting", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_OnlineMeetingRoom", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Org", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_portal_PageDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_portal_Portal", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_portal_PortalExplorer", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_portal_PortalManager", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_portal_ScriptDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_portal_WidgetDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_Application", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_ApplicationExplorer", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_ApplicationExplorer1", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_DictionaryDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_FormDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_ProcessDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_ProcessManager", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- // {"folder": "x_component_process_ProjectionDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_ScriptDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_StatDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_TaskCenter", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_ViewDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_Work", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_Xform", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_process_Xform2", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Profile", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_query_Query", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_query_QueryExplorer", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_query_QueryManager", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_query_StatDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_query_ViewDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_query_TableDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_query_StatementDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Report", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ReportDocument", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ReportMinder", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_ScriptEditor", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Search", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_SelecterTest", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Selector", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_service_AgentDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_service_InvokeDesigner", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_service_ServiceManager", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Setting", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_SmartOfficeRoom", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Snake", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Strategy", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Template", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_TeamWork", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_component_Weixin", "tasks": ["move", "min", "clean", "watch"]},
|
|
|
- {"folder": "x_desktop", "tasks": ["move", "min", "clean", "watch"]}
|
|
|
-];
|
|
|
-
|
|
|
-var uploadOptions = ftpconfig;
|
|
|
+var apps = require('./gulpapps.js');
|
|
|
+var ftpconfig = require('./gulpconfig.js');
|
|
|
|
|
|
var options = minimist(process.argv.slice(2), {//upload: local ftp or sftp
|
|
|
- string: ["upload", "location", "host", "user", "pass", "port", "remotePath"]
|
|
|
+ string: ["ev", "upload", "location", "host", "user", "pass", "port", "remotePath", "dest", "src"]
|
|
|
});
|
|
|
+
|
|
|
+var uploadOptions = ftpconfig.dev;
|
|
|
+if (options.ev && options.ev=="dev"){
|
|
|
+ uploadOptions = ftpconfig.dev;
|
|
|
+}else if (options.ev && options.ev=="release"){
|
|
|
+ uploadOptions = ftpconfig.release;
|
|
|
+}else if (options.ev && options.ev=="wrdp"){
|
|
|
+ uploadOptions = ftpconfig.wrdp;
|
|
|
+}else{
|
|
|
+ options.ev = "dev";
|
|
|
+ uploadOptions = ftpconfig.dev;
|
|
|
+}
|
|
|
+
|
|
|
options.upload = options.upload || "";
|
|
|
options.location = options.location || uploadOptions.location;
|
|
|
options.host = options.host || uploadOptions.host;
|
|
|
@@ -126,81 +40,135 @@ options.user = options.user || uploadOptions.user;
|
|
|
options.pass = options.pass || uploadOptions.pass;
|
|
|
options.port = options.port || uploadOptions.port;
|
|
|
options.remotePath = options.remotePath || uploadOptions.remotePath;
|
|
|
-console.log(options.host);
|
|
|
-console.log(options.user);
|
|
|
-console.log(options.pass);
|
|
|
-console.log(options.port);
|
|
|
-console.log(options.remotePath);
|
|
|
-
|
|
|
-
|
|
|
-var minTasks = [];
|
|
|
-var moveTasks = [];
|
|
|
-var watchTasks = [];
|
|
|
-var cleanTasks = [];
|
|
|
-
|
|
|
-function getMinTask(path){
|
|
|
- return function(){
|
|
|
- var src = 'source/'+path+'/**/*.js';
|
|
|
- var dest = 'dest/'+path+'/';
|
|
|
- return gulp.src(src)
|
|
|
- .pipe(changed(dest))
|
|
|
- .pipe(uglify())
|
|
|
- .pipe(rename({ extname: '.min.js' }))
|
|
|
- .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+path+'/')))
|
|
|
- .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
|
|
|
- host: options.host,
|
|
|
- user: options.user || 'anonymous',
|
|
|
- pass: options.pass || '@anonymous',
|
|
|
- port: options.port || 21,
|
|
|
- remotePath: (options.remotePath || '/')+path
|
|
|
- })))
|
|
|
- .pipe(gulpif((options.upload=='sftp'&&options.host!=''), sftp({
|
|
|
- host: options.host,
|
|
|
- user: options.user || 'anonymous',
|
|
|
- pass: options.pass || null,
|
|
|
- port: options.port || 22,
|
|
|
- remotePath: (options.remotePath || '/')+path
|
|
|
- })))
|
|
|
- .pipe(gulp.dest(dest))
|
|
|
- .pipe(gutil.noop());
|
|
|
- }
|
|
|
-}
|
|
|
-function getMoveTask(path){
|
|
|
- return function(){
|
|
|
- var src = 'source/'+path+'/**/*';
|
|
|
- var dest = 'dest/'+path+'/';
|
|
|
- return gulp.src(src)
|
|
|
- .pipe(changed(dest))
|
|
|
- .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+path+'/')))
|
|
|
- .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
|
|
|
- host: options.host,
|
|
|
- user: options.user || 'anonymous',
|
|
|
- pass: options.pass || '@anonymous',
|
|
|
- port: options.port || 21,
|
|
|
- remotePath: (options.remotePath || '/')+path
|
|
|
- })))
|
|
|
- .pipe(gulpif((options.upload=='sftp'&&options.host!=''), sftp({
|
|
|
- host: options.host,
|
|
|
- user: options.user || 'anonymous',
|
|
|
- pass: options.pass || null,
|
|
|
- port: options.port || 22,
|
|
|
- remotePath: (options.remotePath || '/')+path
|
|
|
- })))
|
|
|
- .pipe(gulp.dest(dest))
|
|
|
- .pipe(gutil.noop());
|
|
|
+options.dest = options.dest || uploadOptions.dest || "dest";
|
|
|
+
|
|
|
+var release_options = {};
|
|
|
+release_options.ev = "release";
|
|
|
+release_options.upload = release_options.upload || "";
|
|
|
+release_options.location = release_options.location || ftpconfig.release.location;
|
|
|
+release_options.host = release_options.host || ftpconfig.release.host;
|
|
|
+release_options.user = release_options.user || ftpconfig.release.user;
|
|
|
+release_options.pass = release_options.pass || ftpconfig.release.pass;
|
|
|
+release_options.port = release_options.port || ftpconfig.release.port;
|
|
|
+release_options.remotePath = release_options.remotePath || ftpconfig.release.remotePath;
|
|
|
+release_options.dest = release_options.dest || ftpconfig.release.dest || "dest";
|
|
|
+
|
|
|
+
|
|
|
+var appTasks = [];
|
|
|
+function getAppTask(path, isMin, thisOptions) {
|
|
|
+ return function (cb) {
|
|
|
+ //var srcFile = 'source/' + path + '/**/*';
|
|
|
+ var option = thisOptions || options;
|
|
|
+ var src;
|
|
|
+ var dest = option.dest+'/' + path + '/';
|
|
|
+ if (isMin){
|
|
|
+ var src_min = ['source/' + path + '/**/*.js', '!**/*.spec.js', '!**/test/**'];
|
|
|
+ var src_move = ['source/' + path + '/**/*', '!**/*.spec.js', '!**/test/**'];
|
|
|
+
|
|
|
+ gutil.log("Move-Uglify", ":", gutil.colors.green(gutil.colors.blue(path), gutil.colors.white('->'), dest));
|
|
|
+
|
|
|
+ return gulp.src(src_min)
|
|
|
+ .pipe(changed(dest))
|
|
|
+ .pipe(uglify())
|
|
|
+ .pipe(rename({ extname: '.min.js' }))
|
|
|
+ .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
|
|
|
+ .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
|
|
|
+ host: option.host,
|
|
|
+ user: option.user || 'anonymous',
|
|
|
+ pass: option.pass || '@anonymous',
|
|
|
+ port: option.port || 21,
|
|
|
+ remotePath: (option.remotePath || '/') + path
|
|
|
+ })))
|
|
|
+ .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
|
|
|
+ host: option.host,
|
|
|
+ user: option.user || 'anonymous',
|
|
|
+ pass: option.pass || null,
|
|
|
+ port: option.port || 22,
|
|
|
+ remotePath: (option.remotePath || '/') + path
|
|
|
+ })))
|
|
|
+ .pipe(gulpif((option.ev == "dev") ,gulp.dest(dest)))
|
|
|
+
|
|
|
+ .pipe(gulp.src(src_move))
|
|
|
+ .pipe(changed(dest))
|
|
|
+ .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
|
|
|
+ .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
|
|
|
+ host: option.host,
|
|
|
+ user: option.user || 'anonymous',
|
|
|
+ pass: option.pass || '@anonymous',
|
|
|
+ port: option.port || 21,
|
|
|
+ remotePath: (option.remotePath || '/') + path
|
|
|
+ })))
|
|
|
+ .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
|
|
|
+ host: option.host,
|
|
|
+ user: option.user || 'anonymous',
|
|
|
+ pass: option.pass || null,
|
|
|
+ port: option.port || 22,
|
|
|
+ remotePath: (option.remotePath || '/') + path
|
|
|
+ })))
|
|
|
+ .pipe(gulp.dest(dest))
|
|
|
+ .pipe(gutil.noop());
|
|
|
+
|
|
|
+
|
|
|
+ }else{
|
|
|
+ src = ['source/' + path + '/**/*', '!**/*.spec.js', '!**/test/**'];
|
|
|
+ gutil.log("Move", ":", gutil.colors.green(gutil.colors.blue(path), gutil.colors.white('->'), dest));
|
|
|
+ return gulp.src(src)
|
|
|
+ .pipe(changed(dest))
|
|
|
+ .pipe(gulpif((option.upload == 'local' && option.location != ''), gulp.dest(option.location + path + '/')))
|
|
|
+ .pipe(gulpif((option.upload == 'ftp' && option.host != ''), ftp({
|
|
|
+ host: option.host,
|
|
|
+ user: option.user || 'anonymous',
|
|
|
+ pass: option.pass || '@anonymous',
|
|
|
+ port: option.port || 21,
|
|
|
+ remotePath: (option.remotePath || '/') + path
|
|
|
+ })))
|
|
|
+ .pipe(gulpif((option.upload == 'sftp' && option.host != ''), sftp({
|
|
|
+ host: option.host,
|
|
|
+ user: option.user || 'anonymous',
|
|
|
+ pass: option.pass || null,
|
|
|
+ port: option.port || 22,
|
|
|
+ remotePath: (option.remotePath || '/') + path
|
|
|
+ })))
|
|
|
+ .pipe(gulp.dest(dest))
|
|
|
+ .pipe(gutil.noop());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function getCleanTask(path){
|
|
|
- return function(cb){
|
|
|
- var dest = 'dest/'+path+'/';
|
|
|
- del(dest, cb);
|
|
|
- cb();
|
|
|
+//var taskObj = {};
|
|
|
+apps.map(function (app) {
|
|
|
+ var isMin = (app.tasks.indexOf("min")!==-1);
|
|
|
+ taskName = app.folder;
|
|
|
+ appTasks.push(taskName);
|
|
|
+ gulp.task(taskName, getAppTask(app.folder, isMin));
|
|
|
+
|
|
|
+ //var isMin = (app.tasks.indexOf("min")!==-1);
|
|
|
+ taskName = app.folder+"_release";
|
|
|
+ //appTasks.push(taskName);
|
|
|
+ gulp.task(taskName, getAppTask(app.folder, isMin, release_options));
|
|
|
+});
|
|
|
+
|
|
|
+// Object.keys(taskObj).map(function(k){
|
|
|
+// exports[k] = parallel(taskObj[k]);
|
|
|
+// });
|
|
|
+
|
|
|
+//exports[app.folder] = parallel(minTask, moveTask);
|
|
|
+
|
|
|
+function getCleanTask(path) {
|
|
|
+ return function (cb) {
|
|
|
+ if (path){
|
|
|
+ var dest = (path=="/") ? options.dest+"/" : options.dest+'/' + path + '/';
|
|
|
+ gutil.log("Clean", ":", gutil.colors.red(dest));
|
|
|
+ del.sync(dest, cb);
|
|
|
+ cb();
|
|
|
+ }else{
|
|
|
+ cb();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-function cleanRemoteFtp(f, cb){
|
|
|
- var file = options.remotePath+f;
|
|
|
+function cleanRemoteFtp(f, cb) {
|
|
|
+ var file = options.remotePath + f;
|
|
|
|
|
|
var ftp = new JSFtp({
|
|
|
host: options.host,
|
|
|
@@ -209,17 +177,17 @@ function cleanRemoteFtp(f, cb){
|
|
|
port: options.port || 21
|
|
|
});
|
|
|
|
|
|
- ftp.raw('dele '+file, function(err) {
|
|
|
- if (err){ cb(); return; }
|
|
|
- if (file.substring(file.length-3).toLowerCase()==".js"){
|
|
|
+ ftp.raw('dele ' + file, function (err) {
|
|
|
+ if (err) { cb(); return; }
|
|
|
+ if (file.substring(file.length - 3).toLowerCase() == ".js") {
|
|
|
file = file.replace('.js', ".min.js");
|
|
|
- ftp.raw('dele '+file, function(err) {
|
|
|
- if (err){ cb(); return; }
|
|
|
+ ftp.raw('dele ' + file, function (err) {
|
|
|
+ if (err) { cb(); return; }
|
|
|
|
|
|
- if (file.indexOf("/")!=-1){
|
|
|
+ if (file.indexOf("/") != -1) {
|
|
|
var p = file.substring(0, file.lastIndexOf("/"));
|
|
|
- ftp.raw('rmd '+p, function(err) {
|
|
|
- if (err){ cb(); return; }
|
|
|
+ ftp.raw('rmd ' + p, function (err) {
|
|
|
+ if (err) { cb(); return; }
|
|
|
|
|
|
ftp.raw.quit();
|
|
|
cb();
|
|
|
@@ -227,11 +195,11 @@ function cleanRemoteFtp(f, cb){
|
|
|
}
|
|
|
|
|
|
});
|
|
|
- }else{
|
|
|
- if (file.indexOf("/")!=-1){
|
|
|
+ } else {
|
|
|
+ if (file.indexOf("/") != -1) {
|
|
|
var pPath = file.substring(0, file.lastIndexOf("/"));
|
|
|
- ftp.raw('rmd '+pPath, function(err) {
|
|
|
- if (err){ cb(); return; }
|
|
|
+ ftp.raw('rmd ' + pPath, function (err) {
|
|
|
+ if (err) { cb(); return; }
|
|
|
ftp.raw.quit();
|
|
|
cb();
|
|
|
});
|
|
|
@@ -239,113 +207,66 @@ function cleanRemoteFtp(f, cb){
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
-function cleanRemoteLocal(f, cb){
|
|
|
- var file = options.location+f;
|
|
|
- del(file, {force: true, dryRun: true}, function(){
|
|
|
- if (file.substring(file.length-3).toLowerCase()==".js"){
|
|
|
+function cleanRemoteLocal(f, cb) {
|
|
|
+ var file = options.location + f;
|
|
|
+ del(file, { force: true, dryRun: true }, function () {
|
|
|
+ if (file.substring(file.length - 3).toLowerCase() == ".js") {
|
|
|
var minfile = file.replace('.js', ".min.js");
|
|
|
- del(minfile, {force: true, dryRun: true}, function(){
|
|
|
+ del(minfile, { force: true, dryRun: true }, function () {
|
|
|
var p = file.substring(0, file.lastIndexOf("/"));
|
|
|
- fs.rmdir(p,function(err){
|
|
|
- if(err){}
|
|
|
+ fs.rmdir(p, function (err) {
|
|
|
+ if (err) { }
|
|
|
cb();
|
|
|
})
|
|
|
});
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
var p = file.substring(0, file.lastIndexOf("/"));
|
|
|
- fs.rmdir(p,function(err){
|
|
|
- if(err){}
|
|
|
+ fs.rmdir(p, function (err) {
|
|
|
+ if (err) { }
|
|
|
cb();
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
|
|
|
-function getCleanRemoteTask(path){
|
|
|
- return function(cb){
|
|
|
- if (options.upload){
|
|
|
+function getCleanRemoteTask(path) {
|
|
|
+ return function (cb) {
|
|
|
+ if (options.upload) {
|
|
|
var file = path.replace(/\\/g, "/");
|
|
|
- file = file.substring(file.indexOf("source/")+7);
|
|
|
+ file = file.substring(file.indexOf("source/") + 7);
|
|
|
|
|
|
- if (options.upload=='local'&&options.location!='') cleanRemoteLocal(file, cb);
|
|
|
- if (options.upload=='ftp'&&options.host!='') cleanRemoteFtp(file, cb);
|
|
|
- }else{
|
|
|
+ if (options.upload == 'local' && options.location != '') cleanRemoteLocal(file, cb);
|
|
|
+ if (options.upload == 'ftp' && options.host != '') cleanRemoteFtp(file, cb);
|
|
|
+ } else {
|
|
|
if (cb) cb();
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-function getWatchTask(path, min){
|
|
|
- return function(cb){
|
|
|
- var moveTask = "move:"+path;
|
|
|
- var minTask = "min:"+path;
|
|
|
- var cleanTask = "clean:"+path;
|
|
|
- if (min) gulp.watch('source/'+path+'/**/*.js', {"events": ['add','change']}, gulp.parallel(minTask));
|
|
|
- gulp.watch('source/'+path+'/**/*', {"events": ['addDir', 'add','change']}, gulp.parallel(moveTask));
|
|
|
-
|
|
|
- // gulp.watch('source/'+path+'/**/*', {"events": ['unlinkDir']}, function(file){
|
|
|
- // console.log("into unlinkDir watch ......."+file);
|
|
|
- // });
|
|
|
-
|
|
|
-
|
|
|
- watcher = gulp.watch('source/'+path+'/**/*', {delay:500});
|
|
|
- watcher.on('unlink', function(file, stats){
|
|
|
- console.log("into unlink watch ......."+file);
|
|
|
- gulp.task("cleanRemote", getCleanRemoteTask(file))
|
|
|
- gulp.series(gulp.parallel(cleanTask, "cleanRemote"), gulp.parallel(minTask, moveTask))();
|
|
|
- });
|
|
|
- // watcher.on('unlinkDir', function(file, stats){
|
|
|
- // console.log("into unlinkDir watch ......."+file);
|
|
|
- // // gulp.task("cleanRemoteDir", getCleanRemoteTask(file))
|
|
|
- // // gulp.series(gulp.parallel(cleanTask, "cleanRemoteDir"), gulp.parallel(minTask, moveTask))();
|
|
|
- // });
|
|
|
- }
|
|
|
+
|
|
|
+function getWatchTask(path) {
|
|
|
+ return (path) ? function (cb) {
|
|
|
+ gutil.log("watch", ":", gutil.colors.green(path, "is watching ..."));
|
|
|
+ gulp.watch(['source/' + path + '/**/*', "!./**/test/**"], { "events": ['addDir', 'add', 'change'] }, gulp.parallel([path]));
|
|
|
+ } : function(cb){cb();};
|
|
|
}
|
|
|
|
|
|
-apps.map(function(app){
|
|
|
- var taskName = "";
|
|
|
- if (app.tasks.indexOf("min")!==-1){
|
|
|
- taskName = "min:"+app.folder;
|
|
|
- minTasks.push(taskName);
|
|
|
- gulp.task(taskName, getMinTask(app.folder));
|
|
|
- }
|
|
|
- if (app.tasks.indexOf("move")!==-1){
|
|
|
- taskName = "move:"+app.folder;
|
|
|
- moveTasks.push(taskName);
|
|
|
- gulp.task(taskName, getMoveTask(app.folder));
|
|
|
- }
|
|
|
- if (app.tasks.indexOf("clean")!==-1){
|
|
|
- taskName = "clean:"+app.folder;
|
|
|
- cleanTasks.push(taskName);
|
|
|
- gulp.task(taskName, getCleanTask(app.folder));
|
|
|
- }
|
|
|
- if (app.tasks.indexOf("watch")!==-1){
|
|
|
- taskName = "watch:"+app.folder;
|
|
|
- watchTasks.push(taskName);
|
|
|
- gulp.task(taskName, getWatchTask(app.folder, (app.tasks.indexOf("min")!==-1)));
|
|
|
- }
|
|
|
+gulp.task("clean", getCleanTask(options.src))
|
|
|
+gulp.task("watch", getWatchTask(options.src));
|
|
|
|
|
|
- if (app.tasks.indexOf("min")!==-1 && app.tasks.indexOf("move")!==-1){
|
|
|
- gulp.task(app.folder, gulp.parallel("min:"+app.folder, "move:"+app.folder));
|
|
|
- }else if (app.tasks.indexOf("min")==-1 && app.tasks.indexOf("move")!==-1){
|
|
|
- gulp.task(app.folder, gulp.parallel("move:"+app.folder));
|
|
|
- }else if (app.tasks.indexOf("min")!==-1 && app.tasks.indexOf("move")==-1){
|
|
|
- gulp.task(app.folder, gulp.parallel("min:"+app.folder));
|
|
|
- }
|
|
|
-});
|
|
|
-gulp.task("index", function(){
|
|
|
+gulp.task("index", function () {
|
|
|
var src = ['source/favicon.ico', 'source/index.html'];
|
|
|
- var dest = "dest"
|
|
|
+ var dest = options.dest;
|
|
|
return gulp.src(src)
|
|
|
.pipe(changed(dest))
|
|
|
- .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+'/')))
|
|
|
- .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
|
|
|
+ .pipe(gulpif((options.upload == 'local' && options.location != ''), gulp.dest(options.location + '/')))
|
|
|
+ .pipe(gulpif((options.upload == 'ftp' && options.host != ''), ftp({
|
|
|
host: options.host,
|
|
|
user: options.user || 'anonymous',
|
|
|
pass: options.pass || '@anonymous',
|
|
|
port: options.port || 21,
|
|
|
remotePath: (options.remotePath || '/')
|
|
|
})))
|
|
|
- .pipe(gulpif((options.upload=='sftp'&&options.host!=''), ftp({
|
|
|
+ .pipe(gulpif((options.upload == 'sftp' && options.host != ''), ftp({
|
|
|
host: options.host,
|
|
|
user: options.user || 'anonymous',
|
|
|
pass: options.pass || null,
|
|
|
@@ -355,50 +276,28 @@ gulp.task("index", function(){
|
|
|
.pipe(gulp.dest(dest))
|
|
|
.pipe(gutil.noop());
|
|
|
});
|
|
|
-
|
|
|
-gulp.task("clean", gulp.series(cleanTasks));
|
|
|
-gulp.task("sync", gulp.series(
|
|
|
- gulp.series(cleanTasks),
|
|
|
- gulp.parallel(minTasks, moveTasks, 'index')
|
|
|
-));
|
|
|
-
|
|
|
-gulp.task("watch", gulp.parallel(watchTasks));
|
|
|
-
|
|
|
-
|
|
|
-gulp.task("git_clean", function(cb){
|
|
|
- var dest = 'D:/O2/github/huqi1980/o2oa/o2web/source/';
|
|
|
- del(dest, {dryRun: true, force: true}, cb);
|
|
|
-});
|
|
|
-
|
|
|
-gulp.task("git_dest", function(){
|
|
|
- var dest = "D:/O2/github/huqi1980/o2oa/o2web/source";
|
|
|
- return gulp.src("source/**/*")
|
|
|
- .pipe(changed(dest))
|
|
|
- .pipe(gulp.dest(dest))
|
|
|
-});
|
|
|
-
|
|
|
-gulp.task("git", gulp.series('git_clean', 'git_dest'));
|
|
|
+gulp.task("cleanAll", getCleanTask('/'));
|
|
|
|
|
|
gulp.task("o2:new-v:html", function () {
|
|
|
var path = "x_desktop";
|
|
|
var src = 'source/x_desktop/*.html';
|
|
|
- var dest = 'dest/x_desktop/';
|
|
|
+ var dest = options.dest + '/x_desktop/';
|
|
|
return gulp.src(src)
|
|
|
.pipe(assetRev())
|
|
|
- .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+path+'/')))
|
|
|
- .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
|
|
|
+ .pipe(gulpif((options.upload == 'local' && options.location != ''), gulp.dest(options.location + path + '/')))
|
|
|
+ .pipe(gulpif((options.upload == 'ftp' && options.host != ''), ftp({
|
|
|
host: options.host,
|
|
|
user: options.user || 'anonymous',
|
|
|
pass: options.pass || '@anonymous',
|
|
|
port: options.port || 21,
|
|
|
- remotePath: (options.remotePath || '/')+path
|
|
|
+ remotePath: (options.remotePath || '/') + path
|
|
|
})))
|
|
|
- .pipe(gulpif((options.upload=='sftp'&&options.host!=''), sftp({
|
|
|
+ .pipe(gulpif((options.upload == 'sftp' && options.host != ''), sftp({
|
|
|
host: options.host,
|
|
|
user: options.user || 'anonymous',
|
|
|
pass: options.pass || null,
|
|
|
port: options.port || 22,
|
|
|
- remotePath: (options.remotePath || '/')+path
|
|
|
+ remotePath: (options.remotePath || '/') + path
|
|
|
})))
|
|
|
.pipe(gulp.dest(dest))
|
|
|
.pipe(gutil.noop());
|
|
|
@@ -407,45 +306,59 @@ gulp.task("o2:new-v:html", function () {
|
|
|
gulp.task("o2:new-v:o2", function () {
|
|
|
var path = "o2_core";
|
|
|
var src = 'source/o2_core/o2.js';
|
|
|
- var dest = 'dest/o2_core/';
|
|
|
+ var dest = options.dest +'/o2_core/';
|
|
|
return gulp.src(src)
|
|
|
.pipe(assetRev())
|
|
|
- .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+path+'/')))
|
|
|
- .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
|
|
|
+ .pipe(gulpif((options.upload == 'local' && options.location != ''), gulp.dest(options.location + path + '/')))
|
|
|
+ .pipe(gulpif((options.upload == 'ftp' && options.host != ''), ftp({
|
|
|
host: options.host,
|
|
|
user: options.user || 'anonymous',
|
|
|
pass: options.pass || '@anonymous',
|
|
|
port: options.port || 21,
|
|
|
- remotePath: (options.remotePath || '/')+path
|
|
|
+ remotePath: (options.remotePath || '/') + path
|
|
|
})))
|
|
|
- .pipe(gulpif((options.upload=='sftp'&&options.host!=''), sftp({
|
|
|
+ .pipe(gulpif((options.upload == 'sftp' && options.host != ''), sftp({
|
|
|
host: options.host,
|
|
|
user: options.user || 'anonymous',
|
|
|
pass: options.pass || null,
|
|
|
port: options.port || 22,
|
|
|
- remotePath: (options.remotePath || '/')+path
|
|
|
+ remotePath: (options.remotePath || '/') + path
|
|
|
})))
|
|
|
.pipe(gulp.dest(dest))
|
|
|
.pipe(uglify())
|
|
|
.pipe(rename({ extname: '.min.js' }))
|
|
|
- .pipe(gulpif((options.upload=='local'&&options.location!=''), gulp.dest(options.location+path+'/')))
|
|
|
- .pipe(gulpif((options.upload=='ftp'&&options.host!=''), ftp({
|
|
|
+ .pipe(gulpif((options.upload == 'local' && options.location != ''), gulp.dest(options.location + path + '/')))
|
|
|
+ .pipe(gulpif((options.upload == 'ftp' && options.host != ''), ftp({
|
|
|
host: options.host,
|
|
|
user: options.user || 'anonymous',
|
|
|
pass: options.pass || '@anonymous',
|
|
|
port: options.port || 21,
|
|
|
- remotePath: (options.remotePath || '/')+path
|
|
|
+ remotePath: (options.remotePath || '/') + path
|
|
|
})))
|
|
|
- .pipe(gulpif((options.upload=='sftp'&&options.host!=''), sftp({
|
|
|
+ .pipe(gulpif((options.upload == 'sftp' && options.host != ''), sftp({
|
|
|
host: options.host,
|
|
|
user: options.user || 'anonymous',
|
|
|
pass: options.pass || null,
|
|
|
port: options.port || 22,
|
|
|
- remotePath: (options.remotePath || '/')+path
|
|
|
+ remotePath: (options.remotePath || '/') + path
|
|
|
})))
|
|
|
.pipe(gulp.dest(dest))
|
|
|
.pipe(gutil.noop());
|
|
|
});
|
|
|
gulp.task("o2:new-v", gulp.parallel("o2:new-v:o2", "o2:new-v:html"));
|
|
|
|
|
|
-gulp.task("default", gulp.series("clean", gulp.series(minTasks, moveTasks, 'index'), "o2:new-v"));
|
|
|
+
|
|
|
+gulp.task("git_clean", function (cb) {
|
|
|
+ var dest = 'D:/O2/github/huqi1980/o2oa/o2web/source/';
|
|
|
+ del(dest, { dryRun: true, force: true }, cb);
|
|
|
+});
|
|
|
+
|
|
|
+gulp.task("git_dest", function () {
|
|
|
+ var dest = "D:/O2/github/huqi1980/o2oa/o2web/source";
|
|
|
+ return gulp.src(["source/**/*", "!./**/test/**"])
|
|
|
+ .pipe(changed(dest))
|
|
|
+ .pipe(gulp.dest(dest))
|
|
|
+});
|
|
|
+gulp.task("git", gulp.series('git_clean', 'git_dest'));
|
|
|
+
|
|
|
+gulp.task("default", gulp.series(gulp.parallel(appTasks, 'index'), "o2:new-v"));
|