正在显示
12 个修改的文件
包含
252 行增加
和
16 行删除
bin/bundle-dll.js
0 → 100644
1 | +var resolveCwd = require('import-cwd'); | |
2 | +var webpack = resolveCwd('webpack'); | |
3 | +/** | |
4 | + * 根据传入dll配置打包库文件 | |
5 | + * webpack.dll.config | |
6 | + */ | |
7 | +function bundle(webpackConfig) { | |
8 | + return new Promise((resolve, reject) => { | |
9 | + const bundler = webpack(webpackConfig); | |
10 | + let bundlerRunCount = 0; | |
11 | + | |
12 | + function onComplete(err, stats) { | |
13 | + if (err) { | |
14 | + return reject(err); | |
15 | + } | |
16 | + | |
17 | + console.log(stats.toString(webpackConfig.stats)); | |
18 | + | |
19 | + if (++bundlerRunCount === (global.WATCH ? webpackConfig.length : 1)) { | |
20 | + return resolve(); | |
21 | + } | |
22 | + } | |
23 | + if (global.WATCH) { | |
24 | + bundler.watch(200, onComplete); | |
25 | + } else { | |
26 | + bundler.run(onComplete); | |
27 | + } | |
28 | + }); | |
29 | +} | |
30 | + | |
31 | +module.exports = bundle; | ... | ... |
bin/bundle.js
0 → 100644
1 | +var resolveCwd = require('import-cwd'); | |
2 | +var webpack = resolveCwd('webpack'); | |
3 | +/** | |
4 | + * 根据传入dll配置打包库文件 | |
5 | + * webpack.config.production | |
6 | + */ | |
7 | +function bundle(webpackConfig) { | |
8 | + return new Promise((resolve, reject) => { | |
9 | + const bundler = webpack(webpackConfig); | |
10 | + let bundlerRunCount = 0; | |
11 | + | |
12 | + function onComplete(err, stats) { | |
13 | + if (err) { | |
14 | + return reject(err); | |
15 | + } | |
16 | + | |
17 | + console.log(stats.toString(webpackConfig.stats)); | |
18 | + | |
19 | + if (++bundlerRunCount === (global.WATCH ? webpackConfig.length : 1)) { | |
20 | + return resolve(); | |
21 | + } | |
22 | + } | |
23 | + | |
24 | + if (global.WATCH) { | |
25 | + bundler.watch(200, onComplete); | |
26 | + } else { | |
27 | + bundler.run(onComplete); | |
28 | + } | |
29 | + }); | |
30 | +} | |
31 | + | |
32 | +module.exports = bundle; | ... | ... |
... | ... | @@ -9,10 +9,15 @@ var inquirer = require('inquirer'); |
9 | 9 | var chalk = require('chalk'); |
10 | 10 | var shell = require("shelljs"); |
11 | 11 | var parseArgs = require('minimist'); |
12 | -const fse = require('fs-extra'); | |
12 | +var fse = require('fs-extra'); | |
13 | 13 | var os = require('os'); |
14 | -const utils = require('./utils'); | |
15 | - | |
14 | +var utils = require('./utils'); | |
15 | +var bundleDll = require('./bundle-dll'); | |
16 | +var bundle = require('./bundle'); | |
17 | +var async = require('asyncawait/async'); | |
18 | +var await = require('asyncawait/await'); | |
19 | +var resolveCwd = require('import-cwd'); | |
20 | +require("@babel/register"); | |
16 | 21 | // import config from '../workai.tools.config'; |
17 | 22 | |
18 | 23 | var program = new commander.Command(); |
... | ... | @@ -125,7 +130,7 @@ program |
125 | 130 | if (option == 'hro') { |
126 | 131 | var hro_template_path = path.resolve(__dirname, '..', 'templates', 'hro_template'); |
127 | 132 | console.log(hro_template_path); |
128 | - fse.copySync(hro_template_path, './hro_template', { | |
133 | + fse.copySync(hro_template_path, './', { | |
129 | 134 | filter: (src, dest) => { |
130 | 135 | console.log(src); |
131 | 136 | if (src.indexOf('node_modules') != -1) |
... | ... | @@ -134,13 +139,78 @@ program |
134 | 139 | return true |
135 | 140 | } |
136 | 141 | }); |
137 | - shell.cd('./hro_template'); | |
142 | + // shell.cd('./'); | |
138 | 143 | shell.exec('yarn install'); |
139 | 144 | shell.exec('workai start'); |
140 | 145 | } |
141 | 146 | }); |
142 | 147 | |
143 | 148 | |
149 | + | |
150 | +/* | |
151 | +* deploy 构建项目 | |
152 | +*/ | |
153 | +program | |
154 | + .command('deploy [dll|all]') | |
155 | + .alias('d') | |
156 | + .description('构建项目') | |
157 | + .action(option => { | |
158 | + var opject_path = process.cwd(); | |
159 | + process.chdir(opject_path);//跳转到项目目录 | |
160 | + console.log(path.resolve(__dirname), process.cwd(), path.resolve(process.cwd(), 'configs')); | |
161 | + | |
162 | + if (option == 'dll') { | |
163 | + var hro_template_path = path.resolve(__dirname, '..', 'templates', 'hro_template'); | |
164 | + _checkEnv(["configs/webpack.dll.**", "!node_modules"]).then(flag => { | |
165 | + if (flag) { | |
166 | + var webpackDllConfig = resolveCwd('./configs/webpack.dll.config'); | |
167 | + bundleDll(webpackDllConfig).then(data => { | |
168 | + console.log("dll file is ok!"); | |
169 | + }); | |
170 | + // shell.exec('npx babel-node server/development.js'); | |
171 | + } else { | |
172 | + console.log("当前所在目录不是项目目录"); | |
173 | + } | |
174 | + }); | |
175 | + } else if (option == 'all') { | |
176 | + var hro_template_path = path.resolve(__dirname, '..', 'templates', 'hro_template'); | |
177 | + _checkEnv(["configs/webpack.production.**", "configs/webpack.dll.**", "!node_modules"]).then(flag => { | |
178 | + if (flag) { | |
179 | + var webpackDllConfig = resolveCwd('./configs/webpack.dll.config'); | |
180 | + var webpackConfig = resolveCwd('./configs/webpack.production.config'); | |
181 | + console.log(webpackDllConfig, webpackConfig); | |
182 | + // shell.exec('npx babel-node server/development.js'); | |
183 | + } else { | |
184 | + console.log("当前所在目录不是项目目录"); | |
185 | + } | |
186 | + }); | |
187 | + } else { | |
188 | + _checkEnv(["configs/webpack.production.**", "!node_modules"]).then(flag => { | |
189 | + if (flag) { | |
190 | + var webpackConfig = resolveCwd('./configs/webpack.production.config'); | |
191 | + bundle(webpackConfig).then(data => { | |
192 | + console.log("bundle file is ok!"); | |
193 | + }); | |
194 | + // shell.exec('npx babel-node server/development.js'); | |
195 | + } else { | |
196 | + console.log("当前所在目录不是项目目录"); | |
197 | + } | |
198 | + }); | |
199 | + } | |
200 | + }); | |
201 | + | |
202 | +/* | |
203 | +*生产模式启动项目 | |
204 | +*/ | |
205 | +program | |
206 | + .command('service [projectPath]') | |
207 | + .alias('s') | |
208 | + .description('生产模式启动') | |
209 | + .action(option => { | |
210 | + shell.exec('npx babel-node server/production.js'); | |
211 | + }); | |
212 | + | |
213 | + | |
144 | 214 | /* |
145 | 215 | *开发模式启动项目 |
146 | 216 | */ |
... | ... | @@ -149,7 +219,7 @@ program |
149 | 219 | .alias('dev') |
150 | 220 | .description('开发模式启动') |
151 | 221 | .action(option => { |
152 | - _checkEnv().then(flag => { | |
222 | + _checkEnv(["configs/webpack.develop.**", "!node_modules"]).then(flag => { | |
153 | 223 | console.log("222:::", flag, process.cwd(), path.resolve(__dirname), option); |
154 | 224 | if (flag) { |
155 | 225 | shell.exec('npx babel-node server/development.js'); |
... | ... | @@ -158,10 +228,13 @@ program |
158 | 228 | } |
159 | 229 | }); |
160 | 230 | }); |
161 | - | |
162 | -function _checkEnv() { | |
163 | - return utils.getPaths(["configs/webpack.**", "!node_modules"]).then(paths => { | |
164 | - return paths.length > 0; | |
231 | +/*环境检测 | |
232 | +*是否是项目环境 | |
233 | +*paths = [] 例:paths = ["configs/webpack.**", "!node_modules"] | |
234 | +*/ | |
235 | +function _checkEnv(paths) { | |
236 | + return utils.getPaths(paths).then(matching => { | |
237 | + return matching.length > 0; | |
165 | 238 | }); |
166 | 239 | } |
167 | 240 | ... | ... |
... | ... | @@ -1106,6 +1106,17 @@ |
1106 | 1106 | "map-cache": "^0.2.2" |
1107 | 1107 | } |
1108 | 1108 | }, |
1109 | + "fs-extra": { | |
1110 | + "version": "8.1.0", | |
1111 | + "resolved": "https://registry.npm.taobao.org/fs-extra/download/fs-extra-8.1.0.tgz", | |
1112 | + "integrity": "sha1-SdQ8RaiM2Wd2aMt74bRu/bjS4cA=", | |
1113 | + "dev": true, | |
1114 | + "requires": { | |
1115 | + "graceful-fs": "^4.2.0", | |
1116 | + "jsonfile": "^4.0.0", | |
1117 | + "universalify": "^0.1.0" | |
1118 | + } | |
1119 | + }, | |
1109 | 1120 | "fs-readdir-recursive": { |
1110 | 1121 | "version": "1.1.0", |
1111 | 1122 | "resolved": "http://registry.npm.taobao.org/fs-readdir-recursive/download/fs-readdir-recursive-1.1.0.tgz", |
... | ... | @@ -2083,6 +2094,15 @@ |
2083 | 2094 | "minimist": "^1.2.0" |
2084 | 2095 | } |
2085 | 2096 | }, |
2097 | + "jsonfile": { | |
2098 | + "version": "4.0.0", | |
2099 | + "resolved": "http://registry.npm.taobao.org/jsonfile/download/jsonfile-4.0.0.tgz", | |
2100 | + "integrity": "sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=", | |
2101 | + "dev": true, | |
2102 | + "requires": { | |
2103 | + "graceful-fs": "^4.1.6" | |
2104 | + } | |
2105 | + }, | |
2086 | 2106 | "kind-of": { |
2087 | 2107 | "version": "6.0.2", |
2088 | 2108 | "resolved": "http://registry.npm.taobao.org/kind-of/download/kind-of-6.0.2.tgz", |
... | ... | @@ -3058,6 +3078,12 @@ |
3058 | 3078 | "set-value": "^2.0.1" |
3059 | 3079 | } |
3060 | 3080 | }, |
3081 | + "universalify": { | |
3082 | + "version": "0.1.2", | |
3083 | + "resolved": "http://registry.npm.taobao.org/universalify/download/universalify-0.1.2.tgz", | |
3084 | + "integrity": "sha1-tkb2m+OULavOzJ1mOcgNwQXvqmY=", | |
3085 | + "dev": true | |
3086 | + }, | |
3061 | 3087 | "unset-value": { |
3062 | 3088 | "version": "1.0.0", |
3063 | 3089 | "resolved": "http://registry.npm.taobao.org/unset-value/download/unset-value-1.0.0.tgz", | ... | ... |
... | ... | @@ -20,12 +20,14 @@ |
20 | 20 | "@babel/core": "^7.4.5", |
21 | 21 | "@babel/node": "^7.4.5", |
22 | 22 | "@babel/register": "^7.4.4", |
23 | + "asyncawait": "^1.0.8", | |
23 | 24 | "chalk": "^2.4.2", |
24 | 25 | "commander": "^2.20.0", |
25 | 26 | "es-checker": "^1.4.1", |
26 | 27 | "fs-extra": "^8.1.0", |
27 | 28 | "git-clone": "^0.1.0", |
28 | 29 | "globby": "^9.2.0", |
30 | + "import-cwd": "^3.0.0", | |
29 | 31 | "inquirer": "^6.4.1", |
30 | 32 | "minimist": "^1.2.0", |
31 | 33 | "rimraf": "^2.6.3", | ... | ... |
... | ... | @@ -5,6 +5,8 @@ |
5 | 5 | ], |
6 | 6 | "plugins": [ |
7 | 7 | "@babel/plugin-syntax-dynamic-import", |
8 | - "@babel/plugin-proposal-class-properties" | |
8 | + "@babel/plugin-proposal-class-properties", | |
9 | + "@babel/plugin-proposal-export-default-from", | |
10 | + "@babel/plugin-proposal-export-namespace-from" | |
9 | 11 | ] |
10 | 12 | } |
\ No newline at end of file | ... | ... |
... | ... | @@ -24,7 +24,12 @@ module.exports = { |
24 | 24 | loader: "babel-loader", |
25 | 25 | options: { |
26 | 26 | presets: ["@babel/env", "@babel/react"], |
27 | - plugins: ["@babel/plugin-proposal-class-properties", "@babel/plugin-syntax-dynamic-import"] | |
27 | + plugins: [ | |
28 | + "@babel/plugin-proposal-class-properties", | |
29 | + "@babel/plugin-syntax-dynamic-import", | |
30 | + "@babel/plugin-proposal-export-default-from", | |
31 | + "@babel/plugin-proposal-export-namespace-from" | |
32 | + ] | |
28 | 33 | } |
29 | 34 | } |
30 | 35 | }, { | ... | ... |
... | ... | @@ -94,8 +94,13 @@ module.exports = { |
94 | 94 | loaders: [{ |
95 | 95 | loader: "babel-loader", |
96 | 96 | options: { |
97 | - presets: ["env", "react", "stage-0"], | |
98 | - plugins: [["import", { "libraryName": "antd" }, "ant"]] | |
97 | + presets: ["@babel/env", "@babel/react"], | |
98 | + plugins: [ | |
99 | + "@babel/plugin-proposal-class-properties", | |
100 | + "@babel/plugin-syntax-dynamic-import", | |
101 | + "@babel/plugin-proposal-export-default-from", | |
102 | + "@babel/plugin-proposal-export-namespace-from" | |
103 | + ] | |
99 | 104 | } |
100 | 105 | }] |
101 | 106 | }), | ... | ... |
... | ... | @@ -17,6 +17,7 @@ |
17 | 17 | "isomorphic-fetch": "^2.2.1", |
18 | 18 | "localforage": "^1.7.3", |
19 | 19 | "moment": "^2.24.0", |
20 | + "plupload": "^2.3.6", | |
20 | 21 | "prop-types": "^15.7.2", |
21 | 22 | "rc-animate": "^2.8.3", |
22 | 23 | "react": "^16.8.6", |
... | ... | @@ -31,23 +32,30 @@ |
31 | 32 | "redux-saga": "^1.0.5", |
32 | 33 | "regenerator-runtime": "^0.13.2", |
33 | 34 | "uuid": "^3.3.2", |
34 | - "workai-express": "git+http://gitlab.workai.com.cn/fanwh/workai-express.git#aecbfb5" | |
35 | + "workai-express": "git+http://gitlab.workai.com.cn/fanwh/workai-express.git#18cf518" | |
35 | 36 | }, |
36 | 37 | "devDependencies": { |
37 | 38 | "@babel/cli": "^7.4.4", |
38 | 39 | "@babel/core": "^7.4.5", |
39 | 40 | "@babel/node": "^7.4.5", |
40 | 41 | "@babel/plugin-proposal-class-properties": "^7.5.0", |
42 | + "@babel/plugin-proposal-export-default-from": "^7.5.2", | |
43 | + "@babel/plugin-proposal-export-namespace-from": "^7.5.2", | |
41 | 44 | "@babel/plugin-syntax-dynamic-import": "^7.2.0", |
42 | 45 | "@babel/preset-env": "^7.4.5", |
43 | 46 | "@babel/preset-react": "^7.0.0", |
44 | 47 | "babel-loader": "^8.0.6", |
48 | + "babel-plugin-import": "^1.12.0", | |
45 | 49 | "css-loader": "^3.0.0", |
50 | + "happypack": "^5.0.1", | |
46 | 51 | "html-webpack-plugin": "^3.2.0", |
47 | 52 | "less": "^3.9.0", |
48 | 53 | "less-loader": "^5.0.0", |
54 | + "mini-css-extract-plugin": "^0.7.0", | |
49 | 55 | "open-browser-webpack-plugin": "^0.0.5", |
56 | + "optimize-css-assets-webpack-plugin": "^5.0.3", | |
50 | 57 | "style-loader": "^0.23.1", |
58 | + "uglifyjs-webpack-plugin": "^2.1.3", | |
51 | 59 | "webpack": "^4.35.2", |
52 | 60 | "webpack-dev-middleware": "^3.7.0", |
53 | 61 | "webpack-hot-middleware": "^2.25.0" | ... | ... |
1 | +/* eslint-disable no-var */ | |
2 | +import path from 'path'; | |
3 | +import workaiExpress from 'workai-express'; | |
4 | + | |
5 | +var app = workaiExpress.app; | |
6 | +var IoC = workaiExpress.IoC; | |
7 | +var bootable = workaiExpress.bootable; | |
8 | + | |
9 | +IoC.use(IoC.dir(path.join(__dirname, 'boot')));//加载配置文件 | |
10 | + | |
11 | + | |
12 | +app.phase(bootable.di.routes(path.join(__dirname, 'routes', 'index.js')));//载入路由 | |
13 | + | |
14 | + | |
15 | +app.boot(function (err) {//配置插件加载完启动server | |
16 | + if (err) { | |
17 | + console.log(err); | |
18 | + process.exit(-1); | |
19 | + return; | |
20 | + } | |
21 | +}); | |
\ No newline at end of file | ... | ... |
... | ... | @@ -269,6 +269,14 @@ async-each@^1.0.1: |
269 | 269 | version "1.0.3" |
270 | 270 | resolved "https://registry.npm.taobao.org/async-each/download/async-each-1.0.3.tgz#b727dbf87d7651602f06f4d4ac387f47d91b0cbf" |
271 | 271 | |
272 | +asyncawait@^1.0.8: | |
273 | + version "1.0.8" | |
274 | + resolved "https://registry.npm.taobao.org/asyncawait/download/asyncawait-1.0.8.tgz#ecd25d68d870ac36cd96338f844e2a4d2efb7242" | |
275 | + dependencies: | |
276 | + bluebird "^3.1.1" | |
277 | + fibers "^2.0.2" | |
278 | + lodash "^4.17.11" | |
279 | + | |
272 | 280 | atob@^2.1.1: |
273 | 281 | version "2.1.2" |
274 | 282 | resolved "https://registry.npm.taobao.org/atob/download/atob-2.1.2.tgz#6d9517eb9e030d2436666651e86bd9f6f13533c9" |
... | ... | @@ -293,6 +301,10 @@ binary-extensions@^1.0.0: |
293 | 301 | version "1.13.1" |
294 | 302 | resolved "https://registry.npm.taobao.org/binary-extensions/download/binary-extensions-1.13.1.tgz#598afe54755b2868a5330d2aff9d4ebb53209b65" |
295 | 303 | |
304 | +bluebird@^3.1.1: | |
305 | + version "3.5.5" | |
306 | + resolved "https://registry.npm.taobao.org/bluebird/download/bluebird-3.5.5.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fbluebird%2Fdownload%2Fbluebird-3.5.5.tgz#a8d0afd73251effbbd5fe384a77d73003c17a71f" | |
307 | + | |
296 | 308 | brace-expansion@^1.1.7: |
297 | 309 | version "1.1.11" |
298 | 310 | resolved "https://registry.npm.taobao.org/brace-expansion/download/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" |
... | ... | @@ -641,6 +653,10 @@ fast-glob@^2.2.6: |
641 | 653 | merge2 "^1.2.3" |
642 | 654 | micromatch "^3.1.10" |
643 | 655 | |
656 | +fibers@^2.0.2: | |
657 | + version "2.0.2" | |
658 | + resolved "https://registry.npm.taobao.org/fibers/download/fibers-2.0.2.tgz#36db63ea61c543174e2264675fea8c2783371366" | |
659 | + | |
644 | 660 | figures@^2.0.0: |
645 | 661 | version "2.0.0" |
646 | 662 | resolved "https://registry.npm.taobao.org/figures/download/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962" |
... | ... | @@ -850,6 +866,18 @@ ignore@^4.0.3: |
850 | 866 | version "4.0.6" |
851 | 867 | resolved "https://registry.npm.taobao.org/ignore/download/ignore-4.0.6.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fignore%2Fdownload%2Fignore-4.0.6.tgz#750e3db5862087b4737ebac8207ffd1ef27b25fc" |
852 | 868 | |
869 | +import-cwd@^3.0.0: | |
870 | + version "3.0.0" | |
871 | + resolved "https://registry.npm.taobao.org/import-cwd/download/import-cwd-3.0.0.tgz#20845547718015126ea9b3676b7592fb8bd4cf92" | |
872 | + dependencies: | |
873 | + import-from "^3.0.0" | |
874 | + | |
875 | +import-from@^3.0.0: | |
876 | + version "3.0.0" | |
877 | + resolved "https://registry.npm.taobao.org/import-from/download/import-from-3.0.0.tgz#055cfec38cd5a27d8057ca51376d7d3bf0891966" | |
878 | + dependencies: | |
879 | + resolve-from "^5.0.0" | |
880 | + | |
853 | 881 | inflight@^1.0.4: |
854 | 882 | version "1.0.6" |
855 | 883 | resolved "https://registry.npm.taobao.org/inflight/download/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" |
... | ... | @@ -1474,6 +1502,10 @@ repeat-string@^1.6.1: |
1474 | 1502 | version "1.6.1" |
1475 | 1503 | resolved "https://registry.npm.taobao.org/repeat-string/download/repeat-string-1.6.1.tgz#8dcae470e1c88abc2d600fff4a776286da75e637" |
1476 | 1504 | |
1505 | +resolve-from@^5.0.0: | |
1506 | + version "5.0.0" | |
1507 | + resolved "https://registry.npm.taobao.org/resolve-from/download/resolve-from-5.0.0.tgz#c35225843df8f776df21c57557bc087e9dfdfc69" | |
1508 | + | |
1477 | 1509 | resolve-url@^0.2.1: |
1478 | 1510 | version "0.2.1" |
1479 | 1511 | resolved "https://registry.npm.taobao.org/resolve-url/download/resolve-url-0.2.1.tgz#2c637fe77c893afd2a663fe21aa9080068e2052a" | ... | ... |
请
注册
或
登录
后发表评论