Created
April 11, 2014 06:30
-
-
Save otakustay/10444171 to your computer and use it in GitHub Desktop.
SVN patch for cb-web-fe to upgrade to edp 1.0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Index: .jshintignore | |
=================================================================== | |
--- .jshintignore (revision 0) | |
+++ .jshintignore (working copy) | |
@@ -0,0 +1,3 @@ | |
+!src/** | |
+src/external/** | |
+ | |
Index: build.sh | |
=================================================================== | |
--- build.sh (revision 14842) | |
+++ build.sh (working copy) | |
@@ -1,27 +1,22 @@ | |
#!/bin/sh | |
+conf="online" | |
+if [ "$#" -eq "1" ];then | |
+ conf=$1 | |
+fi | |
+ | |
rm -rf output | |
edp --version | |
-node tool/build.js --output=output/static | |
+edp build --output=output/static --conf=$conf | |
if [ "$?" -ne "0" ];then | |
- echo "node build failed!" | |
+ echo "edp build failed!" | |
exit 1 | |
-fi | |
+fis | |
- | |
-var="online" | |
-if [ "$#" -eq "1" ];then | |
- var=$1 | |
-fi | |
-python filter.py output/static/index.html $var | |
-python filter.py output/static/creative-preview.html $var | |
- | |
echo `date` > output/static/version.txt | |
-rm -f output/static/*.py output/static/*.sh output/static/conf/* | |
- | |
cd output && tar -czf cb-web-fe.tar.gz static && rm -rf static/ | |
echo "build success!" | |
Index: conf/.edprc | |
=================================================================== | |
--- conf/.edprc (revision 14842) | |
+++ conf/.edprc (working copy) | |
@@ -2,4 +2,3 @@ | |
"user.name": "otakustay", | |
"user.email": "[email protected]" | |
} | |
- | |
Index: conf/dev.json | |
=================================================================== | |
--- conf/dev.json (working copy) | |
+++ conf/dev.json (working copy) | |
@@ -1,10 +1,7 @@ | |
- | |
-#the url after the validation of cas post | |
-#section part needed | |
-[index] | |
-index_uc_login_url=https://mycas.baidu.com:8443/?action=login | |
-verify_code_url=http://mycas.baidu.com:8477/?action=image | |
-cb_login_url=http://admtest.baidu.com:8280/api/tool/user/login | |
-cb_index_url=http://admtest.baidu.com:8280/static/index.html | |
- | |
- | |
+[ | |
+ { "from": "${index_uc_login_url}", "to": "https://mycas.baidu.com:8443/?action=login" }, | |
+ { "from": "${verify_code_url}", "to": "http://mycas.baidu.com:8477/?action=image" }, | |
+ { "from": "${cb_login_url}", "to": "http://admtest.baidu.com:8280/api/tool/user/login" }, | |
+ { "from": "${cb_index_url}", "to": "http://admtest.baidu.com:8280/static/index.html" }, | |
+ { "from": "${cb_dub_js_path}", "to": "http://cbjs.baidu.com/js/zm.js" } | |
+] | |
Index: conf/dev.properties | |
=================================================================== | |
--- conf/dev.properties (revision 14842) | |
+++ conf/dev.properties (working copy) | |
@@ -1,10 +0,0 @@ | |
- | |
-#the url after the validation of cas post | |
-#section part needed | |
-[index] | |
-index_uc_login_url=https://mycas.baidu.com:8443/?action=login | |
-verify_code_url=http://mycas.baidu.com:8477/?action=image | |
-cb_login_url=http://admtest.baidu.com:8280/api/tool/user/login | |
-cb_index_url=http://admtest.baidu.com:8280/static/index.html | |
- | |
- | |
Index: conf/jpaas.json | |
=================================================================== | |
--- conf/jpaas.json (working copy) | |
+++ conf/jpaas.json (working copy) | |
@@ -1,8 +1,7 @@ | |
- | |
-#the url after the validation of cas post | |
-#section part needed | |
-[index] | |
-index_uc_login_url=https://testcas.baidu.com:8443/?action=login | |
-verify_code_url=http://testcas.baidu.com:8477/?action=image | |
-cb_login_url=http://admqa.baidu.com/api/tool/user/login | |
-cb_index_url=http://admqa.baidu.com/static/index.html | |
\ No newline at end of file | |
+[ | |
+ { "from": "index_uc_login_url", "to": "https://testcas.baidu.com:8443/?action=login" }, | |
+ { "from": "verify_code_url", "to": "http://testcas.baidu.com:8477/?action=image" }, | |
+ { "from": "cb_login_url", "to": "http://admqa.baidu.com/api/tool/user/login" }, | |
+ { "from": "cb_index_url", "to": "http://admqa.baidu.com/static/index.html" }, | |
+ { "from": "cb_dub_js_path", "to": "http://admqa.baidu.com:8081/dup/z.js" } | |
+] | |
Index: conf/jpaas.properties | |
=================================================================== | |
--- conf/jpaas.properties (revision 14842) | |
+++ conf/jpaas.properties (working copy) | |
@@ -1,8 +0,0 @@ | |
- | |
-#the url after the validation of cas post | |
-#section part needed | |
-[index] | |
-index_uc_login_url=https://testcas.baidu.com:8443/?action=login | |
-verify_code_url=http://testcas.baidu.com:8477/?action=image | |
-cb_login_url=http://admqa.baidu.com/api/tool/user/login | |
-cb_index_url=http://admqa.baidu.com/static/index.html | |
\ No newline at end of file | |
Index: conf/online.json | |
=================================================================== | |
--- conf/online.json (revision 0) | |
+++ conf/online.json (working copy) | |
@@ -0,0 +1,7 @@ | |
+[ | |
+ { "from": "${index_uc_login_url}", "to": "https://cas.baidu.com?action=login" }, | |
+ { "from": "${verify_code_url}", "to": "http://cas.baidu.com?action=image" }, | |
+ { "from": "${cb_login_url}", "to": "http://adm.baidu.com/api/tool/user/login" }, | |
+ { "from": "${cb_index_url}", "to": "http://adm.baidu.com/static/index.html" }, | |
+ { "from": "${cb_dub_js_path}", "to": "http://cbjs.baidu.com/js/zm.js" } | |
+] | |
Index: conf/online.properties | |
=================================================================== | |
--- conf/online.properties (revision 14842) | |
+++ conf/online.properties (working copy) | |
@@ -1,9 +0,0 @@ | |
- | |
-#the url after the validation of cas post | |
-#section part needed | |
-[index] | |
-index_uc_login_url=https://cas.baidu.com?action=login | |
-verify_code_url=http://cas.baidu.com?action=image | |
-cb_login_url=http://adm.baidu.com/api/tool/user/login | |
-cb_index_url=http://adm.baidu.com/static/index.html | |
-cb_dub_js_path=http://cbjs.baidu.com/js/zm.js | |
Index: conf/qa.json | |
=================================================================== | |
--- conf/qa.json (working copy) | |
+++ conf/qa.json (working copy) | |
@@ -1,9 +1,7 @@ | |
- | |
-#the url after the validation of cas post | |
-#section part needed | |
-[index] | |
-index_uc_login_url=https://testcas.baidu.com:8443/?action=login | |
-verify_code_url=http://testcas.baidu.com:8477/?action=image | |
-cb_login_url=http://admqa.baidu.com:8280/api/tool/user/login | |
-cb_index_url=http://admqa.baidu.com:8280/static/index.html | |
-cb_dub_js_path=http://admqa.baidu.com:8081/dup/z.js | |
\ No newline at end of file | |
+[ | |
+ { "from": "index_uc_login_url", "to": "https://testcas.baidu.com:8443/?action=login" }, | |
+ { "from": "verify_code_url", "to": "http://testcas.baidu.com:8477/?action=image" }, | |
+ { "from": "cb_login_url", "to": "http://admqa.baidu.com:8280/api/tool/user/login" }, | |
+ { "from": "cb_index_url", "to": "http://admqa.baidu.com:8280/static/index.html" }, | |
+ { "from": "cb_dub_js_path", "to": "http://admqa.baidu.com:8081/dup/z.js" } | |
+] | |
Index: conf/qa.properties | |
=================================================================== | |
--- conf/qa.properties (revision 14842) | |
+++ conf/qa.properties (working copy) | |
@@ -1,9 +0,0 @@ | |
- | |
-#the url after the validation of cas post | |
-#section part needed | |
-[index] | |
-index_uc_login_url=https://testcas.baidu.com:8443/?action=login | |
-verify_code_url=http://testcas.baidu.com:8477/?action=image | |
-cb_login_url=http://admqa.baidu.com:8280/api/tool/user/login | |
-cb_index_url=http://admqa.baidu.com:8280/static/index.html | |
-cb_dub_js_path=http://admqa.baidu.com:8081/dup/z.js | |
\ No newline at end of file | |
Index: edp-build-config.js | |
=================================================================== | |
--- edp-build-config.js (revision 14842) | |
+++ edp-build-config.js (working copy) | |
@@ -4,25 +4,21 @@ | |
*/ | |
var AddViewName = require('./tool/build/AddViewName'); | |
-var package = require('./tool/util').getModulesFromPackage; | |
-var namespace = require('./tool/util').getModulesFromNamespace; | |
-var getBizNamespaces = require('./tool/util').getBizNamespaces; | |
- | |
+process.chdir(__dirname); | |
var cwd = process.cwd(); | |
var path = require('path'); | |
+var fs = require('fs'); | |
var args = {}; | |
(function () { | |
for (var i = 4; i < process.argv.length; i++) { | |
var arg = process.argv[i]; | |
- console.log(arg); | |
var pair = arg.split('='); | |
var key = pair[0].substring(2); | |
- var value = pair[1]; | |
+ var value = pair[1] === undefined ? true : pair[1]; | |
args[key] = value; | |
} | |
}()); | |
-var svnRevision = args.revision || ''; | |
/** | |
* 输入目录 | |
@@ -39,35 +35,46 @@ | |
exports.output = path.resolve(cwd, args.output || 'output'); | |
/** | |
+ * 声明特定文件的编码 | |
+ * @type {Object} | |
+ */ | |
+exports.fileEncodings = { | |
+ 'src/common/img/channel-example-csv.csv': 'gbk', | |
+ 'src/common/img/slot-example-csv.csv': 'gbk' | |
+}; | |
+ | |
+/** | |
* 排除文件pattern列表 | |
* | |
* @type {Array} | |
*/ | |
exports.exclude = [ | |
- '/src/static/tpl/*', | |
- '/tool', | |
- '/doc', | |
- '/test', | |
- '/mockup', | |
- '/demo', | |
- '/copyright.txt', | |
- // '/index-debug.html', | |
- '/index-qa.html', | |
- '/module.conf', | |
- '/dep/packages.manifest', | |
- '/dep/*/*/test', | |
- '/dep/*/*/doc', | |
- '/dep/*/*/demo', | |
- '/dep/*/*/example', | |
- '/dep/*/*/tool', | |
- '/dep/*/*/jsduck', | |
- '/dep/*/*/*.md', | |
- '/dep/*/*/package.json', | |
- '/dep/echarts/*/src/util/mapData/rawData/china/*.js', | |
- '/dep/echarts/*/src/util/mapData/rawData/*.js', | |
- '/dep/etpl/2.1.0/main.js', | |
- '/edp-*', | |
- '/.edpproj', | |
+ 'src/static/tpl/*', | |
+ 'tool/**', | |
+ 'doc/**', | |
+ 'test/**', | |
+ 'mockup/**', | |
+ 'output/**', | |
+ 'demo/**', | |
+ 'conf/**', | |
+ 'copyright.txt', | |
+ args.debug ? '' : 'index-debug.html', | |
+ 'index-qa.html', | |
+ 'module.conf', | |
+ 'dep/packages.manifest', | |
+ 'dep/*/*/test', | |
+ 'dep/*/*/doc', | |
+ 'dep/*/*/demo', | |
+ 'dep/*/*/example', | |
+ 'dep/*/*/tool', | |
+ 'dep/*/*/jsduck', | |
+ 'dep/*/*/*.md', | |
+ 'dep/*/*/index.html', | |
+ 'dep/*/*/package.json', | |
+ 'dep/echarts/*/src/util/mapData/rawData/china/*.js', | |
+ 'dep/echarts/*/src/util/mapData/rawData/*.js', | |
+ 'edp-*', | |
+ '.edpproj', | |
'.svn', | |
'.git', | |
'.gitignore', | |
@@ -80,10 +87,10 @@ | |
'*.tmp', | |
'*.bak', | |
'*.swp', | |
- '*.edprc', | |
- '*.jshintignore', | |
- '*.jshintrc', | |
- '*.npmignore', | |
+ '.edprc', | |
+ '.jshintignore', | |
+ '.jshintrc', | |
+ '.npmignore', | |
'*.properties', | |
'*.py', | |
'*.sh', | |
@@ -100,122 +107,87 @@ | |
* | |
* @return {Array} | |
*/ | |
-exports.getProcessors = function () { | |
- return [ | |
- new AddViewName(), | |
- new LessCompiler({ | |
- exclude: [ | |
- 'src/ui/css/*.less', | |
- 'src/common/css/*.less', | |
- 'src/*/css/*.less', | |
- 'src/*/*/css/*.less', | |
- 'src/*/ui/css/*.less', | |
- 'src/*/*/ui/css/*.less' | |
- ], | |
- include: [ | |
- 'src/common/css/extern.less', | |
- 'src/common/css/main.less', | |
- 'src/common/css/reset.less', | |
- 'src/static/css/index.less' | |
- ], | |
- entryExtnames: pageEntries | |
- }), | |
- new CssCompressor(), | |
- new ModuleCompiler({ | |
- exclude: [ | |
- 'dep/etpl/*/src/main.js', | |
- 'dep/jquery/*/src/jquery.js', | |
- 'dep/jquery/*/src/jquery.min.js', | |
- 'src/external/esl.js', | |
- 'src/external/h.js', | |
- 'src/external/json2.js', | |
- 'src/static/footer.js', | |
- 'src/static/header.js' | |
- ], | |
- getCombineConfig: function () { | |
- var bizNamespaces = getBizNamespaces(); | |
+exports.init = function (config, start) { | |
+ require('./tool/util').getSVNRevision(function (revision) { | |
+ revision = revision || (+new Date); | |
- var bizUIModules = []; | |
- bizNamespaces | |
- .map(function (namespace) { return namespace + '/ui'; }) | |
- .forEach(function (bizNamespace) { bizUIModules.push.apply(bizUIModules, namespace(bizNamespace)); }); | |
- | |
- // 3个启动脚本 | |
- var config = { | |
- 'startup/ui': { | |
- include: ['moment/lang/zh-cn'].concat(package('esui')), | |
- exclude: [ | |
- 'esui/Sidebar' // `Sidebar`用自己的 | |
- ] | |
- }, | |
- 'startup/ria': { | |
- include: ['echarts', 'echarts/chart/line', 'echarts/chart/bar'] | |
- .concat(package('er', 'ef', 'ub-ria', 'er-track', 'etpl', 'saber-cookie')) | |
- .concat('common/extension') | |
- .concat(namespace('common/extension')), | |
- exclude: package('mini-event', 'moment', 'underscore', 'esui') | |
- }, | |
- 'startup/biz': { | |
- include: ['report/delivery/Dashboard', 'report/slot/Dashboard', 'report/order/Dashboard'] | |
- .concat(namespace('common', 'ui', 'error', 'bulletin')) | |
- .concat(namespace('dashboard', 'slot', 'order', 'delivery')) | |
- .concat(bizUIModules), | |
- exclude: package( | |
- 'mini-event', 'moment', 'underscore', 'saber-cookie', | |
- 'etpl', 'er', 'er-track', 'ef', 'echarts', 'esui', 'ub-ria' | |
- ) | |
+ config.getProcessors = function () { | |
+ return [ | |
+ new AddViewName({ | |
+ files: [ | |
+ 'src/**/*View.js', | |
+ '!src/common/**' // 基类View不需要名称 | |
+ ] | |
+ }), | |
+ new LessCompiler({ | |
+ files: [ | |
+ 'dep/esui/*/src/css/main.less', | |
+ 'src/common/css/extern.less', | |
+ 'src/common/css/main.less', | |
+ 'src/common/css/reset.less', | |
+ 'src/static/css/index.less' | |
+ ] | |
+ }), | |
+ // new CssCompressor(), | |
+ new ModuleCompiler({ | |
+ files: [ | |
+ '*.js', | |
+ '!dep/etpl/*/src/main.js', | |
+ '!dep/jquery/*/src/jquery.js', | |
+ '!dep/jquery/*/src/jquery.min.js', | |
+ '!src/external/esl.js', | |
+ '!src/external/h.js', | |
+ '!src/external/json2.js', | |
+ '!src/static/footer.js', | |
+ '!src/static/header.js' | |
+ ], | |
+ getCombineConfig: require('./tool/build/get-combine-config') | |
+ }), | |
+ new TplMerge({ | |
+ files: [ | |
+ 'src/**/*.js', | |
+ '!src/external/*', | |
+ '!src/static/*' | |
+ ] | |
+ }), | |
+ // new JsCompressor(), | |
+ new PathMapper({ | |
+ mapper: function (value) { | |
+ value = value.replace( /(^|\/)src(\/|$)/, '$1' + 'asset-' + revision + '$2' ); | |
+ value = value.replace( /(^|\/)dep(\/|$)/, '$1' + 'dep-' + revision + '$2' ); | |
+ return value; | |
} | |
- }; | |
+ }), | |
+ new AddCopyright({ | |
+ files: [ | |
+ 'src/**/*.js', | |
+ 'src/**/*.css' | |
+ ] | |
+ }), | |
+ new StringReplace({ | |
+ name: 'ReplaceDebug', | |
+ files: [ | |
+ '*.htm', | |
+ '*.html' | |
+ ], | |
+ replacements: [ | |
+ { from: 'window.DEBUG = true;', to: 'window.DEBUG = false;' } | |
+ ] | |
+ }), | |
+ new StringReplace({ | |
+ name: 'ReplaceConfPath', | |
+ files: [ | |
+ 'index.html', | |
+ 'creative-preview.html' | |
+ ], | |
+ replacements: JSON.parse(fs.readFileSync('conf/' + (args.conf || 'online') + '.json', 'utf8')) | |
+ }), | |
+ new OutputCleaner() | |
+ ]; | |
+ }; | |
- var baseModules = namespace('common', 'ui') | |
- .concat(package('er', 'ef', 'ub-ria', 'er-track', 'etpl', 'saber-cookie')) | |
- .concat(package('esui', 'echarts', 'zrender', 'mini-event', 'underscore', 'moment')); | |
- | |
- bizNamespaces.forEach(function (bizNamespace) { | |
- var exclude = baseModules.concat(bizNamespace + '/ui'); | |
- // 通用 | |
- config[bizNamespace + '/List'] = { exclude: exclude }; | |
- config[bizNamespace + '/Form'] = { exclude: exclude }; | |
- config[bizNamespace + '/Detail'] = { exclude: exclude }; | |
- config[bizNamespace + '/Read'] = { exclude: exclude }; | |
- // 报表 | |
- config[bizNamespace + '/Date'] = { exclude: exclude }; | |
- config[bizNamespace + '/General'] = { exclude: exclude }; | |
- config[bizNamespace + '/Hour'] = { exclude: exclude }; | |
- }); | |
- | |
- return config; | |
- }, | |
- configFile: 'module.conf', | |
- entryExtnames: moduleEntries | |
- }), | |
- new TplMerge({ | |
- exclude: [ | |
- 'src/external/*', | |
- 'src/static/*' | |
- ] | |
- }), | |
- // new JsCompressor(), | |
- new PathMapper({ | |
- replacements: [ | |
- { type: 'html', tag: 'link', attribute: 'href', extnames: pageEntries }, | |
- { type: 'html', tag: 'img', attribute: 'src', extnames: pageEntries }, | |
- { type: 'html', tag: 'script', attribute: 'src', extnames: pageEntries }, | |
- { type: 'html', tag: 'a', attribute: 'href', extnames: pageEntries }, | |
- { extnames: moduleEntries, replacer: 'module-config' }, | |
- { extnames: 'css,less', replacer: 'css' } | |
- ], | |
- mapper: function (value) { | |
- return value | |
- .replace(/dep/g, 'dep-' + svnRevision) | |
- .replace(/src/g, 'asset-' + svnRevision); | |
- } | |
- }), | |
- new AddCopyright(), | |
- new ReplaceDebug({ | |
- exclude: ['*.tpl.html'] | |
- }) | |
- ]; | |
+ start(); | |
+ }); | |
}; | |
/** | |
Index: filter.py | |
=================================================================== | |
--- filter.py (revision 14842) | |
+++ filter.py (working copy) | |
@@ -1,38 +0,0 @@ | |
- | |
-import re | |
-import sys | |
-import ConfigParser | |
-import os | |
- | |
-maps = {} | |
- | |
-def replacement(match): | |
- code = match.group(1) | |
- value = maps.get(code) | |
- if value==None: | |
- return "${"+code+"}" | |
- else: | |
- return value | |
-if __name__ == '__main__': | |
- if len(sys.argv)!=3: | |
- print "Usage: python " + sys.argv[0] +" fileName env" | |
- elif not os.path.isfile(sys.argv[1]): | |
- print sys.argv[1]+" not exists!" | |
- else: | |
- file = os.path.join("conf",sys.argv[2]+".properties") | |
- | |
- if not os.path.isfile(file): | |
- print str(file)+" not exists!" | |
- | |
- cf = ConfigParser.ConfigParser() | |
- cf.read(file) | |
- for key, value in cf.items("index"): | |
- maps[key]=value | |
- pattern = re.compile(r"\${(.+?)}") | |
- | |
- f=open(sys.argv[1]) | |
- content = f.read() | |
- f.close() | |
- f=open(sys.argv[1],'w') | |
- f.write(pattern.sub(replacement,content)) | |
- f.close() | |
\ No newline at end of file | |
Index: module.conf | |
=================================================================== | |
--- module.conf (revision 14842) | |
+++ module.conf (working copy) | |
@@ -1,77 +1,77 @@ | |
{ | |
"baseUrl": "src", | |
"paths": { | |
- "tpl": "src/common/tpl", | |
- "js": "src/external/js" | |
+ "tpl": "common/tpl", | |
+ "js": "external/js" | |
}, | |
"packages": [ | |
{ | |
"name": "underscore", | |
- "location": "dep/underscore/1.5.2/src", | |
+ "location": "../dep/underscore/1.5.2/src", | |
"main": "underscore" | |
}, | |
{ | |
"name": "ef", | |
- "location": "dep/ef/3.1.0-alpha.3/src", | |
+ "location": "../dep/ef/3.1.0-alpha.3/src", | |
"main": "main" | |
}, | |
{ | |
"name": "er", | |
- "location": "dep/er/3.1.0-alpha.6/src", | |
+ "location": "../dep/er/3.1.0-alpha.6/src", | |
"main": "main" | |
}, | |
{ | |
"name": "esui", | |
- "location": "dep/esui/3.1.0-alpha.6/src", | |
+ "location": "../dep/esui/3.1.0-alpha.6/src", | |
"main": "main" | |
}, | |
{ | |
"name": "echarts", | |
- "location": "dep/echarts/1.3.6/src", | |
+ "location": "../dep/echarts/1.3.6/src", | |
"main": "echarts" | |
}, | |
{ | |
"name": "zrender", | |
- "location": "dep/zrender/1.0.8/src", | |
+ "location": "../dep/zrender/1.0.8/src", | |
"main": "zrender" | |
}, | |
{ | |
"name": "jquery", | |
- "location": "dep/jquery/1.9.1/src", | |
- "main": "jquery.min.js" | |
+ "location": "../dep/jquery/1.9.1/src", | |
+ "main": "jquery.min" | |
}, | |
{ | |
"name": "moment", | |
- "location": "dep/moment/2.0.0/src", | |
+ "location": "../dep/moment/2.0.1/src", | |
"main": "moment" | |
}, | |
{ | |
"name": "saber-cookie", | |
- "location": "dep/saber-cookie/0.1.0/src", | |
+ "location": "../dep/saber-cookie/0.1.0/src", | |
"main": "cookie" | |
}, | |
{ | |
"name": "mini-event", | |
- "location": "dep/mini-event/1.0.0/src", | |
+ "location": "../dep/mini-event/1.0.0/src", | |
"main": "main" | |
}, | |
{ | |
"name": "er-track", | |
- "location": "dep/er-track/0.9.1/src", | |
+ "location": "../dep/er-track/0.9.1/src", | |
"main": "main" | |
}, | |
{ | |
"name": "etpl", | |
- "location": "dep/etpl/2.0.10/src", | |
+ "location": "../dep/etpl/2.0.10/src", | |
"main": "main" | |
}, | |
{ | |
"name": "est", | |
- "location": "dep/est/1.1.0/src" | |
+ "location": "../dep/est/1.1.0/src" | |
}, | |
{ | |
"name": "ub-ria", | |
- "location": "dep/ub-ria/0.8.0-alpha.4/src", | |
+ "location": "../dep/ub-ria/0.8.0-alpha.4/src", | |
"main": "main" | |
}, | |
{ | |
Index: src/common/GlobalData.js | |
=================================================================== | |
--- src/common/GlobalData.js (revision 14842) | |
+++ src/common/GlobalData.js (working copy) | |
@@ -395,7 +395,7 @@ | |
); | |
var globalData = this; | |
- return require('er/Deferred').all( | |
+ var updatingStaticData = require('er/Deferred').all( | |
updating.then( | |
function (data) { | |
return globalData.loadUser() | |
@@ -408,8 +408,8 @@ | |
.then(function () { return data; }); | |
} | |
) | |
- ).then(function () { return arguments[0]; }); | |
- return updating; | |
+ ); | |
+ return updatingStaticData.then(function () { return arguments[0]; }); | |
}; | |
/** | |
Index: tool/build/AddCopyright.js | |
=================================================================== | |
--- tool/build/AddCopyright.js (revision 14842) | |
+++ tool/build/AddCopyright.js (working copy) | |
@@ -1,66 +0,0 @@ | |
-/** | |
- * @file 添加版权声明的构建器 | |
- * @author zhanglili[[email protected]] | |
- */ | |
- | |
-var AbstractProcessor = require('edp-build/lib/processor/abstract'); | |
- | |
-var copyright = ''; | |
- | |
-/** | |
- * 添加版权声明的构建器 | |
- * | |
- * @constructor | |
- * @param {Object} options 初始化参数 | |
- */ | |
-function AddCopyright(options) { | |
- AbstractProcessor.call(this, options); | |
- this.extnames = this.extnames || [ 'css', 'less', 'js' ]; | |
-} | |
- | |
-AddCopyright.prototype = new AbstractProcessor(); | |
- | |
-/** | |
- * 处理器名称 | |
- * | |
- * @type {string} | |
- */ | |
-AddCopyright.prototype.name = 'AddCopyright'; | |
- | |
-/** | |
- * 构建处理 | |
- * | |
- * @param {FileInfo} file 文件信息对象 | |
- * @param {ProcessContext} processContext 构建环境对象 | |
- * @param {Function} callback 处理完成回调函数 | |
- */ | |
-AddCopyright.prototype.process = function (file, processContext, callback) { | |
- if (!copyright) { | |
- copyright = require('fs').readFileSync( | |
- require('path').join(processContext.baseDir, 'copyright.txt'), | |
- 'utf8' | |
- ); | |
- if (copyright.charAt(copyright.length - 1) !== '\n') { | |
- copyright += '\n'; | |
- } | |
- } | |
- | |
- var isMatch = this.extnames.filter( | |
- function (extname) { | |
- return extname === file.extname | |
- } | |
- ); | |
- isMatch = isMatch.length; | |
- | |
- var PROCESSED_PROP = 'AddCopyrightProcessed'; | |
- if (isMatch && !file.get(PROCESSED_PROP)) { | |
- var data = copyright + file.data; | |
- | |
- file.setData(data); | |
- file.set(PROCESSED_PROP, 1); | |
- } | |
- | |
- callback && callback(); | |
-}; | |
- | |
-module.exports = exports = AddCopyright; | |
\ No newline at end of file | |
Index: tool/build/AddViewName.js | |
=================================================================== | |
--- tool/build/AddViewName.js (revision 14842) | |
+++ tool/build/AddViewName.js (working copy) | |
@@ -8,7 +8,7 @@ | |
/** | |
* 添加版权声明的构建器 | |
- * | |
+ * | |
* @constructor | |
* @param {Object} options 初始化参数 | |
*/ | |
@@ -21,7 +21,7 @@ | |
/** | |
* 处理器名称 | |
- * | |
+ * | |
* @type {string} | |
*/ | |
AddViewName.prototype.name = 'AddViewName'; | |
@@ -46,7 +46,7 @@ | |
} | |
); | |
name = name.replace( | |
- /[A-Z]/g, | |
+ /[A-Z]/g, | |
function (match) { return '-' + match.toLowerCase(); } | |
); | |
if (name.charAt(0) === '-') { | |
@@ -54,10 +54,10 @@ | |
} | |
var statement = filename + '.prototype.name = ' + '\'' + name + '\';'; | |
- content = content.substring(0, index) | |
+ content = content.substring(0, index) | |
+ Array(3).join(require('os').EOL) | |
+ Array(9).join(' ') | |
- + statement | |
+ + statement | |
+ content.substring(index); | |
file.setData(content); | |
@@ -67,24 +67,20 @@ | |
/** | |
* 构建处理 | |
- * | |
+ * | |
* @param {FileInfo} file 文件信息对象 | |
* @param {ProcessContext} processContext 构建环境对象 | |
* @param {Function} callback 处理完成回调函数 | |
*/ | |
AddViewName.prototype.process = function (file, processContext, callback) { | |
- // console.log(file.fullPath); | |
- // console.log(Object.keys(processContext)); | |
- // console.log(processContext.baseDir); | |
var relativePath = path.relative(processContext.baseDir, file.fullPath); | |
+ // console.log(); | |
+ // console.log(relativePath); | |
+ | |
// 在`src`下,且不在`common`下的所有View统一加上`name`字段 | |
var PROCESSED_PROP = 'AddViewNameProcessed'; | |
- if (relativePath.indexOf('src/') === 0 | |
- && relativePath.indexOf('src/common/') !== 0 | |
- && /[\w+]View\.js/.test(path.basename(relativePath)) | |
- && !file.get(PROCESSED_PROP) | |
- ) { | |
+ if (!file.get(PROCESSED_PROP)) { | |
this.addNameProperty(file); | |
file.set(PROCESSED_PROP, 1); | |
} | |
Index: tool/build/ReplaceDebug.js | |
=================================================================== | |
--- tool/build/ReplaceDebug.js (revision 14842) | |
+++ tool/build/ReplaceDebug.js (working copy) | |
@@ -1,49 +0,0 @@ | |
-/** | |
- * @file 修正DEBUG变量的处理器 | |
- * @author zhanglili[[email protected]] | |
- */ | |
- | |
-var AbstractProcessor = require('edp-build/lib/processor/abstract'); | |
- | |
-/** | |
- * 添加版权声明的构建器 | |
- * | |
- * @constructor | |
- * @param {Object} options 初始化参数 | |
- */ | |
-function ReplaceDebug(options) { | |
- AbstractProcessor.call(this, options); | |
-} | |
- | |
-ReplaceDebug.prototype = new AbstractProcessor(); | |
- | |
-/** | |
- * 处理器名称 | |
- * | |
- * @type {string} | |
- */ | |
-ReplaceDebug.prototype.name = 'ReplaceDebug'; | |
- | |
-/** | |
- * 构建处理 | |
- * | |
- * @param {FileInfo} file 文件信息对象 | |
- * @param {ProcessContext} processContext 构建环境对象 | |
- * @param {Function} callback 处理完成回调函数 | |
- */ | |
-ReplaceDebug.prototype.process = function (file, processContext, callback) { | |
- var PROCESSED_PROP = 'ReplaceDebugProcessed'; | |
- if (file.extname === 'html' && !file.get(PROCESSED_PROP)) { | |
- var data = file.data.replace( | |
- /window\.DEBUG = true;/, | |
- 'window.DEBUG = false;' | |
- ); | |
- | |
- file.setData(data); | |
- file.set(PROCESSED_PROP, 1); | |
- } | |
- | |
- callback && callback(); | |
-}; | |
- | |
-module.exports = exports = ReplaceDebug; | |
\ No newline at end of file | |
Index: tool/build/copy.js | |
=================================================================== | |
--- tool/build/copy.js (revision 14842) | |
+++ tool/build/copy.js (working copy) | |
@@ -1,6 +0,0 @@ | |
-var fs = require('fs'); | |
- | |
-module.exports = function (src, dest) { | |
- var data = fs.readFileSync(src); | |
- fs.writeFileSync(dest, data, { encoding: null }); | |
-}; | |
\ No newline at end of file | |
Index: tool/build/get-combine-config.js | |
=================================================================== | |
--- tool/build/get-combine-config.js (revision 0) | |
+++ tool/build/get-combine-config.js (working copy) | |
@@ -0,0 +1,91 @@ | |
+/** | |
+ * tool/get-combine-config.js | |
+ * @author leeight([email protected]), otakustay([email protected]) | |
+ **/ | |
+var getBizNamespaces = require('../util').getBizNamespaces; | |
+ | |
+function negative(array){ | |
+ return array.map(function(item){ return '!' + item; }); | |
+} | |
+ | |
+function expand(array) { | |
+ var result = []; | |
+ array.forEach(function(item) { result.push(item, item + '/**'); }); | |
+ return result; | |
+} | |
+ | |
+function generateModuleCombineConfig() { | |
+ var dependencies = [ | |
+ 'er', 'ef', 'ub-ria', 'er-track', 'etpl', 'saber-cookie', | |
+ 'esui', 'echarts', 'zrender', 'mini-event', 'underscore', 'moment' | |
+ ]; | |
+ | |
+ // 3个启动脚本 | |
+ var config = { | |
+ 'startup/ui': { | |
+ files: [ | |
+ 'moment/lang/zh-cn', | |
+ 'esui', 'esui/**', | |
+ | |
+ '!esui/Sidebar' | |
+ ] | |
+ }, | |
+ 'startup/ria': { | |
+ files: [ | |
+ 'echarts', 'echarts/chart/line', 'echarts/chart/bar', 'echarts/chart/pie', 'echarts/chart/map', | |
+ 'er', 'er/**', | |
+ 'ef', 'ef/**', | |
+ 'ub-ria', 'ub-ria/**', | |
+ 'er-track', 'er-track/**', | |
+ 'etpl', 'etpl/**', | |
+ 'saber-cookie', 'saber-cookie/**', | |
+ 'common/extension', 'common/extension/**', | |
+ | |
+ '!mini-event', '!mini-event/**', | |
+ '!moment', '!moment/**', | |
+ '!underscore', '!underscore/**', | |
+ '!esui', '!esui/**' | |
+ ] | |
+ }, | |
+ 'startup/biz': { | |
+ files: [ | |
+ 'common/**', '**/ui/**', 'error/**', // 基础类 | |
+ '**/Dashboard', // 系统首页模块 | |
+ 'bulletin/**', 'dashboard/**', 'slot/**', 'order/**', 'delivery/**', // 业务模块 | |
+ | |
+ '!test/**', // 不要test代码 | |
+ | |
+ '!common/egg/**', 'common/egg/config', // 加载彩蛋配置,但不把彩蛋打包在一起 | |
+ | |
+ negative(expand(dependencies)) // 排除所有第三方库 | |
+ ] | |
+ } | |
+ }; | |
+ | |
+ var bizNamespaces = getBizNamespaces(); | |
+ bizNamespaces.forEach(function (bizNamespace) { | |
+ var exclude = [ | |
+ '!common/**', | |
+ '!**/ui/**', | |
+ negative(expand(dependencies)) | |
+ ]; | |
+ // 通用 | |
+ config[bizNamespace + '/List'] = { files: exclude }; | |
+ config[bizNamespace + '/Form'] = { files: exclude }; | |
+ config[bizNamespace + '/Detail'] = { files: exclude }; | |
+ config[bizNamespace + '/Read'] = { files: exclude }; | |
+ // 报表 | |
+ config[bizNamespace + '/Date'] = { files: exclude }; | |
+ config[bizNamespace + '/General'] = { files: exclude }; | |
+ config[bizNamespace + '/Hour'] = { files: exclude }; | |
+ }); | |
+ | |
+ return config; | |
+} | |
+ | |
+module.exports = generateModuleCombineConfig; | |
+ | |
+if (require.main === module) { | |
+ // console.log(getBizNamespaces()); | |
+ console.log(JSON.stringify(generateModuleCombineConfig(), null, 2)); | |
+} | |
Index: tool/build.js | |
=================================================================== | |
--- tool/build.js (revision 14842) | |
+++ tool/build.js (working copy) | |
@@ -1,69 +0,0 @@ | |
-var path = require('path'); | |
-var util = require('util'); | |
-var argv = require('./build/argv'); | |
- | |
-process.chdir(path.join(__dirname, '..')); | |
-console.log('Switched to ' + process.cwd()); | |
- | |
-var svnInfoOutput = ''; | |
-var svnInfo = require('child_process').exec( | |
- 'svn info', | |
- function (err) { | |
- var svnRevision; | |
- if (err) { | |
- svnRevision = +new Date(); | |
- console.warn( | |
- '\033[31m' | |
- + 'SVN client not found, ' | |
- + 'use timestamp as version number, ' | |
- + 'this may cause MD5 diferrence when deploy' | |
- + '\033[0m' | |
- ); | |
- } | |
- else { | |
- svnRevision = /Revision: (\d+)/.exec(svnInfoOutput)[1]; | |
- console.log('SVN is at revision ' + svnRevision); | |
- } | |
- | |
- console.log('Started building'); | |
- var startTime = new Date(); | |
- var args = ['build', '.', '--revision=' + svnRevision]; | |
- // Windows下必须用`cmd /c edp build . --revision=xxx`这么来,直接执行报错, | |
- // 使用`process.env.comspec`可以判断是否为Windows平台了 | |
- if (process.env.comspec) { | |
- args.unshift('edp'); | |
- args.unshift('/c'); | |
- } | |
- var build = require('child_process').spawn( | |
- process.env.comspec || 'edp', | |
- args.concat(process.argv.slice(2)), | |
- { stdio: 'inherit' } | |
- ); | |
- build.on( | |
- 'error', | |
- function (err) { | |
- console.log('Encountered error:', err); | |
- process.exit(); | |
- } | |
- ); | |
- build.on( | |
- 'close', | |
- function (err) { | |
- console.log('Replacing GBK files'); | |
- | |
- var copy = require('./build/copy'); | |
- copy( | |
- path.join('src', 'common', 'img', 'channel-example-csv.csv'), | |
- path.join(argv.output || 'output', 'asset-' + svnRevision, 'common', 'img', 'channel-example-csv.csv') | |
- ); | |
- copy( | |
- path.join('src', 'common', 'img', 'slot-example-csv.csv'), | |
- path.join(argv.output || 'output', 'asset-' + svnRevision, 'common', 'img', 'slot-example-csv.csv') | |
- ); | |
- | |
- console.log('done within ' + (new Date() - startTime) + 'ms'); | |
- } | |
- ); | |
- } | |
-); | |
-svnInfo.stdout.on('data', function (data) { svnInfoOutput += data; }); | |
\ No newline at end of file | |
Index: tool/util.js | |
=================================================================== | |
--- tool/util.js (revision 14842) | |
+++ tool/util.js (working copy) | |
@@ -5,51 +5,6 @@ | |
var moduleConfigFile = path.resolve(__dirname, '..', 'module.conf'); | |
-function getModulesFromDirectory(directory) { | |
- var modules = []; | |
- var files = require('glob').sync(directory + '/**') | |
- .filter(function (file) { return path.extname(file) === '.js' }); | |
- u.each( | |
- files, | |
- function (file) { | |
- modules.push.apply(modules, amd.getModuleId(file, moduleConfigFile)); | |
- } | |
- ); | |
- return modules; | |
-} | |
- | |
-exports.getModulesFromPackage = function () { | |
- var modules = []; | |
- u.each( | |
- arguments, | |
- function (package) { | |
- var file = amd.getModuleFile(package, moduleConfigFile); | |
- var directory = path.dirname(file); | |
- modules.push.apply(modules, getModulesFromDirectory(directory)); | |
- var packageConfigFile = path.join(directory, '..', 'package.json'); | |
- if (fs.existsSync(packageConfigFile)) { | |
- var packageConfig = JSON.parse(fs.readFileSync(packageConfigFile, 'utf-8')); | |
- if (packageConfig.main) { | |
- modules.push(package + '/' + packageConfig.main); | |
- } | |
- } | |
- } | |
- ); | |
- return modules; | |
-}; | |
- | |
-exports.getModulesFromNamespace = function () { | |
- var modules = []; | |
- u.each( | |
- arguments, | |
- function (namespace) { | |
- var directory = path.resolve(__dirname, '..', 'src', namespace); | |
- modules.push.apply(modules, getModulesFromDirectory(directory)); | |
- } | |
- ); | |
- return modules; | |
-}; | |
- | |
exports.getBizNamespaces = function () { | |
var src = path.resolve(__dirname, '..', 'src'); | |
var namespaces = fs.readdirSync(src) | |
@@ -59,3 +14,48 @@ | |
.map(function (namespace) { return 'tool/' + namespace }); | |
return namespaces.concat(toolNamespaces); | |
}; | |
+ | |
+exports.getSVNRevision = function (callback) { | |
+ var svnInfoOutput = ''; | |
+ var svnInfo = require('child_process').exec( | |
+ 'svn info', | |
+ function (err) { | |
+ if (err) { | |
+ callback(null); | |
+ return; | |
+ } | |
+ var svnRevision = /Revision: (\d+)/.exec(svnInfoOutput)[1]; | |
+ callback(svnRevision); | |
+ return; | |
+ | |
+ console.log('Started building'); | |
+ var startTime = new Date(); | |
+ var args = ['build', '.', '--revision=' + svnRevision]; | |
+ // Windows下必须用`cmd /c edp build . --revision=xxx`这么来,直接执行报错, | |
+ // 使用`process.env.comspec`可以判断是否为Windows平台了 | |
+ if (process.env.comspec) { | |
+ args.unshift('edp'); | |
+ args.unshift('/c'); | |
+ } | |
+ var build = require('child_process').spawn( | |
+ process.env.comspec || 'edp', | |
+ args.concat(process.argv.slice(2)), | |
+ { stdio: 'inherit' } | |
+ ); | |
+ build.on( | |
+ 'error', | |
+ function (err) { | |
+ console.log('Encountered error:', err); | |
+ process.exit(); | |
+ } | |
+ ); | |
+ build.on( | |
+ 'close', | |
+ function (err) { | |
+ console.log('done within ' + (new Date() - startTime) + 'ms'); | |
+ } | |
+ ); | |
+ } | |
+ ); | |
+ svnInfo.stdout.on('data', function (data) { svnInfoOutput += data; }); | |
+}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment