@ffflorian/jszip-cli 3.5.5 → 3.5.7

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.
Files changed (34) hide show
  1. package/dist/{cjs/BuildService.d.ts → BuildService.d.ts} +1 -1
  2. package/dist/{cjs/BuildService.js → BuildService.js} +50 -20
  3. package/dist/{esm/ExtractService.d.ts → ExtractService.d.ts} +1 -1
  4. package/dist/{cjs/ExtractService.js → ExtractService.js} +27 -20
  5. package/dist/{cjs/FileService.d.ts → FileService.d.ts} +1 -1
  6. package/dist/{cjs/FileService.js → FileService.js} +20 -13
  7. package/dist/{cjs/JSZipCLI.d.ts → JSZipCLI.d.ts} +3 -3
  8. package/dist/{cjs/JSZipCLI.js → JSZipCLI.js} +16 -9
  9. package/dist/{cjs/cli.js → cli.js} +25 -23
  10. package/dist/index.d.ts +2 -0
  11. package/dist/index.js +18 -0
  12. package/dist/interfaces.js +2 -0
  13. package/package.json +10 -15
  14. package/dist/cjs/ExtractService.d.ts +0 -11
  15. package/dist/cjs/index.d.ts +0 -2
  16. package/dist/cjs/index.js +0 -2
  17. package/dist/cjs/interfaces.js +0 -1
  18. package/dist/cjs/package.json +0 -3
  19. package/dist/esm/BuildService.d.ts +0 -27
  20. package/dist/esm/BuildService.js +0 -201
  21. package/dist/esm/ExtractService.js +0 -84
  22. package/dist/esm/FileService.d.ts +0 -11
  23. package/dist/esm/FileService.js +0 -70
  24. package/dist/esm/JSZipCLI.d.ts +0 -32
  25. package/dist/esm/JSZipCLI.js +0 -121
  26. package/dist/esm/cli.d.ts +0 -2
  27. package/dist/esm/cli.js +0 -112
  28. package/dist/esm/index.d.ts +0 -2
  29. package/dist/esm/index.js +0 -2
  30. package/dist/esm/interfaces.d.ts +0 -28
  31. package/dist/esm/interfaces.js +0 -1
  32. package/dist/esm/package.json +0 -3
  33. /package/dist/{cjs/cli.d.ts → cli.d.ts} +0 -0
  34. /package/dist/{cjs/interfaces.d.ts → interfaces.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- import { TerminalOptions } from './interfaces.js';
1
+ import { TerminalOptions } from './interfaces';
2
2
  export declare class BuildService {
3
3
  compressedFilesCount: number;
4
4
  outputFile: string | null;
@@ -1,3 +1,27 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
1
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,27 +31,32 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
32
  });
9
33
  };
