jjb-cmd 2.2.3 → 2.2.5
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.
- package/README.md +8 -0
- package/package.json +1 -1
- package/src/new/cmd.auth/index.js +1 -26
- package/src/new/cmd.init/index.js +1 -116
- package/src/new/cmd.install/config.js +1 -70
- package/src/new/cmd.install/index.js +1 -262
- package/src/new/cmd.install/tools.js +1 -230
- package/src/new/cmd.install.app/index.js +1 -27
- package/src/new/cmd.jenkins/index.js +1 -72
- package/src/new/cmd.publish/index.js +1 -197
- package/src/new/cmd.push/index.js +1 -76
- package/src/new/cmd.push/java.js +1 -148
- package/src/new/cmd.push-set/index.js +1 -205
- package/src/new/cmd.refresh/index.js +1 -65
- package/src/new/cmd.reglist/index.js +1 -23
- package/src/new/cmd.rm-rf/index.js +1 -58
- package/src/new/cmd.version/index.js +1 -35
- package/src/old/cli.init.js +1 -26
- package/src/old/cli.install/config.js +1 -206
- package/src/old/cli.install/index.js +1 -340
- package/src/old/cli.install/tools.js +1 -230
- package/src/old/cli.merge.js +1 -80
- package/src/old/cli.pull.js +1 -94
- package/src/old/cli.pull2.js +1 -377
- package/src/old/cli.rm-rf.js +1 -88
- package/src/old/progress-bar.js +1 -23
- package/src/old/util.js +1 -149
- package/build.js +0 -15
- package/obf.config.json +0 -3
- package/src/old/cli.dva.register.saas.txt +0 -40
- package/src/old/cli.dva.register.spa.txt +0 -22
- package/src/old/cli.dva.router.saas.txt +0 -210
- package/src/old/cli.dva.router.spa.txt +0 -119
@@ -1,206 +1 @@
|
|
1
|
-
const
|
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}`;
|
32
|
-
exports.CLI_DVA_ROUTER_SPA = `${__dirname}\\..\\cli.dva.router.spa.txt`;
|
33
|
-
exports.CLI_DVA_ROUTER_SAAS = `${__dirname}\\..\\cli.dva.router.saas.txt`;
|
34
|
-
exports.CLI_DVA_REGISTER_SPA = `${__dirname}\\..\\cli.dva.register.spa.txt`;
|
35
|
-
exports.CLI_DVA_REGISTER_SAAS = `${__dirname}\\..\\cli.dva.register.saas.txt`;
|
36
|
-
exports.CLI_DVA_ROUTER_PATH = '\\dva\\automatic\\router.js';
|
37
|
-
exports.CLI_DVA_REGISTER_PATH = '\\dva\\automatic\\register.js';
|
38
|
-
|
39
|
-
exports.COMMON_CONTENT_NOR_REPLACE = [
|
40
|
-
{
|
41
|
-
path: `\\tools\\index.js`,
|
42
|
-
replace: [
|
43
|
-
[
|
44
|
-
'components',
|
45
|
-
'jjb-react-admin-component'
|
46
|
-
]
|
47
|
-
]
|
48
|
-
},
|
49
|
-
{
|
50
|
-
path: `\\website\\index.js`,
|
51
|
-
replace: [
|
52
|
-
[
|
53
|
-
/const\srelation\s=\srequire\(`~\/application\/\${module.code}\/enumerate\/menu`\)\.default;/,
|
54
|
-
'const relation = require(\'~/enumerate/menu\').default;'
|
55
|
-
],
|
56
|
-
[
|
57
|
-
'components',
|
58
|
-
'jjb-react-admin-component'
|
59
|
-
]
|
60
|
-
]
|
61
|
-
}
|
62
|
-
];
|
63
|
-
|
64
|
-
/**
|
65
|
-
* @description 需要替换的文本(单应用)
|
66
|
-
* @type {[{path: string, replace: string[][]}]}
|
67
|
-
*/
|
68
|
-
exports.COMMON_CONTENT_SPA_REPLACE = [
|
69
|
-
{
|
70
|
-
path: `\\tools\\index.js`,
|
71
|
-
replace: [
|
72
|
-
[
|
73
|
-
'return __planA();',
|
74
|
-
'return process.env;'
|
75
|
-
]
|
76
|
-
]
|
77
|
-
}
|
78
|
-
];
|
79
|
-
|
80
|
-
/**
|
81
|
-
* @description 需要替换的文本(微应用)
|
82
|
-
* @type {[{path: string, replace: string[][]}]}
|
83
|
-
*/
|
84
|
-
exports.COMMON_CONTENT_MICRO_REPLACE = [
|
85
|
-
{
|
86
|
-
path: `\\tools\\index.js`,
|
87
|
-
replace: [
|
88
|
-
[
|
89
|
-
'return __planA();',
|
90
|
-
'return process.env.app;'
|
91
|
-
]
|
92
|
-
]
|
93
|
-
}
|
94
|
-
];
|
95
|
-
|
96
|
-
/**
|
97
|
-
* @description react-admin-component 需要替换的文本
|
98
|
-
* @type {[{path: string, replace: string[][]},{path: string, replace: string[][]},{path: string, replace: string[][]},{path: string, replace: string[][]},{path: string, replace: string[][]},null,null,null,null]}
|
99
|
-
*/
|
100
|
-
exports.COMPONENTS_CONTENT_REPLACE = [
|
101
|
-
{
|
102
|
-
path: `\\Editor\\index.js`,
|
103
|
-
replace: [
|
104
|
-
[
|
105
|
-
'common/http',
|
106
|
-
'jjb-common/http'
|
107
|
-
],
|
108
|
-
[
|
109
|
-
'common/crypto',
|
110
|
-
'jjb-common/crypto'
|
111
|
-
],
|
112
|
-
[
|
113
|
-
'common/tools',
|
114
|
-
'jjb-common/tools'
|
115
|
-
]
|
116
|
-
]
|
117
|
-
},
|
118
|
-
{
|
119
|
-
path: `\\RejectText\\index.js`,
|
120
|
-
replace: [
|
121
|
-
[
|
122
|
-
'common/color',
|
123
|
-
'jjb-common/color'
|
124
|
-
]
|
125
|
-
]
|
126
|
-
},
|
127
|
-
{
|
128
|
-
path: `\\RouterMenu\\index.js`,
|
129
|
-
replace: [
|
130
|
-
[
|
131
|
-
'common/tools',
|
132
|
-
'jjb-common/tools'
|
133
|
-
]
|
134
|
-
]
|
135
|
-
},
|
136
|
-
{
|
137
|
-
path: `\\FileUploader\\index.js`,
|
138
|
-
replace: [
|
139
|
-
[
|
140
|
-
'common/http',
|
141
|
-
'jjb-common/http'
|
142
|
-
],
|
143
|
-
[
|
144
|
-
'common/tools',
|
145
|
-
'jjb-common/tools'
|
146
|
-
]
|
147
|
-
]
|
148
|
-
},
|
149
|
-
{
|
150
|
-
path: `\\ImageCropper\\index.js`,
|
151
|
-
replace: [
|
152
|
-
[
|
153
|
-
'common/http',
|
154
|
-
'jjb-common/http'
|
155
|
-
],
|
156
|
-
[
|
157
|
-
'common/tools',
|
158
|
-
'jjb-common/tools'
|
159
|
-
]
|
160
|
-
]
|
161
|
-
},
|
162
|
-
{
|
163
|
-
path: `\\ImageUploader\\index.js`,
|
164
|
-
replace: [
|
165
|
-
[
|
166
|
-
'common/http',
|
167
|
-
'jjb-common/http'
|
168
|
-
],
|
169
|
-
[
|
170
|
-
'common/tools',
|
171
|
-
'jjb-common/tools'
|
172
|
-
]
|
173
|
-
]
|
174
|
-
},
|
175
|
-
{
|
176
|
-
path: `\\PageHeaderBar\\index.js`,
|
177
|
-
replace: [
|
178
|
-
[
|
179
|
-
'common/color',
|
180
|
-
'jjb-common/color'
|
181
|
-
]
|
182
|
-
]
|
183
|
-
},
|
184
|
-
{
|
185
|
-
path: `\\RouterContainer\\index.js`,
|
186
|
-
replace: [
|
187
|
-
[
|
188
|
-
'common/tools',
|
189
|
-
'jjb-common/tools'
|
190
|
-
]
|
191
|
-
]
|
192
|
-
},
|
193
|
-
{
|
194
|
-
path: `\\RouterContainer\\components\\NavigationTab\\index.js`,
|
195
|
-
replace: [
|
196
|
-
[
|
197
|
-
'common/website',
|
198
|
-
'jjb-common/website'
|
199
|
-
],
|
200
|
-
[
|
201
|
-
'common/tools',
|
202
|
-
'jjb-common/tools'
|
203
|
-
]
|
204
|
-
]
|
205
|
-
}
|
206
|
-
];
|
1
|
+
const a16_0x33e6b8=a16_0x43d4;function a16_0x43d4(_0x4bae89,_0x4878a0){const _0x1fa3c5=a16_0x1fa3();return a16_0x43d4=function(_0x43d4ca,_0x1bc0ff){_0x43d4ca=_0x43d4ca-0x154;let _0x3902ce=_0x1fa3c5[_0x43d4ca];return _0x3902ce;},a16_0x43d4(_0x4bae89,_0x4878a0);}(function(_0x1df3a1,_0x1268b2){const _0x12a8fe=a16_0x43d4,_0x18d9d8=_0x1df3a1();while(!![]){try{const _0x1d0822=parseInt(_0x12a8fe(0x171))/0x1+parseInt(_0x12a8fe(0x159))/0x2+parseInt(_0x12a8fe(0x168))/0x3*(-parseInt(_0x12a8fe(0x155))/0x4)+-parseInt(_0x12a8fe(0x182))/0x5*(-parseInt(_0x12a8fe(0x160))/0x6)+parseInt(_0x12a8fe(0x17a))/0x7*(-parseInt(_0x12a8fe(0x16f))/0x8)+-parseInt(_0x12a8fe(0x169))/0x9*(-parseInt(_0x12a8fe(0x18a))/0xa)+-parseInt(_0x12a8fe(0x184))/0xb;if(_0x1d0822===_0x1268b2)break;else _0x18d9d8['push'](_0x18d9d8['shift']());}catch(_0x59044f){_0x18d9d8['push'](_0x18d9d8['shift']());}}}(a16_0x1fa3,0x2f9bc));const os=require('os');exports[a16_0x33e6b8(0x180)]=a16_0x33e6b8(0x15a),exports[a16_0x33e6b8(0x178)]='jjbAssembly_'+Date[a16_0x33e6b8(0x15d)](),exports[a16_0x33e6b8(0x188)]={'common':{'token':a16_0x33e6b8(0x16d),'projectId':0x117},'react-admin-component':{'token':a16_0x33e6b8(0x16e),'projectId':0x154},'jjb-dva-runtime':{'token':'hLqARY89CN6fUD3yg4NL','projectId':0x23b},'jjb-common-lib':{'token':'e9njpBd1nS_LREN8GFpR','projectId':0x23c},'jjb-common-decorator':{'token':'gPSit8aJsLVmNzuQ5Cy4','projectId':0x23e},'vue-unisass-component':{'token':a16_0x33e6b8(0x17d),'projectId':0x153}},exports[a16_0x33e6b8(0x186)]=os[a16_0x33e6b8(0x173)]()+'\x5c'+exports[a16_0x33e6b8(0x178)],exports[a16_0x33e6b8(0x157)]=__dirname+'\x5c..\x5ccli.dva.router.spa.txt',exports['CLI_DVA_ROUTER_SAAS']=__dirname+'\x5c..\x5ccli.dva.router.saas.txt',exports[a16_0x33e6b8(0x17b)]=__dirname+a16_0x33e6b8(0x177),exports[a16_0x33e6b8(0x16a)]=__dirname+'\x5c..\x5ccli.dva.register.saas.txt',exports[a16_0x33e6b8(0x183)]=a16_0x33e6b8(0x17e),exports[a16_0x33e6b8(0x179)]='\x5cdva\x5cautomatic\x5cregister.js',exports[a16_0x33e6b8(0x17f)]=[{'path':a16_0x33e6b8(0x16b),'replace':[['components',a16_0x33e6b8(0x176)]]},{'path':a16_0x33e6b8(0x161),'replace':[[/const\srelation\s=\srequire\(`~\/application\/\${module.code}\/enumerate\/menu`\)\.default;/,'const\x20relation\x20=\x20require(\x27~/enumerate/menu\x27).default;'],[a16_0x33e6b8(0x167),a16_0x33e6b8(0x176)]]}],exports[a16_0x33e6b8(0x15b)]=[{'path':'\x5ctools\x5cindex.js','replace':[[a16_0x33e6b8(0x170),a16_0x33e6b8(0x181)]]}],exports[a16_0x33e6b8(0x16c)]=[{'path':a16_0x33e6b8(0x16b),'replace':[['return\x20__planA();',a16_0x33e6b8(0x162)]]}],exports[a16_0x33e6b8(0x15e)]=[{'path':'\x5cEditor\x5cindex.js','replace':[[a16_0x33e6b8(0x18c),'jjb-common/http'],[a16_0x33e6b8(0x154),a16_0x33e6b8(0x172)],[a16_0x33e6b8(0x175),'jjb-common/tools']]},{'path':a16_0x33e6b8(0x156),'replace':[['common/color',a16_0x33e6b8(0x18b)]]},{'path':a16_0x33e6b8(0x187),'replace':[[a16_0x33e6b8(0x175),a16_0x33e6b8(0x158)]]},{'path':a16_0x33e6b8(0x185),'replace':[['common/http',a16_0x33e6b8(0x165)],[a16_0x33e6b8(0x175),'jjb-common/tools']]},{'path':a16_0x33e6b8(0x164),'replace':[['common/http',a16_0x33e6b8(0x165)],[a16_0x33e6b8(0x175),a16_0x33e6b8(0x158)]]},{'path':a16_0x33e6b8(0x17c),'replace':[[a16_0x33e6b8(0x18c),'jjb-common/http'],['common/tools',a16_0x33e6b8(0x158)]]},{'path':a16_0x33e6b8(0x15c),'replace':[[a16_0x33e6b8(0x174),a16_0x33e6b8(0x18b)]]},{'path':a16_0x33e6b8(0x163),'replace':[[a16_0x33e6b8(0x175),a16_0x33e6b8(0x158)]]},{'path':a16_0x33e6b8(0x15f),'replace':[[a16_0x33e6b8(0x189),a16_0x33e6b8(0x166)],[a16_0x33e6b8(0x175),'jjb-common/tools']]}];function a16_0x1fa3(){const _0x52e1de=['jjb-common/http','jjb-common/website','components','347661LJkVvy','9zPYhOg','CLI_DVA_REGISTER_SAAS','\x5ctools\x5cindex.js','COMMON_CONTENT_MICRO_REPLACE','G4HJRsHr9D7Ssmixegw2','FT3pKzxpRynFkmddJ9Bs','72EJVvab','return\x20__planA();','262503iowPAf','jjb-common/crypto','tmpdir','common/color','common/tools','jjb-react-admin-component','\x5c..\x5ccli.dva.register.spa.txt','GIT_TEMP_DIR','CLI_DVA_REGISTER_PATH','175259IsrOLm','CLI_DVA_REGISTER_SPA','\x5cImageUploader\x5cindex.js','d4wQ7dzEjYPsgVbKnYei','\x5cdva\x5cautomatic\x5crouter.js','COMMON_CONTENT_NOR_REPLACE','GIT_HOST','return\x20process.env;','10820btYXZL','CLI_DVA_ROUTER_PATH','2080397bvjBcf','\x5cFileUploader\x5cindex.js','TEMPLATE_FOLDER','\x5cRouterMenu\x5cindex.js','CLOUD_PROJECT','common/website','991730yCRyqj','jjb-common/color','common/http','common/crypto','8zAMGKn','\x5cRejectText\x5cindex.js','CLI_DVA_ROUTER_SPA','jjb-common/tools','539308uYSVkm','http://192.168.1.242:10985','COMMON_CONTENT_SPA_REPLACE','\x5cPageHeaderBar\x5cindex.js','now','COMPONENTS_CONTENT_REPLACE','\x5cRouterContainer\x5ccomponents\x5cNavigationTab\x5cindex.js','582WpKQQv','\x5cwebsite\x5cindex.js','return\x20process.env.app;','\x5cRouterContainer\x5cindex.js','\x5cImageCropper\x5cindex.js'];a16_0x1fa3=function(){return _0x52e1de;};return a16_0x1fa3();}
|
@@ -1,340 +1 @@
|
|
1
|
-
const
|
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_content_replace,
|
9
|
-
f_create_package_json,
|
10
|
-
f_pull_git_repository,
|
11
|
-
f_scan_jjb_config_json,
|
12
|
-
f_scan_jjb_config_json_rules,
|
13
|
-
f_update_project_package_json
|
14
|
-
} = require('./tools');
|
15
|
-
const {
|
16
|
-
TEMPLATE_FOLDER,
|
17
|
-
COMMON_CONTENT_SPA_REPLACE,
|
18
|
-
CLI_DVA_ROUTER_PATH,
|
19
|
-
CLI_DVA_REGISTER_PATH,
|
20
|
-
CLI_DVA_ROUTER_SPA,
|
21
|
-
CLI_DVA_REGISTER_SPA,
|
22
|
-
CLI_DVA_ROUTER_SAAS,
|
23
|
-
CLI_DVA_REGISTER_SAAS,
|
24
|
-
COMMON_CONTENT_MICRO_REPLACE,
|
25
|
-
COMMON_CONTENT_NOR_REPLACE,
|
26
|
-
COMPONENTS_CONTENT_REPLACE
|
27
|
-
} = require('./config');
|
28
|
-
const start_time = Date.now();
|
29
|
-
|
30
|
-
module.exports = () => {
|
31
|
-
/**
|
32
|
-
* 下发数据根路径
|
33
|
-
* @type {string}
|
34
|
-
*/
|
35
|
-
const root_path = path.resolve('./');
|
36
|
-
/**
|
37
|
-
* 下发数据src路径
|
38
|
-
* @type {string}
|
39
|
-
*/
|
40
|
-
const target_src = [
|
41
|
-
root_path,
|
42
|
-
'src\\'
|
43
|
-
].join('\\');
|
44
|
-
/**
|
45
|
-
* 下发数据node_modules路径
|
46
|
-
* @type {string}
|
47
|
-
*/
|
48
|
-
const target_node_modules = [
|
49
|
-
root_path,
|
50
|
-
'node_modules'
|
51
|
-
].join('\\');
|
52
|
-
/**
|
53
|
-
* 下发数据package.json路径
|
54
|
-
* @type {string}
|
55
|
-
*/
|
56
|
-
const target_package_json = [
|
57
|
-
root_path,
|
58
|
-
'package.json'
|
59
|
-
].join('\\');
|
60
|
-
if (f_scan_jjb_config_json(root_path)) {
|
61
|
-
/**
|
62
|
-
* 检查配置规则
|
63
|
-
*/
|
64
|
-
const jjb_config = f_scan_jjb_config_json_rules(root_path);
|
65
|
-
/**
|
66
|
-
* 检查项目是否存在node_modules
|
67
|
-
*/
|
68
|
-
if (jjb_config.installTarget === 'node_modules') {
|
69
|
-
if (!fs.existsSync(target_node_modules)) {
|
70
|
-
console.log('【Error】:安装失败,node_modules目录不存在。');
|
71
|
-
process.exit(0);
|
72
|
-
} else {
|
73
|
-
console.log('【Warning】:若安装在node_modules中,请确保projectType = micro-spa,并关闭webpack.config.js rules限制。');
|
74
|
-
}
|
75
|
-
} else {
|
76
|
-
if (!fs.existsSync(target_src)) {
|
77
|
-
console.log('【Error】:安装失败,src目录不存在。');
|
78
|
-
process.exit(0);
|
79
|
-
}
|
80
|
-
}
|
81
|
-
/**
|
82
|
-
* 文件操作:定义一个临时文件夹
|
83
|
-
*/
|
84
|
-
fs.mkdirSync(TEMPLATE_FOLDER);
|
85
|
-
/**
|
86
|
-
* 拉取数据
|
87
|
-
*/
|
88
|
-
f_pull_git_repository(jjb_config.installResources).map(item => {
|
89
|
-
const stream = fs.createWriteStream(item.path);
|
90
|
-
/**
|
91
|
-
* 流操作:下载git仓库
|
92
|
-
*/
|
93
|
-
request(item.repository).pipe(stream).on('close', () => {
|
94
|
-
fs.mkdirSync(item.compress);
|
95
|
-
/**
|
96
|
-
* 流操作:解压
|
97
|
-
*/
|
98
|
-
compressing.zip.uncompress(item.path, item.compress);
|
99
|
-
});
|
100
|
-
});
|
101
|
-
const timer = setInterval(() => {
|
102
|
-
/**
|
103
|
-
* 文件操作:扫描临时文件夹
|
104
|
-
*/
|
105
|
-
const folder_list = fs.readdirSync(TEMPLATE_FOLDER);
|
106
|
-
/**
|
107
|
-
* 文件操作:抓取临时文件夹中的内容
|
108
|
-
*/
|
109
|
-
const match_folder = folder_list.filter(item => jjb_config.installResources.map(item => `${item.name}_zip`).includes(item));
|
110
|
-
/**
|
111
|
-
* 文件操作:判断是否已解压完成
|
112
|
-
*/
|
113
|
-
if (match_folder.length === jjb_config.installResources.length) {
|
114
|
-
/**
|
115
|
-
* 解压完成关闭定时器
|
116
|
-
*/
|
117
|
-
clearInterval(timer);
|
118
|
-
const resource_folder = [];
|
119
|
-
match_folder.forEach(name => {
|
120
|
-
/**
|
121
|
-
* 文件操作:定义解压包路径
|
122
|
-
*/
|
123
|
-
const unzip = [
|
124
|
-
TEMPLATE_FOLDER,
|
125
|
-
name
|
126
|
-
].join('\\');
|
127
|
-
/**
|
128
|
-
* 文件操作:抓取解压包中的文件
|
129
|
-
*/
|
130
|
-
fs.readdirSync(unzip).forEach(dir => resource_folder.push({
|
131
|
-
name: name,
|
132
|
-
path: [
|
133
|
-
unzip,
|
134
|
-
dir
|
135
|
-
].join('\\'),
|
136
|
-
pure_name: name.replace(/_zip$/, ''),
|
137
|
-
import_list: jjb_config.installResources.find(item => `${item.name}_zip` === name).importList
|
138
|
-
}));
|
139
|
-
});
|
140
|
-
resource_folder.forEach(item => {
|
141
|
-
/**
|
142
|
-
* 文件操作:依赖名称
|
143
|
-
*/
|
144
|
-
const folder_name = item.pure_name;
|
145
|
-
/**
|
146
|
-
* 文件操作:按需加载
|
147
|
-
*/
|
148
|
-
const folder_import_list = item.import_list;
|
149
|
-
/**
|
150
|
-
* 文件操作:组装路径
|
151
|
-
*/
|
152
|
-
const folder_idea_path = [
|
153
|
-
item.path,
|
154
|
-
'.idea'
|
155
|
-
].join('//');
|
156
|
-
/**
|
157
|
-
* 文件操作:组装路径
|
158
|
-
*/
|
159
|
-
const folder_git_ignore_path = [
|
160
|
-
item.path,
|
161
|
-
'.gitignore'
|
162
|
-
].join('//');
|
163
|
-
/**
|
164
|
-
* 特殊处理:删除.idea文件夹
|
165
|
-
*/
|
166
|
-
if (fs.existsSync(folder_idea_path)) {
|
167
|
-
f_rm_rf(folder_idea_path);
|
168
|
-
fs.rmdirSync(folder_idea_path);
|
169
|
-
}
|
170
|
-
/**
|
171
|
-
* 特殊处理:删除.gitignore文件
|
172
|
-
*/
|
173
|
-
if (fs.existsSync(folder_git_ignore_path)) {
|
174
|
-
fs.unlinkSync(folder_git_ignore_path);
|
175
|
-
}
|
176
|
-
/**
|
177
|
-
* 文件操作:按需加载
|
178
|
-
*/
|
179
|
-
if (folder_import_list.length) {
|
180
|
-
/**
|
181
|
-
* 文件操作:根据jjb.config.json中的importList获取需要的文件
|
182
|
-
*/
|
183
|
-
fs.readdirSync(item.path).filter(item => !folder_import_list.includes(item) && item !== 'index.js' && item !== 'setting.json').forEach(dir => {
|
184
|
-
/**
|
185
|
-
* 文件操作:组装路径
|
186
|
-
*/
|
187
|
-
const dirPath = `${item.path}\\${dir}`;
|
188
|
-
/**
|
189
|
-
* 文件操作:删除不需要的文件夹内容
|
190
|
-
*/
|
191
|
-
f_rm_rf(dirPath);
|
192
|
-
/**
|
193
|
-
* 文件操作:删除不需要的文件夹
|
194
|
-
*/
|
195
|
-
fs.rmdirSync(dirPath);
|
196
|
-
});
|
197
|
-
if (folder_name === 'react-admin-component') {
|
198
|
-
const codeList = [];
|
199
|
-
fs.readdirSync(item.path).filter(dir => dir !== 'index.js').forEach(dir => {
|
200
|
-
if (dir === 'RouterContainer') {
|
201
|
-
codeList.push(`export { default as RouterContainer, PATH as RouterContainerPATH } from './RouterContainer';`);
|
202
|
-
} else {
|
203
|
-
codeList.push(`export { default as ${dir} } from './${dir}';`);
|
204
|
-
}
|
205
|
-
});
|
206
|
-
fs.writeFileSync(`${item.path}\\index.js`, codeList.join('\n'));
|
207
|
-
}
|
208
|
-
}
|
209
|
-
if (folder_name === 'jjb-common') {
|
210
|
-
/**
|
211
|
-
* 组装dva/automatic路径
|
212
|
-
*/
|
213
|
-
const automaticPath = [
|
214
|
-
item.path,
|
215
|
-
'\\dva\\automatic'
|
216
|
-
].join('\\');
|
217
|
-
if ([
|
218
|
-
'spa',
|
219
|
-
'micro-spa'
|
220
|
-
].includes(jjb_config.projectType)) {
|
221
|
-
/**
|
222
|
-
* 特殊处理:由于micro-spa模式下需要使用react-router-dom自动化技术,spa模式下使用基于dva/router的自动化技术,两者有差异,需要做替换操作
|
223
|
-
*/
|
224
|
-
if (fs.existsSync(automaticPath)) {
|
225
|
-
/**
|
226
|
-
* 文件操作:常规替换
|
227
|
-
*/
|
228
|
-
f_content_replace(jjb_config.projectType === 'spa'
|
229
|
-
? COMMON_CONTENT_SPA_REPLACE
|
230
|
-
: [
|
231
|
-
...COMMON_CONTENT_MICRO_REPLACE,
|
232
|
-
...COMMON_CONTENT_NOR_REPLACE
|
233
|
-
], item.path);
|
234
|
-
/**
|
235
|
-
* 文件操作:替换dva/automatic/router.js
|
236
|
-
*/
|
237
|
-
fs.writeFileSync(item.path + CLI_DVA_ROUTER_PATH, fs.readFileSync(jjb_config.projectType === 'spa'
|
238
|
-
? CLI_DVA_ROUTER_SPA
|
239
|
-
: CLI_DVA_ROUTER_SAAS).toString());
|
240
|
-
/**
|
241
|
-
* 文件操作:替换dva/automatic/register.js
|
242
|
-
*/
|
243
|
-
fs.writeFileSync(item.path + CLI_DVA_REGISTER_PATH, fs.readFileSync(jjb_config.projectType === 'spa'
|
244
|
-
? CLI_DVA_REGISTER_SPA
|
245
|
-
: CLI_DVA_REGISTER_SAAS).toString());
|
246
|
-
}
|
247
|
-
} else if (jjb_config.projectType === 'multi') {
|
248
|
-
/**
|
249
|
-
* 特殊处理:由于multi模式下不需要使用自动化技术,需要删除dva/automatic文件夹
|
250
|
-
*/
|
251
|
-
if (fs.existsSync(automaticPath)) {
|
252
|
-
f_rm_rf(automaticPath);
|
253
|
-
fs.rmdirSync(automaticPath);
|
254
|
-
}
|
255
|
-
}
|
256
|
-
} else if (folder_name === 'react-admin-component') {
|
257
|
-
/**
|
258
|
-
* 特殊处理:仅限micro-spa模式下允许react-admin-component使用node_modules/jjb-common,其他模式使用src/components,目的是兼容老项目
|
259
|
-
*/
|
260
|
-
if (jjb_config.projectType === 'micro-spa') {
|
261
|
-
f_content_replace(COMPONENTS_CONTENT_REPLACE, item.path);
|
262
|
-
}
|
263
|
-
} else if (folder_name === 'vue-unisass-component') {
|
264
|
-
|
265
|
-
}
|
266
|
-
if (jjb_config.installTarget === 'node_modules') {
|
267
|
-
/**
|
268
|
-
* 特殊处理:为了避免与node_modules其他依赖重名,添加一个标识符"jjb-"
|
269
|
-
*/
|
270
|
-
const package_name = folder_name;
|
271
|
-
/**
|
272
|
-
* 文件操作:判断node_modules目录下是否已存在
|
273
|
-
*/
|
274
|
-
if (fs.existsSync(`${target_node_modules}\\${package_name}`)) {
|
275
|
-
/**
|
276
|
-
* 文件操作:删除node_modules目录下文件内容(保留文件夹)
|
277
|
-
*/
|
278
|
-
f_rm_rf(`${target_node_modules}\\${package_name}`);
|
279
|
-
} else {
|
280
|
-
/**
|
281
|
-
* 文件操作:如果不存在,定义一个新的文件夹
|
282
|
-
*/
|
283
|
-
fs.mkdirSync(`${target_node_modules}\\${package_name}`);
|
284
|
-
}
|
285
|
-
/**
|
286
|
-
* 文件操作:复制文件到node_modules中
|
287
|
-
*/
|
288
|
-
f_file_copy(item.path, `${target_node_modules}\\${package_name}`);
|
289
|
-
/**
|
290
|
-
* 文件操作:创建package.json
|
291
|
-
*/
|
292
|
-
f_create_package_json(`${target_node_modules}\\${package_name}`, package_name, '1.0.0');
|
293
|
-
/**
|
294
|
-
* 文件操作:在src/package.json中定义一个组件依赖
|
295
|
-
*/
|
296
|
-
f_update_project_package_json(target_package_json, package_name, '1.0.0');
|
297
|
-
} else if (jjb_config.installTarget === 'src') {
|
298
|
-
/**
|
299
|
-
* 特殊处理:由于老项目问题,此处要将react-admin-component转换为components(仅限src模式)
|
300
|
-
*/
|
301
|
-
const t_name = 'react-admin-component';
|
302
|
-
/**
|
303
|
-
* 文件操作:判断src目录下是否已存在
|
304
|
-
*/
|
305
|
-
if (fs.existsSync(target_src + t_name)) {
|
306
|
-
/**
|
307
|
-
* 文件操作:删除src目录下文件内容(保留文件夹)
|
308
|
-
*/
|
309
|
-
f_rm_rf(target_src + t_name);
|
310
|
-
} else {
|
311
|
-
/**
|
312
|
-
* 文件操作:如果不存在,定义一个新的文件夹
|
313
|
-
*/
|
314
|
-
fs.mkdirSync(target_src + t_name);
|
315
|
-
}
|
316
|
-
/**
|
317
|
-
* 文件操作:复制文件到src中
|
318
|
-
*/
|
319
|
-
f_file_copy(item.path, target_src + t_name);
|
320
|
-
}
|
321
|
-
});
|
322
|
-
setTimeout(() => {
|
323
|
-
/**
|
324
|
-
* 文件操作:删除临时文件夹内容
|
325
|
-
*/
|
326
|
-
f_rm_rf(TEMPLATE_FOLDER);
|
327
|
-
/**
|
328
|
-
* 文件操作:删除临时文件夹
|
329
|
-
*/
|
330
|
-
fs.rmdirSync(TEMPLATE_FOLDER);
|
331
|
-
const end_time = Date.now();
|
332
|
-
console.log(`【jjb-cmd】:install命令执行完成,用时${(end_time - start_time) / 1000}s`);
|
333
|
-
}, 1500);
|
334
|
-
}
|
335
|
-
}, 1000);
|
336
|
-
} else {
|
337
|
-
console.log('【Error】:执行失败,在您的项目根目录,需要一个jjb.config.json文件。');
|
338
|
-
}
|
339
|
-
};
|
340
|
-
|
1
|
+
const a17_0x4162c9=a17_0x26ce;(function(_0x96eef7,_0xce5f8c){const _0x220198=a17_0x26ce,_0x57a9b8=_0x96eef7();while(!![]){try{const _0x1ce153=parseInt(_0x220198(0x198))/0x1+-parseInt(_0x220198(0x1c8))/0x2*(parseInt(_0x220198(0x1b2))/0x3)+-parseInt(_0x220198(0x1af))/0x4*(-parseInt(_0x220198(0x1c0))/0x5)+parseInt(_0x220198(0x1d1))/0x6+parseInt(_0x220198(0x1bb))/0x7+-parseInt(_0x220198(0x1b6))/0x8*(parseInt(_0x220198(0x1ab))/0x9)+parseInt(_0x220198(0x1a1))/0xa*(-parseInt(_0x220198(0x19b))/0xb);if(_0x1ce153===_0xce5f8c)break;else _0x57a9b8['push'](_0x57a9b8['shift']());}catch(_0x5c8451){_0x57a9b8['push'](_0x57a9b8['shift']());}}}(a17_0x1710,0x44a0d));function a17_0x26ce(_0x301f5c,_0x3e71b9){const _0x171005=a17_0x1710();return a17_0x26ce=function(_0x26cef7,_0x255cce){_0x26cef7=_0x26cef7-0x194;let _0x15eab5=_0x171005[_0x26cef7];return _0x15eab5;},a17_0x26ce(_0x301f5c,_0x3e71b9);}const fs=require('fs'),path=require(a17_0x4162c9(0x1a8)),request=require(a17_0x4162c9(0x1cb)),compressing=require(a17_0x4162c9(0x194)),{f_rm_rf,f_file_copy,f_content_replace,f_create_package_json,f_pull_git_repository,f_scan_jjb_config_json,f_scan_jjb_config_json_rules,f_update_project_package_json}=require(a17_0x4162c9(0x1aa)),{TEMPLATE_FOLDER,COMMON_CONTENT_SPA_REPLACE,CLI_DVA_ROUTER_PATH,CLI_DVA_REGISTER_PATH,CLI_DVA_ROUTER_SPA,CLI_DVA_REGISTER_SPA,CLI_DVA_ROUTER_SAAS,CLI_DVA_REGISTER_SAAS,COMMON_CONTENT_MICRO_REPLACE,COMMON_CONTENT_NOR_REPLACE,COMPONENTS_CONTENT_REPLACE}=require(a17_0x4162c9(0x1c4)),start_time=Date[a17_0x4162c9(0x1c5)]();module[a17_0x4162c9(0x1d0)]=()=>{const _0x326066=a17_0x4162c9,_0x42c9ae=path[_0x326066(0x1a4)]('./'),_0x1b8cec=[_0x42c9ae,_0x326066(0x1c3)][_0x326066(0x1a5)]('\x5c'),_0x3e429e=[_0x42c9ae,'node_modules'][_0x326066(0x1a5)]('\x5c'),_0xd0f6a1=[_0x42c9ae,'package.json'][_0x326066(0x1a5)]('\x5c');if(f_scan_jjb_config_json(_0x42c9ae)){const _0x13da0e=f_scan_jjb_config_json_rules(_0x42c9ae);_0x13da0e[_0x326066(0x1d4)]==='node_modules'?!fs[_0x326066(0x1b3)](_0x3e429e)?(console[_0x326066(0x1ac)](_0x326066(0x1a3)),process[_0x326066(0x19d)](0x0)):console[_0x326066(0x1ac)]('【Warning】:若安装在node_modules中,请确保projectType\x20=\x20micro-spa,并关闭webpack.config.js\x20rules限制。'):!fs[_0x326066(0x1b3)](_0x1b8cec)&&(console[_0x326066(0x1ac)](_0x326066(0x1b9)),process[_0x326066(0x19d)](0x0));fs[_0x326066(0x1cd)](TEMPLATE_FOLDER),f_pull_git_repository(_0x13da0e[_0x326066(0x1ce)])['map'](_0x4bf89a=>{const _0x1457fc=_0x326066,_0x44b8c5=fs[_0x1457fc(0x197)](_0x4bf89a[_0x1457fc(0x1a8)]);request(_0x4bf89a['repository'])[_0x1457fc(0x1cf)](_0x44b8c5)['on'](_0x1457fc(0x19c),()=>{const _0x411f84=_0x1457fc;fs['mkdirSync'](_0x4bf89a['compress']),compressing[_0x411f84(0x1a9)][_0x411f84(0x19e)](_0x4bf89a[_0x411f84(0x1a8)],_0x4bf89a[_0x411f84(0x1ad)]);});});const _0x3d05cc=setInterval(()=>{const _0x3cfd2c=_0x326066,_0xbe5b48=fs[_0x3cfd2c(0x196)](TEMPLATE_FOLDER),_0x432b63=_0xbe5b48['filter'](_0x20f503=>_0x13da0e[_0x3cfd2c(0x1ce)][_0x3cfd2c(0x1cc)](_0x3bbf37=>_0x3bbf37[_0x3cfd2c(0x195)]+_0x3cfd2c(0x1bf))['includes'](_0x20f503));if(_0x432b63[_0x3cfd2c(0x1ba)]===_0x13da0e[_0x3cfd2c(0x1ce)][_0x3cfd2c(0x1ba)]){clearInterval(_0x3d05cc);const _0x195c9a=[];_0x432b63[_0x3cfd2c(0x1c2)](_0xf8e728=>{const _0x371fe2=_0x3cfd2c,_0x1e9ce1=[TEMPLATE_FOLDER,_0xf8e728][_0x371fe2(0x1a5)]('\x5c');fs[_0x371fe2(0x196)](_0x1e9ce1)['forEach'](_0x19ffa6=>_0x195c9a['push']({'name':_0xf8e728,'path':[_0x1e9ce1,_0x19ffa6][_0x371fe2(0x1a5)]('\x5c'),'pure_name':_0xf8e728[_0x371fe2(0x1a2)](/_zip$/,''),'import_list':_0x13da0e[_0x371fe2(0x1ce)]['find'](_0x408be2=>_0x408be2['name']+_0x371fe2(0x1bf)===_0xf8e728)['importList']}));}),_0x195c9a['forEach'](_0x43a591=>{const _0x4d2db0=_0x3cfd2c,_0x5194f7=_0x43a591[_0x4d2db0(0x19f)],_0x4d35ef=_0x43a591['import_list'],_0x4bb263=[_0x43a591['path'],'.idea'][_0x4d2db0(0x1a5)]('//'),_0x8779f8=[_0x43a591[_0x4d2db0(0x1a8)],'.gitignore'][_0x4d2db0(0x1a5)]('//');fs[_0x4d2db0(0x1b3)](_0x4bb263)&&(f_rm_rf(_0x4bb263),fs[_0x4d2db0(0x1bc)](_0x4bb263));fs[_0x4d2db0(0x1b3)](_0x8779f8)&&fs[_0x4d2db0(0x1bd)](_0x8779f8);if(_0x4d35ef[_0x4d2db0(0x1ba)]){fs[_0x4d2db0(0x196)](_0x43a591[_0x4d2db0(0x1a8)])['filter'](_0x32cc8f=>!_0x4d35ef[_0x4d2db0(0x1a6)](_0x32cc8f)&&_0x32cc8f!==_0x4d2db0(0x1a7)&&_0x32cc8f!==_0x4d2db0(0x1b1))['forEach'](_0x4381ea=>{const _0x417aa1=_0x4d2db0,_0x21580f=_0x43a591['path']+'\x5c'+_0x4381ea;f_rm_rf(_0x21580f),fs[_0x417aa1(0x1bc)](_0x21580f);});if(_0x5194f7===_0x4d2db0(0x1d3)){const _0x5cb6f7=[];fs[_0x4d2db0(0x196)](_0x43a591[_0x4d2db0(0x1a8)])['filter'](_0x115efe=>_0x115efe!==_0x4d2db0(0x1a7))['forEach'](_0x225fc4=>{const _0x5ad521=_0x4d2db0;_0x225fc4===_0x5ad521(0x1c1)?_0x5cb6f7[_0x5ad521(0x1be)](_0x5ad521(0x1c6)):_0x5cb6f7['push']('export\x20{\x20default\x20as\x20'+_0x225fc4+_0x5ad521(0x1d2)+_0x225fc4+'\x27;');}),fs[_0x4d2db0(0x1b7)](_0x43a591[_0x4d2db0(0x1a8)]+_0x4d2db0(0x1a0),_0x5cb6f7[_0x4d2db0(0x1a5)]('\x0a'));}}if(_0x5194f7===_0x4d2db0(0x1c9)){const _0x26fda4=[_0x43a591[_0x4d2db0(0x1a8)],_0x4d2db0(0x1b8)][_0x4d2db0(0x1a5)]('\x5c');if([_0x4d2db0(0x1d6),_0x4d2db0(0x1c7)][_0x4d2db0(0x1a6)](_0x13da0e[_0x4d2db0(0x1b0)]))fs[_0x4d2db0(0x1b3)](_0x26fda4)&&(f_content_replace(_0x13da0e[_0x4d2db0(0x1b0)]===_0x4d2db0(0x1d6)?COMMON_CONTENT_SPA_REPLACE:[...COMMON_CONTENT_MICRO_REPLACE,...COMMON_CONTENT_NOR_REPLACE],_0x43a591[_0x4d2db0(0x1a8)]),fs[_0x4d2db0(0x1b7)](_0x43a591[_0x4d2db0(0x1a8)]+CLI_DVA_ROUTER_PATH,fs[_0x4d2db0(0x1ae)](_0x13da0e[_0x4d2db0(0x1b0)]==='spa'?CLI_DVA_ROUTER_SPA:CLI_DVA_ROUTER_SAAS)[_0x4d2db0(0x1d5)]()),fs[_0x4d2db0(0x1b7)](_0x43a591[_0x4d2db0(0x1a8)]+CLI_DVA_REGISTER_PATH,fs['readFileSync'](_0x13da0e[_0x4d2db0(0x1b0)]==='spa'?CLI_DVA_REGISTER_SPA:CLI_DVA_REGISTER_SAAS)[_0x4d2db0(0x1d5)]()));else _0x13da0e[_0x4d2db0(0x1b0)]===_0x4d2db0(0x19a)&&(fs[_0x4d2db0(0x1b3)](_0x26fda4)&&(f_rm_rf(_0x26fda4),fs['rmdirSync'](_0x26fda4)));}else{if(_0x5194f7===_0x4d2db0(0x1d3))_0x13da0e['projectType']===_0x4d2db0(0x1c7)&&f_content_replace(COMPONENTS_CONTENT_REPLACE,_0x43a591[_0x4d2db0(0x1a8)]);else{if(_0x5194f7==='vue-unisass-component'){}}}if(_0x13da0e[_0x4d2db0(0x1d4)]===_0x4d2db0(0x1ca)){const _0x382594=_0x5194f7;fs[_0x4d2db0(0x1b3)](_0x3e429e+'\x5c'+_0x382594)?f_rm_rf(_0x3e429e+'\x5c'+_0x382594):fs['mkdirSync'](_0x3e429e+'\x5c'+_0x382594),f_file_copy(_0x43a591[_0x4d2db0(0x1a8)],_0x3e429e+'\x5c'+_0x382594),f_create_package_json(_0x3e429e+'\x5c'+_0x382594,_0x382594,'1.0.0'),f_update_project_package_json(_0xd0f6a1,_0x382594,_0x4d2db0(0x199));}else{if(_0x13da0e['installTarget']===_0x4d2db0(0x1b4)){const _0x5d3b2e=_0x4d2db0(0x1d3);fs[_0x4d2db0(0x1b3)](_0x1b8cec+_0x5d3b2e)?f_rm_rf(_0x1b8cec+_0x5d3b2e):fs[_0x4d2db0(0x1cd)](_0x1b8cec+_0x5d3b2e),f_file_copy(_0x43a591['path'],_0x1b8cec+_0x5d3b2e);}}}),setTimeout(()=>{const _0x120bab=_0x3cfd2c;f_rm_rf(TEMPLATE_FOLDER),fs[_0x120bab(0x1bc)](TEMPLATE_FOLDER);const _0x43e11c=Date[_0x120bab(0x1c5)]();console[_0x120bab(0x1ac)](_0x120bab(0x1b5)+(_0x43e11c-start_time)/0x3e8+'s');},0x5dc);}},0x3e8);}else console[_0x326066(0x1ac)]('【Error】:执行失败,在您的项目根目录,需要一个jjb.config.json文件。');};function a17_0x1710(){const _0x2b5c0a=['map','mkdirSync','installResources','pipe','exports','908814sFetqb','\x20}\x20from\x20\x27./','react-admin-component','installTarget','toString','spa','compressing','name','readdirSync','createWriteStream','290567sqHGBk','1.0.0','multi','198eeeFZv','close','exit','uncompress','pure_name','\x5cindex.js','188900szjjIr','replace','【Error】:安装失败,node_modules目录不存在。','resolve','join','includes','index.js','path','zip','./tools','377847QsiugE','log','compress','readFileSync','11972tNMLOU','projectType','setting.json','4962JmHDjk','existsSync','src','【jjb-cmd】:install命令执行完成,用时','8bUCOIP','writeFileSync','\x5cdva\x5cautomatic','【Error】:安装失败,src目录不存在。','length','573790LOFOSv','rmdirSync','unlinkSync','push','_zip','470sQXMeY','RouterContainer','forEach','src\x5c','./config','now','export\x20{\x20default\x20as\x20RouterContainer,\x20PATH\x20as\x20RouterContainerPATH\x20}\x20from\x20\x27./RouterContainer\x27;','micro-spa','172ogiEKa','jjb-common','node_modules','request'];a17_0x1710=function(){return _0x2b5c0a;};return a17_0x1710();}
|