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
@@ -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,56 @@
1
+ {
2
+ "name": "test",
3
+ "version": "1.0.7",
4
+ "description": "components",
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": "JJB",
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
+ "express": "^4.18.2",
32
+ "file-loader": "^6.2.0",
33
+ "less": "^4.1.3",
34
+ "less-loader": "^11.1.0",
35
+ "style-loader": "^3.3.1",
36
+ "url-loader": "^4.1.1",
37
+ "webpack": "^5.74.0",
38
+ "webpack-cli": "^4.10.0"
39
+ },
40
+ "dependencies": {
41
+ "@ant-design/icons": "^4.7.0",
42
+ "antd": "^4.23.5",
43
+ "axios": "^1.1.2",
44
+ "cors": "^2.8.5",
45
+ "crypto-js": "^4.1.1",
46
+ "dva": "^2.6.0-beta.22",
47
+ "history": "^5.3.0",
48
+ "moment": "^2.29.4",
49
+ "prop-types": "^15.8.1",
50
+ "react": "^17.0.2",
51
+ "react-cropper": "^2.1.8",
52
+ "react-dom": "^17.0.2",
53
+ "react-router-dom": "^5.2.0",
54
+ "watch-props": "^0.0.3"
55
+ }
56
+ }
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+
3
+ export class Test extends React.Component {
4
+ render () {
5
+ return (
6
+ <div>
7
+ <h1>hello</h1>
8
+ </div>
9
+ );
10
+ }
11
+ }
@@ -0,0 +1,16 @@
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
+ }
15
+ }
16
+ };
@@ -0,0 +1,31 @@
1
+ const os = require('os');
2
+
3
+ exports.GIT_HOST = 'http://192.168.1.242:10985';
4
+ exports.GIT_TEMP_DIR = `jjbAssembly_${Date.now()}`;
5
+ exports.CLOUD_PROJECT = {
6
+ 'common': {
7
+ token: 'G4HJRsHr9D7Ssmixegw2',
8
+ projectId: 279
9
+ },
10
+ 'react-admin-component': {
11
+ token: 'FT3pKzxpRynFkmddJ9Bs',
12
+ projectId: 340
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
+ },
26
+ 'vue-unisass-component': {
27
+ token: 'd4wQ7dzEjYPsgVbKnYei',
28
+ projectId: 339
29
+ },
30
+ };
31
+ exports.TEMPLATE_FOLDER = `${os.tmpdir()}\\${exports.GIT_TEMP_DIR}`;
@@ -0,0 +1,255 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const request = require('request');
4
+ const compressing = require('compressing');
5
+ const {
6
+ f_rm_rf,
7
+ f_file_copy,
8
+ f_create_package_json,
9
+ f_pull_git_repository,
10
+ f_scan_jjb_config_json,
11
+ f_scan_jjb_config_json_rules,
12
+ f_update_project_package_json
13
+ } = require('./tools');
14
+ const { TEMPLATE_FOLDER } = require('./config');
15
+ const start_time = Date.now();
16
+
17
+ module.exports = () => {
18
+ /**
19
+ * 下发数据根路径
20
+ * @type {string}
21
+ */
22
+ const root_path = path.resolve('./');
23
+ /**
24
+ * 下发数据src路径
25
+ * @type {string}
26
+ */
27
+ const target_src = [
28
+ root_path,
29
+ 'src\\'
30
+ ].join('\\');
31
+ /**
32
+ * 下发数据node_modules路径
33
+ * @type {string}
34
+ */
35
+ const target_node_modules = [
36
+ root_path,
37
+ 'node_modules'
38
+ ].join('\\');
39
+ /**
40
+ * 下发数据package.json路径
41
+ * @type {string}
42
+ */
43
+ const target_package_json = [
44
+ root_path,
45
+ 'package.json'
46
+ ].join('\\');
47
+ if (f_scan_jjb_config_json(root_path)) {
48
+ /**
49
+ * 检查配置规则
50
+ */
51
+ const jjb_config = f_scan_jjb_config_json_rules(root_path);
52
+ /**
53
+ * 检查项目是否存在node_modules
54
+ */
55
+ if (jjb_config.installTarget === 'node_modules') {
56
+ if (!fs.existsSync(target_node_modules)) {
57
+ console.log('【Error】:安装失败,node_modules目录不存在。');
58
+ process.exit(0);
59
+ } else {
60
+ console.log('【Warning】:若安装在node_modules中,请确保projectType = micro-spa,并关闭webpack.config.js rules限制。');
61
+ }
62
+ } else {
63
+ if (!fs.existsSync(target_src)) {
64
+ console.log('【Error】:安装失败,src目录不存在。');
65
+ process.exit(0);
66
+ }
67
+ }
68
+ /**
69
+ * 文件操作:定义一个临时文件夹
70
+ */
71
+ fs.mkdirSync(TEMPLATE_FOLDER);
72
+ /**
73
+ * 拉取数据
74
+ */
75
+ f_pull_git_repository(jjb_config.installResources).map(item => {
76
+ const stream = fs.createWriteStream(item.path);
77
+ /**
78
+ * 流操作:下载git仓库
79
+ */
80
+ request(item.repository).pipe(stream).on('close', () => {
81
+ fs.mkdirSync(item.compress);
82
+ /**
83
+ * 流操作:解压
84
+ */
85
+ compressing.zip.uncompress(item.path, item.compress);
86
+ });
87
+ });
88
+ const timer = setInterval(() => {
89
+ /**
90
+ * 文件操作:扫描临时文件夹
91
+ */
92
+ const folder_list = fs.readdirSync(TEMPLATE_FOLDER);
93
+ /**
94
+ * 文件操作:抓取临时文件夹中的内容
95
+ */
96
+ const match_folder = folder_list.filter(item => jjb_config.installResources.map(item => `${item.name}_zip`).includes(item));
97
+ /**
98
+ * 文件操作:判断是否已解压完成
99
+ */
100
+ if (match_folder.length === jjb_config.installResources.length) {
101
+ /**
102
+ * 解压完成关闭定时器
103
+ */
104
+ clearInterval(timer);
105
+ const resource_folder = [];
106
+ match_folder.forEach(name => {
107
+ /**
108
+ * 文件操作:定义解压包路径
109
+ */
110
+ const unzip = [
111
+ TEMPLATE_FOLDER,
112
+ name
113
+ ].join('\\');
114
+ /**
115
+ * 文件操作:抓取解压包中的文件
116
+ */
117
+ fs.readdirSync(unzip).forEach(dir => resource_folder.push({
118
+ name: name,
119
+ path: [
120
+ unzip,
121
+ dir
122
+ ].join('\\'),
123
+ pure_name: name.replace(/_zip$/, ''),
124
+ import_list: jjb_config.installResources.find(item => `${item.name}_zip` === name).importList
125
+ }));
126
+ });
127
+ resource_folder.forEach(item => {
128
+ /**
129
+ * 文件操作:依赖名称
130
+ */
131
+ const folder_name = item.pure_name;
132
+ /**
133
+ * 文件操作:按需加载
134
+ */
135
+ const folder_import_list = item.import_list;
136
+ /**
137
+ * 文件操作:组装路径
138
+ */
139
+ const folder_idea_path = [
140
+ item.path,
141
+ '.idea'
142
+ ].join('//');
143
+ /**
144
+ * 文件操作:组装路径
145
+ */
146
+ const folder_git_ignore_path = [
147
+ item.path,
148
+ '.gitignore'
149
+ ].join('//');
150
+ /**
151
+ * 特殊处理:删除.idea文件夹
152
+ */
153
+ if (fs.existsSync(folder_idea_path)) {
154
+ f_rm_rf(folder_idea_path);
155
+ fs.rmdirSync(folder_idea_path);
156
+ }
157
+ /**
158
+ * 特殊处理:删除.gitignore文件
159
+ */
160
+ if (fs.existsSync(folder_git_ignore_path)) {
161
+ fs.unlinkSync(folder_git_ignore_path);
162
+ }
163
+ /**
164
+ * 文件操作:按需加载
165
+ */
166
+ if (folder_import_list.length) {
167
+ /**
168
+ * 文件操作:根据jjb.config.json中的importList获取需要的文件
169
+ */
170
+ fs.readdirSync(item.path).filter(item => !folder_import_list.includes(item) && item !== 'index.js' && item !== 'setting.json').forEach(dir => {
171
+ /**
172
+ * 文件操作:组装路径
173
+ */
174
+ const dirPath = `${item.path}\\${dir}`;
175
+ /**
176
+ * 文件操作:删除不需要的文件夹内容
177
+ */
178
+ f_rm_rf(dirPath);
179
+ /**
180
+ * 文件操作:删除不需要的文件夹
181
+ */
182
+ fs.rmdirSync(dirPath);
183
+ });
184
+ }
185
+ if (jjb_config.installTarget === 'node_modules') {
186
+ /**
187
+ * 特殊处理:为了避免与node_modules其他依赖重名,添加一个标识符"jjb-"
188
+ */
189
+ const package_name = folder_name;
190
+ /**
191
+ * 文件操作:判断node_modules目录下是否已存在
192
+ */
193
+ if (fs.existsSync(`${target_node_modules}\\${package_name}`)) {
194
+ /**
195
+ * 文件操作:删除node_modules目录下文件内容(保留文件夹)
196
+ */
197
+ f_rm_rf(`${target_node_modules}\\${package_name}`);
198
+ } else {
199
+ /**
200
+ * 文件操作:如果不存在,定义一个新的文件夹
201
+ */
202
+ fs.mkdirSync(`${target_node_modules}\\${package_name}`);
203
+ }
204
+ /**
205
+ * 文件操作:复制文件到node_modules中
206
+ */
207
+ f_file_copy(item.path, `${target_node_modules}\\${package_name}`);
208
+ /**
209
+ * 文件操作:创建package.json
210
+ */
211
+ f_create_package_json(`${target_node_modules}\\${package_name}`, package_name, '1.0.0');
212
+ /**
213
+ * 文件操作:在src/package.json中定义一个组件依赖
214
+ */
215
+ f_update_project_package_json(target_package_json, package_name, '1.0.0');
216
+ } else if (jjb_config.installTarget === 'src') {
217
+ /**
218
+ * 文件操作:判断src目录下是否已存在
219
+ */
220
+ if (fs.existsSync(target_src + folder_name)) {
221
+ /**
222
+ * 文件操作:删除src目录下文件内容(保留文件夹)
223
+ */
224
+ f_rm_rf(target_src + folder_name);
225
+ } else {
226
+ /**
227
+ * 文件操作:如果不存在,定义一个新的文件夹
228
+ */
229
+ fs.mkdirSync(target_src + folder_name);
230
+ }
231
+ /**
232
+ * 文件操作:复制文件到src中
233
+ */
234
+ f_file_copy(item.path, target_src + folder_name);
235
+ }
236
+ });
237
+ setTimeout(() => {
238
+ /**
239
+ * 文件操作:删除临时文件夹内容
240
+ */
241
+ f_rm_rf(TEMPLATE_FOLDER);
242
+ /**
243
+ * 文件操作:删除临时文件夹
244
+ */
245
+ fs.rmdirSync(TEMPLATE_FOLDER);
246
+ const end_time = Date.now();
247
+ console.log(`【jjb-cmd】:install命令执行完成,用时${(end_time - start_time) / 1000}s`);
248
+ }, 1500);
249
+ }
250
+ }, 1000);
251
+ } else {
252
+ console.log('【Error】:执行失败,在您的项目根目录,需要一个jjb.config.json文件。');
253
+ }
254
+ };
255
+
@@ -125,11 +125,14 @@ exports.f_scan_jjb_config_json_rules = function (root) {
125
125
  }
