jjb-cmd 1.0.17 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/bin/command-old.js +65 -0
  2. package/bin/command.js +52 -40
  3. package/package.json +7 -4
  4. package/src/new/cmd.init/index.js +48 -0
  5. package/src/{cli.init → new/cmd.init.copy/lib}/jjb.config.json +3 -8
  6. package/src/{cli.init → new/cmd.init.copy/lib}/jjb.script/build.js +0 -0
  7. package/src/new/cmd.init.copy/lib/jjb.script/config.js +149 -0
  8. package/src/{cli.init → new/cmd.init.copy/lib}/jjb.script/proxy.js +0 -0
  9. package/src/{cli.init → new/cmd.init.copy/lib}/jjb.script/server.js +0 -0
  10. package/src/{cli.init → new/cmd.init.copy/lib}/jjb.script/utils.js +0 -0
  11. package/src/{cli.init → new/cmd.init.copy/lib}/package.json +2 -2
  12. package/src/new/cmd.init.copy/lib/src/index.js +1 -0
  13. package/src/{cli.init → new/cmd.init.copy/lib}/webstorm.config.js +0 -0
  14. package/src/new/cmd.init.copy/micro-app/jjb.config.json +40 -0
  15. package/src/new/cmd.init.copy/micro-app/jjb.script/build.js +11 -0
  16. package/src/new/cmd.init.copy/micro-app/jjb.script/config.js +222 -0
  17. package/src/new/cmd.init.copy/micro-app/jjb.script/proxy.js +19 -0
  18. package/src/new/cmd.init.copy/micro-app/jjb.script/server.js +29 -0
  19. package/src/new/cmd.init.copy/micro-app/jjb.script/utils.js +13 -0
  20. package/src/new/cmd.init.copy/micro-app/package.json +65 -0
  21. package/src/new/cmd.init.copy/micro-app/public/index.html +22 -0
  22. package/src/new/cmd.init.copy/micro-app/src/enumerate/namespace/index.js +3 -0
  23. package/src/new/cmd.init.copy/micro-app/src/index.js +24 -0
  24. package/src/new/cmd.init.copy/micro-app/src/models/main/index.js +9 -0
  25. package/src/new/cmd.init.copy/micro-app/src/pages/index.js +11 -0
  26. package/src/new/cmd.init.copy/micro-app/webstorm.config.js +18 -0
  27. package/src/new/cmd.init.copy/react-component/jjb.config.json +33 -0
  28. package/src/new/cmd.init.copy/react-component/jjb.script/build.js +11 -0
  29. package/src/new/cmd.init.copy/react-component/jjb.script/config.js +159 -0
  30. package/src/new/cmd.init.copy/react-component/jjb.script/proxy.js +22 -0
  31. package/src/new/cmd.init.copy/react-component/jjb.script/server.js +29 -0
  32. package/src/new/cmd.init.copy/react-component/jjb.script/utils.js +13 -0
  33. package/src/new/cmd.init.copy/react-component/package.json +56 -0
  34. package/src/new/cmd.init.copy/react-component/src/index.js +11 -0
  35. package/src/new/cmd.init.copy/react-component/webstorm.config.js +16 -0
  36. package/src/new/cmd.install/config.js +31 -0
  37. package/src/new/cmd.install/index.js +255 -0
  38. package/src/{cli.install → new/cmd.install}/tools.js +5 -2
  39. package/src/new/cmd.push/index.js +54 -0
  40. package/src/new/cmd.reglist/index.js +22 -0
  41. package/src/new/cmd.rm-rf/index.js +58 -0
  42. package/src/new/cmd.version/index.js +34 -0
  43. package/src/{cli.dva.register.saas.txt → old/cli.dva.register.saas.txt} +0 -0
  44. package/src/{cli.dva.register.spa.txt → old/cli.dva.register.spa.txt} +0 -0
  45. package/src/{cli.dva.router.saas.txt → old/cli.dva.router.saas.txt} +0 -0
  46. package/src/{cli.dva.router.spa.txt → old/cli.dva.router.spa.txt} +0 -0
  47. package/src/old/cli.init/jjb.config.json +40 -0
  48. package/src/old/cli.init/jjb.script/build.js +11 -0
  49. package/src/{cli.init → old/cli.init}/jjb.script/config.js +12 -11
  50. package/src/old/cli.init/jjb.script/proxy.js +19 -0
  51. package/src/old/cli.init/jjb.script/server.js +29 -0
  52. package/src/old/cli.init/jjb.script/utils.js +13 -0
  53. package/src/old/cli.init/package.json +65 -0
  54. package/src/{cli.init → old/cli.init}/public/index.html +7 -1
  55. package/src/{cli.init → old/cli.init}/src/enumerate/menu/index.js +0 -0
  56. package/src/old/cli.init/src/enumerate/namespace/index.js +3 -0
  57. package/src/{cli.init → old/cli.init}/src/index.js +1 -1
  58. package/src/old/cli.init/src/models/main/index.js +31 -0
  59. package/src/old/cli.init/src/pages/index.js +9 -0
  60. package/src/old/cli.init/webstorm.config.js +18 -0
  61. package/src/{cli.init.js → old/cli.init.js} +1 -4
  62. package/src/{cli.install → old/cli.install}/config.js +12 -0
  63. package/src/{cli.install → old/cli.install}/index.js +3 -5
  64. package/src/old/cli.install/tools.js +230 -0
  65. package/src/{cli.merge.js → old/cli.merge.js} +0 -0
  66. package/src/{cli.pull.js → old/cli.pull.js} +0 -0
  67. package/src/{cli.pull2.js → old/cli.pull2.js} +4 -6
  68. package/src/{cli.rm-rf.js → old/cli.rm-rf.js} +11 -11
  69. package/src/{progress-bar.js → old/progress-bar.js} +0 -0
  70. package/src/{util.js → old/util.js} +0 -0
  71. package/src/cli.init/src/enumerate/namespace/index.js +0 -3
  72. package/src/cli.init/src/models/demo/index.js +0 -10
  73. package/src/cli.init/src/pages/index.js +0 -14
