@ffflorian/jszip-cli 3.15.1 → 3.15.2

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,7 +1,7 @@
1
1
  import { TerminalOptions } from './interfaces.js';
2
2
  export declare class BuildService {
3
3
  compressedFilesCount: number;
4
- outputFile: string | null;
4
+ outputFile: null | string;
5
5
  private entries;
6
6
  private readonly fileService;
7
7
  private readonly ignoreEntries;
@@ -12,16 +12,16 @@ export declare class BuildService {
12
12
  constructor(options: Required<TerminalOptions>);
13
13
  add(rawEntries: string[]): Promise<BuildService>;
14
14
  save(): Promise<BuildService>;
15
+ private addFile;
16
+ private addLink;
17
+ private checkEntry;
18
+ private checkOutput;
19
+ private getBuffer;
15
20
  /**
16
21
  * Note: glob patterns should always use / as a path separator, even on Windows systems,
17
22
  * as \ is used to escape glob characters.
18
23
  * https://github.com/isaacs/node-glob
19
24
  */
20
25
  private normalizePaths;
21
- private addFile;
22
- private addLink;
23
- private checkEntry;
24
- private checkOutput;
25
- private getBuffer;
26
26
  private walkDir;
27
27
  }
@@ -1,9 +1,9 @@
1
- import path from 'node:path';
2
- import { promises as fs } from 'node:fs';
1
+ import { glob } from 'glob';
3
2
  import JSZip from 'jszip';
4
3
  import logdown from 'logdown';
4
+ import { promises as fs } from 'node:fs';
5
+ import path from 'node:path';
5
6
  import progress from 'progress';
6
- import { glob } from 'glob';
7
7
  import { FileService } from './FileService.js';
8
8
  export class BuildService {
9
9
  constructor(options) {
@@ -56,14 +56,6 @@ export class BuildService {
56
56
  }
57
57
  return this;
58
58
  }
59
- /**
60
- * Note: glob patterns should always use / as a path separator, even on Windows systems,
61
- * as \ is used to escape glob characters.
62
- * https://github.com/isaacs/node-glob
63
- */
64
- normalizePaths(rawEntries) {
65
- return rawEntries.map(entry => entry.replace(/\\/g, '/'));
66
- }
67
59
  async addFile(entry, isLink = false) {
68
60
  const { resolvedPath, zipPath } = entry;
69
61
  let fileStat;
@@ -187,6 +179,14 @@ export class BuildService {
187
179
  }
188
180
  });
189
181
  }
