diff --git a/.github/dependabot.yml b/.github/dependabot.yml deleted file mode 100644 index e85c6c93..00000000 --- a/.github/dependabot.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -version: 2 -updates: - - package-ecosystem: npm - directory: "/" - schedule: - interval: daily - time: "06:00" - open-pull-requests-limit: 12 - - package-ecosystem: "github-actions" - directory: "/" - schedule: - interval: daily - time: "06:00" - open-pull-requests-limit: 12 diff --git a/.github/labels.yml b/.github/labels.yml new file mode 100644 index 00000000..ff8ca8d4 --- /dev/null +++ b/.github/labels.yml @@ -0,0 +1,78 @@ +--- +- name: "breaking-change" + color: ee0701 + description: "A breaking change for existing users." +- name: "bugfix" + color: ee0701 + description: "Inconsistencies or issues which will cause a problem for users or implementors." +- name: "documentation" + color: 0052cc + description: "Solely about the documentation of the project." +- name: "enhancement" + color: 1d76db + description: "Enhancement of the code, not introducing new features." +- name: "refactor" + color: 1d76db + description: "Improvement of existing code, not introducing new features." +- name: "performance" + color: 1d76db + description: "Improving performance, not introducing new features." +- name: "new-feature" + color: 0e8a16 + description: "New features or options." +- name: "maintenance" + color: 2af79e + description: "Generic maintenance tasks." +- name: "ci" + color: 1d76db + description: "Work that improves the continue integration." +- name: "dependencies" + color: 1d76db + description: "Upgrade or downgrade of project dependencies." + +- name: "in-progress" + color: fbca04 + description: "Issue is currently being resolved by a developer." +- name: "stale" + color: fef2c0 + description: "There has not been activity on this issue or PR for quite some time." +- name: "no-stale" + color: fef2c0 + description: "This issue or PR is exempted from the stable bot." + +- name: "security" + color: ee0701 + description: "Marks a security issue that needs to be resolved asap." +- name: "incomplete" + color: fef2c0 + description: "Marks a PR or issue that is missing information." +- name: "invalid" + color: fef2c0 + description: "Marks a PR or issue that is missing information." + +- name: "beginner-friendly" + color: 0e8a16 + description: "Good first issue for people wanting to contribute to the project." +- name: "help-wanted" + color: 0e8a16 + description: "We need some extra helping hands or expertise in order to resolve this." + +- name: "priority-critical" + color: ee0701 + description: "This should be dealt with ASAP. Not fixing this issue would be a serious error." +- name: "priority-high" + color: b60205 + description: "After critical issues are fixed, these should be dealt with before any further issues." +- name: "priority-medium" + color: 0e8a16 + description: "This issue may be useful, and needs some attention." +- name: "priority-low" + color: e4ea8a + description: "Nice addition, maybe... someday..." + +- name: "major" + color: b60205 + description: "This PR causes a major version bump in the version number." +- name: "minor" + color: 0e8a16 + description: "This PR causes a minor version bump in the version number." diff --git a/.github/release-drafter.yml b/.github/release-drafter.yml index b7a1a826..2f67a8ac 100644 --- a/.github/release-drafter.yml +++ b/.github/release-drafter.yml @@ -1,21 +1,57 @@ +--- +name-template: "$RESOLVED_VERSION" +tag-template: "$RESOLVED_VERSION" +change-template: "- $TITLE @$AUTHOR (#$NUMBER)" +sort-direction: ascending + categories: - - title: "Breaking Changes" + - title: "Breaking changes" labels: - - "breaking change" - - title: "Features" + - "breaking-change" + - title: "New features" labels: - - "enhancement" - - title: "Bug Fixes" + - "new-feature" + - title: "Bug fixes" + labels: + - "bugfix" + - title: "Enhancements" labels: - - "bug" + - "enhancement" + - "refactor" + - "performance" - title: "Maintenance" labels: - - "ci/cd" - - "dependencies" - "maintenance" - - "tooling" -change-template: "- $TITLE (#$NUMBER)" -name-template: "$NEXT_PATCH_VERSION" -tag-template: "$NEXT_PATCH_VERSION" + - "ci" + - title: "Documentation" + labels: + - "documentation" + - title: "Dependency updates" + labels: + - "dependencies" + +version-resolver: + major: + labels: + - "major" + - "breaking-change" + minor: + labels: + - "minor" + - "new-feature" + patch: + labels: + - "bugfix" + - "chore" + - "ci" + - "dependencies" + - "documentation" + - "enhancement" + - "performance" + - "refactor" + default: patch + template: | + ## What’s changed + $CHANGES diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml new file mode 100644 index 00000000..0956ff2c --- /dev/null +++ b/.github/workflows/labels.yml @@ -0,0 +1,23 @@ +--- +name: Sync labels + +# yamllint disable-line rule:truthy +on: + push: + branches: + - main + paths: + - .github/labels.yml + workflow_dispatch: + +jobs: + labels: + name: Sync labels + runs-on: ubuntu-latest + steps: + - name: Check out code from GitHub + uses: actions/checkout@v6 + - name: Run Label Syncer + uses: micnncim/action-label-syncer@v1.3.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index b808ec4a..fe409caa 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -14,17 +14,22 @@ jobs: strategy: matrix: - node-version: [10.x, 12.x, 14.x] + node-version: [18.x, 20.x] steps: - - uses: actions/checkout@v2.3.4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v2.2.0 - with: - node-version: ${{ matrix.node-version }} - - name: npm install and test - run: | - npm ci - npm test - env: - CI: true + - uses: actions/checkout@v6.0.2 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v6.4.0 + with: + node-version: ${{ matrix.node-version }} + - name: npm install and test + run: | + npm ci + npm test + env: + CI: true + - name: Archive production artifacts + uses: actions/upload-artifact@v7 + with: + name: tmp-zip-node-v${{ matrix.node-version }} + path: tmp/*.zip diff --git a/.github/workflows/npmpublish.yml b/.github/workflows/npmpublish.yml index dab8b2d8..63727024 100644 --- a/.github/workflows/npmpublish.yml +++ b/.github/workflows/npmpublish.yml @@ -4,14 +4,18 @@ on: release: types: [published] +permissions: + id-token: write # Required for OIDC + contents: read + jobs: build: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.2.0 + - uses: actions/checkout@v6.0.2 + - uses: actions/setup-node@v6.4.0 with: - node-version: 12 + node-version: 20.20.2 - run: npm ci - run: npm test @@ -19,12 +23,11 @@ jobs: needs: build runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2.3.4 - - uses: actions/setup-node@v2.2.0 + - uses: actions/checkout@v6.0.2 + - uses: actions/setup-node@v6.4.0 with: - node-version: 12 + node-version: 24.15.0 registry-url: https://registry.npmjs.org/ + package-manager-cache: false - run: npm ci - run: npm publish - env: - NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}} diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index 17eddcb9..7d586812 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -10,6 +10,6 @@ jobs: name: Update Release Draft runs-on: ubuntu-latest steps: - - uses: release-drafter/release-drafter@v5 + - uses: release-drafter/release-drafter@v6 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 00000000..1b8ac889 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,3 @@ +# Ignore artifacts: +build +coverage diff --git a/CHANGELOG.md b/CHANGELOG.md index f5323da1..1b034b84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,27 @@ ## Changelog +**7.0.1** — _May 8, 2026_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/7.0.0...7.0.1) + +**7.0.0** — _October 13, 2024_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/6.0.2...7.0.0) + +**6.0.2** — _March 9, 2024_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/6.0.1...6.0.2) + +**6.0.1** — _February 29, 2024_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/6.0.0...6.0.1) + +**6.0.0** — _February 26, 2024_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/5.0.2...6.0.0) + +**5.0.2** — _February 26, 2024_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/5.0.1...5.0.2) + +**5.0.1** — _September 3, 2023_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/5.0.0...5.0.1) + +**5.0.0** — _September 2, 2023_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.2...5.0.0) + +**4.1.2** — _September 2, 2023_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.1...4.1.2) + **4.1.1** — _May 30th, 2021_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.0...4.1.1) ### Maintenance + - Bump mocha from 8.2.1 to 8.4.0 (#70) - Bump crc32-stream from 4.0.1 to 4.0.2 (#59) - Bump y18n from 4.0.0 to 4.0.1 (#69) @@ -21,17 +40,17 @@ **4.0.1** — _July 20, 2020_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.0.0...4.0.1) -* Bump crc32-stream from 3.0.1 to 4.0.0 (#43) @dependabot +- Bump crc32-stream from 3.0.1 to 4.0.0 (#43) @dependabot **4.0.0** — _July 18, 2020_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/3.0.0...4.0.0) -* Bump mocha from 5.2.0 to 8.0.1 (#36) @dependabot -* Bump readable-stream from 2.3.7 to 3.6.0 (#39) @dependabot -* Bump actions/setup-node from v1 to v2.1.0 (#41) @dependabot -* Bump rimraf from 2.7.1 to 3.0.2 (#38) @dependabot -* Bump mkdirp from 0.5.5 to 1.0.4 (#37) @dependabot -* Bump actions/checkout from v1 to v2.3.1 (#40) @dependabot -* remove support for node < 10 (#42) @ctalkington +- Bump mocha from 5.2.0 to 8.0.1 (#36) @dependabot +- Bump readable-stream from 2.3.7 to 3.6.0 (#39) @dependabot +- Bump actions/setup-node from v1 to v2.1.0 (#41) @dependabot +- Bump rimraf from 2.7.1 to 3.0.2 (#38) @dependabot +- Bump mkdirp from 0.5.5 to 1.0.4 (#37) @dependabot +- Bump actions/checkout from v1 to v2.3.1 (#40) @dependabot +- remove support for node < 10 (#42) @ctalkington **3.0.0** — _April 14, 2020_ — [Diff](https://github.com/archiverjs/node-compress-commons/compare/2.1.1...3.0.0) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index eca68a45..629a8f29 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,13 +2,13 @@ #### Code Style Guide -* code should be indented with 2 spaces -* single quotes should be used where feasible -* commas should be followed by a single space (function params, etc) -* variable declaration should include `var`, [no multiple declarations](http://benalman.com/news/2012/05/multiple-var-statements-javascript/) +- code should be indented with 2 spaces +- single quotes should be used where feasible +- commas should be followed by a single space (function params, etc) +- variable declaration should include `var`, [no multiple declarations](http://benalman.com/news/2012/05/multiple-var-statements-javascript/) #### Tests -* tests should be added to the nodeunit configs in `tests/` -* tests can be run with `npm test` -* see existing tests for guidance \ No newline at end of file +- tests should be added to the nodeunit configs in `tests/` +- tests can be run with `npm test` +- see existing tests for guidance diff --git a/README.md b/README.md index 6a74ce14..19d7ee93 100644 --- a/README.md +++ b/README.md @@ -22,4 +22,4 @@ You can also use `npm install https://github.com/archiverjs/node-compress-common Concept inspired by [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™. -Some logic derived from [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™ and [OpenJDK 7](http://openjdk.java.net/). \ No newline at end of file +Some logic derived from [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)™ and [OpenJDK 7](http://openjdk.java.net/). diff --git a/lib/archivers/archive-entry.js b/lib/archivers/archive-entry.js index 86bc5988..f245a334 100644 --- a/lib/archivers/archive-entry.js +++ b/lib/archivers/archive-entry.js @@ -1,16 +1,6 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var ArchiveEntry = module.exports = function() {}; - -ArchiveEntry.prototype.getName = function() {}; - -ArchiveEntry.prototype.getSize = function() {}; - -ArchiveEntry.prototype.getLastModifiedDate = function() {}; - -ArchiveEntry.prototype.isDirectory = function() {}; \ No newline at end of file +export default class ArchiveEntry { + getName() {} + getSize() {} + getLastModifiedDate() {} + isDirectory() {} +} diff --git a/lib/archivers/archive-output-stream.js b/lib/archivers/archive-output-stream.js index b5fa4939..3aaec771 100644 --- a/lib/archivers/archive-output-stream.js +++ b/lib/archivers/archive-output-stream.js @@ -1,117 +1,98 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var inherits = require('util').inherits; -var Transform = require('readable-stream').Transform; - -var ArchiveEntry = require('./archive-entry'); -var util = require('../util'); - -var ArchiveOutputStream = module.exports = function(options) { - if (!(this instanceof ArchiveOutputStream)) { - return new ArchiveOutputStream(options); +import { inherits } from "util"; +import { isStream } from "is-stream"; +import { Transform } from "readable-stream"; +import ArchiveEntry from "./archive-entry.js"; +import { normalizeInputSource } from "../util/index.js"; + +export default class ArchiveOutputStream extends Transform { + constructor(options) { + super(options); + + this.offset = 0; + this._archive = { + finish: false, + finished: false, + processing: false, + }; } - Transform.call(this, options); - - this.offset = 0; - this._archive = { - finish: false, - finished: false, - processing: false - }; -}; - -inherits(ArchiveOutputStream, Transform); - -ArchiveOutputStream.prototype._appendBuffer = function(zae, source, callback) { - // scaffold only -}; - -ArchiveOutputStream.prototype._appendStream = function(zae, source, callback) { - // scaffold only -}; - -ArchiveOutputStream.prototype._emitErrorCallback = function(err) { - if (err) { - this.emit('error', err); + _appendBuffer(zae, source, callback) { + // scaffold only } -}; - -ArchiveOutputStream.prototype._finish = function(ae) { - // scaffold only -}; -ArchiveOutputStream.prototype._normalizeEntry = function(ae) { - // scaffold only -}; - -ArchiveOutputStream.prototype._transform = function(chunk, encoding, callback) { - callback(null, chunk); -}; + _appendStream(zae, source, callback) { + // scaffold only + } -ArchiveOutputStream.prototype.entry = function(ae, source, callback) { - source = source || null; + _emitErrorCallback = function (err) { + if (err) { + this.emit("error", err); + } + }; - if (typeof callback !== 'function') { - callback = this._emitErrorCallback.bind(this); + _finish(ae) { + // scaffold only } - if (!(ae instanceof ArchiveEntry)) { - callback(new Error('not a valid instance of ArchiveEntry')); - return; + _normalizeEntry(ae) { + // scaffold only } - if (this._archive.finish || this._archive.finished) { - callback(new Error('unacceptable entry after finish')); - return; + _transform(chunk, encoding, callback) { + callback(null, chunk); } - if (this._archive.processing) { - callback(new Error('already processing an entry')); - return; + entry(ae, source, callback) { + source = source || null; + if (typeof callback !== "function") { + callback = this._emitErrorCallback.bind(this); + } + if (!(ae instanceof ArchiveEntry)) { + callback(new Error("not a valid instance of ArchiveEntry")); + return; + } + if (this._archive.finish || this._archive.finished) { + callback(new Error("unacceptable entry after finish")); + return; + } + if (this._archive.processing) { + callback(new Error("already processing an entry")); + return; + } + this._archive.processing = true; + this._normalizeEntry(ae); + this._entry = ae; + source = normalizeInputSource(source); + if (Buffer.isBuffer(source)) { + this._appendBuffer(ae, source, callback); + } else if (isStream(source)) { + this._appendStream(ae, source, callback); + } else { + this._archive.processing = false; + callback( + new Error("input source must be valid Stream or Buffer instance"), + ); + return; + } + return this; } - this._archive.processing = true; - this._normalizeEntry(ae); - this._entry = ae; - - source = util.normalizeInputSource(source); - - if (Buffer.isBuffer(source)) { - this._appendBuffer(ae, source, callback); - } else if (util.isStream(source)) { - this._appendStream(ae, source, callback); - } else { - this._archive.processing = false; - callback(new Error('input source must be valid Stream or Buffer instance')); - return; + finish() { + if (this._archive.processing) { + this._archive.finish = true; + return; + } + this._finish(); } - return this; -}; - -ArchiveOutputStream.prototype.finish = function() { - if (this._archive.processing) { - this._archive.finish = true; - return; + getBytesWritten() { + return this.offset; } - this._finish(); -}; - -ArchiveOutputStream.prototype.getBytesWritten = function() { - return this.offset; -}; - -ArchiveOutputStream.prototype.write = function(chunk, cb) { - if (chunk) { - this.offset += chunk.length; + write(chunk, cb) { + if (chunk) { + this.offset += chunk.length; + } + return super.write(chunk, cb); } - - return Transform.prototype.write.call(this, chunk, cb); -}; \ No newline at end of file +} diff --git a/lib/archivers/zip/constants.js b/lib/archivers/zip/constants.js index c30b3250..f901a6f8 100644 --- a/lib/archivers/zip/constants.js +++ b/lib/archivers/zip/constants.js @@ -1,71 +1,100 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -module.exports = { - WORD: 4, - DWORD: 8, - EMPTY: Buffer.alloc(0), - - SHORT: 2, - SHORT_MASK: 0xffff, - SHORT_SHIFT: 16, - SHORT_ZERO: Buffer.from(Array(2)), - LONG: 4, - LONG_ZERO: Buffer.from(Array(4)), - - MIN_VERSION_INITIAL: 10, - MIN_VERSION_DATA_DESCRIPTOR: 20, - MIN_VERSION_ZIP64: 45, - VERSION_MADEBY: 45, - - METHOD_STORED: 0, - METHOD_DEFLATED: 8, - - PLATFORM_UNIX: 3, - PLATFORM_FAT: 0, - - SIG_LFH: 0x04034b50, - SIG_DD: 0x08074b50, - SIG_CFH: 0x02014b50, - SIG_EOCD: 0x06054b50, - SIG_ZIP64_EOCD: 0x06064B50, - SIG_ZIP64_EOCD_LOC: 0x07064B50, - - ZIP64_MAGIC_SHORT: 0xffff, - ZIP64_MAGIC: 0xffffffff, - ZIP64_EXTRA_ID: 0x0001, - - ZLIB_NO_COMPRESSION: 0, - ZLIB_BEST_SPEED: 1, - ZLIB_BEST_COMPRESSION: 9, - ZLIB_DEFAULT_COMPRESSION: -1, - - MODE_MASK: 0xFFF, - DEFAULT_FILE_MODE: 33188, // 010644 = -rw-r--r-- = S_IFREG | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH - DEFAULT_DIR_MODE: 16877, // 040755 = drwxr-xr-x = S_IFDIR | S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH - - EXT_FILE_ATTR_DIR: 1106051088, // 010173200020 = drwxr-xr-x = (((S_IFDIR | 0755) << 16) | S_DOS_D) - EXT_FILE_ATTR_FILE: 2175008800, // 020151000040 = -rw-r--r-- = (((S_IFREG | 0644) << 16) | S_DOS_A) >>> 0 - - // Unix file types - S_IFMT: 61440, // 0170000 type of file mask - S_IFIFO: 4096, // 010000 named pipe (fifo) - S_IFCHR: 8192, // 020000 character special - S_IFDIR: 16384, // 040000 directory - S_IFBLK: 24576, // 060000 block special - S_IFREG: 32768, // 0100000 regular - S_IFLNK: 40960, // 0120000 symbolic link - S_IFSOCK: 49152, // 0140000 socket - - // DOS file type flags - S_DOS_A: 32, // 040 Archive - S_DOS_D: 16, // 020 Directory - S_DOS_V: 8, // 010 Volume - S_DOS_S: 4, // 04 System - S_DOS_H: 2, // 02 Hidden - S_DOS_R: 1 // 01 Read Only +export const WORD = 4; +export const DWORD = 8; +export const EMPTY = Buffer.alloc(0); +export const SHORT = 2; +export const SHORT_MASK = 0xffff; +export const SHORT_SHIFT = 16; +export const SHORT_ZERO = Buffer.from(Array(2)); +export const LONG = 4; +export const LONG_ZERO = Buffer.from(Array(4)); +export const MIN_VERSION_INITIAL = 10; +export const MIN_VERSION_DATA_DESCRIPTOR = 20; +export const MIN_VERSION_ZIP64 = 45; +export const VERSION_MADEBY = 45; +export const METHOD_STORED = 0; +export const METHOD_DEFLATED = 8; +export const PLATFORM_UNIX = 3; +export const PLATFORM_FAT = 0; +export const SIG_LFH = 0x04034b50; +export const SIG_DD = 0x08074b50; +export const SIG_CFH = 0x02014b50; +export const SIG_EOCD = 0x06054b50; +export const SIG_ZIP64_EOCD = 0x06064b50; +export const SIG_ZIP64_EOCD_LOC = 0x07064b50; +export const ZIP64_MAGIC_SHORT = 0xffff; +export const ZIP64_MAGIC = 0xffffffff; +export const ZIP64_EXTRA_ID = 0x0001; +export const ZLIB_NO_COMPRESSION = 0; +export const ZLIB_BEST_SPEED = 1; +export const ZLIB_BEST_COMPRESSION = 9; +export const ZLIB_DEFAULT_COMPRESSION = -1; +export const MODE_MASK = 0xfff; +export const DEFAULT_FILE_MODE = 33188; +export const DEFAULT_DIR_MODE = 16877; +export const EXT_FILE_ATTR_DIR = 1106051088; +export const EXT_FILE_ATTR_FILE = 2175008800; +export const S_IFMT = 61440; +export const S_IFIFO = 4096; +export const S_IFCHR = 8192; +export const S_IFDIR = 16384; +export const S_IFBLK = 24576; +export const S_IFREG = 32768; +export const S_IFLNK = 40960; +export const S_IFSOCK = 49152; +export const S_DOS_A = 32; +export const S_DOS_D = 16; +export const S_DOS_V = 8; +export const S_DOS_S = 4; +export const S_DOS_H = 2; +export const S_DOS_R = 1; // 01 Read Only +export default { + WORD, + DWORD, + EMPTY, + SHORT, + SHORT_MASK, + SHORT_SHIFT, + SHORT_ZERO, + LONG, + LONG_ZERO, + MIN_VERSION_INITIAL, + MIN_VERSION_DATA_DESCRIPTOR, + MIN_VERSION_ZIP64, + VERSION_MADEBY, + METHOD_STORED, + METHOD_DEFLATED, + PLATFORM_UNIX, + PLATFORM_FAT, + SIG_LFH, + SIG_DD, + SIG_CFH, + SIG_EOCD, + SIG_ZIP64_EOCD, + SIG_ZIP64_EOCD_LOC, + ZIP64_MAGIC_SHORT, + ZIP64_MAGIC, + ZIP64_EXTRA_ID, + ZLIB_NO_COMPRESSION, + ZLIB_BEST_SPEED, + ZLIB_BEST_COMPRESSION, + ZLIB_DEFAULT_COMPRESSION, + MODE_MASK, + DEFAULT_FILE_MODE, + DEFAULT_DIR_MODE, + EXT_FILE_ATTR_DIR, + EXT_FILE_ATTR_FILE, + S_IFMT, + S_IFIFO, + S_IFCHR, + S_IFDIR, + S_IFBLK, + S_IFREG, + S_IFLNK, + S_IFSOCK, + S_DOS_A, + S_DOS_D, + S_DOS_V, + S_DOS_S, + S_DOS_H, + S_DOS_R, }; diff --git a/lib/archivers/zip/general-purpose-bit.js b/lib/archivers/zip/general-purpose-bit.js index 62703996..35c8011d 100644 --- a/lib/archivers/zip/general-purpose-bit.js +++ b/lib/archivers/zip/general-purpose-bit.js @@ -1,11 +1,4 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var zipUtil = require('./util'); +import { getShortBytes, getShortBytesValue } from "./util.js"; var DATA_DESCRIPTOR_FLAG = 1 << 3; var ENCRYPTION_FLAG = 1 << 0; @@ -14,88 +7,73 @@ var SLIDING_DICTIONARY_SIZE_FLAG = 1 << 1; var STRONG_ENCRYPTION_FLAG = 1 << 6; var UFT8_NAMES_FLAG = 1 << 11; -var GeneralPurposeBit = module.exports = function() { - if (!(this instanceof GeneralPurposeBit)) { - return new GeneralPurposeBit(); +export default class GeneralPurposeBit { + constructor() { + this.descriptor = false; + this.encryption = false; + this.utf8 = false; + this.numberOfShannonFanoTrees = 0; + this.strongEncryption = false; + this.slidingDictionarySize = 0; + return this; } - - this.descriptor = false; - this.encryption = false; - this.utf8 = false; - this.numberOfShannonFanoTrees = 0; - this.strongEncryption = false; - this.slidingDictionarySize = 0; - - return this; -}; - -GeneralPurposeBit.prototype.encode = function() { - return zipUtil.getShortBytes( - (this.descriptor ? DATA_DESCRIPTOR_FLAG : 0) | - (this.utf8 ? UFT8_NAMES_FLAG : 0) | - (this.encryption ? ENCRYPTION_FLAG : 0) | - (this.strongEncryption ? STRONG_ENCRYPTION_FLAG : 0) - ); -}; - -GeneralPurposeBit.prototype.parse = function(buf, offset) { - var flag = zipUtil.getShortBytesValue(buf, offset); - var gbp = new GeneralPurposeBit(); - - gbp.useDataDescriptor((flag & DATA_DESCRIPTOR_FLAG) !== 0); - gbp.useUTF8ForNames((flag & UFT8_NAMES_FLAG) !== 0); - gbp.useStrongEncryption((flag & STRONG_ENCRYPTION_FLAG) !== 0); - gbp.useEncryption((flag & ENCRYPTION_FLAG) !== 0); - gbp.setSlidingDictionarySize((flag & SLIDING_DICTIONARY_SIZE_FLAG) !== 0 ? 8192 : 4096); - gbp.setNumberOfShannonFanoTrees((flag & NUMBER_OF_SHANNON_FANO_TREES_FLAG) !== 0 ? 3 : 2); - - return gbp; -}; - -GeneralPurposeBit.prototype.setNumberOfShannonFanoTrees = function(n) { - this.numberOfShannonFanoTrees = n; -}; - -GeneralPurposeBit.prototype.getNumberOfShannonFanoTrees = function() { - return this.numberOfShannonFanoTrees; -}; - -GeneralPurposeBit.prototype.setSlidingDictionarySize = function(n) { - this.slidingDictionarySize = n; -}; - -GeneralPurposeBit.prototype.getSlidingDictionarySize = function() { - return this.slidingDictionarySize; -}; - -GeneralPurposeBit.prototype.useDataDescriptor = function(b) { - this.descriptor = b; -}; - -GeneralPurposeBit.prototype.usesDataDescriptor = function() { - return this.descriptor; -}; - -GeneralPurposeBit.prototype.useEncryption = function(b) { - this.encryption = b; -}; - -GeneralPurposeBit.prototype.usesEncryption = function() { - return this.encryption; -}; - -GeneralPurposeBit.prototype.useStrongEncryption = function(b) { - this.strongEncryption = b; -}; - -GeneralPurposeBit.prototype.usesStrongEncryption = function() { - return this.strongEncryption; -}; - -GeneralPurposeBit.prototype.useUTF8ForNames = function(b) { - this.utf8 = b; -}; - -GeneralPurposeBit.prototype.usesUTF8ForNames = function() { - return this.utf8; -}; \ No newline at end of file + encode() { + return getShortBytes( + (this.descriptor ? DATA_DESCRIPTOR_FLAG : 0) | + (this.utf8 ? UFT8_NAMES_FLAG : 0) | + (this.encryption ? ENCRYPTION_FLAG : 0) | + (this.strongEncryption ? STRONG_ENCRYPTION_FLAG : 0), + ); + } + static parse(buf, offset) { + var flag = getShortBytesValue(buf, offset); + var gbp = new GeneralPurposeBit(); + gbp.useDataDescriptor((flag & DATA_DESCRIPTOR_FLAG) !== 0); + gbp.useUTF8ForNames((flag & UFT8_NAMES_FLAG) !== 0); + gbp.useStrongEncryption((flag & STRONG_ENCRYPTION_FLAG) !== 0); + gbp.useEncryption((flag & ENCRYPTION_FLAG) !== 0); + gbp.setSlidingDictionarySize( + (flag & SLIDING_DICTIONARY_SIZE_FLAG) !== 0 ? 8192 : 4096, + ); + gbp.setNumberOfShannonFanoTrees( + (flag & NUMBER_OF_SHANNON_FANO_TREES_FLAG) !== 0 ? 3 : 2, + ); + return gbp; + } + setNumberOfShannonFanoTrees(n) { + this.numberOfShannonFanoTrees = n; + } + getNumberOfShannonFanoTrees() { + return this.numberOfShannonFanoTrees; + } + setSlidingDictionarySize(n) { + this.slidingDictionarySize = n; + } + getSlidingDictionarySize() { + return this.slidingDictionarySize; + } + useDataDescriptor(b) { + this.descriptor = b; + } + usesDataDescriptor() { + return this.descriptor; + } + useEncryption(b) { + this.encryption = b; + } + usesEncryption() { + return this.encryption; + } + useStrongEncryption(b) { + this.strongEncryption = b; + } + usesStrongEncryption() { + return this.strongEncryption; + } + useUTF8ForNames(b) { + this.utf8 = b; + } + usesUTF8ForNames() { + return this.utf8; + } +} diff --git a/lib/archivers/zip/unix-stat.js b/lib/archivers/zip/unix-stat.js index 1326cd1d..896a89d9 100644 --- a/lib/archivers/zip/unix-stat.js +++ b/lib/archivers/zip/unix-stat.js @@ -1,53 +1,19 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -module.exports = { - /** - * Bits used for permissions (and sticky bit) - */ - PERM_MASK: 4095, // 07777 - - /** - * Bits used to indicate the filesystem object type. - */ - FILE_TYPE_FLAG: 61440, // 0170000 - - /** - * Indicates symbolic links. - */ - LINK_FLAG: 40960, // 0120000 - - /** - * Indicates plain files. - */ - FILE_FLAG: 32768, // 0100000 - - /** - * Indicates directories. - */ - DIR_FLAG: 16384, // 040000 - - // ---------------------------------------------------------- - // somewhat arbitrary choices that are quite common for shared - // installations - // ----------------------------------------------------------- - - /** - * Default permissions for symbolic links. - */ - DEFAULT_LINK_PERM: 511, // 0777 - - /** - * Default permissions for directories. - */ - DEFAULT_DIR_PERM: 493, // 0755 - - /** - * Default permissions for plain files. - */ - DEFAULT_FILE_PERM: 420 // 0644 -}; \ No newline at end of file +export const PERM_MASK = 4095; +export const FILE_TYPE_FLAG = 61440; +export const LINK_FLAG = 40960; +export const FILE_FLAG = 32768; +export const DIR_FLAG = 16384; +export const DEFAULT_LINK_PERM = 511; +export const DEFAULT_DIR_PERM = 493; +export const DEFAULT_FILE_PERM = 420; // 0644 + +export default { + PERM_MASK, + FILE_TYPE_FLAG, + LINK_FLAG, + FILE_FLAG, + DIR_FLAG, + DEFAULT_LINK_PERM, + DEFAULT_DIR_PERM, + DEFAULT_FILE_PERM, +}; diff --git a/lib/archivers/zip/util.js b/lib/archivers/zip/util.js index 22055ae5..73f09ffa 100644 --- a/lib/archivers/zip/util.js +++ b/lib/archivers/zip/util.js @@ -1,74 +1,74 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var util = module.exports = {}; - -util.dateToDos = function(d, forceLocalTime) { +export function dateToDos(d, forceLocalTime) { forceLocalTime = forceLocalTime || false; - var year = forceLocalTime ? d.getFullYear() : d.getUTCFullYear(); - if (year < 1980) { return 2162688; // 1980-1-1 00:00:00 } else if (year >= 2044) { return 2141175677; // 2043-12-31 23:59:58 } - var val = { year: year, month: forceLocalTime ? d.getMonth() : d.getUTCMonth(), date: forceLocalTime ? d.getDate() : d.getUTCDate(), hours: forceLocalTime ? d.getHours() : d.getUTCHours(), minutes: forceLocalTime ? d.getMinutes() : d.getUTCMinutes(), - seconds: forceLocalTime ? d.getSeconds() : d.getUTCSeconds() + seconds: forceLocalTime ? d.getSeconds() : d.getUTCSeconds(), }; - - return ((val.year - 1980) << 25) | ((val.month + 1) << 21) | (val.date << 16) | - (val.hours << 11) | (val.minutes << 5) | (val.seconds / 2); -}; - -util.dosToDate = function(dos) { - return new Date(((dos >> 25) & 0x7f) + 1980, ((dos >> 21) & 0x0f) - 1, (dos >> 16) & 0x1f, (dos >> 11) & 0x1f, (dos >> 5) & 0x3f, (dos & 0x1f) << 1); -}; - -util.fromDosTime = function(buf) { - return util.dosToDate(buf.readUInt32LE(0)); -}; - -util.getEightBytes = function(v) { + return ( + ((val.year - 1980) << 25) | + ((val.month + 1) << 21) | + (val.date << 16) | + (val.hours << 11) | + (val.minutes << 5) | + (val.seconds / 2) + ); +} +export function dosToDate(dos) { + return new Date( + ((dos >> 25) & 0x7f) + 1980, + ((dos >> 21) & 0x0f) - 1, + (dos >> 16) & 0x1f, + (dos >> 11) & 0x1f, + (dos >> 5) & 0x3f, + (dos & 0x1f) << 1, + ); +} +export function fromDosTime(buf) { + return dosToDate(buf.readUInt32LE(0)); +} +export function getEightBytes(v) { var buf = Buffer.alloc(8); buf.writeUInt32LE(v % 0x0100000000, 0); buf.writeUInt32LE((v / 0x0100000000) | 0, 4); - return buf; -}; - -util.getShortBytes = function(v) { +} +export function getShortBytes(v) { var buf = Buffer.alloc(2); - buf.writeUInt16LE((v & 0xFFFF) >>> 0, 0); - + buf.writeUInt16LE((v & 0xffff) >>> 0, 0); return buf; -}; - -util.getShortBytesValue = function(buf, offset) { +} +export function getShortBytesValue(buf, offset) { return buf.readUInt16LE(offset); -}; - -util.getLongBytes = function(v) { +} +export function getLongBytes(v) { var buf = Buffer.alloc(4); - buf.writeUInt32LE((v & 0xFFFFFFFF) >>> 0, 0); - + buf.writeUInt32LE((v & 0xffffffff) >>> 0, 0); return buf; -}; - -util.getLongBytesValue = function(buf, offset) { +} +export function getLongBytesValue(buf, offset) { return buf.readUInt32LE(offset); +} +export function toDosTime(d) { + return getLongBytes(util.dateToDos(d)); +} +export default { + dateToDos, + dosToDate, + fromDosTime, + getEightBytes, + getShortBytes, + getShortBytesValue, + getLongBytes, + getLongBytesValue, + toDosTime, }; - -util.toDosTime = function(d) { - return util.getLongBytes(util.dateToDos(d)); -}; \ No newline at end of file diff --git a/lib/archivers/zip/zip-archive-entry.js b/lib/archivers/zip/zip-archive-entry.js index c53ad0ad..2f01d458 100644 --- a/lib/archivers/zip/zip-archive-entry.js +++ b/lib/archivers/zip/zip-archive-entry.js @@ -1,413 +1,380 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var inherits = require('util').inherits; -var normalizePath = require('normalize-path'); - -var ArchiveEntry = require('../archive-entry'); -var GeneralPurposeBit = require('./general-purpose-bit'); -var UnixStat = require('./unix-stat'); - -var constants = require('./constants'); -var zipUtil = require('./util'); - -var ZipArchiveEntry = module.exports = function(name) { - if (!(this instanceof ZipArchiveEntry)) { - return new ZipArchiveEntry(name); +import { inherits } from "util"; +import normalizePath from "normalize-path"; +import ArchiveEntry from "../archive-entry.js"; +import GeneralPurposeBit from "./general-purpose-bit.js"; +import UnixStat from "./unix-stat.js"; +import { + EMPTY, + MIN_VERSION_INITIAL, + MODE_MASK, + PLATFORM_FAT, + PLATFORM_UNIX, + S_DOS_A, + S_DOS_D, + S_IFDIR, + S_IFREG, + SHORT_MASK, + SHORT_SHIFT, + ZIP64_MAGIC, +} from "./constants.js"; +import { dateToDos, dosToDate } from "./util.js"; + +export default class ZipArchiveEntry extends ArchiveEntry { + constructor(name) { + super(); + this.platform = PLATFORM_FAT; + this.method = -1; + this.name = null; + this.size = 0; + this.csize = 0; + this.gpb = new GeneralPurposeBit(); + this.crc = 0; + this.time = -1; + this.minver = MIN_VERSION_INITIAL; + this.mode = -1; + this.extra = null; + this.exattr = 0; + this.inattr = 0; + this.comment = null; + if (name) { + this.setName(name); + } } - ArchiveEntry.call(this); - - this.platform = constants.PLATFORM_FAT; - this.method = -1; - - this.name = null; - this.size = 0; - this.csize = 0; - this.gpb = new GeneralPurposeBit(); - this.crc = 0; - this.time = -1; - - this.minver = constants.MIN_VERSION_INITIAL; - this.mode = -1; - this.extra = null; - this.exattr = 0; - this.inattr = 0; - this.comment = null; - - if (name) { - this.setName(name); + /** + * Returns the extra fields related to the entry. + * + * @returns {Buffer} + */ + getCentralDirectoryExtra() { + return this.getExtra(); } -}; - -inherits(ZipArchiveEntry, ArchiveEntry); - -/** - * Returns the extra fields related to the entry. - * - * @returns {Buffer} - */ -ZipArchiveEntry.prototype.getCentralDirectoryExtra = function() { - return this.getExtra(); -}; - -/** - * Returns the comment set for the entry. - * - * @returns {string} - */ -ZipArchiveEntry.prototype.getComment = function() { - return this.comment !== null ? this.comment : ''; -}; - -/** - * Returns the compressed size of the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getCompressedSize = function() { - return this.csize; -}; - -/** - * Returns the CRC32 digest for the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getCrc = function() { - return this.crc; -}; - -/** - * Returns the external file attributes for the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getExternalAttributes = function() { - return this.exattr; -}; - -/** - * Returns the extra fields related to the entry. - * - * @returns {Buffer} - */ -ZipArchiveEntry.prototype.getExtra = function() { - return this.extra !== null ? this.extra : constants.EMPTY; -}; - -/** - * Returns the general purpose bits related to the entry. - * - * @returns {GeneralPurposeBit} - */ -ZipArchiveEntry.prototype.getGeneralPurposeBit = function() { - return this.gpb; -}; - -/** - * Returns the internal file attributes for the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getInternalAttributes = function() { - return this.inattr; -}; - -/** - * Returns the last modified date of the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getLastModifiedDate = function() { - return this.getTime(); -}; -/** - * Returns the extra fields related to the entry. - * - * @returns {Buffer} - */ -ZipArchiveEntry.prototype.getLocalFileDataExtra = function() { - return this.getExtra(); -}; - -/** - * Returns the compression method used on the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getMethod = function() { - return this.method; -}; - -/** - * Returns the filename of the entry. - * - * @returns {string} - */ -ZipArchiveEntry.prototype.getName = function() { - return this.name; -}; - -/** - * Returns the platform on which the entry was made. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getPlatform = function() { - return this.platform; -}; - -/** - * Returns the size of the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getSize = function() { - return this.size; -}; - -/** - * Returns a date object representing the last modified date of the entry. - * - * @returns {number|Date} - */ -ZipArchiveEntry.prototype.getTime = function() { - return this.time !== -1 ? zipUtil.dosToDate(this.time) : -1; -}; - -/** - * Returns the DOS timestamp for the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getTimeDos = function() { - return this.time !== -1 ? this.time : 0; -}; - -/** - * Returns the UNIX file permissions for the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getUnixMode = function() { - return this.platform !== constants.PLATFORM_UNIX ? 0 : ((this.getExternalAttributes() >> constants.SHORT_SHIFT) & constants.SHORT_MASK); -}; - -/** - * Returns the version of ZIP needed to extract the entry. - * - * @returns {number} - */ -ZipArchiveEntry.prototype.getVersionNeededToExtract = function() { - return this.minver; -}; - -/** - * Sets the comment of the entry. - * - * @param comment - */ -ZipArchiveEntry.prototype.setComment = function(comment) { - if (Buffer.byteLength(comment) !== comment.length) { - this.getGeneralPurposeBit().useUTF8ForNames(true); + /** + * Returns the comment set for the entry. + * + * @returns {string} + */ + getComment() { + return this.comment !== null ? this.comment : ""; } - this.comment = comment; -}; - -/** - * Sets the compressed size of the entry. - * - * @param size - */ -ZipArchiveEntry.prototype.setCompressedSize = function(size) { - if (size < 0) { - throw new Error('invalid entry compressed size'); + /** + * Returns the compressed size of the entry. + * + * @returns {number} + */ + getCompressedSize() { + return this.csize; } - this.csize = size; -}; - -/** - * Sets the checksum of the entry. - * - * @param crc - */ -ZipArchiveEntry.prototype.setCrc = function(crc) { - if (crc < 0) { - throw new Error('invalid entry crc32'); + /** + * Returns the CRC32 digest for the entry. + * + * @returns {number} + */ + getCrc() { + return this.crc; } - this.crc = crc; -}; - -/** - * Sets the external file attributes of the entry. - * - * @param attr - */ -ZipArchiveEntry.prototype.setExternalAttributes = function(attr) { - this.exattr = attr >>> 0; -}; - -/** - * Sets the extra fields related to the entry. - * - * @param extra - */ -ZipArchiveEntry.prototype.setExtra = function(extra) { - this.extra = extra; -}; - -/** - * Sets the general purpose bits related to the entry. - * - * @param gpb - */ -ZipArchiveEntry.prototype.setGeneralPurposeBit = function(gpb) { - if (!(gpb instanceof GeneralPurposeBit)) { - throw new Error('invalid entry GeneralPurposeBit'); + /** + * Returns the external file attributes for the entry. + * + * @returns {number} + */ + getExternalAttributes = function () { + return this.exattr; + }; + + /** + * Returns the extra fields related to the entry. + * + * @returns {Buffer} + */ + getExtra() { + return this.extra !== null ? this.extra : EMPTY; } - this.gpb = gpb; -}; - -/** - * Sets the internal file attributes of the entry. - * - * @param attr - */ -ZipArchiveEntry.prototype.setInternalAttributes = function(attr) { - this.inattr = attr; -}; - -/** - * Sets the compression method of the entry. - * - * @param method - */ -ZipArchiveEntry.prototype.setMethod = function(method) { - if (method < 0) { - throw new Error('invalid entry compression method'); + /** + * Returns the general purpose bits related to the entry. + * + * @returns {GeneralPurposeBit} + */ + getGeneralPurposeBit() { + return this.gpb; } - this.method = method; -}; - -/** - * Sets the name of the entry. - * - * @param name - * @param prependSlash - */ -ZipArchiveEntry.prototype.setName = function(name, prependSlash = false) { - name = normalizePath(name, false) - .replace(/^\w+:/, '') - .replace(/^(\.\.\/|\/)+/, ''); - - if (prependSlash) { - name = `/${name}`; + /** + * Returns the internal file attributes for the entry. + * + * @returns {number} + */ + getInternalAttributes() { + return this.inattr; } - if (Buffer.byteLength(name) !== name.length) { - this.getGeneralPurposeBit().useUTF8ForNames(true); + /** + * Returns the last modified date of the entry. + * + * @returns {number} + */ + getLastModifiedDate() { + return this.getTime(); } - this.name = name; -}; - -/** - * Sets the platform on which the entry was made. - * - * @param platform - */ -ZipArchiveEntry.prototype.setPlatform = function(platform) { - this.platform = platform; -}; - -/** - * Sets the size of the entry. - * - * @param size - */ -ZipArchiveEntry.prototype.setSize = function(size) { - if (size < 0) { - throw new Error('invalid entry size'); + /** + * Returns the extra fields related to the entry. + * + * @returns {Buffer} + */ + getLocalFileDataExtra() { + return this.getExtra(); } - this.size = size; -}; - -/** - * Sets the time of the entry. - * - * @param time - * @param forceLocalTime - */ -ZipArchiveEntry.prototype.setTime = function(time, forceLocalTime) { - if (!(time instanceof Date)) { - throw new Error('invalid entry time'); + /** + * Returns the compression method used on the entry. + * + * @returns {number} + */ + getMethod() { + return this.method; } - this.time = zipUtil.dateToDos(time, forceLocalTime); -}; - -/** - * Sets the UNIX file permissions for the entry. - * - * @param mode - */ -ZipArchiveEntry.prototype.setUnixMode = function(mode) { - mode |= this.isDirectory() ? constants.S_IFDIR : constants.S_IFREG; - - var extattr = 0; - extattr |= (mode << constants.SHORT_SHIFT) | (this.isDirectory() ? constants.S_DOS_D : constants.S_DOS_A); - - this.setExternalAttributes(extattr); - this.mode = mode & constants.MODE_MASK; - this.platform = constants.PLATFORM_UNIX; -}; - -/** - * Sets the version of ZIP needed to extract this entry. - * - * @param minver - */ -ZipArchiveEntry.prototype.setVersionNeededToExtract = function(minver) { - this.minver = minver; -}; - -/** - * Returns true if this entry represents a directory. - * - * @returns {boolean} - */ -ZipArchiveEntry.prototype.isDirectory = function() { - return this.getName().slice(-1) === '/'; -}; + /** + * Returns the filename of the entry. + * + * @returns {string} + */ + getName() { + return this.name; + } -/** - * Returns true if this entry represents a unix symlink, - * in which case the entry's content contains the target path - * for the symlink. - * - * @returns {boolean} - */ -ZipArchiveEntry.prototype.isUnixSymlink = function() { - return (this.getUnixMode() & UnixStat.FILE_TYPE_FLAG) === UnixStat.LINK_FLAG; -}; + /** + * Returns the platform on which the entry was made. + * + * @returns {number} + */ + getPlatform() { + return this.platform; + } + /** + * Returns the size of the entry. + * + * @returns {number} + */ + getSize() { + return this.size; + } + /** + * Returns a date object representing the last modified date of the entry. + * + * @returns {number|Date} + */ + getTime() { + return this.time !== -1 ? dosToDate(this.time) : -1; + } + /** + * Returns the DOS timestamp for the entry. + * + * @returns {number} + */ + getTimeDos() { + return this.time !== -1 ? this.time : 0; + } + /** + * Returns the UNIX file permissions for the entry. + * + * @returns {number} + */ + getUnixMode() { + return this.platform !== PLATFORM_UNIX + ? 0 + : (this.getExternalAttributes() >> SHORT_SHIFT) & SHORT_MASK; + } + /** + * Returns the version of ZIP needed to extract the entry. + * + * @returns {number} + */ + getVersionNeededToExtract() { + return this.minver; + } + /** + * Sets the comment of the entry. + * + * @param comment + */ + setComment(comment) { + if (Buffer.byteLength(comment) !== comment.length) { + this.getGeneralPurposeBit().useUTF8ForNames(true); + } + this.comment = comment; + } + /** + * Sets the compressed size of the entry. + * + * @param size + */ + setCompressedSize(size) { + if (size < 0) { + throw new Error("invalid entry compressed size"); + } + this.csize = size; + } + /** + * Sets the checksum of the entry. + * + * @param crc + */ + setCrc(crc) { + if (crc < 0) { + throw new Error("invalid entry crc32"); + } + this.crc = crc; + } + /** + * Sets the external file attributes of the entry. + * + * @param attr + */ + setExternalAttributes(attr) { + this.exattr = attr >>> 0; + } + /** + * Sets the extra fields related to the entry. + * + * @param extra + */ + setExtra(extra) { + this.extra = extra; + } + /** + * Sets the general purpose bits related to the entry. + * + * @param gpb + */ + setGeneralPurposeBit(gpb) { + if (!(gpb instanceof GeneralPurposeBit)) { + throw new Error("invalid entry GeneralPurposeBit"); + } + this.gpb = gpb; + } + /** + * Sets the internal file attributes of the entry. + * + * @param attr + */ + setInternalAttributes(attr) { + this.inattr = attr; + } + /** + * Sets the compression method of the entry. + * + * @param method + */ + setMethod(method) { + if (method < 0) { + throw new Error("invalid entry compression method"); + } + this.method = method; + } + /** + * Sets the name of the entry. + * + * @param name + * @param prependSlash + */ + setName(name, prependSlash = false) { + name = normalizePath(name, false) + .replace(/^\w+:/, "") + .replace(/^(\.\.\/|\/)+/, ""); + if (prependSlash) { + name = `/${name}`; + } + if (Buffer.byteLength(name) !== name.length) { + this.getGeneralPurposeBit().useUTF8ForNames(true); + } + this.name = name; + } + /** + * Sets the platform on which the entry was made. + * + * @param platform + */ + setPlatform(platform) { + this.platform = platform; + } + /** + * Sets the size of the entry. + * + * @param size + */ + setSize(size) { + if (size < 0) { + throw new Error("invalid entry size"); + } + this.size = size; + } + /** + * Sets the time of the entry. + * + * @param time + * @param forceLocalTime + */ + setTime(time, forceLocalTime) { + if (!(time instanceof Date)) { + throw new Error("invalid entry time"); + } + this.time = dateToDos(time, forceLocalTime); + } + /** + * Sets the UNIX file permissions for the entry. + * + * @param mode + */ + setUnixMode(mode) { + mode |= this.isDirectory() ? S_IFDIR : S_IFREG; + var extattr = 0; + extattr |= (mode << SHORT_SHIFT) | (this.isDirectory() ? S_DOS_D : S_DOS_A); + this.setExternalAttributes(extattr); + this.mode = mode & MODE_MASK; + this.platform = PLATFORM_UNIX; + } + /** + * Sets the version of ZIP needed to extract this entry. + * + * @param minver + */ + setVersionNeededToExtract(minver) { + this.minver = minver; + } + /** + * Returns true if this entry represents a directory. + * + * @returns {boolean} + */ + isDirectory() { + return this.getName().slice(-1) === "/"; + } + /** + * Returns true if this entry represents a unix symlink, + * in which case the entry's content contains the target path + * for the symlink. + * + * @returns {boolean} + */ + isUnixSymlink() { + return ( + (this.getUnixMode() & UnixStat.FILE_TYPE_FLAG) === UnixStat.LINK_FLAG + ); + } -/** - * Returns true if this entry is using the ZIP64 extension of ZIP. - * - * @returns {boolean} - */ -ZipArchiveEntry.prototype.isZip64 = function() { - return this.csize > constants.ZIP64_MAGIC || this.size > constants.ZIP64_MAGIC; -}; + /** + * Returns true if this entry is using the ZIP64 extension of ZIP. + * + * @returns {boolean} + */ + isZip64() { + return this.csize > ZIP64_MAGIC || this.size > ZIP64_MAGIC; + } +} diff --git a/lib/archivers/zip/zip-archive-output-stream.js b/lib/archivers/zip/zip-archive-output-stream.js index 0b17dd49..33711fc8 100644 --- a/lib/archivers/zip/zip-archive-output-stream.js +++ b/lib/archivers/zip/zip-archive-output-stream.js @@ -1,440 +1,371 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var inherits = require('util').inherits; -var crc32 = require('buffer-crc32'); -var {CRC32Stream} = require('crc32-stream'); -var {DeflateCRC32Stream} = require('crc32-stream'); - -var ArchiveOutputStream = require('../archive-output-stream'); -var ZipArchiveEntry = require('./zip-archive-entry'); -var GeneralPurposeBit = require('./general-purpose-bit'); - -var constants = require('./constants'); -var util = require('../../util'); -var zipUtil = require('./util'); - -var ZipArchiveOutputStream = module.exports = function(options) { - if (!(this instanceof ZipArchiveOutputStream)) { - return new ZipArchiveOutputStream(options); - } - - options = this.options = this._defaults(options); - - ArchiveOutputStream.call(this, options); - - this._entry = null; - this._entries = []; - this._archive = { - centralLength: 0, - centralOffset: 0, - comment: '', - finish: false, - finished: false, - processing: false, - forceZip64: options.forceZip64, - forceLocalTime: options.forceLocalTime - }; -}; - -inherits(ZipArchiveOutputStream, ArchiveOutputStream); - -ZipArchiveOutputStream.prototype._afterAppend = function(ae) { - this._entries.push(ae); - - if (ae.getGeneralPurposeBit().usesDataDescriptor()) { - this._writeDataDescriptor(ae); - } - - this._archive.processing = false; - this._entry = null; - - if (this._archive.finish && !this._archive.finished) { - this._finish(); - } -}; - -ZipArchiveOutputStream.prototype._appendBuffer = function(ae, source, callback) { - if (source.length === 0) { - ae.setMethod(constants.METHOD_STORED); - } - - var method = ae.getMethod(); - - if (method === constants.METHOD_STORED) { - ae.setSize(source.length); - ae.setCompressedSize(source.length); - ae.setCrc(crc32.unsigned(source)); - } - - this._writeLocalFileHeader(ae); - - if (method === constants.METHOD_STORED) { - this.write(source); - this._afterAppend(ae); - callback(null, ae); - return; - } else if (method === constants.METHOD_DEFLATED) { - this._smartStream(ae, callback).end(source); - return; - } else { - callback(new Error('compression method ' + method + ' not implemented')); - return; - } -}; - -ZipArchiveOutputStream.prototype._appendStream = function(ae, source, callback) { - ae.getGeneralPurposeBit().useDataDescriptor(true); - ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR); - - this._writeLocalFileHeader(ae); - - var smart = this._smartStream(ae, callback); - source.once('error', function(err) { - smart.emit('error', err); - smart.end(); - }) - source.pipe(smart); -}; - -ZipArchiveOutputStream.prototype._defaults = function(o) { - if (typeof o !== 'object') { +import { inherits } from "util"; +import crc32 from "crc-32"; +import { CRC32Stream, DeflateCRC32Stream } from "crc32-stream"; +import ArchiveOutputStream from "../archive-output-stream.js"; +import ZipArchiveEntry from "./zip-archive-entry.js"; +import GeneralPurposeBit from "./general-purpose-bit.js"; +import { + LONG_ZERO, + METHOD_DEFLATED, + METHOD_STORED, + MIN_VERSION_DATA_DESCRIPTOR, + MIN_VERSION_ZIP64, + SHORT_ZERO, + SIG_EOCD, + SIG_DD, + SIG_CFH, + SIG_LFH, + SIG_ZIP64_EOCD, + SIG_ZIP64_EOCD_LOC, + VERSION_MADEBY, + ZIP64_EXTRA_ID, + ZIP64_MAGIC, + ZIP64_MAGIC_SHORT, + ZLIB_BEST_SPEED, +} from "./constants.js"; +import { getEightBytes, getLongBytes, getShortBytes } from "./util.js"; + +function _defaults(o) { + if (typeof o !== "object") { o = {}; } - - if (typeof o.zlib !== 'object') { + if (typeof o.zlib !== "object") { o.zlib = {}; } - - if (typeof o.zlib.level !== 'number') { - o.zlib.level = constants.ZLIB_BEST_SPEED; + if (typeof o.zlib.level !== "number") { + o.zlib.level = ZLIB_BEST_SPEED; } - o.forceZip64 = !!o.forceZip64; o.forceLocalTime = !!o.forceLocalTime; - return o; -}; - -ZipArchiveOutputStream.prototype._finish = function() { - this._archive.centralOffset = this.offset; - - this._entries.forEach(function(ae) { - this._writeCentralFileHeader(ae); - }.bind(this)); - - this._archive.centralLength = this.offset - this._archive.centralOffset; - - if (this.isZip64()) { - this._writeCentralDirectoryZip64(); +} + +export default class ZipArchiveOutputStream extends ArchiveOutputStream { + constructor(options) { + const _options = _defaults(options); + super(_options); + this.options = _options; + this._entry = null; + this._entries = []; + this._archive = { + centralLength: 0, + centralOffset: 0, + comment: "", + finish: false, + finished: false, + processing: false, + forceZip64: _options.forceZip64, + forceLocalTime: _options.forceLocalTime, + }; } - this._writeCentralDirectoryEnd(); - - this._archive.processing = false; - this._archive.finish = true; - this._archive.finished = true; - this.end(); -}; + _afterAppend(ae) { + this._entries.push(ae); + if (ae.getGeneralPurposeBit().usesDataDescriptor()) { + this._writeDataDescriptor(ae); + } + this._archive.processing = false; + this._entry = null; + if (this._archive.finish && !this._archive.finished) { + this._finish(); + } + } -ZipArchiveOutputStream.prototype._normalizeEntry = function(ae) { - if (ae.getMethod() === -1) { - ae.setMethod(constants.METHOD_DEFLATED); + _appendBuffer(ae, source, callback) { + if (source.length === 0) { + ae.setMethod(METHOD_STORED); + } + var method = ae.getMethod(); + if (method === METHOD_STORED) { + ae.setSize(source.length); + ae.setCompressedSize(source.length); + ae.setCrc(crc32.buf(source) >>> 0); + } + this._writeLocalFileHeader(ae); + if (method === METHOD_STORED) { + this.write(source); + this._afterAppend(ae); + callback(null, ae); + return; + } else if (method === METHOD_DEFLATED) { + this._smartStream(ae, callback).end(source); + return; + } else { + callback(new Error("compression method " + method + " not implemented")); + return; + } } - if (ae.getMethod() === constants.METHOD_DEFLATED) { + _appendStream(ae, source, callback) { ae.getGeneralPurposeBit().useDataDescriptor(true); - ae.setVersionNeededToExtract(constants.MIN_VERSION_DATA_DESCRIPTOR); + ae.setVersionNeededToExtract(MIN_VERSION_DATA_DESCRIPTOR); + this._writeLocalFileHeader(ae); + var smart = this._smartStream(ae, callback); + source.once("error", function (err) { + smart.emit("error", err); + smart.end(); + }); + source.pipe(smart); } - if (ae.getTime() === -1) { - ae.setTime(new Date(), this._archive.forceLocalTime); + _finish() { + this._archive.centralOffset = this.offset; + this._entries.forEach( + function (ae) { + this._writeCentralFileHeader(ae); + }.bind(this), + ); + this._archive.centralLength = this.offset - this._archive.centralOffset; + if (this.isZip64()) { + this._writeCentralDirectoryZip64(); + } + this._writeCentralDirectoryEnd(); + this._archive.processing = false; + this._archive.finish = true; + this._archive.finished = true; + this.end(); } - ae._offsets = { - file: 0, - data: 0, - contents: 0, - }; -}; - -ZipArchiveOutputStream.prototype._smartStream = function(ae, callback) { - var deflate = ae.getMethod() === constants.METHOD_DEFLATED; - var process = deflate ? new DeflateCRC32Stream(this.options.zlib) : new CRC32Stream(); - var error = null; - - function handleStuff() { - var digest = process.digest().readUInt32BE(0); - ae.setCrc(digest); - ae.setSize(process.size()); - ae.setCompressedSize(process.size(true)); - this._afterAppend(ae); - callback(error, ae); + _normalizeEntry(ae) { + if (ae.getMethod() === -1) { + ae.setMethod(METHOD_DEFLATED); + } + if (ae.getMethod() === METHOD_DEFLATED) { + ae.getGeneralPurposeBit().useDataDescriptor(true); + ae.setVersionNeededToExtract(MIN_VERSION_DATA_DESCRIPTOR); + } + if (ae.getTime() === -1) { + ae.setTime(new Date(), this._archive.forceLocalTime); + } + ae._offsets = { + file: 0, + data: 0, + contents: 0, + }; } - process.once('end', handleStuff.bind(this)); - process.once('error', function(err) { - error = err; - }); - - process.pipe(this, { end: false }); - - return process; -}; - -ZipArchiveOutputStream.prototype._writeCentralDirectoryEnd = function() { - var records = this._entries.length; - var size = this._archive.centralLength; - var offset = this._archive.centralOffset; - - if (this.isZip64()) { - records = constants.ZIP64_MAGIC_SHORT; - size = constants.ZIP64_MAGIC; - offset = constants.ZIP64_MAGIC; + _smartStream(ae, callback) { + var deflate = ae.getMethod() === METHOD_DEFLATED; + var process = deflate + ? new DeflateCRC32Stream(this.options.zlib) + : new CRC32Stream(); + var error = null; + function handleStuff() { + var digest = process.digest().readUInt32BE(0); + ae.setCrc(digest); + ae.setSize(process.size()); + ae.setCompressedSize(process.size(true)); + this._afterAppend(ae); + callback(error, ae); + } + process.once("end", handleStuff.bind(this)); + process.once("error", function (err) { + error = err; + }); + process.pipe(this, { end: false }); + return process; } - // signature - this.write(zipUtil.getLongBytes(constants.SIG_EOCD)); - - // disk numbers - this.write(constants.SHORT_ZERO); - this.write(constants.SHORT_ZERO); - - // number of entries - this.write(zipUtil.getShortBytes(records)); - this.write(zipUtil.getShortBytes(records)); - - // length and location of CD - this.write(zipUtil.getLongBytes(size)); - this.write(zipUtil.getLongBytes(offset)); - - // archive comment - var comment = this.getComment(); - var commentLength = Buffer.byteLength(comment); - this.write(zipUtil.getShortBytes(commentLength)); - this.write(comment); -}; - -ZipArchiveOutputStream.prototype._writeCentralDirectoryZip64 = function() { - // signature - this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD)); - - // size of the ZIP64 EOCD record - this.write(zipUtil.getEightBytes(44)); - - // version made by - this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64)); - - // version to extract - this.write(zipUtil.getShortBytes(constants.MIN_VERSION_ZIP64)); - - // disk numbers - this.write(constants.LONG_ZERO); - this.write(constants.LONG_ZERO); - - // number of entries - this.write(zipUtil.getEightBytes(this._entries.length)); - this.write(zipUtil.getEightBytes(this._entries.length)); - - // length and location of CD - this.write(zipUtil.getEightBytes(this._archive.centralLength)); - this.write(zipUtil.getEightBytes(this._archive.centralOffset)); - - // extensible data sector - // not implemented at this time - - // end of central directory locator - this.write(zipUtil.getLongBytes(constants.SIG_ZIP64_EOCD_LOC)); - - // disk number holding the ZIP64 EOCD record - this.write(constants.LONG_ZERO); - - // relative offset of the ZIP64 EOCD record - this.write(zipUtil.getEightBytes(this._archive.centralOffset + this._archive.centralLength)); - - // total number of disks - this.write(zipUtil.getLongBytes(1)); -}; - -ZipArchiveOutputStream.prototype._writeCentralFileHeader = function(ae) { - var gpb = ae.getGeneralPurposeBit(); - var method = ae.getMethod(); - var offsets = ae._offsets; - - var size = ae.getSize(); - var compressedSize = ae.getCompressedSize(); - - if (ae.isZip64() || offsets.file > constants.ZIP64_MAGIC) { - size = constants.ZIP64_MAGIC; - compressedSize = constants.ZIP64_MAGIC; - - ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64); - - var extraBuf = Buffer.concat([ - zipUtil.getShortBytes(constants.ZIP64_EXTRA_ID), - zipUtil.getShortBytes(24), - zipUtil.getEightBytes(ae.getSize()), - zipUtil.getEightBytes(ae.getCompressedSize()), - zipUtil.getEightBytes(offsets.file) - ], 28); - - ae.setExtra(extraBuf); + _writeCentralDirectoryEnd() { + var records = this._entries.length; + var size = this._archive.centralLength; + var offset = this._archive.centralOffset; + if (this.isZip64()) { + records = ZIP64_MAGIC_SHORT; + size = ZIP64_MAGIC; + offset = ZIP64_MAGIC; + } + // signature + this.write(getLongBytes(SIG_EOCD)); + // disk numbers + this.write(SHORT_ZERO); + this.write(SHORT_ZERO); + // number of entries + this.write(getShortBytes(records)); + this.write(getShortBytes(records)); + // length and location of CD + this.write(getLongBytes(size)); + this.write(getLongBytes(offset)); + // archive comment + var comment = this.getComment(); + var commentLength = Buffer.byteLength(comment); + this.write(getShortBytes(commentLength)); + this.write(comment); } - // signature - this.write(zipUtil.getLongBytes(constants.SIG_CFH)); - - // version made by - this.write(zipUtil.getShortBytes((ae.getPlatform() << 8) | constants.VERSION_MADEBY)); - - // version to extract and general bit flag - this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract())); - this.write(gpb.encode()); - - // compression method - this.write(zipUtil.getShortBytes(method)); - - // datetime - this.write(zipUtil.getLongBytes(ae.getTimeDos())); - - // crc32 checksum - this.write(zipUtil.getLongBytes(ae.getCrc())); - - // sizes - this.write(zipUtil.getLongBytes(compressedSize)); - this.write(zipUtil.getLongBytes(size)); - - var name = ae.getName(); - var comment = ae.getComment(); - var extra = ae.getCentralDirectoryExtra(); - - if (gpb.usesUTF8ForNames()) { - name = Buffer.from(name); - comment = Buffer.from(comment); + _writeCentralDirectoryZip64() { + // signature + this.write(getLongBytes(SIG_ZIP64_EOCD)); + // size of the ZIP64 EOCD record + this.write(getEightBytes(44)); + // version made by + this.write(getShortBytes(MIN_VERSION_ZIP64)); + // version to extract + this.write(getShortBytes(MIN_VERSION_ZIP64)); + // disk numbers + this.write(LONG_ZERO); + this.write(LONG_ZERO); + // number of entries + this.write(getEightBytes(this._entries.length)); + this.write(getEightBytes(this._entries.length)); + // length and location of CD + this.write(getEightBytes(this._archive.centralLength)); + this.write(getEightBytes(this._archive.centralOffset)); + // extensible data sector + // not implemented at this time + // end of central directory locator + this.write(getLongBytes(SIG_ZIP64_EOCD_LOC)); + // disk number holding the ZIP64 EOCD record + this.write(LONG_ZERO); + // relative offset of the ZIP64 EOCD record + this.write( + getEightBytes(this._archive.centralOffset + this._archive.centralLength), + ); + // total number of disks + this.write(getLongBytes(1)); } - // name length - this.write(zipUtil.getShortBytes(name.length)); - - // extra length - this.write(zipUtil.getShortBytes(extra.length)); - - // comments length - this.write(zipUtil.getShortBytes(comment.length)); - - // disk number start - this.write(constants.SHORT_ZERO); - - // internal attributes - this.write(zipUtil.getShortBytes(ae.getInternalAttributes())); - - // external attributes - this.write(zipUtil.getLongBytes(ae.getExternalAttributes())); - - // relative offset of LFH - if (offsets.file > constants.ZIP64_MAGIC) { - this.write(zipUtil.getLongBytes(constants.ZIP64_MAGIC)); - } else { - this.write(zipUtil.getLongBytes(offsets.file)); + _writeCentralFileHeader(ae) { + var gpb = ae.getGeneralPurposeBit(); + var method = ae.getMethod(); + var fileOffset = ae._offsets.file; + var size = ae.getSize(); + var compressedSize = ae.getCompressedSize(); + if (ae.isZip64() || fileOffset > ZIP64_MAGIC) { + size = ZIP64_MAGIC; + compressedSize = ZIP64_MAGIC; + fileOffset = ZIP64_MAGIC; + ae.setVersionNeededToExtract(MIN_VERSION_ZIP64); + var extraBuf = Buffer.concat( + [ + getShortBytes(ZIP64_EXTRA_ID), + getShortBytes(24), + getEightBytes(ae.getSize()), + getEightBytes(ae.getCompressedSize()), + getEightBytes(ae._offsets.file), + ], + 28, + ); + ae.setExtra(extraBuf); + } + // signature + this.write(getLongBytes(SIG_CFH)); + // version made by + this.write(getShortBytes((ae.getPlatform() << 8) | VERSION_MADEBY)); + // version to extract and general bit flag + this.write(getShortBytes(ae.getVersionNeededToExtract())); + this.write(gpb.encode()); + // compression method + this.write(getShortBytes(method)); + // datetime + this.write(getLongBytes(ae.getTimeDos())); + // crc32 checksum + this.write(getLongBytes(ae.getCrc())); + // sizes + this.write(getLongBytes(compressedSize)); + this.write(getLongBytes(size)); + var name = ae.getName(); + var comment = ae.getComment(); + var extra = ae.getCentralDirectoryExtra(); + if (gpb.usesUTF8ForNames()) { + name = Buffer.from(name); + comment = Buffer.from(comment); + } + // name length + this.write(getShortBytes(name.length)); + // extra length + this.write(getShortBytes(extra.length)); + // comments length + this.write(getShortBytes(comment.length)); + // disk number start + this.write(SHORT_ZERO); + // internal attributes + this.write(getShortBytes(ae.getInternalAttributes())); + // external attributes + this.write(getLongBytes(ae.getExternalAttributes())); + // relative offset of LFH + this.write(getLongBytes(fileOffset)); + // name + this.write(name); + // extra + this.write(extra); + // comment + this.write(comment); } - // name - this.write(name); - - // extra - this.write(extra); - - // comment - this.write(comment); -}; - -ZipArchiveOutputStream.prototype._writeDataDescriptor = function(ae) { - // signature - this.write(zipUtil.getLongBytes(constants.SIG_DD)); - - // crc32 checksum - this.write(zipUtil.getLongBytes(ae.getCrc())); - - // sizes - if (ae.isZip64()) { - this.write(zipUtil.getEightBytes(ae.getCompressedSize())); - this.write(zipUtil.getEightBytes(ae.getSize())); - } else { - this.write(zipUtil.getLongBytes(ae.getCompressedSize())); - this.write(zipUtil.getLongBytes(ae.getSize())); + _writeDataDescriptor(ae) { + // signature + this.write(getLongBytes(SIG_DD)); + // crc32 checksum + this.write(getLongBytes(ae.getCrc())); + // sizes + if (ae.isZip64()) { + this.write(getEightBytes(ae.getCompressedSize())); + this.write(getEightBytes(ae.getSize())); + } else { + this.write(getLongBytes(ae.getCompressedSize())); + this.write(getLongBytes(ae.getSize())); + } } -}; -ZipArchiveOutputStream.prototype._writeLocalFileHeader = function(ae) { - var gpb = ae.getGeneralPurposeBit(); - var method = ae.getMethod(); - var name = ae.getName(); - var extra = ae.getLocalFileDataExtra(); - - if (ae.isZip64()) { - gpb.useDataDescriptor(true); - ae.setVersionNeededToExtract(constants.MIN_VERSION_ZIP64); + _writeLocalFileHeader(ae) { + var gpb = ae.getGeneralPurposeBit(); + var method = ae.getMethod(); + var name = ae.getName(); + var extra = ae.getLocalFileDataExtra(); + if (ae.isZip64()) { + gpb.useDataDescriptor(true); + ae.setVersionNeededToExtract(MIN_VERSION_ZIP64); + } + if (gpb.usesUTF8ForNames()) { + name = Buffer.from(name); + } + ae._offsets.file = this.offset; + // signature + this.write(getLongBytes(SIG_LFH)); + // version to extract and general bit flag + this.write(getShortBytes(ae.getVersionNeededToExtract())); + this.write(gpb.encode()); + // compression method + this.write(getShortBytes(method)); + // datetime + this.write(getLongBytes(ae.getTimeDos())); + ae._offsets.data = this.offset; + // crc32 checksum and sizes + if (gpb.usesDataDescriptor()) { + this.write(LONG_ZERO); + this.write(LONG_ZERO); + this.write(LONG_ZERO); + } else { + this.write(getLongBytes(ae.getCrc())); + this.write(getLongBytes(ae.getCompressedSize())); + this.write(getLongBytes(ae.getSize())); + } + // name length + this.write(getShortBytes(name.length)); + // extra length + this.write(getShortBytes(extra.length)); + // name + this.write(name); + // extra + this.write(extra); + ae._offsets.contents = this.offset; } - if (gpb.usesUTF8ForNames()) { - name = Buffer.from(name); + getComment(comment) { + return this._archive.comment !== null ? this._archive.comment : ""; } - ae._offsets.file = this.offset; - - // signature - this.write(zipUtil.getLongBytes(constants.SIG_LFH)); - - // version to extract and general bit flag - this.write(zipUtil.getShortBytes(ae.getVersionNeededToExtract())); - this.write(gpb.encode()); - - // compression method - this.write(zipUtil.getShortBytes(method)); - - // datetime - this.write(zipUtil.getLongBytes(ae.getTimeDos())); - - ae._offsets.data = this.offset; - - // crc32 checksum and sizes - if (gpb.usesDataDescriptor()) { - this.write(constants.LONG_ZERO); - this.write(constants.LONG_ZERO); - this.write(constants.LONG_ZERO); - } else { - this.write(zipUtil.getLongBytes(ae.getCrc())); - this.write(zipUtil.getLongBytes(ae.getCompressedSize())); - this.write(zipUtil.getLongBytes(ae.getSize())); + isZip64() { + return ( + this._archive.forceZip64 || + this._entries.length > ZIP64_MAGIC_SHORT || + this._archive.centralLength > ZIP64_MAGIC || + this._archive.centralOffset > ZIP64_MAGIC + ); } - // name length - this.write(zipUtil.getShortBytes(name.length)); - - // extra length - this.write(zipUtil.getShortBytes(extra.length)); - - // name - this.write(name); - - // extra - this.write(extra); - - ae._offsets.contents = this.offset; -}; - -ZipArchiveOutputStream.prototype.getComment = function(comment) { - return this._archive.comment !== null ? this._archive.comment : ''; -}; - -ZipArchiveOutputStream.prototype.isZip64 = function() { - return this._archive.forceZip64 || this._entries.length > constants.ZIP64_MAGIC_SHORT || this._archive.centralLength > constants.ZIP64_MAGIC || this._archive.centralOffset > constants.ZIP64_MAGIC; -}; - -ZipArchiveOutputStream.prototype.setComment = function(comment) { - this._archive.comment = comment; -}; + setComment(comment) { + this._archive.comment = comment; + } +} diff --git a/lib/compress-commons.js b/lib/compress-commons.js index ef3bc1db..9fc8fec6 100644 --- a/lib/compress-commons.js +++ b/lib/compress-commons.js @@ -1,13 +1,18 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -module.exports = { - ArchiveEntry: require('./archivers/archive-entry'), - ZipArchiveEntry: require('./archivers/zip/zip-archive-entry'), - ArchiveOutputStream: require('./archivers/archive-output-stream'), - ZipArchiveOutputStream: require('./archivers/zip/zip-archive-output-stream') -}; \ No newline at end of file +import ArchiveEntry from "./archivers/archive-entry.js"; +import ZipArchiveEntry from "./archivers/zip/zip-archive-entry.js"; +import ArchiveOutputStream from "./archivers/archive-output-stream.js"; +import ZipArchiveOutputStream from "./archivers/zip/zip-archive-output-stream.js"; + +export { + ArchiveEntry, + ZipArchiveEntry, + ArchiveOutputStream, + ZipArchiveOutputStream, +}; + +export default { + ArchiveEntry, + ZipArchiveEntry, + ArchiveOutputStream, + ZipArchiveOutputStream, +}; diff --git a/lib/util/index.js b/lib/util/index.js index 20a67833..0c8a6289 100644 --- a/lib/util/index.js +++ b/lib/util/index.js @@ -1,30 +1,20 @@ -/** - * node-compress-commons - * - * Copyright (c) 2014 Chris Talkington, contributors. - * Licensed under the MIT license. - * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT - */ -var Stream = require('stream').Stream; -var PassThrough = require('readable-stream').PassThrough; +import { Stream } from "stream"; +import { PassThrough } from "readable-stream"; +import { isStream } from "is-stream"; -var util = module.exports = {}; - -util.isStream = function(source) { - return source instanceof Stream; -}; - -util.normalizeInputSource = function(source) { +export function normalizeInputSource(source) { if (source === null) { return Buffer.alloc(0); - } else if (typeof source === 'string') { + } else if (typeof source === "string") { return Buffer.from(source); - } else if (util.isStream(source) && !source._readableState) { + } else if (isStream(source) && !source._readableState) { var normalized = new PassThrough(); source.pipe(normalized); - return normalized; } - return source; -}; \ No newline at end of file +} + +export default { + normalizeInputSource, +}; diff --git a/package-lock.json b/package-lock.json index 53677dfd..eb1d881f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,905 +1,1288 @@ { "name": "compress-commons", - "version": "4.1.1", - "lockfileVersion": 1, + "version": "7.0.0", + "lockfileVersion": 3, "requires": true, - "dependencies": { - "@ungap/promise-all-settled": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz", - "integrity": "sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q==", - "dev": true + "packages": { + "": { + "name": "compress-commons", + "version": "7.0.0", + "license": "MIT", + "dependencies": { + "crc-32": "^1.2.0", + "crc32-stream": "^7.0.1", + "is-stream": "^4.0.0", + "normalize-path": "^3.0.0", + "readable-stream": "^4.0.0" + }, + "devDependencies": { + "chai": "6.2.2", + "mkdirp": "3.0.1", + "mocha": "11.7.5", + "prettier": "3.8.3", + "rimraf": "6.1.3" + }, + "engines": { + "node": ">=18" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dev": true, + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } }, - "ansi-colors": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz", - "integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==", + "node_modules/@isaacs/cliui/node_modules/ansi-regex": { + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.1.0.tgz", + "integrity": "sha512-7HSX4QQb4CspciLpVFwyRe79O3xsIZDDLER21kERQ71oaPodF8jL725AgJMFAYbooIqolJoRLuM81SpeUkpkvA==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "dev": true, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==", "dev": true }, - "ansi-regex": { + "node_modules/@isaacs/cliui/node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dev": true, + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/@isaacs/cliui/node_modules/strip-ansi": { + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.1.0.tgz", + "integrity": "sha512-iq6eVVI64nQQTRYq2KtEg2d2uU7LElhTJwsH4YzIHZshxlgZms/wIc4VoDQTlG/IvVIrBKG06CrZnp0qv7hkcQ==", + "dev": true, + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/@isaacs/cliui/node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dev": true, + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "dev": true, + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/abort-controller": { "version": "3.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-3.0.0.tgz", - "integrity": "sha1-7QMXwyIGT3lGbAKWa922Bas32Zg=", - "dev": true + "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", + "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", + "dependencies": { + "event-target-shim": "^5.0.0" + }, + "engines": { + "node": ">=6.5" + } + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "dev": true, + "engines": { + "node": ">=8" + } }, - "ansi-styles": { + "node_modules/ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", "dev": true, - "requires": { + "dependencies": { "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, - "anymatch": { - "version": "3.1.2", - "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.2.tgz", - "integrity": "sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg==", - "dev": true, - "requires": { - "normalize-path": "^3.0.0", - "picomatch": "^2.0.4" - } - }, - "argparse": { + "node_modules/argparse": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz", "integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==", "dev": true }, - "assertion-error": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/assertion-error/-/assertion-error-1.1.0.tgz", - "integrity": "sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==", - "dev": true - }, - "balanced-match": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", - "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=", - "dev": true - }, - "binary-extensions": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz", - "integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==", + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==", "dev": true }, - "brace-expansion": { - "version": "1.1.11", - "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", - "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", - "dev": true, - "requires": { - "balanced-match": "1.0.0", - "concat-map": "0.0.1" - } + "node_modules/base64-js": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz", + "integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, - "braces": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz", - "integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==", + "node_modules/brace-expansion": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.1.0.tgz", + "integrity": "sha512-TN1kCZAgdgweJhWWpgKYrQaMNHcDULHkWwQIspdtjV4Y5aurRdZpjAqn6yX3FPqTA9ngHCc4hJxMAMgGfve85w==", "dev": true, - "requires": { - "fill-range": "^7.0.1" + "dependencies": { + "balanced-match": "^1.0.0" } }, - "browser-stdout": { + "node_modules/browser-stdout": { "version": "1.3.1", "resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz", "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=" + "node_modules/buffer": { + "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", + "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ], + "dependencies": { + "base64-js": "^1.3.1", + "ieee754": "^1.2.1" + } }, - "camelcase": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", - "integrity": "sha512-c7wVvbw3f37nuobQNtgsgG9POC9qMbNuMQmTCqZv23b6MIz0fcYpBiOlv9gEN/hdLdnZTDQhg6e9Dq5M1vKvfg==", - "dev": true + "node_modules/camelcase": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz", + "integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==", + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "chai": { - "version": "4.3.4", - "resolved": "https://registry.npmjs.org/chai/-/chai-4.3.4.tgz", - "integrity": "sha512-yS5H68VYOCtN1cjfwumDSuzn/9c+yza4f3reKXlE5rUg7SFcCEy90gJvydNgOYtblyf4Zi6jIWRnXOgErta0KA==", + "node_modules/chai": { + "version": "6.2.2", + "resolved": "https://registry.npmjs.org/chai/-/chai-6.2.2.tgz", + "integrity": "sha512-NUPRluOfOiTKBKvWPtSD4PhFvWCqOi0BGStNWs57X9js7XGTprSmFoz5F0tWhR4WPjNeR9jXqdC7/UpSJTnlRg==", "dev": true, - "requires": { - "assertion-error": "^1.1.0", - "check-error": "^1.0.2", - "deep-eql": "^3.0.1", - "get-func-name": "^2.0.0", - "pathval": "^1.1.1", - "type-detect": "^4.0.5" + "engines": { + "node": ">=18" } }, - "chalk": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.1.tgz", - "integrity": "sha512-diHzdDKxcU+bAsUboHLPEDQiw0qEe0qd7SYUn3HgcFlWgbDcfLGswOHYeGrHKzG9z6UYf01d9VFMfZxPM1xZSg==", + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", "dev": true, - "requires": { + "dependencies": { "ansi-styles": "^4.1.0", "supports-color": "^7.1.0" }, - "dependencies": { - "supports-color": { - "version": "7.2.0", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", - "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", - "dev": true, - "requires": { - "has-flag": "^4.0.0" - } - } + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" } }, - "check-error": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/check-error/-/check-error-1.0.2.tgz", - "integrity": "sha1-V00xLt2Iu13YkS6Sht1sCu1KrII=", - "dev": true + "node_modules/chalk/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } }, - "chokidar": { - "version": "3.5.2", - "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.2.tgz", - "integrity": "sha512-ekGhOnNVPgT77r4K/U3GDhu+FQ2S8TnK/s2KbIGXi0SZWuwkZ2QNyfWdZW+TVfn84DpEP7rLeCt2UI6bJ8GwbQ==", + "node_modules/chokidar": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-4.0.3.tgz", + "integrity": "sha512-Qgzu8kfBvo+cA4962jnP1KkS6Dop5NS6g7R5LFYJr4b8Ub94PPQXUksCw9PvXoeXPRRddRNC5C1JQUR2SMGtnA==", "dev": true, - "requires": { - "anymatch": "~3.1.2", - "braces": "~3.0.2", - "fsevents": "~2.3.2", - "glob-parent": "~5.1.2", - "is-binary-path": "~2.1.0", - "is-glob": "~4.0.1", - "normalize-path": "~3.0.0", - "readdirp": "~3.6.0" + "dependencies": { + "readdirp": "^4.0.1" + }, + "engines": { + "node": ">= 14.16.0" + }, + "funding": { + "url": "https://paulmillr.com/funding/" } }, - "cliui": { - "version": "7.0.4", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", - "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "node_modules/cliui": { + "version": "8.0.1", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-8.0.1.tgz", + "integrity": "sha512-BSeNnyus75C4//NQ9gQt1/csTXyo/8Sb+afLAkzAptFuMsod9HFokGNudZpi/oQV73hnVK+sR+5PVRMd+Dr7YQ==", "dev": true, - "requires": { + "dependencies": { "string-width": "^4.2.0", - "strip-ansi": "^6.0.0", + "strip-ansi": "^6.0.1", "wrap-ansi": "^7.0.0" }, - "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } + "engines": { + "node": ">=12" } }, - "color-convert": { + "node_modules/color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", "dev": true, - "requires": { + "dependencies": { "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" } }, - "color-name": { + "node_modules/color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", "dev": true }, - "concat-map": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", - "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=", - "dev": true + "node_modules/crc-32": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==", + "bin": { + "crc32": "bin/crc32.njs" + }, + "engines": { + "node": ">=0.8" + } }, - "crc-32": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.0.tgz", - "integrity": "sha512-1uBwHxF+Y/4yF5G48fwnKq6QsIXheor3ZLPT80yGBV1oEUwpPojlEhQbWKVw1VwcTQyMGHK1/XMmTjmlsmTTGA==", - "requires": { - "exit-on-epipe": "~1.0.1", - "printj": "~1.1.0" - } - }, - "crc32-stream": { - "version": "4.0.2", - "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-4.0.2.tgz", - "integrity": "sha512-DxFZ/Hk473b/muq1VJ///PMNLj0ZMnzye9thBpmjpJKCc5eMgB95aK8zCGrGfQ90cWo561Te6HK9D+j4KPdM6w==", - "requires": { + "node_modules/crc32-stream": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/crc32-stream/-/crc32-stream-7.0.1.tgz", + "integrity": "sha512-IBWsY8xznyQrcHn8h4bC8/4ErNke5elzgG8GcqF4RFPw6aHkWWRc7Tgw6upjaTX/CT/yQgqYENkxYsTYN+hW2g==", + "dependencies": { "crc-32": "^1.2.0", - "readable-stream": "^3.4.0" + "readable-stream": "^4.0.0" + }, + "engines": { + "node": ">=18" } }, - "debug": { - "version": "4.3.1", - "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", - "integrity": "sha512-doEwdvm4PCeK4K3RQN2ZC2BYUBaxwLARCqZmMjtF8a51J2Rb0xpVloFRnCODwqjpwnAoao4pelN8l3RJdv3gRQ==", + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", "dev": true, - "requires": { - "ms": "2.1.2" + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/debug": { + "version": "4.3.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.7.tgz", + "integrity": "sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ==", + "dev": true, "dependencies": { - "ms": { - "version": "2.1.2", - "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", - "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", - "dev": true + "ms": "^2.1.3" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true } } }, - "decamelize": { + "node_modules/decamelize": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz", "integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "deep-eql": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/deep-eql/-/deep-eql-3.0.1.tgz", - "integrity": "sha512-+QeIQyN5ZuO+3Uk5DYh6/1eKO0m0YmJFGNmFHGACpf1ClL1nmlV/p4gNgbl2pJGxgXb4faqo6UE+M5ACEMyVcw==", + "node_modules/diff": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-7.0.0.tgz", + "integrity": "sha512-PJWHUb1RFevKCwaFA9RlG5tCd+FO5iRh9A8HEtkmBH2Li03iJriB6m6JIN4rGz3K3JLawI7/veA1xzRKP6ISBw==", "dev": true, - "requires": { - "type-detect": "^4.0.0" + "engines": { + "node": ">=0.3.1" } }, - "diff": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz", - "integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==", + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==", "dev": true }, - "emoji-regex": { + "node_modules/emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", "dev": true }, - "escalade": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", - "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", - "dev": true + "node_modules/escalade": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.2.0.tgz", + "integrity": "sha512-WUj2qlxaQtO4g6Pq5c29GTcWGDyd8itL8zTlipgECz3JesAiiOKotd8JU6otB3PACgG6xkJUyVhboMS+bje/jA==", + "dev": true, + "engines": { + "node": ">=6" + } }, - "escape-string-regexp": { + "node_modules/escape-string-regexp": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz", "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", - "dev": true + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "exit-on-epipe": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/exit-on-epipe/-/exit-on-epipe-1.0.1.tgz", - "integrity": "sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==" + "node_modules/event-target-shim": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", + "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", + "engines": { + "node": ">=6" + } }, - "fill-range": { - "version": "7.0.1", - "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", - "integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==", - "dev": true, - "requires": { - "to-regex-range": "^5.0.1" + "node_modules/events": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/events/-/events-3.3.0.tgz", + "integrity": "sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==", + "engines": { + "node": ">=0.8.x" } }, - "find-up": { + "node_modules/find-up": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz", "integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==", "dev": true, - "requires": { + "dependencies": { "locate-path": "^6.0.0", "path-exists": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "flat": { + "node_modules/flat": { "version": "5.0.2", "resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz", "integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==", - "dev": true - }, - "fs.realpath": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", - "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=", - "dev": true + "dev": true, + "bin": { + "flat": "cli.js" + } }, - "fsevents": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", - "integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==", + "node_modules/foreground-child": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.3.0.tgz", + "integrity": "sha512-Ld2g8rrAyMYFXBhEqMz8ZAHBi4J4uS1i/CxGMDnjyFWddMXLVcDp051DZfu+t7+ab7Wv6SMqpWmyFIj5UbfFvg==", "dev": true, - "optional": true + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } }, - "get-caller-file": { + "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", - "dev": true - }, - "get-func-name": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/get-func-name/-/get-func-name-2.0.0.tgz", - "integrity": "sha1-6td0q+5y4gQJQzoGY2YCPdaIekE=", - "dev": true - }, - "glob": { - "version": "7.1.7", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.7.tgz", - "integrity": "sha512-OvD9ENzPLbegENnYP5UUfJIirTg4+XwMWGaQfQTY0JenxNvvIKP3U3/tAQSPIu/lHxXYSZmpXlUHeqAIdKzBLQ==", "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "engines": { + "node": "6.* || 8.* || >= 10.*" } }, - "glob-parent": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", - "integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==", + "node_modules/glob": { + "version": "10.5.0", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.5.0.tgz", + "integrity": "sha512-DfXN8DfhJ7NH3Oe7cFmu3NCu1wKbkReJ8TorzSAFbSKrlNaQSKfIzqYqVY8zlbs2NLBbWpRiU52GX2PbaBVNkg==", + "deprecated": "Old versions of glob are not supported, and contain widely publicized security vulnerabilities, which have been fixed in the current version. Please update. Support for old versions may be purchased (at exorbitant rates) by contacting i@izs.me", "dev": true, - "requires": { - "is-glob": "^4.0.1" + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^3.1.2", + "minimatch": "^9.0.4", + "minipass": "^7.1.2", + "package-json-from-dist": "^1.0.0", + "path-scurry": "^1.11.1" + }, + "bin": { + "glob": "dist/esm/bin.mjs" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "growl": { - "version": "1.10.5", - "resolved": "https://registry.npmjs.org/growl/-/growl-1.10.5.tgz", - "integrity": "sha512-qBr4OuELkhPenW6goKVXiv47US3clb3/IbuWF9KNKEijAy9oeHxU9IgzjvJhHkUzhaj7rOUD7+YGWqUjLp5oSA==", - "dev": true - }, - "has-flag": { + "node_modules/has-flag": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "he": { + "node_modules/he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", "integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==", - "dev": true - }, - "inflight": { - "version": "1.0.6", - "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", - "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, - "requires": { - "once": "1.4.0", - "wrappy": "1.0.2" + "bin": { + "he": "bin/he" } }, - "inherits": { - "version": "2.0.4", - "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", - "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + "node_modules/ieee754": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz", + "integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] }, - "is-binary-path": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", - "integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==", + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", "dev": true, - "requires": { - "binary-extensions": "^2.0.0" + "engines": { + "node": ">=8" } }, - "is-extglob": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", - "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", - "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", - "dev": true - }, - "is-glob": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.1.tgz", - "integrity": "sha512-5G0tKtBTFImOqDnLB2hG6Bp2qcKEFduo4tZu9MT/H6NQv/ghhy30o55ufafxJ/LdH79LLs2Kfrn85TLKyA7BUg==", + "node_modules/is-path-inside": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/is-path-inside/-/is-path-inside-3.0.3.tgz", + "integrity": "sha512-Fd4gABb+ycGAmKou8eMftCupSir5lRxqf4aD/vd0cD2qc4HL07OjCeuHMr8Ro4CoMaeCKDB0/ECBOVWjTwUvPQ==", "dev": true, - "requires": { - "is-extglob": "^2.1.1" + "engines": { + "node": ">=8" } }, - "is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", - "dev": true - }, - "is-plain-obj": { + "node_modules/is-plain-obj": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "is-unicode-supported": { + "node_modules/is-stream": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-4.0.1.tgz", + "integrity": "sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==", + "engines": { + "node": ">=18" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/is-unicode-supported": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz", "integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==", - "dev": true + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "isexe": { + "node_modules/isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", "dev": true }, - "js-yaml": { + "node_modules/jackspeak": { + "version": "3.4.3", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-3.4.3.tgz", + "integrity": "sha512-OGlZQpz2yfahA/Rd1Y8Cd9SIEsqvXkLVoSw/cgwhnhFMDbsQFeZYoJJ7bIZBS9BcamUW96asq/npPWugM+RQBw==", + "dev": true, + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/js-yaml": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz", "integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==", "dev": true, - "requires": { + "dependencies": { "argparse": "^2.0.1" + }, + "bin": { + "js-yaml": "bin/js-yaml.js" } }, - "locate-path": { + "node_modules/locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", "integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==", "dev": true, - "requires": { + "dependencies": { "p-locate": "^5.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "log-symbols": { + "node_modules/log-symbols": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz", "integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==", "dev": true, - "requires": { + "dependencies": { "chalk": "^4.1.0", "is-unicode-supported": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "minimatch": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", - "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "node_modules/lru-cache": { + "version": "10.4.3", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-10.4.3.tgz", + "integrity": "sha512-JNAzZcXrCt42VGLuYz0zfAzDfAvJWW6AfYlDBQyDV5DClI2m5sAmK+OIO7s59XfsRsWHp02jAJrRadPRGTt6SQ==", + "dev": true + }, + "node_modules/minimatch": { + "version": "9.0.9", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.9.tgz", + "integrity": "sha512-OBwBN9AL4dqmETlpS2zasx+vTeWclWzkblfZk7KTA5j3jeOONz/tRCnZomUyvNg83wL5Zv9Ss6HMJXAgL8R2Yg==", "dev": true, - "requires": { - "brace-expansion": "1.1.11" + "dependencies": { + "brace-expansion": "^2.0.2" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "mkdirp": { - "version": "1.0.4", - "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", - "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", - "dev": true + "node_modules/minipass": { + "version": "7.1.3", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-7.1.3.tgz", + "integrity": "sha512-tEBHqDnIoM/1rXME1zgka9g6Q2lcoCkxHLuc7ODJ5BxbP5d4c2Z5cGgtXAku59200Cx7diuHTOYfSBD8n6mm8A==", + "dev": true, + "engines": { + "node": ">=16 || 14 >=14.17" + } }, - "mocha": { - "version": "9.0.2", - "resolved": "https://registry.npmjs.org/mocha/-/mocha-9.0.2.tgz", - "integrity": "sha512-FpspiWU+UT9Sixx/wKimvnpkeW0mh6ROAKkIaPokj3xZgxeRhcna/k5X57jJghEr8X+Cgu/Vegf8zCX5ugSuTA==", - "dev": true, - "requires": { - "@ungap/promise-all-settled": "1.1.2", - "ansi-colors": "4.1.1", - "browser-stdout": "1.3.1", - "chokidar": "3.5.2", - "debug": "4.3.1", - "diff": "5.0.0", - "escape-string-regexp": "4.0.0", - "find-up": "5.0.0", - "glob": "7.1.7", - "growl": "1.10.5", - "he": "1.2.0", - "js-yaml": "4.1.0", - "log-symbols": "4.1.0", - "minimatch": "3.0.4", - "ms": "2.1.3", - "nanoid": "3.1.23", - "serialize-javascript": "6.0.0", - "strip-json-comments": "3.1.1", - "supports-color": "8.1.1", - "which": "2.0.2", - "wide-align": "1.1.3", - "workerpool": "6.1.5", - "yargs": "16.2.0", - "yargs-parser": "20.2.4", - "yargs-unparser": "2.0.0" - } - }, - "ms": { + "node_modules/mkdirp": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-3.0.1.tgz", + "integrity": "sha512-+NsyUUAZDmo6YVHzL/stxSu3t9YS1iljliy3BSDrXJ/dkn1KYdmtZODGGjLcc9XLgVVpH4KshHB8XmZgMhaBXg==", + "dev": true, + "bin": { + "mkdirp": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/mocha": { + "version": "11.7.5", + "resolved": "https://registry.npmjs.org/mocha/-/mocha-11.7.5.tgz", + "integrity": "sha512-mTT6RgopEYABzXWFx+GcJ+ZQ32kp4fMf0xvpZIIfSq9Z8lC/++MtcCnQ9t5FP2veYEP95FIYSvW+U9fV4xrlig==", + "dev": true, + "dependencies": { + "browser-stdout": "^1.3.1", + "chokidar": "^4.0.1", + "debug": "^4.3.5", + "diff": "^7.0.0", + "escape-string-regexp": "^4.0.0", + "find-up": "^5.0.0", + "glob": "^10.4.5", + "he": "^1.2.0", + "is-path-inside": "^3.0.3", + "js-yaml": "^4.1.0", + "log-symbols": "^4.1.0", + "minimatch": "^9.0.5", + "ms": "^2.1.3", + "picocolors": "^1.1.1", + "serialize-javascript": "^6.0.2", + "strip-json-comments": "^3.1.1", + "supports-color": "^8.1.1", + "workerpool": "^9.2.0", + "yargs": "^17.7.2", + "yargs-parser": "^21.1.1", + "yargs-unparser": "^2.0.0" + }, + "bin": { + "_mocha": "bin/_mocha", + "mocha": "bin/mocha.js" + }, + "engines": { + "node": "^18.18.0 || ^20.9.0 || >=21.1.0" + } + }, + "node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", "dev": true }, - "nanoid": { - "version": "3.1.23", - "resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.1.23.tgz", - "integrity": "sha512-FiB0kzdP0FFVGDKlRLEQ1BgDzU87dy5NnzjeW9YZNt+/c3+q82EQDUwniSAUxp/F0gFNI1ZhKU1FqYsMuqZVnw==", - "dev": true - }, - "normalize-path": { + "node_modules/normalize-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", - "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" - }, - "once": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", - "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", - "dev": true, - "requires": { - "wrappy": "1.0.2" + "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==", + "engines": { + "node": ">=0.10.0" } }, - "p-limit": { + "node_modules/p-limit": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz", "integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==", "dev": true, - "requires": { + "dependencies": { "yocto-queue": "^0.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "p-locate": { + "node_modules/p-locate": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz", "integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==", "dev": true, - "requires": { + "dependencies": { "p-limit": "^3.0.2" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" } }, - "path-exists": { + "node_modules/package-json-from-dist": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/package-json-from-dist/-/package-json-from-dist-1.0.1.tgz", + "integrity": "sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==", + "dev": true + }, + "node_modules/path-exists": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + } }, - "path-is-absolute": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", - "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=", - "dev": true + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "1.11.1", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.11.1.tgz", + "integrity": "sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==", + "dev": true, + "dependencies": { + "lru-cache": "^10.2.0", + "minipass": "^5.0.0 || ^6.0.2 || ^7.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.18" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } }, - "pathval": { + "node_modules/picocolors": { "version": "1.1.1", - "resolved": "https://registry.npmjs.org/pathval/-/pathval-1.1.1.tgz", - "integrity": "sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.1.tgz", + "integrity": "sha512-xceH2snhtb5M9liqDsmEw56le376mTZkEX/jEb/RxNFyegNul7eNslCXP9FDj/Lcu0X8KEyMceP2ntpaHrDEVA==", "dev": true }, - "picomatch": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.0.tgz", - "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", - "dev": true + "node_modules/prettier": { + "version": "3.8.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.8.3.tgz", + "integrity": "sha512-7igPTM53cGHMW8xWuVTydi2KO233VFiTNyF5hLJqpilHfmn8C8gPf+PS7dUT64YcXFbiMGZxS9pCSxL/Dxm/Jw==", + "dev": true, + "bin": { + "prettier": "bin/prettier.cjs" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/prettier/prettier?sponsor=1" + } }, - "printj": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", - "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==" + "node_modules/process": { + "version": "0.11.10", + "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", + "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==", + "engines": { + "node": ">= 0.6.0" + } }, - "randombytes": { + "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", "integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==", "dev": true, - "requires": { + "dependencies": { "safe-buffer": "^5.1.0" } }, - "readable-stream": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.0.tgz", - "integrity": "sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA==", - "requires": { - "inherits": "^2.0.3", - "string_decoder": "^1.1.1", - "util-deprecate": "^1.0.1" + "node_modules/readable-stream": { + "version": "4.7.0", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-4.7.0.tgz", + "integrity": "sha512-oIGGmcpTLwPga8Bn6/Z75SVaH1z5dUut2ibSyAMVhmUggWpmDn2dapB0n7f8nwaSiRtepAsfJyfXIO5DCVAODg==", + "dependencies": { + "abort-controller": "^3.0.0", + "buffer": "^6.0.3", + "events": "^3.3.0", + "process": "^0.11.10", + "string_decoder": "^1.3.0" + }, + "engines": { + "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "readdirp": { - "version": "3.6.0", - "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz", - "integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==", + "node_modules/readdirp": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", + "integrity": "sha512-GDhwkLfywWL2s6vEjyhri+eXmfH6j1L7JE27WhqLeYzoh/A3DBaYGEj2H/HFZCn/kMfim73FXxEJTw06WtxQwg==", "dev": true, - "requires": { - "picomatch": "^2.2.1" + "engines": { + "node": ">= 14.18.0" + }, + "funding": { + "type": "individual", + "url": "https://paulmillr.com/funding/" } }, - "require-directory": { + "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", - "integrity": "sha1-jGStX9MNqxyXbiNE/+f3kqam30I=", - "dev": true + "integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==", + "dev": true, + "engines": { + "node": ">=0.10.0" + } }, - "rimraf": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", - "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", - "dev": true, - "requires": { - "glob": "^7.1.3" - }, - "dependencies": { - "glob": { - "version": "7.1.6", - "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", - "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", - "dev": true, - "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" - } - } + "node_modules/rimraf": { + "version": "6.1.3", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-6.1.3.tgz", + "integrity": "sha512-LKg+Cr2ZF61fkcaK1UdkH2yEBBKnYjTyWzTJT6KNPcSPaiT7HSdhtMXQuN5wkTX0Xu72KQ1l8S42rlmexS2hSA==", + "dev": true, + "dependencies": { + "glob": "^13.0.3", + "package-json-from-dist": "^1.0.1" + }, + "bin": { + "rimraf": "dist/esm/bin.mjs" + }, + "engines": { + "node": "20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" } }, - "safe-buffer": { - "version": "5.1.2", - "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", - "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" + "node_modules/rimraf/node_modules/balanced-match": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-4.0.4.tgz", + "integrity": "sha512-BLrgEcRTwX2o6gGxGOCNyMvGSp35YofuYzw9h1IMTRmKqttAZZVU67bdb9Pr2vUHA8+j3i2tJfjO6C6+4myGTA==", + "dev": true, + "engines": { + "node": "18 || 20 || >=22" + } }, - "serialize-javascript": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz", - "integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==", + "node_modules/rimraf/node_modules/brace-expansion": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-5.0.6.tgz", + "integrity": "sha512-kLpxurY4Z4r9sgMsyG0Z9uzsBlgiU/EFKhj/h91/8yHu0edo7XuixOIH3VcJ8kkxs6/jPzoI6U9Vj3WqbMQ94g==", + "dev": true, + "dependencies": { + "balanced-match": "^4.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + } + }, + "node_modules/rimraf/node_modules/glob": { + "version": "13.0.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-13.0.6.tgz", + "integrity": "sha512-Wjlyrolmm8uDpm/ogGyXZXb1Z+Ca2B8NbJwqBVg0axK9GbBeoS7yGV6vjXnYdGm6X53iehEuxxbyiKp8QmN4Vw==", + "dev": true, + "dependencies": { + "minimatch": "^10.2.2", + "minipass": "^7.1.3", + "path-scurry": "^2.0.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/rimraf/node_modules/lru-cache": { + "version": "11.3.6", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-11.3.6.tgz", + "integrity": "sha512-Gf/KoL3C/MlI7Bt0PGI9I+TeTC/I6r/csU58N4BSNc4lppLBeKsOdFYkK+dX0ABDUMJNfCHTyPpzwwO21Awd3A==", + "dev": true, + "engines": { + "node": "20 || >=22" + } + }, + "node_modules/rimraf/node_modules/minimatch": { + "version": "10.2.5", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-10.2.5.tgz", + "integrity": "sha512-MULkVLfKGYDFYejP07QOurDLLQpcjk7Fw+7jXS2R2czRQzR56yHRveU5NDJEOviH+hETZKSkIk5c+T23GjFUMg==", "dev": true, - "requires": { + "dependencies": { + "brace-expansion": "^5.0.5" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/rimraf/node_modules/path-scurry": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-2.0.2.tgz", + "integrity": "sha512-3O/iVVsJAPsOnpwWIeD+d6z/7PmqApyQePUtCndjatj/9I5LylHvt5qluFaBT3I5h3r1ejfR056c+FCv+NnNXg==", + "dev": true, + "dependencies": { + "lru-cache": "^11.0.0", + "minipass": "^7.1.2" + }, + "engines": { + "node": "18 || 20 || >=22" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/safe-buffer": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", + "integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==", + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/feross" + }, + { + "type": "patreon", + "url": "https://www.patreon.com/feross" + }, + { + "type": "consulting", + "url": "https://feross.org/support" + } + ] + }, + "node_modules/serialize-javascript": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.2.tgz", + "integrity": "sha512-Saa1xPByTTq2gdeFZYLLo+RFE35NHZkAbqZeWNd3BpzppeVisAqpDjcp8dyf6uIvEqJRd46jemmyA4iFIeVk8g==", + "dev": true, + "dependencies": { "randombytes": "^2.1.0" } }, - "string-width": { - "version": "2.1.1", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-2.1.1.tgz", - "integrity": "sha512-nOqH59deCq9SRHlxq1Aw85Jnt4w6KvLKqWVik6oA9ZklXLNIOlqg4F2yrT1MVaTjAqvVwdfeZ7w7aCvJD7ugkw==", + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, - "requires": { - "is-fullwidth-code-point": "^2.0.0", - "strip-ansi": "^4.0.0" + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" } }, - "string_decoder": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "requires": { - "safe-buffer": "5.1.2" + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true, + "engines": { + "node": ">=8" } }, - "strip-ansi": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-4.0.0.tgz", - "integrity": "sha1-qEeQIusaw2iocTibY1JixQXuNo8=", + "node_modules/signal-exit": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.1.0.tgz", + "integrity": "sha512-bzyZ1e88w9O1iNJbKnOlvYTrWPDl46O1bG0D3XInv+9tkPrxrN8jUUTiFlDkkmKWgn1M6CfIA13SuGqOa9Korw==", + "dev": true, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/string_decoder": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.3.0.tgz", + "integrity": "sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==", + "dependencies": { + "safe-buffer": "~5.2.0" + } + }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dev": true, + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", "dev": true, - "requires": { - "ansi-regex": "^3.0.0" + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" } }, - "strip-json-comments": { + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dev": true, + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-json-comments": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz", "integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==", - "dev": true + "dev": true, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, - "supports-color": { + "node_modules/supports-color": { "version": "8.1.1", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", "dev": true, - "requires": { + "dependencies": { "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" } }, - "to-regex-range": { - "version": "5.0.1", - "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", - "integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==", - "dev": true, - "requires": { - "is-number": "^7.0.0" - } - }, - "type-detect": { - "version": "4.0.8", - "resolved": "https://registry.npmjs.org/type-detect/-/type-detect-4.0.8.tgz", - "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", - "dev": true - }, - "util-deprecate": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz", - "integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=" - }, - "which": { + "node_modules/which": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, - "requires": { + "dependencies": { "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" } }, - "wide-align": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.3.tgz", - "integrity": "sha512-QGkOQc8XL6Bt5PwnsExKBPuMKBxnGxWWW3fU55Xt4feHozMUhdUMaBCk290qpm/wG5u/RSKzwdAC4i51YigihA==", - "dev": true, - "requires": { - "string-width": "^1.0.2 || 2" - } - }, - "workerpool": { - "version": "6.1.5", - "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.1.5.tgz", - "integrity": "sha512-XdKkCK0Zqc6w3iTxLckiuJ81tiD/o5rBE/m+nXpRCB+/Sq4DqkfXZ/x0jW02DG1tGsfUGXbTJyZDP+eu67haSw==", + "node_modules/workerpool": { + "version": "9.3.4", + "resolved": "https://registry.npmjs.org/workerpool/-/workerpool-9.3.4.tgz", + "integrity": "sha512-TmPRQYYSAnnDiEB0P/Ytip7bFGvqnSU6I2BcuSw7Hx+JSg/DsUi5ebYfc8GYaSdpuvOcEs6dXxPurOYpe9QFwg==", "dev": true }, - "wrap-ansi": { + "node_modules/wrap-ansi": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", "dev": true, - "requires": { + "dependencies": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" }, - "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" } }, - "wrappy": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", - "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=", - "dev": true + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } }, - "y18n": { + "node_modules/y18n": { "version": "5.0.8", "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz", "integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==", - "dev": true + "dev": true, + "engines": { + "node": ">=10" + } }, - "yargs": { - "version": "16.2.0", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", - "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "node_modules/yargs": { + "version": "17.7.2", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-17.7.2.tgz", + "integrity": "sha512-7dSzzRQ++CKnNI/krKnYRV7JKKPUXMEh61soaHKg9mrWEhzFWhFnxPxGl+69cD1Ou63C13NUPCnmIcrvqCuM6w==", "dev": true, - "requires": { - "cliui": "^7.0.2", + "dependencies": { + "cliui": "^8.0.1", "escalade": "^3.1.1", "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", - "string-width": "^4.2.0", + "string-width": "^4.2.3", "y18n": "^5.0.5", - "yargs-parser": "^20.2.2" + "yargs-parser": "^21.1.1" }, - "dependencies": { - "ansi-regex": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", - "dev": true - }, - "is-fullwidth-code-point": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", - "dev": true - }, - "string-width": { - "version": "4.2.2", - "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.2.tgz", - "integrity": "sha512-XBJbT3N4JhVumXE0eoLU9DCjcaF92KLNqTmFCnG1pf8duUxFGwtP6AD6nkjw9a3IdiRtL3E2w3JDiE/xi3vOeA==", - "dev": true, - "requires": { - "emoji-regex": "^8.0.0", - "is-fullwidth-code-point": "^3.0.0", - "strip-ansi": "^6.0.0" - } - }, - "strip-ansi": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", - "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", - "dev": true, - "requires": { - "ansi-regex": "^5.0.0" - } - } + "engines": { + "node": ">=12" } }, - "yargs-parser": { - "version": "20.2.4", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", - "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", - "dev": true + "node_modules/yargs-parser": { + "version": "21.1.1", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-21.1.1.tgz", + "integrity": "sha512-tVpsJW7DdjecAiFpbIB1e3qxIQsE6NoPc5/eTdrbbIC4h0LVsWhnoa3g+m2HclBIujHzsxZ4VJVA+GUuc2/LBw==", + "dev": true, + "engines": { + "node": ">=12" + } }, - "yargs-unparser": { + "node_modules/yargs-unparser": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz", "integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==", "dev": true, - "requires": { + "dependencies": { "camelcase": "^6.0.0", "decamelize": "^4.0.0", "flat": "^5.0.2", "is-plain-obj": "^2.1.0" + }, + "engines": { + "node": ">=10" } }, - "yocto-queue": { + "node_modules/yocto-queue": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz", "integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==", - "dev": true + "dev": true, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } } } } diff --git a/package.json b/package.json index cc34dced..ec8ee772 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "compress-commons", - "version": "4.1.1", + "version": "7.0.1", "description": "a library that defines a common interface for working with archive formats within node", "homepage": "https://github.com/archiverjs/node-compress-commons", "author": { @@ -15,27 +15,30 @@ "url": "https://github.com/archiverjs/node-compress-commons/issues" }, "license": "MIT", - "main": "lib/compress-commons.js", + "type": "module", + "exports": "./lib/compress-commons.js", "files": [ "lib" ], "engines": { - "node": ">= 10" + "node": ">=18" }, "scripts": { "test": "mocha --reporter dot" }, "dependencies": { - "buffer-crc32": "^0.2.13", - "crc32-stream": "^4.0.2", + "crc-32": "^1.2.0", + "crc32-stream": "^7.0.1", + "is-stream": "^4.0.0", "normalize-path": "^3.0.0", - "readable-stream": "^3.6.0" + "readable-stream": "^4.0.0" }, "devDependencies": { - "chai": "^4.0.0", - "mkdirp": "^1.0.4", - "mocha": "^9.0.2", - "rimraf": "^3.0.2" + "chai": "6.2.2", + "mkdirp": "3.0.1", + "mocha": "11.7.5", + "prettier": "3.8.3", + "rimraf": "6.1.3" }, "keywords": [ "compress", diff --git a/renovate.json b/renovate.json new file mode 100644 index 00000000..0d65ef2a --- /dev/null +++ b/renovate.json @@ -0,0 +1,30 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": ["config:recommended", "schedule:daily", ":pinDevDependencies"], + "timezone": "America/Chicago", + "labels": ["dependencies"], + "packageRules": [ + { + "matchManagers": ["npm", "nvm"], + "separateMultipleMajor": true + }, + { + "matchManagers": ["npm", "nvm"], + "matchUpdateTypes": ["minor", "patch"], + "automerge": true + }, + { + "matchManagers": ["github-actions"], + "addLabels": ["ci", "github-actions"], + "rangeStrategy": "pin" + }, + { + "matchManagers": ["github-actions"], + "matchUpdateTypes": ["minor", "patch"], + "automerge": true + } + ], + "constraints": { + "npm": "<9" + } +} diff --git a/test/archive-output-stream.js b/test/archive-output-stream.js index 29a27b13..f13dcb1b 100644 --- a/test/archive-output-stream.js +++ b/test/archive-output-stream.js @@ -1,18 +1,8 @@ -/*global before,describe,it */ -var fs = require('fs'); -var assert = require('chai').assert; -var mkdir = require('mkdirp'); - -var helpers = require('./helpers'); - -var commons = require('../lib/compress-commons'); - -var testBuffer = helpers.binaryBuffer(1024 * 16); - -describe('ArchiveOutputStream', function() { - - describe('#entry', function() { - - }); - -}); \ No newline at end of file +import fs from "fs"; +import { assert } from "chai"; +import { binaryBuffer } from "./helpers/index.js"; + +var testBuffer = binaryBuffer(1024 * 16); +describe("ArchiveOutputStream", function () { + describe("#entry", function () {}); +}); diff --git a/test/commons.js b/test/commons.js index 99bbd7d8..13a5b82c 100644 --- a/test/commons.js +++ b/test/commons.js @@ -1,10 +1,7 @@ +import { assert } from "chai"; /*global before,describe,it */ -var assert = require('chai').assert; -var commons = require('../lib/compress-commons'); - -describe('commons', function() { +describe("commons", function () { // it('will do something some day', function(){ // }); - -}); \ No newline at end of file +}); diff --git a/test/general-purpose-bit.js b/test/general-purpose-bit.js index eb87590b..7a427115 100644 --- a/test/general-purpose-bit.js +++ b/test/general-purpose-bit.js @@ -1,98 +1,55 @@ +import { assert } from "chai"; +import GeneralPurposeBit from "../lib/archivers/zip/general-purpose-bit.js"; /*global before,describe,it */ -var assert = require('chai').assert; -var GeneralPurposeBit = require('../lib/archivers/zip/general-purpose-bit'); var gpb; - -describe('GeneralPurposeBit', function() { - - beforeEach(function() { +describe("GeneralPurposeBit", function () { + beforeEach(function () { gpb = new GeneralPurposeBit(); }); - - describe('#encode', function() { - it('should return a Buffer', function(){ + describe("#encode", function () { + it("should return a Buffer", function () { gpb.useDataDescriptor(); assert.ok(Buffer.isBuffer(gpb.encode())); }); }); - - describe('#parse', function() { - it.skip('should be tested', function() { - - }); + describe("#parse", function () { + it.skip("should be tested", function () {}); }); - - describe('#setNumberOfShannonFanoTrees', function() { - it.skip('should be tested', function() { - - }); + describe("#setNumberOfShannonFanoTrees", function () { + it.skip("should be tested", function () {}); }); - - describe('#getNumberOfShannonFanoTrees', function() { - it.skip('should be tested', function() { - - }); + describe("#getNumberOfShannonFanoTrees", function () { + it.skip("should be tested", function () {}); }); - - describe('#setSlidingDictionarySize', function() { - it.skip('should be tested', function() { - - }); + describe("#setSlidingDictionarySize", function () { + it.skip("should be tested", function () {}); }); - - describe('#getSlidingDictionarySize', function() { - it.skip('should be tested', function() { - - }); + describe("#getSlidingDictionarySize", function () { + it.skip("should be tested", function () {}); }); - - describe('#useDataDescriptor', function() { - it.skip('should be tested', function() { - - }); + describe("#useDataDescriptor", function () { + it.skip("should be tested", function () {}); }); - - describe('#usesDataDescriptor', function() { - it.skip('should be tested', function() { - - }); + describe("#usesDataDescriptor", function () { + it.skip("should be tested", function () {}); }); - - describe('#useEncryption', function() { - it.skip('should be tested', function() { - - }); + describe("#useEncryption", function () { + it.skip("should be tested", function () {}); }); - - describe('#usesEncryption', function() { - it.skip('should be tested', function() { - - }); + describe("#usesEncryption", function () { + it.skip("should be tested", function () {}); }); - - describe('#useStrongEncryption', function() { - it.skip('should be tested', function() { - - }); + describe("#useStrongEncryption", function () { + it.skip("should be tested", function () {}); }); - - describe('#usesStrongEncryption', function() { - it.skip('should be tested', function() { - - }); + describe("#usesStrongEncryption", function () { + it.skip("should be tested", function () {}); }); - - describe('#useUTF8ForNames', function() { - it.skip('should be tested', function() { - - }); + describe("#useUTF8ForNames", function () { + it.skip("should be tested", function () {}); }); - - describe('#usesUTF8ForNames', function() { - it.skip('should be tested', function() { - - }); + describe("#usesUTF8ForNames", function () { + it.skip("should be tested", function () {}); }); - -}); \ No newline at end of file +}); diff --git a/test/helpers/index.js b/test/helpers/index.js index c4eb5514..9c23f52c 100644 --- a/test/helpers/index.js +++ b/test/helpers/index.js @@ -1,87 +1,67 @@ -var crypto = require('crypto'); -var fs = require('fs'); -var inherits = require('util').inherits; - -var Stream = require('stream').Stream; -var Readable = require('readable-stream').Readable; -var Writable = require('readable-stream').Writable; - -function binaryBuffer(n) { +import crypto from "crypto"; +import { WriteStream } from "fs"; +import { inherits } from "util"; +import { Stream } from "stream"; +import { Readable } from "readable-stream"; +import { Writable } from "readable-stream"; + +export function binaryBuffer(n) { var buffer = Buffer.alloc(n); - for (var i = 0; i < n; i++) { - buffer.writeUInt8(i&255, i); + buffer.writeUInt8(i & 255, i); } - return buffer; } -module.exports.binaryBuffer = binaryBuffer; - -function BinaryStream(size, options) { - Readable.call(this, options); - - var buf = Buffer.alloc(size); - - for (var i = 0; i < size; i++) { - buf.writeUInt8(i&255, i); +export class BinaryStream extends Readable { + constructor(size, options) { + super(options); + var buf = Buffer.alloc(size); + for (var i = 0; i < size; i++) { + buf.writeUInt8(i & 255, i); + } + this.push(buf); + this.push(null); } - this.push(buf); - this.push(null); + _read(size) {} } -inherits(BinaryStream, Readable); - -BinaryStream.prototype._read = function(size) {}; - -module.exports.BinaryStream = BinaryStream; +export class DeadEndStream extends Writable { + constructor(options) { + super(options); + } -function DeadEndStream(options) { - Writable.call(this, options); + _write(chuck, encoding, callback) { + callback(); + } } -inherits(DeadEndStream, Writable); - -DeadEndStream.prototype._write = function(chuck, encoding, callback) { - callback(); -}; - -module.exports.DeadEndStream = DeadEndStream; - -function fileBuffer(filepath) { +export function fileBuffer(filepath) { return fs.readFileSync(filepath); } -module.exports.fileBuffer = fileBuffer; - -function UnBufferedStream() { - this.readable = true; -} - -inherits(UnBufferedStream, Stream); - -module.exports.UnBufferedStream = UnBufferedStream; - -function WriteHashStream(path, options) { - fs.WriteStream.call(this, path, options); - - this.hash = crypto.createHash('sha1'); - this.digest = null; - - this.on('close', function() { - this.digest = this.hash.digest('hex'); - }); +export class UnBufferedStream extends Stream { + constructor() { + super(); + this.readable = true; + } } -inherits(WriteHashStream, fs.WriteStream); - -WriteHashStream.prototype.write = function(chunk) { - if (chunk) { - this.hash.update(chunk); +export class WriteHashStream extends WriteStream { + constructor(path, options) { + super(path, options); + this.hash = crypto.createHash("sha1"); + this.digest = null; + this.on("close", function () { + this.digest = this.hash.digest("hex"); + }); } - return fs.WriteStream.prototype.write.call(this, chunk); -}; - -module.exports.WriteHashStream = WriteHashStream; \ No newline at end of file + write(chunk) { + if (chunk) { + this.hash.update(chunk); + } + return super.write(chunk); + } +} diff --git a/test/zip-archive-entry.js b/test/zip-archive-entry.js index 5b18d0f3..bcf88e5e 100644 --- a/test/zip-archive-entry.js +++ b/test/zip-archive-entry.js @@ -1,319 +1,254 @@ +import { assert } from "chai"; +import { ZipArchiveEntry } from "../lib/compress-commons.js"; +import GeneralPurposeBit from "../lib/archivers/zip/general-purpose-bit.js"; +import UnixStat from "../lib/archivers/zip/unix-stat.js"; /*global before,describe,it */ -var assert = require('chai').assert; - -var commons = require('../lib/compress-commons'); -var ZipArchiveEntry = commons.ZipArchiveEntry; -var GeneralPurposeBit = require('../lib/archivers/zip/general-purpose-bit'); -var UnixStat = require('../lib/archivers/zip/unix-stat'); var entry; // Jan 03 2013 14:26:38 GMT var testDate = new Date(Date.UTC(2013, 0, 3, 14, 26, 38, 0)); -describe('ZipArchiveEntry', function() { - - beforeEach(function() { - entry = new ZipArchiveEntry('file.txt'); +describe("ZipArchiveEntry", function () { + beforeEach(function () { + entry = new ZipArchiveEntry("file.txt"); }); - // Getters - describe('#getCentralDirectoryExtra', function() { - it.skip('should be tested', function() { - - }); + describe("#getCentralDirectoryExtra", function () { + it.skip("should be tested", function () {}); }); - - describe('#getComment', function() { - it('should return the comment', function() { - entry.setComment('file comment'); - assert.equal(entry.getComment(), 'file comment'); + describe("#getComment", function () { + it("should return the comment", function () { + entry.setComment("file comment"); + assert.equal(entry.getComment(), "file comment"); }); }); - - describe('#getCompressedSize', function() { - it('should return the compressed size', function() { + describe("#getCompressedSize", function () { + it("should return the compressed size", function () { entry.csize = 10; assert.equal(entry.getCompressedSize(), 10); }); }); - - describe('#getCrc', function() { - it('should return the CRC32', function() { + describe("#getCrc", function () { + it("should return the CRC32", function () { entry.crc = 585446183; assert.equal(entry.getCrc(), 585446183); }); }); - - describe('#getExternalAttributes', function() { - it('should return the external attributes', function() { + describe("#getExternalAttributes", function () { + it("should return the external attributes", function () { entry.exattr = 2180972576; assert.equal(entry.getExternalAttributes(), 2180972576); }); }); - - describe('#getExtra', function() { - it.skip('should be tested', function() { - - }); + describe("#getExtra", function () { + it.skip("should be tested", function () {}); }); - - describe('#getGeneralPurposeBit', function() { - it('should return the general purpose bit flag', function() { + describe("#getGeneralPurposeBit", function () { + it("should return the general purpose bit flag", function () { var gpb = new GeneralPurposeBit(); gpb.useDataDescriptor(true); entry.gpb = gpb; assert.equal(entry.getGeneralPurposeBit(), gpb); }); }); - - describe('#getInternalAttributes', function() { - it('should return the internal attributes', function() { + describe("#getInternalAttributes", function () { + it("should return the internal attributes", function () { entry.inattr = 2180972576; assert.equal(entry.getInternalAttributes(), 2180972576); }); }); - - describe('#getLastModifiedDate', function() { - it.skip('should be tested', function() { - - }); + describe("#getLastModifiedDate", function () { + it.skip("should be tested", function () {}); }); - - describe('#getLocalFileDataExtra', function() { - it.skip('should be tested', function() { - - }); + describe("#getLocalFileDataExtra", function () { + it.skip("should be tested", function () {}); }); - - describe('#getMethod', function() { - it('should return the compression method', function() { + describe("#getMethod", function () { + it("should return the compression method", function () { entry.method = 0; assert.equal(entry.getMethod(), 0); }); }); - - describe('#getName', function() { - it('should return the name', function() { - entry.name = 'file.txt'; - assert.equal(entry.getName(), 'file.txt'); + describe("#getName", function () { + it("should return the name", function () { + entry.name = "file.txt"; + assert.equal(entry.getName(), "file.txt"); }); }); - - describe('#getPlatform', function() { - it('should return the platform', function() { + describe("#getPlatform", function () { + it("should return the platform", function () { entry.platform = 3; assert.equal(entry.getPlatform(), 3); }); }); - - describe('#getSize', function() { - it('should return the size', function() { + describe("#getSize", function () { + it("should return the size", function () { entry.size = 25; assert.equal(entry.getSize(), 25); }); }); - - describe('#getTime', function() { - it('should return a Date object', function() { + describe("#getTime", function () { + it("should return a Date object", function () { entry.time = 1109607251; - assert.typeOf(entry.getTime(), 'Date'); + assert.typeOf(entry.getTime(), "Date"); }); }); - - describe('#getTimeDos', function() { - it('should return a number', function() { + describe("#getTimeDos", function () { + it("should return a number", function () { entry.time = 1109607251; - assert.typeOf(entry.getTimeDos(), 'number'); + assert.typeOf(entry.getTimeDos(), "number"); }); }); - - describe('#getUnixMode', function() { - it('should return the unix filemode', function() { - entry.mode = 0777; + describe("#getUnixMode", function () { + it("should return the unix filemode", function () { + entry.mode = 511; // 0777 entry.exattr = 2180972576; entry.platform = 3; - assert.equal(entry.getUnixMode(), 0100777); + assert.equal(entry.getUnixMode(), 33279); // 0100777 }); - - it('should set proper external attributes for an unix directory', function () { - entry = new ZipArchiveEntry('directory/'); - entry.setUnixMode(0777); - + it("should set proper external attributes for an unix directory", function () { + entry = new ZipArchiveEntry("directory/"); + entry.setUnixMode(511); // 0777 assert.ok(entry.getPlatform(), 3); assert.ok(entry.isDirectory()); - var exattr = entry.getExternalAttributes() >> 16; - assert.equal(exattr & 040000, 040000); + assert.equal(exattr & 16384, 16384); // 040000 }); }); - - describe('#getVersionNeededToExtract', function() { - it.skip('should be tested', function() { - - }); + describe("#getVersionNeededToExtract", function () { + it.skip("should be tested", function () {}); }); - // Setters - describe('#setComment', function() { - it('should set internal variable', function() { - entry.setComment('file comment'); - assert.propertyVal(entry, 'comment', 'file comment'); + describe("#setComment", function () { + it("should set internal variable", function () { + entry.setComment("file comment"); + assert.propertyVal(entry, "comment", "file comment"); }); - - it('should set utf8 bit when receiving strings byte count != string length', function() { - entry.setComment('ÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäçèéêëìíîïñòóôõöùúûüýÿ'); + it("should set utf8 bit when receiving strings byte count != string length", function () { + entry.setComment("ÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäçèéêëìíîïñòóôõöùúûüýÿ"); assert.ok(entry.getGeneralPurposeBit().usesUTF8ForNames()); }); }); - - describe('#setCompressedSize', function() { - it('should set internal variable', function() { + describe("#setCompressedSize", function () { + it("should set internal variable", function () { entry.setCompressedSize(10); - assert.propertyVal(entry, 'csize', 10); + assert.propertyVal(entry, "csize", 10); }); }); - - describe('#setCrc', function() { - it('should set internal variable', function() { + describe("#setCrc", function () { + it("should set internal variable", function () { entry.setCrc(585446183); - assert.propertyVal(entry, 'crc', 585446183); + assert.propertyVal(entry, "crc", 585446183); }); }); - - describe('#setExternalAttributes', function() { - it('should set internal variable', function() { + describe("#setExternalAttributes", function () { + it("should set internal variable", function () { entry.setExternalAttributes(2180972576); - assert.propertyVal(entry, 'exattr', 2180972576); + assert.propertyVal(entry, "exattr", 2180972576); }); }); - - describe('#setExtra', function() { - it.skip('should be tested', function() { - - }); + describe("#setExtra", function () { + it.skip("should be tested", function () {}); }); - - describe('#setGeneralPurposeBit', function() { - it('should set internal variable', function() { + describe("#setGeneralPurposeBit", function () { + it("should set internal variable", function () { var gpb = new GeneralPurposeBit(); gpb.useDataDescriptor(true); entry.setGeneralPurposeBit(gpb); - assert.propertyVal(entry, 'gpb', gpb); + assert.propertyVal(entry, "gpb", gpb); }); }); - - describe('#setInternalAttributes', function() { - it('should set internal variable', function() { + describe("#setInternalAttributes", function () { + it("should set internal variable", function () { entry.setInternalAttributes(2180972576); - assert.propertyVal(entry, 'inattr', 2180972576); + assert.propertyVal(entry, "inattr", 2180972576); }); }); - - describe('#setMethod', function() { - it('should set internal variable', function() { + describe("#setMethod", function () { + it("should set internal variable", function () { entry.setMethod(8); - assert.propertyVal(entry, 'method', 8); + assert.propertyVal(entry, "method", 8); }); }); - - describe('#setName', function() { - it('should set internal variable', function() { - entry.setName('file.txt'); - assert.propertyVal(entry, 'name', 'file.txt'); + describe("#setName", function () { + it("should set internal variable", function () { + entry.setName("file.txt"); + assert.propertyVal(entry, "name", "file.txt"); }); - - it('should allow setting prefix of / at the beginning of path', function() { - entry.setName('file.txt', true); - assert.propertyVal(entry, 'name', '/file.txt'); + it("should allow setting prefix of / at the beginning of path", function () { + entry.setName("file.txt", true); + assert.propertyVal(entry, "name", "/file.txt"); }); - - it('should allow ./ at the beginning of path', function() { - entry.setName('./file.txt'); - assert.propertyVal(entry, 'name', './file.txt'); + it("should allow ./ at the beginning of path", function () { + entry.setName("./file.txt"); + assert.propertyVal(entry, "name", "./file.txt"); }); - - it('should clean windows style paths', function() { - entry.setName('\\windows\\file.txt'); - assert.propertyVal(entry, 'name', 'windows/file.txt'); - - entry.setName('c:\\this\\path\\file.txt'); - assert.propertyVal(entry, 'name', 'this/path/file.txt'); - - entry.setName('\\\\server\\share\\'); - assert.propertyVal(entry, 'name', 'server/share/'); + it("should clean windows style paths", function () { + entry.setName("\\windows\\file.txt"); + assert.propertyVal(entry, "name", "windows/file.txt"); + entry.setName("c:\\this\\path\\file.txt"); + assert.propertyVal(entry, "name", "this/path/file.txt"); + entry.setName("\\\\server\\share\\"); + assert.propertyVal(entry, "name", "server/share/"); }); - - it('should clean multiple forward slashes at beginning of path', function() { - entry.setName('//forward/file.txt'); - assert.propertyVal(entry, 'name', 'forward/file.txt'); + it("should clean multiple forward slashes at beginning of path", function () { + entry.setName("//forward/file.txt"); + assert.propertyVal(entry, "name", "forward/file.txt"); }); - - it('should set utf8 bit when receiving strings byte count != string length', function() { - entry.setName('ÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäçèéêëìíîïñòóôõöùúûüýÿ.txt'); + it("should set utf8 bit when receiving strings byte count != string length", function () { + entry.setName("ÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝàáâãäçèéêëìíîïñòóôõöùúûüýÿ.txt"); assert.ok(entry.getGeneralPurposeBit().usesUTF8ForNames()); }); }); - - describe('#setPlatform', function() { - it('should set internal variable', function() { + describe("#setPlatform", function () { + it("should set internal variable", function () { entry.setPlatform(3); - assert.propertyVal(entry, 'platform', 3); + assert.propertyVal(entry, "platform", 3); }); }); - - describe('#setSize', function() { - it('should set internal variable', function() { + describe("#setSize", function () { + it("should set internal variable", function () { entry.setSize(15); - assert.propertyVal(entry, 'size', 15); + assert.propertyVal(entry, "size", 15); }); }); - - describe('#setTime', function() { - it('should set internal variable', function() { + describe("#setTime", function () { + it("should set internal variable", function () { entry.setTime(testDate); - assert.propertyVal(entry, 'time', 1109619539); + assert.propertyVal(entry, "time", 1109619539); }); }); - - describe('#setUnixMode', function() { - it('should set internal variables', function() { - entry.setUnixMode(0777); - assert.propertyVal(entry, 'exattr', 2180972576); - assert.propertyVal(entry, 'mode', 0777); - assert.equal(entry.getUnixMode(), 0100777); - + describe("#setUnixMode", function () { + it("should set internal variables", function () { + entry.setUnixMode(511); + assert.propertyVal(entry, "exattr", 2180972576); + assert.propertyVal(entry, "mode", 511); // 0777 + assert.equal(entry.getUnixMode(), 33279); // 0100777 }); - - it('should also preserve filetype information', function() { - entry.setUnixMode(0120755); - assert.propertyVal(entry, 'exattr', 2716663840); - assert.propertyVal(entry, 'mode', 0755); - assert.equal(entry.getUnixMode(), 0120755); + it("should also preserve filetype information", function () { + entry.setUnixMode(41453); + assert.propertyVal(entry, "exattr", 2716663840); + assert.propertyVal(entry, "mode", 493); // 0755 + assert.equal(entry.getUnixMode(), 41453); // 0120755 }); }); - - describe('#setVersionNeededToExtract', function() { - it.skip('should be tested', function() { - - }); + describe("#setVersionNeededToExtract", function () { + it.skip("should be tested", function () {}); }); - // Others - describe('#isDirectory', function() { - it('should return a boolean based on name of entry', function() { + describe("#isDirectory", function () { + it("should return a boolean based on name of entry", function () { assert.notOk(entry.isDirectory()); - entry.setName('some/directory/'); + entry.setName("some/directory/"); assert.ok(entry.isDirectory()); }); }); - - describe('#isUnixSymlink', function() { - it('should return a boolean if the entry is a symlink', function() { - entry.setUnixMode(UnixStat.LINK_FLAG); - assert.ok(entry.isUnixSymlink()); - - entry.setUnixMode(UnixStat.LINK_FLAG | UnixStat.DIR_FLAG); - assert.notOk(entry.isUnixSymlink()); - }); + describe("#isUnixSymlink", function () { + it("should return a boolean if the entry is a symlink", function () { + entry.setUnixMode(UnixStat.LINK_FLAG); + assert.ok(entry.isUnixSymlink()); + entry.setUnixMode(UnixStat.LINK_FLAG | UnixStat.DIR_FLAG); + assert.notOk(entry.isUnixSymlink()); + }); }); }); diff --git a/test/zip-archive-output-stream.js b/test/zip-archive-output-stream.js index b24ce556..6fc1781d 100644 --- a/test/zip-archive-output-stream.js +++ b/test/zip-archive-output-stream.js @@ -1,127 +1,124 @@ -/*global before,describe,it */ -var fs = require('fs'); -var stream = require('stream'); -var assert = require('chai').assert; -var mkdir = require('mkdirp'); - -var helpers = require('./helpers'); -var WriteHashStream = helpers.WriteHashStream; -var testBuffer = helpers.binaryBuffer(1024 * 16); -var testDate = new Date('Jan 03 2013 14:26:38 GMT'); - -var commons = require('../lib/compress-commons'); -var ZipArchiveEntry = commons.ZipArchiveEntry; -var ZipArchiveOutputStream = commons.ZipArchiveOutputStream; - -describe('ZipArchiveOutputStream', function() { - - before(function() { - mkdir.sync('tmp'); +import { createReadStream } from "fs"; +import { Stream, Transform } from "stream"; +import { assert } from "chai"; +import { mkdirp } from "mkdirp"; +import { Readable } from "readable-stream"; +import { WriteHashStream, binaryBuffer } from "./helpers/index.js"; +import { + ZipArchiveEntry, + ZipArchiveOutputStream, +} from "../lib/compress-commons.js"; + +var testBuffer = binaryBuffer(1024 * 16); +var testDate = new Date("Jan 03 2013 14:26:38 GMT"); + +describe("ZipArchiveOutputStream", function () { + before(function () { + mkdirp.sync("tmp"); }); - - describe('#entry', function() { - it('should append Buffer sources', function(done) { + describe("#entry", function () { + it("should append Buffer sources", function (done) { var archive = new ZipArchiveOutputStream(); - var testStream = new WriteHashStream('tmp/zip-buffer.zip'); - var entry = new ZipArchiveEntry('buffer.txt'); - - testStream.on('close', function() { + var testStream = new WriteHashStream("tmp/zip-buffer.zip"); + var entry = new ZipArchiveEntry("buffer.txt"); + testStream.on("close", function () { done(); }); - archive.pipe(testStream); - archive.entry(entry, testBuffer).finish(); }); - - it('should append Stream sources', function(done) { + it("should append Stream sources", function (done) { var archive = new ZipArchiveOutputStream(); - var testStream = new WriteHashStream('tmp/zip-stream.zip'); - var entry = new ZipArchiveEntry('stream.txt'); - - testStream.on('close', function() { + var testStream = new WriteHashStream("tmp/zip-stream.zip"); + var entry = new ZipArchiveEntry("stream.txt"); + testStream.on("close", function () { done(); }); - archive.pipe(testStream); - - archive.entry(entry, fs.createReadStream('test/fixtures/test.txt')).finish(); + archive.entry(entry, createReadStream("test/fixtures/test.txt")).finish(); }); - - it('should stop streaming on Stream error', function(done) { + it("should append Stream-like sources", function (done) { var archive = new ZipArchiveOutputStream(); - var testStream = new WriteHashStream('tmp/zip-stream.zip'); - var entry = new ZipArchiveEntry('stream.txt'); - + var testStream = new WriteHashStream("tmp/zip-stream-like.zip"); + var entry = new ZipArchiveEntry("stream-like.txt"); + testStream.on("close", function () { + done(); + }); + archive.pipe(testStream); + archive.entry(entry, Readable.from(["test"])).finish(); + }); + it("should stop streaming on Stream error", function (done) { + var archive = new ZipArchiveOutputStream(); + var testStream = new WriteHashStream("tmp/zip-stream.zip"); + var entry = new ZipArchiveEntry("stream.txt"); var callbackError = null; var callbackCalls = 0; - - testStream.on('close', function() { - assert.equal(callbackError.message, 'something went wrong'); + testStream.on("close", function () { + assert.equal(callbackError.message, "something went wrong"); assert.equal(callbackCalls, 1); done(); }); - archive.pipe(testStream); - - var file = new stream.Transform(); - archive.entry(entry, file, function(err) { + var file = new Transform(); + archive.entry(entry, file, function (err) { callbackCalls += 1; callbackError = err; }); archive.finish(); - - process.nextTick(function() { - file.emit('error', new Error('something went wrong')); - }) + process.nextTick(function () { + file.emit("error", new Error("something went wrong")); + }); }); - - it('should append multiple sources', function(done) { + it("should append multiple sources", function (done) { var archive = new ZipArchiveOutputStream(); - var testStream = new WriteHashStream('tmp/zip-multiple.zip'); - - var entry = new ZipArchiveEntry('string.txt'); - var entry2 = new ZipArchiveEntry('buffer.txt'); - var entry3 = new ZipArchiveEntry('stream.txt'); - var entry4 = new ZipArchiveEntry('stream-store.png'); + var testStream = new WriteHashStream("tmp/zip-multiple.zip"); + var entry = new ZipArchiveEntry("string.txt"); + var entry2 = new ZipArchiveEntry("buffer.txt"); + var entry3 = new ZipArchiveEntry("stream.txt"); + var entry4 = new ZipArchiveEntry("stream-store.png"); entry4.setMethod(0); - - testStream.on('close', function() { + var entry5 = new ZipArchiveEntry("buffer-store.txt"); + entry5.setMethod(0); + testStream.on("close", function () { done(); }); - archive.pipe(testStream); - - archive.entry(entry, 'string', function(err) { + archive.entry(entry, "string", function (err) { if (err) throw err; - archive.entry(entry2, testBuffer, function(err) { + archive.entry(entry2, testBuffer, function (err) { if (err) throw err; - archive.entry(entry3, fs.createReadStream('test/fixtures/test.txt'), function(err) { - if (err) throw err; - archive.entry(entry4, fs.createReadStream('test/fixtures/image.png'), function(err) { + archive.entry( + entry3, + createReadStream("test/fixtures/test.txt"), + function (err) { if (err) throw err; - archive.finish(); - }); - }); + archive.entry( + entry4, + createReadStream("test/fixtures/image.png"), + function (err) { + if (err) throw err; + archive.entry(entry5, testBuffer, function (err) { + if (err) throw err; + archive.finish(); + }); + }, + ); + }, + ); }); }); }); - - it('should force ZIP64', function(done) { + it("should force ZIP64", function (done) { var archive = new ZipArchiveOutputStream({ - forceZip64: true + forceZip64: true, }); - var testStream = new WriteHashStream('tmp/zip-stream64.zip'); - var entry = new ZipArchiveEntry('stream.txt'); - - testStream.on('close', function() { + var testStream = new WriteHashStream("tmp/zip-stream64.zip"); + var entry = new ZipArchiveEntry("stream.txt"); + testStream.on("close", function () { done(); }); - archive.pipe(testStream); - - archive.entry(entry, fs.createReadStream('test/fixtures/test.txt')).finish(); + archive.entry(entry, createReadStream("test/fixtures/test.txt")).finish(); }); }); - -}); \ No newline at end of file +});