jjb-cmd 1.0.16 → 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} +5 -9
  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} +37 -25
  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 +11 -8
  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
@@ -6,7 +6,7 @@
6
6
 
7
7
  import React from 'react';
8
8
  import { ConfigProvider } from 'antd';
9
- import { Route, Router, Switch } from 'dva/router';
9
+ import { BrowserRouter, Route, Switch } from 'dva/router';
10
10
 
11
11
  /**
12
12
  * @description 是否匹配页面
@@ -153,27 +153,26 @@ function treeRoutes (routes = []) {
153
153
  return optimizationTree(result);
154
154
  }
155
155
 
156
- function RenderRouter (routes = [], inProps = {}) {
156
+ function RenderRoute (routes = [], inProps = {}) {
157
157
  return (
158
- <Router history={inProps.history}>
159
- <Switch>
160
- {routes.map(({
161
- path,
162
- children,
163
- Component
164
- }, index) => (
165
- <Route
166
- key={index}
167
- path={`${(process.env.app || {}).basename || ''}${path}`}
168
- render={props => (
169
- <Component {...props}>
170
- {RenderRouter(children, inProps)}
171
- </Component>
172
- )}
173
- />
174
- ))}
175
- </Switch>
176
- </Router>
158
+ <Switch>
159
+ {routes.map(({
160
+ path,
161
+ children,
162
+ Component
163
+ }, index) => (
164
+ <Route
165
+ exact={path === '/'}
166
+ key={index}
167
+ path={path}
168
+ render={props => (
169
+ <Component {...props}>
170
+ {RenderRoute(children, inProps)}
171
+ </Component>
172
+ )}
173
+ />
174
+ ))}
175
+ </Switch>
177
176
  );
178
177
  }
179
178
 
@@ -189,10 +188,23 @@ export const AutomaticRouter = ({
189
188
  }) => {
190
189
  return (
191
190
  <ConfigProvider locale={require('antd/lib/locale/zh_CN').default}>
192
- {RenderRouter(treeRoutes(getRoutes()), {
193
- app,
194
- history
195
- })}
191
+ <BrowserRouter basename={(process.env.app || {}).basename || ''}>
192
+ <Switch>
193
+ {(process.env.app || {}).notRouter
194
+ ? (
195
+ <Route
196
+ path="*"
197
+ component={require('~/pages').default}
198
+ />
199
+ )
200
+ : (
201
+ RenderRoute(treeRoutes(getRoutes()), {
202
+ app,
203
+ history
204
+ })
205
+ )}
206
+ </Switch>
207
+ </BrowserRouter>
196
208
  </ConfigProvider>
197
209
  );
198
210
  };
@@ -0,0 +1,40 @@
1
+ {
2
+ "projectType": "micro-spa",
3
+ "installTarget": "node_modules",
4
+ "installResources": [
5
+ "jjb-dva-runtime",
6
+ "jjb-common-decorator"
7
+ ],
8
+ "environment": {
9
+ "development": {
10
+ "API_HOSE": ""
11
+ },
12
+ "test": {
13
+ "API_HOSE": ""
14
+ },
15
+ "release": {
16
+ "API_HOSE": ""
17
+ },
18
+ "production": {
19
+ "API_HOSE": ""
20
+ }
21
+ },
22
+ "contextInject": {
23
+ "notRouter": true
24
+ },
25
+ "windowInject": {
26
+ "title": "JJB Micro App",
27
+ "jjbCommonLibUrl": ""
28
+ },
29
+ "server": {
30
+ "port": "8080",
31
+ "host": "127.0.0.1"
32
+ },
33
+ "framework": {
34
+ "antd": {
35
+ "link-color": "#021e43",
36
+ "primary-color": "#021e43",
37
+ "border-radius-base": "2px"
38
+ }
39
+ }
40
+ }
@@ -0,0 +1,11 @@
1
+ const { hasEnvironment } = require('./utils');
2
+
3
+ if (!hasEnvironment()) {
4
+ throw Error('jjb.script[build]: 启动build需要提供NODE_ENV变量,请确认你所运行的脚本是否正确?');
5
+ }
6
+
7
+ require('webpack')(require('./config')('production').webpack).run(err => {
8
+ if (!err) {
9
+ console.log('项目打包完成!');
10
+ }
11
+ });
@@ -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’对象中
@@ -85,10 +86,10 @@ module.exports = mode => {
85
86
  include: [
86
87
  // 整个‘src’目录
87
88
  path.resolve(__dirname, '../src'),
88
- // ‘jjb-common’库
89
- path.resolve(__dirname, '../node_modules/jjb-common'),
90
- // ‘jjb-react-admin-component’库
91
- 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')
92
93
  ],
93
94
  // 配置‘babel-loader’
94
95
  options: {
@@ -152,9 +153,7 @@ module.exports = mode => {
152
153
  resolve: {
153
154
  // 为‘import’或‘require’定义别名路径
154
155
  alias: {
155
- '~': requireResolve('src'),
156
- 'common': requireResolve('src/common'),
157
- 'components': requireResolve('src/components')
156
+ '~': requireResolve('src')
158
157
  }
159
158
  },
160
159
  // 插件
@@ -180,6 +179,10 @@ module.exports = mode => {
180
179
  // 每次打包前删除‘dist’目录
181
180
  new CleanWebpackPlugin()
182
181
  ],
182
+ // 外部扩展
183
+ externals: {
184
+ 'window:jjb-common-lib': 'jjbCommonLib'
185
+ },
183
186
  // 打包优化
184
187
  optimization: isProduction
185
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
  */