182
+ /**
183
+ * Note: glob patterns should always use / as a path separator, even on Windows systems,
184
+ * as \ is used to escape glob characters.
185
+ * https://github.com/isaacs/node-glob
186
+ */
187
+ normalizePaths(rawEntries) {
188
+ return rawEntries.map(entry => entry.replace(/\\/g, '/'));
189
+ }
190
190
  async walkDir(entry) {
191
191
  this.logger.info(`Walking directory ${entry.resolvedPath} ...`);
192
192
  const dirEntries = await fs.readdir(entry.resolvedPath);
@@ -1,7 +1,7 @@
1
1
  import { TerminalOptions } from './interfaces.js';
2
2
  export declare class ExtractService {
3
3
  extractedFilesCount: number;
4
- outputDir: string | null;
4
+ outputDir: null | string;
5
5
  private readonly logger;
6
6
  private readonly options;
7
7
  private readonly progressBar;
@@ -1,8 +1,8 @@
1
+ import JSZip from 'jszip';
2
+ import logdown from 'logdown';
1
3
  import fs from 'node:fs/promises';
2
4
  import os from 'node:os';
3
5
  import path from 'node:path';
4
- import JSZip from 'jszip';
5
- import logdown from 'logdown';
6
6
  import progress from 'progress';
7
7
  export class ExtractService {
8
8
  constructor(options) {
@@ -29,7 +29,9 @@ export class ExtractService {
29
29
  try {
30
30
  await fs.mkdir(this.outputDir, { recursive: true });
31
31
  }
32
- catch (_a) { }
32
+ catch (_a) {
33
+ // no-op
34
+ }
33
35
  }
34
36
  const resolvedPath = path.resolve(entry);
35
37
  const data = await fs.readFile(resolvedPath);
@@ -55,7 +57,9 @@ export class ExtractService {
55
57
  try {
56
58
  await fs.mkdir(resolvedFilePath, { recursive: true });
57
59
  }
58
- catch (_b) { }
60
+ catch (_b) {
61
+ // no-op
62
+ }
59
63
  }
60
64
  else {
61
65
  const data = await entry.async('nodebuffer');
@@ -1,6 +1,6 @@
1
+ import logdown from 'logdown';
1
2
  import fs from 'node:fs/promises';
2
3
  import path from 'node:path';
3
- import logdown from 'logdown';
4
4
  export class FileService {
5
5
  constructor(options) {
6
6
  this.options = options;
@@ -28,7 +28,9 @@ export class FileService {
28
28
  try {
29
29
  await fs.mkdir(dirPath, { recursive: true });
30
30
  }
31
- catch (_c) { }
31
+ catch (_c) {
32
+ // no-op
33
+ }
32
34
  return true;
33
35
  }
34
36
  return false;
@@ -1,6 +1,6 @@
1
+ import type { TerminalOptions } from './interfaces.js';
1
2
  import { BuildService } from './BuildService.js';
2
3
  import { ExtractService } from './ExtractService.js';
3
- import type { TerminalOptions } from './interfaces.js';
4
4
  export declare class JSZipCLI {
5
5
  private readonly buildService;
6
6
  private readonly configExplorer;
package/dist/JSZipCLI.js CHANGED
@@ -71,14 +71,14 @@ export class JSZipCLI {
71
71
  }
72
72
  if (this.options.mode === 'add') {
73
73
  const buildService = await this.add();
74
- const { outputFile, compressedFilesCount } = await buildService.save();
74
+ const { compressedFilesCount, outputFile } = await buildService.save();
75
75
  if (this.options.outputEntry && !this.options.quiet) {
76
76
  console.info(`Done compressing ${compressedFilesCount} files to "${outputFile}".`);
77
77
  }
78
78
  return this;
79
79
  }
80
80
  else if (this.options.mode === 'extract') {
81
- const { outputDir, extractedFilesCount } = await this.extract();
81
+ const { extractedFilesCount, outputDir } = await this.extract();
82
82
  if (this.options.outputEntry && !this.options.quiet) {
83
83
  console.info(`Done extracting ${extractedFilesCount} files to "${outputDir}".`);
84
84
  }
package/dist/cli.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import { program as commander } from 'commander';
2
3
  import fs from 'node:fs';
3
4
  import path from 'node:path';
4
- import { program as commander } from 'commander';
5
5
  import { JSZipCLI } from './JSZipCLI.js';
6
6
  const __dirname = import.meta.dirname;
7
7
  const packageJsonPath = path.join(__dirname, '../package.json');
@@ -51,7 +51,7 @@ commander
51
51
  ...(options.verbose && { verbose: options.verbose }),
52
52
  });
53
53
  await jszip.add(entries);
54
- const { outputFile, compressedFilesCount } = await jszip.save();
54
+ const { compressedFilesCount, outputFile } = await jszip.save();
55
55
  if (options.output && !options.quiet) {
56
56
  console.info(`Done compressing ${compressedFilesCount} files to "${outputFile}".`);
57
57
  }
@@ -76,7 +76,7 @@ commander
76
76
  .action(async (archives) => {
77
77
  const options = commander.opts();
78
78
  try {
79
- const { outputDir, extractedFilesCount } = await new JSZipCLI({
79
+ const { extractedFilesCount, outputDir } = await new JSZipCLI({
80
80
  ...((options.config && { configFile: options.config }) || (options.noconfig && { configFile: false })),
81
81
  ...(options.force && { force: options.force }),
82
82
  ...(options.ignore && { ignoreEntries: [options.ignore] }),
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './JSZipCLI.js';
2
1
  export * from './interfaces.js';
2
+ export * from './JSZipCLI.js';
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- export * from './JSZipCLI.js';
2
1
  export * from './interfaces.js';
2
+ export * from './JSZipCLI.js';
@@ -1,28 +1,28 @@
1
+ export interface ConfigFileOptions extends TerminalOptions {
2
+ /** Which files or directories to add. */
3
+ entries: string[];
4
+ /** Add or extract files. */
5
+ mode: 'add' | 'extract';
6
+ }
7
+ export interface Entry {
8
+ resolvedPath: string;
9
+ zipPath: string;
10
+ }
1
11
  export interface TerminalOptions {
2
12
  /** The compression level to use (0 = save only, 9 = best compression) (default: 5). */
3
13
  compressionLevel?: number;
4
14
  /** Use a configuration file (default: .jsziprc.json). */
5
- configFile?: string | boolean;
15
+ configFile?: boolean | string;
6
16
  /** Whether to dereference (follow) symlinks (default: false). */
7
17
  dereferenceLinks?: boolean;
8
18
  /** Force overwriting files and directories when extracting (default: false). */
9
19
  force?: boolean;
10
20
  /** Ignore entries (e.g. `*.js.map`). */
11
- ignoreEntries?: Array<string | RegExp>;
21
+ ignoreEntries?: Array<RegExp | string>;
12
22
  /** Set the output directory (default: stdout). */
13
- outputEntry?: string | null;
23
+ outputEntry?: null | string;
14
24
  /** Don't log anything excluding errors (default: false). */
15
25
  quiet?: boolean;
16
26
  /** Enable verbose logging (default: false). */
17
27
  verbose?: boolean;
18
28
  }
19
- export interface ConfigFileOptions extends TerminalOptions {
20
- /** Which files or directories to add. */
21
- entries: string[];
22
- /** Add or extract files. */
23
- mode: 'add' | 'extract';
24
- }
25
- export interface Entry {
26
- resolvedPath: string;
27
- zipPath: string;
28
- }
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Florian Imdahl <git@ffflorian.de>",
3
3
  "bin": "dist/cli.js",
4
4
  "dependencies": {
5
- "commander": "14.0.2",
5
+ "commander": "14.0.3",
6
6
  "cosmiconfig": "9.0.0",
7
7
  "glob": "13.0.0",
8
8
  "jszip": "3.10.1",
@@ -11,12 +11,13 @@
11
11
  },
12
12
  "description": "A zip CLI based on jszip.",
13
13
  "devDependencies": {
14
+ "@types/node": "~24",
14
15
  "@types/progress": "2.0.7",
15
16
  "cross-env": "10.1.0",
16
17
  "rimraf": "6.1.2",
17
18
  "tsx": "4.21.0",
18
19
  "typescript": "5.9.3",
19
- "vitest": "4.0.16"
20
+ "vitest": "4.0.18"
20
21
  },
21
22
  "engines": {
22
23
  "node": ">= 18"
@@ -42,6 +43,6 @@
42
43
  "test": "vitest run"
43
44
  },
44
45
  "type": "module",
45
- "version": "3.15.1",
46
- "gitHead": "ba772186f0c4fb05492ef586666b8e44faefe71d"
46
+ "version": "3.15.2",
47
+ "gitHead": "59997e7c64b551213644945256b13ff3ba1ccfcd"
47
48
  }