@@ -13,7 +13,7 @@ const config = require(requireResolve('jjb.config.json'));
13
13
  const packageJSON = require(requireResolve('package.json'));
14
14
  const server = (config.server || {});
15
15
  const environment = (config.environment || {})[ process.env.NODE_ENV ];
16
- const windowInject = (config.windowInject || {});
16
+ const windowInject = Object.assign((config.windowInject || {}), environment);
17
17
  const contextInject = (config.contextInject || {});
18
18
  const contextData = {
19
19
  ...environment,
@@ -31,6 +31,7 @@ module.exports = mode => {
31
31
  entry: './src/index.js',
32
32
  // 输出
33
33
  output: {
34
+ libraryTarget: 'umd',
34
35
  // 指定输出目录文件名
35
36
  path: path.resolve(__dirname, '../dist'),
36
37
  // 定义全局变量,暴露到‘window’对象中
@@ -38,9 +39,7 @@ module.exports = mode => {
38
39
  // 指定编译的‘js’存放目录文件名称
39
40
  filename: 'static/js/[id].js',
40
41
  // 输出公共路径
41
- publicPath: '/',
42
- // 默认暴露‘window’此处修改为暴露到‘exports’中
43
- libraryTarget: 'umd'
42
+ publicPath: '/'
44
43
  },
45
44
  // ‘node.module’
46
45
  module: {
@@ -87,10 +86,10 @@ module.exports = mode => {
87
86
  include: [
88
87
  // 整个‘src’目录
89
88
  path.resolve(__dirname, '../src'),
90
- // ‘jjb-common’库
91
- path.resolve(__dirname, '../node_modules/jjb-common'),
92
- // ‘jjb-react-admin-component’库
93
- path.resolve(__dirname, '../node_modules/jjb-react-admin-component')
89
+ // ‘jjb-dva-runtime’库
90
+ path.resolve(__dirname, '../node_modules/jjb-dva-runtime'),
91
+ // ‘jjb-common-decorator’库
92
+ path.resolve(__dirname, '../node_modules/jjb-common-decorator')
94
93
  ],
95
94
  // 配置‘babel-loader’
96
95
  options: {
@@ -154,9 +153,7 @@ module.exports = mode => {
154
153
  resolve: {
155
154
  // 为‘import’或‘require’定义别名路径
156
155
  alias: {
157
- '~': requireResolve('src'),
158
- 'common': requireResolve('src/common'),
159
- 'components': requireResolve('src/components')
156
+ '~': requireResolve('src')
160
157
  }
161
158
  },
162
159
  // 插件
@@ -182,6 +179,10 @@ module.exports = mode => {
182
179
  // 每次打包前删除‘dist’目录
183
180
  new CleanWebpackPlugin()
184
181
  ],
182
+ // 外部扩展
183
+ externals: {
184
+ 'window:jjb-common-lib': 'jjbCommonLib'
185
+ },
185
186
  // 打包优化
186
187
  optimization: isProduction
187
188
  ? {
@@ -0,0 +1,19 @@
1
+ const express = require('express');
2
+ const history = require('connect-history-api-fallback');
3
+ const app = express();
4
+ const port = '8766';
5
+
6
+ /**
7
+ * 单页面应用需要的历史记录模块
8
+ */
9
+ app.use(history());
10
+
11
+ /**
12
+ * 输出静态资源
13
+ */
14
+ app.use(express.static('../dist'));
15
+
16
+ /**
17
+ * 监听端口
18
+ */
19
+ app.listen(port, () => console.log(`Your application is running here: http://localhost:${port}`));
@@ -0,0 +1,29 @@
1
+ const Server = require('webpack-dev-server');
2
+ const webpack = require('webpack');
3
+ const { hasEnvironment } = require('./utils');
4
+
5
+ if (!hasEnvironment()) {
6
+ throw Error('jjb.script[server]: 启动server需要提供NODE_ENV变量,请确认你所运行的脚本是否正确?');
7
+ }
8
+
9
+ const config = require('./config')('development');
10
+
11
+ new Server({
12
+ host: config.server.host || '127.0.0.1',
13
+ port: config.server.port || '8080',
14
+ headers: {
15
+ 'Access-Control-Allow-Origin': '*',
16
+ 'Access-Control-Allow-Methods': '*',
17
+ 'Access-Control-Allow-Headers': '*'
18
+ },
19
+ compress: true,
20
+ client: {
21
+ overlay: {
22
+ errors: true,
23
+ warnings: true
24
+ }
25
+ },
26
+ historyApiFallback: {
27
+ disableDotRule: true
28
+ }
29
+ }, webpack(config.webpack)).startCallback(() => console.log('jjb.server 服务已启动,正在编译。'));
@@ -0,0 +1,13 @@
1
+ const path = require('path');
2
+ /**
3
+ * @description 是否有环境变量‘NODE_ENV’
4
+ * @return {boolean}
5
+ */
6
+ exports.hasEnvironment = () => process.env.NODE_ENV !== undefined;
7
+
8
+ /**
9
+ * @description 文件解析
10
+ * @param name {string}
11
+ * @return {`${string}\\${string}`}
12
+ */
13
+ exports.requireResolve = name => `${path.resolve(__dirname, '..')}\\${name}`;
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "jjbMicroApp",
3
+ "version": "1.0.0",
4
+ "description": "jjb-micro-app",
5
+ "main": "index.js",
6
+ "scripts": {
7
+ "serve": "node jjb.script/server.js",
8
+ "build": "node jjb.script/build.js",
9
+ "serve:development": "cross-env NODE_ENV=development npm run serve",
10
+ "serve:test": "cross-env NODE_ENV=test npm run serve",
11
+ "serve:release": "cross-env NODE_ENV=release npm run serve",
12
+ "serve:production": "cross-env NODE_ENV=production npm run serve",
13
+ "build:development": "cross-env NODE_ENV=development npm run build",
14
+ "build:test": "cross-env NODE_ENV=test npm run build",
15
+ "build:release": "cross-env NODE_ENV=release npm run build",
16
+ "build:production": "cross-env NODE_ENV=production npm run build",
17
+ "jjb-cmd:install": "jjb-cmd install"
18
+ },
19
+ "author": "XiWell",
20
+ "license": "MIT",
21
+ "devDependencies": {
22
+ "@babel/core": "^7.19.3",
23
+ "@babel/plugin-proposal-decorators": "^7.19.3",
24
+ "@babel/preset-react": "^7.18.6",
25
+ "babel-loader": "^8.2.5",
26
+ "babel-plugin-import": "^1.13.5",
27
+ "clean-webpack-plugin": "^4.0.0",
28
+ "connect-history-api-fallback": "^2.0.0",
29
+ "cross-env": "^7.0.3",
30
+ "css-loader": "^6.7.1",
31
+ "css-minimizer-webpack-plugin": "^4.2.1",
32
+ "express": "^4.18.2",
33
+ "file-loader": "^6.2.0",
34
+ "html-webpack-plugin": "^5.5.0",
35
+ "less": "^4.1.3",
36
+ "less-loader": "^11.1.0",
37
+ "mini-css-extract-plugin": "^2.6.1",
38
+ "style-loader": "^3.3.1",
39
+ "terser-webpack-plugin": "^5.3.6",
40
+ "uglifyjs-webpack-plugin": "^2.2.0",
41
+ "url-loader": "^4.1.1",
42
+ "webpack": "^5.74.0",
43
+ "webpack-bundle-analyzer": "^4.6.1",
44
+ "webpack-cli": "^4.10.0",
45
+ "webpack-dev-server": "^4.11.1"
46
+ },
47
+ "dependencies": {
48
+ "@ant-design/icons": "^4.7.0",
49
+ "antd": "^4.23.5",
50
+ "axios": "^1.1.2",
51
+ "crypto-js": "^4.1.1",
52
+ "dva": "^2.6.0-beta.22",
53
+ "history": "^5.3.0",
54
+ "moment": "^2.29.4",
55
+ "prop-types": "^15.8.1",
56
+ "qiankun": "^2.8.3",
57
+ "react": "^17.0.2",
58
+ "react-cropper": "^2.1.8",
59
+ "react-dom": "^17.0.2",
60
+ "react-router-dom": "^5.2.0",
61
+ "watch-props": "^0.0.3",
62
+ "jjb-dva-runtime": "1.0.0",
63
+ "jjb-common-decorator": "1.0.0"
64
+ }
65
+ }
@@ -7,9 +7,15 @@
7
7
  <title>
8
8
  <%= htmlWebpackPlugin.options.title %>
9
9
  </title>
10
+ <script>
11
+ window.__JJB_environment = {
12
+ API_HOST: '<%= htmlWebpackPlugin.options.API_HOST %>'
13
+ };
14
+ </script>
15
+ <script src="<%= htmlWebpackPlugin.options.jjbCommonLibUrl %>"></script>
10
16
  </head>
11
17
  <body>
12
18
  <noscript>此网页需要开启JavaScript功能。</noscript>
13
- <div id="root"></div>
19
+ <div id="root" style="width: 100%; height: 100%; position: relative"></div>
14
20
  </body>
15
21
  </html>
@@ -0,0 +1,3 @@
1
+ import { defineNamespace } from 'jjb-dva-runtime';
2
+
3
+ export const NS_MAIN = defineNamespace('main');
@@ -1,4 +1,4 @@
1
- import { registerApplication } from 'jjb-common/dva/automatic/register';
1
+ import { registerApplication } from 'jjb-dva-runtime/automatic/register';
2
2
 
3
3
  const app = registerApplication();
4
4
 
@@ -0,0 +1,31 @@
1
+ import { NS_MAIN } from '~/enumerate/namespace';
2
+ import { registerModelNew } from 'jjb-dva-runtime';
3
+ import { GetBaseApplicationConfig } from '~/api/main';
4
+
5
+ export default registerModelNew(NS_MAIN, {
6
+ state: {
7
+ loading: false
8
+ },
9
+ effects: {
10
+ /**
11
+ * @return {Promise<{IResponse}>}
12
+ */
13
+ getBaseApplicationConfigAction: () => [
14
+ 'loading',
15
+ GetBaseApplicationConfig,
16
+ ({
17
+ tabs = {},
18
+ aside = {},
19
+ header = {},
20
+ content = {}
21
+ }) => ({
22
+ baseApplicationConfig: {
23
+ tabs,
24
+ aside,
25
+ header,
26
+ content
27
+ }
28
+ })
29
+ ]
30
+ }
31
+ });
@@ -0,0 +1,9 @@
1
+ import React from 'react';
2
+
3
+ export default class App extends React.Component {
4
+ render () {
5
+ return (
6
+ <h1>Hello World</h1>
7
+ );
8
+ }
9
+ }
@@ -0,0 +1,18 @@
1
+ 'use strict';
2
+ const path = require('path');
3
+
4
+ function resolve (dir) {
5
+ return path.join(__dirname, '.', dir);
6
+ }
7
+
8
+ module.exports = {
9
+ context: path.resolve(__dirname, './'),
10
+ resolve: {
11
+ extensions: [ '.js' ],
12
+ alias: {
13
+ '~': resolve('src/'),
14
+ 'common': resolve('src/common'),
15
+ 'components': resolve('src/components')
16
+ }
17
+ }
18
+ };
@@ -2,10 +2,7 @@ const path = require('path');
2
2
  const readline = require('readline');
3
3
  const { f_file_copy } = require('./cli.install/tools');
4
4
  const fs = require('fs');
5
- const A = readline.createInterface({
6
- input: process.stdin,
7
- output: process.stdout
8
- });
5
+
9
6
  module.exports = () => {
10
7
  /**
11
8
  * 下发数据根路径
@@ -11,6 +11,18 @@ exports.CLOUD_PROJECT = {
11
11
  token: 'FT3pKzxpRynFkmddJ9Bs',
12
12
  projectId: 340
13
13
  },
14
+ 'jjb-dva-runtime': {
15
+ token: 'hLqARY89CN6fUD3yg4NL',
16
+ projectId: 571
17
+ },
18
+ 'jjb-common-lib': {
19
+ token: 'e9njpBd1nS_LREN8GFpR',
20
+ projectId: 572
21
+ },
22
+ 'jjb-common-decorator': {
23
+ token: 'gPSit8aJsLVmNzuQ5Cy4',
24
+ projectId: 574
25
+ },
14
26
  'vue-unisass-component': {
15
27
  token: 'd4wQ7dzEjYPsgVbKnYei',
16
28
  projectId: 339
@@ -206,7 +206,7 @@ module.exports = () => {
206
206
  fs.writeFileSync(`${item.path}\\index.js`, codeList.join('\n'));
207
207
  }
208
208
  }
209
- if (folder_name === 'common') {
209
+ if (folder_name === 'jjb-common') {
210
210
  /**
211
211
  * 组装dva/automatic路径
212
212
  */
@@ -267,7 +267,7 @@ module.exports = () => {
267
267
  /**
268
268
  * 特殊处理:为了避免与node_modules其他依赖重名,添加一个标识符"jjb-"
269
269
  */
270
- const package_name = `jjb-${folder_name}`;
270
+ const package_name = folder_name;
271
271
  /**
272
272
  * 文件操作:判断node_modules目录下是否已存在
273
273
  */
@@ -298,9 +298,7 @@ module.exports = () => {
298
298
  /**
299
299
  * 特殊处理:由于老项目问题,此处要将react-admin-component转换为components(仅限src模式)
300
300
  */
301
- const t_name = folder_name === 'react-admin-component'
302
- ? 'components'
303
- : folder_name;
301
+ const t_name = 'react-admin-component';
304
302
  /**
305
303
  * 文件操作:判断src目录下是否已存在
306
304
  */
@@ -0,0 +1,230 @@
1
+ const fs = require('fs');
2
+ const os = require('os');
3
+ const {
4
+ GIT_HOST,
5
+ GIT_TEMP_DIR,
6
+ CLOUD_PROJECT
7
+ } = require('./config');
8
+
9
+ /**
10
+ * @description 删除全部
11
+ * @param path {string} 路径
12
+ */
13
+ exports.f_rm_rf = function (path) {
14
+ if (fs.existsSync(path)) {
15
+ const list = fs.readdirSync(path);
16
+ for (let i = 0; i < list.length; i++) {
17
+ const item = list[ i ];
18
+ const vPath = `${path}/${item}`;
19
+ if (fs.statSync(vPath).isDirectory()) {
20
+ exports.f_rm_rf(vPath);
21
+ fs.rmdirSync(vPath);
22
+ } else {
23
+ fs.unlinkSync(vPath);
24
+ }
25
+ }
26
+ }
27
+ };
28
+
29
+ /**
30
+ * @typedef {object} GitResource
31
+ * @property {string} path
32
+ * @property {string} compress
33
+ * @property {string} repository
34
+ */
35
+
36
+ /**
37
+ * @description 拉取git资源
38
+ * @param installResources {Resource[]} 资源名称
39
+ * @return {GitResource[]}
40
+ */
41
+ exports.f_pull_git_repository = function (installResources = []) {
42
+ return installResources.map(item => {
43
+ const resource = CLOUD_PROJECT[ item.name ] || undefined;
44
+ const template = os.tmpdir();
45
+ return {
46
+ path: `${template}\\${GIT_TEMP_DIR}\\${item.name}.zip`,
47
+ compress: `${template}\\${GIT_TEMP_DIR}\\${item.name}_zip`,
48
+ repository: `${GIT_HOST}/api/v4/projects/${resource.projectId}/repository/archive.zip?private_token=${resource.token}&ref=master`
49
+ };
50
+ });
51
+ };
52
+
53
+ /**
54
+ * @description 扫描是否存在jjb.config.json
55
+ * @param root 路径
56
+ * @returns {boolean}
57
+ */
58
+ exports.f_scan_jjb_config_json = function (root) {
59
+ return fs.existsSync(`${root}\\jjb.config.json`);
60
+ };
61
+
62
+ /**
63
+ * @typedef {object} JJB_CONFIG_JSON
64
+ * @property {string} projectType
65
+ * @property {string} installTarget
66
+ * @property {Resource[]} installResources
67
+ */
68
+
69
+ /**
70
+ * @description 验证规则
71
+ * @param root {string} 路径
72
+ * @return {JJB_CONFIG_JSON}
73
+ */
74
+ exports.f_scan_jjb_config_json_rules = function (root) {
75
+ let jjb_config_json = {};
76
+ try {
77
+ jjb_config_json = JSON.parse(fs.readFileSync(`${root}\\jjb.config.json`).toString());
78
+ } catch (e) {
79
+ console.log('【Error】:[jjb.config.json]文件解析失败,请确认是否配置正确。');
80
+ process.exit(0);
81
+ }
82
+ if (!('projectType' in jjb_config_json)) {
83
+ console.log('【Error】:[jjb.config.json]文件配置无效,需要projectType属性。');
84
+ process.exit(0);
85
+ }
86
+ if (!('installTarget' in jjb_config_json)) {
87
+ console.log('【Error】:[jjb.config.json]文件配置无效,需要installTarget属性。');
88
+ process.exit(0);
89
+ }
90
+ if (!('installResources' in jjb_config_json)) {
91
+ console.log('【Error】:[jjb.config.json]文件配置无效,需要installResources属性。');
92
+ process.exit(0);
93
+ }
94
+ if (typeof jjb_config_json.projectType !== 'string') {
95
+ console.log('【Error】:[jjb.config.json.projectType]类型是一个string。');
96
+ process.exit(0);
97
+ }
98
+ if (![
99
+ 'multi',
100
+ 'spa',
101
+ 'uniapp',
102
+ 'micro-spa'
103
+ ].includes(jjb_config_json.projectType)) {
104
+ console.log('【Error】:[jjb.config.json.projectType]配置无效,有效值<multi | spa | micro-spa | uniapp>。');
105
+ process.exit(0);
106
+ }
107
+ if (typeof jjb_config_json.installTarget !== 'string') {
108
+ console.log('【Error】:[jjb.config.json.installTarget]类型是一个string。');
109
+ process.exit(0);
110
+ }
111
+ if (![
112
+ 'node_modules',
113
+ 'src'
114
+ ].includes(jjb_config_json.installTarget)) {
115
+ console.log('【Error】:[jjb.config.json.node_modules]配置无效,有效值<node_modules | src>。');
116
+ process.exit(0);
117
+ }
118
+ if (!Array.isArray(jjb_config_json.installResources)) {
119
+ console.log('【Error】:[jjb.config.json.installResources]类型是一个Array<string>。');
120
+ process.exit(0);
121
+ }
122
+ if (jjb_config_json.installResources.length === 0) {
123
+ console.log('【Error】:[jjb.config.json.installResources]无资源。');
124
+ process.exit(0);
125
+ }
126
+ const resources = exports.f_resolve_install_resources(jjb_config_json.installResources);
127
+ if (resources.map(item => item.name).filter(v => ![
128
+ 'jjb-common',
129
+ 'jjb-dva-runtime',
130
+ 'jjb-common-lib',
131
+ 'jjb-common-decorator',
132
+ 'react-admin-component',
133
+ 'vue-unisass-component'
134
+ ].includes(v)).length !== 0) {
135
+ console.log('【Error】:[jjb.config.json.installResources]配置无效,有效值<common | react-admin-component | vue-unisass-component | jjb-common-decorator | jjb-dva-runtime | jjb-common-lib>。');
136
+ process.exit(0);
137
+ }
138
+ jjb_config_json.installResources = resources;
139
+ return jjb_config_json;
140
+ };
141
+
142
+ /**
143
+ * @description 创建package.json
144
+ * @param path {string} 路径
145
+ * @param name {string} 包名
146
+ * @param version {string} 版本
147
+ */
148
+ exports.f_create_package_json = function (path, name, version) {
149
+ fs.writeFileSync(`${path}\\package.json`, `{"name":"${name}","version":"${version}","main": "index.js"}`);
150
+ };
151
+
152
+ /**
153
+ * @typedef {object} Resource
154
+ * @property {string} name
155
+ * @property {string[]} importList
156
+ */
157
+
158
+ /**
159
+ * @description 分析resources
160
+ * @param installResources
161
+ * @return {Resource[]}
162
+ */
163
+ exports.f_resolve_install_resources = function (installResources = []) {
164
+ const resources = [];
165
+ if (Array.isArray(installResources)) {
166
+ installResources.forEach(resource => {
167
+ if (Array.isArray(resource)) {
168
+ const [ name, importList = [] ] = resource;
169
+ resources.push({
170
+ name,
171
+ importList
172
+ });
173
+ } else {
174
+ resources.push({
175
+ name: resource,
176
+ importList: []
177
+ });
178
+ }
179
+ });
180
+ }
181
+ return resources;
182
+ };
183
+
184
+ /**
185
+ * @description 更新项目package.json文件
186
+ * @param path {string} 路径
187
+ * @param name {string} 包名
188
+ * @param version {string} 版本
189
+ */
190
+ exports.f_update_project_package_json = function (path, name, version) {
191
+ const packageJSONFile = JSON.parse(fs.readFileSync(path).toString());
192
+ packageJSONFile.dependencies[ name ] = version;
193
+ fs.writeFileSync(path, JSON.stringify(packageJSONFile, null, 2));
194
+ };
195
+
196
+ /**
197
+ * @description 复制文件
198
+ * @param originSrc
199
+ * @param targetSrc
200
+ */
201
+ exports.f_file_copy = function (originSrc, targetSrc) {
202
+ fs.readdirSync(originSrc).forEach(dir => {
203
+ const oPath = `${originSrc}\\${dir}`;
204
+ const tPath = `${targetSrc}\\${dir}`;
205
+ if (fs.statSync(oPath).isDirectory()) {
206
+ fs.mkdirSync(tPath);
207
+ exports.f_file_copy(oPath, tPath);
208
+ } else {
209
+ fs.writeFileSync(tPath, fs.readFileSync(oPath).toString());
210
+ }
211
+ });
212
+ };
213
+
214
+ /**
215
+ * @description 替换文件操作
216
+ * @param source {[]} 替换源
217
+ * @param root {string} 路径
218
+ */
219
+ exports.f_content_replace = function (source = [], root) {
220
+ source.forEach(item => {
221
+ const path = root + item.path;
222
+ if (fs.existsSync(path)) {
223
+ let content = fs.readFileSync(path).toString();
224
+ item.replace.forEach(rep => {
225
+ content = content.replace(rep[ 0 ], rep[ 1 ]);
226
+ });
227
+ fs.writeFileSync(path, content);
228
+ }
229
+ });
230
+ };
File without changes
File without changes
@@ -16,14 +16,12 @@ const CLOUD_PROJECT = {
16
16
  'common': {
17
17
  token: 'G4HJRsHr9D7Ssmixegw2',
18
18
  projectId: 279,
19
- localName: 'common',
20
- sha: '20e00c48'
19
+ localName: 'common'
21
20
  },
22
21
  'react-admin-component': {
23
22
  token: 'FT3pKzxpRynFkmddJ9Bs',
24
23
  projectId: 340,
25
- localName: 'components',
26
- sha: 'a79d730b'
24
+ localName: 'components'
27
25
  }
28
26
  };
29
27
  // common 需要替换的文本(常规应用)
@@ -219,7 +217,7 @@ module.exports = input => {
219
217
  utils.DeleteDirAllFile(`${tmpDir}/${GIT_TEMP_DIR}`, () => {
220
218
  fs.mkdirSync(`${tmpDir}/${GIT_TEMP_DIR}`);
221
219
  const stream = fs.createWriteStream(zipPath);
222
- request(`${GIT_HOST}/api/v4/projects/${cloudObj.projectId}/repository/archive.zip?private_token=${cloudObj.token}&sha=${cloudObj.sha}`)
220
+ request(`${GIT_HOST}/api/v4/projects/${cloudObj.projectId}/repository/archive.zip?private_token=${cloudObj.token}&ref=master`)
223
221
  .pipe(stream)
224
222
  .on('close', () => {
225
223
  fs.mkdirSync(zipFolder);
@@ -227,7 +225,7 @@ module.exports = input => {
227
225
  .then(() => {
228
226
  setTimeout(() => {
229
227
  fs.readdirSync(zipFolder).forEach(dirName => {
230
- if (dirName.indexOf(`-${cloudObj.sha}`) !== -1) {
228
+ if (dirName.indexOf('-master-') !== -1) {
231
229
  /* 删除下载的文件 */
232
230
  utils.DeleteDirAllFile(`${srcFolderPath}\\${cloudObj.localName}`, () => {
233
231
  /* 创建临时文件夹 */
@@ -18,8 +18,8 @@ module.exports = function () {
18
18
  if (answer.trim() === 'y') {
19
19
  console.log('正在计算项目数,请稍等...');
20
20
  setTimeout(() => {
21
- scanner(root_path);
22
- console.log(`计算完成共计[${f_total}]项目。`);
21
+ // scanner(root_path);
22
+ // console.log(`计算完成共计[${f_total}]项目。`);
23
23
  setTimeout(() => {
24
24
  console.clear();
25
25
  exec(root_path);
@@ -50,19 +50,19 @@ function exec (path) {
50
50
  if (fs.statSync(vPath).isDirectory()) {
51
51
  exec(vPath);
52
52
  fs.rmdirSync(vPath, { recursive: true });
53
- f_number = f_number + 1;
54
- // console.log('删除文件夹:' + vPath);
53
+ // f_number = f_number + 1;
54
+ console.log('删除文件夹:' + vPath);
55
55
  } else {
56
56
  fs.unlinkSync(vPath);
57
- f_number = f_number + 1;
58
- // console.log('删除文件:' + vPath);
57
+ // f_number = f_number + 1;
58
+ console.log('删除文件:' + vPath);
59
59
  }
60
- progress.render({
61
- completed: f_number,
62
- total: f_total
63
- });
60
+ // progress.render({
61
+ // completed: f_number,
62
+ // total: f_total
63
+ // });
64
64
  } catch (e) {
65
- // console.log('删除异常:' + vPath);
65
+ console.log('删除异常:' + vPath);
66
66
  }
67
67
  }
68
68
  }
File without changes
File without changes
@@ -1,3 +0,0 @@
1
- import { defineNamespace } from 'jjb-common/dva';
2
-
3
- export const NS_DEMO = defineNamespace('demo');