Skip to content

Commit

Permalink
esm: node v18+ required (#193)
Browse files Browse the repository at this point in the history
* conversion to esm

* Delete .github/workflows/npmpublish.yml.save
  • Loading branch information
ctalkington authored Oct 14, 2024
1 parent c903277 commit 6570975
Show file tree
Hide file tree
Showing 25 changed files with 1,542 additions and 3,086 deletions.
34 changes: 17 additions & 17 deletions .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ jobs:

strategy:
matrix:
node-version: [14.x, 16.x, 18.x, 20.x]
node-version: [18.x, 20.x]

steps:
- uses: actions/[email protected]
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
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@v4
with:
name: tmp-zip-node-v${{ matrix.node-version }}
path: tmp/*.zip
- uses: actions/[email protected]
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/[email protected]
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@v4
with:
name: tmp-zip-node-v${{ matrix.node-version }}
path: tmp/*.zip
4 changes: 2 additions & 2 deletions .github/workflows/npmpublish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: 16
node-version: 20
- run: npm ci
- run: npm test

Expand All @@ -22,7 +22,7 @@ jobs:
- uses: actions/[email protected]
- uses: actions/[email protected]
with:
node-version: 16
node-version: 20
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
Expand Down
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Ignore artifacts:
build
coverage
18 changes: 9 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,12 @@

**5.0.0** — <small>_September 2, 2023_</small> — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.2...5.0.0)


**4.1.2** — <small>_September 2, 2023_</small> — [Diff](https://github.com/archiverjs/node-compress-commons/compare/4.1.1...4.1.2)

**4.1.1** — <small>_May 30th, 2021_</small> — [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)
Expand All @@ -36,17 +36,17 @@

**4.0.1** — <small>_July 20, 2020_</small> — [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** — <small>_July 18, 2020_</small> — [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** — <small>_April 14, 2020_</small> — [Diff](https://github.com/archiverjs/node-compress-commons/compare/2.1.1...3.0.0)

Expand Down
14 changes: 7 additions & 7 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
- tests should be added to the nodeunit configs in `tests/`
- tests can be run with `npm test`
- see existing tests for guidance
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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/)&trade;.

Some logic derived from [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)&trade; and [OpenJDK 7](http://openjdk.java.net/).
Some logic derived from [Apache Commons Compress](http://commons.apache.org/proper/commons-compress/)&trade; and [OpenJDK 7](http://openjdk.java.net/).
22 changes: 6 additions & 16 deletions lib/archivers/archive-entry.js
Original file line number Diff line number Diff line change
@@ -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() {};
export default class ArchiveEntry {
getName() {}
getSize() {}
getLastModifiedDate() {}
isDirectory() {}
}
178 changes: 79 additions & 99 deletions lib/archivers/archive-output-stream.js
Original file line number Diff line number Diff line change
@@ -1,118 +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 isStream = require('is-stream');
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 (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);
};
}
Loading

0 comments on commit 6570975

Please sign in to comment.