jjb-cmd 2.2.3 → 2.2.4
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 +4 -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_0x73930d=a16_0x2fd8;function a16_0x5e06(){const _0x35635=['\x5cRejectText\x5cindex.js','common/website','\x5cFileUploader\x5cindex.js','COMMON_CONTENT_SPA_REPLACE','jjbAssembly_','jjb-common/color','\x5cImageCropper\x5cindex.js','CLI_DVA_ROUTER_PATH','common/color','CLI_DVA_ROUTER_SAAS','\x5cPageHeaderBar\x5cindex.js','138367JxYxXM','\x5cImageUploader\x5cindex.js','TEMPLATE_FOLDER','4kaaPZh','COMPONENTS_CONTENT_REPLACE','jjb-common/crypto','1025700uwZNQP','CLOUD_PROJECT','\x5cEditor\x5cindex.js','\x5ctools\x5cindex.js','common/http','CLI_DVA_REGISTER_SPA','221921rzJokU','jjb-common/http','CLI_DVA_REGISTER_PATH','return\x20process.env;','\x5c..\x5ccli.dva.register.saas.txt','jjb-react-admin-component','\x5c..\x5ccli.dva.router.spa.txt','e9njpBd1nS_LREN8GFpR','hLqARY89CN6fUD3yg4NL','24RCFBbf','G4HJRsHr9D7Ssmixegw2','GIT_TEMP_DIR','gPSit8aJsLVmNzuQ5Cy4','now','d4wQ7dzEjYPsgVbKnYei','COMMON_CONTENT_NOR_REPLACE','const\x20relation\x20=\x20require(\x27~/enumerate/menu\x27).default;','common/crypto','4hlBbzD','tmpdir','GIT_HOST','5871415IJLVrE','http://192.168.1.242:10985','\x5c..\x5ccli.dva.register.spa.txt','\x5cdva\x5cautomatic\x5crouter.js','52506kooEpc','jjb-common/website','common/tools','FT3pKzxpRynFkmddJ9Bs','\x5cRouterContainer\x5cindex.js','components','691791jjqwjj','jjb-common/tools','1854340BYFvgy','12IDNJhs'];a16_0x5e06=function(){return _0x35635;};return a16_0x5e06();}(function(_0x432606,_0x393423){const _0x3f2807=a16_0x2fd8,_0x3a8326=_0x432606();while(!![]){try{const _0x5661be=parseInt(_0x3f2807(0x101))/0x1*(parseInt(_0x3f2807(0xe5))/0x2)+parseInt(_0x3f2807(0xf2))/0x3*(-parseInt(_0x3f2807(0x104))/0x4)+-parseInt(_0x3f2807(0x107))/0x5+-parseInt(_0x3f2807(0xf5))/0x6*(parseInt(_0x3f2807(0x10d))/0x7)+parseInt(_0x3f2807(0xdc))/0x8*(parseInt(_0x3f2807(0xec))/0x9)+-parseInt(_0x3f2807(0xf4))/0xa+parseInt(_0x3f2807(0xe8))/0xb;if(_0x5661be===_0x393423)break;else _0x3a8326['push'](_0x3a8326['shift']());}catch(_0x276f76){_0x3a8326['push'](_0x3a8326['shift']());}}}(a16_0x5e06,0x23040));function a16_0x2fd8(_0x421bd9,_0x48f7bc){const _0x5e069b=a16_0x5e06();return a16_0x2fd8=function(_0x2fd8db,_0x3356a2){_0x2fd8db=_0x2fd8db-0xdc;let _0x486cc6=_0x5e069b[_0x2fd8db];return _0x486cc6;},a16_0x2fd8(_0x421bd9,_0x48f7bc);}const os=require('os');exports[a16_0x73930d(0xe7)]=a16_0x73930d(0xe9),exports[a16_0x73930d(0xde)]=a16_0x73930d(0xfa)+Date[a16_0x73930d(0xe0)](),exports[a16_0x73930d(0x108)]={'common':{'token':a16_0x73930d(0xdd),'projectId':0x117},'react-admin-component':{'token':a16_0x73930d(0xef),'projectId':0x154},'jjb-dva-runtime':{'token':a16_0x73930d(0x115),'projectId':0x23b},'jjb-common-lib':{'token':a16_0x73930d(0x114),'projectId':0x23c},'jjb-common-decorator':{'token':a16_0x73930d(0xdf),'projectId':0x23e},'vue-unisass-component':{'token':a16_0x73930d(0xe1),'projectId':0x153}},exports[a16_0x73930d(0x103)]=os[a16_0x73930d(0xe6)]()+'\x5c'+exports[a16_0x73930d(0xde)],exports['CLI_DVA_ROUTER_SPA']=__dirname+a16_0x73930d(0x113),exports[a16_0x73930d(0xff)]=__dirname+'\x5c..\x5ccli.dva.router.saas.txt',exports[a16_0x73930d(0x10c)]=__dirname+a16_0x73930d(0xea),exports['CLI_DVA_REGISTER_SAAS']=__dirname+a16_0x73930d(0x111),exports[a16_0x73930d(0xfd)]=a16_0x73930d(0xeb),exports[a16_0x73930d(0x10f)]='\x5cdva\x5cautomatic\x5cregister.js',exports[a16_0x73930d(0xe2)]=[{'path':'\x5ctools\x5cindex.js','replace':[[a16_0x73930d(0xf1),a16_0x73930d(0x112)]]},{'path':'\x5cwebsite\x5cindex.js','replace':[[/const\srelation\s=\srequire\(`~\/application\/\${module.code}\/enumerate\/menu`\)\.default;/,a16_0x73930d(0xe3)],['components',a16_0x73930d(0x112)]]}],exports[a16_0x73930d(0xf9)]=[{'path':'\x5ctools\x5cindex.js','replace':[['return\x20__planA();',a16_0x73930d(0x110)]]}],exports['COMMON_CONTENT_MICRO_REPLACE']=[{'path':a16_0x73930d(0x10a),'replace':[['return\x20__planA();','return\x20process.env.app;']]}],exports[a16_0x73930d(0x105)]=[{'path':a16_0x73930d(0x109),'replace':[[a16_0x73930d(0x10b),a16_0x73930d(0x10e)],[a16_0x73930d(0xe4),a16_0x73930d(0x106)],[a16_0x73930d(0xee),a16_0x73930d(0xf3)]]},{'path':a16_0x73930d(0xf6),'replace':[['common/color',a16_0x73930d(0xfb)]]},{'path':'\x5cRouterMenu\x5cindex.js','replace':[[a16_0x73930d(0xee),a16_0x73930d(0xf3)]]},{'path':a16_0x73930d(0xf8),'replace':[[a16_0x73930d(0x10b),a16_0x73930d(0x10e)],[a16_0x73930d(0xee),a16_0x73930d(0xf3)]]},{'path':a16_0x73930d(0xfc),'replace':[[a16_0x73930d(0x10b),a16_0x73930d(0x10e)],['common/tools',a16_0x73930d(0xf3)]]},{'path':a16_0x73930d(0x102),'replace':[[a16_0x73930d(0x10b),'jjb-common/http'],['common/tools',a16_0x73930d(0xf3)]]},{'path':a16_0x73930d(0x100),'replace':[[a16_0x73930d(0xfe),a16_0x73930d(0xfb)]]},{'path':a16_0x73930d(0xf0),'replace':[[a16_0x73930d(0xee),a16_0x73930d(0xf3)]]},{'path':'\x5cRouterContainer\x5ccomponents\x5cNavigationTab\x5cindex.js','replace':[[a16_0x73930d(0xf7),a16_0x73930d(0xed)],[a16_0x73930d(0xee),a16_0x73930d(0xf3)]]}];
|
@@ -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_0x309371=a17_0x49a6;function a17_0x49a6(_0x6f339b,_0x15898d){const _0x23b51d=a17_0x23b5();return a17_0x49a6=function(_0x49a67f,_0x850f9a){_0x49a67f=_0x49a67f-0x1b4;let _0x21a5ad=_0x23b51d[_0x49a67f];return _0x21a5ad;},a17_0x49a6(_0x6f339b,_0x15898d);}(function(_0x30ab25,_0x235235){const _0x3999af=a17_0x49a6,_0x9f9838=_0x30ab25();while(!![]){try{const _0x211c29=-parseInt(_0x3999af(0x1c2))/0x1*(-parseInt(_0x3999af(0x1bc))/0x2)+-parseInt(_0x3999af(0x1e6))/0x3+-parseInt(_0x3999af(0x1ce))/0x4+parseInt(_0x3999af(0x1cf))/0x5+-parseInt(_0x3999af(0x1c1))/0x6*(-parseInt(_0x3999af(0x1c8))/0x7)+-parseInt(_0x3999af(0x1ef))/0x8*(parseInt(_0x3999af(0x1f4))/0x9)+parseInt(_0x3999af(0x1dc))/0xa*(parseInt(_0x3999af(0x1e4))/0xb);if(_0x211c29===_0x235235)break;else _0x9f9838['push'](_0x9f9838['shift']());}catch(_0x467872){_0x9f9838['push'](_0x9f9838['shift']());}}}(a17_0x23b5,0x3b95e));function a17_0x23b5(){const _0x333b38=['1.0.0','exports','import_list','1609348bBaBOB','656395OzGXXA','rmdirSync','spa','projectType','now','\x20}\x20from\x20\x27./','forEach','_zip','pure_name','name','map','\x5cdva\x5cautomatic','.idea','661510lPXQbg','index.js','zip','mkdirSync','exit','path','【Warning】:若安装在node_modules中,请确保projectType\x20=\x20micro-spa,并关闭webpack.config.js\x20rules限制。','writeFileSync','99LhYPjr','installTarget','862422NSQJsT','includes','.gitignore','react-admin-component','【Error】:安装失败,src目录不存在。','replace','readdirSync','uncompress','src','296WXyDwx','length','log','node_modules','pipe','112023pEwgbe','filter','micro-spa','【jjb-cmd】:install命令执行完成,用时','setting.json','multi','\x5cindex.js','unlinkSync','join','export\x20{\x20default\x20as\x20','src\x5c','6jUewqi','vue-unisass-component','importList','【Error】:安装失败,node_modules目录不存在。','compress','2802HctFJL','94789oGgAQY','push','installResources','toString','RouterContainer','existsSync','5747DNrjmM','compressing','export\x20{\x20default\x20as\x20RouterContainer,\x20PATH\x20as\x20RouterContainerPATH\x20}\x20from\x20\x27./RouterContainer\x27;'];a17_0x23b5=function(){return _0x333b38;};return a17_0x23b5();}const fs=require('fs'),path=require(a17_0x309371(0x1e1)),request=require('request'),compressing=require(a17_0x309371(0x1c9)),{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('./tools'),{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('./config'),start_time=Date[a17_0x309371(0x1d3)]();module[a17_0x309371(0x1cc)]=()=>{const _0xbd21d0=a17_0x309371,_0x3ba2f6=path['resolve']('./'),_0x920d71=[_0x3ba2f6,_0xbd21d0(0x1bb)][_0xbd21d0(0x1b9)]('\x5c'),_0x5179e3=[_0x3ba2f6,_0xbd21d0(0x1f2)]['join']('\x5c'),_0x2d63b0=[_0x3ba2f6,'package.json'][_0xbd21d0(0x1b9)]('\x5c');if(f_scan_jjb_config_json(_0x3ba2f6)){const _0xe3852a=f_scan_jjb_config_json_rules(_0x3ba2f6);_0xe3852a[_0xbd21d0(0x1e5)]===_0xbd21d0(0x1f2)?!fs[_0xbd21d0(0x1c7)](_0x5179e3)?(console[_0xbd21d0(0x1f1)](_0xbd21d0(0x1bf)),process[_0xbd21d0(0x1e0)](0x0)):console[_0xbd21d0(0x1f1)](_0xbd21d0(0x1e2)):!fs['existsSync'](_0x920d71)&&(console[_0xbd21d0(0x1f1)](_0xbd21d0(0x1ea)),process['exit'](0x0));fs[_0xbd21d0(0x1df)](TEMPLATE_FOLDER),f_pull_git_repository(_0xe3852a[_0xbd21d0(0x1c4)])['map'](_0x4f2b4f=>{const _0x5e3c61=_0xbd21d0,_0x31c192=fs['createWriteStream'](_0x4f2b4f[_0x5e3c61(0x1e1)]);request(_0x4f2b4f['repository'])[_0x5e3c61(0x1f3)](_0x31c192)['on']('close',()=>{const _0x1076be=_0x5e3c61;fs['mkdirSync'](_0x4f2b4f[_0x1076be(0x1c0)]),compressing[_0x1076be(0x1de)][_0x1076be(0x1ed)](_0x4f2b4f[_0x1076be(0x1e1)],_0x4f2b4f[_0x1076be(0x1c0)]);});});const _0x27e606=setInterval(()=>{const _0x3187a8=_0xbd21d0,_0xc270e7=fs[_0x3187a8(0x1ec)](TEMPLATE_FOLDER),_0x177e0b=_0xc270e7[_0x3187a8(0x1f5)](_0x365d9c=>_0xe3852a[_0x3187a8(0x1c4)][_0x3187a8(0x1d9)](_0x2798f9=>_0x2798f9[_0x3187a8(0x1d8)]+'_zip')[_0x3187a8(0x1e7)](_0x365d9c));if(_0x177e0b[_0x3187a8(0x1f0)]===_0xe3852a[_0x3187a8(0x1c4)][_0x3187a8(0x1f0)]){clearInterval(_0x27e606);const _0x3964c3=[];_0x177e0b[_0x3187a8(0x1d5)](_0x258141=>{const _0x22197c=_0x3187a8,_0x5969b7=[TEMPLATE_FOLDER,_0x258141][_0x22197c(0x1b9)]('\x5c');fs[_0x22197c(0x1ec)](_0x5969b7)[_0x22197c(0x1d5)](_0xe5a80f=>_0x3964c3[_0x22197c(0x1c3)]({'name':_0x258141,'path':[_0x5969b7,_0xe5a80f][_0x22197c(0x1b9)]('\x5c'),'pure_name':_0x258141[_0x22197c(0x1eb)](/_zip$/,''),'import_list':_0xe3852a[_0x22197c(0x1c4)]['find'](_0x5a6bab=>_0x5a6bab[_0x22197c(0x1d8)]+_0x22197c(0x1d6)===_0x258141)[_0x22197c(0x1be)]}));}),_0x3964c3['forEach'](_0x4a5488=>{const _0x4ec08d=_0x3187a8,_0x2557dd=_0x4a5488[_0x4ec08d(0x1d7)],_0x18c5d9=_0x4a5488[_0x4ec08d(0x1cd)],_0x263aff=[_0x4a5488[_0x4ec08d(0x1e1)],_0x4ec08d(0x1db)][_0x4ec08d(0x1b9)]('//'),_0x5b32cc=[_0x4a5488[_0x4ec08d(0x1e1)],_0x4ec08d(0x1e8)]['join']('//');fs['existsSync'](_0x263aff)&&(f_rm_rf(_0x263aff),fs[_0x4ec08d(0x1d0)](_0x263aff));fs[_0x4ec08d(0x1c7)](_0x5b32cc)&&fs[_0x4ec08d(0x1b8)](_0x5b32cc);if(_0x18c5d9['length']){fs[_0x4ec08d(0x1ec)](_0x4a5488['path'])['filter'](_0x1a91e2=>!_0x18c5d9['includes'](_0x1a91e2)&&_0x1a91e2!==_0x4ec08d(0x1dd)&&_0x1a91e2!==_0x4ec08d(0x1b5))[_0x4ec08d(0x1d5)](_0x416ffc=>{const _0x136f3d=_0x4ec08d,_0x2fb67e=_0x4a5488[_0x136f3d(0x1e1)]+'\x5c'+_0x416ffc;f_rm_rf(_0x2fb67e),fs[_0x136f3d(0x1d0)](_0x2fb67e);});if(_0x2557dd===_0x4ec08d(0x1e9)){const _0x4ca839=[];fs[_0x4ec08d(0x1ec)](_0x4a5488[_0x4ec08d(0x1e1)])['filter'](_0x991439=>_0x991439!==_0x4ec08d(0x1dd))[_0x4ec08d(0x1d5)](_0xa2bf07=>{const _0x2b8114=_0x4ec08d;_0xa2bf07===_0x2b8114(0x1c6)?_0x4ca839[_0x2b8114(0x1c3)](_0x2b8114(0x1ca)):_0x4ca839[_0x2b8114(0x1c3)](_0x2b8114(0x1ba)+_0xa2bf07+_0x2b8114(0x1d4)+_0xa2bf07+'\x27;');}),fs[_0x4ec08d(0x1e3)](_0x4a5488[_0x4ec08d(0x1e1)]+_0x4ec08d(0x1b7),_0x4ca839[_0x4ec08d(0x1b9)]('\x0a'));}}if(_0x2557dd==='jjb-common'){const _0x2dbd13=[_0x4a5488[_0x4ec08d(0x1e1)],_0x4ec08d(0x1da)][_0x4ec08d(0x1b9)]('\x5c');if([_0x4ec08d(0x1d1),_0x4ec08d(0x1f6)][_0x4ec08d(0x1e7)](_0xe3852a['projectType']))fs[_0x4ec08d(0x1c7)](_0x2dbd13)&&(f_content_replace(_0xe3852a[_0x4ec08d(0x1d2)]==='spa'?COMMON_CONTENT_SPA_REPLACE:[...COMMON_CONTENT_MICRO_REPLACE,...COMMON_CONTENT_NOR_REPLACE],_0x4a5488['path']),fs[_0x4ec08d(0x1e3)](_0x4a5488['path']+CLI_DVA_ROUTER_PATH,fs['readFileSync'](_0xe3852a['projectType']===_0x4ec08d(0x1d1)?CLI_DVA_ROUTER_SPA:CLI_DVA_ROUTER_SAAS)['toString']()),fs[_0x4ec08d(0x1e3)](_0x4a5488[_0x4ec08d(0x1e1)]+CLI_DVA_REGISTER_PATH,fs['readFileSync'](_0xe3852a[_0x4ec08d(0x1d2)]===_0x4ec08d(0x1d1)?CLI_DVA_REGISTER_SPA:CLI_DVA_REGISTER_SAAS)[_0x4ec08d(0x1c5)]()));else _0xe3852a[_0x4ec08d(0x1d2)]===_0x4ec08d(0x1b6)&&(fs[_0x4ec08d(0x1c7)](_0x2dbd13)&&(f_rm_rf(_0x2dbd13),fs[_0x4ec08d(0x1d0)](_0x2dbd13)));}else{if(_0x2557dd===_0x4ec08d(0x1e9))_0xe3852a[_0x4ec08d(0x1d2)]===_0x4ec08d(0x1f6)&&f_content_replace(COMPONENTS_CONTENT_REPLACE,_0x4a5488['path']);else{if(_0x2557dd===_0x4ec08d(0x1bd)){}}}if(_0xe3852a[_0x4ec08d(0x1e5)]==='node_modules'){const _0x1bf8d5=_0x2557dd;fs['existsSync'](_0x5179e3+'\x5c'+_0x1bf8d5)?f_rm_rf(_0x5179e3+'\x5c'+_0x1bf8d5):fs[_0x4ec08d(0x1df)](_0x5179e3+'\x5c'+_0x1bf8d5),f_file_copy(_0x4a5488[_0x4ec08d(0x1e1)],_0x5179e3+'\x5c'+_0x1bf8d5),f_create_package_json(_0x5179e3+'\x5c'+_0x1bf8d5,_0x1bf8d5,_0x4ec08d(0x1cb)),f_update_project_package_json(_0x2d63b0,_0x1bf8d5,_0x4ec08d(0x1cb));}else{if(_0xe3852a[_0x4ec08d(0x1e5)]===_0x4ec08d(0x1ee)){const _0x40b730=_0x4ec08d(0x1e9);fs[_0x4ec08d(0x1c7)](_0x920d71+_0x40b730)?f_rm_rf(_0x920d71+_0x40b730):fs['mkdirSync'](_0x920d71+_0x40b730),f_file_copy(_0x4a5488[_0x4ec08d(0x1e1)],_0x920d71+_0x40b730);}}}),setTimeout(()=>{const _0x17fc0f=_0x3187a8;f_rm_rf(TEMPLATE_FOLDER),fs[_0x17fc0f(0x1d0)](TEMPLATE_FOLDER);const _0x14424f=Date[_0x17fc0f(0x1d3)]();console[_0x17fc0f(0x1f1)](_0x17fc0f(0x1b4)+(_0x14424f-start_time)/0x3e8+'s');},0x5dc);}},0x3e8);}else console[_0xbd21d0(0x1f1)]('【Error】:执行失败,在您的项目根目录,需要一个jjb.config.json文件。');};
|