@ffflorian/jszip-cli 3.9.1 → 3.10.1
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/BuildService.d.ts +1 -1
- package/dist/BuildService.js +8 -7
- package/dist/ExtractService.js +9 -3
- package/dist/FileService.js +5 -2
- package/dist/JSZipCLI.d.ts +1 -1
- package/dist/JSZipCLI.js +2 -1
- package/dist/cli.js +3 -3
- package/package.json +2 -4
package/dist/BuildService.d.ts
CHANGED
|
@@ -10,7 +10,7 @@ export declare class BuildService {
|
|
|
10
10
|
private readonly options;
|
|
11
11
|
private readonly progressBar;
|
|
12
12
|
constructor(options: Required<TerminalOptions>);
|
|
13
|
-
add(rawEntries: string[]): BuildService
|
|
13
|
+
add(rawEntries: string[]): Promise<BuildService>;
|
|
14
14
|
save(): Promise<BuildService>;
|
|
15
15
|
/**
|
|
16
16
|
* Note: glob patterns should always use / as a path separator, even on Windows systems,
|
package/dist/BuildService.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
|
-
import fs from 'fs
|
|
2
|
+
import { promises as fs } from 'node:fs';
|
|
3
3
|
import JSZip from 'jszip';
|
|
4
4
|
import logdown from 'logdown';
|
|
5
5
|
import progress from 'progress';
|
|
6
|
-
import {
|
|
6
|
+
import { glob } from 'glob';
|
|
7
7
|
import { FileService } from './FileService.js';
|
|
8
8
|
export class BuildService {
|
|
9
9
|
constructor(options) {
|
|
@@ -26,17 +26,18 @@ export class BuildService {
|
|
|
26
26
|
});
|
|
27
27
|
this.compressedFilesCount = 0;
|
|
28
28
|
}
|
|
29
|
-
add(rawEntries) {
|
|
29
|
+
async add(rawEntries) {
|
|
30
30
|
this.logger.info(`Adding ${rawEntries.length} entr${rawEntries.length === 1 ? 'y' : 'ies'} to ZIP file.`);
|
|
31
31
|
const normalizedEntries = this.normalizePaths(rawEntries);
|
|
32
|
-
this.entries =
|
|
32
|
+
this.entries = [];
|
|
33
|
+
for (const rawEntry of await glob(normalizedEntries)) {
|
|
33
34
|
const resolvedPath = path.resolve(rawEntry);
|
|
34
35
|
const baseName = path.basename(rawEntry);
|
|
35
|
-
|
|
36
|
+
this.entries.push({
|
|
36
37
|
resolvedPath,
|
|
37
38
|
zipPath: baseName,
|
|
38
|
-
};
|
|
39
|
-
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
40
41
|
return this;
|
|
41
42
|
}
|
|
42
43
|
async save() {
|
package/dist/ExtractService.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
1
2
|
import os from 'node:os';
|
|
2
3
|
import path from 'node:path';
|
|
3
|
-
import fs from 'fs-extra';
|
|
4
4
|
import JSZip from 'jszip';
|
|
5
5
|
import logdown from 'logdown';
|
|
6
6
|
import progress from 'progress';
|
|
@@ -26,7 +26,10 @@ export class ExtractService {
|
|
|
26
26
|
for (const entry of rawEntries) {
|
|
27
27
|
const jszip = new JSZip();
|
|
28
28
|
if (this.outputDir) {
|
|
29
|
-
|
|
29
|
+
try {
|
|
30
|
+
await fs.mkdir(this.outputDir, { recursive: true });
|
|
31
|
+
}
|
|
32
|
+
catch (_a) { }
|
|
30
33
|
}
|
|
31
34
|
const resolvedPath = path.resolve(entry);
|
|
32
35
|
const data = await fs.readFile(resolvedPath);
|
|
@@ -49,7 +52,10 @@ export class ExtractService {
|
|
|
49
52
|
for (const [filePath, entry] of entries) {
|
|
50
53
|
const resolvedFilePath = path.join(this.outputDir, filePath);
|
|
51
54
|
if (entry.dir) {
|
|
52
|
-
|
|
55
|
+
try {
|
|
56
|
+
await fs.mkdir(resolvedFilePath, { recursive: true });
|
|
57
|
+
}
|
|
58
|
+
catch (_b) { }
|
|
53
59
|
}
|
|
54
60
|
else {
|
|
55
61
|
const data = await entry.async('nodebuffer');
|
package/dist/FileService.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
1
2
|
import path from 'node:path';
|
|
2
|
-
import fs from 'fs-extra';
|
|
3
3
|
import logdown from 'logdown';
|
|
4
4
|
export class FileService {
|
|
5
5
|
constructor(options) {
|
|
@@ -25,7 +25,10 @@ export class FileService {
|
|
|
25
25
|
catch (_b) {
|
|
26
26
|
this.logger.info(`Directory "${dirPath}" doesn't exist.`, this.options.force ? 'Creating.' : 'Not creating.');
|
|
27
27
|
if (this.options.force) {
|
|
28
|
-
|
|
28
|
+
try {
|
|
29
|
+
await fs.mkdir(dirPath, { recursive: true });
|
|
30
|
+
}
|
|
31
|
+
catch (_c) { }
|
|
29
32
|
return true;
|
|
30
33
|
}
|
|
31
34
|
return false;
|
package/dist/JSZipCLI.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare class JSZipCLI {
|
|
|
15
15
|
* @param rawEntries The entries (files, directories) to add.
|
|
16
16
|
* If not specified, entries from configuration file are used.
|
|
17
17
|
*/
|
|
18
|
-
add(rawEntries?: string[]): BuildService
|
|
18
|
+
add(rawEntries?: string[]): Promise<BuildService>;
|
|
19
19
|
/**
|
|
20
20
|
* Add files and directories to the ZIP file.
|
|
21
21
|
* @param rawEntries The entries (files, directories) to extract.
|
package/dist/JSZipCLI.js
CHANGED
|
@@ -69,7 +69,8 @@ export class JSZipCLI {
|
|
|
69
69
|
throw new Error('No configuration file and no mode specified.');
|
|
70
70
|
}
|
|
71
71
|
if (this.options.mode === 'add') {
|
|
72
|
-
const
|
|
72
|
+
const buildService = await this.add();
|
|
73
|
+
const { outputFile, compressedFilesCount } = await buildService.save();
|
|
73
74
|
if (this.options.outputEntry && !this.options.quiet) {
|
|
74
75
|
console.info(`Done compressing ${compressedFilesCount} files to "${outputFile}".`);
|
|
75
76
|
}
|
package/dist/cli.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import fs from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { program as commander } from 'commander';
|
|
4
|
-
import fs from 'fs-extra';
|
|
5
5
|
import { JSZipCLI } from './JSZipCLI.js';
|
|
6
6
|
const __dirname = import.meta.dirname;
|
|
7
7
|
const packageJsonPath = path.join(__dirname, '../package.json');
|
|
8
|
-
const { description, name, version } = fs.
|
|
8
|
+
const { description, name, version } = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
|
|
9
9
|
commander
|
|
10
10
|
.name(name.replace(/^@[^/]+\//, ''))
|
|
11
11
|
.description(description)
|
|
@@ -50,7 +50,7 @@ commander
|
|
|
50
50
|
...(options.quiet && { quiet: options.quiet }),
|
|
51
51
|
...(options.verbose && { verbose: options.verbose }),
|
|
52
52
|
});
|
|
53
|
-
jszip.add(entries);
|
|
53
|
+
await jszip.add(entries);
|
|
54
54
|
const { outputFile, compressedFilesCount } = await jszip.save();
|
|
55
55
|
if (options.output && !options.quiet) {
|
|
56
56
|
console.info(`Done compressing ${compressedFilesCount} files to "${outputFile}".`);
|
package/package.json
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
"dependencies": {
|
|
5
5
|
"commander": "14.0.2",
|
|
6
6
|
"cosmiconfig": "9.0.0",
|
|
7
|
-
"fs-extra": "11.3.2",
|
|
8
7
|
"glob": "11.0.3",
|
|
9
8
|
"jszip": "3.10.1",
|
|
10
9
|
"logdown": "3.3.1",
|
|
@@ -12,7 +11,6 @@
|
|
|
12
11
|
},
|
|
13
12
|
"description": "A zip CLI based on jszip.",
|
|
14
13
|
"devDependencies": {
|
|
15
|
-
"@types/fs-extra": "11.0.4",
|
|
16
14
|
"@types/progress": "2.0.7",
|
|
17
15
|
"cross-env": "10.1.0",
|
|
18
16
|
"rimraf": "6.1.0",
|
|
@@ -44,6 +42,6 @@
|
|
|
44
42
|
"test": "vitest run"
|
|
45
43
|
},
|
|
46
44
|
"type": "module",
|
|
47
|
-
"version": "3.
|
|
48
|
-
"gitHead": "
|
|
45
|
+
"version": "3.10.1",
|
|
46
|
+
"gitHead": "eedb2984fd69190a0b69a992d18fe451e714e04d"
|
|
49
47
|
}
|