From 639ef80b146c20b33d4480ba548a807b57c22b37 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 3 Sep 2023 15:53:01 -0500 Subject: [PATCH 1/4] use crc-32 instead of buffer-crc32 (#162) * use crc-32 instead of buffer-crc32 * expand tests * artifacts --- .github/workflows/nodejs.yml | 5 +++++ .../zip/zip-archive-output-stream.js | 4 ++-- package-lock.json | 19 +++---------------- package.json | 2 +- test/zip-archive-output-stream.js | 7 ++++++- 5 files changed, 17 insertions(+), 20 deletions(-) diff --git a/.github/workflows/nodejs.yml b/.github/workflows/nodejs.yml index 6d5053fa..cff04237 100644 --- a/.github/workflows/nodejs.yml +++ b/.github/workflows/nodejs.yml @@ -28,3 +28,8 @@ jobs: npm test env: CI: true + - name: Archive production artifacts + uses: actions/upload-artifact@v3 + with: + name: tmp-zip + path: tmp/*.zip diff --git a/lib/archivers/zip/zip-archive-output-stream.js b/lib/archivers/zip/zip-archive-output-stream.js index 0b17dd49..9e04922b 100644 --- a/lib/archivers/zip/zip-archive-output-stream.js +++ b/lib/archivers/zip/zip-archive-output-stream.js @@ -6,7 +6,7 @@ * https://github.com/archiverjs/node-compress-commons/blob/master/LICENSE-MIT */ var inherits = require('util').inherits; -var crc32 = require('buffer-crc32'); +var crc32 = require('crc-32'); var {CRC32Stream} = require('crc32-stream'); var {DeflateCRC32Stream} = require('crc32-stream'); @@ -68,7 +68,7 @@ ZipArchiveOutputStream.prototype._appendBuffer = function(ae, source, callback) if (method === constants.METHOD_STORED) { ae.setSize(source.length); ae.setCompressedSize(source.length); - ae.setCrc(crc32.unsigned(source)); + ae.setCrc(crc32.buf(source) >>> 0); } this._writeLocalFileHeader(ae); diff --git a/package-lock.json b/package-lock.json index 9a7521ba..0f3b8f08 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "compress-commons", - "version": "4.1.2", + "version": "5.0.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "compress-commons", - "version": "4.1.2", + "version": "5.0.0", "license": "MIT", "dependencies": { - "buffer-crc32": "^0.2.13", + "crc-32": "^1.2.0", "crc32-stream": "^5.0.0", "normalize-path": "^3.0.0", "readable-stream": "^3.6.0" @@ -125,14 +125,6 @@ "integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==", "dev": true }, - "node_modules/buffer-crc32": { - "version": "0.2.13", - "resolved": "https://registry.npmjs.org/buffer-crc32/-/buffer-crc32-0.2.13.tgz", - "integrity": "sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=", - "engines": { - "node": "*" - } - }, "node_modules/camelcase": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", @@ -1301,11 +1293,6 @@ "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=" - }, "camelcase": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.2.0.tgz", diff --git a/package.json b/package.json index ac9b0b34..3269110b 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "test": "mocha --reporter dot" }, "dependencies": { - "buffer-crc32": "^0.2.13", + "crc-32": "^1.2.0", "crc32-stream": "^5.0.0", "normalize-path": "^3.0.0", "readable-stream": "^3.6.0" diff --git a/test/zip-archive-output-stream.js b/test/zip-archive-output-stream.js index b24ce556..ba2bbf7b 100644 --- a/test/zip-archive-output-stream.js +++ b/test/zip-archive-output-stream.js @@ -85,6 +85,8 @@ describe('ZipArchiveOutputStream', function() { var entry3 = new ZipArchiveEntry('stream.txt'); var entry4 = new ZipArchiveEntry('stream-store.png'); entry4.setMethod(0); + var entry5 = new ZipArchiveEntry('buffer-store.txt') + entry5.setMethod(0) testStream.on('close', function() { done(); @@ -100,7 +102,10 @@ describe('ZipArchiveOutputStream', function() { if (err) throw err; archive.entry(entry4, fs.createReadStream('test/fixtures/image.png'), function(err) { if (err) throw err; - archive.finish(); + archive.entry(entry5, testBuffer, function(err) { + if (err) throw err; + archive.finish(); + }); }); }); }); From e2d211537b3d363f9d7871b198b772d2c56776cb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 3 Sep 2023 16:02:52 -0500 Subject: [PATCH 2/4] Update dependency crc-32 to v1.2.2 (#163) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> --- package-lock.json | 49 ++++++----------------------------------------- 1 file changed, 6 insertions(+), 43 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0f3b8f08..09fc267e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -299,13 +299,9 @@ "dev": true }, "node_modules/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==", - "dependencies": { - "exit-on-epipe": "~1.0.1", - "printj": "~1.1.0" - }, + "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" }, @@ -408,14 +404,6 @@ "url": "https://github.com/sponsors/sindresorhus" } }, - "node_modules/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==", - "engines": { - "node": ">=0.8" - } - }, "node_modules/fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -872,17 +860,6 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, - "node_modules/printj": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", - "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==", - "bin": { - "printj": "bin/printj.njs" - }, - "engines": { - "node": ">=0.8" - } - }, "node_modules/randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", @@ -1424,13 +1401,9 @@ "dev": true }, "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" - } + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/crc-32/-/crc-32-1.2.2.tgz", + "integrity": "sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==" }, "crc32-stream": { "version": "5.0.0", @@ -1497,11 +1470,6 @@ "integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==", "dev": true }, - "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==" - }, "fill-range": { "version": "7.0.1", "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz", @@ -1819,11 +1787,6 @@ "integrity": "sha512-lY1Q/PiJGC2zOv/z391WOTD+Z02bCgsFfvxoXXf6h7kv9o+WmsmzYqrAwY63sNgOxE4xEdq0WyUnXfKeBrSvYw==", "dev": true }, - "printj": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/printj/-/printj-1.1.2.tgz", - "integrity": "sha512-zA2SmoLaxZyArQTOPj5LXecR+RagfPSU5Kw1qP+jkWeNlrq+eJZyY2oS68SU1Z/7/myXM4lo9716laOFAVStCQ==" - }, "randombytes": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz", From e6861b1ff20f8a0cee6f70506fddc3d3c84aa1b0 Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 3 Sep 2023 16:04:10 -0500 Subject: [PATCH 3/4] Update CHANGELOG.md --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 50b0efdf..ccb7e020 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,7 @@ ## Changelog +**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) From cc7fd02fe1f07afeb7975a34d365c2f16a24418e Mon Sep 17 00:00:00 2001 From: Chris Talkington Date: Sun, 3 Sep 2023 16:05:00 -0500 Subject: [PATCH 4/4] bump version for release --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3269110b..badd0009 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "compress-commons", - "version": "5.0.0", + "version": "5.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": {