jjb-cmd 2.2.2 → 2.2.3

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 +1,230 @@
1
- function a4_0x4ee3(_0x11bb78,_0x1b00c9){const _0x12264d=a4_0x1226();return a4_0x4ee3=function(_0x4ee38c,_0xe9ce13){_0x4ee38c=_0x4ee38c-0x12d;let _0x241c8a=_0x12264d[_0x4ee38c];return _0x241c8a;},a4_0x4ee3(_0x11bb78,_0x1b00c9);}const a4_0x1909c9=a4_0x4ee3;function a4_0x1226(){const _0x5e29c8=['length','dependencies','exit','name','6gjaOvI','{\x22name\x22:\x22','/repository/archive.zip?private_token=','jjb-common-lib','4145685mITfGK','existsSync','token','forEach','writeFileSync','parse','【Error】:[jjb.config.json.projectType]类型是一个string。','rmdirSync','f_resolve_install_resources','f_rm_rf','installTarget','15579585CXHOLF','21Taxpqg','.zip','996828vaStrp','【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>。','path','\x22,\x22main\x22:\x20\x22index.js\x22}','mkdirSync','f_update_project_package_json','\x22,\x22version\x22:\x22','60653oRoysw','string','projectType','isDirectory','multi','86370WcQxdq','f_scan_jjb_config_json_rules','&ref=master','includes','【Error】:[jjb.config.json]文件配置无效,需要installTarget属性。','_zip','jjb-common','spa','/api/v4/projects/','projectId','micro-spa','2465520tjqfKK','\x5cjjb.config.json','installResources','jjb-common-decorator','【Error】:[jjb.config.json.installResources]无资源。','f_pull_git_repository','toString','src','【Error】:[jjb.config.json.installTarget]类型是一个string。','f_scan_jjb_config_json','f_file_copy','node_modules','【Error】:[jjb.config.json.installResources]类型是一个Array<string>。','【Error】:[jjb.config.json.node_modules]配置无效,有效值<node_modules\x20|\x20src>。','push','【Error】:[jjb.config.json]文件配置无效,需要installResources属性。','stringify','uniapp','f_create_package_json','isArray','readdirSync','statSync','554517gqIFYP','\x5cpackage.json','replace','【Error】:[jjb.config.json]文件配置无效,需要projectType属性。','log','【Error】:[jjb.config.json]文件解析失败,请确认是否配置正确。','f_content_replace','map','readFileSync'];a4_0x1226=function(){return _0x5e29c8;};return a4_0x1226();}(function(_0x2290ad,_0x2867e5){const _0x4ab8b5=a4_0x4ee3,_0x29053d=_0x2290ad();while(!![]){try{const _0xfe4ba6=parseInt(_0x4ab8b5(0x16b))/0x1+parseInt(_0x4ab8b5(0x152))/0x2*(-parseInt(_0x4ab8b5(0x145))/0x3)+-parseInt(_0x4ab8b5(0x164))/0x4+-parseInt(_0x4ab8b5(0x156))/0x5+-parseInt(_0x4ab8b5(0x170))/0x6*(parseInt(_0x4ab8b5(0x162))/0x7)+parseInt(_0x4ab8b5(0x12f))/0x8+parseInt(_0x4ab8b5(0x161))/0x9;if(_0xfe4ba6===_0x2867e5)break;else _0x29053d['push'](_0x29053d['shift']());}catch(_0x496233){_0x29053d['push'](_0x29053d['shift']());}}}(a4_0x1226,0x677b6));const fs=require('fs'),os=require('os'),{GIT_HOST,GIT_TEMP_DIR,CLOUD_PROJECT}=require('./config');exports[a4_0x1909c9(0x15f)]=function(_0x3f23c9){const _0x2369ce=a4_0x1909c9;if(fs['existsSync'](_0x3f23c9)){const _0x123996=fs[_0x2369ce(0x143)](_0x3f23c9);for(let _0x43c0e2=0x0;_0x43c0e2<_0x123996['length'];_0x43c0e2++){const _0x727488=_0x123996[_0x43c0e2],_0x20b428=_0x3f23c9+'/'+_0x727488;fs[_0x2369ce(0x144)](_0x20b428)[_0x2369ce(0x16e)]()?(exports['f_rm_rf'](_0x20b428),fs[_0x2369ce(0x15d)](_0x20b428)):fs['unlinkSync'](_0x20b428);}}},exports[a4_0x1909c9(0x134)]=function(_0x432673=[]){const _0x128e39=a4_0x1909c9;return _0x432673[_0x128e39(0x14c)](_0x86b578=>{const _0x43bc7c=_0x128e39,_0x5a1f1e=CLOUD_PROJECT[_0x86b578[_0x43bc7c(0x151)]]||undefined,_0x1dd5fb=os['tmpdir']();return{'path':_0x1dd5fb+'\x5c'+GIT_TEMP_DIR+'\x5c'+_0x86b578[_0x43bc7c(0x151)]+_0x43bc7c(0x163),'compress':_0x1dd5fb+'\x5c'+GIT_TEMP_DIR+'\x5c'+_0x86b578[_0x43bc7c(0x151)]+_0x43bc7c(0x175),'repository':GIT_HOST+_0x43bc7c(0x178)+_0x5a1f1e[_0x43bc7c(0x12d)]+_0x43bc7c(0x154)+_0x5a1f1e[_0x43bc7c(0x158)]+_0x43bc7c(0x172)};});},exports[a4_0x1909c9(0x138)]=function(_0x1f81ed){const _0x12614a=a4_0x1909c9;return fs[_0x12614a(0x157)](_0x1f81ed+_0x12614a(0x130));},exports[a4_0x1909c9(0x171)]=function(_0x49a91b){const _0x6c0ea5=a4_0x1909c9;let _0x13f108={};try{_0x13f108=JSON[_0x6c0ea5(0x15b)](fs[_0x6c0ea5(0x14d)](_0x49a91b+_0x6c0ea5(0x130))[_0x6c0ea5(0x135)]());}catch(_0x122709){console[_0x6c0ea5(0x149)](_0x6c0ea5(0x14a)),process[_0x6c0ea5(0x150)](0x0);}!(_0x6c0ea5(0x16d)in _0x13f108)&&(console[_0x6c0ea5(0x149)](_0x6c0ea5(0x148)),process[_0x6c0ea5(0x150)](0x0));!('installTarget'in _0x13f108)&&(console[_0x6c0ea5(0x149)](_0x6c0ea5(0x174)),process[_0x6c0ea5(0x150)](0x0));!('installResources'in _0x13f108)&&(console[_0x6c0ea5(0x149)](_0x6c0ea5(0x13e)),process[_0x6c0ea5(0x150)](0x0));typeof _0x13f108[_0x6c0ea5(0x16d)]!=='string'&&(console[_0x6c0ea5(0x149)](_0x6c0ea5(0x15c)),process[_0x6c0ea5(0x150)](0x0));![_0x6c0ea5(0x16f),_0x6c0ea5(0x177),_0x6c0ea5(0x140),_0x6c0ea5(0x12e)]['includes'](_0x13f108[_0x6c0ea5(0x16d)])&&(console[_0x6c0ea5(0x149)]('【Error】:[jjb.config.json.projectType]配置无效,有效值<multi\x20|\x20spa\x20|\x20micro-spa\x20|\x20uniapp>。'),process['exit'](0x0));typeof _0x13f108[_0x6c0ea5(0x160)]!==_0x6c0ea5(0x16c)&&(console[_0x6c0ea5(0x149)](_0x6c0ea5(0x137)),process[_0x6c0ea5(0x150)](0x0));![_0x6c0ea5(0x13a),_0x6c0ea5(0x136)][_0x6c0ea5(0x173)](_0x13f108['installTarget'])&&(console['log'](_0x6c0ea5(0x13c)),process['exit'](0x0));!Array[_0x6c0ea5(0x142)](_0x13f108[_0x6c0ea5(0x131)])&&(console['log'](_0x6c0ea5(0x13b)),process[_0x6c0ea5(0x150)](0x0));_0x13f108[_0x6c0ea5(0x131)][_0x6c0ea5(0x14e)]===0x0&&(console['log'](_0x6c0ea5(0x133)),process[_0x6c0ea5(0x150)](0x0));const _0x31a6f0=exports['f_resolve_install_resources'](_0x13f108[_0x6c0ea5(0x131)]);return _0x31a6f0['map'](_0x9cb393=>_0x9cb393[_0x6c0ea5(0x151)])['filter'](_0x242644=>![_0x6c0ea5(0x176),'jjb-dva-runtime',_0x6c0ea5(0x155),_0x6c0ea5(0x132),'react-admin-component','vue-unisass-component'][_0x6c0ea5(0x173)](_0x242644))[_0x6c0ea5(0x14e)]!==0x0&&(console[_0x6c0ea5(0x149)](_0x6c0ea5(0x165)),process[_0x6c0ea5(0x150)](0x0)),_0x13f108['installResources']=_0x31a6f0,_0x13f108;},exports[a4_0x1909c9(0x141)]=function(_0x254f69,_0x20a3ce,_0x530ef3){const _0x3496c5=a4_0x1909c9;fs['writeFileSync'](_0x254f69+_0x3496c5(0x146),_0x3496c5(0x153)+_0x20a3ce+_0x3496c5(0x16a)+_0x530ef3+_0x3496c5(0x167));},exports[a4_0x1909c9(0x15e)]=function(_0x335e19=[]){const _0x2ff0de=a4_0x1909c9,_0x3c15e5=[];return Array[_0x2ff0de(0x142)](_0x335e19)&&_0x335e19[_0x2ff0de(0x159)](_0x8e71f9=>{const _0x256748=_0x2ff0de;if(Array[_0x256748(0x142)](_0x8e71f9)){const [_0xe253,_0x14d28d=[]]=_0x8e71f9;_0x3c15e5['push']({'name':_0xe253,'importList':_0x14d28d});}else _0x3c15e5[_0x256748(0x13d)]({'name':_0x8e71f9,'importList':[]});}),_0x3c15e5;},exports[a4_0x1909c9(0x169)]=function(_0x43c4a6,_0x34fe55,_0x3ea016){const _0x366942=a4_0x1909c9,_0x12df10=JSON[_0x366942(0x15b)](fs[_0x366942(0x14d)](_0x43c4a6)['toString']());_0x12df10[_0x366942(0x14f)][_0x34fe55]=_0x3ea016,fs[_0x366942(0x15a)](_0x43c4a6,JSON[_0x366942(0x13f)](_0x12df10,null,0x2));},exports['f_file_copy']=function(_0x495299,_0x1f0ea0){const _0x2e2fc8=a4_0x1909c9;fs[_0x2e2fc8(0x143)](_0x495299)[_0x2e2fc8(0x159)](_0x1f8492=>{const _0x1d4dfd=_0x2e2fc8,_0x5e952e=_0x495299+'\x5c'+_0x1f8492,_0x4ecdc2=_0x1f0ea0+'\x5c'+_0x1f8492;fs[_0x1d4dfd(0x144)](_0x5e952e)[_0x1d4dfd(0x16e)]()?(fs[_0x1d4dfd(0x168)](_0x4ecdc2),exports[_0x1d4dfd(0x139)](_0x5e952e,_0x4ecdc2)):fs[_0x1d4dfd(0x15a)](_0x4ecdc2,fs[_0x1d4dfd(0x14d)](_0x5e952e)[_0x1d4dfd(0x135)]());});},exports[a4_0x1909c9(0x14b)]=function(_0x146aba=[],_0x4a3d78){const _0x41ead0=a4_0x1909c9;_0x146aba[_0x41ead0(0x159)](_0x22c561=>{const _0x29ed91=_0x41ead0,_0x44bb7e=_0x4a3d78+_0x22c561[_0x29ed91(0x166)];if(fs[_0x29ed91(0x157)](_0x44bb7e)){let _0x58a38c=fs['readFileSync'](_0x44bb7e)['toString']();_0x22c561[_0x29ed91(0x147)]['forEach'](_0x5cc307=>{const _0x401152=_0x29ed91;_0x58a38c=_0x58a38c[_0x401152(0x147)](_0x5cc307[0x0],_0x5cc307[0x1]);}),fs[_0x29ed91(0x15a)](_0x44bb7e,_0x58a38c);}});};
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 +1,27 @@
1
- function a5_0x3cee(_0x1b4c5d,_0x2ca7b8){const _0x154986=a5_0x1549();return a5_0x3cee=function(_0x3ceec4,_0x5b7437){_0x3ceec4=_0x3ceec4-0x113;let _0x15fa7a=_0x154986[_0x3ceec4];return _0x15fa7a;},a5_0x3cee(_0x1b4c5d,_0x2ca7b8);}const a5_0x144b0d=a5_0x3cee;function a5_0x1549(){const _0x54c57f=['npm','207snUNHz','36116NyMBpC','yarn','5001759cvvZaQ','install\x20husky\x20please\x20wait....','child_process','【Error】:no\x20registry\x20source,\x20available:[npm,\x20yarn]','3729930MgfXUO','npx\x20husky\x20install','910302yODbXY','77EnrxWa','path','129xFPxqh','7XmgJWZ','6367048lTXVyU','100370CXTamB','6274ZSnfmj','log','execSync'];a5_0x1549=function(){return _0x54c57f;};return a5_0x1549();}(function(_0x247d54,_0x5a297d){const _0x4b4711=a5_0x3cee,_0x45da54=_0x247d54();while(!![]){try{const _0x526477=parseInt(_0x4b4711(0x126))/0x1*(parseInt(_0x4b4711(0x116))/0x2)+parseInt(_0x4b4711(0x11a))/0x3*(parseInt(_0x4b4711(0x11b))/0x4)+parseInt(_0x4b4711(0x121))/0x5+-parseInt(_0x4b4711(0x123))/0x6*(-parseInt(_0x4b4711(0x113))/0x7)+-parseInt(_0x4b4711(0x114))/0x8+-parseInt(_0x4b4711(0x11d))/0x9+-parseInt(_0x4b4711(0x115))/0xa*(parseInt(_0x4b4711(0x124))/0xb);if(_0x526477===_0x5a297d)break;else _0x45da54['push'](_0x45da54['shift']());}catch(_0x1faff0){_0x45da54['push'](_0x45da54['shift']());}}}(a5_0x1549,0x7aebe));const child_process=require(a5_0x144b0d(0x11f)),path=require(a5_0x144b0d(0x125)),fs=require('fs');module['exports']=_0x6d51ad=>{const _0xbb9a71=a5_0x144b0d;![_0xbb9a71(0x119),_0xbb9a71(0x11c)]['includes'](_0x6d51ad)&&(console[_0xbb9a71(0x117)](_0xbb9a71(0x120)),process['exit'](0x0));const _0x273e66=path['resolve']('./');console[_0xbb9a71(0x117)]('install\x20modules\x20please\x20wait....'),child_process['execSync'](_0x6d51ad==='yarn'?'yarn':'npm\x20install',{'cwd':_0x273e66}),!fs['existsSync'](_0x273e66+'/.git')&&(console[_0xbb9a71(0x117)]('git\x20init\x20please\x20wait....'),child_process[_0xbb9a71(0x118)]('git\x20init',{'cwd':_0x273e66})),console[_0xbb9a71(0x117)](_0xbb9a71(0x11e)),child_process['execSync'](_0xbb9a71(0x122),{'cwd':_0x273e66}),console['log']('Finish!');};
1
+ const child_process = require('child_process');
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+
5
+ module.exports = registry_source => {
6
+
7
+ if (!['npm', 'yarn'].includes(registry_source)) {
8
+ console.log(`【Error】:no registry source, available:[npm, yarn]`);
9
+ process.exit(0);
10
+ }
11
+
12
+ /**
13
+ * 当前根路径
14
+ * @type {Promise<void> | Promise<string>}
15
+ */
16
+ const root_path = path.resolve('./');
17
+
18
+ console.log("install modules please wait....");
19
+ child_process.execSync(registry_source === 'yarn' ? 'yarn' : 'npm install', { cwd: root_path });
20
+ if (!fs.existsSync(`${root_path}/.git`)) {
21
+ console.log("git init please wait....");
22
+ child_process.execSync(`git init`, { cwd: root_path });
23
+ }
24
+ console.log("install husky please wait....");
25
+ child_process.execSync(`npx husky install`, { cwd: root_path });
26
+ console.log("Finish!");
27
+ };
@@ -1 +1,72 @@
1
- const a6_0x31fe04=a6_0x5783;function a6_0x5764(){const _0x35862e=['build','http://','279036MfNMeu','path','241128lrTHKI','9896910CDYyHw','18Jssfqt','jenkinsNamespace','jenkins','jobName','exports','\x5cjjb.config.js','2248cKSdzZ','4030wvWNAO','jenkinsUserName','850073KAICta','error:\x20','error','开始构建...','job','jenkinsPassword','470143EyuzHl','1852XOCmcx','resolve','branchName','existsSync','14310bEJUvb','join','../../../.auth','log','【Error】:no\x20auth\x20login'];a6_0x5764=function(){return _0x35862e;};return a6_0x5764();}function a6_0x5783(_0x398190,_0x5203d2){const _0x57647c=a6_0x5764();return a6_0x5783=function(_0x57838f,_0x5ddc09){_0x57838f=_0x57838f-0x7f;let _0x139ff1=_0x57647c[_0x57838f];return _0x139ff1;},a6_0x5783(_0x398190,_0x5203d2);}(function(_0x3cb34c,_0x38e672){const _0x103a24=a6_0x5783,_0xc193e8=_0x3cb34c();while(!![]){try{const _0x1befd7=-parseInt(_0x103a24(0x90))/0x1+parseInt(_0x103a24(0x7f))/0x2+parseInt(_0x103a24(0x9c))/0x3+-parseInt(_0x103a24(0x91))/0x4*(parseInt(_0x103a24(0x88))/0x5)+parseInt(_0x103a24(0x81))/0x6*(parseInt(_0x103a24(0x8a))/0x7)+parseInt(_0x103a24(0x87))/0x8*(-parseInt(_0x103a24(0x95))/0x9)+parseInt(_0x103a24(0x80))/0xa;if(_0x1befd7===_0x38e672)break;else _0xc193e8['push'](_0xc193e8['shift']());}catch(_0x5e4408){_0xc193e8['push'](_0xc193e8['shift']());}}}(a6_0x5764,0x43be1));const path=require(a6_0x31fe04(0x9d)),fs=require('fs'),Jenkins=require('jenkins');module[a6_0x31fe04(0x85)]=arguments=>{const _0x523094=a6_0x31fe04,_0x5b03df=path[_0x523094(0x96)](__dirname,_0x523094(0x97));!fs[_0x523094(0x94)](_0x5b03df)&&(console[_0x523094(0x98)](_0x523094(0x99)),process['exit'](0x0));const _0x4397e3=path[_0x523094(0x92)]('./'),_0xa7ee6b=_0x4397e3+_0x523094(0x86),_0x41e359=require(_0xa7ee6b),_0x8e9f55=_0x41e359['environment'][arguments],_0x2f9591=_0x8e9f55[_0x523094(0x83)]||{},_0x4a25f5=_0x2f9591[_0x523094(0x93)],_0x515765=_0x2f9591[_0x523094(0x84)],_0x2dd4d6=_0x2f9591['jenkinsHost'],_0x475e3a=_0x2f9591[_0x523094(0x89)],_0x3e9158=_0x2f9591[_0x523094(0x8f)],_0x549d62=_0x2f9591[_0x523094(0x82)],_0x23c29b=new Jenkins({'baseUrl':_0x523094(0x9b)+_0x475e3a+':'+_0x3e9158+'@'+_0x2dd4d6});try{const _0x181956=_0x23c29b[_0x523094(0x8e)][_0x523094(0x9a)]({'name':_0x515765,'parameters':{'app_Version':_0x4a25f5,'build_version':arguments,'k8s_namespace':_0x549d62,'branch':_0x4a25f5,'merge':!![]},'token':_0x3e9158});console[_0x523094(0x98)](_0x523094(0x8d),_0x181956);}catch(_0x128350){console[_0x523094(0x8c)](_0x523094(0x8b),_0x128350);}};
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const Jenkins = require('jenkins');
4
+
5
+ module.exports = arguments => {
6
+
7
+ const authPath = path.join(__dirname, '../../../.auth');
8
+ if (!fs.existsSync(authPath)) {
9
+ console.log(`【Error】:no auth login`);
10
+ process.exit(0);
11
+ }
12
+
13
+ /**
14
+ * 当前根路径
15
+ * @type {Promise<void> | Promise<string>}
16
+ */
17
+ const root_path = path.resolve('./');
18
+
19
+ /**
20
+ * jjb配置文件路径
21
+ * @type {string}
22
+ */
23
+ const config_json_path = `${root_path}\\jjb.config.js`;
24
+ /**
25
+ * 获取配置对象
26
+ */
27
+ const jjbConfig = require(config_json_path);
28
+ /**
29
+ * 获取当前处理环境配置信息
30
+ */
31
+ const envData = jjbConfig.environment[arguments];
32
+
33
+ const jenkinsData = envData.jenkins || {};
34
+
35
+ //分支名
36
+ const branchName = jenkinsData.branchName;
37
+ //项目名
38
+ const jobName = jenkinsData.jobName;
39
+ //主机
40
+ const jenkinsHost = jenkinsData.jenkinsHost;
41
+ //登录用户
42
+ const jenkinsUserName = jenkinsData.jenkinsUserName;
43
+ //登录密码
44
+ const jenkinsPassword = jenkinsData.jenkinsPassword;
45
+ //namespace
46
+ const jenkinsNamespace = jenkinsData.jenkinsNamespace;
47
+
48
+ //发起请求
49
+ const jenkins = new Jenkins({
50
+ // https://用户名:密码/token@jenkins地址
51
+ baseUrl: `http://${jenkinsUserName}:${jenkinsPassword}@${jenkinsHost}`,
52
+ });
53
+
54
+ try {
55
+ const result = jenkins.job.build({
56
+ name: jobName,
57
+ // jenkins中需要的参数,若无则为空
58
+ parameters: {
59
+ app_Version: branchName,
60
+ build_version: arguments,
61
+ k8s_namespace: jenkinsNamespace,
62
+ branch: branchName,
63
+ merge: true
64
+ },
65
+ token: jenkinsPassword
66
+ })
67
+ console.log('开始构建...', result)
68
+ } catch (error) {
69
+ console.error('error: ', error);
70
+ }
71
+
72
+ }
@@ -1 +1,197 @@
1
- function a7_0x1dd5(_0xf9e64f,_0x4f31eb){const _0x35c219=a7_0x35c2();return a7_0x1dd5=function(_0x1dd5ea,_0x62403c){_0x1dd5ea=_0x1dd5ea-0xb4;let _0x144bfd=_0x35c219[_0x1dd5ea];return _0x144bfd;},a7_0x1dd5(_0xf9e64f,_0x4f31eb);}const a7_0x2eaf5d=a7_0x1dd5;function a7_0x35c2(){const _0x1d7e1e=['question','length','stringify','【Error】:请在window下暴露配置信息','no\x20message','579970EhkZWo','child_process','platform','split','npm\x20run\x20build:production','existsSync','2495760qxeKer','stdin','execSync','【Error】:no\x20auth\x20login','message','\x5cthumbnail.png','resolve','data','readFileSync','from','发布失败!根目录缺少‘dist/index.js’文件,无法完成发布。','1051310koDncP','post','createInterface','3643272DeCyBq','【Error】:组件根目录必须包含thumbnail.png缩略图片','1480904CzFGEj','base64','51ucZwSt','log','return\x20','请输入此次提交信息,按Enter确认:','Auth\x20Fail!','then','package_content','toString','axios','arch','catch','package_version','../../../package.json','thumbnail_base64','【Error】:window暴露配置缺少info基础信息','exit','\x5cREADME.md','yarn\x20build:production','\x5cpackage.json','match','exports','status','【Error】:请必须包含README.md说明文件','readline','1sBIyuM','join','parse','2677248eYrkoK','hostname','readme_content','defaultSetting','发布失败!根目录缺少‘package.json’文件,无法完成发布。','Please\x20wait,\x20build\x20...','13236pzqMSq'];a7_0x35c2=function(){return _0x1d7e1e;};return a7_0x35c2();}(function(_0x207c64,_0x11332f){const _0x5aedfe=a7_0x1dd5,_0x6fefa5=_0x207c64();while(!![]){try{const _0x495d30=parseInt(_0x5aedfe(0xbb))/0x1*(parseInt(_0x5aedfe(0xca))/0x2)+parseInt(_0x5aedfe(0xe2))/0x3*(-parseInt(_0x5aedfe(0xc4))/0x4)+parseInt(_0x5aedfe(0xdb))/0x5+-parseInt(_0x5aedfe(0xd0))/0x6+-parseInt(_0x5aedfe(0xbe))/0x7+parseInt(_0x5aedfe(0xe0))/0x8+parseInt(_0x5aedfe(0xde))/0x9;if(_0x495d30===_0x11332f)break;else _0x6fefa5['push'](_0x6fefa5['shift']());}catch(_0x7aa042){_0x6fefa5['push'](_0x6fefa5['shift']());}}}(a7_0x35c2,0x397e3));const path=require('path'),fs=require('fs'),os=require('os'),axios=require(a7_0x2eaf5d(0xea)),readline=require(a7_0x2eaf5d(0xba)),io=readline[a7_0x2eaf5d(0xdd)]({'input':process[a7_0x2eaf5d(0xd1)],'output':process['stdout']}),child_process=require(a7_0x2eaf5d(0xcb)),{getApiHost}=require('../cmd.install/config');module[a7_0x2eaf5d(0xb7)]=_0x5268f3=>{const _0x1eb327=a7_0x2eaf5d,_0x253ce4=path[_0x1eb327(0xbc)](__dirname,'../../../.auth');!fs[_0x1eb327(0xcf)](_0x253ce4)&&(console[_0x1eb327(0xe3)](_0x1eb327(0xd3)),process[_0x1eb327(0xf1)](0x0));const [_0x30fd2b,_0x2a5645]=fs[_0x1eb327(0xd8)](_0x253ce4)[_0x1eb327(0xe9)]()[_0x1eb327(0xcd)]('/');axios['post'](getApiHost()+'/api/auth',{'username':_0x30fd2b,'password':_0x2a5645})[_0x1eb327(0xe7)](_0x2418e4=>{const _0x226002=_0x1eb327;if(_0x2418e4['data'][_0x226002(0xb8)]){const _0x5f43e4=path[_0x226002(0xd6)]('./');console[_0x226002(0xe3)](_0x226002(0xc3));fs[_0x226002(0xcf)](_0x5f43e4+'/yarn.lock')?child_process[_0x226002(0xd2)](_0x226002(0xb4),{'cwd':_0x5f43e4}):child_process[_0x226002(0xd2)](_0x226002(0xce),{'cwd':_0x5f43e4});const _0x50d7e3=_0x5f43e4+'\x5cdist\x5cindex.js',_0x582b90=_0x5f43e4+_0x226002(0xb5),_0x4a63b7=_0x5f43e4+_0x226002(0xf2),_0x434977=_0x5f43e4+_0x226002(0xd5),_0x41e88a=[os[_0x226002(0xbf)](),os[_0x226002(0xcc)](),os[_0x226002(0xeb)](),new Date()[_0x226002(0xe9)]()],_0x292941=JSON[_0x226002(0xbd)](fs[_0x226002(0xd8)](path[_0x226002(0xbc)](__dirname,_0x226002(0xee)))[_0x226002(0xe9)]()),{version:_0x5dcd50}=_0x292941,_0x55654e={'username':_0x30fd2b,'cmd_version':_0x5dcd50,'hostname':os['hostname'](),'platform':os[_0x226002(0xcc)]()};if(fs[_0x226002(0xcf)](_0x582b90)){if(fs['existsSync'](_0x50d7e3)){_0x55654e[_0x226002(0xed)]=_0x5268f3?_0x5268f3:0x0,_0x55654e[_0x226002(0xe8)]=fs[_0x226002(0xd8)](_0x50d7e3)[_0x226002(0xe9)](),_0x55654e['component_config_content']={};const _0xd43ea8=fs[_0x226002(0xd8)](_0x50d7e3)[_0x226002(0xe9)](),_0x24ba09=_0xd43ea8[_0x226002(0xb6)](/(window\[).+?(\.componentKey|.+]={)/img);if(_0x24ba09&&_0x24ba09['length']){const _0x2b6819=_0xd43ea8[_0x226002(0xb6)](/componentKey.+([{,]info:\s{0,}{)/img);if(_0x2b6819&&_0x2b6819['length']){let _0x140b02='{';const _0x41db56=_0xd43ea8['split'](_0x2b6819[0x0])[0x1];for(let _0x532f75=0x0;_0x532f75<_0x41db56[_0x226002(0xc6)];_0x532f75++){_0x140b02+=_0x41db56[_0x532f75];if(_0x41db56[_0x532f75]==='}')try{const _0x11a82c=new Function(_0x226002(0xe4)+_0x140b02)();_0x55654e['component_config_content']={..._0x11a82c,'defaultSetting':{}};}catch(_0x3088ae){}}}else console[_0x226002(0xe3)]('【Error】:window暴露配置缺少info基础信息'),process[_0x226002(0xf1)](0x0);const _0x6c5c12=_0xd43ea8[_0x226002(0xb6)](/componentKey.+([{,]settings:\s{0,}{)/img);if(_0x6c5c12&&_0x6c5c12[_0x226002(0xc6)]){let _0x2b218b='{';const _0x2e7c35=_0xd43ea8[_0x226002(0xcd)](_0x6c5c12[0x0])[0x1];for(let _0x29e6d3=0x0;_0x29e6d3<_0x2e7c35[_0x226002(0xc6)];_0x29e6d3++){_0x2b218b+=_0x2e7c35[_0x29e6d3];if(_0x2e7c35[_0x29e6d3]==='}')try{const _0xfb0172=new Function(_0x226002(0xe4)+_0x2b218b)();_0x55654e['component_config_content'][_0x226002(0xc1)]=_0xfb0172;}catch(_0x48987c){}}_0x55654e['component_config_content']=JSON[_0x226002(0xc7)](_0x55654e['component_config_content']);}else console[_0x226002(0xe3)](_0x226002(0xf0)),process[_0x226002(0xf1)](0x0);}else console[_0x226002(0xe3)](_0x226002(0xc8)),process[_0x226002(0xf1)](0x0);fs[_0x226002(0xcf)](_0x4a63b7)?_0x55654e[_0x226002(0xc0)]=fs['readFileSync'](_0x4a63b7)['toString']():(console['log'](_0x226002(0xb9)),process[_0x226002(0xf1)](0x0));if(!fs[_0x226002(0xcf)](_0x434977))console[_0x226002(0xe3)](_0x226002(0xdf)),process['exit'](0x0);else{const _0x39cd09=fs[_0x226002(0xd8)](_0x434977),_0x257533=Buffer[_0x226002(0xd9)](_0x39cd09)[_0x226002(0xe9)](_0x226002(0xe1));_0x55654e[_0x226002(0xef)]=_0x257533;}io[_0x226002(0xc5)](_0x226002(0xe5),function(_0x412e71){const _0x25a8e0=_0x226002;_0x55654e[_0x25a8e0(0xd4)]=_0x412e71||_0x25a8e0(0xc9),axios[_0x25a8e0(0xdc)](getApiHost()+'/api/file/publish',_0x55654e)['then'](_0x436100=>{const _0x44d9ce=_0x25a8e0;console[_0x44d9ce(0xe3)](_0x436100[_0x44d9ce(0xd7)][_0x44d9ce(0xd4)]),process[_0x44d9ce(0xf1)](0x0);})[_0x25a8e0(0xec)](_0x4c7f08=>{const _0x2ff5a8=_0x25a8e0;console[_0x2ff5a8(0xe3)](_0x4c7f08),console[_0x2ff5a8(0xe3)]('网络异常。'),process['exit'](0x0);});});}else console[_0x226002(0xe3)](_0x226002(0xda)),process['exit'](0x0);}else console['log'](_0x226002(0xc2)),process[_0x226002(0xf1)](0x0);}else console[_0x226002(0xe3)](_0x226002(0xe6));})[_0x1eb327(0xec)](_0x53a41c=>{const _0x4d22f4=_0x1eb327;console[_0x4d22f4(0xe3)](_0x53a41c),console[_0x4d22f4(0xe3)]('Auth\x20NetWork\x20Fail!');});};
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const os = require('os');
4
+ const axios = require('axios');
5
+ const readline = require('readline');
6
+ const io = readline.createInterface({
7
+ input: process.stdin,
8
+ output: process.stdout
9
+ });
10
+ const child_process = require('child_process');
11
+ const { getApiHost } = require('../cmd.install/config');
12
+
13
+ module.exports = version => {
14
+
15
+ const authPath = path.join(__dirname, '../../../.auth');
16
+ if (!fs.existsSync(authPath)) {
17
+ console.log(`【Error】:no auth login`);
18
+ process.exit(0);
19
+ }
20
+
21
+ const [ username, password ] = fs.readFileSync(authPath).toString().split('/');
22
+ axios.post(`${getApiHost()}/api/auth`, {
23
+ username,
24
+ password
25
+ }).then(res => {
26
+ if (res.data.status) {
27
+
28
+ /**
29
+ * 下发数据根路径
30
+ * @type {string}
31
+ */
32
+ const root_path = path.resolve('./');
33
+
34
+ console.log('Please wait, build ...');
35
+ if (fs.existsSync(root_path + '/yarn.lock')) {
36
+ child_process.execSync('yarn build:production', { cwd: root_path });
37
+ } else {
38
+ child_process.execSync('npm run build:production', { cwd: root_path });
39
+ }
40
+
41
+ const dist_folder_path = `${root_path}\\dist\\index.js`;
42
+ const package_json_path = `${root_path}\\package.json`;
43
+ const readme_path = `${root_path}\\README.md`;
44
+ const thumbnail_png_path = `${root_path}\\thumbnail.png`;
45
+ const log_text = [
46
+ os.hostname(),
47
+ os.platform(),
48
+ os.arch(),
49
+ new Date().toString()
50
+ ];
51
+
52
+ const package_json_file = JSON.parse(fs.readFileSync(path.join(__dirname, '../../../package.json')).toString());
53
+ const {
54
+ version: cmd_version
55
+ } = package_json_file;
56
+
57
+ const pushData = {
58
+ username,
59
+ cmd_version,
60
+ hostname: os.hostname(),
61
+ platform: os.platform()
62
+ };
63
+
64
+ if (fs.existsSync(package_json_path)) {
65
+ if (fs.existsSync(dist_folder_path)) {
66
+ pushData.package_version = version
67
+ ? version
68
+ : 0;
69
+ pushData.package_content = fs.readFileSync(dist_folder_path).toString();
70
+ pushData.component_config_content = {};
71
+
72
+ const dist_content = fs.readFileSync(dist_folder_path).toString();
73
+
74
+
75
+ const matches = dist_content.match(/(window\[).+?(\.componentKey|.+]={)/img);
76
+ if (matches && matches.length){
77
+
78
+ const infoMatches = dist_content.match(/componentKey.+([{,]info:\s{0,}{)/img);
79
+ if (infoMatches && infoMatches.length) {
80
+ let infoStr = '{';
81
+ const infoStr1 = dist_content.split(infoMatches[0])[1];
82
+ for (let i = 0; i < infoStr1.length; i++){
83
+ infoStr += infoStr1[i];
84
+ if (infoStr1[i] === '}') {
85
+ try {
86
+ const currJson = new Function('return '+infoStr)();
87
+ pushData.component_config_content = {
88
+ ...currJson,
89
+ defaultSetting: {}
90
+ };
91
+ } catch (e) {
92
+
93
+ }
94
+ }
95
+ }
96
+ } else {
97
+ console.log('【Error】:window暴露配置缺少info基础信息');
98
+ process.exit(0);
99
+ }
100
+
101
+ const settingsMatches = dist_content.match(/componentKey.+([{,]settings:\s{0,}{)/img);
102
+ if (settingsMatches && settingsMatches.length) {
103
+ let settingsStr = '{';
104
+ const settingsStr1 = dist_content.split(settingsMatches[0])[1];
105
+ for (let i = 0; i < settingsStr1.length; i++){
106
+ settingsStr += settingsStr1[i];
107
+ if (settingsStr1[i] === '}') {
108
+ try {
109
+ const currJson = new Function('return '+settingsStr)();
110
+ pushData.component_config_content.defaultSetting = currJson;
111
+ } catch (e) {
112
+
113
+ }
114
+ }
115
+ }
116
+
117
+ pushData.component_config_content = JSON.stringify(pushData.component_config_content);
118
+ } else {
119
+ console.log('【Error】:window暴露配置缺少info基础信息');
120
+ process.exit(0);
121
+ }
122
+
123
+ // let currStr = matches[0].split('=')[1];
124
+ // const str= dist_content.split(matches[0])[1];
125
+ // for (let i = 0; i< str.length; i++){
126
+ // currStr += str[i]
127
+ // if (str[i] === '}'){
128
+ // try {
129
+ // const currJson = new Function('return '+currStr)();
130
+ // if (!currJson.info) {
131
+ // console.log('【Error】:window暴露配置缺少info基础信息');
132
+ // process.exit(0);
133
+ // }
134
+ // if (!currJson.settings) {
135
+ // console.log('【Error】:window暴露配置缺少settings基础信息');
136
+ // process.exit(0);
137
+ // }
138
+ // pushData.component_config_content = JSON.stringify({
139
+ // ...currJson.info,
140
+ // defaultSetting: currJson.settings
141
+ // });
142
+ // break;
143
+ // }
144
+ // catch (e) {
145
+ // console.log(e)
146
+ // }
147
+ // }
148
+ //
149
+ // }
150
+ } else {
151
+ console.log('【Error】:请在window下暴露配置信息');
152
+ process.exit(0);
153
+ }
154
+
155
+ if (fs.existsSync(readme_path)) {
156
+ pushData.readme_content = fs.readFileSync(readme_path).toString();
157
+ } else {
158
+ console.log('【Error】:请必须包含README.md说明文件');
159
+ process.exit(0);
160
+ }
161
+
162
+ if (!fs.existsSync(thumbnail_png_path)) {
163
+ console.log('【Error】:组件根目录必须包含thumbnail.png缩略图片');
164
+ process.exit(0);
165
+ } else {
166
+ const thumbnailData = fs.readFileSync(thumbnail_png_path);
167
+ const thumbnail_base64 = Buffer.from(thumbnailData).toString('base64');
168
+ pushData.thumbnail_base64 = thumbnail_base64;
169
+ }
170
+
171
+ io.question('请输入此次提交信息,按Enter确认:', function (message) {
172
+ pushData.message = message || 'no message';
173
+ axios.post(`${getApiHost()}/api/file/publish`, pushData).then(res => {
174
+ console.log(res.data.message);
175
+ process.exit(0);
176
+ }).catch(e => {
177
+ console.log(e);
178
+ console.log('网络异常。');
179
+ process.exit(0);
180
+ });
181
+ });
182
+ } else {
183
+ console.log('发布失败!根目录缺少‘dist/index.js’文件,无法完成发布。');
184
+ process.exit(0);
185
+ }
186
+ } else {
187
+ console.log('发布失败!根目录缺少‘package.json’文件,无法完成发布。');
188
+ process.exit(0);
189
+ }
190
+ } else {
191
+ console.log('Auth Fail!');
192
+ }
193
+ }).catch(e => {
194
+ console.log(e);
195
+ console.log('Auth NetWork Fail!');
196
+ });
197
+ };
@@ -1 +1,76 @@
1
- const a8_0x5672c7=a8_0x40d5;(function(_0x446f61,_0x14bce3){const _0x5e04ea=a8_0x40d5,_0x25331c=_0x446f61();while(!![]){try{const _0x57accb=-parseInt(_0x5e04ea(0x1f7))/0x1+parseInt(_0x5e04ea(0x200))/0x2*(parseInt(_0x5e04ea(0x1e7))/0x3)+-parseInt(_0x5e04ea(0x1f0))/0x4+parseInt(_0x5e04ea(0x1fa))/0x5+parseInt(_0x5e04ea(0x1ef))/0x6*(parseInt(_0x5e04ea(0x1e9))/0x7)+parseInt(_0x5e04ea(0x1f9))/0x8*(parseInt(_0x5e04ea(0x1ea))/0x9)+-parseInt(_0x5e04ea(0x1f2))/0xa*(-parseInt(_0x5e04ea(0x1e4))/0xb);if(_0x57accb===_0x14bce3)break;else _0x25331c['push'](_0x25331c['shift']());}catch(_0x4ea707){_0x25331c['push'](_0x25331c['shift']());}}}(a8_0x3c13,0xbd780));function a8_0x3c13(){const _0x5f24fd=['4429024zmCNTU','catch','5158430XVScDc','arch','/api/file/push','\x5cdist\x5cindex.js','../cmd.install/config','337606vBiXIt','resolve','8VuGwWc','151305XoKezh','log','stringify','post','data','message','39458yxXqKl','toString','发布失败!根目录缺少‘dist/index.js’文件,无法完成发布。','existsSync','push','hostname','status','网络异常。','exit','/api/auth','11KxxYhg','readFileSync','then','6shoxAt','\x5cpackage.json','343819WdrYwu','12508011SVnkEN','parse','split','platform','join','30qFzDtc'];a8_0x3c13=function(){return _0x5f24fd;};return a8_0x3c13();}const path=require('path'),fs=require('fs'),os=require('os'),axios=require('axios'),{getApiHost}=require(a8_0x5672c7(0x1f6));function a8_0x40d5(_0x42045e,_0x55672f){const _0x3c1334=a8_0x3c13();return a8_0x40d5=function(_0x40d52e,_0xff089e){_0x40d52e=_0x40d52e-0x1de;let _0xbbdfcd=_0x3c1334[_0x40d52e];return _0xbbdfcd;},a8_0x40d5(_0x42045e,_0x55672f);}module['exports']=_0x9aa1e1=>{const _0x541fd3=a8_0x5672c7,_0x43c012=path[_0x541fd3(0x1ee)](__dirname,'../../../.auth');!fs[_0x541fd3(0x203)](_0x43c012)&&(console['log']('【Error】:no\x20auth\x20login'),process[_0x541fd3(0x1e2)](0x0));const [_0x4299c4,_0x1a0535]=fs['readFileSync'](_0x43c012)[_0x541fd3(0x201)]()[_0x541fd3(0x1ec)]('/');axios[_0x541fd3(0x1fd)](getApiHost()+_0x541fd3(0x1e3),{'username':_0x4299c4,'password':_0x1a0535})[_0x541fd3(0x1e6)](_0x1677ce=>{const _0x3891a4=_0x541fd3;if(_0x1677ce[_0x3891a4(0x1fe)][_0x3891a4(0x1e0)]){const _0x27ae03=path[_0x3891a4(0x1f8)]('./'),_0x40d463=_0x27ae03+_0x3891a4(0x1f5),_0x7411cd=_0x27ae03+_0x3891a4(0x1e8),_0x5c587c=[os[_0x3891a4(0x1df)](),os[_0x3891a4(0x1ed)](),os[_0x3891a4(0x1f3)](),new Date()[_0x3891a4(0x201)](),JSON['stringify'](os['networkInterfaces'](),null,'\x09')];if(fs[_0x3891a4(0x203)](_0x7411cd)){if(fs[_0x3891a4(0x203)](_0x40d463)){const _0x1a8b0d=JSON[_0x3891a4(0x1eb)](fs[_0x3891a4(0x1e5)](_0x7411cd)[_0x3891a4(0x201)]()),{name:_0x5f0932,version:_0x2acc78}=_0x1a8b0d;_0x5c587c[_0x3891a4(0x1de)](JSON[_0x3891a4(0x1fc)](_0x1a8b0d)),axios['post'](getApiHost()+_0x3891a4(0x1f4),{'username':_0x4299c4,'log_text':_0x5c587c['join']('\x0a'),'package_name':_0x5f0932,'package_version':_0x9aa1e1?_0x9aa1e1:_0x2acc78,'package_content':fs['readFileSync'](_0x40d463)[_0x3891a4(0x201)]()})[_0x3891a4(0x1e6)](_0x466af2=>{const _0x2a00cc=_0x3891a4;console[_0x2a00cc(0x1fb)](_0x466af2[_0x2a00cc(0x1fe)][_0x2a00cc(0x1ff)]),process['exit'](0x0);})[_0x3891a4(0x1f1)](_0x584a0b=>{const _0x37b38b=_0x3891a4;console[_0x37b38b(0x1fb)](_0x584a0b),console[_0x37b38b(0x1fb)](_0x37b38b(0x1e1)),process[_0x37b38b(0x1e2)](0x0);});}else console[_0x3891a4(0x1fb)](_0x3891a4(0x202)),process[_0x3891a4(0x1e2)](0x0);}else console[_0x3891a4(0x1fb)]('发布失败!根目录缺少‘package.json’文件,无法完成发布。'),process[_0x3891a4(0x1e2)](0x0);}else console[_0x3891a4(0x1fb)]('Auth\x20Fail!');})[_0x541fd3(0x1f1)](_0x4509cf=>{console['log']('Auth\x20NetWork\x20Fail!');});};
1
+ const path = require('path');
2
+ const fs = require('fs');
3
+ const os = require('os');
4
+ const axios = require('axios');
5
+ const { getApiHost } = require('../cmd.install/config');
6
+
7
+ module.exports = version => {
8
+
9
+ const authPath = path.join(__dirname, '../../../.auth');
10
+ if (!fs.existsSync(authPath)) {
11
+ console.log(`【Error】:no auth login`);
12
+ process.exit(0);
13
+ }
14
+
15
+ const [username , password] = fs.readFileSync(authPath).toString().split('/');
16
+ axios.post(`${getApiHost()}/api/auth`, {
17
+ username,
18
+ password
19
+ }).then(res => {
20
+ if (res.data.status) {
21
+ /**
22
+ * 下发数据根路径
23
+ * @type {string}
24
+ */
25
+ const root_path = path.resolve('./');
26
+ const dist_folder_path = `${root_path}\\dist\\index.js`;
27
+ const package_json_path = `${root_path}\\package.json`;
28
+
29
+ const log_text = [
30
+ os.hostname(),
31
+ os.platform(),
32
+ os.arch(),
33
+ new Date().toString(),
34
+ JSON.stringify(os.networkInterfaces(), null, '\t')
35
+ ];
36
+
37
+ if (fs.existsSync(package_json_path)) {
38
+ if (fs.existsSync(dist_folder_path)) {
39
+ const package_json_file = JSON.parse(fs.readFileSync(package_json_path).toString());
40
+ const {
41
+ name: package_name,
42
+ version: package_version
43
+ } = package_json_file;
44
+ log_text.push(JSON.stringify(package_json_file));
45
+
46
+ axios.post(`${getApiHost()}/api/file/push`, {
47
+ username,
48
+ log_text: log_text.join('\n'),
49
+ package_name,
50
+ package_version: version
51
+ ? version
52
+ : package_version,
53
+ package_content: fs.readFileSync(dist_folder_path).toString()
54
+ }).then(res => {
55
+ console.log(res.data.message);
56
+ process.exit(0);
57
+ }).catch(e => {
58
+ console.log(e);
59
+ console.log('网络异常。');
60
+ process.exit(0);
61
+ });
62
+ } else {
63
+ console.log('发布失败!根目录缺少‘dist/index.js’文件,无法完成发布。');
64
+ process.exit(0);
65
+ }
66
+ } else {
67
+ console.log('发布失败!根目录缺少‘package.json’文件,无法完成发布。');
68
+ process.exit(0);
69
+ }
70
+ } else {
71
+ console.log('Auth Fail!');
72
+ }
73
+ }).catch(e => {
74
+ console.log('Auth NetWork Fail!');
75
+ });
76
+ };