jjb-cmd 2.2.1 → 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
- const a4_0x4046da=a4_0x57c1;(function(_0x1965a6,_0xb663e7){const _0x3f81bc=a4_0x57c1,_0x259cc7=_0x1965a6();while(!![]){try{const _0x4b7742=parseInt(_0x3f81bc(0xc0))/0x1+parseInt(_0x3f81bc(0x9c))/0x2+parseInt(_0x3f81bc(0xa8))/0x3+parseInt(_0x3f81bc(0x96))/0x4*(parseInt(_0x3f81bc(0xb9))/0x5)+-parseInt(_0x3f81bc(0xd1))/0x6*(parseInt(_0x3f81bc(0xb6))/0x7)+-parseInt(_0x3f81bc(0x99))/0x8*(-parseInt(_0x3f81bc(0xd2))/0x9)+-parseInt(_0x3f81bc(0xba))/0xa*(parseInt(_0x3f81bc(0xb5))/0xb);if(_0x4b7742===_0xb663e7)break;else _0x259cc7['push'](_0x259cc7['shift']());}catch(_0x5648c1){_0x259cc7['push'](_0x259cc7['shift']());}}}(a4_0x39f1,0x87d25));const fs=require('fs'),os=require('os'),{GIT_HOST,GIT_TEMP_DIR,CLOUD_PROJECT}=require(a4_0x4046da(0xae));function a4_0x57c1(_0x2511c1,_0x48212a){const _0x39f1c6=a4_0x39f1();return a4_0x57c1=function(_0x57c18e,_0x48911e){_0x57c18e=_0x57c18e-0x8c;let _0xd55054=_0x39f1c6[_0x57c18e];return _0xd55054;},a4_0x57c1(_0x2511c1,_0x48212a);}function a4_0x39f1(){const _0x154c38=['110757cUMRLM','string','【Error】:[jjb.config.json.installResources]无资源。','installResources','existsSync','jjb-dva-runtime','writeFileSync','projectType','micro-spa','【Error】:[jjb.config.json]文件配置无效,需要projectType属性。','【Error】:[jjb.config.json.installResources]类型是一个Array<string>。','\x22,\x22version\x22:\x22','filter','jjb-common','f_content_replace','【Error】:[jjb.config.json.projectType]类型是一个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>。','73620SgdAEH','5410926bxNDMV','f_pull_git_repository','f_scan_jjb_config_json','vue-unisass-component','map','{\x22name\x22:\x22','includes','name','isArray','statSync','uniapp','isDirectory','【Error】:[jjb.config.json]文件配置无效,需要installResources属性。','push','f_create_package_json','jjb-common-lib','4MdgTYW','f_update_project_package_json','log','8NWmRps','stringify','/repository/archive.zip?private_token=','1496128GYATBz','spa','【Error】:[jjb.config.json]文件配置无效,需要installTarget属性。','f_file_copy','readdirSync','src','multi','【Error】:[jjb.config.json]文件解析失败,请确认是否配置正确。','length','unlinkSync','installTarget','\x5cjjb.config.json','213246DNgdOw','node_modules','forEach','rmdirSync','path','【Error】:[jjb.config.json.projectType]配置无效,有效值<multi\x20|\x20spa\x20|\x20micro-spa\x20|\x20uniapp>。','./config','jjb-common-decorator','f_rm_rf','f_resolve_install_resources','&ref=master','toString','\x22,\x22main\x22:\x20\x22index.js\x22}','11BkJNHs','280MWAjes','parse','_zip','945645uTCdia','6731210mAEcbm','exit','projectId','readFileSync','【Error】:[jjb.config.json.installTarget]类型是一个string。','replace'];a4_0x39f1=function(){return _0x154c38;};return a4_0x39f1();}exports[a4_0x4046da(0xb0)]=function(_0x23dd0c){const _0x38608e=a4_0x4046da;if(fs[_0x38608e(0xc4)](_0x23dd0c)){const _0x554c89=fs[_0x38608e(0xa0)](_0x23dd0c);for(let _0x1fef15=0x0;_0x1fef15<_0x554c89[_0x38608e(0xa4)];_0x1fef15++){const _0x3344bd=_0x554c89[_0x1fef15],_0x467c93=_0x23dd0c+'/'+_0x3344bd;fs[_0x38608e(0x8f)](_0x467c93)['isDirectory']()?(exports[_0x38608e(0xb0)](_0x467c93),fs[_0x38608e(0xab)](_0x467c93)):fs[_0x38608e(0xa5)](_0x467c93);}}},exports[a4_0x4046da(0xd3)]=function(_0x4754fb=[]){const _0x15798e=a4_0x4046da;return _0x4754fb[_0x15798e(0xd6)](_0x927200=>{const _0x3d334c=_0x15798e,_0x1e1a9b=CLOUD_PROJECT[_0x927200[_0x3d334c(0x8d)]]||undefined,_0x2ef9b9=os['tmpdir']();return{'path':_0x2ef9b9+'\x5c'+GIT_TEMP_DIR+'\x5c'+_0x927200[_0x3d334c(0x8d)]+'.zip','compress':_0x2ef9b9+'\x5c'+GIT_TEMP_DIR+'\x5c'+_0x927200[_0x3d334c(0x8d)]+_0x3d334c(0xb8),'repository':GIT_HOST+'/api/v4/projects/'+_0x1e1a9b[_0x3d334c(0xbc)]+_0x3d334c(0x9b)+_0x1e1a9b['token']+_0x3d334c(0xb2)};});},exports[a4_0x4046da(0xd4)]=function(_0x2cf650){const _0x58e962=a4_0x4046da;return fs[_0x58e962(0xc4)](_0x2cf650+_0x58e962(0xa7));},exports['f_scan_jjb_config_json_rules']=function(_0x2a984a){const _0xff76bd=a4_0x4046da;let _0x38e11e={};try{_0x38e11e=JSON[_0xff76bd(0xb7)](fs[_0xff76bd(0xbd)](_0x2a984a+'\x5cjjb.config.json')['toString']());}catch(_0x3a7842){console[_0xff76bd(0x98)](_0xff76bd(0xa3)),process[_0xff76bd(0xbb)](0x0);}!(_0xff76bd(0xc7)in _0x38e11e)&&(console['log'](_0xff76bd(0xc9)),process[_0xff76bd(0xbb)](0x0));!('installTarget'in _0x38e11e)&&(console[_0xff76bd(0x98)](_0xff76bd(0x9e)),process['exit'](0x0));!(_0xff76bd(0xc3)in _0x38e11e)&&(console[_0xff76bd(0x98)](_0xff76bd(0x92)),process[_0xff76bd(0xbb)](0x0));typeof _0x38e11e['projectType']!==_0xff76bd(0xc1)&&(console[_0xff76bd(0x98)](_0xff76bd(0xcf)),process[_0xff76bd(0xbb)](0x0));![_0xff76bd(0xa2),_0xff76bd(0x9d),_0xff76bd(0x90),_0xff76bd(0xc8)]['includes'](_0x38e11e[_0xff76bd(0xc7)])&&(console[_0xff76bd(0x98)](_0xff76bd(0xad)),process[_0xff76bd(0xbb)](0x0));typeof _0x38e11e['installTarget']!==_0xff76bd(0xc1)&&(console[_0xff76bd(0x98)](_0xff76bd(0xbe)),process[_0xff76bd(0xbb)](0x0));![_0xff76bd(0xa9),_0xff76bd(0xa1)]['includes'](_0x38e11e[_0xff76bd(0xa6)])&&(console[_0xff76bd(0x98)]('【Error】:[jjb.config.json.node_modules]配置无效,有效值<node_modules\x20|\x20src>。'),process[_0xff76bd(0xbb)](0x0));!Array[_0xff76bd(0x8e)](_0x38e11e['installResources'])&&(console[_0xff76bd(0x98)](_0xff76bd(0xca)),process[_0xff76bd(0xbb)](0x0));_0x38e11e[_0xff76bd(0xc3)][_0xff76bd(0xa4)]===0x0&&(console['log'](_0xff76bd(0xc2)),process[_0xff76bd(0xbb)](0x0));const _0x147b24=exports[_0xff76bd(0xb1)](_0x38e11e[_0xff76bd(0xc3)]);return _0x147b24['map'](_0x48bbad=>_0x48bbad['name'])[_0xff76bd(0xcc)](_0x3edf1b=>![_0xff76bd(0xcd),_0xff76bd(0xc5),_0xff76bd(0x95),_0xff76bd(0xaf),'react-admin-component',_0xff76bd(0xd5)][_0xff76bd(0x8c)](_0x3edf1b))[_0xff76bd(0xa4)]!==0x0&&(console[_0xff76bd(0x98)](_0xff76bd(0xd0)),process[_0xff76bd(0xbb)](0x0)),_0x38e11e[_0xff76bd(0xc3)]=_0x147b24,_0x38e11e;},exports[a4_0x4046da(0x94)]=function(_0x1217f1,_0x41eb28,_0x409474){const _0x228178=a4_0x4046da;fs['writeFileSync'](_0x1217f1+'\x5cpackage.json',_0x228178(0xd7)+_0x41eb28+_0x228178(0xcb)+_0x409474+_0x228178(0xb4));},exports[a4_0x4046da(0xb1)]=function(_0x1f15a8=[]){const _0x4b06d8=a4_0x4046da,_0xde718f=[];return Array[_0x4b06d8(0x8e)](_0x1f15a8)&&_0x1f15a8[_0x4b06d8(0xaa)](_0x5e05bc=>{const _0x2ce6eb=_0x4b06d8;if(Array[_0x2ce6eb(0x8e)](_0x5e05bc)){const [_0x1e0faa,_0x46ee35=[]]=_0x5e05bc;_0xde718f['push']({'name':_0x1e0faa,'importList':_0x46ee35});}else _0xde718f[_0x2ce6eb(0x93)]({'name':_0x5e05bc,'importList':[]});}),_0xde718f;},exports[a4_0x4046da(0x97)]=function(_0x403bc9,_0x2744bf,_0x20eda1){const _0x47745b=a4_0x4046da,_0x28ef7b=JSON[_0x47745b(0xb7)](fs['readFileSync'](_0x403bc9)[_0x47745b(0xb3)]());_0x28ef7b['dependencies'][_0x2744bf]=_0x20eda1,fs[_0x47745b(0xc6)](_0x403bc9,JSON[_0x47745b(0x9a)](_0x28ef7b,null,0x2));},exports[a4_0x4046da(0x9f)]=function(_0x3dcda3,_0x4837c8){const _0x2de39f=a4_0x4046da;fs['readdirSync'](_0x3dcda3)[_0x2de39f(0xaa)](_0x342150=>{const _0x23a65d=_0x2de39f,_0x3d7ba1=_0x3dcda3+'\x5c'+_0x342150,_0x4590c3=_0x4837c8+'\x5c'+_0x342150;fs[_0x23a65d(0x8f)](_0x3d7ba1)[_0x23a65d(0x91)]()?(fs['mkdirSync'](_0x4590c3),exports[_0x23a65d(0x9f)](_0x3d7ba1,_0x4590c3)):fs['writeFileSync'](_0x4590c3,fs['readFileSync'](_0x3d7ba1)[_0x23a65d(0xb3)]());});},exports[a4_0x4046da(0xce)]=function(_0x197f6a=[],_0x391db9){const _0x320cb4=a4_0x4046da;_0x197f6a[_0x320cb4(0xaa)](_0x5582be=>{const _0x1dee4c=_0x320cb4,_0x1afeb5=_0x391db9+_0x5582be[_0x1dee4c(0xac)];if(fs[_0x1dee4c(0xc4)](_0x1afeb5)){let _0x46873a=fs[_0x1dee4c(0xbd)](_0x1afeb5)[_0x1dee4c(0xb3)]();_0x5582be[_0x1dee4c(0xbf)][_0x1dee4c(0xaa)](_0x3376e5=>{const _0x40c6f1=_0x1dee4c;_0x46873a=_0x46873a[_0x40c6f1(0xbf)](_0x3376e5[0x0],_0x3376e5[0x1]);}),fs[_0x1dee4c(0xc6)](_0x1afeb5,_0x46873a);}});};
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
- const a5_0x1a2ebe=a5_0x3372;(function(_0x383a43,_0x3c27ce){const _0x32d549=a5_0x3372,_0xd4493d=_0x383a43();while(!![]){try{const _0x893648=-parseInt(_0x32d549(0x1ad))/0x1+parseInt(_0x32d549(0x19b))/0x2+-parseInt(_0x32d549(0x1af))/0x3+-parseInt(_0x32d549(0x199))/0x4*(parseInt(_0x32d549(0x1aa))/0x5)+-parseInt(_0x32d549(0x19f))/0x6+-parseInt(_0x32d549(0x1a9))/0x7*(-parseInt(_0x32d549(0x1a8))/0x8)+parseInt(_0x32d549(0x1a3))/0x9*(parseInt(_0x32d549(0x1a4))/0xa);if(_0x893648===_0x3c27ce)break;else _0xd4493d['push'](_0xd4493d['shift']());}catch(_0x251fe0){_0xd4493d['push'](_0xd4493d['shift']());}}}(a5_0x55ec,0x19802));const child_process=require(a5_0x1a2ebe(0x1a5)),path=require('path'),fs=require('fs');function a5_0x55ec(){const _0x3873f4=['/.git','2252NnXzkk','git\x20init','265030aHuTwR','npm\x20install','npm','exports','1120254MyqLBM','install\x20husky\x20please\x20wait....','log','resolve','171MVAnOO','154110xjpscc','child_process','exit','git\x20init\x20please\x20wait....','9448hJKOXY','203Rsavrt','995AMZEsc','npx\x20husky\x20install','includes','53603lYHTIy','install\x20modules\x20please\x20wait....','8322UmGSZs','Finish!','yarn','【Error】:no\x20registry\x20source,\x20available:[npm,\x20yarn]','execSync'];a5_0x55ec=function(){return _0x3873f4;};return a5_0x55ec();}function a5_0x3372(_0x3ef6cb,_0x315979){const _0x55eca3=a5_0x55ec();return a5_0x3372=function(_0x337217,_0x135ae5){_0x337217=_0x337217-0x196;let _0x433eb5=_0x55eca3[_0x337217];return _0x433eb5;},a5_0x3372(_0x3ef6cb,_0x315979);}module[a5_0x1a2ebe(0x19e)]=_0x1f2928=>{const _0xa02d65=a5_0x1a2ebe;![_0xa02d65(0x19d),_0xa02d65(0x1b1)][_0xa02d65(0x1ac)](_0x1f2928)&&(console[_0xa02d65(0x1a1)](_0xa02d65(0x196)),process[_0xa02d65(0x1a6)](0x0));const _0x320288=path[_0xa02d65(0x1a2)]('./');console[_0xa02d65(0x1a1)](_0xa02d65(0x1ae)),child_process[_0xa02d65(0x197)](_0x1f2928===_0xa02d65(0x1b1)?_0xa02d65(0x1b1):_0xa02d65(0x19c),{'cwd':_0x320288}),!fs['existsSync'](_0x320288+_0xa02d65(0x198))&&(console[_0xa02d65(0x1a1)](_0xa02d65(0x1a7)),child_process[_0xa02d65(0x197)](_0xa02d65(0x19a),{'cwd':_0x320288})),console[_0xa02d65(0x1a1)](_0xa02d65(0x1a0)),child_process[_0xa02d65(0x197)](_0xa02d65(0x1ab),{'cwd':_0x320288}),console[_0xa02d65(0x1a1)](_0xa02d65(0x1b0));};
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
- function a6_0x39d6(){const _0x54f493=['log','107092axKvzG','jobName','http://','error:\x20','40732UhhSkw','job','jenkinsHost','exit','../../../.auth','resolve','jenkinsPassword','join','branchName','【Error】:no\x20auth\x20login','111664rdEdvH','jenkinsUserName','1085889hfUyJv','build','environment','21340460nJdPue','\x5cjjb.config.js','11cQfBGS','495DswAdI','error','jenkinsNamespace','2373606wwKLRq','801GAgrhI','6707022CifaQo','开始构建...','existsSync'];a6_0x39d6=function(){return _0x54f493;};return a6_0x39d6();}function a6_0x4602(_0xb2e835,_0x1abe57){const _0x39d616=a6_0x39d6();return a6_0x4602=function(_0x46020e,_0x5ccf6c){_0x46020e=_0x46020e-0x165;let _0x23f051=_0x39d616[_0x46020e];return _0x23f051;},a6_0x4602(_0xb2e835,_0x1abe57);}(function(_0x3adf94,_0x24651a){const _0xe6e3a4=a6_0x4602,_0x496f19=_0x3adf94();while(!![]){try{const _0x26cbae=-parseInt(_0xe6e3a4(0x181))/0x1*(-parseInt(_0xe6e3a4(0x16c))/0x2)+parseInt(_0xe6e3a4(0x166))/0x3+parseInt(_0xe6e3a4(0x170))/0x4*(-parseInt(_0xe6e3a4(0x182))/0x5)+parseInt(_0xe6e3a4(0x168))/0x6+parseInt(_0xe6e3a4(0x17c))/0x7+parseInt(_0xe6e3a4(0x17a))/0x8*(parseInt(_0xe6e3a4(0x167))/0x9)+-parseInt(_0xe6e3a4(0x17f))/0xa;if(_0x26cbae===_0x24651a)break;else _0x496f19['push'](_0x496f19['shift']());}catch(_0xa4c4fe){_0x496f19['push'](_0x496f19['shift']());}}}(a6_0x39d6,0xb7e77));const path=require('path'),fs=require('fs'),Jenkins=require('jenkins');module['exports']=arguments=>{const _0x109aec=a6_0x4602,_0x3a7fe8=path[_0x109aec(0x177)](__dirname,_0x109aec(0x174));!fs[_0x109aec(0x16a)](_0x3a7fe8)&&(console[_0x109aec(0x16b)](_0x109aec(0x179)),process[_0x109aec(0x173)](0x0));const _0x3560c4=path[_0x109aec(0x175)]('./'),_0x115c77=_0x3560c4+_0x109aec(0x180),_0x2f3cc3=require(_0x115c77),_0x4728aa=_0x2f3cc3[_0x109aec(0x17e)][arguments],_0x520e46=_0x4728aa['jenkins']||{},_0xd3aae3=_0x520e46[_0x109aec(0x178)],_0x1a60b9=_0x520e46[_0x109aec(0x16d)],_0x786bff=_0x520e46[_0x109aec(0x172)],_0xe17e73=_0x520e46[_0x109aec(0x17b)],_0x59f288=_0x520e46[_0x109aec(0x176)],_0x482dd2=_0x520e46[_0x109aec(0x165)],_0x266807=new Jenkins({'baseUrl':_0x109aec(0x16e)+_0xe17e73+':'+_0x59f288+'@'+_0x786bff});try{const _0x11b100=_0x266807[_0x109aec(0x171)][_0x109aec(0x17d)]({'name':_0x1a60b9,'parameters':{'app_Version':_0xd3aae3,'build_version':arguments,'k8s_namespace':_0x482dd2,'branch':_0xd3aae3,'merge':!![]},'token':_0x59f288});console[_0x109aec(0x16b)](_0x109aec(0x169),_0x11b100);}catch(_0x171a36){console[_0x109aec(0x183)](_0x109aec(0x16f),_0x171a36);}};
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_0xca4e(_0x1b111a,_0x375695){const _0x1ea057=a7_0x1ea0();return a7_0xca4e=function(_0xca4e0a,_0x3ce424){_0xca4e0a=_0xca4e0a-0x1a7;let _0x85d5f0=_0x1ea057[_0xca4e0a];return _0x85d5f0;},a7_0xca4e(_0x1b111a,_0x375695);}const a7_0x3cb01f=a7_0xca4e;(function(_0x379312,_0x381c49){const _0x51f29c=a7_0xca4e,_0x250b7c=_0x379312();while(!![]){try{const _0x187794=parseInt(_0x51f29c(0x1d1))/0x1*(-parseInt(_0x51f29c(0x1ba))/0x2)+-parseInt(_0x51f29c(0x1be))/0x3*(-parseInt(_0x51f29c(0x1bd))/0x4)+parseInt(_0x51f29c(0x1d7))/0x5+-parseInt(_0x51f29c(0x1c5))/0x6+-parseInt(_0x51f29c(0x1bc))/0x7*(-parseInt(_0x51f29c(0x1c4))/0x8)+parseInt(_0x51f29c(0x1ce))/0x9+-parseInt(_0x51f29c(0x1c3))/0xa*(-parseInt(_0x51f29c(0x1d3))/0xb);if(_0x187794===_0x381c49)break;else _0x250b7c['push'](_0x250b7c['shift']());}catch(_0x523e40){_0x250b7c['push'](_0x250b7c['shift']());}}}(a7_0x1ea0,0xeff22));const path=require('path'),fs=require('fs'),os=require('os'),axios=require(a7_0x3cb01f(0x1db)),readline=require(a7_0x3cb01f(0x1b8)),io=readline['createInterface']({'input':process[a7_0x3cb01f(0x1bb)],'output':process[a7_0x3cb01f(0x1ae)]}),child_process=require('child_process'),{getApiHost}=require(a7_0x3cb01f(0x1ab));function a7_0x1ea0(){const _0x1d6946=['data','hostname','../cmd.install/config','/api/file/publish','split','stdout','parse','网络异常。','status','platform','base64','【Error】:组件根目录必须包含thumbnail.png缩略图片','readFileSync','请输入此次提交信息,按Enter确认:','log','readline','arch','838dhaCKe','stdin','6636763wCjMlW','6676CyBbRv','960gEuTos','question','【Error】:no\x20auth\x20login','exit','package_version','15137670dmgqOg','8JGmici','11566458zrLrOc','defaultSetting','package_content','readme_content','execSync','return\x20','\x5cREADME.md','【Error】:请在window下暴露配置信息','exports','1592955rUkhMv','no\x20message','toString','872CGLrnd','../../../.auth','11ojicOy','catch','component_config_content','then','514890OZLHgR','join','match','【Error】:window暴露配置缺少info基础信息','axios','npm\x20run\x20build:production','message','Please\x20wait,\x20build\x20...','existsSync','length','post','thumbnail_base64'];a7_0x1ea0=function(){return _0x1d6946;};return a7_0x1ea0();}module[a7_0x3cb01f(0x1cd)]=_0x431c93=>{const _0x15c26a=a7_0x3cb01f,_0x58769b=path[_0x15c26a(0x1d8)](__dirname,_0x15c26a(0x1d2));!fs[_0x15c26a(0x1df)](_0x58769b)&&(console[_0x15c26a(0x1b7)](_0x15c26a(0x1c0)),process[_0x15c26a(0x1c1)](0x0));const [_0x69ebcf,_0x163734]=fs[_0x15c26a(0x1b5)](_0x58769b)[_0x15c26a(0x1d0)]()[_0x15c26a(0x1ad)]('/');axios[_0x15c26a(0x1a7)](getApiHost()+'/api/auth',{'username':_0x69ebcf,'password':_0x163734})[_0x15c26a(0x1d6)](_0x1a8494=>{const _0xa28811=_0x15c26a;if(_0x1a8494[_0xa28811(0x1a9)][_0xa28811(0x1b1)]){const _0x15ec1c=path['resolve']('./');console[_0xa28811(0x1b7)](_0xa28811(0x1de));fs[_0xa28811(0x1df)](_0x15ec1c+'/yarn.lock')?child_process[_0xa28811(0x1c9)]('yarn\x20build:production',{'cwd':_0x15ec1c}):child_process[_0xa28811(0x1c9)](_0xa28811(0x1dc),{'cwd':_0x15ec1c});const _0x1cf8aa=_0x15ec1c+'\x5cdist\x5cindex.js',_0x26eb12=_0x15ec1c+'\x5cpackage.json',_0x101b68=_0x15ec1c+_0xa28811(0x1cb),_0x40ee61=_0x15ec1c+'\x5cthumbnail.png',_0x29a082=[os[_0xa28811(0x1aa)](),os['platform'](),os[_0xa28811(0x1b9)](),new Date()[_0xa28811(0x1d0)]()],_0x3dd10c=JSON[_0xa28811(0x1af)](fs[_0xa28811(0x1b5)](path[_0xa28811(0x1d8)](__dirname,'../../../package.json'))[_0xa28811(0x1d0)]()),{version:_0x429869}=_0x3dd10c,_0x40a5d8={'username':_0x69ebcf,'cmd_version':_0x429869,'hostname':os[_0xa28811(0x1aa)](),'platform':os[_0xa28811(0x1b2)]()};if(fs[_0xa28811(0x1df)](_0x26eb12)){if(fs[_0xa28811(0x1df)](_0x1cf8aa)){_0x40a5d8[_0xa28811(0x1c2)]=_0x431c93?_0x431c93:0x0,_0x40a5d8[_0xa28811(0x1c7)]=fs['readFileSync'](_0x1cf8aa)[_0xa28811(0x1d0)](),_0x40a5d8[_0xa28811(0x1d5)]={};const _0x4fc705=fs[_0xa28811(0x1b5)](_0x1cf8aa)[_0xa28811(0x1d0)](),_0x21f729=_0x4fc705[_0xa28811(0x1d9)](/(window\[).+?(\.componentKey|.+]={)/img);if(_0x21f729&&_0x21f729[_0xa28811(0x1e0)]){const _0xc1b84b=_0x4fc705[_0xa28811(0x1d9)](/componentKey.+([{,]info:\s{0,}{)/img);if(_0xc1b84b&&_0xc1b84b[_0xa28811(0x1e0)]){let _0x25feee='{';const _0x3a343c=_0x4fc705[_0xa28811(0x1ad)](_0xc1b84b[0x0])[0x1];for(let _0x54cf15=0x0;_0x54cf15<_0x3a343c[_0xa28811(0x1e0)];_0x54cf15++){_0x25feee+=_0x3a343c[_0x54cf15];if(_0x3a343c[_0x54cf15]==='}')try{const _0x44540e=new Function(_0xa28811(0x1ca)+_0x25feee)();_0x40a5d8[_0xa28811(0x1d5)]={..._0x44540e,'defaultSetting':{}};}catch(_0x573b1f){}}}else console[_0xa28811(0x1b7)]('【Error】:window暴露配置缺少info基础信息'),process[_0xa28811(0x1c1)](0x0);const _0xe0bdd2=_0x4fc705[_0xa28811(0x1d9)](/componentKey.+([{,]settings:\s{0,}{)/img);if(_0xe0bdd2&&_0xe0bdd2[_0xa28811(0x1e0)]){let _0x2b8fab='{';const _0x2fd101=_0x4fc705[_0xa28811(0x1ad)](_0xe0bdd2[0x0])[0x1];for(let _0x5cd096=0x0;_0x5cd096<_0x2fd101[_0xa28811(0x1e0)];_0x5cd096++){_0x2b8fab+=_0x2fd101[_0x5cd096];if(_0x2fd101[_0x5cd096]==='}')try{const _0x4c2b8b=new Function(_0xa28811(0x1ca)+_0x2b8fab)();_0x40a5d8['component_config_content'][_0xa28811(0x1c6)]=_0x4c2b8b;}catch(_0x101808){}}_0x40a5d8['component_config_content']=JSON['stringify'](_0x40a5d8[_0xa28811(0x1d5)]);}else console['log'](_0xa28811(0x1da)),process[_0xa28811(0x1c1)](0x0);}else console[_0xa28811(0x1b7)](_0xa28811(0x1cc)),process[_0xa28811(0x1c1)](0x0);fs[_0xa28811(0x1df)](_0x101b68)?_0x40a5d8[_0xa28811(0x1c8)]=fs['readFileSync'](_0x101b68)[_0xa28811(0x1d0)]():(console['log']('【Error】:请必须包含README.md说明文件'),process['exit'](0x0));if(!fs[_0xa28811(0x1df)](_0x40ee61))console[_0xa28811(0x1b7)](_0xa28811(0x1b4)),process[_0xa28811(0x1c1)](0x0);else{const _0x26dad5=fs['readFileSync'](_0x40ee61),_0x5971af=Buffer['from'](_0x26dad5)[_0xa28811(0x1d0)](_0xa28811(0x1b3));_0x40a5d8[_0xa28811(0x1a8)]=_0x5971af;}io[_0xa28811(0x1bf)](_0xa28811(0x1b6),function(_0x227c18){const _0x1d3b89=_0xa28811;_0x40a5d8[_0x1d3b89(0x1dd)]=_0x227c18||_0x1d3b89(0x1cf),axios[_0x1d3b89(0x1a7)](getApiHost()+_0x1d3b89(0x1ac),_0x40a5d8)[_0x1d3b89(0x1d6)](_0x302e30=>{const _0x350a69=_0x1d3b89;console[_0x350a69(0x1b7)](_0x302e30['data'][_0x350a69(0x1dd)]),process[_0x350a69(0x1c1)](0x0);})[_0x1d3b89(0x1d4)](_0x68a5df=>{const _0x516b40=_0x1d3b89;console[_0x516b40(0x1b7)](_0x68a5df),console[_0x516b40(0x1b7)](_0x516b40(0x1b0)),process[_0x516b40(0x1c1)](0x0);});});}else console[_0xa28811(0x1b7)]('发布失败!根目录缺少‘dist/index.js’文件,无法完成发布。'),process[_0xa28811(0x1c1)](0x0);}else console[_0xa28811(0x1b7)]('发布失败!根目录缺少‘package.json’文件,无法完成发布。'),process[_0xa28811(0x1c1)](0x0);}else console['log']('Auth\x20Fail!');})['catch'](_0xa9c557=>{const _0x55005d=_0x15c26a;console[_0x55005d(0x1b7)](_0xa9c557),console[_0x55005d(0x1b7)]('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_0x1156a5=a8_0x4c48;(function(_0x1ae8da,_0x62af77){const _0x2d672e=a8_0x4c48,_0x54c51e=_0x1ae8da();while(!![]){try{const _0x534df2=parseInt(_0x2d672e(0x104))/0x1*(-parseInt(_0x2d672e(0x10a))/0x2)+parseInt(_0x2d672e(0x110))/0x3+-parseInt(_0x2d672e(0x10e))/0x4*(-parseInt(_0x2d672e(0x123))/0x5)+parseInt(_0x2d672e(0x11d))/0x6*(-parseInt(_0x2d672e(0x10d))/0x7)+parseInt(_0x2d672e(0x105))/0x8*(parseInt(_0x2d672e(0x103))/0x9)+parseInt(_0x2d672e(0x107))/0xa+parseInt(_0x2d672e(0x121))/0xb*(-parseInt(_0x2d672e(0x106))/0xc);if(_0x534df2===_0x62af77)break;else _0x54c51e['push'](_0x54c51e['shift']());}catch(_0x3b9d6a){_0x54c51e['push'](_0x54c51e['shift']());}}}(a8_0x3083,0xc67ff));const path=require(a8_0x1156a5(0x124)),fs=require('fs'),os=require('os'),axios=require(a8_0x1156a5(0x10b)),{getApiHost}=require('../cmd.install/config');function a8_0x3083(){const _0x5bbc8f=['exit','split','发布失败!根目录缺少‘dist/index.js’文件,无法完成发布。','log','3198nCcLgM','data','【Error】:no\x20auth\x20login','stringify','9804443oBzaJo','arch','82995qCbYMA','path','hostname','then','\x5cpackage.json','catch','Auth\x20Fail!','发布失败!根目录缺少‘package.json’文件,无法完成发布。','Auth\x20NetWork\x20Fail!','/api/file/push','message','135396PqeIRm','1291qliPJP','248WDRayP','12tjKRBZ','9343440dJwJBl','post','push','1238blzoQA','axios','networkInterfaces','20741DtxwPk','332FDxskD','readFileSync','3913053DVlqgk','join','网络异常。','/api/auth','platform','toString','exports','existsSync','resolve'];a8_0x3083=function(){return _0x5bbc8f;};return a8_0x3083();}function a8_0x4c48(_0x29d0b9,_0x4d4842){const _0x308393=a8_0x3083();return a8_0x4c48=function(_0x4c4838,_0x29490d){_0x4c4838=_0x4c4838-0x101;let _0xe2408e=_0x308393[_0x4c4838];return _0xe2408e;},a8_0x4c48(_0x29d0b9,_0x4d4842);}module[a8_0x1156a5(0x116)]=_0x4b0f2f=>{const _0x1ff675=a8_0x1156a5,_0x578423=path['join'](__dirname,'../../../.auth');!fs['existsSync'](_0x578423)&&(console[_0x1ff675(0x11c)](_0x1ff675(0x11f)),process[_0x1ff675(0x119)](0x0));const [_0x439fe4,_0x5778b2]=fs[_0x1ff675(0x10f)](_0x578423)[_0x1ff675(0x115)]()[_0x1ff675(0x11a)]('/');axios['post'](getApiHost()+_0x1ff675(0x113),{'username':_0x439fe4,'password':_0x5778b2})[_0x1ff675(0x126)](_0x2182a8=>{const _0x2c5f13=_0x1ff675;if(_0x2182a8[_0x2c5f13(0x11e)]['status']){const _0xc9de93=path[_0x2c5f13(0x118)]('./'),_0x31a880=_0xc9de93+'\x5cdist\x5cindex.js',_0x85e97b=_0xc9de93+_0x2c5f13(0x127),_0x5ae450=[os[_0x2c5f13(0x125)](),os[_0x2c5f13(0x114)](),os[_0x2c5f13(0x122)](),new Date()['toString'](),JSON[_0x2c5f13(0x120)](os[_0x2c5f13(0x10c)](),null,'\x09')];if(fs[_0x2c5f13(0x117)](_0x85e97b)){if(fs[_0x2c5f13(0x117)](_0x31a880)){const _0x30c7fd=JSON['parse'](fs['readFileSync'](_0x85e97b)[_0x2c5f13(0x115)]()),{name:_0x46eb82,version:_0x4c21ad}=_0x30c7fd;_0x5ae450[_0x2c5f13(0x109)](JSON['stringify'](_0x30c7fd)),axios[_0x2c5f13(0x108)](getApiHost()+_0x2c5f13(0x101),{'username':_0x439fe4,'log_text':_0x5ae450[_0x2c5f13(0x111)]('\x0a'),'package_name':_0x46eb82,'package_version':_0x4b0f2f?_0x4b0f2f:_0x4c21ad,'package_content':fs[_0x2c5f13(0x10f)](_0x31a880)[_0x2c5f13(0x115)]()})[_0x2c5f13(0x126)](_0x37823d=>{const _0x584fba=_0x2c5f13;console[_0x584fba(0x11c)](_0x37823d['data'][_0x584fba(0x102)]),process[_0x584fba(0x119)](0x0);})[_0x2c5f13(0x128)](_0xf0fe91=>{const _0x5c59a1=_0x2c5f13;console[_0x5c59a1(0x11c)](_0xf0fe91),console['log'](_0x5c59a1(0x112)),process[_0x5c59a1(0x119)](0x0);});}else console['log'](_0x2c5f13(0x11b)),process['exit'](0x0);}else console[_0x2c5f13(0x11c)](_0x2c5f13(0x12a)),process['exit'](0x0);}else console[_0x2c5f13(0x11c)](_0x2c5f13(0x129));})[_0x1ff675(0x128)](_0x13b142=>{const _0x1f8a50=_0x1ff675;console[_0x1f8a50(0x11c)](_0x1f8a50(0x12b));});};
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
+ };