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,230 +1 @@
|
|
1
|
-
const
|
2
|
-
const os = require('os');
|
3
|
-
const {
|
4
|
-
GIT_HOST,
|
5
|
-
GIT_TEMP_DIR,
|
6
|
-
CLOUD_PROJECT
|
7
|
-
} = require('./config');
|
8
|
-
|
9
|
-
/**
|
10
|
-
* @description 删除全部
|
11
|
-
* @param path {string} 路径
|
12
|
-
*/
|
13
|
-
exports.f_rm_rf = function (path) {
|
14
|
-
if (fs.existsSync(path)) {
|
15
|
-
const list = fs.readdirSync(path);
|
16
|
-
for (let i = 0; i < list.length; i++) {
|
17
|
-
const item = list[ i ];
|
18
|
-
const vPath = `${path}/${item}`;
|
19
|
-
if (fs.statSync(vPath).isDirectory()) {
|
20
|
-
exports.f_rm_rf(vPath);
|
21
|
-
fs.rmdirSync(vPath);
|
22
|
-
} else {
|
23
|
-
fs.unlinkSync(vPath);
|
24
|
-
}
|
25
|
-
}
|
26
|
-
}
|
27
|
-
};
|
28
|
-
|
29
|
-
/**
|
30
|
-
* @typedef {object} GitResource
|
31
|
-
* @property {string} path
|
32
|
-
* @property {string} compress
|
33
|
-
* @property {string} repository
|
34
|
-
*/
|
35
|
-
|
36
|
-
/**
|
37
|
-
* @description 拉取git资源
|
38
|
-
* @param installResources {Resource[]} 资源名称
|
39
|
-
* @return {GitResource[]}
|
40
|
-
*/
|
41
|
-
exports.f_pull_git_repository = function (installResources = []) {
|
42
|
-
return installResources.map(item => {
|
43
|
-
const resource = CLOUD_PROJECT[ item.name ] || undefined;
|
44
|
-
const template = os.tmpdir();
|
45
|
-
return {
|
46
|
-
path: `${template}\\${GIT_TEMP_DIR}\\${item.name}.zip`,
|
47
|
-
compress: `${template}\\${GIT_TEMP_DIR}\\${item.name}_zip`,
|
48
|
-
repository: `${GIT_HOST}/api/v4/projects/${resource.projectId}/repository/archive.zip?private_token=${resource.token}&ref=master`
|
49
|
-
};
|
50
|
-
});
|
51
|
-
};
|
52
|
-
|
53
|
-
/**
|
54
|
-
* @description 扫描是否存在jjb.config.json
|
55
|
-
* @param root 路径
|
56
|
-
* @returns {boolean}
|
57
|
-
*/
|
58
|
-
exports.f_scan_jjb_config_json = function (root) {
|
59
|
-
return fs.existsSync(`${root}\\jjb.config.json`);
|
60
|
-
};
|
61
|
-
|
62
|
-
/**
|
63
|
-
* @typedef {object} JJB_CONFIG_JSON
|
64
|
-
* @property {string} projectType
|
65
|
-
* @property {string} installTarget
|
66
|
-
* @property {Resource[]} installResources
|
67
|
-
*/
|
68
|
-
|
69
|
-
/**
|
70
|
-
* @description 验证规则
|
71
|
-
* @param root {string} 路径
|
72
|
-
* @return {JJB_CONFIG_JSON}
|
73
|
-
*/
|
74
|
-
exports.f_scan_jjb_config_json_rules = function (root) {
|
75
|
-
let jjb_config_json = {};
|
76
|
-
try {
|
77
|
-
jjb_config_json = JSON.parse(fs.readFileSync(`${root}\\jjb.config.json`).toString());
|
78
|
-
} catch (e) {
|
79
|
-
console.log('【Error】:[jjb.config.json]文件解析失败,请确认是否配置正确。');
|
80
|
-
process.exit(0);
|
81
|
-
}
|
82
|
-
if (!('projectType' in jjb_config_json)) {
|
83
|
-
console.log('【Error】:[jjb.config.json]文件配置无效,需要projectType属性。');
|
84
|
-
process.exit(0);
|
85
|
-
}
|
86
|
-
if (!('installTarget' in jjb_config_json)) {
|
87
|
-
console.log('【Error】:[jjb.config.json]文件配置无效,需要installTarget属性。');
|
88
|
-
process.exit(0);
|
89
|
-
}
|
90
|
-
if (!('installResources' in jjb_config_json)) {
|
91
|
-
console.log('【Error】:[jjb.config.json]文件配置无效,需要installResources属性。');
|
92
|
-
process.exit(0);
|
93
|
-
}
|
94
|
-
if (typeof jjb_config_json.projectType !== 'string') {
|
95
|
-
console.log('【Error】:[jjb.config.json.projectType]类型是一个string。');
|
96
|
-
process.exit(0);
|
97
|
-
}
|
98
|
-
if (![
|
99
|
-
'multi',
|
100
|
-
'spa',
|
101
|
-
'uniapp',
|
102
|
-
'micro-spa'
|
103
|
-
].includes(jjb_config_json.projectType)) {
|
104
|
-
console.log('【Error】:[jjb.config.json.projectType]配置无效,有效值<multi | spa | micro-spa | uniapp>。');
|
105
|
-
process.exit(0);
|
106
|
-
}
|
107
|
-
if (typeof jjb_config_json.installTarget !== 'string') {
|
108
|
-
console.log('【Error】:[jjb.config.json.installTarget]类型是一个string。');
|
109
|
-
process.exit(0);
|
110
|
-
}
|
111
|
-
if (![
|
112
|
-
'node_modules',
|
113
|
-
'src'
|
114
|
-
].includes(jjb_config_json.installTarget)) {
|
115
|
-
console.log('【Error】:[jjb.config.json.node_modules]配置无效,有效值<node_modules | src>。');
|
116
|
-
process.exit(0);
|
117
|
-
}
|
118
|
-
if (!Array.isArray(jjb_config_json.installResources)) {
|
119
|
-
console.log('【Error】:[jjb.config.json.installResources]类型是一个Array<string>。');
|
120
|
-
process.exit(0);
|
121
|
-
}
|
122
|
-
if (jjb_config_json.installResources.length === 0) {
|
123
|
-
console.log('【Error】:[jjb.config.json.installResources]无资源。');
|
124
|
-
process.exit(0);
|
125
|
-
}
|
126
|
-
const resources = exports.f_resolve_install_resources(jjb_config_json.installResources);
|
127
|
-
if (resources.map(item => item.name).filter(v => ![
|
128
|
-
'jjb-common',
|
129
|
-
'jjb-dva-runtime',
|
130
|
-
'jjb-common-lib',
|
131
|
-
'jjb-common-decorator',
|
132
|
-
'react-admin-component',
|
133
|
-
'vue-unisass-component'
|
134
|
-
].includes(v)).length !== 0) {
|
135
|
-
console.log('【Error】:[jjb.config.json.installResources]配置无效,有效值<common | react-admin-component | vue-unisass-component | jjb-common-decorator | jjb-dva-runtime | jjb-common-lib>。');
|
136
|
-
process.exit(0);
|
137
|
-
}
|
138
|
-
jjb_config_json.installResources = resources;
|
139
|
-
return jjb_config_json;
|
140
|
-
};
|
141
|
-
|
142
|
-
/**
|
143
|
-
* @description 创建package.json
|
144
|
-
* @param path {string} 路径
|
145
|
-
* @param name {string} 包名
|
146
|
-
* @param version {string} 版本
|
147
|
-
*/
|
148
|
-
exports.f_create_package_json = function (path, name, version) {
|
149
|
-
fs.writeFileSync(`${path}\\package.json`, `{"name":"${name}","version":"${version}","main": "index.js"}`);
|
150
|
-
};
|
151
|
-
|
152
|
-
/**
|
153
|
-
* @typedef {object} Resource
|
154
|
-
* @property {string} name
|
155
|
-
* @property {string[]} importList
|
156
|
-
*/
|
157
|
-
|
158
|
-
/**
|
159
|
-
* @description 分析resources
|
160
|
-
* @param installResources
|
161
|
-
* @return {Resource[]}
|
162
|
-
*/
|
163
|
-
exports.f_resolve_install_resources = function (installResources = []) {
|
164
|
-
const resources = [];
|
165
|
-
if (Array.isArray(installResources)) {
|
166
|
-
installResources.forEach(resource => {
|
167
|
-
if (Array.isArray(resource)) {
|
168
|
-
const [ name, importList = [] ] = resource;
|
169
|
-
resources.push({
|
170
|
-
name,
|
171
|
-
importList
|
172
|
-
});
|
173
|
-
} else {
|
174
|
-
resources.push({
|
175
|
-
name: resource,
|
176
|
-
importList: []
|
177
|
-
});
|
178
|
-
}
|
179
|
-
});
|
180
|
-
}
|
181
|
-
return resources;
|
182
|
-
};
|
183
|
-
|
184
|
-
/**
|
185
|
-
* @description 更新项目package.json文件
|
186
|
-
* @param path {string} 路径
|
187
|
-
* @param name {string} 包名
|
188
|
-
* @param version {string} 版本
|
189
|
-
*/
|
190
|
-
exports.f_update_project_package_json = function (path, name, version) {
|
191
|
-
const packageJSONFile = JSON.parse(fs.readFileSync(path).toString());
|
192
|
-
packageJSONFile.dependencies[ name ] = version;
|
193
|
-
fs.writeFileSync(path, JSON.stringify(packageJSONFile, null, 2));
|
194
|
-
};
|
195
|
-
|
196
|
-
/**
|
197
|
-
* @description 复制文件
|
198
|
-
* @param originSrc
|
199
|
-
* @param targetSrc
|
200
|
-
*/
|
201
|
-
exports.f_file_copy = function (originSrc, targetSrc) {
|
202
|
-
fs.readdirSync(originSrc).forEach(dir => {
|
203
|
-
const oPath = `${originSrc}\\${dir}`;
|
204
|
-
const tPath = `${targetSrc}\\${dir}`;
|
205
|
-
if (fs.statSync(oPath).isDirectory()) {
|
206
|
-
fs.mkdirSync(tPath);
|
207
|
-
exports.f_file_copy(oPath, tPath);
|
208
|
-
} else {
|
209
|
-
fs.writeFileSync(tPath, fs.readFileSync(oPath).toString());
|
210
|
-
}
|
211
|
-
});
|
212
|
-
};
|
213
|
-
|
214
|
-
/**
|
215
|
-
* @description 替换文件操作
|
216
|
-
* @param source {[]} 替换源
|
217
|
-
* @param root {string} 路径
|
218
|
-
*/
|
219
|
-
exports.f_content_replace = function (source = [], root) {
|
220
|
-
source.forEach(item => {
|
221
|
-
const path = root + item.path;
|
222
|
-
if (fs.existsSync(path)) {
|
223
|
-
let content = fs.readFileSync(path).toString();
|
224
|
-
item.replace.forEach(rep => {
|
225
|
-
content = content.replace(rep[ 0 ], rep[ 1 ]);
|
226
|
-
});
|
227
|
-
fs.writeFileSync(path, content);
|
228
|
-
}
|
229
|
-
});
|
230
|
-
};
|
1
|
+
const a18_0x38b743=a18_0x1ce7;(function(_0x4a7873,_0x25a702){const _0x5a1b1c=a18_0x1ce7,_0x170ad5=_0x4a7873();while(!![]){try{const _0x2d9fc4=-parseInt(_0x5a1b1c(0xed))/0x1+-parseInt(_0x5a1b1c(0xb9))/0x2*(parseInt(_0x5a1b1c(0xcf))/0x3)+parseInt(_0x5a1b1c(0xbe))/0x4+-parseInt(_0x5a1b1c(0xb4))/0x5*(-parseInt(_0x5a1b1c(0xea))/0x6)+-parseInt(_0x5a1b1c(0xc4))/0x7+parseInt(_0x5a1b1c(0xde))/0x8*(-parseInt(_0x5a1b1c(0xa5))/0x9)+parseInt(_0x5a1b1c(0xdb))/0xa;if(_0x2d9fc4===_0x25a702)break;else _0x170ad5['push'](_0x170ad5['shift']());}catch(_0x2e3d95){_0x170ad5['push'](_0x170ad5['shift']());}}}(a18_0x33b5,0x6e086));const fs=require('fs'),os=require('os'),{GIT_HOST,GIT_TEMP_DIR,CLOUD_PROJECT}=require(a18_0x38b743(0xbf));exports[a18_0x38b743(0xad)]=function(_0x4eb241){const _0x146d8d=a18_0x38b743;if(fs[_0x146d8d(0xc5)](_0x4eb241)){const _0x2137ed=fs['readdirSync'](_0x4eb241);for(let _0x4b1454=0x0;_0x4b1454<_0x2137ed[_0x146d8d(0xca)];_0x4b1454++){const _0x8074fa=_0x2137ed[_0x4b1454],_0x143ad5=_0x4eb241+'/'+_0x8074fa;fs[_0x146d8d(0xab)](_0x143ad5)[_0x146d8d(0xd0)]()?(exports[_0x146d8d(0xad)](_0x143ad5),fs[_0x146d8d(0xc9)](_0x143ad5)):fs['unlinkSync'](_0x143ad5);}}},exports['f_pull_git_repository']=function(_0x569049=[]){return _0x569049['map'](_0x2c3623=>{const _0x141ba5=a18_0x1ce7,_0x3190ae=CLOUD_PROJECT[_0x2c3623[_0x141ba5(0xd8)]]||undefined,_0x8a762a=os[_0x141ba5(0xa7)]();return{'path':_0x8a762a+'\x5c'+GIT_TEMP_DIR+'\x5c'+_0x2c3623[_0x141ba5(0xd8)]+'.zip','compress':_0x8a762a+'\x5c'+GIT_TEMP_DIR+'\x5c'+_0x2c3623[_0x141ba5(0xd8)]+_0x141ba5(0xe7),'repository':GIT_HOST+_0x141ba5(0xd9)+_0x3190ae[_0x141ba5(0xd5)]+_0x141ba5(0xc2)+_0x3190ae[_0x141ba5(0xcc)]+_0x141ba5(0xaa)};});},exports[a18_0x38b743(0xc0)]=function(_0x15032c){const _0x2cd8c9=a18_0x38b743;return fs[_0x2cd8c9(0xc5)](_0x15032c+_0x2cd8c9(0xcd));},exports[a18_0x38b743(0xaf)]=function(_0x3faa29){const _0x357d12=a18_0x38b743;let _0x33f930={};try{_0x33f930=JSON[_0x357d12(0xd4)](fs[_0x357d12(0xb8)](_0x3faa29+_0x357d12(0xcd))[_0x357d12(0xcb)]());}catch(_0x14bf9d){console[_0x357d12(0xdd)](_0x357d12(0xee)),process[_0x357d12(0xe4)](0x0);}!(_0x357d12(0xe6)in _0x33f930)&&(console['log']('【Error】:[jjb.config.json]文件配置无效,需要projectType属性。'),process[_0x357d12(0xe4)](0x0));!('installTarget'in _0x33f930)&&(console[_0x357d12(0xdd)](_0x357d12(0xd1)),process['exit'](0x0));!('installResources'in _0x33f930)&&(console[_0x357d12(0xdd)](_0x357d12(0xc3)),process[_0x357d12(0xe4)](0x0));typeof _0x33f930[_0x357d12(0xe6)]!==_0x357d12(0xd2)&&(console[_0x357d12(0xdd)](_0x357d12(0xda)),process[_0x357d12(0xe4)](0x0));![_0x357d12(0xec),_0x357d12(0xba),'uniapp',_0x357d12(0xa8)][_0x357d12(0xb3)](_0x33f930['projectType'])&&(console[_0x357d12(0xdd)](_0x357d12(0xb7)),process[_0x357d12(0xe4)](0x0));typeof _0x33f930[_0x357d12(0xa9)]!=='string'&&(console[_0x357d12(0xdd)](_0x357d12(0xe0)),process[_0x357d12(0xe4)](0x0));![_0x357d12(0xeb),_0x357d12(0xc8)][_0x357d12(0xb3)](_0x33f930[_0x357d12(0xa9)])&&(console[_0x357d12(0xdd)]('【Error】:[jjb.config.json.node_modules]配置无效,有效值<node_modules\x20|\x20src>。'),process[_0x357d12(0xe4)](0x0));!Array[_0x357d12(0xe5)](_0x33f930[_0x357d12(0xef)])&&(console['log'](_0x357d12(0xce)),process[_0x357d12(0xe4)](0x0));_0x33f930[_0x357d12(0xef)]['length']===0x0&&(console[_0x357d12(0xdd)](_0x357d12(0xb1)),process['exit'](0x0));const _0x6ca458=exports['f_resolve_install_resources'](_0x33f930[_0x357d12(0xef)]);return _0x6ca458[_0x357d12(0xb2)](_0x43c1ab=>_0x43c1ab['name'])[_0x357d12(0xe3)](_0x1d7e3e=>![_0x357d12(0xe2),'jjb-dva-runtime',_0x357d12(0xbc),'jjb-common-decorator',_0x357d12(0xbb),_0x357d12(0xe8)][_0x357d12(0xb3)](_0x1d7e3e))['length']!==0x0&&(console['log'](_0x357d12(0xe1)),process['exit'](0x0)),_0x33f930[_0x357d12(0xef)]=_0x6ca458,_0x33f930;},exports['f_create_package_json']=function(_0x37eece,_0x13e31c,_0x177abd){const _0x21500d=a18_0x38b743;fs['writeFileSync'](_0x37eece+'\x5cpackage.json',_0x21500d(0xbd)+_0x13e31c+_0x21500d(0xdc)+_0x177abd+_0x21500d(0xdf));},exports[a18_0x38b743(0xb0)]=function(_0x4ceb3e=[]){const _0x129086=a18_0x38b743,_0x1c36bc=[];return Array[_0x129086(0xe5)](_0x4ceb3e)&&_0x4ceb3e[_0x129086(0xc7)](_0x5d19cd=>{const _0x10a0ae=_0x129086;if(Array['isArray'](_0x5d19cd)){const [_0x2c49d2,_0x37b57e=[]]=_0x5d19cd;_0x1c36bc[_0x10a0ae(0xb5)]({'name':_0x2c49d2,'importList':_0x37b57e});}else _0x1c36bc['push']({'name':_0x5d19cd,'importList':[]});}),_0x1c36bc;},exports[a18_0x38b743(0xc6)]=function(_0x568c0c,_0x3272eb,_0x3d98b3){const _0x428065=a18_0x38b743,_0x2c17ab=JSON[_0x428065(0xd4)](fs[_0x428065(0xb8)](_0x568c0c)[_0x428065(0xcb)]());_0x2c17ab[_0x428065(0xe9)][_0x3272eb]=_0x3d98b3,fs[_0x428065(0xd7)](_0x568c0c,JSON[_0x428065(0xd6)](_0x2c17ab,null,0x2));},exports[a18_0x38b743(0xa6)]=function(_0xebf76a,_0x2a1798){const _0x4c4a43=a18_0x38b743;fs[_0x4c4a43(0xae)](_0xebf76a)[_0x4c4a43(0xc7)](_0x5e4972=>{const _0x5952f0=_0x4c4a43,_0x5c26e0=_0xebf76a+'\x5c'+_0x5e4972,_0x393210=_0x2a1798+'\x5c'+_0x5e4972;fs['statSync'](_0x5c26e0)['isDirectory']()?(fs[_0x5952f0(0xb6)](_0x393210),exports[_0x5952f0(0xa6)](_0x5c26e0,_0x393210)):fs[_0x5952f0(0xd7)](_0x393210,fs[_0x5952f0(0xb8)](_0x5c26e0)['toString']());});},exports[a18_0x38b743(0xd3)]=function(_0x17d7ef=[],_0x2be4b0){const _0x28f605=a18_0x38b743;_0x17d7ef[_0x28f605(0xc7)](_0x46a8cf=>{const _0x372803=_0x28f605,_0x4bc57f=_0x2be4b0+_0x46a8cf[_0x372803(0xac)];if(fs[_0x372803(0xc5)](_0x4bc57f)){let _0x5988a3=fs[_0x372803(0xb8)](_0x4bc57f)['toString']();_0x46a8cf['replace']['forEach'](_0x268564=>{const _0x5d71f9=_0x372803;_0x5988a3=_0x5988a3[_0x5d71f9(0xc1)](_0x268564[0x0],_0x268564[0x1]);}),fs[_0x372803(0xd7)](_0x4bc57f,_0x5988a3);}});};function a18_0x1ce7(_0x2d9da1,_0x23a27e){const _0x33b5b0=a18_0x33b5();return a18_0x1ce7=function(_0x1ce7e2,_0x56c6c3){_0x1ce7e2=_0x1ce7e2-0xa5;let _0xb36640=_0x33b5b0[_0x1ce7e2];return _0xb36640;},a18_0x1ce7(_0x2d9da1,_0x23a27e);}function a18_0x33b5(){const _0xc4b4ac=['【Error】:[jjb.config.json.installResources]类型是一个Array<string>。','756Pwrvfn','isDirectory','【Error】:[jjb.config.json]文件配置无效,需要installTarget属性。','string','f_content_replace','parse','projectId','stringify','writeFileSync','name','/api/v4/projects/','【Error】:[jjb.config.json.projectType]类型是一个string。','13874450VTIbZZ','\x22,\x22version\x22:\x22','log','274552PVCWaD','\x22,\x22main\x22:\x20\x22index.js\x22}','【Error】:[jjb.config.json.installTarget]类型是一个string。','【Error】:[jjb.config.json.installResources]配置无效,有效值<common\x20|\x20react-admin-component\x20|\x20vue-unisass-component\x20|\x20jjb-common-decorator\x20|\x20jjb-dva-runtime\x20|\x20jjb-common-lib>。','jjb-common','filter','exit','isArray','projectType','_zip','vue-unisass-component','dependencies','58032QhpUhT','node_modules','multi','135482idgEDy','【Error】:[jjb.config.json]文件解析失败,请确认是否配置正确。','installResources','9gqsagO','f_file_copy','tmpdir','micro-spa','installTarget','&ref=master','statSync','path','f_rm_rf','readdirSync','f_scan_jjb_config_json_rules','f_resolve_install_resources','【Error】:[jjb.config.json.installResources]无资源。','map','includes','65VLEuJC','push','mkdirSync','【Error】:[jjb.config.json.projectType]配置无效,有效值<multi\x20|\x20spa\x20|\x20micro-spa\x20|\x20uniapp>。','readFileSync','4106fuaEzh','spa','react-admin-component','jjb-common-lib','{\x22name\x22:\x22','1790268MlAZwb','./config','f_scan_jjb_config_json','replace','/repository/archive.zip?private_token=','【Error】:[jjb.config.json]文件配置无效,需要installResources属性。','5760279xZSmEc','existsSync','f_update_project_package_json','forEach','src','rmdirSync','length','toString','token','\x5cjjb.config.json'];a18_0x33b5=function(){return _0xc4b4ac;};return a18_0x33b5();}
|
package/src/old/cli.merge.js
CHANGED
@@ -1,80 +1 @@
|
|
1
|
-
const
|
2
|
-
const path = require('path');
|
3
|
-
const utils = require('./util.js');
|
4
|
-
|
5
|
-
//项目路径
|
6
|
-
let projectPath = '';
|
7
|
-
//项目脚手架路径
|
8
|
-
let vesselPath = '';
|
9
|
-
//input传入参数 指令:地区:环境 start:chongqing:dev
|
10
|
-
let commandArr = [];
|
11
|
-
//application数据
|
12
|
-
const fromFileData = {};
|
13
|
-
const applicationJson = {};
|
14
|
-
|
15
|
-
/**
|
16
|
-
* input 指令:地区:环境 start:chongqing:dev
|
17
|
-
*/
|
18
|
-
module.exports = (input, source) => {
|
19
|
-
commandArr = input.split(':');
|
20
|
-
projectPath = path.resolve('./project');
|
21
|
-
vesselPath = path.resolve('./vessel/src');
|
22
|
-
let applicationPath = vesselPath;
|
23
|
-
if (source === 'mp') {
|
24
|
-
applicationPath = vesselPath + '/application';
|
25
|
-
utils.CreatePaths(vesselPath, ['application']);
|
26
|
-
}
|
27
|
-
const inputRegion = commandArr[1];
|
28
|
-
const settingJson = JSON.parse(fs.readFileSync(`${projectPath}/${inputRegion}/setting.json`).toString());
|
29
|
-
TileItems(settingJson.items, () => {
|
30
|
-
|
31
|
-
fromFileData.router.forEach(fromItem => {
|
32
|
-
const itemPathArr = fromItem.pathAdr.split(fromItem.region);
|
33
|
-
const filePathArr = itemPathArr[1].split('/');
|
34
|
-
const application = filePathArr[1];
|
35
|
-
if (!applicationJson[application]) {
|
36
|
-
applicationJson[application] = {
|
37
|
-
routerConfig: [],
|
38
|
-
routerPath: []
|
39
|
-
};
|
40
|
-
}
|
41
|
-
applicationJson[application].routerConfig.push(`{ path: '${fromItem.path}', component: () => import('${fromItem.file}') }`);
|
42
|
-
applicationJson[application].routerPath.push(fromItem.path);
|
43
|
-
|
44
|
-
let applicationStr = filePathArr.join('/');
|
45
|
-
|
46
|
-
const strArr = applicationStr.split('/');
|
47
|
-
utils.CreatePaths(applicationPath, strArr.slice(0, strArr.length - 1)).then(() => {
|
48
|
-
const fileContent = fs.readFileSync(fromItem.pathAdr).toString();
|
49
|
-
fs.writeFileSync(`${vesselPath}/${applicationStr}`, fileContent);
|
50
|
-
});
|
51
|
-
|
52
|
-
});
|
53
|
-
|
54
|
-
});
|
55
|
-
};
|
56
|
-
|
57
|
-
/**
|
58
|
-
* 平铺,展开所有路径
|
59
|
-
* @param items
|
60
|
-
* @param cb
|
61
|
-
* @constructor
|
62
|
-
*/
|
63
|
-
function TileItems (items, cb) {
|
64
|
-
items.forEach((item, index) => {
|
65
|
-
const region = item.region;
|
66
|
-
item.from.forEach((from, fromIndex) => {
|
67
|
-
const pathArr = [];
|
68
|
-
utils.DeepScanner(projectPath + '/' + region + '/' + from.file, pathArr);
|
69
|
-
const newPathArr = pathArr.map(pathItem => ({ region, pathAdr: pathItem, ...from }));
|
70
|
-
if (!fromFileData[from.fileType]) {
|
71
|
-
fromFileData[from.fileType] = newPathArr;
|
72
|
-
} else {
|
73
|
-
fromFileData[from.fileType] = fromFileData[from.fileType].concat(newPathArr);
|
74
|
-
}
|
75
|
-
if (index === items.length - 1 && fromIndex === item.from.length - 1) {
|
76
|
-
cb();
|
77
|
-
}
|
78
|
-
});
|
79
|
-
})
|
80
|
-
}
|
1
|
+
function a19_0x5713(){const _0x4084fb=['exports','\x27)\x20}','readFileSync','map','/setting.json','7090392Jpclux','\x27,\x20component:\x20()\x20=>\x20import(\x27','path','DeepScanner','299831CmAvCa','region','1VJeFvb','toString','file','./project','./util.js','items','from','parse','writeFileSync','./vessel/src','then','resolve','12cXUihk','36unVHZW','472115DqPSMI','application','CreatePaths','9QSPPEl','180xHAnXw','router','length','359655CSouqF','forEach','routerPath','routerConfig','19062527CEWKvC','3484438KQXmtK','fileType','push','slice','split','3171790bgBzET'];a19_0x5713=function(){return _0x4084fb;};return a19_0x5713();}const a19_0x1f3a83=a19_0x2e24;(function(_0x503d0d,_0x139e3d){const _0x1468a6=a19_0x2e24,_0x4ccdf7=_0x503d0d();while(!![]){try{const _0x36279b=-parseInt(_0x1468a6(0x9b))/0x1*(-parseInt(_0x1468a6(0x8a))/0x2)+parseInt(_0x1468a6(0x85))/0x3+-parseInt(_0x1468a6(0x7d))/0x4*(parseInt(_0x1468a6(0x7e))/0x5)+-parseInt(_0x1468a6(0x82))/0x6*(parseInt(_0x1468a6(0x99))/0x7)+-parseInt(_0x1468a6(0x95))/0x8*(parseInt(_0x1468a6(0x81))/0x9)+parseInt(_0x1468a6(0x8f))/0xa+parseInt(_0x1468a6(0x89))/0xb*(parseInt(_0x1468a6(0x7c))/0xc);if(_0x36279b===_0x139e3d)break;else _0x4ccdf7['push'](_0x4ccdf7['shift']());}catch(_0x5d7cf0){_0x4ccdf7['push'](_0x4ccdf7['shift']());}}}(a19_0x5713,0xd9908));const fs=require('fs'),path=require(a19_0x1f3a83(0x97)),utils=require(a19_0x1f3a83(0x9f));let projectPath='',vesselPath='',commandArr=[];function a19_0x2e24(_0x3bc65b,_0x3e0e7b){const _0x571304=a19_0x5713();return a19_0x2e24=function(_0x2e248a,_0x34a5ce){_0x2e248a=_0x2e248a-0x79;let _0x55a38a=_0x571304[_0x2e248a];return _0x55a38a;},a19_0x2e24(_0x3bc65b,_0x3e0e7b);}const fromFileData={},applicationJson={};module[a19_0x1f3a83(0x90)]=(_0x3095db,_0x42c453)=>{const _0x1c8720=a19_0x1f3a83;commandArr=_0x3095db[_0x1c8720(0x8e)](':'),projectPath=path[_0x1c8720(0x7b)](_0x1c8720(0x9e)),vesselPath=path[_0x1c8720(0x7b)](_0x1c8720(0x79));let _0x198de3=vesselPath;_0x42c453==='mp'&&(_0x198de3=vesselPath+'/application',utils[_0x1c8720(0x80)](vesselPath,[_0x1c8720(0x7f)]));const _0x117cbd=commandArr[0x1],_0x38578d=JSON[_0x1c8720(0xa2)](fs['readFileSync'](projectPath+'/'+_0x117cbd+_0x1c8720(0x94))[_0x1c8720(0x9c)]());TileItems(_0x38578d[_0x1c8720(0xa0)],()=>{const _0x1aa872=_0x1c8720;fromFileData[_0x1aa872(0x83)][_0x1aa872(0x86)](_0x3d153a=>{const _0x294bf8=_0x1aa872,_0x42aba1=_0x3d153a['pathAdr']['split'](_0x3d153a[_0x294bf8(0x9a)]),_0x409c4a=_0x42aba1[0x1]['split']('/'),_0x1e99c1=_0x409c4a[0x1];!applicationJson[_0x1e99c1]&&(applicationJson[_0x1e99c1]={'routerConfig':[],'routerPath':[]});applicationJson[_0x1e99c1][_0x294bf8(0x88)]['push']('{\x20path:\x20\x27'+_0x3d153a[_0x294bf8(0x97)]+_0x294bf8(0x96)+_0x3d153a[_0x294bf8(0x9d)]+_0x294bf8(0x91)),applicationJson[_0x1e99c1][_0x294bf8(0x87)][_0x294bf8(0x8c)](_0x3d153a[_0x294bf8(0x97)]);let _0x574b60=_0x409c4a['join']('/');const _0x1f8f0f=_0x574b60[_0x294bf8(0x8e)]('/');utils['CreatePaths'](_0x198de3,_0x1f8f0f[_0x294bf8(0x8d)](0x0,_0x1f8f0f[_0x294bf8(0x84)]-0x1))[_0x294bf8(0x7a)](()=>{const _0x237d7f=_0x294bf8,_0x5d9eb8=fs[_0x237d7f(0x92)](_0x3d153a['pathAdr'])[_0x237d7f(0x9c)]();fs[_0x237d7f(0xa3)](vesselPath+'/'+_0x574b60,_0x5d9eb8);});});});};function TileItems(_0x3a12a0,_0x5e8f2e){_0x3a12a0['forEach']((_0x3f6550,_0xb9411)=>{const _0x4ca0c4=a19_0x2e24,_0x38096c=_0x3f6550[_0x4ca0c4(0x9a)];_0x3f6550['from'][_0x4ca0c4(0x86)]((_0x9d6312,_0x3439d8)=>{const _0x3fedb2=_0x4ca0c4,_0x10a57a=[];utils[_0x3fedb2(0x98)](projectPath+'/'+_0x38096c+'/'+_0x9d6312[_0x3fedb2(0x9d)],_0x10a57a);const _0x36b291=_0x10a57a[_0x3fedb2(0x93)](_0x167bfe=>({'region':_0x38096c,'pathAdr':_0x167bfe,..._0x9d6312}));!fromFileData[_0x9d6312[_0x3fedb2(0x8b)]]?fromFileData[_0x9d6312[_0x3fedb2(0x8b)]]=_0x36b291:fromFileData[_0x9d6312['fileType']]=fromFileData[_0x9d6312[_0x3fedb2(0x8b)]]['concat'](_0x36b291),_0xb9411===_0x3a12a0['length']-0x1&&_0x3439d8===_0x3f6550[_0x3fedb2(0xa1)]['length']-0x1&&_0x5e8f2e();});});}
|
package/src/old/cli.pull.js
CHANGED
@@ -1,94 +1 @@
|
|
1
|
-
'use strict';
|
2
|
-
|
3
|
-
const fs = require('fs');
|
4
|
-
const os = require('os');
|
5
|
-
const path = require('path');
|
6
|
-
const utils = require('./util');
|
7
|
-
const request = require('request');
|
8
|
-
const compressing = require('compressing');
|
9
|
-
|
10
|
-
//临时存放目录
|
11
|
-
const GIT_TEMP_DIR = 'jjbAssembly';
|
12
|
-
//GIT仓库
|
13
|
-
const GIT_HOST = 'http://192.168.1.242:10985';
|
14
|
-
//项目列表,后期可存库
|
15
|
-
const CLOUD_PROJECT = {
|
16
|
-
'common': {
|
17
|
-
token: 'G4HJRsHr9D7Ssmixegw2',
|
18
|
-
projectId: 279,
|
19
|
-
localName: 'common'
|
20
|
-
},
|
21
|
-
'react-admin-component': {
|
22
|
-
token: 'FT3pKzxpRynFkmddJ9Bs',
|
23
|
-
projectId: 340,
|
24
|
-
localName: 'components'
|
25
|
-
}
|
26
|
-
};
|
27
|
-
|
28
|
-
module.exports = input => {
|
29
|
-
const dirName = input;
|
30
|
-
const currDir = path.resolve('./');
|
31
|
-
try {
|
32
|
-
if (fs.statSync(currDir + '\\src')) {
|
33
|
-
const srcDir = currDir + '\\src';
|
34
|
-
const cloudObj = CLOUD_PROJECT[ dirName ] || undefined;
|
35
|
-
if (cloudObj) {
|
36
|
-
const tmpDir = os.tmpdir();
|
37
|
-
const dirPath = tmpDir + `/${GIT_TEMP_DIR}/${dirName}.zip`;
|
38
|
-
const dirUnzip = `${tmpDir}/${GIT_TEMP_DIR}/unzip/`;
|
39
|
-
utils.DeleteDirAllFile(`${tmpDir}/${GIT_TEMP_DIR}`, () => {
|
40
|
-
fs.mkdirSync(`${tmpDir}/${GIT_TEMP_DIR}`);
|
41
|
-
let stream = fs.createWriteStream(dirPath);
|
42
|
-
request(`${GIT_HOST}/api/v4/projects/${cloudObj.projectId}/repository/archive.zip?private_token=${cloudObj.token}&ref=master`).pipe(stream)
|
43
|
-
.on('close', () => {
|
44
|
-
fs.mkdirSync(dirUnzip);
|
45
|
-
compressing.zip.uncompress(dirPath, dirUnzip)
|
46
|
-
.then(() => {
|
47
|
-
setTimeout(() => {
|
48
|
-
const srcAll = fs.readdirSync(dirUnzip);
|
49
|
-
srcAll.forEach(dirName => {
|
50
|
-
if (dirName.indexOf('-master-') !== -1) {
|
51
|
-
const nowPath = srcDir + '\\' + cloudObj.localName;
|
52
|
-
utils.DeleteDirAllFile(nowPath, () => {
|
53
|
-
fs.mkdirSync(nowPath);
|
54
|
-
utils.CopyFolder(dirUnzip + dirName, nowPath);
|
55
|
-
setTimeout(() => {
|
56
|
-
const isMutilate = fs.existsSync(srcDir + '\\' + 'application');
|
57
|
-
if (!isMutilate) {
|
58
|
-
const commonToolsPath = srcDir + '\\' + 'common\\tools\\index.js';
|
59
|
-
const commonWebsitePath = srcDir + '\\' + 'common\\website\\index.js';
|
60
|
-
let commonToolsFile = fs.readFileSync(commonToolsPath).toString();
|
61
|
-
let commonWebsiteFile = fs.readFileSync(commonWebsitePath).toString();
|
62
|
-
commonToolsFile = commonToolsFile.replace('return __planA();', 'return process.env;');
|
63
|
-
commonWebsiteFile = commonWebsiteFile.replace(/const\srelation\s=\srequire\(`~\/application\/\${module.code}\/enumerate\/menu`\)\.default;/, "const relation = require('~/enumerate/menu').default;");
|
64
|
-
fs.writeFileSync(commonToolsPath, commonToolsFile);
|
65
|
-
fs.writeFileSync(commonWebsitePath, commonWebsiteFile);
|
66
|
-
fs.writeFileSync(`${srcDir}\\common\\dva\\automatic\\router.js`, fs.readFileSync(`${__dirname}\\cli.dva.router.spa.txt`).toString());
|
67
|
-
fs.writeFileSync(`${srcDir}\\common\\dva\\automatic\\register.js`, fs.readFileSync(`${__dirname}\\cli.dva.register.spa.txt`).toString());
|
68
|
-
} else {
|
69
|
-
fs.exists(srcDir + '\\' + 'common\\dva\\automatic\\index.js', has => {
|
70
|
-
if (has) {
|
71
|
-
fs.readdirSync(srcDir + '\\' + 'common\\dva\\automatic').forEach(p => {
|
72
|
-
fs.unlinkSync(srcDir + '\\' + 'common\\dva\\automatic\\' + p);
|
73
|
-
});
|
74
|
-
fs.rmdirSync(srcDir + '\\' + 'common\\dva\\automatic');
|
75
|
-
}
|
76
|
-
});
|
77
|
-
}
|
78
|
-
}, 1000);
|
79
|
-
});
|
80
|
-
}
|
81
|
-
});
|
82
|
-
console.log(dirName + '-文件下载完毕');
|
83
|
-
}, 2000);
|
84
|
-
});
|
85
|
-
});
|
86
|
-
});
|
87
|
-
} else {
|
88
|
-
console.error('【Error】: 未获取到项目 ' + dirName);
|
89
|
-
}
|
90
|
-
}
|
91
|
-
} catch (e) {
|
92
|
-
console.error('【Error】: 当前目录不存在src子目录,无法完成pull操作。');
|
93
|
-
}
|
94
|
-
};
|
1
|
+
'use strict';function a20_0x3053(){const _0x5abd13=['common','\x5ccommon\x5cdva\x5cautomatic\x5cregister.js','close','token','912961CRYmnx','common\x5cwebsite\x5cindex.js','exists','resolve','path','then','&ref=master','G4HJRsHr9D7Ssmixegw2','return\x20__planA();','8022hGVdcK','readdirSync','CopyFolder','-master-','statSync','replace','projectId','rmdirSync','http://192.168.1.242:10985','mkdirSync','8708436tcTeIo','\x5csrc','pipe','855670zVHMPC','log','10OxhuYD','./util','exports','createWriteStream','components','30256sVthIC','/unzip/','request','DeleteDirAllFile','forEach','existsSync','readFileSync','common\x5cdva\x5cautomatic\x5cindex.js','-文件下载完毕','3080760yOJtFX','406315DAXwIw','application','42lCsdPV','writeFileSync','【Error】:\x20当前目录不存在src子目录,无法完成pull操作。','unlinkSync','toString','error','393OVIeEt','/repository/archive.zip?private_token=','【Error】:\x20未获取到项目\x20','common\x5cdva\x5cautomatic','/api/v4/projects/','999fOANcM','\x5ccommon\x5cdva\x5cautomatic\x5crouter.js','return\x20process.env;','compressing'];a20_0x3053=function(){return _0x5abd13;};return a20_0x3053();}const a20_0x3d68c3=a20_0x1faf;function a20_0x1faf(_0x4ad2ca,_0x37e544){const _0x30532d=a20_0x3053();return a20_0x1faf=function(_0x1faf06,_0x5a8d61){_0x1faf06=_0x1faf06-0x121;let _0x2c0bab=_0x30532d[_0x1faf06];return _0x2c0bab;},a20_0x1faf(_0x4ad2ca,_0x37e544);}(function(_0x40f634,_0x6cc8fd){const _0x362aa4=a20_0x1faf,_0x9a1303=_0x40f634();while(!![]){try{const _0x348b64=-parseInt(_0x362aa4(0x159))/0x1+-parseInt(_0x362aa4(0x14c))/0x2*(-parseInt(_0x362aa4(0x136))/0x3)+parseInt(_0x362aa4(0x12d))/0x4+-parseInt(_0x362aa4(0x12e))/0x5+-parseInt(_0x362aa4(0x130))/0x6*(parseInt(_0x362aa4(0x143))/0x7)+parseInt(_0x362aa4(0x124))/0x8*(parseInt(_0x362aa4(0x13b))/0x9)+-parseInt(_0x362aa4(0x15b))/0xa*(-parseInt(_0x362aa4(0x156))/0xb);if(_0x348b64===_0x6cc8fd)break;else _0x9a1303['push'](_0x9a1303['shift']());}catch(_0x3d4c72){_0x9a1303['push'](_0x9a1303['shift']());}}}(a20_0x3053,0xa073f));const fs=require('fs'),os=require('os'),path=require(a20_0x3d68c3(0x147)),utils=require(a20_0x3d68c3(0x15c)),request=require(a20_0x3d68c3(0x126)),compressing=require(a20_0x3d68c3(0x13e)),GIT_TEMP_DIR='jjbAssembly',GIT_HOST=a20_0x3d68c3(0x154),CLOUD_PROJECT={'common':{'token':a20_0x3d68c3(0x14a),'projectId':0x117,'localName':a20_0x3d68c3(0x13f)},'react-admin-component':{'token':'FT3pKzxpRynFkmddJ9Bs','projectId':0x154,'localName':a20_0x3d68c3(0x123)}};module[a20_0x3d68c3(0x121)]=_0x8cc6ca=>{const _0x2b9678=a20_0x3d68c3,_0x1eb2cb=_0x8cc6ca,_0x12b7f0=path[_0x2b9678(0x146)]('./');try{if(fs[_0x2b9678(0x150)](_0x12b7f0+_0x2b9678(0x157))){const _0x271f64=_0x12b7f0+_0x2b9678(0x157),_0x391a27=CLOUD_PROJECT[_0x1eb2cb]||undefined;if(_0x391a27){const _0x21e9ea=os['tmpdir'](),_0xd5d5a2=_0x21e9ea+('/'+GIT_TEMP_DIR+'/'+_0x1eb2cb+'.zip'),_0x4357bc=_0x21e9ea+'/'+GIT_TEMP_DIR+_0x2b9678(0x125);utils[_0x2b9678(0x127)](_0x21e9ea+'/'+GIT_TEMP_DIR,()=>{const _0x31952c=_0x2b9678;fs['mkdirSync'](_0x21e9ea+'/'+GIT_TEMP_DIR);let _0x27e072=fs[_0x31952c(0x122)](_0xd5d5a2);request(GIT_HOST+_0x31952c(0x13a)+_0x391a27[_0x31952c(0x152)]+_0x31952c(0x137)+_0x391a27[_0x31952c(0x142)]+_0x31952c(0x149))[_0x31952c(0x158)](_0x27e072)['on'](_0x31952c(0x141),()=>{const _0x463494=_0x31952c;fs['mkdirSync'](_0x4357bc),compressing['zip']['uncompress'](_0xd5d5a2,_0x4357bc)[_0x463494(0x148)](()=>{setTimeout(()=>{const _0x20ca46=a20_0x1faf,_0x189d75=fs['readdirSync'](_0x4357bc);_0x189d75['forEach'](_0x216e43=>{const _0x200999=a20_0x1faf;if(_0x216e43['indexOf'](_0x200999(0x14f))!==-0x1){const _0x1c76b3=_0x271f64+'\x5c'+_0x391a27['localName'];utils[_0x200999(0x127)](_0x1c76b3,()=>{const _0x963a1a=_0x200999;fs[_0x963a1a(0x155)](_0x1c76b3),utils[_0x963a1a(0x14e)](_0x4357bc+_0x216e43,_0x1c76b3),setTimeout(()=>{const _0x4f1764=_0x963a1a,_0x48baf3=fs[_0x4f1764(0x129)](_0x271f64+'\x5c'+_0x4f1764(0x12f));if(!_0x48baf3){const _0x21cfbf=_0x271f64+'\x5c'+'common\x5ctools\x5cindex.js',_0x139022=_0x271f64+'\x5c'+_0x4f1764(0x144);let _0x4646ac=fs[_0x4f1764(0x12a)](_0x21cfbf)[_0x4f1764(0x134)](),_0x3c425f=fs[_0x4f1764(0x12a)](_0x139022)[_0x4f1764(0x134)]();_0x4646ac=_0x4646ac[_0x4f1764(0x151)](_0x4f1764(0x14b),_0x4f1764(0x13d)),_0x3c425f=_0x3c425f[_0x4f1764(0x151)](/const\srelation\s=\srequire\(`~\/application\/\${module.code}\/enumerate\/menu`\)\.default;/,'const\x20relation\x20=\x20require(\x27~/enumerate/menu\x27).default;'),fs['writeFileSync'](_0x21cfbf,_0x4646ac),fs[_0x4f1764(0x131)](_0x139022,_0x3c425f),fs[_0x4f1764(0x131)](_0x271f64+_0x4f1764(0x13c),fs[_0x4f1764(0x12a)](__dirname+'\x5ccli.dva.router.spa.txt')[_0x4f1764(0x134)]()),fs['writeFileSync'](_0x271f64+_0x4f1764(0x140),fs[_0x4f1764(0x12a)](__dirname+'\x5ccli.dva.register.spa.txt')[_0x4f1764(0x134)]());}else fs[_0x4f1764(0x145)](_0x271f64+'\x5c'+_0x4f1764(0x12b),_0xcac96e=>{const _0x3bbf35=_0x4f1764;_0xcac96e&&(fs[_0x3bbf35(0x14d)](_0x271f64+'\x5c'+_0x3bbf35(0x139))[_0x3bbf35(0x128)](_0x2de6b=>{const _0x1307de=_0x3bbf35;fs[_0x1307de(0x133)](_0x271f64+'\x5c'+'common\x5cdva\x5cautomatic\x5c'+_0x2de6b);}),fs[_0x3bbf35(0x153)](_0x271f64+'\x5c'+_0x3bbf35(0x139)));});},0x3e8);});}}),console[_0x20ca46(0x15a)](_0x1eb2cb+_0x20ca46(0x12c));},0x7d0);});});});}else console[_0x2b9678(0x135)](_0x2b9678(0x138)+_0x1eb2cb);}}catch(_0x20959d){console['error'](_0x2b9678(0x132));}};
|