@matterbridge/thread 3.11.2 → 3.11.3-dev-20261109-ca46ffb
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/dist/workerArchiveCommand.js +12 -6
- package/dist/zipjs.d.ts +1 -1
- package/dist/zipjs.js +3 -3
- package/package.json +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isArchiveWorkerData } from '@matterbridge/types';
|
|
2
|
+
import { getErrorMessage } from '@matterbridge/utils/error';
|
|
2
3
|
import { logModuleLoaded } from '@matterbridge/utils/loader';
|
|
3
4
|
import { ThreadsWrapper } from './threadsWrapper.js';
|
|
4
5
|
import { createZip, readZip, unZip } from './zipjs.js';
|
|
@@ -10,12 +11,17 @@ export default new ThreadsWrapper('ArchiveCommand', async (worker) => {
|
|
|
10
11
|
}
|
|
11
12
|
worker.logger("info", `Starting archive command ${worker.workerData.command} on ${worker.workerData.archivePath} with source paths ${worker.workerData.sourcePaths.join(', ')} and destination path ${worker.workerData.destinationPath}...`);
|
|
12
13
|
let success = false;
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
try {
|
|
15
|
+
if (worker.workerData.command === 'zip')
|
|
16
|
+
success = (await createZip(worker.workerData.archivePath, worker.workerData.sourcePaths, worker.workerData.archiveNames)) > 0;
|
|
17
|
+
else if (worker.workerData.command === 'verify')
|
|
18
|
+
success = (await readZip(worker.workerData.archivePath)).length > 0;
|
|
19
|
+
else if (worker.workerData.command === 'unzip')
|
|
20
|
+
success = (await unZip(worker.workerData.archivePath, worker.workerData.destinationPath)).length > 0;
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
worker.logger("error", `Archive command ${worker.workerData.command} on ${worker.workerData.archivePath} error: ${getErrorMessage(error)}`);
|
|
24
|
+
}
|
|
19
25
|
if (success)
|
|
20
26
|
worker.logger("info", `Archive command ${worker.workerData.command} on ${worker.workerData.archivePath} with source paths ${worker.workerData.sourcePaths.join(', ')} and destination path ${worker.workerData.destinationPath} executed successfully`);
|
|
21
27
|
else
|
package/dist/zipjs.d.ts
CHANGED
|
@@ -5,6 +5,6 @@ export interface ZipContentEntry {
|
|
|
5
5
|
uncompressedSize: number;
|
|
6
6
|
lastModDate: Date;
|
|
7
7
|
}
|
|
8
|
-
export declare function createZip(zipPath: string, sourcePaths: string[]): Promise<number>;
|
|
8
|
+
export declare function createZip(zipPath: string, sourcePaths: string[], archiveNames?: string[]): Promise<number>;
|
|
9
9
|
export declare function readZip(zipPath: string): Promise<ZipContentEntry[]>;
|
|
10
10
|
export declare function unZip(zipPath: string, destinationPath?: string): Promise<string>;
|
package/dist/zipjs.js
CHANGED
|
@@ -3,15 +3,15 @@ import path from 'node:path';
|
|
|
3
3
|
import { configure, Uint8ArrayReader, Uint8ArrayWriter, ZipReader, ZipWriter } from '@zip.js/zip.js';
|
|
4
4
|
import { AnsiLogger } from 'node-ansi-logger';
|
|
5
5
|
configure({ useWebWorkers: false });
|
|
6
|
-
export async function createZip(zipPath, sourcePaths) {
|
|
6
|
+
export async function createZip(zipPath, sourcePaths, archiveNames) {
|
|
7
7
|
if (sourcePaths.length === 0)
|
|
8
8
|
throw new Error('No files or directories provided to createZip.');
|
|
9
9
|
const log = createLogger();
|
|
10
10
|
const writer = new ZipWriter(new Uint8ArrayWriter());
|
|
11
11
|
let entryCount = 0;
|
|
12
|
-
for (const sourcePath of sourcePaths) {
|
|
12
|
+
for (const [index, sourcePath] of sourcePaths.entries()) {
|
|
13
13
|
const resolvedSourcePath = path.resolve(sourcePath);
|
|
14
|
-
entryCount += await addZipEntry(writer, resolvedSourcePath, path.basename(resolvedSourcePath), log);
|
|
14
|
+
entryCount += await addZipEntry(writer, resolvedSourcePath, archiveNames?.[index] ?? path.basename(resolvedSourcePath), log);
|
|
15
15
|
}
|
|
16
16
|
const zipData = await writer.close();
|
|
17
17
|
await mkdir(path.dirname(zipPath), { recursive: true });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@matterbridge/thread",
|
|
3
|
-
"version": "3.11.
|
|
3
|
+
"version": "3.11.3-dev-20261109-ca46ffb",
|
|
4
4
|
"description": "Matterbridge thread library",
|
|
5
5
|
"author": "https://github.com/Luligu",
|
|
6
6
|
"homepage": "https://matterbridge.io/",
|
|
@@ -80,8 +80,8 @@
|
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
82
|
"@matter/main": "0.18.0",
|
|
83
|
-
"@matterbridge/types": "3.11.
|
|
84
|
-
"@matterbridge/utils": "3.11.
|
|
83
|
+
"@matterbridge/types": "3.11.3-dev-20261109-ca46ffb",
|
|
84
|
+
"@matterbridge/utils": "3.11.3-dev-20261109-ca46ffb",
|
|
85
85
|
"@zip.js/zip.js": "2.24.0",
|
|
86
86
|
"node-ansi-logger": "3.3.1"
|
|
87
87
|
}
|