biz-a-cli 2.3.9 → 2.3.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/uploadApp.js +47 -12
- package/envs/env.dev.js +1 -1
- package/envs/env.js +2 -1
- package/package.json +2 -2
package/bin/uploadApp.js
CHANGED
|
@@ -5,7 +5,7 @@ import axios from "axios";
|
|
|
5
5
|
import { promises as fs } from "fs";
|
|
6
6
|
import { runInNewContext, runInThisContext } from "vm";
|
|
7
7
|
import uglify from "uglify-js";
|
|
8
|
-
import tar from "tar";
|
|
8
|
+
import * as tar from "tar";
|
|
9
9
|
import {statSync, readFileSync} from 'fs';
|
|
10
10
|
import { verify, sign, privateDecrypt, constants as cryptoConstants, randomBytes, createCipheriv } from 'node:crypto';
|
|
11
11
|
import { basename } from "node:path"
|
|
@@ -159,7 +159,32 @@ const encryptIt = (data, encryptKey)=>{
|
|
|
159
159
|
return Buffer.concat([initializeVector, cipher.update(data), cipher.final()]) // we put "iv" at beginning of cipherText, seperate it when doing decryption
|
|
160
160
|
}
|
|
161
161
|
|
|
162
|
+
const compressIt = async (fileName, folderPath)=>{
|
|
163
|
+
let compressSuccess = false
|
|
164
|
+
const maxRetry = 10
|
|
165
|
+
let retryCount = 0
|
|
166
|
+
do {
|
|
167
|
+
tar.c({file: fileName, cwd: folderPath, gzip: {level:9}, strict: true, sync: true}, await fs.readdir(folderPath))
|
|
168
|
+
compressSuccess = true
|
|
169
|
+
tar.t({file: fileName, cwd: folderPath, sync: true, onentry: (entry)=>{
|
|
170
|
+
if (entry.size==0) {
|
|
171
|
+
compressSuccess = false
|
|
172
|
+
}
|
|
173
|
+
}})
|
|
174
|
+
if (compressSuccess==false) {
|
|
175
|
+
await fs.unlink(fileName)
|
|
176
|
+
retryCount++
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
while ((compressSuccess==false) && (retryCount<=maxRetry))
|
|
180
|
+
}
|
|
181
|
+
|
|
162
182
|
const uploadTemplateApps = async () => {
|
|
183
|
+
/*
|
|
184
|
+
hex => 2 char = 1 bytes => can be encrypted
|
|
185
|
+
base64 => 4 char = 3 bytes => can be encrypted. Smaller size compare to Hex
|
|
186
|
+
utf8 => 1 char = 1 - 4 bytes => can not be encrypted, encryption need precise bytes per Character. Smallest Size compare to Hex and base64
|
|
187
|
+
*/
|
|
163
188
|
process.chdir(options.workingDir)
|
|
164
189
|
try {
|
|
165
190
|
const bundlingStart = performance.now()
|
|
@@ -180,11 +205,6 @@ const uploadTemplateApps = async () => {
|
|
|
180
205
|
// if (['finalib.js', 'solib.js'].indexOf(fileName)==-1) {continue}
|
|
181
206
|
const minifiedData = await getFileMinifiedData(fileName);
|
|
182
207
|
const encryptedData = encryptIt(minifiedData, keys.encryptKey)
|
|
183
|
-
/*
|
|
184
|
-
hex => 2 char = 1 bytes => can be encrypted
|
|
185
|
-
base64 => 4 char = 3 bytes => can be encrypted. Smaller size compare to Hex
|
|
186
|
-
utf8 => 1 char = 1 - 4 bytes => can not be encrypted, encryption need precise bytes per Character. Smallest Size compare to Hex and base64
|
|
187
|
-
*/
|
|
188
208
|
if (fileName=='menu.json') {
|
|
189
209
|
keys.metadata['menu'] = encryptedData.toString('base64')
|
|
190
210
|
} else {
|
|
@@ -192,11 +212,8 @@ const uploadTemplateApps = async () => {
|
|
|
192
212
|
}
|
|
193
213
|
processedFile++
|
|
194
214
|
}
|
|
195
|
-
|
|
196
|
-
// compressor
|
|
197
215
|
const bundleFile = `${rootFolder}${bundleName}.tgz`
|
|
198
|
-
|
|
199
|
-
await fs.rm(bundleFolder, {force: true, recursive: true})
|
|
216
|
+
await compressIt(bundleFile, bundleFolder)
|
|
200
217
|
console.log(`Finished packing ${processedFile} files into "${bundleFile}" (${((performance.now()-bundlingStart)/1000).toFixed(2)}s)`)
|
|
201
218
|
|
|
202
219
|
// send to FINAPI
|
|
@@ -221,8 +238,26 @@ const uploadTemplateApps = async () => {
|
|
|
221
238
|
}
|
|
222
239
|
}
|
|
223
240
|
|
|
224
|
-
uploadTemplateApps()
|
|
241
|
+
await uploadTemplateApps()
|
|
242
|
+
|
|
243
|
+
/* const testCompressor = async ()=>{
|
|
244
|
+
const loopCount = 10000
|
|
245
|
+
let errorCount = 0
|
|
246
|
+
for(var i=1; i<=loopCount;i++){
|
|
247
|
+
console.log(i);
|
|
248
|
+
await uploadTemplateApps()
|
|
249
|
+
tar.t({file:'upload/spos.tgz', onentry: (entry)=>{
|
|
250
|
+
if (entry.size==0) {
|
|
251
|
+
console.log(`${i} : Empty file found...`, entry.type, entry.path, entry.size)
|
|
252
|
+
errorCount++
|
|
253
|
+
}
|
|
254
|
+
}})
|
|
255
|
+
}
|
|
256
|
+
console.log(`${errorCount} error of ${loopCount}`)
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
testCompressor() */
|
|
225
260
|
|
|
226
|
-
// uploadApp -s https://finaapi.imamatek.com
|
|
261
|
+
// uploadApp -s https://finaapi.imamatek.com -p 1205 -i 2 -d "C:\agung\source\biza templates\imamatek"
|
|
227
262
|
// ..\cli\bin\uploadApp.js -s https://finaapi.imamatek.com:1205 -i 2 -d "C:\agung\source\biza templates\imamatek"
|
|
228
263
|
// uploadApp -s https://finaapi.imamatek.com:1205 -i 2 -d ".\imamatek"
|
package/envs/env.dev.js
CHANGED
|
@@ -6,6 +6,6 @@ export const envDev = {
|
|
|
6
6
|
encodeURIComponent('imm@2019') + '@imm-cdm-dev.rf6wr.mongodb.net/?retryWrites=true&w=majority',
|
|
7
7
|
COMPANY_REGISTER: 'companyregister-dev',
|
|
8
8
|
// BIZA_SERVER_LINK: 'https://biz-a-dev-41e7c93a25e5.herokuapp.com'
|
|
9
|
-
BIZA_SERVER_LINK: '
|
|
9
|
+
BIZA_SERVER_LINK: 'http://localhost:3000'
|
|
10
10
|
// BIZA_SERVER_LINK: 'http://localhost:3000'
|
|
11
11
|
};
|
package/envs/env.js
CHANGED
|
@@ -5,5 +5,6 @@ export const env = {
|
|
|
5
5
|
CDM_MONGO_LINK: 'mongodb+srv://imm_cdm:' +
|
|
6
6
|
encodeURIComponent('imm@2019') + '@imm-cdm.ohcqt.mongodb.net/?retryWrites=true&w=majority',
|
|
7
7
|
COMPANY_REGISTER: 'companyregister',
|
|
8
|
-
BIZA_SERVER_LINK: 'https://biz-a.herokuapp.com'
|
|
8
|
+
// BIZA_SERVER_LINK: 'https://biz-a.herokuapp.com'
|
|
9
|
+
BIZA_SERVER_LINK: 'http://localhost:3000'
|
|
9
10
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "biz-a-cli",
|
|
3
3
|
"nameDev": "biz-a-cli-dev",
|
|
4
|
-
"version": "2.3.
|
|
4
|
+
"version": "2.3.10",
|
|
5
5
|
"versionDev": "0.0.27",
|
|
6
6
|
"description": "",
|
|
7
7
|
"main": "bin/index.js",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"socket.io-client": "^4.7.5",
|
|
39
39
|
"socket.io-stream": "^0.9.1",
|
|
40
40
|
"web-push": "^3.6.7",
|
|
41
|
-
"tar": "^
|
|
41
|
+
"tar": "^7.1.0",
|
|
42
42
|
"uglify-js": "^3.17.4",
|
|
43
43
|
"yargs": "^17.7.2"
|
|
44
44
|
},
|