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.
@@ -1,230 +1 @@
1
- const fs = require('fs');
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_0x3d47ab=a18_0x4aba;function a18_0x3b2a(){const _0x7f3a8e=['filter','\x5cpackage.json','f_resolve_install_resources','includes','path','projectId','node_modules','installTarget','readdirSync','readFileSync','\x22,\x22main\x22:\x20\x22index.js\x22}','13577265DUPbZA','218230RWYZER','exit','f_rm_rf','tmpdir','jjb-common-decorator','src','【Error】:[jjb.config.json.node_modules]配置无效,有效值<node_modules\x20|\x20src>。','【Error】:[jjb.config.json]文件配置无效,需要installTarget属性。','f_file_copy','【Error】:[jjb.config.json.installResources]类型是一个Array<string>。','【Error】:[jjb.config.json.projectType]配置无效,有效值<multi\x20|\x20spa\x20|\x20micro-spa\x20|\x20uniapp>。','react-admin-component','existsSync','token','f_scan_jjb_config_json','{\x22name\x22:\x22','uniapp','length','.zip','projectType','writeFileSync','【Error】:[jjb.config.json]文件配置无效,需要projectType属性。','4620360IZJNXU','spa','\x22,\x22version\x22:\x22','rmdirSync','mkdirSync','toString','push','22eXDkhZ','25044dLDtjI','jjb-common','【Error】:[jjb.config.json.installResources]无资源。','4ldrwtX','string','_zip','【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>。','5OwgHBd','replace','4640886vFwArS','【Error】:[jjb.config.json]文件解析失败,请确认是否配置正确。','41OvRoJi','parse','【Error】:[jjb.config.json.projectType]类型是一个string。','log','1393452IFxszQ','name','jjb-dva-runtime','jjb-common-lib','installResources','isArray','statSync','isDirectory','f_update_project_package_json','4141452rvjOou','f_content_replace','stringify','vue-unisass-component','\x5cjjb.config.json','/api/v4/projects/','forEach','multi'];a18_0x3b2a=function(){return _0x7f3a8e;};return a18_0x3b2a();}function a18_0x4aba(_0x1e7c34,_0xadbcd7){const _0x3b2ad8=a18_0x3b2a();return a18_0x4aba=function(_0x4aba55,_0x363d2c){_0x4aba55=_0x4aba55-0x1e3;let _0x130d0d=_0x3b2ad8[_0x4aba55];return _0x130d0d;},a18_0x4aba(_0x1e7c34,_0xadbcd7);}(function(_0x1a10a4,_0x56aa9d){const _0x4ba244=a18_0x4aba,_0x4c4dd3=_0x1a10a4();while(!![]){try{const _0x51a8cb=-parseInt(_0x4ba244(0x1e7))/0x1*(parseInt(_0x4ba244(0x226))/0x2)+-parseInt(_0x4ba244(0x1eb))/0x3*(parseInt(_0x4ba244(0x229))/0x4)+parseInt(_0x4ba244(0x1e3))/0x5*(-parseInt(_0x4ba244(0x1e5))/0x6)+parseInt(_0x4ba244(0x1f4))/0x7+parseInt(_0x4ba244(0x21e))/0x8+parseInt(_0x4ba244(0x207))/0x9+parseInt(_0x4ba244(0x208))/0xa*(parseInt(_0x4ba244(0x225))/0xb);if(_0x51a8cb===_0x56aa9d)break;else _0x4c4dd3['push'](_0x4c4dd3['shift']());}catch(_0xdb4bae){_0x4c4dd3['push'](_0x4c4dd3['shift']());}}}(a18_0x3b2a,0xecd3d));const fs=require('fs'),os=require('os'),{GIT_HOST,GIT_TEMP_DIR,CLOUD_PROJECT}=require('./config');exports['f_rm_rf']=function(_0x271354){const _0x4ca93a=a18_0x4aba;if(fs['existsSync'](_0x271354)){const _0x170e39=fs[_0x4ca93a(0x204)](_0x271354);for(let _0x2f2a2c=0x0;_0x2f2a2c<_0x170e39['length'];_0x2f2a2c++){const _0x2c7413=_0x170e39[_0x2f2a2c],_0x2a603a=_0x271354+'/'+_0x2c7413;fs['statSync'](_0x2a603a)[_0x4ca93a(0x1f2)]()?(exports[_0x4ca93a(0x20a)](_0x2a603a),fs[_0x4ca93a(0x221)](_0x2a603a)):fs['unlinkSync'](_0x2a603a);}}},exports['f_pull_git_repository']=function(_0x4b0a8d=[]){return _0x4b0a8d['map'](_0x387ba7=>{const _0x3ec55c=a18_0x4aba,_0x121b20=CLOUD_PROJECT[_0x387ba7['name']]||undefined,_0xfc6a4b=os[_0x3ec55c(0x20b)]();return{'path':_0xfc6a4b+'\x5c'+GIT_TEMP_DIR+'\x5c'+_0x387ba7[_0x3ec55c(0x1ec)]+_0x3ec55c(0x21a),'compress':_0xfc6a4b+'\x5c'+GIT_TEMP_DIR+'\x5c'+_0x387ba7[_0x3ec55c(0x1ec)]+_0x3ec55c(0x22b),'repository':GIT_HOST+_0x3ec55c(0x1f9)+_0x121b20[_0x3ec55c(0x201)]+'/repository/archive.zip?private_token='+_0x121b20[_0x3ec55c(0x215)]+'&ref=master'};});},exports[a18_0x3d47ab(0x216)]=function(_0x53caae){const _0xf20e95=a18_0x3d47ab;return fs[_0xf20e95(0x214)](_0x53caae+_0xf20e95(0x1f8));},exports['f_scan_jjb_config_json_rules']=function(_0x44ea99){const _0x2c275d=a18_0x3d47ab;let _0x463a5a={};try{_0x463a5a=JSON[_0x2c275d(0x1e8)](fs['readFileSync'](_0x44ea99+_0x2c275d(0x1f8))['toString']());}catch(_0x78fa84){console[_0x2c275d(0x1ea)](_0x2c275d(0x1e6)),process[_0x2c275d(0x209)](0x0);}!(_0x2c275d(0x21b)in _0x463a5a)&&(console[_0x2c275d(0x1ea)](_0x2c275d(0x21d)),process[_0x2c275d(0x209)](0x0));!(_0x2c275d(0x203)in _0x463a5a)&&(console['log'](_0x2c275d(0x20f)),process[_0x2c275d(0x209)](0x0));!('installResources'in _0x463a5a)&&(console[_0x2c275d(0x1ea)]('【Error】:[jjb.config.json]文件配置无效,需要installResources属性。'),process['exit'](0x0));typeof _0x463a5a[_0x2c275d(0x21b)]!=='string'&&(console[_0x2c275d(0x1ea)](_0x2c275d(0x1e9)),process['exit'](0x0));![_0x2c275d(0x1fb),_0x2c275d(0x21f),_0x2c275d(0x218),'micro-spa'][_0x2c275d(0x1ff)](_0x463a5a['projectType'])&&(console[_0x2c275d(0x1ea)](_0x2c275d(0x212)),process[_0x2c275d(0x209)](0x0));typeof _0x463a5a[_0x2c275d(0x203)]!==_0x2c275d(0x22a)&&(console['log']('【Error】:[jjb.config.json.installTarget]类型是一个string。'),process[_0x2c275d(0x209)](0x0));![_0x2c275d(0x202),_0x2c275d(0x20d)]['includes'](_0x463a5a[_0x2c275d(0x203)])&&(console['log'](_0x2c275d(0x20e)),process[_0x2c275d(0x209)](0x0));!Array[_0x2c275d(0x1f0)](_0x463a5a[_0x2c275d(0x1ef)])&&(console[_0x2c275d(0x1ea)](_0x2c275d(0x211)),process['exit'](0x0));_0x463a5a[_0x2c275d(0x1ef)][_0x2c275d(0x219)]===0x0&&(console['log'](_0x2c275d(0x228)),process[_0x2c275d(0x209)](0x0));const _0x312b85=exports[_0x2c275d(0x1fe)](_0x463a5a[_0x2c275d(0x1ef)]);return _0x312b85['map'](_0x259dea=>_0x259dea['name'])[_0x2c275d(0x1fc)](_0x29e5cf=>![_0x2c275d(0x227),_0x2c275d(0x1ed),_0x2c275d(0x1ee),_0x2c275d(0x20c),_0x2c275d(0x213),_0x2c275d(0x1f7)]['includes'](_0x29e5cf))[_0x2c275d(0x219)]!==0x0&&(console[_0x2c275d(0x1ea)](_0x2c275d(0x22c)),process[_0x2c275d(0x209)](0x0)),_0x463a5a[_0x2c275d(0x1ef)]=_0x312b85,_0x463a5a;},exports['f_create_package_json']=function(_0x3a9ec8,_0x567d69,_0x42d897){const _0x2f2c78=a18_0x3d47ab;fs[_0x2f2c78(0x21c)](_0x3a9ec8+_0x2f2c78(0x1fd),_0x2f2c78(0x217)+_0x567d69+_0x2f2c78(0x220)+_0x42d897+_0x2f2c78(0x206));},exports[a18_0x3d47ab(0x1fe)]=function(_0x1c93f3=[]){const _0x4fba04=a18_0x3d47ab,_0x34662b=[];return Array[_0x4fba04(0x1f0)](_0x1c93f3)&&_0x1c93f3['forEach'](_0x1f5e2b=>{const _0xb94748=_0x4fba04;if(Array['isArray'](_0x1f5e2b)){const [_0x3630bd,_0x515e71=[]]=_0x1f5e2b;_0x34662b[_0xb94748(0x224)]({'name':_0x3630bd,'importList':_0x515e71});}else _0x34662b[_0xb94748(0x224)]({'name':_0x1f5e2b,'importList':[]});}),_0x34662b;},exports[a18_0x3d47ab(0x1f3)]=function(_0x3218f9,_0x5ec6e4,_0x2fc387){const _0x272e54=a18_0x3d47ab,_0x306e00=JSON['parse'](fs[_0x272e54(0x205)](_0x3218f9)[_0x272e54(0x223)]());_0x306e00['dependencies'][_0x5ec6e4]=_0x2fc387,fs[_0x272e54(0x21c)](_0x3218f9,JSON[_0x272e54(0x1f6)](_0x306e00,null,0x2));},exports[a18_0x3d47ab(0x210)]=function(_0x53cca6,_0x583fc4){const _0x3394f5=a18_0x3d47ab;fs['readdirSync'](_0x53cca6)[_0x3394f5(0x1fa)](_0x48bd1f=>{const _0x1cb583=_0x3394f5,_0x3b5d5a=_0x53cca6+'\x5c'+_0x48bd1f,_0x59f8ee=_0x583fc4+'\x5c'+_0x48bd1f;fs[_0x1cb583(0x1f1)](_0x3b5d5a)[_0x1cb583(0x1f2)]()?(fs[_0x1cb583(0x222)](_0x59f8ee),exports[_0x1cb583(0x210)](_0x3b5d5a,_0x59f8ee)):fs['writeFileSync'](_0x59f8ee,fs['readFileSync'](_0x3b5d5a)[_0x1cb583(0x223)]());});},exports[a18_0x3d47ab(0x1f5)]=function(_0x1cc4fd=[],_0x357495){_0x1cc4fd['forEach'](_0x84e92e=>{const _0x5e8639=a18_0x4aba,_0x2e8a25=_0x357495+_0x84e92e[_0x5e8639(0x200)];if(fs['existsSync'](_0x2e8a25)){let _0x16fd89=fs['readFileSync'](_0x2e8a25)[_0x5e8639(0x223)]();_0x84e92e[_0x5e8639(0x1e4)][_0x5e8639(0x1fa)](_0x5f173b=>{const _0x1c6acc=_0x5e8639;_0x16fd89=_0x16fd89[_0x1c6acc(0x1e4)](_0x5f173b[0x0],_0x5f173b[0x1]);}),fs[_0x5e8639(0x21c)](_0x2e8a25,_0x16fd89);}});};
@@ -1,80 +1 @@
1
- const fs = require('fs');
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
+ const a19_0x4b924b=a19_0x417e;(function(_0xcfaa91,_0x480861){const _0x3268bc=a19_0x417e,_0x39e90f=_0xcfaa91();while(!![]){try{const _0x275967=parseInt(_0x3268bc(0x7b))/0x1+-parseInt(_0x3268bc(0x9d))/0x2*(-parseInt(_0x3268bc(0x89))/0x3)+-parseInt(_0x3268bc(0x95))/0x4*(parseInt(_0x3268bc(0x8a))/0x5)+parseInt(_0x3268bc(0x88))/0x6*(-parseInt(_0x3268bc(0x9a))/0x7)+-parseInt(_0x3268bc(0x9e))/0x8+-parseInt(_0x3268bc(0x90))/0x9+-parseInt(_0x3268bc(0x83))/0xa*(-parseInt(_0x3268bc(0x91))/0xb);if(_0x275967===_0x480861)break;else _0x39e90f['push'](_0x39e90f['shift']());}catch(_0x165e1d){_0x39e90f['push'](_0x39e90f['shift']());}}}(a19_0x3b8c,0x74f3b));const fs=require('fs'),path=require(a19_0x4b924b(0x80)),utils=require('./util.js');function a19_0x417e(_0xebd7b3,_0x3b3f91){const _0x3b8cc2=a19_0x3b8c();return a19_0x417e=function(_0x417e97,_0x59adc8){_0x417e97=_0x417e97-0x7a;let _0xa5090f=_0x3b8cc2[_0x417e97];return _0xa5090f;},a19_0x417e(_0xebd7b3,_0x3b3f91);}let projectPath='',vesselPath='',commandArr=[];function a19_0x3b8c(){const _0x389fa9=['26pczulL','5757176EFaRTo','region','resolve','routerConfig','application','955560kkFByQ','length','pathAdr','push','then','path','\x27,\x20component:\x20()\x20=>\x20import(\x27','file','6678150XJNOJu','{\x20path:\x20\x27','slice','items','/application','3464124acMOOA','86271WMIDvu','100qmzBuY','toString','CreatePaths','./project','concat','./vessel/src','7299990hGuuHJ','33zptbTW','fileType','DeepScanner','split','149140ApkgiD','from','readFileSync','parse','routerPath','7QaAabb','router','forEach'];a19_0x3b8c=function(){return _0x389fa9;};return a19_0x3b8c();}const fromFileData={},applicationJson={};module['exports']=(_0x1bef7c,_0x76dda3)=>{const _0x35350c=a19_0x4b924b;commandArr=_0x1bef7c[_0x35350c(0x94)](':'),projectPath=path[_0x35350c(0xa0)](_0x35350c(0x8d)),vesselPath=path['resolve'](_0x35350c(0x8f));let _0x3a5dfe=vesselPath;_0x76dda3==='mp'&&(_0x3a5dfe=vesselPath+_0x35350c(0x87),utils[_0x35350c(0x8c)](vesselPath,[_0x35350c(0x7a)]));const _0x17f8cb=commandArr[0x1],_0x47e4b9=JSON[_0x35350c(0x98)](fs[_0x35350c(0x97)](projectPath+'/'+_0x17f8cb+'/setting.json')[_0x35350c(0x8b)]());TileItems(_0x47e4b9[_0x35350c(0x86)],()=>{const _0x24b738=_0x35350c;fromFileData[_0x24b738(0x9b)][_0x24b738(0x9c)](_0x29b02e=>{const _0x2c3c93=_0x24b738,_0x90b9ae=_0x29b02e['pathAdr'][_0x2c3c93(0x94)](_0x29b02e[_0x2c3c93(0x9f)]),_0x191dd6=_0x90b9ae[0x1]['split']('/'),_0x23704e=_0x191dd6[0x1];!applicationJson[_0x23704e]&&(applicationJson[_0x23704e]={'routerConfig':[],'routerPath':[]});applicationJson[_0x23704e][_0x2c3c93(0xa1)][_0x2c3c93(0x7e)](_0x2c3c93(0x84)+_0x29b02e[_0x2c3c93(0x80)]+_0x2c3c93(0x81)+_0x29b02e[_0x2c3c93(0x82)]+'\x27)\x20}'),applicationJson[_0x23704e][_0x2c3c93(0x99)][_0x2c3c93(0x7e)](_0x29b02e['path']);let _0x238098=_0x191dd6['join']('/');const _0x5878c9=_0x238098[_0x2c3c93(0x94)]('/');utils['CreatePaths'](_0x3a5dfe,_0x5878c9[_0x2c3c93(0x85)](0x0,_0x5878c9[_0x2c3c93(0x7c)]-0x1))[_0x2c3c93(0x7f)](()=>{const _0x6d0517=_0x2c3c93,_0x42eb3b=fs[_0x6d0517(0x97)](_0x29b02e[_0x6d0517(0x7d)])[_0x6d0517(0x8b)]();fs['writeFileSync'](vesselPath+'/'+_0x238098,_0x42eb3b);});});});};function TileItems(_0x448933,_0x24b55b){const _0x3f49bd=a19_0x4b924b;_0x448933[_0x3f49bd(0x9c)]((_0x909fdc,_0x44496b)=>{const _0x39031f=_0x3f49bd,_0x4ecdd9=_0x909fdc['region'];_0x909fdc[_0x39031f(0x96)][_0x39031f(0x9c)]((_0x1bd5a1,_0x21359a)=>{const _0x303be2=_0x39031f,_0x367a55=[];utils[_0x303be2(0x93)](projectPath+'/'+_0x4ecdd9+'/'+_0x1bd5a1[_0x303be2(0x82)],_0x367a55);const _0x10ad9a=_0x367a55['map'](_0x513c6b=>({'region':_0x4ecdd9,'pathAdr':_0x513c6b,..._0x1bd5a1}));!fromFileData[_0x1bd5a1[_0x303be2(0x92)]]?fromFileData[_0x1bd5a1['fileType']]=_0x10ad9a:fromFileData[_0x1bd5a1[_0x303be2(0x92)]]=fromFileData[_0x1bd5a1[_0x303be2(0x92)]][_0x303be2(0x8e)](_0x10ad9a),_0x44496b===_0x448933[_0x303be2(0x7c)]-0x1&&_0x21359a===_0x909fdc[_0x303be2(0x96)][_0x303be2(0x7c)]-0x1&&_0x24b55b();});});}
@@ -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';const a20_0x13694e=a20_0x4b0e;(function(_0x3fd4eb,_0x32d6e9){const _0x39ad2e=a20_0x4b0e,_0x543783=_0x3fd4eb();while(!![]){try{const _0x400d49=-parseInt(_0x39ad2e(0x1e5))/0x1+parseInt(_0x39ad2e(0x1d0))/0x2*(parseInt(_0x39ad2e(0x1cc))/0x3)+-parseInt(_0x39ad2e(0x1da))/0x4+parseInt(_0x39ad2e(0x1be))/0x5+-parseInt(_0x39ad2e(0x1c6))/0x6+-parseInt(_0x39ad2e(0x1ba))/0x7+-parseInt(_0x39ad2e(0x1d4))/0x8*(-parseInt(_0x39ad2e(0x1e4))/0x9);if(_0x400d49===_0x32d6e9)break;else _0x543783['push'](_0x543783['shift']());}catch(_0x3376bf){_0x543783['push'](_0x543783['shift']());}}}(a20_0x40a2,0x7491c));function a20_0x4b0e(_0x56511c,_0xde3a6d){const _0x40a23e=a20_0x40a2();return a20_0x4b0e=function(_0x4b0eba,_0x12add8){_0x4b0eba=_0x4b0eba-0x1b4;let _0x3bed40=_0x40a23e[_0x4b0eba];return _0x3bed40;},a20_0x4b0e(_0x56511c,_0xde3a6d);}const fs=require('fs'),os=require('os'),path=require(a20_0x13694e(0x1d8)),utils=require(a20_0x13694e(0x1e7)),request=require(a20_0x13694e(0x1c7)),compressing=require('compressing'),GIT_TEMP_DIR=a20_0x13694e(0x1ca),GIT_HOST=a20_0x13694e(0x1d6),CLOUD_PROJECT={'common':{'token':a20_0x13694e(0x1db),'projectId':0x117,'localName':a20_0x13694e(0x1d2)},'react-admin-component':{'token':a20_0x13694e(0x1b8),'projectId':0x154,'localName':'components'}};function a20_0x40a2(){const _0x2e69cc=['log','common\x5cwebsite\x5cindex.js','jjbAssembly','DeleteDirAllFile','18gFkbZt','projectId','toString','then','180062vXLalv','-master-','common','unlinkSync','96dErLKI','&ref=master','http://192.168.1.242:10985','readFileSync','path','【Error】:\x20当前目录不存在src子目录,无法完成pull操作。','1152352YUtIoj','G4HJRsHr9D7Ssmixegw2','createWriteStream','common\x5cdva\x5cautomatic\x5c','【Error】:\x20未获取到项目\x20','\x5csrc','\x5ccli.dva.router.spa.txt','forEach','writeFileSync','const\x20relation\x20=\x20require(\x27~/enumerate/menu\x27).default;','358011OQJvya','45965cMNbKd','pipe','./util','resolve','/repository/archive.zip?private_token=','close','return\x20process.env;','rmdirSync','tmpdir','\x5ccommon\x5cdva\x5cautomatic\x5cregister.js','token','statSync','mkdirSync','FT3pKzxpRynFkmddJ9Bs','readdirSync','272041DTTzdd','error','localName','exports','11210okVCUy','-文件下载完毕','common\x5cdva\x5cautomatic','\x5ccommon\x5cdva\x5cautomatic\x5crouter.js','existsSync','indexOf','uncompress','exists','1016352xJYZHJ','request'];a20_0x40a2=function(){return _0x2e69cc;};return a20_0x40a2();}module[a20_0x13694e(0x1bd)]=_0x5c1f86=>{const _0x2728a7=a20_0x13694e,_0x5eadb6=_0x5c1f86,_0x5758dd=path[_0x2728a7(0x1e8)]('./');try{if(fs[_0x2728a7(0x1b6)](_0x5758dd+_0x2728a7(0x1df))){const _0x5add3f=_0x5758dd+_0x2728a7(0x1df),_0x123e9c=CLOUD_PROJECT[_0x5eadb6]||undefined;if(_0x123e9c){const _0x1c512a=os[_0x2728a7(0x1ed)](),_0x2f9299=_0x1c512a+('/'+GIT_TEMP_DIR+'/'+_0x5eadb6+'.zip'),_0x5f581f=_0x1c512a+'/'+GIT_TEMP_DIR+'/unzip/';utils[_0x2728a7(0x1cb)](_0x1c512a+'/'+GIT_TEMP_DIR,()=>{const _0x1c01b1=_0x2728a7;fs[_0x1c01b1(0x1b7)](_0x1c512a+'/'+GIT_TEMP_DIR);let _0x35752f=fs[_0x1c01b1(0x1dc)](_0x2f9299);request(GIT_HOST+'/api/v4/projects/'+_0x123e9c[_0x1c01b1(0x1cd)]+_0x1c01b1(0x1e9)+_0x123e9c[_0x1c01b1(0x1b5)]+_0x1c01b1(0x1d5))[_0x1c01b1(0x1e6)](_0x35752f)['on'](_0x1c01b1(0x1ea),()=>{const _0xcfb729=_0x1c01b1;fs[_0xcfb729(0x1b7)](_0x5f581f),compressing['zip'][_0xcfb729(0x1c4)](_0x2f9299,_0x5f581f)[_0xcfb729(0x1cf)](()=>{setTimeout(()=>{const _0x26e101=a20_0x4b0e,_0x3c386f=fs[_0x26e101(0x1b9)](_0x5f581f);_0x3c386f['forEach'](_0xea7c18=>{const _0x2da574=_0x26e101;if(_0xea7c18[_0x2da574(0x1c3)](_0x2da574(0x1d1))!==-0x1){const _0x5a6247=_0x5add3f+'\x5c'+_0x123e9c[_0x2da574(0x1bc)];utils[_0x2da574(0x1cb)](_0x5a6247,()=>{const _0x5d3299=_0x2da574;fs[_0x5d3299(0x1b7)](_0x5a6247),utils['CopyFolder'](_0x5f581f+_0xea7c18,_0x5a6247),setTimeout(()=>{const _0x315523=_0x5d3299,_0xf42a25=fs[_0x315523(0x1c2)](_0x5add3f+'\x5c'+'application');if(!_0xf42a25){const _0x176f99=_0x5add3f+'\x5c'+'common\x5ctools\x5cindex.js',_0x5cd109=_0x5add3f+'\x5c'+_0x315523(0x1c9);let _0x39da92=fs[_0x315523(0x1d7)](_0x176f99)[_0x315523(0x1ce)](),_0x4f5468=fs['readFileSync'](_0x5cd109)[_0x315523(0x1ce)]();_0x39da92=_0x39da92['replace']('return\x20__planA();',_0x315523(0x1eb)),_0x4f5468=_0x4f5468['replace'](/const\srelation\s=\srequire\(`~\/application\/\${module.code}\/enumerate\/menu`\)\.default;/,_0x315523(0x1e3)),fs['writeFileSync'](_0x176f99,_0x39da92),fs[_0x315523(0x1e2)](_0x5cd109,_0x4f5468),fs[_0x315523(0x1e2)](_0x5add3f+_0x315523(0x1c1),fs[_0x315523(0x1d7)](__dirname+_0x315523(0x1e0))[_0x315523(0x1ce)]()),fs[_0x315523(0x1e2)](_0x5add3f+_0x315523(0x1b4),fs[_0x315523(0x1d7)](__dirname+'\x5ccli.dva.register.spa.txt')['toString']());}else fs[_0x315523(0x1c5)](_0x5add3f+'\x5c'+'common\x5cdva\x5cautomatic\x5cindex.js',_0x1ca80f=>{const _0x35bf1e=_0x315523;_0x1ca80f&&(fs[_0x35bf1e(0x1b9)](_0x5add3f+'\x5c'+'common\x5cdva\x5cautomatic')[_0x35bf1e(0x1e1)](_0x4fbac2=>{const _0x598f58=_0x35bf1e;fs[_0x598f58(0x1d3)](_0x5add3f+'\x5c'+_0x598f58(0x1dd)+_0x4fbac2);}),fs[_0x35bf1e(0x1ec)](_0x5add3f+'\x5c'+_0x35bf1e(0x1c0)));});},0x3e8);});}}),console[_0x26e101(0x1c8)](_0x5eadb6+_0x26e101(0x1bf));},0x7d0);});});});}else console[_0x2728a7(0x1bb)](_0x2728a7(0x1de)+_0x5eadb6);}}catch(_0x525b79){console[_0x2728a7(0x1bb)](_0x2728a7(0x1d9));}};