@bprotsyk/aso-core 2.0.52 → 2.0.53
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/lib/utils/server-util.js
CHANGED
|
@@ -10,7 +10,7 @@ const ssh2_sftp_client_1 = __importDefault(require("ssh2-sftp-client"));
|
|
|
10
10
|
const fs_1 = __importDefault(require("fs"));
|
|
11
11
|
const mustache_1 = __importDefault(require("mustache"));
|
|
12
12
|
const path_1 = __importDefault(require("path"));
|
|
13
|
-
|
|
13
|
+
const unzipper_1 = __importDefault(require("unzipper"));
|
|
14
14
|
const { promisify } = require("util");
|
|
15
15
|
const execPromise = promisify(child_process_1.default.exec);
|
|
16
16
|
exports.IP = "185.123.53.227";
|
|
@@ -248,23 +248,21 @@ class ServerUtil {
|
|
|
248
248
|
}
|
|
249
249
|
try {
|
|
250
250
|
await new Promise((resolve, reject) => {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
// .on('close', resolve)
|
|
267
|
-
// .on('error', reject);
|
|
251
|
+
fs_1.default.createReadStream(zipFilePath)
|
|
252
|
+
.pipe(unzipper_1.default.Parse())
|
|
253
|
+
.on('entry', (entry) => {
|
|
254
|
+
// Видаляємо перший сегмент шляху, щоб уникнути кореневої директорії
|
|
255
|
+
const entryPath = path_1.default.join(outputDir, ...entry.path.split('/').slice(1));
|
|
256
|
+
if (entry.type === 'Directory') {
|
|
257
|
+
this.ensureDirectoryExistence(entryPath);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
this.ensureDirectoryExistence(path_1.default.dirname(entryPath));
|
|
261
|
+
entry.pipe(fs_1.default.createWriteStream(entryPath));
|
|
262
|
+
}
|
|
263
|
+
})
|
|
264
|
+
.on('close', resolve)
|
|
265
|
+
.on('error', reject);
|
|
268
266
|
});
|
|
269
267
|
console.log('File successfully extracted.');
|
|
270
268
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bprotsyk/aso-core",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.53",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"types": "lib/index.d.ts",
|
|
6
6
|
"scripts": {
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"@types/mongoose": "^5.11.97",
|
|
28
28
|
"@types/node-ssh": "^7.0.6",
|
|
29
29
|
"@types/styled-components": "^5.1.26",
|
|
30
|
+
"@types/unzipper": "^0.10.10",
|
|
30
31
|
"axios": "^1.4.0",
|
|
31
32
|
"module-alias": "^2.2.2",
|
|
32
33
|
"mongoose": "^6.8.3",
|
package/src/utils/server-util.ts
CHANGED
|
@@ -4,7 +4,7 @@ import Client from "ssh2-sftp-client";
|
|
|
4
4
|
import fs from "fs";
|
|
5
5
|
import mustache from "mustache";
|
|
6
6
|
import path from "path";
|
|
7
|
-
|
|
7
|
+
import unzipper from 'unzipper';
|
|
8
8
|
|
|
9
9
|
const { promisify } = require("util");
|
|
10
10
|
const execPromise = promisify(ChildProcess.exec);
|
|
@@ -315,24 +315,24 @@ export class ServerUtil {
|
|
|
315
315
|
|
|
316
316
|
try {
|
|
317
317
|
await new Promise((resolve, reject) => {
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
318
|
+
fs.createReadStream(zipFilePath)
|
|
319
|
+
.pipe(unzipper.Parse())
|
|
320
|
+
.on('entry', (entry) => {
|
|
321
|
+
// Видаляємо перший сегмент шляху, щоб уникнути кореневої директорії
|
|
322
|
+
const entryPath = path.join(
|
|
323
|
+
outputDir,
|
|
324
|
+
...entry.path.split('/').slice(1)
|
|
325
|
+
);
|
|
326
|
+
|
|
327
|
+
if (entry.type === 'Directory') {
|
|
328
|
+
this.ensureDirectoryExistence(entryPath);
|
|
329
|
+
} else {
|
|
330
|
+
this.ensureDirectoryExistence(path.dirname(entryPath));
|
|
331
|
+
entry.pipe(fs.createWriteStream(entryPath));
|
|
332
|
+
}
|
|
333
|
+
})
|
|
334
|
+
.on('close', resolve)
|
|
335
|
+
.on('error', reject);
|
|
336
336
|
});
|
|
337
337
|
|
|
338
338
|
console.log('File successfully extracted.');
|