10
- import * as fs from 'fs-extra';
11
- import JSZip from 'jszip';
12
- import logdown from 'logdown';
13
- import path from 'path';
14
- import progress from 'progress';
15
- import { FileService } from './FileService.js';
16
- import { globSync } from 'glob';
17
- export class BuildService {
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.BuildService = void 0;
39
+ const fs = __importStar(require("fs-extra"));
40
+ const jszip_1 = __importDefault(require("jszip"));
41
+ const logdown_1 = __importDefault(require("logdown"));
42
+ const path_1 = __importDefault(require("path"));
43
+ const progress_1 = __importDefault(require("progress"));
44
+ const FileService_1 = require("./FileService");
45
+ const glob_1 = require("glob");
46
+ class BuildService {
18
47
  constructor(options) {
19
- this.fileService = new FileService(options);
20
- this.jszip = new JSZip();
48
+ this.fileService = new FileService_1.FileService(options);
49
+ this.jszip = new jszip_1.default();
21
50
  this.options = options;
22
- this.logger = logdown('jszip-cli/BuildService', {
51
+ this.logger = (0, logdown_1.default)('jszip-cli/BuildService', {
23
52
  logger: console,
24
53
  markdown: false,
25
54
  });
26
55
  this.logger.state = { isEnabled: options.verbose };
27
56
  this.entries = [];
28
57
  this.ignoreEntries = this.options.ignoreEntries.map(entry => entry instanceof RegExp ? entry : new RegExp(entry.replace(/\*/g, '.*')));
29
- this.outputFile = this.options.outputEntry ? path.resolve(this.options.outputEntry) : null;
30
- this.progressBar = new progress('Compressing [:bar] :percent :elapseds', {
58
+ this.outputFile = this.options.outputEntry ? path_1.default.resolve(this.options.outputEntry) : null;
59
+ this.progressBar = new progress_1.default('Compressing [:bar] :percent :elapseds', {
31
60
  complete: '=',
32
61
  incomplete: ' ',
33
62
  total: 100,
@@ -38,9 +67,9 @@ export class BuildService {
38
67
  add(rawEntries) {
39
68
  this.logger.info(`Adding ${rawEntries.length} entr${rawEntries.length === 1 ? 'y' : 'ies'} to ZIP file.`);
40
69
  const normalizedEntries = this.normalizePaths(rawEntries);
41
- this.entries = globSync(normalizedEntries).map(rawEntry => {
42
- const resolvedPath = path.resolve(rawEntry);
43
- const baseName = path.basename(rawEntry);
70
+ this.entries = (0, glob_1.globSync)(normalizedEntries).map(rawEntry => {
71
+ const resolvedPath = path_1.default.resolve(rawEntry);
72
+ const baseName = path_1.default.basename(rawEntry);
44
73
  return {
45
74
  resolvedPath,
46
75
  zipPath: baseName,
@@ -55,7 +84,7 @@ export class BuildService {
55
84
  const data = yield this.getBuffer();
56
85
  if (this.outputFile) {
57
86
  if (!this.outputFile.match(/\.\w+$/)) {
58
- this.outputFile = path.join(this.outputFile, 'data.zip');
87
+ this.outputFile = path_1.default.join(this.outputFile, 'data.zip');
59
88
  }
60
89
  this.logger.info(`Saving finished zip file to "${this.outputFile}" ...`);
61
90
  yield this.fileService.writeFile(data, this.outputFile);
@@ -170,9 +199,9 @@ export class BuildService {
170
199
  return __awaiter(this, void 0, void 0, function* () {
171
200
  if (this.outputFile) {
172
201
  if (this.outputFile.match(/\.\w+$/)) {
173
- const dirExists = yield this.fileService.dirExists(path.dirname(this.outputFile));
202
+ const dirExists = yield this.fileService.dirExists(path_1.default.dirname(this.outputFile));
174
203
  if (!dirExists) {
175
- throw new Error(`Directory "${path.dirname(this.outputFile)}" doesn't exist or is not writable.`);
204
+ throw new Error(`Directory "${path_1.default.dirname(this.outputFile)}" doesn't exist or is not writable.`);
176
205
  }
177
206
  const fileIsWritable = yield this.fileService.fileIsWritable(this.outputFile);
178
207
  if (!fileIsWritable) {
@@ -211,7 +240,7 @@ export class BuildService {
211
240
  const dirEntries = yield fs.readdir(entry.resolvedPath);
212
241
  for (const dirEntry of dirEntries) {
213
242
  const newZipPath = entry.zipPath === '.' ? dirEntry : `${entry.zipPath}/${dirEntry}`;
214
- const newResolvedPath = path.join(entry.resolvedPath, dirEntry);
243
+ const newResolvedPath = path_1.default.join(entry.resolvedPath, dirEntry);
215
244
  yield this.checkEntry({
216
245
  resolvedPath: newResolvedPath,
217
246
  zipPath: newZipPath,
@@ -220,3 +249,4 @@ export class BuildService {
220
249
  });
221
250
  }
222
251
  }
252
+ exports.BuildService = BuildService;
@@ -1,4 +1,4 @@
1
- import { TerminalOptions } from './interfaces.js';
1
+ import { TerminalOptions } from './interfaces';
2
2
  export declare class ExtractService {
3
3
  extractedFilesCount: number;
4
4
  outputDir: string | null;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,22 +8,27 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
10
- import fs from 'fs-extra';
11
- import JSZip from 'jszip';
12
- import logdown from 'logdown';
13
- import os from 'os';
14
- import path from 'path';
15
- import progress from 'progress';
16
- export class ExtractService {
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.ExtractService = void 0;
16
+ const fs_extra_1 = __importDefault(require("fs-extra"));
17
+ const jszip_1 = __importDefault(require("jszip"));
18
+ const logdown_1 = __importDefault(require("logdown"));
19
+ const os_1 = __importDefault(require("os"));
20
+ const path_1 = __importDefault(require("path"));
21
+ const progress_1 = __importDefault(require("progress"));
22
+ class ExtractService {
17
23
  constructor(options) {
18
24
  this.options = options;
19
- this.logger = logdown('jszip-cli/ExtractService', {
25
+ this.logger = (0, logdown_1.default)('jszip-cli/ExtractService', {
20
26
  logger: console,
21
27
  markdown: false,
22
28
  });
23
29
  this.logger.state.isEnabled = this.options.verbose;
24
- this.outputDir = this.options.outputEntry ? path.resolve(this.options.outputEntry) : null;
25
- this.progressBar = new progress('Extracting [:bar] :percent :elapseds', {
30
+ this.outputDir = this.options.outputEntry ? path_1.default.resolve(this.options.outputEntry) : null;
31
+ this.progressBar = new progress_1.default('Extracting [:bar] :percent :elapseds', {
26
32
  complete: '=',
27
33
  incomplete: ' ',
28
34
  total: 100,
@@ -32,14 +38,14 @@ export class ExtractService {
32
38
  }
33
39
  extract(rawEntries) {
34
40
  return __awaiter(this, void 0, void 0, function* () {
35
- const isWin32 = os.platform() === 'win32';
41
+ const isWin32 = os_1.default.platform() === 'win32';
36
42
  for (const entry of rawEntries) {
37
- const jszip = new JSZip();
43
+ const jszip = new jszip_1.default();
38
44
  if (this.outputDir) {
39
- yield fs.ensureDir(this.outputDir);
45
+ yield fs_extra_1.default.ensureDir(this.outputDir);
40
46
  }
41
- const resolvedPath = path.resolve(entry);
42
- const data = yield fs.readFile(resolvedPath);
47
+ const resolvedPath = path_1.default.resolve(entry);
48
+ const data = yield fs_extra_1.default.readFile(resolvedPath);
43
49
  const entries = [];
44
50
  yield jszip.loadAsync(data, { createFolders: true });
45
51
  if (!this.outputDir) {
@@ -56,13 +62,13 @@ export class ExtractService {
56
62
  });
57
63
  let lastPercent = 0;
58
64
  yield Promise.all(entries.map(([filePath, entry], index) => __awaiter(this, void 0, void 0, function* () {
59
- const resolvedFilePath = path.join(this.outputDir, filePath);
65
+ const resolvedFilePath = path_1.default.join(this.outputDir, filePath);
60
66
  if (entry.dir) {
61
- yield fs.ensureDir(resolvedFilePath);
67
+ yield fs_extra_1.default.ensureDir(resolvedFilePath);
62
68
  }
63
69
  else {
64
70
  const data = yield entry.async('nodebuffer');
65
- yield fs.writeFile(resolvedFilePath, data, {
71
+ yield fs_extra_1.default.writeFile(resolvedFilePath, data, {
66
72
  encoding: 'utf-8',
67
73
  });
68
74
  this.extractedFilesCount++;
@@ -74,11 +80,11 @@ export class ExtractService {
74
80
  }
75
81
  if (isWin32) {
76
82
  if (entry.dosPermissions) {
77
- yield fs.chmod(resolvedFilePath, entry.dosPermissions);
83
+ yield fs_extra_1.default.chmod(resolvedFilePath, entry.dosPermissions);
78
84
  }
79
85
  }
80
86
  else if (entry.unixPermissions) {
81
- yield fs.chmod(resolvedFilePath, entry.unixPermissions);
87
+ yield fs_extra_1.default.chmod(resolvedFilePath, entry.unixPermissions);
82
88
  }
83
89
  })));
84
90
  }
@@ -93,3 +99,4 @@ export class ExtractService {
93
99
  });
94
100
  }
95
101
  }
102
+ exports.ExtractService = ExtractService;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { TerminalOptions } from './interfaces.js';
2
+ import type { TerminalOptions } from './interfaces';
3
3
  export declare class FileService {
4
4
  private readonly logger;
5
5
  private readonly options;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,13 +8,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
10
- import fs from 'fs-extra';
11
- import logdown from 'logdown';
12
- import path from 'path';
13
- export class FileService {
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.FileService = void 0;
16
+ const fs_extra_1 = __importDefault(require("fs-extra"));
17
+ const logdown_1 = __importDefault(require("logdown"));
18
+ const path_1 = __importDefault(require("path"));
19
+ class FileService {
14
20
  constructor(options) {
15
21
  this.options = options;
16
- this.logger = logdown('jszip-cli/FileService', {
22
+ this.logger = (0, logdown_1.default)('jszip-cli/FileService', {
17
23
  logger: console,
18
24
  markdown: false,
19
25
  });
@@ -22,9 +28,9 @@ export class FileService {
22
28
  dirExists(dirPath) {
23
29
  return __awaiter(this, void 0, void 0, function* () {
24
30
  try {
25
- yield fs.access(dirPath, fs.constants.F_OK);
31
+ yield fs_extra_1.default.access(dirPath, fs_extra_1.default.constants.F_OK);
26
32
  try {
27
- yield fs.access(dirPath, fs.constants.W_OK);
33
+ yield fs_extra_1.default.access(dirPath, fs_extra_1.default.constants.W_OK);
28
34
  return true;
29
35
  }
30
36
  catch (error) {
@@ -35,7 +41,7 @@ export class FileService {
35
41
  catch (error) {
36
42
  this.logger.info(`Directory "${dirPath}" doesn't exist.`, this.options.force ? 'Creating.' : 'Not creating.');
37
43
  if (this.options.force) {
38
- yield fs.ensureDir(dirPath);
44
+ yield fs_extra_1.default.ensureDir(dirPath);
39
45
  return true;
40
46
  }
41
47
  return false;
@@ -44,10 +50,10 @@ export class FileService {
44
50
  }
45
51
  fileIsReadable(filePath) {
46
52
  return __awaiter(this, void 0, void 0, function* () {
47
- const dirExists = yield this.dirExists(path.dirname(filePath));
53
+ const dirExists = yield this.dirExists(path_1.default.dirname(filePath));
48
54
  if (dirExists) {
49
55
  try {
50
- yield fs.access(filePath, fs.constants.F_OK | fs.constants.R_OK);
56
+ yield fs_extra_1.default.access(filePath, fs_extra_1.default.constants.F_OK | fs_extra_1.default.constants.R_OK);
51
57
  return true;
52
58
  }
53
59
  catch (error) {
@@ -59,11 +65,11 @@ export class FileService {
59
65
  }
60
66
  fileIsWritable(filePath) {
61
67
  return __awaiter(this, void 0, void 0, function* () {
62
- const dirName = path.dirname(filePath);
68
+ const dirName = path_1.default.dirname(filePath);
63
69
  const dirExists = yield this.dirExists(dirName);
64
70
  if (dirExists) {
65
71
  try {
66
- yield fs.access(filePath, fs.constants.F_OK | fs.constants.R_OK);
72
+ yield fs_extra_1.default.access(filePath, fs_extra_1.default.constants.F_OK | fs_extra_1.default.constants.R_OK);
67
73
  this.logger.info(`File "${filePath}" already exists.`, this.options.force ? 'Forcing overwrite.' : 'Not overwriting.');
68
74
  return this.options.force;
69
75
  }
@@ -78,10 +84,11 @@ export class FileService {
78
84
  return __awaiter(this, void 0, void 0, function* () {
79
85
  const fileIsWritable = yield this.fileIsWritable(filePath);
80
86
  if (fileIsWritable) {
81
- yield fs.writeFile(filePath, data);
87
+ yield fs_extra_1.default.writeFile(filePath, data);
82
88
  return this;
83
89
  }
84
90
  throw new Error(`File "${this.options.outputEntry}" already exists.`);
85
91
  });
86
92
  }
87
93
  }
94
+ exports.FileService = FileService;
@@ -1,6 +1,6 @@
1
- import { BuildService } from './BuildService.js';
2
- import { ExtractService } from './ExtractService.js';
3
- import type { TerminalOptions } from './interfaces.js';
1
+ import { BuildService } from './BuildService';
2
+ import { ExtractService } from './ExtractService';
3
+ import type { TerminalOptions } from './interfaces';
4
4
  export declare class JSZipCLI {
5
5
  private readonly buildService;
6
6
  private readonly configExplorer;
@@ -1,3 +1,4 @@
1
+ "use strict";
1
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -7,10 +8,15 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
9
  });
9
10
  };
10
- import { cosmiconfigSync } from 'cosmiconfig';
11
- import logdown from 'logdown';
12
- import { BuildService } from './BuildService.js';
13
- import { ExtractService } from './ExtractService.js';
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.JSZipCLI = void 0;
16
+ const cosmiconfig_1 = require("cosmiconfig");
17
+ const logdown_1 = __importDefault(require("logdown"));
18
+ const BuildService_1 = require("./BuildService");
19
+ const ExtractService_1 = require("./ExtractService");
14
20
  const defaultOptions = {
15
21
  compressionLevel: 5,
16
22
  configFile: true,
@@ -21,21 +27,21 @@ const defaultOptions = {
21
27
  quiet: false,
22
28
  verbose: false,
23
29
  };
24
- export class JSZipCLI {
30
+ class JSZipCLI {
25
31
  constructor(options) {
26
32
  this.terminalOptions = options;
27
- this.logger = logdown('jszip-cli/index', {
33
+ this.logger = (0, logdown_1.default)('jszip-cli/index', {
28
34
  logger: console,
29
35
  markdown: false,
30
36
  });
31
- this.configExplorer = cosmiconfigSync('jszip');
37
+ this.configExplorer = (0, cosmiconfig_1.cosmiconfigSync)('jszip');
32
38
  this.options = Object.assign(Object.assign({}, defaultOptions), this.terminalOptions);
33
39
  this.logger.state.isEnabled = this.options.verbose;
34
40
  this.logger.info('Merged options', this.options);
35
41
  this.checkConfigFile();
36
42
  this.logger.info('Loaded options', this.options);
37
- this.buildService = new BuildService(this.options);
38
- this.extractService = new ExtractService(this.options);
43
+ this.buildService = new BuildService_1.BuildService(this.options);
44
+ this.extractService = new ExtractService_1.ExtractService(this.options);
39
45
  }
40
46
  /**
41
47
  * Add files and directories to the ZIP file.
@@ -130,3 +136,4 @@ export class JSZipCLI {
130
136
  this.logger.state.isEnabled = this.options.verbose;
131
137
  }
132
138
  }
139
+ exports.JSZipCLI = JSZipCLI;
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env node
2
+ "use strict";
2
3
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
4
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
5
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,19 +9,20 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
9
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
10
  });
10
11
  };
11
- import { program as commander } from 'commander';
12
- import fs from 'fs-extra';
13
- import path from 'path';
14
- import { fileURLToPath } from 'url';
15
- import { JSZipCLI } from './JSZipCLI.js';
16
- const __filename = fileURLToPath(import.meta.url);
17
- const __dirname = path.dirname(__filename);
18
- const defaultPackageJsonPath = path.join(__dirname, '../../package.json');
19
- const packageJsonPath = fs.existsSync(defaultPackageJsonPath)
12
+ var __importDefault = (this && this.__importDefault) || function (mod) {
13
+ return (mod && mod.__esModule) ? mod : { "default": mod };
14
+ };
15
+ Object.defineProperty(exports, "__esModule", { value: true });
16
+ const commander_1 = require("commander");
17
+ const fs_extra_1 = __importDefault(require("fs-extra"));
18
+ const path_1 = __importDefault(require("path"));
19
+ const JSZipCLI_1 = require("./JSZipCLI");
20
+ const defaultPackageJsonPath = path_1.default.join(__dirname, '../../package.json');
21
+ const packageJsonPath = fs_extra_1.default.existsSync(defaultPackageJsonPath)
20
22
  ? defaultPackageJsonPath
21
- : path.join(__dirname, '../package.json');
22
- const { description, name, version } = fs.readJSONSync(packageJsonPath);
23
- commander
23
+ : path_1.default.join(__dirname, '../package.json');
24
+ const { description, name, version } = fs_extra_1.default.readJSONSync(packageJsonPath);
25
+ commander_1.program
24
26
  .name(name.replace(/^@[^/]+\//, ''))
25
27
  .description(description)
26
28
  .option('--noconfig', "don't look for a configuration file")
@@ -37,7 +39,7 @@ commander
37
39
  console.error(`\n error: invalid command \`${args[0]}'\n`);
38
40
  process.exit(1);
39
41
  });
40
- commander
42
+ commander_1.program
41
43
  .command('add')
42
44
  .alias('a')
43
45
  .description('add files and directories to a new ZIP archive')
@@ -52,9 +54,9 @@ commander
52
54
  .option('-V, --verbose', 'enable verbose logging', false)
53
55
  .arguments('[entries...]')
54
56
  .action((entries) => __awaiter(void 0, void 0, void 0, function* () {
55
- const options = commander.opts();
57
+ const options = commander_1.program.opts();
56
58
  try {
57
- const jszip = new JSZipCLI(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (options.level && { compressionLevel: Number(options.level) })), ((options.config && { configFile: options.config }) || (options.noconfig && { configFile: false }))), (options.dereference && { dereferenceLinks: options.dereference })), (options.force && { force: options.force })), (options.ignore && { ignoreEntries: [options.ignore] })), (options.output && { outputEntry: options.output })), (options.quiet && { quiet: options.quiet })), (options.verbose && { verbose: options.verbose })));
59
+ const jszip = new JSZipCLI_1.JSZipCLI(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (options.level && { compressionLevel: Number(options.level) })), ((options.config && { configFile: options.config }) || (options.noconfig && { configFile: false }))), (options.dereference && { dereferenceLinks: options.dereference })), (options.force && { force: options.force })), (options.ignore && { ignoreEntries: [options.ignore] })), (options.output && { outputEntry: options.output })), (options.quiet && { quiet: options.quiet })), (options.verbose && { verbose: options.verbose })));
58
60
  jszip.add(entries);
59
61
  const { outputFile, compressedFilesCount } = yield jszip.save();
60
62
  if (options.output && !options.quiet) {
@@ -66,7 +68,7 @@ commander
66
68
  process.exit(1);
67
69
  }
68
70
  }));
69
- commander
71
+ commander_1.program
70
72
  .command('extract')
71
73
  .alias('e')
72
74
  .description('extract files and directories from ZIP archive(s)')
@@ -79,9 +81,9 @@ commander
79
81
  .option('-q, --quiet', "don't log anything excluding errors", false)
80
82
  .arguments('<archives...>')
81
83
  .action((archives) => __awaiter(void 0, void 0, void 0, function* () {
82
- const options = commander.opts();
84
+ const options = commander_1.program.opts();
83
85
  try {
84
- const { outputDir, extractedFilesCount } = yield new JSZipCLI(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((options.config && { configFile: options.config }) || (options.noconfig && { configFile: false }))), (options.force && { force: options.force })), (options.ignore && { ignoreEntries: [options.ignore] })), (options.output && { outputEntry: options.output })), (options.quiet && { quiet: options.quiet })), (options.verbose && { verbose: options.verbose }))).extract(archives);
86
+ const { outputDir, extractedFilesCount } = yield new JSZipCLI_1.JSZipCLI(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, ((options.config && { configFile: options.config }) || (options.noconfig && { configFile: false }))), (options.force && { force: options.force })), (options.ignore && { ignoreEntries: [options.ignore] })), (options.output && { outputEntry: options.output })), (options.quiet && { quiet: options.quiet })), (options.verbose && { verbose: options.verbose }))).extract(archives);
85
87
  if (options.output && !options.quiet) {
86
88
  console.info(`Done extracting ${extractedFilesCount} files to "${outputDir}".`);
87
89
  }
@@ -91,7 +93,7 @@ commander
91
93
  process.exit(1);
92
94
  }
93
95
  }));
94
- commander
96
+ commander_1.program
95
97
  .command('fileMode', { hidden: true, isDefault: true })
96
98
  .option('--noconfig', "don't look for a configuration file", false)
97
99
  .option('-c, --config <path>', 'use a configuration file (default: .jsziprc.json)')
@@ -101,12 +103,12 @@ commander
101
103
  .option('-V, --verbose', 'enable verbose logging', false)
102
104
  .option('-q, --quiet', "don't log anything excluding errors", false)
103
105
  .action(() => __awaiter(void 0, void 0, void 0, function* () {
104
- const options = commander.opts();
106
+ const options = commander_1.program.opts();
105
107
  try {
106
108
  if (options.noconfig) {
107
- commander.outputHelp();
109
+ commander_1.program.outputHelp();
108
110
  }
109
- yield new JSZipCLI(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (options.config && { configFile: options.config })), (options.force && { force: options.force })), (options.ignore && { ignoreEntries: [options.ignore] })), (options.output && { outputEntry: options.output })), (options.quiet && { quiet: options.quiet })), (options.verbose && { verbose: options.verbose }))).fileMode();
111
+ yield new JSZipCLI_1.JSZipCLI(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, (options.config && { configFile: options.config })), (options.force && { force: options.force })), (options.ignore && { ignoreEntries: [options.ignore] })), (options.output && { outputEntry: options.output })), (options.quiet && { quiet: options.quiet })), (options.verbose && { verbose: options.verbose }))).fileMode();
110
112
  }
111
113
  catch (error) {
112
114
  if (error.message.includes('ENOENT')) {
@@ -118,4 +120,4 @@ commander
118
120
  process.exit(1);
119
121
  }
120
122
  }));
121
- commander.parse(process.argv);
123
+ commander_1.program.parse(process.argv);
@@ -0,0 +1,2 @@
1
+ export * from './JSZipCLI';
2
+ export * from './interfaces';
package/dist/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./JSZipCLI"), exports);
18
+ __exportStar(require("./interfaces"), exports);
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "author": "Florian Imdahl <git@ffflorian.de>",
3
- "bin": "dist/cjs/cli.js",
3
+ "bin": "dist/cli.js",
4
4
  "dependencies": {
5
5
  "commander": "11.1.0",
6
- "cosmiconfig": "8.3.6",
7
- "fs-extra": "11.1.1",
6
+ "cosmiconfig": "9.0.0",
7
+ "fs-extra": "11.2.0",
8
8
  "glob": "10.3.10",
9
9
  "jszip": "3.10.1",
10
10
  "logdown": "3.3.1",
@@ -16,9 +16,9 @@
16
16
  "@types/progress": "2.0.7",
17
17
  "cross-env": "7.0.3",
18
18
  "rimraf": "5.0.5",
19
- "ts-node": "10.9.1",
20
- "typescript": "5.2.2",
21
- "vitest": "0.34.6"
19
+ "ts-node": "10.9.2",
20
+ "typescript": "5.3.3",
21
+ "vitest": "1.1.0"
22
22
  },
23
23
  "engines": {
24
24
  "node": ">= 10.9"
@@ -33,21 +33,16 @@
33
33
  "zip"
34
34
  ],
35
35
  "license": "GPL-3.0",
36
- "main": "dist/cjs/index.js",
37
- "module": "dist/esm/index.js",
36
+ "main": "dist/index.js",
38
37
  "name": "@ffflorian/jszip-cli",
39
38
  "repository": "https://github.com/ffflorian/node-packages/tree/main/packages/jszip-cli",
40
39
  "scripts": {
41
- "build": "yarn build:cjs && yarn build:esm && yarn generate:packagejson",
42
- "build:cjs": "tsc -p tsconfig.cjs.json",
43
- "build:esm": "tsc -p tsconfig.json",
40
+ "build": "tsc -p tsconfig.json",
44
41
  "clean": "rimraf dist",
45
42
  "dist": "yarn clean && yarn build",
46
- "generate:packagejson": "../../bin/generate-hybrid-package-json.sh",
47
43
  "start": "cross-env NODE_DEBUG=\"jszip-cli/*\" node --loader ts-node/esm src/cli.ts",
48
44
  "test": "vitest run"
49
45
  },
50
- "type": "module",
51
- "version": "3.5.5",
52
- "gitHead": "82888f0b00cccbce10922db5811575bf5dbbe253"
46
+ "version": "3.5.7",
47
+ "gitHead": "3c0d19e5bb6a3f2904837ee4ce40e9ab3ee57db2"
53
48
  }
@@ -1,11 +0,0 @@
1
- import { TerminalOptions } from './interfaces.js';
2
- export declare class ExtractService {
3
- extractedFilesCount: number;
4
- outputDir: string | null;
5
- private readonly logger;
6
- private readonly options;
7
- private readonly progressBar;
8
- constructor(options: Required<TerminalOptions>);
9
- extract(rawEntries: string[]): Promise<ExtractService>;
10
- private printStream;
11
- }
@@ -1,2 +0,0 @@
1
- export * from './JSZipCLI.js';
2
- export * from './interfaces.js';
package/dist/cjs/index.js DELETED
@@ -1,2 +0,0 @@
1
- export * from './JSZipCLI.js';
2
- export * from './interfaces.js';
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- {
2
- "type": "commonjs"
3
- }