compressing 1.5.1 → 1.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/History.md CHANGED
@@ -1,4 +1,28 @@
1
1
 
2
+ 1.6.2 / 2022-07-11
3
+ ==================
4
+
5
+ **fixes**
6
+ * [[`96226d3`](http://github.com/node-modules/compressing/commit/96226d363c7c8fa9ef1a8098af646de19e729ce7)] - fix: add `suppressSizeWarning` to types and typo fix (#72) (Zeeko <<zeeko@zeeko.dev>>)
7
+
8
+ 1.6.1 / 2022-07-11
9
+ ==================
10
+
11
+ **fixes**
12
+ * [[`ba49232`](http://github.com/node-modules/compressing/commit/ba49232780a57c9a3800642d7d39ae1dcdfc9409)] - fix(types): onEntry stream type should ReadStream (#73) (Songhn <<songhn233@gmail.com>>)
13
+
14
+ **others**
15
+ * [[`054d4a4`](http://github.com/node-modules/compressing/commit/054d4a41ae4ca5d7b9b83e7298e32cc1d62d7ef4)] - 🤖 TEST: Use GitHub Action (#69) (fengmk2 <<fengmk2@gmail.com>>)
16
+
17
+ 1.6.0 / 2022-06-13
18
+ ==================
19
+
20
+ **features**
21
+ * [[`bd8ef44`](http://github.com/node-modules/compressing/commit/bd8ef44ade2f4b93d41ff2f78d6f17902d965798)] - feat: unzip should keep file mode (#68) (Artin <<lengthmin@gmail.com>>)
22
+
23
+ **others**
24
+ * [[`592e518`](http://github.com/node-modules/compressing/commit/592e5180dfbdbc6cb1becd1baf6a007ce7b7cd39)] - Create codeql-analysis.yml (fengmk2 <<fengmk2@gmail.com>>)
25
+
2
26
  1.5.1 / 2020-05-11
3
27
  ==================
4
28
 
package/README.md CHANGED
@@ -1,22 +1,13 @@
1
1
  # compressing
2
2
 
3
3
  [![NPM version][npm-image]][npm-url]
4
- [![build status][travis-image]][travis-url]
5
4
  [![Test coverage][codecov-image]][codecov-url]
6
- [![David deps][david-image]][david-url]
7
- [![Known Vulnerabilities][snyk-image]][snyk-url]
8
5
  [![npm download][download-image]][download-url]
9
6
 
10
7
  [npm-image]: https://img.shields.io/npm/v/compressing.svg?style=flat-square
11
8
  [npm-url]: https://npmjs.org/package/compressing
12
- [travis-image]: https://img.shields.io/travis/node-modules/compressing.svg?style=flat-square
13
- [travis-url]: https://travis-ci.org/node-modules/compressing
14
9
  [codecov-image]: https://codecov.io/gh/node-modules/compressing/branch/master/graph/badge.svg
15
10
  [codecov-url]: https://codecov.io/gh/node-modules/compressing
16
- [david-image]: https://img.shields.io/david/node-modules/compressing.svg?style=flat-square
17
- [david-url]: https://david-dm.org/node-modules/compressing
18
- [snyk-image]: https://snyk.io/test/npm/compressing/badge.svg?style=flat-square
19
- [snyk-url]: https://snyk.io/test/npm/compressing
20
11
  [download-image]: https://img.shields.io/npm/dm/compressing.svg?style=flat-square
21
12
  [download-url]: https://npmjs.org/package/compressing
22
13
 
@@ -88,7 +79,6 @@ const destStream = fs.createWriteStream('path/to/destination.gz');
88
79
  pump(sourceStream, gzipStream, destStream, handleError);
89
80
  ```
90
81
 
91
-
92
82
  ### Compress a dir
93
83
 
94
84
  Use tar as an example, tgz and zip is same as gzip.
@@ -167,8 +157,7 @@ compressing.tgz.uncompress(stream, 'path/to/destination/dir')
167
157
  .catch(handleError);
168
158
  ```
169
159
 
170
- **Note: tar, tgz and zip have the same uncompressing API as above: destination should be a path of a directory, while that of gzip is slightly different: destination must be a file or filestream.**
171
-
160
+ __Note: tar, tgz and zip have the same uncompressing API as above: destination should be a path of a directory, while that of gzip is slightly different: destination must be a file or filestream.__
172
161
 
173
162
  And working with urllib is super easy. Let's download a tgz file and uncompress to a directory:
174
163
 
@@ -280,7 +269,7 @@ Use this API to uncompress a file. This is a convenient method, which wraps Unco
280
269
  Params
281
270
 
282
271
  - source {String|Buffer|Stream} - source to be uncompressed
283
- - dest {String|Stream} - uncompressing destination. When uncompressing tar, tgz and zip, it should be a directory path (eg. `/path/to/xx`). **When uncompressing gzip, it should be a file path or a writable stream.**
272
+ - dest {String|Stream} - uncompressing destination. When uncompressing tar, tgz and zip, it should be a directory path (eg. `/path/to/xx`). __When uncompressing gzip, it should be a file path or a writable stream.__
284
273
  - opts {Object} - usually you don't need it
285
274
  - opts.zipFileNameEncoding {String} - Only work on zip format, default is 'utf8'.
286
275
  Major non-UTF8 encodings by languages:
@@ -374,4 +363,15 @@ Due to the design of the .zip file format, it's impossible to interpret a .zip f
374
363
 
375
364
  Although the API is streaming style(try to keep it handy), it still loads all data into memory.
376
365
 
377
- https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api
366
+ <https://github.com/thejoshwolfe/yauzl#no-streaming-unzip-api>
367
+ <!-- GITCONTRIBUTOR_START -->
368
+
369
+ ## Contributors
370
+
371
+ |[<img src="https://avatars.githubusercontent.com/u/456108?v=4" width="100px;"/><br/><sub><b>shaoshuai0102</b></sub>](https://github.com/shaoshuai0102)<br/>|[<img src="https://avatars.githubusercontent.com/u/156269?v=4" width="100px;"/><br/><sub><b>fengmk2</b></sub>](https://github.com/fengmk2)<br/>|[<img src="https://avatars.githubusercontent.com/u/360661?v=4" width="100px;"/><br/><sub><b>popomore</b></sub>](https://github.com/popomore)<br/>|[<img src="https://avatars.githubusercontent.com/u/9692408?v=4" width="100px;"/><br/><sub><b>DiamondYuan</b></sub>](https://github.com/DiamondYuan)<br/>|[<img src="https://avatars.githubusercontent.com/u/13938334?v=4" width="100px;"/><br/><sub><b>bytemain</b></sub>](https://github.com/bytemain)<br/>|[<img src="https://avatars.githubusercontent.com/u/8382136?v=4" width="100px;"/><br/><sub><b>Ryqsky</b></sub>](https://github.com/Ryqsky)<br/>|
372
+ | :---: | :---: | :---: | :---: | :---: | :---: |
373
+ [<img src="https://avatars.githubusercontent.com/u/47357585?v=4" width="100px;"/><br/><sub><b>songhn233</b></sub>](https://github.com/songhn233)<br/>|[<img src="https://avatars.githubusercontent.com/u/9857273?v=4" width="100px;"/><br/><sub><b>ShadyZOZ</b></sub>](https://github.com/ShadyZOZ)<br/>
374
+
375
+ This project follows the git-contributor [spec](https://github.com/xudafeng/git-contributor), auto updated at `Mon Jul 11 2022 08:28:25 GMT+0800`.
376
+
377
+ <!-- GITCONTRIBUTOR_END -->
package/index.d.ts CHANGED
@@ -8,6 +8,7 @@ interface streamEntryOpts {
8
8
  relativePath?: string
9
9
  ignoreBase?: boolean
10
10
  size?: number
11
+ suppressSizeWarning?: boolean
11
12
  }
12
13
 
13
14
  interface streamHeader {
@@ -15,6 +16,12 @@ interface streamHeader {
15
16
  name: string
16
17
  }
17
18
 
19
+ interface streamHeaderWithMode {
20
+ type: 'file' | 'directory',
21
+ name: string
22
+ mode: number
23
+ }
24
+
18
25
  export namespace gzip {
19
26
 
20
27
  function compressFile(source: sourceType, dest: destType, opts?: any): Promise<void>
@@ -79,7 +86,7 @@ export namespace tar {
79
86
  });
80
87
 
81
88
  on(event: string, listener: (...args: any[]) => void): this
82
- on(event: 'entry', listener: (header: streamHeader, stream: WriteStream, next: () => void) => void): this
89
+ on(event: 'entry', listener: (header: streamHeaderWithMode, stream: ReadStream, next: () => void) => void): this
83
90
  on(event: 'finish', listener: () => void): this
84
91
  on(event: 'error', listener: (err: Error) => void): this
85
92
 
@@ -124,7 +131,7 @@ export namespace tgz {
124
131
  });
125
132
 
126
133
  on(event: string, listener: (...args: any[]) => void): this
127
- on(event: 'entry', listener: (header: streamHeader, stream: WriteStream, next: () => void) => void): this
134
+ on(event: 'entry', listener: (header: streamHeaderWithMode, stream: ReadStream, next: () => void) => void): this
128
135
  on(event: 'finish', listener: () => void): this
129
136
  on(event: 'error', listener: (err: Error) => void): this
130
137
 
@@ -177,7 +184,7 @@ export namespace zip {
177
184
  });
178
185
 
179
186
  on(event: string, listener: (...args: any[]) => void): this
180
- on(event: 'entry', listener: (header: streamHeader, stream: WriteStream, next: () => void) => void): this
187
+ on(event: 'entry', listener: (header: streamHeaderWithMode, stream: ReadStream, next: () => void) => void): this
181
188
  on(event: 'finish', listener: () => void): this
182
189
  on(event: 'error', listener: (err: Error) => void): this
183
190
 
@@ -45,7 +45,7 @@ class TarFileStream extends stream.Transform {
45
45
  });
46
46
  } else {
47
47
  if (!opts.suppressSizeWarning) {
48
- console.warn('You should specify the size of streamming data by opts.size to prevent all streaming data from loading into memory. If you are sure about memory cost, pass opts.supressSizeWarning: true to suppress this warning');
48
+ console.warn('You should specify the size of streamming data by opts.size to prevent all streaming data from loading into memory. If you are sure about memory cost, pass opts.suppressSizeWarning: true to suppress this warning');
49
49
  }
50
50
  const buf = [];
51
51
  this.entry = new stream.Writable({
package/lib/tar/stream.js CHANGED
@@ -101,7 +101,7 @@ class TarStream extends BaseStream {
101
101
  entry.pipe(entryStream);
102
102
  } else {
103
103
  if (!opts.suppressSizeWarning) {
104
- console.warn('You should specify the size of streamming data by opts.size to prevent all streaming data from loading into memory. If you are sure about memory cost, pass opts.supressSizeWarning: true to suppress this warning');
104
+ console.warn('You should specify the size of streamming data by opts.size to prevent all streaming data from loading into memory. If you are sure about memory cost, pass opts.suppressSizeWarning: true to suppress this warning');
105
105
  }
106
106
  const buf = [];
107
107
  const collectStream = new stream.Writable({
@@ -18,6 +18,15 @@ const STRIP_NAME = Symbol('ZipUncompressStream#stripName');
18
18
  // - support "absolute path"
19
19
  const DEFAULTS = { lazyEntries: true, decodeStrings: false };
20
20
 
21
+ // from: https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/node/zip.ts#L51
22
+ function modeFromEntry(entry) {
23
+ const attr = entry.externalFileAttributes >> 16 || 33188;
24
+
25
+ return [ 448 /* S_IRWXU */, 56 /* S_IRWXG */, 7 /* S_IRWXO */ ]
26
+ .map(mask => attr & mask)
27
+ .reduce((a, b) => a + b, attr & 61440 /* S_IFMT */);
28
+ }
29
+
21
30
  class ZipUncompressStream extends UncompressBaseStream {
22
31
  constructor(opts) {
23
32
  opts = opts || {};
@@ -77,6 +86,7 @@ class ZipUncompressStream extends UncompressBaseStream {
77
86
 
78
87
  zipFile
79
88
  .on('entry', entry => {
89
+ const mode = modeFromEntry(entry);
80
90
  // fileName is buffer by default because decodeStrings = false
81
91
  if (Buffer.isBuffer(entry.fileName)) {
82
92
  if (this._zipFileNameEncoding === 'utf8') {
@@ -92,7 +102,7 @@ class ZipUncompressStream extends UncompressBaseStream {
92
102
  const type = /\/$/.test(entry.fileName) ? 'directory' : 'file';
93
103
  const name = entry.fileName = this[STRIP_NAME](entry.fileName, type);
94
104
 
95
- const header = { name, type, yauzl: entry };
105
+ const header = { name, type, yauzl: entry, mode };
96
106
 
97
107
  if (type === 'file') {
98
108
  zipFile.openReadStream(entry, (err, readStream) => {
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "compressing",
3
- "version": "1.5.1",
3
+ "version": "1.6.2",
4
4
  "description": "Everything you need for compressing and uncompressing",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
+ "contributor": "git-contributor",
7
8
  "ts-test": "tsc -p ./test/fixtures/types/tsconfig.json",
8
9
  "test": "egg-bin test && npm run ts-test",
9
10
  "cov": "egg-bin cov",
10
- "lint": "eslint .",
11
+ "lint": "eslint . --fix",
11
12
  "ci": "npm run lint && npm run ts-test && npm run cov"
12
13
  },
13
14
  "repository": {
@@ -52,9 +53,10 @@
52
53
  "@types/node": "^10.12.9",
53
54
  "dir-compare": "^1.3.0",
54
55
  "egg-bin": "^1.9.1",
55
- "egg-ci": "^1.8.0",
56
+ "egg-ci": "^2.1.0",
56
57
  "eslint": "^3.10.2",
57
58
  "eslint-config-egg": "^3.2.0",
59
+ "git-contributor": "^1.1.0",
58
60
  "mm": "^2.0.0",
59
61
  "mz-modules": "^2.1.0",
60
62
  "power-assert": "^1.4.2",
@@ -66,7 +68,8 @@
66
68
  "node": ">= 4.0.0"
67
69
  },
68
70
  "ci": {
69
- "version": "4, 6, 8, 10, 12",
71
+ "version": "10, 12, 14, 16, 18",
72
+ "os": "linux, macos",
70
73
  "license": {
71
74
  "year": "2017",
72
75
  "fullname": "node-modules and other contributors"