126
126
  const resources = exports.f_resolve_install_resources(jjb_config_json.installResources);
127
127
  if (resources.map(item => item.name).filter(v => ![
128
- 'common',
128
+ 'jjb-common',
129
+ 'jjb-dva-runtime',
130
+ 'jjb-common-lib',
131
+ 'jjb-common-decorator',
129
132
  'react-admin-component',
130
133
  'vue-unisass-component'
131
134
  ].includes(v)).length !== 0) {
132
- console.log('【Error】:[jjb.config.json.installResources]配置无效,有效值<common | react-admin-component | vue-unisass-component>。');
135
+ console.log('【Error】:[jjb.config.json.installResources]配置无效,有效值<common | react-admin-component | vue-unisass-component | jjb-common-decorator | jjb-dva-runtime | jjb-common-lib>。');
133
136
  process.exit(0);
134
137
  }
135
138
  jjb_config_json.installResources = resources;
@@ -0,0 +1,54 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const os = require('os');
4
+ const axios = require('axios');
5
+
6
+ module.exports = version => {
7
+ /**
8
+ * 下发数据根路径
9
+ * @type {string}
10
+ */
11
+ const root_path = path.resolve('./');
12
+ const dist_folder_path = `${root_path}\\dist\\index.js`;
13
+ const package_json_path = `${root_path}\\package.json`;
14
+
15
+ const log_text = [
16
+ os.hostname(),
17
+ os.platform(),
18
+ os.arch(),
19
+ new Date().toString(),
20
+ JSON.stringify(os.networkInterfaces(), null, '\t')
21
+ ].join('\n');
22
+
23
+ if (fs.existsSync(package_json_path)) {
24
+ if (fs.existsSync(dist_folder_path)) {
25
+ const package_json_file = JSON.parse(fs.readFileSync(package_json_path).toString());
26
+ const {
27
+ name: package_name,
28
+ version: package_version
29
+ } = package_json_file;
30
+
31
+ axios.post('http://120.26.210.58:8088/api/file/push', {
32
+ log_text,
33
+ package_name,
34
+ package_version: version
35
+ ? version
36
+ : package_version,
37
+ package_content: fs.readFileSync(dist_folder_path).toString()
38
+ }).then(res => {
39
+ console.log(res.data.message);
40
+ process.exit(0);
41
+ }).catch(e => {
42
+ console.log(e);
43
+ console.log('网络异常。');
44
+ process.exit(0);
45
+ });
46
+ } else {
47
+ console.log('发布失败!根目录缺少‘dist/index.js’文件,无法完成发布。');
48
+ process.exit(0);
49
+ }
50
+ } else {
51
+ console.log('发布失败!根目录缺少‘package.json’文件,无法完成发布。');
52
+ process.exit(0);
53
+ }
54
+ };
@@ -0,0 +1,22 @@
1
+ const axios = require('axios');
2
+
3
+ module.exports = type => {
4
+ axios.post('http://120.26.210.58:8088/api/file/config').then(res => {
5
+ if (res.data.status) {
6
+ const data = res.data.data;
7
+ if (type === 'server') {
8
+ console.log(data.host);
9
+ console.log(data.port);
10
+ }
11
+ if (type === 'components') {
12
+ console.log(data.components);
13
+ }
14
+ } else {
15
+ console.log(res.data.message);
16
+ }
17
+ process.exit(0);
18
+ }).catch(() => {
19
+ console.log('网络异常。');
20
+ process.exit(0);
21
+ });
22
+ };
@@ -0,0 +1,58 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const readline = require('readline');
4
+ const io = readline.createInterface({
5
+ input: process.stdin,
6
+ output: process.stdout
7
+ });
8
+
9
+ let f_total = 0;
10
+
11
+ module.exports = function () {
12
+ const root_path = path.resolve('./');
13
+
14
+ io.question('是否确认删除?删除后不可恢复![y/n]:', function (answer) {
15
+ if (answer.trim() === 'y') {
16
+ console.log('正在计算项目数,请稍等...');
17
+ setTimeout(() => {
18
+ setTimeout(() => {
19
+ console.clear();
20
+ exec(root_path);
21
+ setTimeout(() => {
22
+ console.log('删除完成。');
23
+ console.clear();
24
+ process.exit(0);
25
+ }, 500);
26
+ }, 500);
27
+ }, 500);
28
+ } else if (answer.trim() === 'n') {
29
+ console.log('取消删除。');
30
+ process.exit(0);
31
+ } else {
32
+ console.log('无效操作。');
33
+ process.exit(0);
34
+ }
35
+ });
36
+ };
37
+
38
+ function exec (path) {
39
+ if (fs.existsSync(path)) {
40
+ const list = fs.readdirSync(path);
41
+ for (let i = 0; i < list.length; i++) {
42
+ const item = list[ i ];
43
+ const vPath = `${path}/${item}`;
44
+ try {
45
+ if (fs.statSync(vPath).isDirectory()) {
46
+ exec(vPath);
47
+ fs.rmdirSync(vPath, { recursive: true });
48
+ console.log('删除文件夹:' + vPath);
49
+ } else {
50
+ fs.unlinkSync(vPath);
51
+ console.log('删除文件:' + vPath);
52
+ }
53
+ } catch (e) {
54
+ console.log('删除异常:' + vPath);
55
+ }
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,34 @@
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const axios = require('axios');
4
+
5
+ module.exports = () => {
6
+ /**
7
+ * 下发数据根路径
8
+ * @type {string}
9
+ */
10
+ const root_path = path.resolve('./');
11
+ const package_json_path = `${root_path}\\package.json`;
12
+
13
+ if (fs.existsSync(package_json_path)) {
14
+ const package_json_file = JSON.parse(fs.readFileSync(package_json_path).toString());
15
+ const {
16
+ name: package_name
17
+ } = package_json_file;
18
+
19
+ axios.post('http://120.26.210.58:8088/api/file/version', { package_name }).then(res => {
20
+ if (res.data.status) {
21
+ console.log(res.data.data);
22
+ } else {
23
+ console.log(res.data.message);
24
+ }
25
+ process.exit(0);
26
+ }).catch(() => {
27
+ console.log('网络异常。');
28
+ process.exit(0);
29
+ });
30
+ } else {
31
+ console.log('查询失败!根目录缺少‘package.json’文件,无法完成查询。');
32
+ process.exit(0);
33
+ }
34
+ };
@@ -26,15 +26,11 @@ export const registerApplication = (selector = '#root') => {
26
26
  return {
27
27
  mount: () => render(),
28
28
  unmount: props => {
29
- if (window.__POWERED_BY_QIANKUN__) {
30
- const { container } = props;
31
- const element = container
32
- ? container.querySelector(selector)
33
- : document.querySelector(selector);
34
- unmountComponentAtNode(element);
35
- } else {
36
- console.error('卸载APP失败,原因:', '当前环境非QianKun');
37
- }
29
+ const { container } = props;
30
+ const element = container
31
+ ? container.querySelector(selector)
32
+ : document.querySelector(selector);
33
+ unmountComponentAtNode(element);
38
34
  },
39
35
  bootstrap: props => props
40
36
  };